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:
@@ -1408,7 +1408,7 @@ function encode_item_xchan($xchan) {
|
||||
function encode_item_terms($terms,$mirror = false) {
|
||||
$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) {
|
||||
$allowed_export_terms[] = TERM_PCATEGORY;
|
||||
@@ -1432,7 +1432,7 @@ function encode_item_terms($terms,$mirror = false) {
|
||||
* @return string
|
||||
*/
|
||||
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');
|
||||
}
|
||||
@@ -1478,6 +1478,9 @@ function decode_tags($t) {
|
||||
case 'bookmark':
|
||||
$tag['type'] = TERM_BOOKMARK;
|
||||
break;
|
||||
case 'communitytag':
|
||||
$tag['type'] = TERM_COMMUNITYTAG;
|
||||
break;
|
||||
default:
|
||||
case 'unknown':
|
||||
$tag['type'] = TERM_UNKNOWN;
|
||||
@@ -3032,7 +3035,7 @@ function tag_deliver($uid, $item_id) {
|
||||
if(is_array($j_obj['link']))
|
||||
$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",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
@@ -3437,7 +3440,7 @@ function check_item_source($uid, $item) {
|
||||
foreach($words as $word) {
|
||||
if(substr($word,0,1) === '#' && $tags) {
|
||||
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;
|
||||
}
|
||||
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
||||
@@ -3490,7 +3493,7 @@ function post_is_importable($item,$abook) {
|
||||
continue;
|
||||
if(substr($word,0,1) === '#' && $tags) {
|
||||
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;
|
||||
}
|
||||
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
||||
@@ -3511,7 +3514,7 @@ function post_is_importable($item,$abook) {
|
||||
continue;
|
||||
if(substr($word,0,1) === '#' && $tags) {
|
||||
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;
|
||||
}
|
||||
elseif((strpos($word,'/') === 0) && preg_match($word,$text))
|
||||
@@ -4162,12 +4165,12 @@ function enumerate_permissions($obj) {
|
||||
|
||||
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();
|
||||
|
||||
if(count($terms)) {
|
||||
foreach($terms as $term) {
|
||||
if($term['type'] == TERM_HASHTAG)
|
||||
if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG))
|
||||
$ret[] = array('#',$term['url'],$term['term']);
|
||||
else
|
||||
$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(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
|
||||
$sql_extra .= sprintf(" AND item.body like '%s' ",
|
||||
dbesc(protect_sprintf('%' . $arr['search'] . '%'))
|
||||
|
||||
Reference in New Issue
Block a user