diff options
author | Christian Vogeley <christian.vogeley@hotmail.de> | 2013-10-20 01:22:51 +0200 |
---|---|---|
committer | Christian Vogeley <christian.vogeley@hotmail.de> | 2013-10-20 01:22:51 +0200 |
commit | 2db45695e8067e49eb4c8a6d8044cd9cac7f07e5 (patch) | |
tree | 7a1029e10578e99f0dbbef6e22c42eb784ddd9d1 /include | |
parent | c0789bdb4fc7412efd5e2fb1e15b63d359a74cfa (diff) | |
parent | 49fb6326e0e978f57b2f988935af6e8e3d2f4417 (diff) | |
download | volse-hubzilla-2db45695e8067e49eb4c8a6d8044cd9cac7f07e5.tar.gz volse-hubzilla-2db45695e8067e49eb4c8a6d8044cd9cac7f07e5.tar.bz2 volse-hubzilla-2db45695e8067e49eb4c8a6d8044cd9cac7f07e5.zip |
Merge upstream
Diffstat (limited to 'include')
-rw-r--r-- | include/ItemObject.php | 1 | ||||
-rw-r--r-- | include/api.php | 8 | ||||
-rw-r--r-- | include/auth.php | 3 | ||||
-rw-r--r-- | include/conversation.php | 2 | ||||
-rw-r--r-- | include/dir_fns.php | 21 | ||||
-rwxr-xr-x | include/items.php | 33 | ||||
-rw-r--r-- | include/notifier.php | 5 | ||||
-rw-r--r-- | include/oauth.php | 9 | ||||
-rw-r--r-- | include/onedirsync.php | 23 | ||||
-rw-r--r-- | include/poller.php | 2 | ||||
-rwxr-xr-x | include/text.php | 153 | ||||
-rw-r--r-- | include/zot.php | 9 |
12 files changed, 190 insertions, 79 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php index df9386232..fc99c50ad 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -201,6 +201,7 @@ class Item extends BaseObject { 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, $item['author']['xchan_addr']), 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), $item['owner']['xchan_addr']), 'to' => t('to'), + 'via' => t('via'), 'wall' => t('Wall-to-Wall'), 'vwall' => t('via Wall-To-Wall:'), 'profile_url' => $profile_link, diff --git a/include/api.php b/include/api.php index 2760914e9..1dd970cbc 100644 --- a/include/api.php +++ b/include/api.php @@ -72,7 +72,9 @@ require_once('include/photos.php'); // login with oauth try { $oauth = new FKOAuth1(); - list($consumer,$token) = $oauth->verify_request(OAuthRequest::from_request()); + $req = OAuthRequest::from_request(); + list($consumer,$token) = $oauth->verify_request($req); +// list($consumer,$token) = $oauth->verify_request(OAuthRequest::from_request()); if (!is_null($token)){ $oauth->loginUser($token->uid); call_hooks('logged_in', $a->user); @@ -676,7 +678,6 @@ require_once('include/photos.php'); } } - // call out normal post function require_once('mod/item.php'); @@ -696,7 +697,7 @@ require_once('include/photos.php'); require_once('include/security.php'); $lastwall = q("SELECT * from item where 1 - and item_private != 0 and item_restrict = 0 + and item_private = 0 and item_restrict = 0 and author_xchan = '%s' and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and verb = '%s' @@ -749,6 +750,7 @@ require_once('include/photos.php'); ); $status_info['user'] = $user_info; } + return api_apply_template("status", $type, array('$status' => $status_info)); } diff --git a/include/auth.php b/include/auth.php index d04ebbe43..8eb8bf333 100644 --- a/include/auth.php +++ b/include/auth.php @@ -61,7 +61,8 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p if(((x($_POST,'auth-params')) && ($_POST['auth-params'] === 'logout')) || ($a->module === 'logout')) { // process logout request - call_hooks("logging_out"); + $args = array('channel_id' => local_user()); + call_hooks('logging_out', $args); nuke_session(); info( t('Logged out.') . EOL); goaway(z_root()); diff --git a/include/conversation.php b/include/conversation.php index 1820a8568..f9568c23f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1076,7 +1076,7 @@ function status_editor($a,$x,$popup=false) { call_hooks('jot_networks', $jotnets); $o .= replace_macros($tpl,array( - '$return_path' => $a->query_string, + '$return_path' => ((x($x,'return_path')) ? $x['return_path'] : $a->query_string), '$action' => $a->get_baseurl(true) . '/item', '$share' => (x($x,'button') ? $x['button'] : t('Share')), '$webpage' => $webpage, diff --git a/include/dir_fns.php b/include/dir_fns.php index 585121434..adbcb6e3c 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -3,9 +3,23 @@ require_once('include/permissions.php'); function find_upstream_directory($dirmode) { + $preferred = get_config('system','directory_server'); + if($preferred) + return array('url' => $preferred); return ''; } +function dir_sort_links() { + + $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( + '$header' => t('Sort Options'), + '$normal' => t('Alphabetic'), + '$reverse' => t('Reverse Alphabetic'), + '$date' => t('Newest to Oldest') + )); + return $o; +} + function sync_directories($dirmode) { @@ -71,7 +85,7 @@ function sync_directories($dirmode) { if(is_array($t['flags']) && in_array('deleted',$t['flags'])) $ud_flags |= UPDATE_FLAGS_DELETED; $z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) - values ( '%s', '%s', '%s', '%d, '%s' ) ", + values ( '%s', '%s', '%s', %d, '%s' ) ", dbesc($t['hash']), dbesc($t['transaction_id']), dbesc($t['timestamp']), @@ -89,12 +103,15 @@ function update_directory_entry($ud) { logger('update_directory_entry: ' . print_r($ud,true), LOGGER_DATA); if($ud['ud_addr'] && (! ($ud['ud_flags'] & UPDATE_FLAGS_DELETED))) { + $success = false; $x = zot_finger($ud['ud_addr'],''); if($x['success']) { $j = json_decode($x['body'],true); + if($j) + $success = true; $y = import_xchan($j,0); } - else { + if(! $success) { $r = q("update updates set ud_last = '%s' where ud_addr = '%s'", dbesc(datetime_convert()), dbesc($ud['ud_addr']) diff --git a/include/items.php b/include/items.php index 800684ae2..2229da5db 100755 --- a/include/items.php +++ b/include/items.php @@ -1429,6 +1429,8 @@ function item_store($arr,$allow_exec = false) { return ret; } + $uplinked_comment = false; + // If a page layout is provided, ensure it exists and belongs to us. if(array_key_exists('layout_mid',$arr) && $arr['layout_mid']) { @@ -1620,6 +1622,16 @@ function item_store($arr,$allow_exec = false) { if($r[0]['item_flags'] & ITEM_WALL) $arr['item_flags'] = $arr['item_flags'] | ITEM_WALL; + + // An uplinked comment might arrive with a downstream owner. + // Fix it. + + if($r[0]['owner_xchan'] !== $arr['owner_xchan']) { + $arr['owner_xchan'] = $r[0]['owner_xchan']; + $uplinked_comment = true; + } + + // if the parent is private, force privacy for the entire conversation // This differs from the above settings as it subtly allows comments from // email correspondents to be private even if the overall thread is not. @@ -1813,6 +1825,7 @@ function item_store_update($arr,$allow_exec = false) { unset($arr['id']); unset($arr['uid']); + if(array_key_exists('edit',$arr)) unset($arr['edit']); $arr['mimetype'] = ((x($arr,'mimetype')) ? notags(trim($arr['mimetype'])) : 'text/bbcode'); @@ -2136,11 +2149,9 @@ function tag_deliver($uid,$item_id) { intval($uid) ); -// issue #59 -// FIXME - check security on post and allowed senders, right now we just allow it. The author *may* be foreign and the original owner is lost on our copy of the post. So this could be very hard to verify. For instance what happens if the top-level post was a wall-to-wall? -// if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK) && ($x[0]['author_xchan'] == $item['author_xchan'])) { + if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK)) { -// logger('tag_deliver: creating second delivery chain for owner comment.'); + logger('tag_deliver: creating second delivery chain for comment to tagged post.'); // now change this copy of the post to a forum head message and deliver to all the tgroup members @@ -2150,6 +2161,14 @@ function tag_deliver($uid,$item_id) { $flag_bits = ITEM_WALL|ITEM_ORIGIN; + // maintain the original source, which will be the original item owner and was stored in source_xchan + // when we created the delivery fork + + $r = q("update item set source_xchan = '%s' where id = %d limit 1", + dbesc($x[0]['source_xchan']), + intval($item_id) + ); + $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d where id = %d limit 1", intval($flag_bits), @@ -2249,6 +2268,12 @@ function tag_deliver($uid,$item_id) { $flag_bits = ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK; + // preserve the source + + $r = q("update item set source_xchan = owner_xchan where id = %d limit 1", + intval($item_id) + ); + $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d where id = %d limit 1", intval($flag_bits), diff --git a/include/notifier.php b/include/notifier.php index 0c7ac5264..6ea2e71bb 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -325,12 +325,13 @@ function notifier_run($argv, $argc){ // tag_deliver'd post which needs to be sent back to the original author if(($cmd === 'uplink') && ($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post)) { - $uplink = true; + logger('notifier: uplink'); + $uplink = true; } if(($relay_to_owner || $uplink) && ($cmd !== 'relay')) { logger('notifier: followup relay', LOGGER_DEBUG); - $recipients = array(($uplink) ? $parent_item['author_xchan'] : $parent_item['owner_xchan']); + $recipients = array(($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan']); $private = true; if(! $encoded_item['flags']) $encoded_item['flags'] = array(); diff --git a/include/oauth.php b/include/oauth.php index b10802ecd..8eb8a83d8 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -151,15 +151,22 @@ class FKOAuth1 extends OAuthServer { header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); } + $_SESSION['uid'] = $record['channel_id']; $_SESSION['theme'] = $record['channel_theme']; $_SESSION['account_id'] = $record['channel_account_id']; $_SESSION['mobile_theme'] = get_pconfig($record['channel_id'], 'system', 'mobile_theme'); $_SESSION['authenticated'] = 1; -// $_SESSION['page_flags'] = $record['page-flags']; $_SESSION['my_url'] = $a->get_baseurl() . '/channel/' . $record['channel_address']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $_SESSION['allow_api'] = true; + $x = q("select * from account where account_id = %d limit 1", + intval($record['channel_account_id']) + ); + if($x) + $a->account = $x[0]; + + change_channel($record['channel_id']); $a->channel = $record; diff --git a/include/onedirsync.php b/include/onedirsync.php index b9c17628a..8ae1df5e5 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -12,7 +12,7 @@ function onedirsync_run($argv, $argc){ cli_startup(); $a = get_app(); - logger('onedirsync: start'); + logger('onedirsync: start ' . intval($argv[1])); if(($argc > 1) && (intval($argv[1]))) $update_id = intval($argv[1]); @@ -28,9 +28,28 @@ function onedirsync_run($argv, $argc){ if(! $r) return; - if($r['ud_flags'] & UPDATE_FLAGS_UPDATED) + if(($r[0]['ud_flags'] & UPDATE_FLAGS_UPDATED) || (! $r[0]['ud_addr'])) return; + // Have we probed this channel more recently than the other directory server + // (where we received this update from) ? + // If we have, we don't need to do anything except mark any older entries updated + + $x = q("select * from updates where ud_addr = '%s' and ud_date > '%s' and ( ud_flags & %d ) order by ud_date desc limit 1", + dbesc($r[0]['ud_addr']), + dbesc($r[0]['ud_date']), + intval(UPDATE_FLAGS_UPDATED) + ); + if($x) { + $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not ( ud_flags & %d ) and ud_date < '%s' ", + intval(UPDATE_FLAGS_UPDATED), + dbesc($r[0]['ud_addr']), + intval(UPDATE_FLAGS_UPDATED), + dbesc($x[0]['ud_date']) + ); + return; + } + update_directory_entry($r[0]); return; diff --git a/include/poller.php b/include/poller.php index 95eb810a0..94ca99e54 100644 --- a/include/poller.php +++ b/include/poller.php @@ -242,7 +242,7 @@ function poller_run($argv, $argc){ } if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { - $r = q("select ud_id from updates where not ( ud_flags & %d ) and ( ud_last = '0000-00-00 00:00:00' OR ud_last > UTC_TIMESTAMP() - INTERVAL 7 DAY ) ", + $r = q("select distinct ud_addr, updates.* from updates where not ( ud_flags & %d ) and ud_addr != '' and ( ud_last = '0000-00-00 00:00:00' OR ud_last > UTC_TIMESTAMP() - INTERVAL 7 DAY ) group by ud_addr ", intval(UPDATE_FLAGS_UPDATED) ); if($r) { diff --git a/include/text.php b/include/text.php index a3f2a651c..ff75535b0 100755 --- a/include/text.php +++ b/include/text.php @@ -1015,45 +1015,33 @@ function unobscure(&$item) { } - -function prepare_body(&$item,$attach = false) { - - $a = get_app(); - - - - call_hooks('prepare_body_init', $item); - - unobscure($item); - - $s = prepare_text($item['body'],$item['mimetype']); - - $prep_arr = array('item' => $item, 'html' => $s); - call_hooks('prepare_body', $prep_arr); - $s = $prep_arr['html']; - - if(! $attach) { - return $s; - } - +function theme_attachments(&$item) { $arr = json_decode_plus($item['attach']); - if(count($arr)) { - $s .= '<div class="body-attach">'; + if(is_array($arr) && count($arr)) { + $attaches = array(); foreach($arr as $r) { - $matches = false; $icon = ''; $icontype = substr($r['type'],0,strpos($r['type'],'/')); + // FIXME This should probably be a giant "if" statement in the template so that we don't have icon names + // embedded in php code + switch($icontype) { case 'video': + $icon = 'icon-facetime-video'; + break; case 'audio': + $icon = 'icon-volume-up'; + break; case 'image': + $icon = 'icon-picture'; + break; case 'text': - $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>'; + $icon = 'icon-align-justify'; break; default: - $icon = '<div class="attachtype icon s22 type-unkn"></div>'; + $icon = 'icon-question'; break; } @@ -1062,60 +1050,101 @@ function prepare_body(&$item,$attach = false) { $title = t('unknown.???'); $title .= ' ' . $r['length'] . ' ' . t('bytes'); - $url = $a->get_baseurl() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision']; + $url = z_root() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision']; $s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>'; + $attaches[] = array('title' => $title, 'url' => $url, 'icon' => $icon ); + } - $s .= '<div class="clear"></div></div>'; + + } -// At some point in time, posttags were removed from the threaded conversation templates, but remained in the search_item template. -// Code to put them back was added into include/conversation.php and/or include/ItemObject.php but under new class names -// Then it was discovered that the following bits remained of the old code. -// Commented out, but we may decide to use this instead of the other version and put all the tag rendering in one place. In the other -// location it is more theme-able. -// if(is_array($item['term']) && count($item['term'])) { -// $tstr = ''; -// foreach($item['term'] as $t) { -// $t1 = format_term_for_display($t); -// if($t1) { -// if($tstr) -// $tstr .= ' '; -// $tstr .= $t1; -// } -// } -// if($tstr) -// $s .= '<br /><div class="posttags">' . $tstr . '</div>'; -// } + $s = replace_macros(get_markup_template('item_attach.tpl'), array( + '$attaches' => $attaches + )); + + return $s; + +} - $writeable = ((get_observer_hash() == $item['owner_xchan']) ? true : false); - $x = ''; +function format_categories(&$item,$writeable) { + + $s = ''; $terms = get_terms_oftype($item['term'],TERM_CATEGORY); if($terms) { + $categories = array(); foreach($terms as $t) { - if(strlen($x)) - $x .= ','; - $x .= htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') - . (($writeable) ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : ''); + $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') ; + if(! trim($term)) + continue; + $removelink = (($writeable) ? z_root() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) : ''); + $categories[] = array('term' => $term, 'writeable' => $writeable, 'removelink' => $removelink, 'url' => $t['url']); } - if(strlen($x)) - $s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>'; + } + $s = replace_macros(get_markup_template('item_categories.tpl'),array( + '$remove' => t('remove category'), + '$categories' => $categories + )); + return $s; +} - } +function format_filer(&$item) { - $x = ''; + $s = ''; $terms = get_terms_oftype($item['term'],TERM_FILE); if($terms) { + $categories = array(); foreach($terms as $t) { - if(strlen($x)) - $x .= ' '; - $x .= htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') - . ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>'; + $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') ; + if(! trim($term)) + continue; + $removelink = z_root() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']); + $categories[] = array('term' => $term, 'removelink' => $removelink); } - if(strlen($x) && (local_user() == $item['uid'])) - $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>'; } + $s = replace_macros(get_markup_template('item_filer.tpl'),array( + '$remove' => t('remove from file'), + '$categories' => $categories + )); + return $s; +} + + + + + +function prepare_body(&$item,$attach = false) { + + $a = get_app(); + + + + call_hooks('prepare_body_init', $item); + + unobscure($item); + + $s = prepare_text($item['body'],$item['mimetype']); + + $prep_arr = array('item' => $item, 'html' => $s); + call_hooks('prepare_body', $prep_arr); + $s = $prep_arr['html']; + + if(! $attach) { + return $s; + } + + + $s .= theme_attachments($item); + + + $writeable = ((get_observer_hash() == $item['owner_xchan']) ? true : false); + + $s .= format_categories($item,$writeable); + + if(local_user() == $item['uid']) + $s .= format_filer($item); // Look for spoiler $spoilersearch = '<blockquote class="spoiler">'; diff --git a/include/zot.php b/include/zot.php index b250557e6..0ee099ce5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -723,6 +723,14 @@ function import_xchan($arr,$ud_flags = 1) { update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags); logger('import_xchan: changed: ' . $what,LOGGER_DEBUG); } + elseif(! $ud_flags) { + // nothing changed but we still need to update the updates record + q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) ", + intval(UPDATE_FLAGS_UPDATED), + dbesc($arr['address']), + intval(UPDATE_FLAGS_UPDATED) + ); + } if(! x($ret,'message')) { $ret['success'] = true; @@ -1568,6 +1576,7 @@ function update_modtime($hash,$guid,$addr,$flags = 0) { else { q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) ", intval(UPDATE_FLAGS_UPDATED), + dbesc($addr), intval(UPDATE_FLAGS_UPDATED) ); } |