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:
parent
a44795e6c3
commit
301072a86c
1
boot.php
1
boot.php
@ -423,6 +423,7 @@ define ( 'TERM_SAVEDSEARCH', 6 );
|
|||||||
define ( 'TERM_THING', 7 );
|
define ( 'TERM_THING', 7 );
|
||||||
define ( 'TERM_BOOKMARK', 8 );
|
define ( 'TERM_BOOKMARK', 8 );
|
||||||
define ( 'TERM_HIERARCHY', 9 );
|
define ( 'TERM_HIERARCHY', 9 );
|
||||||
|
define ( 'TERM_COMMUNITYTAG', 10 );
|
||||||
|
|
||||||
define ( 'TERM_OBJ_POST', 1 );
|
define ( 'TERM_OBJ_POST', 1 );
|
||||||
define ( 'TERM_OBJ_PHOTO', 2 );
|
define ( 'TERM_OBJ_PHOTO', 2 );
|
||||||
|
@ -674,7 +674,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||||||
$unverified = '';
|
$unverified = '';
|
||||||
|
|
||||||
// $tags=array();
|
// $tags=array();
|
||||||
// $terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN));
|
// $terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN,TERM_COMMUNITYTAG));
|
||||||
// if(count($terms))
|
// if(count($terms))
|
||||||
// foreach($terms as $tag)
|
// foreach($terms as $tag)
|
||||||
// $tags[] = format_term_for_display($tag);
|
// $tags[] = format_term_for_display($tag);
|
||||||
|
@ -1408,7 +1408,7 @@ function encode_item_xchan($xchan) {
|
|||||||
function encode_item_terms($terms,$mirror = false) {
|
function encode_item_terms($terms,$mirror = false) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
$allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK );
|
$allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK, TERM_COMMUNITYTAG );
|
||||||
|
|
||||||
if($mirror) {
|
if($mirror) {
|
||||||
$allowed_export_terms[] = TERM_PCATEGORY;
|
$allowed_export_terms[] = TERM_PCATEGORY;
|
||||||
@ -1432,7 +1432,7 @@ function encode_item_terms($terms,$mirror = false) {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function termtype($t) {
|
function termtype($t) {
|
||||||
$types = array('unknown','hashtag','mention','category','private_category','file','search','thing','bookmark');
|
$types = array('unknown','hashtag','mention','category','private_category','file','search','thing','bookmark', 'hierarchy', 'communitytag');
|
||||||
|
|
||||||
return(($types[$t]) ? $types[$t] : 'unknown');
|
return(($types[$t]) ? $types[$t] : 'unknown');
|
||||||
}
|
}
|
||||||
@ -1478,6 +1478,9 @@ function decode_tags($t) {
|
|||||||
case 'bookmark':
|
case 'bookmark':
|
||||||
$tag['type'] = TERM_BOOKMARK;
|
$tag['type'] = TERM_BOOKMARK;
|
||||||
break;
|
break;
|
||||||
|
case 'communitytag':
|
||||||
|
$tag['type'] = TERM_COMMUNITYTAG;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
case 'unknown':
|
case 'unknown':
|
||||||
$tag['type'] = TERM_UNKNOWN;
|
$tag['type'] = TERM_UNKNOWN;
|
||||||
@ -3032,7 +3035,7 @@ function tag_deliver($uid, $item_id) {
|
|||||||
if(is_array($j_obj['link']))
|
if(is_array($j_obj['link']))
|
||||||
$taglink = get_rel_link($j_obj['link'],'alternate');
|
$taglink = get_rel_link($j_obj['link'],'alternate');
|
||||||
|
|
||||||
store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_HASHTAG,$j_obj['title'],$j_obj['id']);
|
store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']);
|
||||||
$x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d",
|
$x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
@ -3437,7 +3440,7 @@ function check_item_source($uid, $item) {
|
|||||||
foreach($words as $word) {
|
foreach($words as $word) {
|
||||||
if(substr($word,0,1) === '#' && $tags) {
|
if(substr($word,0,1) === '#' && $tags) {
|
||||||
foreach($tags as $t)
|
foreach($tags as $t)
|
||||||
if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
|
if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
||||||
@ -3490,7 +3493,7 @@ function post_is_importable($item,$abook) {
|
|||||||
continue;
|
continue;
|
||||||
if(substr($word,0,1) === '#' && $tags) {
|
if(substr($word,0,1) === '#' && $tags) {
|
||||||
foreach($tags as $t)
|
foreach($tags as $t)
|
||||||
if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
|
if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
||||||
@ -3511,7 +3514,7 @@ function post_is_importable($item,$abook) {
|
|||||||
continue;
|
continue;
|
||||||
if(substr($word,0,1) === '#' && $tags) {
|
if(substr($word,0,1) === '#' && $tags) {
|
||||||
foreach($tags as $t)
|
foreach($tags as $t)
|
||||||
if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
|
if((($t['type'] == TERM_HASHTAG) || ($t['type'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
||||||
@ -4162,12 +4165,12 @@ function enumerate_permissions($obj) {
|
|||||||
|
|
||||||
function item_getfeedtags($item) {
|
function item_getfeedtags($item) {
|
||||||
|
|
||||||
$terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION));
|
$terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_COMMUNITYTAG));
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
if(count($terms)) {
|
if(count($terms)) {
|
||||||
foreach($terms as $term) {
|
foreach($terms as $term) {
|
||||||
if($term['type'] == TERM_HASHTAG)
|
if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG))
|
||||||
$ret[] = array('#',$term['url'],$term['term']);
|
$ret[] = array('#',$term['url'],$term['term']);
|
||||||
else
|
else
|
||||||
$ret[] = array('@',$term['url'],$term['term']);
|
$ret[] = array('@',$term['url'],$term['term']);
|
||||||
@ -4875,7 +4878,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
|
|||||||
if($arr['search']) {
|
if($arr['search']) {
|
||||||
|
|
||||||
if(strpos($arr['search'],'#') === 0)
|
if(strpos($arr['search'],'#') === 0)
|
||||||
$sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG);
|
$sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG,TERM_COMMUNITYTAG);
|
||||||
else
|
else
|
||||||
$sql_extra .= sprintf(" AND item.body like '%s' ",
|
$sql_extra .= sprintf(" AND item.body like '%s' ",
|
||||||
dbesc(protect_sprintf('%' . $arr['search'] . '%'))
|
dbesc(protect_sprintf('%' . $arr['search'] . '%'))
|
||||||
|
@ -26,12 +26,21 @@ function file_tag_file_query($table,$s,$type = 'file') {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function term_query($table,$s,$type = TERM_UNKNOWN) {
|
function term_query($table,$s,$type = TERM_UNKNOWN, $type2 = '') {
|
||||||
|
|
||||||
return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ",
|
if($type2) {
|
||||||
intval($type),
|
return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type in (%d, %d) and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ",
|
||||||
protect_sprintf(dbesc($s))
|
intval($type),
|
||||||
);
|
intval($type2),
|
||||||
|
protect_sprintf(dbesc($s))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ",
|
||||||
|
intval($type),
|
||||||
|
protect_sprintf(dbesc($s))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +93,7 @@ function get_terms_oftype($arr,$type) {
|
|||||||
|
|
||||||
function format_term_for_display($term) {
|
function format_term_for_display($term) {
|
||||||
$s = '';
|
$s = '';
|
||||||
if($term['type'] == TERM_HASHTAG)
|
if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG))
|
||||||
$s .= '#';
|
$s .= '#';
|
||||||
elseif($term['type'] == TERM_MENTION)
|
elseif($term['type'] == TERM_MENTION)
|
||||||
$s .= '@';
|
$s .= '@';
|
||||||
|
@ -1298,7 +1298,7 @@ function format_categories(&$item,$writeable) {
|
|||||||
function format_hashtags(&$item) {
|
function format_hashtags(&$item) {
|
||||||
$s = '';
|
$s = '';
|
||||||
|
|
||||||
$terms = get_terms_oftype($item['term'], TERM_HASHTAG);
|
$terms = get_terms_oftype($item['term'], array(TERM_HASHTAG,TERM_COMMUNITYTAG));
|
||||||
if($terms) {
|
if($terms) {
|
||||||
foreach($terms as $t) {
|
foreach($terms as $t) {
|
||||||
$term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ;
|
$term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ;
|
||||||
|
@ -1933,11 +1933,12 @@ function remove_community_tag($sender, $arr, $uid) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q("delete from term where uid = %d and oid = %d and otype = %d and type = %d and term = '%s' and url = '%s'",
|
q("delete from term where uid = %d and oid = %d and otype = %d and type in ( %d, %d ) and term = '%s' and url = '%s'",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
intval($r[0]['id']),
|
intval($r[0]['id']),
|
||||||
intval(TERM_OBJ_POST),
|
intval(TERM_OBJ_POST),
|
||||||
intval(TERM_HASHTAG),
|
intval(TERM_HASHTAG),
|
||||||
|
intval(TERM_COMMUNITYTAG),
|
||||||
dbesc($i['object']['title']),
|
dbesc($i['object']['title']),
|
||||||
dbesc(get_rel_link($i['object']['link'],'alternate'))
|
dbesc(get_rel_link($i['object']['link'],'alternate'))
|
||||||
);
|
);
|
||||||
|
@ -189,7 +189,7 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
|
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
|
||||||
}
|
}
|
||||||
if(x($hashtags)) {
|
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) {
|
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_unseen = ((local_channel() != $profile_uid) ? 1 : 0);
|
||||||
$item_wall = (($post_type === 'wall' || $post_type === 'wall-comment') ? 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));
|
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
|
||||||
}
|
}
|
||||||
if(x($hashtags)) {
|
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) {
|
if(! $update) {
|
||||||
@ -313,7 +313,7 @@ function network_content(&$a, $update = 0, $load = false) {
|
|||||||
if(x($_GET,'search')) {
|
if(x($_GET,'search')) {
|
||||||
$search = escape_tags($_GET['search']);
|
$search = escape_tags($_GET['search']);
|
||||||
if(strpos($search,'#') === 0) {
|
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 {
|
else {
|
||||||
$sql_extra .= sprintf(" AND item.body like '%s' ",
|
$sql_extra .= sprintf(" AND item.body like '%s' ",
|
||||||
|
@ -75,9 +75,10 @@ function search_content(&$a,$update = 0, $load = false) {
|
|||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
if($tag) {
|
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_OBJ_POST),
|
||||||
intval(TERM_HASHTAG),
|
intval(TERM_HASHTAG),
|
||||||
|
intval(TERM_COMMUNITYTAG),
|
||||||
dbesc(protect_sprintf($search))
|
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",
|
$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_HASHTAG),
|
||||||
|
intval(TERM_COMMUNITYTAG)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
|
@ -123,7 +123,7 @@ function tagger_content(&$a) {
|
|||||||
$arr['object'] = $obj;
|
$arr['object'] = $obj;
|
||||||
$arr['parent_mid'] = $item['mid'];
|
$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);
|
$ret = post_activity_item($arr);
|
||||||
|
|
||||||
if($ret['success'])
|
if($ret['success'])
|
||||||
|
3725
util/hmessages.po
3725
util/hmessages.po
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
2015-11-19.1221
|
2015-11-20.1222
|
||||||
|
Reference in New Issue
Block a user