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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
23
mod/item.php
23
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);
|
||||
|
||||
@@ -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' ",
|
||||
|
||||
@@ -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))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user