diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 19 | ||||
-rwxr-xr-x | include/items.php | 27 | ||||
-rw-r--r-- | include/security.php | 10 | ||||
-rw-r--r-- | include/text.php | 7 | ||||
-rw-r--r-- | include/zot.php | 21 |
5 files changed, 50 insertions, 34 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 260240a44..1239e5497 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -175,12 +175,29 @@ function bb_parse_element($match) { $j = json_decode(base64url_decode($match[1]),true); if ($j) { - $o = EOL . '<a href="#" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . t('Install ' . $j['type'] . ' element: ') . $j['pagetitle'] . '</a>' . EOL; + $text = sprintf( t('Install %s element: '), translate_design_element($j['type'])) . $j['pagetitle']; + $o = EOL . '<a href="#" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . $text . '</a>' . EOL; } return $o; } +function translate_design_element($type) { + switch($type) { + case 'webpage': + $ret = t('webpage'); + break; + case 'layout': + $ret = t('layout'); + break; + case 'block': + $ret = t('block'); + break; + } + + return $ret; +} + /** * @brief Returns an QR-code image from a value given in $match[1]. * diff --git a/include/items.php b/include/items.php index e4d16668a..828f43621 100755 --- a/include/items.php +++ b/include/items.php @@ -949,6 +949,14 @@ function import_author_diaspora($x) { if(! $x['address']) return false; + $r = q("select * from xchan where xchan_addr = '%s' limit 1", + dbesc($x['address']) + ); + if($r) { + logger('in_cache: ' . $x['address'], LOGGER_DATA); + return $r[0]['chan_hash']; + } + if(discover_by_webbie($x['address'])) { $r = q("select xchan_hash from xchan where xchan_addr = '%s' limit 1", dbesc($x['address']) @@ -4095,6 +4103,8 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { $linked_item = (($item['resource_id']) ? true : false); + logger('item: ' . $item . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA); + switch($stage) { case DROPITEM_PHASE2: $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', @@ -4333,12 +4343,14 @@ function fetch_post_tags($items,$link = false) { -function zot_feed($uid,$observer_xchan,$arr) { +function zot_feed($uid,$observer_hash,$arr) { $result = array(); $mindate = null; $message_id = null; + require_once('include/security.php'); + if(array_key_exists('mindate',$arr)) { $mindate = datetime_convert('UTC','UTC',$arr['mindate']); } @@ -4356,14 +4368,14 @@ function zot_feed($uid,$observer_xchan,$arr) { if($message_id) logger('message_id: ' . $message_id,LOGGER_DEBUG); - if(! perm_is_allowed($uid,$observer_xchan,'view_stream')) { + if(! perm_is_allowed($uid,$observer_hash,'view_stream')) { logger('zot_feed: permission denied.'); return $result; } if(! is_sys_channel($uid)) { require_once('include/security.php'); - $sql_extra = item_permissions_sql($uid); + $sql_extra = item_permissions_sql($uid,$observer_hash); } $limit = " LIMIT 100 "; @@ -4377,6 +4389,7 @@ function zot_feed($uid,$observer_xchan,$arr) { $limit = ''; } + $items = array(); /** @FIXME fix this part for PostgreSQL */ @@ -4386,7 +4399,6 @@ function zot_feed($uid,$observer_xchan,$arr) { } if(is_sys_channel($uid)) { - require_once('include/security.php'); $r = q("SELECT parent, created, postopts from item WHERE uid != %d and uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ") AND item_restrict = 0 @@ -4592,7 +4604,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C //$start = dba_timer(); require_once('include/security.php'); - $sql_extra .= item_permissions_sql($channel['channel_id']); + $sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash); if($arr['pages']) $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " "; @@ -4698,7 +4710,10 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo $page_type = ''; - if($webpage == ITEM_TYPE_WEBPAGE) + if(! $post_id) + return; + + if($webpage == ITEM_TYPE_WEBPAGE) $page_type = 'WEBPAGE'; elseif($webpage == ITEM_TYPE_BLOCK) $page_type = 'BUILDBLOCK'; diff --git a/include/security.php b/include/security.php index c3b0e9763..91683cc98 100644 --- a/include/security.php +++ b/include/security.php @@ -148,7 +148,7 @@ function change_channel($change_channel) { * * @return string additional SQL where statement */ -function permissions_sql($owner_id, $remote_verified = false, $groups = null) { +function permissions_sql($owner_id, $remote_observer = null) { $local_channel = local_channel(); @@ -181,7 +181,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) { */ else { - $observer = get_observer_hash(); + $observer = (($remote_observer) ? $remote_observer : get_observer_hash()); if($observer) { $groups = init_groups_visitor($observer); @@ -217,7 +217,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) { * * @return string additional SQL where statement */ -function item_permissions_sql($owner_id, $remote_verified = false, $groups = null) { +function item_permissions_sql($owner_id, $remote_observer = null) { $local_channel = local_channel(); @@ -227,7 +227,7 @@ function item_permissions_sql($owner_id, $remote_verified = false, $groups = nul * default permissions - anonymous user */ - $sql = " AND item_private=0 "; + $sql = " AND item_private = 0 "; /** * Profile owner - everything is visible @@ -246,7 +246,7 @@ function item_permissions_sql($owner_id, $remote_verified = false, $groups = nul */ else { - $observer = get_observer_hash(); + $observer = (($remote_observer) ? $remote_observer : get_observer_hash()); if($observer) { $groups = init_groups_visitor($observer); diff --git a/include/text.php b/include/text.php index 67410dfbc..58e3436ca 100644 --- a/include/text.php +++ b/include/text.php @@ -1384,7 +1384,6 @@ function prepare_body(&$item,$attach = false) { else { call_hooks('prepare_body_init', $item); unobscure($item); - $s = prepare_text($item['body'],$item['mimetype'], true); } @@ -1392,9 +1391,8 @@ function prepare_body(&$item,$attach = false) { call_hooks('prepare_body', $prep_arr); $s = $prep_arr['html']; - q("update item set html = '%s' where id = %d", - dbesc($prep_arr['html']), + dbesc($s), intval($item['id']) ); @@ -1456,9 +1454,6 @@ function prepare_body(&$item,$attach = false) { $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body_final', $prep_arr); - - - return $prep_arr['html']; } diff --git a/include/zot.php b/include/zot.php index 22a324edd..694338a9e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2899,25 +2899,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { // Perform discovery if the referenced xchan hasn't ever been seen on this hub. // This relies on the undocumented behaviour that red sites send xchan info with the abook + // and import_author_xchan will look them up on all federated networks - if($abook['abook_xchan'] && $abook['xchan_address']) { + if($abook['abook_xchan'] && $abook['xchan_addr']) { $h = zot_get_hublocs($abook['abook_xchan']); if(! $h) { - $f = zot_finger($abook['xchan_address'],$channel); - if(! $f['success']) { - logger('process_channel_sync_delivery: abook not probe-able' . $abook['xchan_address']); - continue; - } - $j = json_decode($f['body'],true); - if(! ($j['success'] && $j['guid'])) { - logger('process_channel_sync_delivery: probe failed.'); - continue; - } - - $x = import_xchan($j); - - if(! $x['success']) { - logger('process_channel_sync_delivery: import failed.'); + $xhash = import_author_xchan(encode_item_xchan($abook)); + if(! $xhash) { + logger('process_channel_sync_delivery: import of ' . $abook['xchan_addr'] . ' failed.'); continue; } } |