aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-11-20 00:15:48 -0800
committerredmatrix <redmatrix@redmatrix.me>2015-11-20 00:15:48 -0800
commit301072a86cacd2620a08cf07f2cef55dffac3c2f (patch)
treee6f64f9e95be882bdb7afeb4939dc485d38d3527 /mod
parenta44795e6c32d90d54e5a4321cad4ffe0f3409a09 (diff)
downloadvolse-hubzilla-301072a86cacd2620a08cf07f2cef55dffac3c2f.tar.gz
volse-hubzilla-301072a86cacd2620a08cf07f2cef55dffac3c2f.tar.bz2
volse-hubzilla-301072a86cacd2620a08cf07f2cef55dffac3c2f.zip
issue #85, community tags and file tags lost during edits. This required splitting off communitytags as a separate tag type and is not backward compatible. Community tags on older posts or those federated from redmatrix clones will not be preserved during edits.
Diffstat (limited to 'mod')
-rw-r--r--mod/channel.php2
-rw-r--r--mod/item.php23
-rw-r--r--mod/network.php4
-rw-r--r--mod/search.php3
-rw-r--r--mod/search_ac.php5
-rw-r--r--mod/tagger.php2
6 files changed, 32 insertions, 7 deletions
diff --git a/mod/channel.php b/mod/channel.php
index 0af2666cc..2b9d0ed89 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -189,7 +189,7 @@ function channel_content(&$a, $update = 0, $load = false) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
}
if(x($hashtags)) {
- $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG));
+ $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
if($datequery) {
diff --git a/mod/item.php b/mod/item.php
index 1e39ca9c9..34484eff7 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -651,6 +651,29 @@ function item_post(&$a) {
}
}
+ if($orig_post) {
+ // preserve original tags
+ $t = q("select * from term where oid = %d and otype = %d and uid = %d and type in ( %d, %d, %d )",
+ intval($orig_post['id']),
+ intval(TERM_OBJ_POST),
+ intval($profile_uid),
+ intval(TERM_UNKNOWN),
+ intval(TERM_FILE),
+ intval(TERM_COMMUNITYTAG)
+ );
+ if($t) {
+ foreach($t as $t1) {
+ $post_tags[] = array(
+ 'uid' => $profile_uid,
+ 'type' => $t1['type'],
+ 'otype' => TERM_OBJ_POST,
+ 'term' => $t1['term'],
+ 'url' => $t1['url'],
+ );
+ }
+ }
+ }
+
$item_unseen = ((local_channel() != $profile_uid) ? 1 : 0);
$item_wall = (($post_type === 'wall' || $post_type === 'wall-comment') ? 1 : 0);
diff --git a/mod/network.php b/mod/network.php
index 53de975a4..9f0604296 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -248,7 +248,7 @@ function network_content(&$a, $update = 0, $load = false) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
}
if(x($hashtags)) {
- $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG));
+ $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
if(! $update) {
@@ -313,7 +313,7 @@ function network_content(&$a, $update = 0, $load = false) {
if(x($_GET,'search')) {
$search = escape_tags($_GET['search']);
if(strpos($search,'#') === 0) {
- $sql_extra .= term_query('item',substr($search,1),TERM_HASHTAG);
+ $sql_extra .= term_query('item',substr($search,1),TERM_HASHTAG,TERM_COMMUNITYTAG);
}
else {
$sql_extra .= sprintf(" AND item.body like '%s' ",
diff --git a/mod/search.php b/mod/search.php
index a0085fca9..555d46f6a 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -75,9 +75,10 @@ function search_content(&$a,$update = 0, $load = false) {
return $o;
if($tag) {
- $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type = %d and term = '%s') ",
+ $sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type in ( %d , %d) and term = '%s') ",
intval(TERM_OBJ_POST),
intval(TERM_HASHTAG),
+ intval(TERM_COMMUNITYTAG),
dbesc(protect_sprintf($search))
);
}
diff --git a/mod/search_ac.php b/mod/search_ac.php
index e42945d43..19c1dc940 100644
--- a/mod/search_ac.php
+++ b/mod/search_ac.php
@@ -42,8 +42,9 @@ function search_ac_init(&$a){
}
}
- $r = q("select distinct term, tid, url from term where type = %d $tag_sql_extra group by term order by term asc",
- intval(TERM_HASHTAG)
+ $r = q("select distinct term, tid, url from term where type in ( %d, %d ) $tag_sql_extra group by term order by term asc",
+ intval(TERM_HASHTAG),
+ intval(TERM_COMMUNITYTAG)
);
if(count($r)) {
diff --git a/mod/tagger.php b/mod/tagger.php
index 9f9855ed8..27a8a15ea 100644
--- a/mod/tagger.php
+++ b/mod/tagger.php
@@ -123,7 +123,7 @@ function tagger_content(&$a) {
$arr['object'] = $obj;
$arr['parent_mid'] = $item['mid'];
- store_item_tag($item['uid'],$item['id'],TERM_OBJ_POST,TERM_HASHTAG,$term,$tagid);
+ store_item_tag($item['uid'],$item['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$term,$tagid);
$ret = post_activity_item($arr);
if($ret['success'])