deprecate the item_id table - replace with iconfig. A possibly useful function in the iconfig class would be a search which takes a service id and type and uid, matches against an item and returns the iid. That could save a bit of code duplication.

This commit is contained in:
redmatrix 2016-06-13 19:58:24 -07:00
parent 6d4188f05e
commit 1e68d4fb75
24 changed files with 172 additions and 145 deletions

View File

@ -52,8 +52,8 @@ class Block extends \Zotlabs\Web\Controller {
require_once('include/security.php');
$sql_options = item_permissions_sql($u[0]['channel_id']);
$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 = '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 = '%s' and iconfig.k = 'BUILDBLOCK' and
item_type = %d $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
@ -64,8 +64,8 @@ class Block extends \Zotlabs\Web\Controller {
// Check again with no permissions clause to see if it is a permissions issue
$x = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and
$x = 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 = 'BUILDBLOCK' and
item_type = %d $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),

View File

@ -111,8 +111,11 @@ class Blocks extends \Zotlabs\Web\Controller {
$editor = status_editor($a,$x);
$r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id
where item_id.uid = %d and service = 'BUILDBLOCK' and item_type = %d order by item.created desc",
$r = q("select iconfig.iid, iconfig.k, iconfig.v, mid, title, body, mimetype, created, edited from iconfig
left join item on iconfig.iid = item.id
where uid = %d and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK'
and item_type = %d order by item.created desc",
intval($owner),
intval(ITEM_TYPE_BLOCK)
);
@ -129,12 +132,12 @@ class Blocks extends \Zotlabs\Web\Controller {
'created' => $rr['created'],
'edited' => $rr['edited'],
'mimetype' => $rr['mimetype'],
'pagetitle' => $rr['sid'],
'pagetitle' => $rr['v'],
'mid' => $rr['mid']
);
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
'name' => $rr['sid'],
'name' => $rr['v'],
'title' => $rr['title'],
'created' => $rr['created'],
'edited' => $rr['edited'],

View File

@ -106,12 +106,13 @@ class Display extends \Zotlabs\Web\Controller {
$x = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
);
$y = q("select * from item_id where uid = %d and service = 'WEBPAGE' and iid = %d limit 1",
$y = q("select * from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item.id = %d limit 1",
intval($target_item['uid']),
intval($target_item['id'])
);
if($x && $y) {
goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['sid']);
goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['v']);
}
else {
notice( t('Page not found.') . EOL);

View File

@ -85,11 +85,11 @@ class Editblock extends \Zotlabs\Web\Controller {
intval($owner)
);
if($itm) {
$item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1",
$item_id = q("select * from iconfig where cat = 'system' and k = 'BUILDBLOCK' and iid = %d limit 1",
intval($itm[0]['id'])
);
if($item_id)
$block_title = $item_id[0]['sid'];
$block_title = $item_id[0]['v'];
}
else {
notice( t('Item not found') . EOL);

View File

@ -96,11 +96,12 @@ class Editlayout extends \Zotlabs\Web\Controller {
intval($owner)
);
$item_id = q("select * from item_id where service = 'PDL' and iid = %d limit 1",
$item_id = q("select * from iconfig where cat = 'system' and k = 'PDL' and iid = %d limit 1",
intval($itm[0]['id'])
);
if($item_id)
$layout_title = $item_id[0]['sid'];
$layout_title = $item_id[0]['v'];
$rp = 'layouts/' . $which;

View File

@ -114,11 +114,11 @@ class Editwebpage extends \Zotlabs\Web\Controller {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']),$key);
}
$item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1",
$item_id = q("select * from iconfig where cat = 'system' and k = 'WEBPAGE' and iid = %d limit 1",
intval($itm[0]['id'])
);
if($item_id)
$page_title = $item_id[0]['sid'];
$page_title = $item_id[0]['v'];
$mimetype = $itm[0]['mimetype'];

View File

@ -138,8 +138,6 @@ class Impel extends \Zotlabs\Web\Controller {
$pagetitle = strtolower(\URLify::transliterate($j['pagetitle']));
}
// Verify ability to use html or php!!!
$execflag = false;
@ -154,21 +152,14 @@ class Impel extends \Zotlabs\Web\Controller {
}
}
$remote_id = 0;
$z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1",
dbesc($pagetitle),
dbesc($namespace),
intval(local_channel())
);
$i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['mid']),
intval(local_channel())
);
if($z && $i) {
$remote_id = $z[0]['id'];
\Zotlabs\Lib\IConfig::Set($arr,'system',$namespace,(($pagetitle) ? $pagetitle : substr($arr['mid'],0,16)),true);
if($i) {
$arr['id'] = $i[0]['id'];
// don't update if it has the same timestamp as the original
if($arr['edited'] > $i[0]['edited'])
@ -182,12 +173,12 @@ class Impel extends \Zotlabs\Web\Controller {
intval(local_channel())
);
}
else
$x = item_store($arr,$execflag);
}
if($x['success']) {
if($x && $x['success']) {
$item_id = $x['item_id'];
update_remote_id($channel,$item_id,$arr['item_type'],$pagetitle,$namespace,$remote_id,$arr['mid']);
}
}
@ -200,6 +191,7 @@ class Impel extends \Zotlabs\Web\Controller {
}
//??? should perhaps return ret?
json_return_and_die(true);
}

