start conversion to AccessList object

This commit is contained in:
redmatrix 2015-08-27 21:22:59 -07:00
parent 04b4897dd8
commit 3fbb955cf2
3 changed files with 20 additions and 25 deletions

View File

@ -10,8 +10,7 @@ class AccessList {
private $explicit;
function _construct($channel) {
function __construct($channel) {
if($channel) {
$this->allow_cid = $channel['channel_allow_cid'];

View File

@ -2,6 +2,7 @@
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/AccessList.php');
function menu_fetch($name,$uid,$observer_xchan) {
@ -299,19 +300,18 @@ function menu_add_item($menu_id, $uid, $arr) {
$channel = get_app()->get_channel();
}
$str_group_allow = perms2str($arr['group_allow']);
$str_contact_allow = perms2str($arr['contact_allow']);
$str_group_deny = perms2str($arr['group_deny']);
$str_contact_deny = perms2str($arr['contact_deny']);
$acl = new AccessList($channel);
$acl->set_from_array($arr);
$p = $acl->get();
$r = q("insert into menu_item ( mitem_link, mitem_desc, mitem_flags, allow_cid, allow_gid, deny_cid, deny_gid, mitem_channel_id, mitem_menu_id, mitem_order ) values ( '%s', '%s', %d, '%s', '%s', '%s', '%s', %d, %d, %d ) ",
dbesc($mitem_link),
dbesc($mitem_desc),
intval($mitem_flags),
dbesc($str_contact_allow),
dbesc($str_group_allow),
dbesc($str_contact_deny),
dbesc($str_group_deny),
dbesc($p['allow_cid']),
dbesc($p['allow_gid']),
dbesc($p['deny_cid']),
dbesc($p['deny_gid']),
intval($uid),
intval($menu_id),
intval($mitem_order)
@ -341,19 +341,19 @@ function menu_edit_item($menu_id, $uid, $arr) {
$channel = get_app()->get_channel();
}
$str_group_allow = perms2str($arr['group_allow']);
$str_contact_allow = perms2str($arr['contact_allow']);
$str_group_deny = perms2str($arr['group_deny']);
$str_contact_deny = perms2str($arr['contact_deny']);
$acl = new AccessList($channel);
$acl->set_from_array($arr);
$p = $acl->get();
$r = q("update menu_item set mitem_link = '%s', mitem_desc = '%s', mitem_flags = %d, allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', mitem_order = %d where mitem_channel_id = %d and mitem_menu_id = %d and mitem_id = %d",
dbesc($mitem_link),
dbesc($mitem_desc),
intval($mitem_flags),
dbesc($str_contact_allow),
dbesc($str_group_allow),
dbesc($str_contact_deny),
dbesc($str_group_deny),
dbesc($p['allow_cid']),
dbesc($p['allow_gid']),
dbesc($p['deny_cid']),
dbesc($p['deny_gid']),
intval($mitem_order),
intval($uid),
intval($menu_id),

View File

@ -2,6 +2,7 @@
require_once('include/menu.php');
require_once('include/acl_selectors.php');
require_once('include/AccessList.php');
function mitem_init(&$a) {
@ -125,12 +126,7 @@ function mitem_content(&$a) {
$menu_names[] = $menus['menu_name'];
}
$perm_defaults = array(
'allow_cid' => $channel['channel_allow_cid'],
'allow_gid' => $channel['channel_allow_gid'],
'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid']
);
$acl = new AccessList($channel);
$lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock');
@ -151,7 +147,7 @@ function mitem_content(&$a) {
'$menu_id' => $a->data['menu']['menu_id'],
'$permissions' => t('Menu Item Permissions'),
'$permdesc' => t("\x28click to open/close\x29"),
'$aclselect' => populate_acl($perm_defaults,false),
'$aclselect' => populate_acl($acl->get(),false),
'$mitem_desc' => array('mitem_desc', t('Link Name'), '', 'Visible name of the link','*'),
'$mitem_link' => array('mitem_link', t('Link or Submenu Target'), '', t('Enter URL of the link or select a menu name to create a submenu'), '*', 'list="menu-names"'),
'$usezid' => array('usezid', t('Use magic-auth if available'), true, '', array(t('No'), t('Yes'))),