From 6cafab10e6e168da73a9916c04e54fa43e2ae85b Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 3 Jun 2013 16:29:33 -0700 Subject: fix pager, doc update --- mod/directory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 21fb14bfc..7aeba3504 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -4,7 +4,7 @@ require_once('include/dir_fns.php'); function directory_init(&$a) { - $a->set_pager_itemspage(60); + $a->set_pager_itemspage(80); } @@ -66,7 +66,7 @@ function directory_content(&$a) { logger('mod_directory: query: ' . $query); $x = z_fetch_url($query); - logger('directory: return from upstream: ' . print_r($x,true)); + logger('directory: return from upstream: ' . print_r($x,true), LOGGER_DATA); if($x['success']) { $t = 0; -- cgit v1.2.3 From b866cc26fa95c6fc1df98bef2994350b9eb07231 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 3 Jun 2013 18:16:00 -0700 Subject: templatise alt_pager --- mod/directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 7aeba3504..46fc34e16 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -166,7 +166,7 @@ function directory_content(&$a) { )); - $o .= alt_pager($a,$j['records'], t('more'), t('back')); + $o .= alt_pager($a,$j['records'], t('next page'), t('previous page')); } else { -- cgit v1.2.3 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 From 8321a2e41a09ba77749b288cca003413fe6a9ebb Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 4 Jun 2013 20:07:13 -0700 Subject: tagging posts now sends out a presumably legal activity message - all that's missing is catching it on the post owner's side, checking if people can tag this stream, and then add the tag to the parent message. --- mod/tagger.php | 79 ++++++++++------------------------------------------------ 1 file changed, 13 insertions(+), 66 deletions(-) (limited to 'mod') diff --git a/mod/tagger.php b/mod/tagger.php index ba045cddc..28e10d131 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -23,7 +23,7 @@ function tagger_content(&$a) { logger('tagger: tag ' . $term . ' item ' . $item_id); - $r = q("SELECT * FROM `item` left join xchan on xchan_hash = author_hash WHERE `id` = '%s' and uid = %d LIMIT 1", + $r = q("SELECT * FROM item left join xchan on xchan_hash = author_xchan WHERE id = '%s' and uid = %d LIMIT 1", dbesc($item_id), intval(local_user()) ); @@ -79,9 +79,6 @@ function tagger_content(&$a) { - $mid = item_message_id(); - $xterm = xmlify($term); - $link = xmlify('' . "\n") ; @@ -102,18 +99,20 @@ function tagger_content(&$a) { $channel = $a->get_channel(); - $arr = array(); + $arr['owner_xchan'] = $item['owner_xchan']; + $arr['author_xchan'] = $channel['channel_hash']; - $arr['owner_hash'] = $item['owner_hash']; - $arr['author_hash'] = $channel['channel_hash']; -// FIXME - everything past this point is still unported + $arr['item_flags'] = ITEM_ORIGIN; + if($item['item_flags'] & ITEM_WALL) + $arr['item_flags'] |= ITEM_WALL; - $ulink = '[zrl=' . $contact['url'] . ']' . $contact['name'] . '[/zrl]'; - $alink = '[zrl=' . $item['author-link'] . ']' . $item['author-name'] . '[/zrl]'; + $ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]'; + $alink = '[zrl=' . $item['xchan_url'] . ']' . $item['xchan_name'] . '[/zrl]'; $plink = '[zrl=' . $item['plink'] . ']' . $post_type . '[/zrl]'; + $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink ); $arr['verb'] = ACTIVITY_TAG; @@ -121,65 +120,13 @@ function tagger_content(&$a) { $arr['target'] = $target; $arr['obj_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']; - $arr['deny_gid'] = $item['deny_gid']; - $arr['visible'] = 1; - $arr['unseen'] = 1; - $arr['origin'] = 1; - - $post_id = item_store($arr); - - 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", - 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']) ? ',' : '') . '#[zrl=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/zrl]'), - intval($item['id']) - ); - } + $arr['parent_mid'] = $item['mid']; - // if the original post is on this site, update it. + $ret = post_activity_item($arr); - $r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `mid` = '%s' LIMIT 1", - dbesc($item['mid']) - ); - if(count($r)) { - $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']) ? ',' : '') . '#[zrl=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/zrl]'), - intval($r[0]['id']) - ); - } - - } - - - $arr['id'] = $post_id; - - call_hooks('post_local_end', $arr); - - proc_run('php',"include/notifier.php","tag","$post_id"); + if($ret['success']) + proc_run('php','include/notifier.php','tag',$ret['activity']['id']); killme(); - return; // NOTREACHED - - } \ No newline at end of file -- cgit v1.2.3 From 2493770af9f5cbdbae1ca93488b27bb354842ea4 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Jun 2013 18:40:10 -0700 Subject: doh - would probably help to decode the data before trying to use it... --- mod/import.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index 9443f5c60..47c1ece7b 100644 --- a/mod/import.php +++ b/mod/import.php @@ -60,6 +60,7 @@ function import_post(&$a) { return; } + $data = json_decode($data,true); // logger('import: data: ' . print_r($data,true)); -- cgit v1.2.3 From e65449ee11a0f83bc57e8e028182672a2b4682a4 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Jun 2013 19:15:44 -0700 Subject: missing include, plus change to new red api path for basic export --- mod/import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index 47c1ece7b..0c91cf118 100644 --- a/mod/import.php +++ b/mod/import.php @@ -4,7 +4,7 @@ // connection to original server. require_once('include/Contact.php'); - +require_once('include/zot.php'); function import_post(&$a) { @@ -39,7 +39,7 @@ function import_post(&$a) { $servername = substr($old_address,strpos($old_address,'@')+1); $scheme = 'https://'; - $api_path = '/api/export/basic?f=&channel=' . $channelname; + $api_path = '/api/red/channel/export/basic?f=&channel=' . $channelname; $binary = false; $redirects = 0; $opts = array('http_auth' => $email . ':' . $password); -- cgit v1.2.3 From f18a909eefbc491bbdef68f0fc03d14af4b32191 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Jun 2013 19:35:04 -0700 Subject: set default channel to new import if a default channel wasn't already set --- mod/import.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/import.php b/mod/import.php index 0c91cf118..d1b3216d0 100644 --- a/mod/import.php +++ b/mod/import.php @@ -114,6 +114,8 @@ function import_post(&$a) { // reset $channel = $r[0]; + set_default_login_identity($a->get_account(),$channel['channel_id'],false); + if($data['photo']) { require_once('include/photo/photo_driver.php'); import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],get_account_id,$channel['channel_id']); -- cgit v1.2.3 From e0c6ee208297123ddc2aa37eadda69289230a01f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 5 Jun 2013 23:07:52 -0700 Subject: photo album listing widget broken --- mod/photos.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/photos.php b/mod/photos.php index 5b81e18a7..65bf866f1 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -650,10 +650,10 @@ function photos_content(&$a) { $albumselect .= ''; if(count($a->data['albums'])) { foreach($a->data['albums'] as $album) { - if(($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos'))) + if($album['text'] === '') continue; - $selected = (($selname === $album['album']) ? ' selected="selected" ' : ''); - $albumselect .= ''; + $selected = (($selname === $album['text']) ? ' selected="selected" ' : ''); + $albumselect .= ''; } } -- cgit v1.2.3