diff options
author | zotlabs <mike@macgirvin.com> | 2017-03-16 17:11:48 -0700 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-03-29 12:02:09 +0200 |
commit | 0bad26e116499d9b656c28f64c81275df4bbecb6 (patch) | |
tree | a5a30a33e97db03bb7fdeb156045ba41205546e8 /Zotlabs/Widget/Item.php | |
parent | cd57483ed9069a26b52ae8d7d74fdc537da89946 (diff) | |
download | volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.gz volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.bz2 volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.zip |
the rest of the standard widgets converted
Diffstat (limited to 'Zotlabs/Widget/Item.php')
-rw-r--r-- | Zotlabs/Widget/Item.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Item.php b/Zotlabs/Widget/Item.php new file mode 100644 index 000000000..273d5649c --- /dev/null +++ b/Zotlabs/Widget/Item.php @@ -0,0 +1,54 @@ +<?php + +namespace Zotlabs\Widget; + +require_once('include/security.php'); + +class Item { + + function widget($arr) { + + $channel_id = 0; + if(array_key_exists('channel_id',$arr) && intval($arr['channel_id'])) + $channel_id = intval($arr['channel_id']); + if(! $channel_id) + $channel_id = \App::$profile_uid; + if(! $channel_id) + return ''; + + + if((! $arr['mid']) && (! $arr['title'])) + return ''; + + if(! perm_is_allowed($channel_id, get_observer_hash(), 'view_pages')) + return ''; + + $sql_extra = item_permissions_sql($channel_id); + + if($arr['title']) { + $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) + ); + } + else { + $r = q("select * from item where mid = '%s' and uid = %d and item_type = " + . intval(ITEM_TYPE_WEBPAGE) . " $sql_extra limit 1", + dbesc($arr['mid']), + intval($channel_id) + ); + } + + if(! $r) + return ''; + + xchan_query($r); + $r = fetch_post_tags($r, true); + + $o = prepare_page($r[0]); + return $o; + } +} |