View File

@ -1,4 +1,5 @@
<?php
namespace Zotlabs\Module;
/**
@ -229,7 +230,7 @@ class Item extends \Zotlabs\Web\Controller {
if($namespace && $remote_id) {
// It wasn't an internally generated post - see if we've got an item matching this remote service id
$i = q("select iid from item_id where service = '%s' and sid = '%s' limit 1",
$i = q("select iid from iconfig where cat = 'system' and k = '%s' and v = '%s' limit 1",
dbesc($namespace),
dbesc($remote_id)
);
@ -880,13 +881,21 @@ class Item extends \Zotlabs\Web\Controller {
}
}
if($webpage) {
Zlib\IConfig::Set($datarray,'system', webpage_to_namespace($webpage),
(($pagetitle) ? $pagetitle : substr($datarray['mid'],0,16)),true);
}
elseif($namespace) {
Zlib\IConfig::Set($datarray,'system', $namespace,
(($remote_id) ? $remote_id : substr($datarray['mid'],0,16)),true);
}
if($orig_post) {
$datarray['id'] = $post_id;
item_store_update($datarray,$execflag);
update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
if(! $parent) {
$r = q("select * from item where id = %d",
intval($post_id)
@ -894,10 +903,7 @@ class Item extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
$rid = q("select * from item_id where iid = %d",
intval($post_id)
);
build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true)),'item_id' => $rid));
build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true))));
}
}
if(! $nopush)
@ -979,9 +985,6 @@ class Item extends \Zotlabs\Web\Controller {
// NOTREACHED
}
update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
if(($parent) && ($parent != $post_id)) {
// Store the comment signature information in case we need to relay to Diaspora
//$ditem = $datarray;
@ -995,10 +998,7 @@ class Item extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
$rid = q("select * from item_id where iid = %d",
intval($post_id)
);
build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true)),'item_id' => $rid));
build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true))));
}
}

View File

@ -90,13 +90,14 @@ class Layouts extends \Zotlabs\Web\Controller {
return;
}
//This feature is not exposed in redbasic ui since it is not clear why one would want to
//download a json encoded pdl file - we dont have a possibility to import it.
//Use the buildin share/install feature instead.
// This feature is not exposed in redbasic ui since it is not clear why one would want to
// download a json encoded pdl file - we dont have a possibility to import it.
// Use the buildin share/install feature instead.
if((argc() > 3) && (argv(2) === 'share') && (argv(3))) {
$r = q("select sid, service, mimetype, title, body from item_id
left join item on item.id = item_id.iid
where item_id.uid = %d and item.mid = '%s' and service = 'PDL' order by sid asc",
$r = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
left join item on item.id = iconfig.iid
where uid = %d and mid = '%s' and iconfig.cat = 'system' and iconfig.k = 'PDL' order by iconfig.v asc",
intval($owner),
dbesc(argv(3))
);
@ -141,8 +142,9 @@ class Layouts extends \Zotlabs\Web\Controller {
$editor = status_editor($a,$x);
$r = q("select iid, sid, mid, title, body, mimetype, created, edited, item_type from item_id left join item on item_id.iid = item.id
where item_id.uid = %d and service = 'PDL' and item_type = %d order by item.created desc",
$r = q("select iconfig.iid, iconfig.v, mid, title, body, mimetype, created, edited, item_type from iconfig
left join item on iconfig.iid = item.id
where uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' and item_type = %d order by item.created desc",
intval($owner),
intval(ITEM_TYPE_PDL)
);
@ -164,7 +166,7 @@ class Layouts extends \Zotlabs\Web\Controller {
);
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
'title' => $rr['sid'],
'title' => $rr['v'],
'descr' => $rr['title'],
'mid' => $rr['mid'],
'created' => $rr['created'],

View File

@ -65,9 +65,10 @@ class Page extends \Zotlabs\Web\Controller {
require_once('include/security.php');
$sql_options = item_permissions_sql($u[0]['channel_id']);
$r = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and item.item_delayed = 0 and (( service = 'WEBPAGE' and item_type = %d )
OR ( service = 'PDL' 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 item.item_delayed = 0
and (( iconfig.k = 'WEBPAGE' and item_type = %d )
OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
intval(ITEM_TYPE_WEBPAGE),
@ -77,9 +78,9 @@ class Page extends \Zotlabs\Web\Controller {
// Check again with no permissions clause to see if it is a permissions issue
$x = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid = '%s' and item.item_delayed = 0 and service = 'WEBPAGE' and
item_type = %d $revision limit 1",
$x = 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 item.item_delayed = 0
and iconfig.k = 'WEBPAGE' and item_type = %d $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
intval(ITEM_TYPE_WEBPAGE)
@ -120,9 +121,6 @@ class Page extends \Zotlabs\Web\Controller {
}
function get() {
$r = \App::$data['webpage'];

View File

@ -138,12 +138,20 @@ class Webpages extends \Zotlabs\Web\Controller {
$sql_extra = item_permissions_sql($owner);
$r = q("select * from item_id left join item on item_id.iid = item.id
where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc",
$r = q("select * from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d
$sql_extra order by item.created desc",
intval($owner),
intval(ITEM_TYPE_WEBPAGE)
);
// $r = q("select * from item_id left join item on item_id.iid = item.id
// where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc",
// intval($owner),
// intval(ITEM_TYPE_WEBPAGE)
// );
$pages = null;
if($r) {
@ -160,13 +168,13 @@ class Webpages extends \Zotlabs\Web\Controller {
'created' => $rr['created'],
'edited' => $rr['edited'],
'mimetype' => $rr['mimetype'],
'pagetitle' => $rr['sid'],
'pagetitle' => $rr['v'],
'mid' => $rr['mid'],
'layout_mid' => $rr['layout_mid']
);
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
'pagetitle' => $rr['sid'],
'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']),

View File

@ -179,7 +179,8 @@ class Comanche {
$channel_id = $this->get_channel_id();
if($channel_id) {
$r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1",
$r = q("select * from item inner join iconfig on iconfig.iid = item.id and item.uid = %d
and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK' and iconfig.v = '%s' limit 1",
intval($channel_id),
dbesc($name)
);
@ -282,12 +283,12 @@ class Comanche {
/**
* Widgets will have to get any operational arguments from the session, the
* global app environment, or config storage until we implement argument passing
* Render a widget
*
* @param string $name
* @param string $text
*/
function widget($name, $text) {
$vars = array();
$matches = array();
@ -314,7 +315,7 @@ class Comanche {
require_once(theme_include($theme_widget));
}
if (function_exists($func))
if(function_exists($func))
return $func($vars);
}

View File

@ -48,7 +48,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.9' );
define ( 'ZOT_REVISION', 1.1 );
define ( 'DB_UPDATE_VERSION', 1176 );
define ( 'DB_UPDATE_VERSION', 1177 );
/**

View File

@ -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'])

View File

@ -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">';

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}
}
}

View File

@ -3537,9 +3537,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 +4104,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) {

View File

@ -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']));
}
}

View File

@ -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_id.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>';
}
}

View File

@ -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 . '%'),

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1176 );
define( 'UPDATE_VERSION' , 1177 );
/**
*
@ -2254,3 +2254,16 @@ function update_r1175() {
return UPDATE_FAILED;
}
function update_r1176() {
$r = q("select * from item_id where true");
if($r) {
foreach($r as $rr) {
\Zotlabs\Lib\IConfig::Set($rr['iid'],'system',$rr['service'],$rr['sid'],true);
}
}
return UPDATE_SUCCESS;
}