First attempt to turn access control into an object class. The access control manipulation is getting too complex and this will help keep it manageable and reduce a lot of code duplication.
This commit is contained in:
parent
c2bc6a04ab
commit
04b4897dd8
72
include/AccessList.php
Normal file
72
include/AccessList.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class AccessList {
|
||||||
|
|
||||||
|
private $allow_cid;
|
||||||
|
private $allow_gid;
|
||||||
|
private $deny_cid;
|
||||||
|
private $deny_gid;
|
||||||
|
|
||||||
|
private $explicit;
|
||||||
|
|
||||||
|
|
||||||
|
function _construct($channel) {
|
||||||
|
|
||||||
|
if($channel) {
|
||||||
|
$this->allow_cid = $channel['channel_allow_cid'];
|
||||||
|
$this->allow_gid = $channel['channel_allow_gid'];
|
||||||
|
$this->deny_cid = $channel['channel_deny_cid'];
|
||||||
|
$this->deny_gid = $channel['channel_deny_gid'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->allow_cid = '';
|
||||||
|
$this->allow_gid = '';
|
||||||
|
$this->deny_cid = '';
|
||||||
|
$this->deny_gid = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->explicit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_explicit() {
|
||||||
|
return $this->explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set($arr,$explicit = true) {
|
||||||
|
$this->allow_cid = $arr['allow_cid'];
|
||||||
|
$this->allow_gid = $arr['allow_gid'];
|
||||||
|
$this->deny_cid = $arr['deny_cid'];
|
||||||
|
$this->deny_gid = $arr['deny_gid'];
|
||||||
|
|
||||||
|
$this->explicit = $explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
return array(
|
||||||
|
'allow_cid' => $this->allow_cid,
|
||||||
|
'allow_gid' => $this->allow_gid,
|
||||||
|
'deny_cid' => $this->deny_cid,
|
||||||
|
'deny_gid' => $this->deny_gid,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_from_array($arr,$explicit = true) {
|
||||||
|
$this->allow_cid = perms2str((is_array($arr['contact_allow']))
|
||||||
|
? $arr['contact_allow'] : explode(',',$arr['contact_allow']));
|
||||||
|
$this->allow_gid = perms2str((is_array($arr['group_allow']))
|
||||||
|
? $arr['group_allow'] : explode(',',$arr['group_allow']));
|
||||||
|
$this->deny_cid = perms2str((is_array($arr['contact_deny']))
|
||||||
|
? $arr['contact_deny'] : explode(',',$arr['contact_deny']));
|
||||||
|
$this->deny_gid = perms2str((is_array($arr['group_deny']))
|
||||||
|
? $arr['group_deny'] : explode(',',$arr['group_deny']));
|
||||||
|
|
||||||
|
$this->explicit = $explicit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_private() {
|
||||||
|
return (($this->allow_cid || $this->allow_gid || $this->deny_cid || $this->deny_gid) ? true : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@ require_once('include/crypto.php');
|
|||||||
require_once('include/enotify.php');
|
require_once('include/enotify.php');
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
require_once('include/attach.php');
|
require_once('include/attach.php');
|
||||||
|
require_once('include/AccessList.php');
|
||||||
|
|
||||||
function item_post(&$a) {
|
function item_post(&$a) {
|
||||||
|
|
||||||
@ -305,6 +306,8 @@ function item_post(&$a) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ACL = new AccessList($channel);
|
||||||
|
|
||||||
|
|
||||||
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
|
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
|
||||||
if($webpage)
|
if($webpage)
|
||||||
|
Reference in New Issue
Block a user