diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2016-02-24 17:44:27 +0100 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2016-02-24 17:44:27 +0100 |
commit | ddeab48f9b314eed067c31086945acee33964d37 (patch) | |
tree | a814d6244991017af57ea03670d45d9ca1286cc0 /include/text.php | |
parent | cc264b2d60049a844fe17322fbcb367712a7071f (diff) | |
parent | 039eb585240a5fa106ede00a055036458a4f5393 (diff) | |
download | volse-hubzilla-ddeab48f9b314eed067c31086945acee33964d37.tar.gz volse-hubzilla-ddeab48f9b314eed067c31086945acee33964d37.tar.bz2 volse-hubzilla-ddeab48f9b314eed067c31086945acee33964d37.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php index f6fa1c304..6b074d390 100644 --- a/include/text.php +++ b/include/text.php @@ -2728,3 +2728,63 @@ function item_url_replace($channel,&$item,$old,$new) { // @fixme item['plink'] and item['llink'] } + + +/** + * @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><sxo33e>" => 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; +} |