This should get community tagging pretty close to working - deleting a community tag is left as a FIXME
This commit is contained in:
		| @@ -1915,7 +1915,9 @@ function get_item_contact($item,$contacts) { | ||||
|  | ||||
| function tag_deliver($uid,$item_id) { | ||||
|  | ||||
| 	// look for mention tags and setup a second delivery chain for forum/community posts if appropriate | ||||
| 	// Called when we deliver things that might be tagged in ways that require delivery processing. | ||||
| 	// Handles community tagging of posts and also look for mention tags  | ||||
| 	// and sets up a second delivery chain if appropriate | ||||
|  | ||||
| 	$a = get_app(); | ||||
|  | ||||
| @@ -1931,13 +1933,41 @@ function tag_deliver($uid,$item_id) { | ||||
| 		intval($item_id), | ||||
| 		intval($uid) | ||||
| 	); | ||||
| 	if(! count($i)) | ||||
| 	if(! $i) | ||||
| 		return; | ||||
|  | ||||
| 	$i = fetch_post_tags($i); | ||||
|  | ||||
| 	$item = $i[0]; | ||||
|  | ||||
|  | ||||
| 	if($item['obj_type'] === ACTIVITY_OBJ_TAGTERM) { | ||||
|  | ||||
| 		// We received a community tag activity for a post. | ||||
| 		// See if we are the owner of the parent item and have given permission to tag our posts. | ||||
| 		// If so tag the parent post. | ||||
|   | ||||
| 		// FIXME --- If the item is deleted, remove the tag from the parent. | ||||
| 		// (First ensure that deleted items use this function, or else do that part separately.) | ||||
|  | ||||
| 		if(($item['owner_xchan'] === $u[0]['channel_hash']) && (! get_pconfig($u[0]['channel_id'],'system','blocktags'))) { | ||||
| 			$j_tgt = json_decode($item['target'],true); | ||||
| 			if($j_tgt && $j_tgt['mid']) { | ||||
| 				$p = q("select * from item where mid = '%s' and uid = %d limit 1", | ||||
| 					dbesc($j_tgt['mid']), | ||||
| 					intval($u[0]['channel_id']) | ||||
| 				); | ||||
| 				if($p) { | ||||
| 					$j_obj = json_decode($item['object'],true); | ||||
| 					if($j_obj && $j_obj['id'] && $j_obj['title']) { | ||||
| 						store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_HASHTAG,$j_obj['title'],$j['obj']['id']); | ||||
| 						proc_run('php','include/notifier.php','edit_post',$p[0]['id']); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$terms = get_terms_oftype($item['term'],TERM_MENTION); | ||||
|  | ||||
| 	logger('tag_deliver: post mentions: ' . print_r($terms,true), LOGGER_DATA); | ||||
|   | ||||
| @@ -1594,7 +1594,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') { | ||||
| 		dbesc($term), | ||||
| 		dbesc($url) | ||||
| 	); | ||||
| 	if(count($r)) | ||||
| 	if($r) | ||||
| 		return false; | ||||
| 	$r = q("insert into term (uid, oid, otype, type, term, url) | ||||
| 		values( %d, %d, %d, %d, '%s', '%s') ", | ||||
| @@ -1646,7 +1646,7 @@ function file_tag_save_file($uid,$item,$file) { | ||||
| 		intval($item), | ||||
| 		intval($uid) | ||||
| 	); | ||||
| 	if(count($r)) { | ||||
| 	if($r) { | ||||
| 		if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']')) | ||||
| 			q("update item set file = '%s' where id = %d and uid = %d limit 1", | ||||
| 				dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'), | ||||
| @@ -1676,7 +1676,7 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) { | ||||
| 		intval($item), | ||||
| 		intval($uid) | ||||
| 	); | ||||
| 	if(! count($r)) | ||||
| 	if(! $r) | ||||
| 		return false; | ||||
|  | ||||
| 	q("update item set file = '%s' where id = %d and uid = %d limit 1", | ||||
| @@ -1689,7 +1689,7 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) { | ||||
| 		intval($uid) | ||||
| 	); | ||||
|  | ||||
| 	if(! count($r)) { | ||||
| 	if(! $r) { | ||||
| 		$saved = get_pconfig($uid,'system','filetags'); | ||||
| 		set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved)); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user