From 9f15600c7c426c4f557809ed2036802381e5bf12 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Jun 2013 01:27:50 -0700 Subject: community tagging - it's not much closer to working but a really good developer can now possibly hack their way through it instead of "there's only one person on the planet that can ever make this work". --- mod/settings.php | 4 +- mod/tagger.php | 119 ++++++++++++++++++++++++++----------------------------- 2 files changed, 60 insertions(+), 63 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 5ee6b5d15..f417586af 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -456,6 +456,7 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','post_newfriend', $post_newfriend); set_pconfig(local_user(),'system','post_joingroup', $post_joingroup); set_pconfig(local_user(),'system','post_profilechange', $post_profilechange); + set_pconfig(local_user(),'system','blocktags',$blocktags); /* if($page_flags == PAGE_PRVGROUP) { @@ -907,7 +908,6 @@ function settings_content(&$a) { $expire = $channel['channel_expire_days']; $blockwall = $a->user['blockwall']; - $blocktags = $a->user['blocktags']; $unkmail = $a->user['unkmail']; $cntunkmail = $a->user['cntunkmail']; @@ -939,6 +939,8 @@ function settings_content(&$a) { $post_profilechange = get_pconfig(local_user(), 'system','post_profilechange'); $post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0 + $blocktags = get_pconfig(local_user(),'system','blocktags'); + $blocktags = (($blocktags===false) ? '0' : $blocktags); $timezone = date_default_timezone_get(); diff --git a/mod/tagger.php b/mod/tagger.php index b8e90e2fd..ba045cddc 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -23,11 +23,12 @@ function tagger_content(&$a) { logger('tagger: tag ' . $term . ' item ' . $item_id); - $r = q("SELECT * FROM `item` WHERE `id` = '%s' LIMIT 1", - dbesc($item_id) + $r = q("SELECT * FROM `item` left join xchan on xchan_hash = author_hash WHERE `id` = '%s' and uid = %d LIMIT 1", + dbesc($item_id), + intval(local_user()) ); - if(! $item_id || (! count($r))) { + if((! $item_id) || (! $r)) { logger('tagger: no item ' . $item_id); return; } @@ -36,85 +37,79 @@ function tagger_content(&$a) { $owner_uid = $item['uid']; - $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1", - intval($owner_uid) - ); - if(count($r)) { - $owner_nick = $r[0]['nickname']; - $blocktags = $r[0]['blocktags']; + switch($item['resource_type']) { + case 'photo': + $targettype = ACTIVITY_OBJ_PHOTO; + $post_type = t('photo'); + break; + case 'event': + $targgettype = ACTIVITY_OBJ_EVENT; + $post_type = t('event'); + break; + default: + $targettype = ACTIVITY_OBJ_NOTE; + $post_type = t('status'); + if($item['mid'] != $item['parent_mid']) + $post_type = t('comment'); + break; } - if(local_user() != $owner_uid) - return; - $r = q("select * from contact where self = 1 and uid = %d limit 1", - intval(local_user()) - ); - if(count($r)) - $contact = $r[0]; - else { - logger('tagger: no contact_id'); - return; - } + $links = array(array('rel' => 'alternate','type' => 'text/html', + 'href' => z_root() . '/display/' . $item['mid'])); + + $target = json_encode(array( + 'type' => $targettype, + 'id' => $item['mid'], + 'link' => $links, + 'title' => $item['title'], + 'content' => $item['body'], + 'created' => $item['created'], + 'edited' => $item['edited'], + 'author' => array( + 'name' => $item['xchan_name'], + 'address' => $item['xchan_addr'], + 'guid' => $item['xchan_guid'], + 'guid_sig' => $item['xchan_guid_sig'], + 'link' => array( + array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item['xchan_url']), + array('rel' => 'photo', 'type' => $item['xchan_photo_mimetype'], 'href' => $item['xchan_photo_m'])), + ), + )); + + $mid = item_message_id(); $xterm = xmlify($term); - $post_type = (($item['resource_id']) ? t('photo') : t('status')); - $targettype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); $link = xmlify('' . "\n") ; - $body = xmlify($item['body']); - - $target = <<< EOT - - $targettype - 1 - {$item['mid']} - $link - - $body - -EOT; - $tagid = $a->get_baseurl() . '/search?tag=' . $term; $objtype = ACTIVITY_OBJ_TAGTERM; - $obj = <<< EOT - - $objtype - 1 - $tagid - $tagid - $xterm - $xterm - -EOT; + $obj = json_encode(array( + 'type' => $objtype, + 'id' => $tagid, + 'link' => array(array('rel' => 'alternate','type' => 'text/html', 'href' => $tagid)), + 'title' => $term, + 'content' => $term + )); $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); - if(! isset($bodyverb)) - return; - $termlink = html_entity_decode('⌗') . '[zrl=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/zrl]'; + $channel = $a->get_channel(); + + $arr = array(); - $arr['mid'] = $mid; - $arr['uid'] = $owner_uid; - $arr['contact-id'] = $contact['id']; - $arr['type'] = 'activity'; - $arr['wall'] = $item['wall']; - $arr['gravity'] = GRAVITY_COMMENT; - $arr['parent'] = $item['id']; - $arr['parent_mid'] = $item['mid']; - $arr['owner-name'] = $item['author-name']; - $arr['owner-link'] = $item['author-link']; - $arr['owner-avatar'] = $item['author-avatar']; - $arr['author-name'] = $contact['name']; - $arr['author-link'] = $contact['url']; - $arr['author-avatar'] = $contact['thumb']; + + $arr['owner_hash'] = $item['owner_hash']; + $arr['author_hash'] = $channel['channel_hash']; + +// FIXME - everything past this point is still unported $ulink = '[zrl=' . $contact['url'] . ']' . $contact['name'] . '[/zrl]'; $alink = '[zrl=' . $item['author-link'] . ']' . $item['author-name'] . '[/zrl]'; -- cgit v1.2.3