aboutsummaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 'include')
-rw-r--r--include/conversation.php2
-rwxr-xr-xinclude/items.php21
-rw-r--r--include/taxonomy.php21
-rw-r--r--include/text.php2
-rw-r--r--include/zot.php3
5 files changed, 31 insertions, 18 deletions
diff --git a/include/conversation.php b/include/conversation.php
index 6cdbb878f..2c447acbc 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -674,7 +674,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
$unverified = '';
// $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))
// foreach($terms as $tag)
// $tags[] = format_term_for_display($tag);
diff --git a/include/items.php b/include/items.php
index 43bbdda28..7d349c631 100755
--- a/include/items.php
+++ b/include/items.php
@@ -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'] . '%'))
diff --git a/include/taxonomy.php b/include/taxonomy.php
index e68b9659f..b396d53f1 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -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 ) ",
- intval($type),
- protect_sprintf(dbesc($s))
- );
+ if($type2) {
+ 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 ) ",
+ 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) {
$s = '';
- if($term['type'] == TERM_HASHTAG)
+ if(($term['type'] == TERM_HASHTAG) || ($term['type'] == TERM_COMMUNITYTAG))
$s .= '#';
elseif($term['type'] == TERM_MENTION)
$s .= '@';
diff --git a/include/text.php b/include/text.php
index 4053c15b2..7c8834fc8 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1298,7 +1298,7 @@ function format_categories(&$item,$writeable) {
function format_hashtags(&$item) {
$s = '';
- $terms = get_terms_oftype($item['term'], TERM_HASHTAG);
+ $terms = get_terms_oftype($item['term'], array(TERM_HASHTAG,TERM_COMMUNITYTAG));
if($terms) {
foreach($terms as $t) {
$term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ;
diff --git a/include/zot.php b/include/zot.php
index 0a1a8ee51..23fb9c4ad 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1933,11 +1933,12 @@ function remove_community_tag($sender, $arr, $uid) {
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($r[0]['id']),
intval(TERM_OBJ_POST),
intval(TERM_HASHTAG),
+ intval(TERM_COMMUNITYTAG),
dbesc($i['object']['title']),
dbesc(get_rel_link($i['object']['link'],'alternate'))
);