Revision [16719]
This is an old revision of GroupManagement made by OcsVez on 2007-05-31 10:41:13.
Group-Management
thanks for the kind permission given by VictorManuelVarela victor manuel varela, who achieved the basic concept.the following changes have been made to the wakkaaliases:
- the original is split into two functions. the assembling of the groups array only needs to be done once and not every time hasaccess() is called.
- since groups can contain other groups, again circular statements have to be blocked.
- items are now comma delimited. it's far more readable in the wikka.config.php and the new line (which was the delimiter before) didn't even give any advantage in coding.
the following functions are new to the wakka class:
%%(php)<?
aliases stuff, written by http://www.nivel0.net/VictorManuelVarela/
function BuildAliasesArray () {
if (! is_array($this->config['aliases'])) $this->config['aliases'] = array (' ' => $this->config['aliases']);
check for aliases in Wakka pages
if (isset($this->config['aliases'][' '])) {
$aliasPages = explode(",", $this->config['aliases'][' ']);
for ($i = count($aliasPages)-1; $i >= 0; $i--) { any idea why the last page should be included first?
$aliasPage = $this->LoadPage($aliasPages[$i]);
foreach (explode("\n", $aliasPage['body']) as $line) {
stripping comments
if (preg_match("/^(.*)?#/", $line, $matches)) $line = $matches[1];
$atmp = explode(':',$line);
$aliases[trim($atmp[0])] = trim($atmp[1]);
}
}
$this->config['aliases'] = array_merge($this->config['aliases'], $aliases);
unset($this->config['aliases'][' ']);
unset($this->config['aliases'][]);
}
}function ReplaceAliases ($acl) {
if (!$this->config['aliases']) return $acl;
$list = array();
$new_acl = ;
foreach (explode("\n", $acl) as $line) {
$line = trim($line);
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches)) {
$negate = "!";
$line = trim($matches[1]);
} else $negate = ;
if ($this->config["aliases"][$line]) $list = $this->GetMembers($line); else $list[] = $line;
$new_acl .= $negate.join("\n".$negate, $list)."\n";
}
return $new_acl;
}function GetMembers($group) {
$result = array();
if ($group