diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/api.php | 17 | ||||
-rw-r--r-- | include/bbcode.php | 7 | ||||
-rw-r--r-- | include/channel.php | 21 | ||||
-rw-r--r-- | include/connections.php | 16 | ||||
-rw-r--r-- | include/conversation.php | 7 | ||||
-rw-r--r-- | include/help.php | 17 | ||||
-rw-r--r-- | include/import.php | 13 | ||||
-rwxr-xr-x | include/items.php | 46 | ||||
-rw-r--r-- | include/page_widgets.php | 11 | ||||
-rw-r--r-- | include/text.php | 12 | ||||
-rw-r--r-- | include/widgets.php | 9 |
11 files changed, 101 insertions, 75 deletions
diff --git a/include/api.php b/include/api.php index be525f7e9..df6aba957 100644 --- a/include/api.php +++ b/include/api.php @@ -839,7 +839,7 @@ require_once('include/api_auth.php'); $_REQUEST['parent_mid'] = $parent; if($_REQUEST['namespace'] && $parent) { - $x = q("select iid from item_id where service = '%s' and sid = '%s' limit 1", + $x = q("select iid from iconfig where cat = 'system' and k = '%s' and v = '%s' limit 1", dbesc($_REQUEST['namespace']), dbesc($parent) ); @@ -967,20 +967,10 @@ require_once('include/api_auth.php'); $ret = array(); $tmp = array(); - $str = ''; foreach($i as $ii) { $tmp[] = encode_item($ii,true); - if($str) - $str .= ','; - $str .= $ii['id']; } $ret['item'] = $tmp; - if($str) { - $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item.id in ( $str ) "); - - if($r) - $ret['item_id'] = $r; - } json_return_and_die($ret); } @@ -1462,7 +1452,8 @@ require_once('include/api_auth.php'); } else { if($_REQUEST['namespace'] && $_REQUEST['remote_id']) { - $r = q("select * from item_id where service = '%s' and sid = '%s' and uid = %d limit 1", + $r = q("select * from iconfig left join item on iconfig.iid = item.id + where cat = 'system' and k = '%s' and v = '%s' and item.uid = %d limit 1", dbesc($_REQUEST['namespace']), dbesc($_REQUEST['remote_id']), intval($user_info['uid']) @@ -1472,7 +1463,7 @@ require_once('include/api_auth.php'); $id = $r[0]['iid']; } if($_REQUEST['namespace'] && $_REQUEST['comment_id']) { - $r = q("select * from item_id left join item on item.id = item_id.iid where service = '%s' and sid = '%s' and uid = %d and item.id != item.parent limit 1", + $r = q("select * from iconfig left join item on item.id = iconfig.iid where cat = 'system' and k = '%s' and v = '%s' and uid = %d and item.id != item.parent limit 1", dbesc($_REQUEST['namespace']), dbesc($_REQUEST['comment_id']), intval($user_info['uid']) diff --git a/include/bbcode.php b/include/bbcode.php index 42741b392..63a475779 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -242,6 +242,13 @@ function bb_ShareAttributes($match) { if ($matches[1] != "") $message_id = $matches[1]; + if(! $message_id) { + preg_match("/guid='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $message_id = $matches[1]; + } + + $reldate = '<span class="autotime" title="' . datetime_convert('UTC', date_default_timezone_get(), $posted, 'c') . '" >' . datetime_convert('UTC', date_default_timezone_get(), $posted, 'r') . '</span>'; $headline = '<div class="shared_container"> <div class="shared_header">'; diff --git a/include/channel.php b/include/channel.php index 087bd4162..92c274105 100644 --- a/include/channel.php +++ b/include/channel.php @@ -16,7 +16,7 @@ require_once('include/menu.php'); * @param int $account_id * Account_id used for this request * - * @returns assoziative array with: + * @returns associative array with: * * \e boolean \b success boolean true if creating a new channel is allowed for this account * * \e string \b message (optional) if success is false, optional error text * * \e int \b total_identities @@ -676,14 +676,6 @@ function identity_basic_export($channel_id, $items = false) { $ret['mail'] = $m; } - $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d", - intval($channel_id) - ); - - if($r) - $ret['item_id'] = $r; - - //$key = get_config('system','prvkey'); /** @warning this may run into memory limits on smaller systems */ @@ -746,17 +738,6 @@ function identity_export_year($channel_id,$year,$month = 0) { $ret['item'][] = encode_item($rr,true); } - $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d - and item.created >= '%s' and item.created < '%s' order by created ", - intval($channel_id), - dbesc($mindate), - dbesc($maxdate) - ); - - if($r) - $ret['item_id'] = $r; - - return $ret; } diff --git a/include/connections.php b/include/connections.php index 2d10b8354..ed4526a09 100644 --- a/include/connections.php +++ b/include/connections.php @@ -283,18 +283,30 @@ function channel_remove($channel_id, $local = true, $unset_session=false) { Zotlabs\Daemon\Master::Summon(array('Notifier','purge_all',$channel_id)); } + + $r = q("select * from iconfig left join item on item.id = iconfig.iid + where item.uid = %d", + intval($channel_id) + ); + if($r) { + foreach($r as $rr) { + q("delete from iconfig where iid = %d", + intval($rr['iid']) + ); + } + } + + q("DELETE FROM `groups` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `event` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `item` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `item_id` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `mail` WHERE `channel_id` = %d", intval($channel_id)); q("DELETE FROM `notify` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `photo` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `attach` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `profile` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `spam` WHERE `uid` = %d", intval($channel_id)); // @FIXME At this stage we need to remove the file resources located under /store/$nickname diff --git a/include/conversation.php b/include/conversation.php index bf29048b6..d2d4ffca0 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -403,9 +403,12 @@ function count_descendants($item) { * @return boolean */ function visible_activity($item) { - $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); + $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ]; - $post_types = array(ACTIVITY_OBJ_NOTE,ACTIVITY_OBJ_COMMENT,basename(ACTIVITY_OBJ_NOTE),basename(ACTIVITY_OBJ_COMMENT)); + $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)]; + + if(intval($item['item_notshown'])) + return false; foreach ($hidden_activities as $act) { if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { diff --git a/include/help.php b/include/help.php index 5518eeb70..7f57f3334 100644 --- a/include/help.php +++ b/include/help.php @@ -30,7 +30,8 @@ function search_doc_files($s) { $regexop = db_getfunc('REGEXP'); - $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and + $r = q("select iconfig.v, item.* from item left join iconfig on item.id = iconfig.iid + where iconfig.cat = 'system' and iconfig.k = 'docfile' and body $regexop '%s' and item_type = %d $pager_sql", dbesc($s), intval(ITEM_TYPE_DOC) @@ -50,7 +51,7 @@ function search_doc_files($s) { } } } - if(stristr($r[$x]['sid'],$s)) + if(stristr($r[$x]['v'],$s)) $r[$x]['rank'] ++; $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s)); // bias the results to the observer's native language @@ -123,12 +124,15 @@ function store_doc_file($s) { $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash']; $item['item_type'] = ITEM_TYPE_DOC; - $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and - sid = '%s' and item_type = %d limit 1", + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where iconfig.cat = 'system' and iconfig.k = 'docfile' and + iconfig.v = '%s' and item_type = %d limit 1", dbesc($s), intval(ITEM_TYPE_DOC) ); + \Zotlabs\Lib\IConfig::Set($item,'system','docfile',$s); + if($r) { $item['id'] = $r[0]['id']; $item['mid'] = $item['parent_mid'] = $r[0]['mid']; @@ -139,10 +143,7 @@ function store_doc_file($s) { $x = item_store($item); } - if($x['success']) { - update_remote_id($sys,$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']); - } - + return $x; } diff --git a/include/import.php b/include/import.php index be456bfa9..0f52f3ff8 100644 --- a/include/import.php +++ b/include/import.php @@ -624,19 +624,14 @@ function import_item_ids($channel,$itemids) { ); if(! $r) continue; - $z = q("select * from item_id where service = '%s' and sid = '%s' and iid = %d and uid = %d limit 1", + $z = q("select * from iconfig where iconfig.cat = 'system' and iconfig.k = '%s' + and iconfig.v = '%s' and iid = %d limit 1", dbesc($i['service']), dbesc($i['sid']), - intval($r[0]['id']), - intval($channel['channel_id']) + intval($r[0]['id']) ); if(! $z) { - q("insert into item_id (iid,uid,sid,service) values(%d,%d,'%s','%s')", - intval($r[0]['id']), - intval($channel['channel_id']), - dbesc($i['sid']), - dbesc($i['service']) - ); + \Zotlabs\Lib\IConfig::Set($r[0]['id'],'system',$i['service'],$i['sid'],true); } } } diff --git a/include/items.php b/include/items.php index 93385c6e6..a844cd1f6 100755 --- a/include/items.php +++ b/include/items.php @@ -677,13 +677,23 @@ function get_item_elements($x,$allow_code = false) { $arr['item_flags'] = 0; - if(array_key_exists('flags',$x) && in_array('consensus',$x['flags'])) - $arr['item_consensus'] = 1; + if(array_key_exists('flags',$x)) { - if(array_key_exists('flags',$x) && in_array('deleted',$x['flags'])) - $arr['item_deleted'] = 1; - if(array_key_exists('flags',$x) && in_array('hidden',$x['flags'])) - $arr['item_hidden'] = 1; + if(in_array('consensus',$x['flags'])) + $arr['item_consensus'] = 1; + + if(in_array('deleted',$x['flags'])) + $arr['item_deleted'] = 1; + + if(in_array('notshown',$x['flags'])) + $arr['item_notshown'] = 1; + + // hidden item are no longer propagated - notshown may be a suitable alternative + + if(in_array('hidden',$x['flags'])) + $arr['item_hidden'] = 1; + + } // Here's the deal - the site might be down or whatever but if there's a new person you've never // seen before sending stuff to your stream, we MUST be able to look them up and import their data from their @@ -1339,6 +1349,8 @@ function encode_item_flags($item) { $ret[] = 'deleted'; if(intval($item['item_hidden'])) $ret[] = 'hidden'; + if(intval($item['item_notshown'])) + $ret[] = 'notshown'; if(intval($item['item_thread_top'])) $ret[] = 'thread_parent'; if(intval($item['item_nsfw'])) @@ -3537,9 +3549,8 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { intval($item['id']) ); - q("delete from item_id where iid = %d and uid = %d", - intval($item['id']), - intval($item['uid']) + q("delete from iconfig where iid = %d", + intval($item['id']) ); q("delete from term where oid = %d and otype = %d", @@ -4105,6 +4116,23 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C return $items; } +function webpage_to_namespace($webpage) { + + if($webpage == ITEM_TYPE_WEBPAGE) + $page_type = 'WEBPAGE'; + elseif($webpage == ITEM_TYPE_BLOCK) + $page_type = 'BUILDBLOCK'; + elseif($webpage == ITEM_TYPE_PDL) + $page_type = 'PDL'; + elseif($webpage == ITEM_TYPE_DOC) + $page_type = 'docfile'; + else + $page_type = 'unknown'; + return $page_type; + +} + + function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid) { diff --git a/include/page_widgets.php b/include/page_widgets.php index 49d1439be..3270de4a3 100644 --- a/include/page_widgets.php +++ b/include/page_widgets.php @@ -1,7 +1,8 @@ <?php // A basic toolbar for observers with write_pages permissions -function writepages_widget ($who,$which){ + +function writepages_widget ($who,$which) { return replace_macros(get_markup_template('write_pages.tpl'), array( '$new' => t('New Page'), '$newurl' => "webpages/$who", @@ -13,9 +14,11 @@ function writepages_widget ($who,$which){ // Chan is channel_id, $which is channel_address - we'll need to pass observer later too. -function pagelist_widget ($owner,$which){ - $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", +function pagelist_widget ($owner,$which) { + + $r = q("select * from iconfig left join item on iconfig.iid = item.id where item_id.uid = %d + and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' order by item.created desc", intval($owner) ); @@ -24,7 +27,7 @@ function pagelist_widget ($owner,$which){ if($r) { $pages = array(); foreach($r as $rr) { - $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited'])); + $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['v'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited'])); } } diff --git a/include/text.php b/include/text.php index 1bc19da34..bd59aa732 100644 --- a/include/text.php +++ b/include/text.php @@ -1743,7 +1743,8 @@ function unamp($s) { } function layout_select($channel_id, $current = '') { - $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and item_type = %d ", + $r = q("select mid, v from item left join iconfig on iconfig.iid = item.id + where iconfig.cat = 'system' and iconfig.k = 'PDL' and item.uid = %d and item_type = %d ", intval($channel_id), intval(ITEM_TYPE_PDL) ); @@ -1753,7 +1754,7 @@ function layout_select($channel_id, $current = '') { $options .= '<option value="" ' . $empty_selected . '>' . t('default') . '</option>'; foreach($r as $rr) { $selected = (($rr['mid'] == $current) ? ' selected="selected" ' : ''); - $options .= '<option value="' . $rr['mid'] . '"' . $selected . '>' . $rr['sid'] . '</option>'; + $options .= '<option value="' . $rr['mid'] . '"' . $selected . '>' . $rr['v'] . '</option>'; } } @@ -2821,13 +2822,16 @@ function expand_acl($s) { // If it has a pdl we'll load it as we know the mid and pass the body through comanche_parser() which will generate the // page layout from the given description +// @FIXME - there is apparently a very similar function called layout_select; this one should probably take precedence +// and the other should be checked for compatibility and removed function pdl_selector($uid, $current="") { $o = ''; $sql_extra = item_permissions_sql($uid); - $r = q("select item_id.*, mid from item_id left join item on iid = item.id where item_id.uid = %d and item_id.uid = item.uid and service = 'PDL' $sql_extra order by sid asc", + $r = q("select iconfig.*, mid from item_id left join item on iconfig.iid = item.id + where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' $sql_extra order by v asc", intval($uid) ); @@ -2841,7 +2845,7 @@ function pdl_selector($uid, $current="") { $entries[] = array('title' => t('Default'), 'mid' => ''); foreach($entries as $selection) { $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= "<option value=\"{$selection['mid']}\" $selected >{$selection['sid']}</option>"; + $o .= "<option value=\"{$selection['mid']}\" $selected >{$selection['v']}</option>"; } $o .= '</select>'; diff --git a/include/widgets.php b/include/widgets.php index 3ca189af0..cdd5d72ab 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -994,8 +994,9 @@ function widget_item($arr) { $sql_extra = item_permissions_sql($channel_id); if($arr['title']) { - $r = q("select item.* from item left join item_id on item.id = item_id.iid - where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and item_type = %d $sql_options $revision limit 1", + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' + and iconfig.k = 'WEBPAGE' and item_type = %d $sql_options $revision limit 1", intval($channel_id), dbesc($arr['title']), intval(ITEM_TYPE_WEBPAGE) @@ -1253,8 +1254,8 @@ function widget_random_block($arr) { $randfunc = db_getfunc('RAND'); - $r = q("select item.* from item left join item_id on item.id = item_id.iid - where item.uid = %d and sid like '%s' and service = 'BUILDBLOCK' and + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v like '%s' and iconfig.k = 'BUILDBLOCK' and item_type = %d $sql_options order by $randfunc limit 1", intval($channel_id), dbesc('%' . $contains . '%'), |