From dfbe2eaf9856140de84f4d891fd442cdd6872545 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 20 Feb 2016 00:49:37 -0800 Subject: Revert "move accesslist class to namespace" This reverts commit a9711895cf254a0ca34b1e3f7c8e75bb832e6973. --- Zotlabs/Access/AccessList.php | 148 ------------------------------------------ boot.php | 2 +- include/AccessList.php | 148 ++++++++++++++++++++++++++++++++++++++++++ include/items.php | 2 +- include/menu.php | 4 +- include/photos.php | 2 +- mod/chat.php | 6 +- mod/cover_photo.php | 2 +- mod/events.php | 4 +- mod/filestorage.php | 2 +- mod/item.php | 2 +- mod/mitem.php | 2 +- mod/photos.php | 4 +- mod/rpost.php | 2 +- mod/settings.php | 4 +- mod/thing.php | 4 +- 16 files changed, 169 insertions(+), 169 deletions(-) delete mode 100644 Zotlabs/Access/AccessList.php create mode 100644 include/AccessList.php diff --git a/Zotlabs/Access/AccessList.php b/Zotlabs/Access/AccessList.php deleted file mode 100644 index bff7fad5e..000000000 --- a/Zotlabs/Access/AccessList.php +++ /dev/null @@ -1,148 +0,0 @@ -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; - } - - /** - * Set AccessList from strings such as those in already - * existing stored data items - */ - - 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; - } - - /** - * return an array consisting of the current - * access list components where the elements - * are directly storable. - */ - - function get() { - return array( - 'allow_cid' => $this->allow_cid, - 'allow_gid' => $this->allow_gid, - 'deny_cid' => $this->deny_cid, - 'deny_gid' => $this->deny_gid, - ); - } - - /** - * Set AccessList from arrays, such as those provided by - * acl_selector(). For convenience, a string (or non-array) input is - * assumed to be a comma-separated list and auto-converted into an array. - */ - - 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); - } - -} - -/** - * @brief Used to wrap ACL elements in angle brackets for storage. - * - * @param[in,out] array &$item - */ -function sanitise_acl(&$item) { - if (strlen($item)) - $item = '<' . notags(trim($item)) . '>'; - else - unset($item); -} - -/** - * @brief Convert an ACL array to a storable string. - * - * @param array $p - * @return array - */ -function perms2str($p) { - $ret = ''; - - if (is_array($p)) - $tmp = $p; - else - $tmp = explode(',', $p); - - if (is_array($tmp)) { - array_walk($tmp, 'sanitise_acl'); - $ret = implode('', $tmp); - } - - return $ret; -} - - -/** - * @brief Turn user/group ACLs stored as angle bracketed text into arrays. - * - * turn string array of angle-bracketed elements into string array - * e.g. "<123xyz><246qyo>" => array(123xyz,246qyo,sxo33e); - * - * @param string $s - * @return array - */ -function expand_acl($s) { - $ret = array(); - - if(strlen($s)) { - $t = str_replace('<','',$s); - $a = explode('>',$t); - foreach($a as $aa) { - if($aa) - $ret[] = $aa; - } - } - - return $ret; -} diff --git a/boot.php b/boot.php index 03d81b360..2dc542d28 100755 --- a/boot.php +++ b/boot.php @@ -43,7 +43,7 @@ require_once('include/taxonomy.php'); require_once('include/identity.php'); require_once('include/Contact.php'); require_once('include/account.php'); - +require_once('include/AccessList.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); diff --git a/include/AccessList.php b/include/AccessList.php new file mode 100644 index 000000000..43f1de111 --- /dev/null +++ b/include/AccessList.php @@ -0,0 +1,148 @@ +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; + } + + /** + * Set AccessList from strings such as those in already + * existing stored data items + */ + + 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; + } + + /** + * return an array consisting of the current + * access list components where the elements + * are directly storable. + */ + + function get() { + return array( + 'allow_cid' => $this->allow_cid, + 'allow_gid' => $this->allow_gid, + 'deny_cid' => $this->deny_cid, + 'deny_gid' => $this->deny_gid, + ); + } + + /** + * Set AccessList from arrays, such as those provided by + * acl_selector(). For convenience, a string (or non-array) input is + * assumed to be a comma-separated list and auto-converted into an array. + */ + + 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); + } + +} + +/** + * @brief Used to wrap ACL elements in angle brackets for storage. + * + * @param[in,out] array &$item + */ +function sanitise_acl(&$item) { + if (strlen($item)) + $item = '<' . notags(trim($item)) . '>'; + else + unset($item); +} + +/** + * @brief Convert an ACL array to a storable string. + * + * @param array $p + * @return array + */ +function perms2str($p) { + $ret = ''; + + if (is_array($p)) + $tmp = $p; + else + $tmp = explode(',', $p); + + if (is_array($tmp)) { + array_walk($tmp, 'sanitise_acl'); + $ret = implode('', $tmp); + } + + return $ret; +} + + +/** + * @brief Turn user/group ACLs stored as angle bracketed text into arrays. + * + * turn string array of angle-bracketed elements into string array + * e.g. "<123xyz><246qyo>" => array(123xyz,246qyo,sxo33e); + * + * @param string $s + * @return array + */ +function expand_acl($s) { + $ret = array(); + + if(strlen($s)) { + $t = str_replace('<','',$s); + $a = explode('>',$t); + foreach($a as $aa) { + if($aa) + $ret[] = $aa; + } + } + + return $ret; +} diff --git a/include/items.php b/include/items.php index ee69f90af..a9597c1cf 100755 --- a/include/items.php +++ b/include/items.php @@ -5440,7 +5440,7 @@ function send_profile_photo_activity($channel,$photo,$profile) { $arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext; - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $x = $acl->get(); $arr['allow_cid'] = $x['allow_cid']; diff --git a/include/menu.php b/include/menu.php index d90cefddb..075372515 100644 --- a/include/menu.php +++ b/include/menu.php @@ -299,7 +299,7 @@ function menu_add_item($menu_id, $uid, $arr) { $channel = get_app()->get_channel(); } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $acl->set_from_array($arr); $p = $acl->get(); @@ -340,7 +340,7 @@ function menu_edit_item($menu_id, $uid, $arr) { $channel = get_app()->get_channel(); } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $acl->set_from_array($arr); $p = $acl->get(); diff --git a/include/photos.php b/include/photos.php index 1a57ce76f..93511d2c0 100644 --- a/include/photos.php +++ b/include/photos.php @@ -48,7 +48,7 @@ function photo_upload($channel, $observer, $args) { // all other settings. 'allow_cid' being passed from an external source takes priority over channel settings. // ...messy... needs re-factoring once the photos/files integration stabilises - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); if(array_key_exists('directory',$args) && $args['directory']) $acl->set($args['directory']); if(array_key_exists('allow_cid',$args)) diff --git a/mod/chat.php b/mod/chat.php index f219bde73..79a5c050b 100644 --- a/mod/chat.php +++ b/mod/chat.php @@ -54,7 +54,7 @@ function chat_post(&$a) { goaway(z_root() . '/chat/' . $channel['channel_address']); } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $acl->set_from_array($_REQUEST); $arr = $acl->get(); @@ -162,7 +162,7 @@ function chat_content(&$a) { intval($a->profile['profile_uid']) ); if($x) { - $acl = new Zotlabs\Access\AccessList(false); + $acl = new AccessList(false); $acl->set($x[0]); $private = $acl->is_private(); @@ -199,7 +199,7 @@ function chat_content(&$a) { if(local_channel() && argc() > 2 && argv(2) === 'new') { - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $channel_acl = $acl->get(); require_once('include/acl_selectors.php'); diff --git a/mod/cover_photo.php b/mod/cover_photo.php index 9c99859ea..de11857b0 100644 --- a/mod/cover_photo.php +++ b/mod/cover_photo.php @@ -239,7 +239,7 @@ function send_cover_photo_activity($channel,$photo,$profile) { $arr['body'] = sprintf($t,$channel['channel_name'],$ptext) . "\n\n" . $ltext; - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $x = $acl->get(); $arr['allow_cid'] = $x['allow_cid']; diff --git a/mod/events.php b/mod/events.php index b07ffa184..ed9f0f2e3 100755 --- a/mod/events.php +++ b/mod/events.php @@ -118,7 +118,7 @@ function events_post(&$a) { $channel = $a->get_channel(); - $acl = new Zotlabs\Access\AccessList(false); + $acl = new AccessList(false); if($event_id) { $x = q("select * from event where id = %d and uid = %d limit 1", @@ -422,7 +422,7 @@ function events_content(&$a) { require_once('include/acl_selectors.php'); - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $perm_defaults = $acl->get(); $tpl = get_markup_template('event_form.tpl'); diff --git a/mod/filestorage.php b/mod/filestorage.php index 753300e89..7ba8c1801 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -30,7 +30,7 @@ function filestorage_post(&$a) { $channel = $a->get_channel(); - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $acl->set_from_array($_REQUEST); $x = $acl->get(); diff --git a/mod/item.php b/mod/item.php index f23bff3ac..d861967a9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -310,7 +310,7 @@ function item_post(&$a) { } } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true)); diff --git a/mod/mitem.php b/mod/mitem.php index 7f582c649..d6572bd56 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -127,7 +127,7 @@ function mitem_content(&$a) { $menu_names[] = $menus['menu_name']; } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'); diff --git a/mod/photos.php b/mod/photos.php index 8f44f01b2..944686637 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -85,7 +85,7 @@ function photos_post(&$a) { $owner_record = $s[0]; - $acl = new Zotlabs\Access\AccessList($a->data['channel']); + $acl = new AccessList($a->data['channel']); if((argc() > 3) && (argv(2) === 'album')) { @@ -595,7 +595,7 @@ function photos_content(&$a) { if($_is_owner) { $channel = $a->get_channel(); - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $channel_acl = $acl->get(); $lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); diff --git a/mod/rpost.php b/mod/rpost.php index 915b1ca96..ab5ef4ccd 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -95,7 +95,7 @@ function rpost_content(&$a) { $channel = $a->get_channel(); - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $channel_acl = $acl->get(); diff --git a/mod/settings.php b/mod/settings.php index a6655f46a..2f90b037f 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -323,7 +323,7 @@ function settings_post(&$a) { foreach($global_perms as $k => $v) { $set_perms .= ', ' . $v[0] . ' = ' . intval($_POST[$k]) . ' '; } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $acl->set_from_array($_POST); $x = $acl->get(); @@ -1002,7 +1002,7 @@ function settings_content(&$a) { $stpl = get_markup_template('settings.tpl'); - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $perm_defaults = $acl->get(); require_once('include/group.php'); diff --git a/mod/thing.php b/mod/thing.php index 7e7d1bdc7..7c5020e62 100644 --- a/mod/thing.php +++ b/mod/thing.php @@ -65,7 +65,7 @@ function thing_init(&$a) { if((! $name) || (! $translated_verb)) return; - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); if(array_key_exists('contact_allow',$_REQUEST) || array_key_exists('group_allow',$_REQUEST) @@ -271,7 +271,7 @@ function thing_content(&$a) { return; } - $acl = new Zotlabs\Access\AccessList($channel); + $acl = new AccessList($channel); $channel_acl = $acl->get(); $lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); -- cgit v1.2.3