From 531710142c271bc4002e16345d3ccd5d3f1c83e2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 23 Mar 2016 20:04:09 -0700 Subject: add hook to allow plugins to perform a follow activity from an activityfeed --- include/items.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 879f8ea12..2884d8e52 100755 --- a/include/items.php +++ b/include/items.php @@ -3848,8 +3848,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray = get_atom_elements($feed,$item,$author); if($contact['xchan_network'] === 'rss') { - $res['public_policy'] = 'specific'; - $res['comment_policy'] = 'none'; + $datarray['public_policy'] = 'specific'; + $datarray['comment_policy'] = 'none'; } if((! x($author,'author_name')) || ($author['author_is_feed'])) @@ -3911,8 +3911,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray = get_atom_elements($feed,$item,$author); if($contact['xchan_network'] === 'rss') { - $res['public_policy'] = 'specific'; - $res['comment_policy'] = 'none'; + $datarray['public_policy'] = 'specific'; + $datarray['comment_policy'] = 'none'; } @@ -3932,6 +3932,16 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray['author_xchan'] = ''; + if(activity_match($datarray['verb'],ACTIVITY_FOLLOW) && $datarray['obj_type'] === ACTIVITY_OBJ_PERSON) { + $cb = array('item' => $datarray,'channel' => $importer, 'xchan' => null, 'author' => $author, 'caught' => false); + call_hooks('follow_from_feed',$cb); + if($cb['caught']) { + if($cb['return_code']) + http_status_exit($cb['return_code']); + continue; + } + } + if($author['author_link'] != $contact['xchan_url']) { $x = import_author_unknown(array('name' => $author['author_name'],'url' => $author['author_link'],'photo' => array('src' => $author['author_photo']))); if($x) -- cgit v1.2.3 From 1cd3b4182595b838a535dd6b6990251db05d49e6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 30 Mar 2016 22:13:24 -0700 Subject: deprecate $a->get_baseurl() --- include/items.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 2884d8e52..18e777a7f 100755 --- a/include/items.php +++ b/include/items.php @@ -2966,7 +2966,7 @@ function send_status_notifications($post_id,$item) { if($unfollowed) return; - $link = get_app()->get_baseurl() . '/display/' . $item['mid']; + $link = z_root() . '/display/' . $item['mid']; $y = q("select id from notify where link = '%s' and uid = %d limit 1", dbesc($link), @@ -4297,7 +4297,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) { $a = get_app(); logger('fix_private_photos', LOGGER_DEBUG); - $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')); + $site = substr(z_root(),strpos(z_root(),'://')); $orig_body = $s; $new_body = ''; @@ -4589,7 +4589,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if(! $interactive) return 0; notice( t('Item not found.') . EOL); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/' . $_SESSION['return_url']); } $item = $r[0]; @@ -4662,13 +4662,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) proc_run('php','include/notifier.php','drop',$notify_id); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/' . $_SESSION['return_url']); } else { if(! $interactive) return 0; notice( t('Permission denied.') . EOL); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/' . $_SESSION['return_url']); } } -- cgit v1.2.3 From 9abd95fad3784a10fc48bc40f9b8a75d7d74edda Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 31 Mar 2016 16:06:03 -0700 Subject: static App --- include/items.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 18e777a7f..09479e428 100755 --- a/include/items.php +++ b/include/items.php @@ -274,7 +274,7 @@ function can_comment_on_post($observer_xchan, $item) { return true; if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'diaspora')) return true; - if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],get_app()->get_hostname())) + if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],App::get_hostname())) return true; return false; @@ -413,8 +413,8 @@ function post_activity_item($arr) { if(! array_key_exists('item_thread_top',$arr) && (! $is_comment)) $arr['item_thread_top'] = 1; - $channel = get_app()->get_channel(); - $observer = get_app()->get_observer(); + $channel = App::get_channel(); + $observer = App::get_observer(); $arr['aid'] = ((x($arr,'aid')) ? $arr['aid'] : $channel['channel_account_id']); $arr['uid'] = ((x($arr,'uid')) ? $arr['uid'] : $channel['channel_id']); @@ -602,7 +602,7 @@ function get_feed_for($channel, $observer_hash, $params) { 'order' => 'post', 'top' => $params['top'], 'cat' => $params['cat'] - ), $channel, $observer_hash, CLIENT_MODE_NORMAL, get_app()->module); + ), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module); $feed_template = get_markup_template('atom_feed.tpl'); @@ -1362,7 +1362,7 @@ function map_scope($scope, $strip = false) { case PERMS_AUTHED: return 'authenticated'; case PERMS_SITE: - return 'site: ' . get_app()->get_hostname(); + return 'site: ' . App::get_hostname(); case PERMS_PENDING: return 'any connections'; case PERMS_CONTACTS: @@ -2265,7 +2265,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['body'] = trim(z_input_filter($arr['uid'],$arr['body'],$arr['mimetype'])); if(local_channel() && (! $arr['sig'])) { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($channel['channel_hash'] === $arr['author_xchan']) { $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey'])); $arr['item_verified'] = 1; @@ -2661,7 +2661,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { $arr['body'] = trim(z_input_filter($arr['uid'],$arr['body'],$arr['mimetype'])); if(local_channel() && (! $arr['sig'])) { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($channel['channel_hash'] === $arr['author_xchan']) { $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey'])); $arr['item_verified'] = 1; @@ -2887,7 +2887,7 @@ function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id, logger('storing diaspora comment signature',LOGGER_DEBUG); - $diaspora_handle = $channel['channel_address'] . '@' . get_app()->get_hostname(); + $diaspora_handle = $channel['channel_address'] . '@' . App::get_hostname(); $signed_text = $datarray['mid'] . ';' . $parent_item['mid'] . ';' . $signed_body . ';' . $diaspora_handle; @@ -4612,7 +4612,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal $ok_to_delete = true; // author deletion - $observer = $a->get_observer(); + $observer = App::get_observer(); if($observer && $observer['xchan_hash'] && ($observer['xchan_hash'] === $item['author_xchan'])) $ok_to_delete = true; @@ -5201,8 +5201,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $pager_sql = ''; } else { $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 20); - $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); - $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(get_app()->pager['itemspage']), intval(get_app()->pager['start'])); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); } if (isset($arr['start']) && isset($arr['records'])) @@ -5472,7 +5472,7 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, * @return boolean */ function comment_local_origin($item) { - if(stripos($item['mid'], get_app()->get_hostname()) && ($item['parent'] != $item['id'])) + if(stripos($item['mid'], App::get_hostname()) && ($item['parent'] != $item['id'])) return true; return false; -- cgit v1.2.3 From 0cda43145629586e6110e83fa2356e1c4ee4811a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 31 Mar 2016 20:15:47 -0700 Subject: create miniApp to convert existing settings files to the static App class --- include/items.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 09479e428..07cf2e0e8 100755 --- a/include/items.php +++ b/include/items.php @@ -4294,7 +4294,6 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { } function fix_private_photos($s, $uid, $item = null, $cid = 0) { - $a = get_app(); logger('fix_private_photos', LOGGER_DEBUG); $site = substr(z_root(),strpos(z_root(),'://')); @@ -4577,8 +4576,6 @@ function drop_items($items) { function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { - $a = get_app(); - // locate item to be deleted $r = q("SELECT * FROM item WHERE id = %d LIMIT 1", @@ -5077,8 +5074,6 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $result = array('success' => false); - $a = get_app(); - $sql_extra = ''; $sql_nets = ''; $sql_options = ''; -- cgit v1.2.3