diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/items.php | 46 | ||||
-rwxr-xr-x | include/oembed.php | 15 | ||||
-rw-r--r-- | include/permissions.php | 4 | ||||
-rw-r--r-- | include/poller.php | 20 | ||||
-rwxr-xr-x | include/text.php | 30 |
5 files changed, 87 insertions, 28 deletions
diff --git a/include/items.php b/include/items.php index 4704ca344..9041e3da7 100755 --- a/include/items.php +++ b/include/items.php @@ -98,17 +98,25 @@ function post_activity_item($arr) { $ret = array('success' => false); + $is_comment = false; + if((($arr['parent']) && $arr['parent'] != $arr['id']) || (($arr['parent_mid']) && $arr['parent_mid'] != $arr['mid'])) + $is_comment = true; + if(! x($arr,'item_flags')) { - $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP; + if($is_comment) + $arr['item_flags'] = ITEM_ORIGIN; + else + $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP; } + $channel = get_app()->get_channel(); $observer = get_app()->get_observer(); $arr['aid'] = ((x($arr,'aid')) ? $arr['aid'] : $channel['channel_account_id']); $arr['uid'] = ((x($arr,'uid')) ? $arr['uid'] : $channel['channel_id']); - if(! perm_is_allowed($arr['uid'],$observer['xchan_hash'],(($arr['parent']) ? 'post_comment' : 'post_wall'))) { + if(! perm_is_allowed($arr['uid'],$observer['xchan_hash'],(($is_comment) ? 'post_comments' : 'post_wall'))) { $ret['message'] = t('Permission denied'); return $ret; } @@ -1907,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(); @@ -1923,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); diff --git a/include/oembed.php b/include/oembed.php index 7f8e4ca7d..04a40f6ee 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -51,12 +51,17 @@ function oembed_fetch_url($embedurl){ } } - if ($txt==false || $txt==""){ + if ($txt==false || $txt=="") { + $x = array('url' => $embedurl,'videowidth' => $a->videowidth); + call_hooks('oembed_probe',$x); + if(array_key_exists('embed',$x)) + $txt = $x['embed']; + // try oohembed service - $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=' . $a->videowidth; - $result = z_fetch_url($ourl); - if($result['success']) - $txt = $result['body']; +// $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=' . $a->videowidth; +// $result = z_fetch_url($ourl); +// if($result['success']) +// $txt = $result['body']; } $txt=trim($txt); diff --git a/include/permissions.php b/include/permissions.php index a8f8d2629..071a599f8 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -98,7 +98,7 @@ function get_all_perms($uid,$observer_xchan,$internal_use = true) { // If they're blocked - they can't read or write - if(($x) && ($x[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)) { + if(($x) && (($x[0]['abook_flags'] & ABOOK_FLAG_BLOCKED) || ($x[0]['abook_flags'] & ABOOK_FLAG_PENDING))) { $ret[$perm_name] = false; continue; } @@ -242,7 +242,7 @@ function perm_is_allowed($uid,$observer_xchan,$permission) { // If they're blocked - they can't read or write - if(($x) && ($x[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)) + if(($x) && (($x[0]['abook_flags'] & ABOOK_FLAG_BLOCKED) || ($x[0]['abook_flags'] & ABOOK_FLAG_PENDING))) return false; if(($x) && (! $global_perms[$permission][2]) && ($x[0]['abook_flags'] & ABOOK_FLAG_IGNORED)) diff --git a/include/poller.php b/include/poller.php index 433bc8caf..dff16d3d7 100644 --- a/include/poller.php +++ b/include/poller.php @@ -85,6 +85,26 @@ function poller_run($argv, $argc){ proc_run('php','include/expire.php'); } + // update any photos which didn't get imported properly + // This should be rare + + $r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = '' + and xchan_photo_date < UTC_TIMESTAMP() - INTERVAL 1 DAY"); + if($r) { + require_once('include/photo/photo_driver.php'); + foreach($r as $rr) { + $photos = import_profile_photo($rr['xchan_photo_l'],$rr['xchan_hash']); + $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' + where xchan_hash = '%s' limit 1", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($rr['xchan_hash']) + ); + } + } + $manual_id = 0; $generation = 0; diff --git a/include/text.php b/include/text.php index 9f32959b2..71f2257ac 100755 --- a/include/text.php +++ b/include/text.php @@ -334,20 +334,16 @@ function alt_pager(&$a, $i, $more = '', $less = '') { $pagenum = $a->pager['page']; $url = $a->get_baseurl() . '/' . $stripped; - $o .= '<div class="pager">'; - - if($a->pager['page'] > 1) - $o .= "<a href=\"$url"."&page=".($a->pager['page'] - 1).'">' . $less . '</a>'; - if($i > 0 && $i == $a->pager['itemspage']) { - if($a->pager['page']>1) - $o .= " | "; - $o .= "<a href=\"$url"."&page=".($a->pager['page'] + 1).'">' . $more . '</a>'; - } - - - $o .= '</div>'."\r\n"; + return replace_macros(get_markup_template('alt_pager.tpl'),array( + '$has_less' => (($a->pager['page'] > 1) ? true : false), + '$has_more' => (($i > 0 && $i == $a->pager['itemspage']) ? true : false), + '$less' => $less, + '$more' => $more, + '$url' => $url, + '$prevpage' => $a->pager['page'] - 1, + '$nextpage' => $a->pager['page'] + 1, + )); - return $o; } // Turn user/group ACLs stored as angle bracketed text into arrays @@ -1598,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') ", @@ -1650,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) . ']'), @@ -1680,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", @@ -1693,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)); |