X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Ftagger.php;h=2c469a58bbf2571cf3924d3fb85ac495fb1bab69;hb=e803e56eea2790c8bf042ec44404ca73aaba9d93;hp=da4e74c61b2ecb0b12d9589ad4b907c25ab7ac80;hpb=31502207bd8361a5fa27cb10ea037e4cca5a5678;p=friendica.git diff --git a/mod/tagger.php b/mod/tagger.php index da4e74c61b..2c469a58bb 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -47,17 +47,9 @@ function tagger_content(&$a) { if(local_user() != $owner_uid) return; - if(remote_user()) { - $r = q("select * from contact where id = %d AND `uid` = %d limit 1", - intval(remote_user()), - intval($item['uid']) - ); - } - else { - $r = q("select * from contact where self = 1 and uid = %d limit 1", - intval(local_user()) - ); - } + $r = q("select * from contact where self = 1 and uid = %d limit 1", + intval(local_user()) + ); if(count($r)) $contact = $r[0]; else { @@ -66,14 +58,14 @@ function tagger_content(&$a) { } $uri = item_new_uri($a->get_hostname(),$owner_uid); - + $xterm = xmlify($term); $post_type = (($item['resource-id']) ? t('photo') : t('status')); - $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); + $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); - $link = xmlify('' . "\n") ; - $body = $item['body']; + $body = xmlify($item['body']); $target = <<< EOT @@ -86,7 +78,7 @@ function tagger_content(&$a) { EOT; - $tagid = $a->get_baseurl() . '/search?search=' . $term; + $tagid = $a->get_baseurl() . '/search?tag=' . $term; $objtype = ACTIVITY_OBJ_TAGTERM; $obj = <<< EOT @@ -95,8 +87,8 @@ EOT; 1 $tagid $tagid - $term - $term + $xterm + $xterm EOT; @@ -105,7 +97,7 @@ EOT; if(! isset($bodyverb)) return; - $termlink = '#[url=' . $a->get_baseurl() . '/search?search=' . urlencode($term) . ']'. $term . '[/url]'; + $termlink = html_entity_decode('⌗') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; $arr = array(); @@ -134,6 +126,7 @@ EOT; $arr['target'] = $target; $arr['object-type'] = $objtype; $arr['object'] = $obj; + $arr['private'] = $item['private']; $arr['allow_cid'] = $item['allow_cid']; $arr['allow_gid'] = $item['allow_gid']; $arr['deny_cid'] = $item['deny_cid']; @@ -143,25 +136,39 @@ EOT; $arr['last-child'] = 1; $arr['origin'] = 1; - $post_id = item_store($arr); + $post_id = item_store($arr); + +// q("UPDATE `item` set plink = '%s' where id = %d", +// dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id), +// intval($post_id) +// ); - q("UPDATE `item` set plink = '%s' where id = %d limit 1", - dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id), - intval($post_id) - ); - if(! $item['visible']) { - $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", intval($item['id']), intval($owner_uid) ); - } + } - if((! $blocktags) && (! stristr($item['tag'], ']' . $term . '[' ))) { - q("update item set tag = '%s' where id = %d limit 1", - dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'), + $term_objtype = (($item['resource-id']) ? TERM_OBJ_PHOTO : TERM_OBJ_POST ); + $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'", + intval($item['id']), + dbesc($term) + ); + if((! $blocktags) && $t[0]['tcount']==0 ) { + /*q("update item set tag = '%s' where id = %d", + dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), intval($item['id']) + );*/ + + q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)", + intval($item['id']), + $term_objtype, + TERM_HASHTAG, + dbesc($term), + dbesc($a->get_baseurl() . '/search?tag=' . $term), + intval($owner_uid) ); } @@ -174,15 +181,30 @@ EOT; $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1", intval($r[0]['uid']) ); - if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { - q("update item set tag = '%s' where id = %d limit 1", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'), + $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'", + intval($r[0]['id']), + dbesc($term) + ); + if(count($x) && !$x[0]['blocktags'] && $t[0]['tcount']==0){ + q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)", + intval($r[0]['id']), + $term_objtype, + TERM_HASHTAG, + dbesc($term), + dbesc($a->get_baseurl() . '/search?tag=' . $term), + intval($owner_uid) + ); + } + + /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { + q("update item set tag = '%s' where id = %d", + dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), intval($r[0]['id']) ); - } + }*/ } - + $arr['id'] = $post_id; @@ -195,4 +217,4 @@ EOT; return; // NOTREACHED -} \ No newline at end of file +}