Revision history for GroupManagement
Revision [23278]
Last edited on 2016-05-20 07:38:47 by JavaWoman [Replaces old-style internal links with new pipe-split links.]Additions:
thanks for the kind permission given by [[VictorManuelVarela | victor manuel varela]], who achieved the [[http://www.wakkawiki.com/WakkaAliases | basic concept]].
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 | see diff for changes]], codebase is wikka 1.1.3.8)
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 | see diff for changes]], codebase is wikka 1.1.3.8)
Deletions:
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
Revision [19305]
Edited on 2008-01-28 00:14:45 by JavaWoman [Modified links pointing to docs server]No Differences
Revision [17238]
Edited on 2007-07-07 16:30:07 by JavaWoman [ links for wakkawiki.com (not wakkawiki.de)]Additions:
thanks for the kind permission given by [[VictorManuelVarela victor manuel varela]], who achieved the [[http://www.wakkawiki.com/WakkaAliases basic concept]].
the following changes have been made to the ""WakkaAliases"":
the following changes have been made to the ""WakkaAliases"":
Deletions:
the following changes have been made to the wakkaaliases:
Additions:
if (! is_array($this->config['aliases'])) $this->config['aliases'] = array ('+' => $this->config['aliases']);
if (isset($this->config['aliases']['+'])) {
$aliasPages = explode(",", $this->config['aliases']['+']);
unset($this->config['aliases']['+']);
if ($group && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
// old: foreach (explode (',', $current) as $item) $list[] = trim($item);
foreach (explode (',', $groups[$line]) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
$result = $list;
} while ($replaced);
return array_unique($result);
function IsMember($group, $user = "") {
if (!$user) $user = $this->GetUserName();
if (in_array($user, $this->GetMembers($group))) return true;
?>%%
~&Changed the GetMembers function because it didn't work for me. I think $current is not correct here. --DudeliDumidi
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
function Run($tag, $method = "")
{
// do our stuff!
if (!$this->method = trim($method)) $this->method = "show";
if (!$this->tag = trim($tag)) $this->Redirect($this->href("", $this->config["root_page"]));
$this->BuildAliasesArray();
if ((!$this->GetUser() && isset($_COOKIE["name"])) && ($user = $this->LoadUser($_COOKIE["name"], $_COOKIE["password"]))) $this->SetUser($user);
$this->SetPage($this->LoadPage($tag, (isset($_REQUEST["time"]) ? $_REQUEST["time"] :'')));
$this->LogReferrer();
$this->ACLs = $this->LoadAllACLs($this->tag);
$this->ReadInterWikiConfig();
if(!($this->GetMicroTime()%3)) $this->Maintenance();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
{
print($this->Method($this->method));
elseif (preg_match('/\.(gif|jpg|png)$/', $this->method))
{
header('Location: images/' . $this->method);
elseif (preg_match('/\.css$/', $this->method))
{
header('Location: css/' . $this->method);
else
{
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
print($this->Header().$this->Method($this->method).$this->Footer());
?>%%
the second one every time, the hasaccess() function needs an acl list
function HasAccess($privilege, $tag = "", $user = "")
{
// set defaults
if (!$tag) $tag = $this->GetPageTag();
if (!$user) $user = $this->GetUserName();
// if current user is owner, return true. owner can do anything!
if ($this->UserIsOwner($tag)) return true;
// see whether user is registered and logged in
if ($this->GetUser()) $registered = true;
// load acl
if ($tag == $this->GetPageTag())
{
$acl = $this->ACLs[$privilege."_acl"];
else
{
$tag_ACLs = $this->LoadAllACLs($tag);
$acl = $tag_ACLs[$privilege."_acl"];
// replace group names with the respective member list
$acl = $this->ReplaceAliases($acl);
// fine fine... now go through acl
foreach (explode("\n", $acl) as $line)
{
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches))
{
$negate = 1;
$line = $matches[1];
else
{
$negate = 0;
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
// if there's still anything left... lines with just a "!" don't count!
if ($line)
{
switch ($line[0])
{
// everyone
case "*":
return !$negate;
// only registered users
case "+":
// return ($registered) ? !$negate : false;
return ($registered) ? !$negate : $negate;
// aha! a user entry.
default:
if ($line == $user)
{
return !$negate;
}
}
// tough luck.
return false;
?>%%
now we can hook in the isAdmin() function (**caution:** wikka then expects a group in $wakka->config["admins"]!):
function IsAdmin() { return $this->IsMember($this->config["admins"]); }
?>%%
and the wikka.config.php yet needs to be adjusted
'aliases' => array
('Administrators' => 'BillGates,JoseMariaAznar,GeorgeBush',
'DangerousPeople' => 'Administrators,DreckFehler',
'+' => 'WikkaGroups,MoreWikkaGroups'),
'admins' => 'Administrators',
?>%%
if the variable $wakka->config['aliases'] contains a **string** instead of an array, it is treated as a list of wikipages which maintain the group handling. in that case one of the pages should contain a group named "Administrators" (or whatever is defined in the config['admins'] variable). but to my understanding it's better for security reasons to leave the admin group in the config file (if not, make sure to restrict at least write access to the page that defines the admin group ;))
%%(php)<? 'aliases' => 'WikkaSystemGroups,WikkaGroups', ?>%%
a definition in a wikipage looks like this (whoever those spanish guys may be):
%%Superusers: ManoloCortes,PedroTriguero,JoseVera
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Check it at ACLsWithUserGroups --ChristianBarthelemy
----
CategoryUserContributions
if (isset($this->config['aliases']['+'])) {
$aliasPages = explode(",", $this->config['aliases']['+']);
unset($this->config['aliases']['+']);
if ($group && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
// old: foreach (explode (',', $current) as $item) $list[] = trim($item);
foreach (explode (',', $groups[$line]) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
$result = $list;
} while ($replaced);
return array_unique($result);
function IsMember($group, $user = "") {
if (!$user) $user = $this->GetUserName();
if (in_array($user, $this->GetMembers($group))) return true;
?>%%
~&Changed the GetMembers function because it didn't work for me. I think $current is not correct here. --DudeliDumidi
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
function Run($tag, $method = "")
{
// do our stuff!
if (!$this->method = trim($method)) $this->method = "show";
if (!$this->tag = trim($tag)) $this->Redirect($this->href("", $this->config["root_page"]));
$this->BuildAliasesArray();
if ((!$this->GetUser() && isset($_COOKIE["name"])) && ($user = $this->LoadUser($_COOKIE["name"], $_COOKIE["password"]))) $this->SetUser($user);
$this->SetPage($this->LoadPage($tag, (isset($_REQUEST["time"]) ? $_REQUEST["time"] :'')));
$this->LogReferrer();
$this->ACLs = $this->LoadAllACLs($this->tag);
$this->ReadInterWikiConfig();
if(!($this->GetMicroTime()%3)) $this->Maintenance();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
{
print($this->Method($this->method));
elseif (preg_match('/\.(gif|jpg|png)$/', $this->method))
{
header('Location: images/' . $this->method);
elseif (preg_match('/\.css$/', $this->method))
{
header('Location: css/' . $this->method);
else
{
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
print($this->Header().$this->Method($this->method).$this->Footer());
?>%%
the second one every time, the hasaccess() function needs an acl list
function HasAccess($privilege, $tag = "", $user = "")
{
// set defaults
if (!$tag) $tag = $this->GetPageTag();
if (!$user) $user = $this->GetUserName();
// if current user is owner, return true. owner can do anything!
if ($this->UserIsOwner($tag)) return true;
// see whether user is registered and logged in
if ($this->GetUser()) $registered = true;
// load acl
if ($tag == $this->GetPageTag())
{
$acl = $this->ACLs[$privilege."_acl"];
else
{
$tag_ACLs = $this->LoadAllACLs($tag);
$acl = $tag_ACLs[$privilege."_acl"];
// replace group names with the respective member list
$acl = $this->ReplaceAliases($acl);
// fine fine... now go through acl
foreach (explode("\n", $acl) as $line)
{
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches))
{
$negate = 1;
$line = $matches[1];
else
{
$negate = 0;
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
// if there's still anything left... lines with just a "!" don't count!
if ($line)
{
switch ($line[0])
{
// everyone
case "*":
return !$negate;
// only registered users
case "+":
// return ($registered) ? !$negate : false;
return ($registered) ? !$negate : $negate;
// aha! a user entry.
default:
if ($line == $user)
{
return !$negate;
}
}
// tough luck.
return false;
?>%%
now we can hook in the isAdmin() function (**caution:** wikka then expects a group in $wakka->config["admins"]!):
function IsAdmin() { return $this->IsMember($this->config["admins"]); }
?>%%
and the wikka.config.php yet needs to be adjusted
'aliases' => array
('Administrators' => 'BillGates,JoseMariaAznar,GeorgeBush',
'DangerousPeople' => 'Administrators,DreckFehler',
'+' => 'WikkaGroups,MoreWikkaGroups'),
'admins' => 'Administrators',
?>%%
if the variable $wakka->config['aliases'] contains a **string** instead of an array, it is treated as a list of wikipages which maintain the group handling. in that case one of the pages should contain a group named "Administrators" (or whatever is defined in the config['admins'] variable). but to my understanding it's better for security reasons to leave the admin group in the config file (if not, make sure to restrict at least write access to the page that defines the admin group ;))
%%(php)<? 'aliases' => 'WikkaSystemGroups,WikkaGroups', ?>%%
a definition in a wikipage looks like this (whoever those spanish guys may be):
%%Superusers: ManoloCortes,PedroTriguero,JoseVera
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Check it at ACLsWithUserGroups --ChristianBarthelemy
----
CategoryUserContributions
Deletions:
if (isset($this->config['aliases'][' '])) {
$aliasPages = explode(",", $this->config['aliases'][' ']);
unset($this->config['aliases'][' ']);
if ($group
Additions:
if (! is_array($this->config['aliases'])) $this->config['aliases'] = array (' ' => $this->config['aliases']);
if (isset($this->config['aliases'][' '])) {
$aliasPages = explode(",", $this->config['aliases'][' ']);
unset($this->config['aliases'][' ']);
if ($group
if (isset($this->config['aliases'][' '])) {
$aliasPages = explode(",", $this->config['aliases'][' ']);
unset($this->config['aliases'][' ']);
if ($group
Deletions:
if (isset($this->config['aliases']['+'])) {
$aliasPages = explode(",", $this->config['aliases']['+']);
unset($this->config['aliases']['+']);
if ($group && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
// old: foreach (explode (',', $current) as $item) $list[] = trim($item);
foreach (explode (',', $groups[$line]) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
$result = $list;
} while ($replaced);
return array_unique($result);
function IsMember($group, $user = "") {
if (!$user) $user = $this->GetUserName();
if (in_array($user, $this->GetMembers($group))) return true;
?>%%
~&Changed the GetMembers function because it didn't work for me. I think $current is not correct here. --DudeliDumidi
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
function Run($tag, $method = "")
{
// do our stuff!
if (!$this->method = trim($method)) $this->method = "show";
if (!$this->tag = trim($tag)) $this->Redirect($this->href("", $this->config["root_page"]));
$this->BuildAliasesArray();
if ((!$this->GetUser() && isset($_COOKIE["name"])) && ($user = $this->LoadUser($_COOKIE["name"], $_COOKIE["password"]))) $this->SetUser($user);
$this->SetPage($this->LoadPage($tag, (isset($_REQUEST["time"]) ? $_REQUEST["time"] :'')));
$this->LogReferrer();
$this->ACLs = $this->LoadAllACLs($this->tag);
$this->ReadInterWikiConfig();
if(!($this->GetMicroTime()%3)) $this->Maintenance();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
{
print($this->Method($this->method));
elseif (preg_match('/\.(gif|jpg|png)$/', $this->method))
{
header('Location: images/' . $this->method);
elseif (preg_match('/\.css$/', $this->method))
{
header('Location: css/' . $this->method);
else
{
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
print($this->Header().$this->Method($this->method).$this->Footer());
?>%%
the second one every time, the hasaccess() function needs an acl list
function HasAccess($privilege, $tag = "", $user = "")
{
// set defaults
if (!$tag) $tag = $this->GetPageTag();
if (!$user) $user = $this->GetUserName();
// if current user is owner, return true. owner can do anything!
if ($this->UserIsOwner($tag)) return true;
// see whether user is registered and logged in
if ($this->GetUser()) $registered = true;
// load acl
if ($tag == $this->GetPageTag())
{
$acl = $this->ACLs[$privilege."_acl"];
else
{
$tag_ACLs = $this->LoadAllACLs($tag);
$acl = $tag_ACLs[$privilege."_acl"];
// replace group names with the respective member list
$acl = $this->ReplaceAliases($acl);
// fine fine... now go through acl
foreach (explode("\n", $acl) as $line)
{
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches))
{
$negate = 1;
$line = $matches[1];
else
{
$negate = 0;
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
// if there's still anything left... lines with just a "!" don't count!
if ($line)
{
switch ($line[0])
{
// everyone
case "*":
return !$negate;
// only registered users
case "+":
// return ($registered) ? !$negate : false;
return ($registered) ? !$negate : $negate;
// aha! a user entry.
default:
if ($line == $user)
{
return !$negate;
}
}
// tough luck.
return false;
?>%%
now we can hook in the isAdmin() function (**caution:** wikka then expects a group in $wakka->config["admins"]!):
function IsAdmin() { return $this->IsMember($this->config["admins"]); }
?>%%
and the wikka.config.php yet needs to be adjusted
'aliases' => array
('Administrators' => 'BillGates,JoseMariaAznar,GeorgeBush',
'DangerousPeople' => 'Administrators,DreckFehler',
'+' => 'WikkaGroups,MoreWikkaGroups'),
'admins' => 'Administrators',
?>%%
if the variable $wakka->config['aliases'] contains a **string** instead of an array, it is treated as a list of wikipages which maintain the group handling. in that case one of the pages should contain a group named "Administrators" (or whatever is defined in the config['admins'] variable). but to my understanding it's better for security reasons to leave the admin group in the config file (if not, make sure to restrict at least write access to the page that defines the admin group ;))
%%(php)<? 'aliases' => 'WikkaSystemGroups,WikkaGroups', ?>%%
a definition in a wikipage looks like this (whoever those spanish guys may be):
%%Superusers: ManoloCortes,PedroTriguero,JoseVera
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Check it at ACLsWithUserGroups --ChristianBarthelemy
----
CategoryUserContributions
Revision [13745]
Edited on 2006-04-06 08:37:07 by DudeliDumidi [I see, many edits today: another bugfix]Additions:
$acl = $this->ReplaceAliases($acl);
Deletions:
Revision [13739]
Edited on 2006-04-06 06:05:36 by DudeliDumidi [Forgot to correct the other two errors]Additions:
$this->BuildAliasesArray();
$acl["list"] = $this->ReplaceAliases($acl["list"]);
$acl["list"] = $this->ReplaceAliases($acl["list"]);
Deletions:
$acl["list"] = $this->ReplaceGroups($acl["list"]);
Revision [13738]
Edited on 2006-04-06 06:04:20 by DudeliDumidi [Typo? corrected in BuildAliasesArray]Additions:
if (preg_match("/^(.*)?#/", $line, $matches)) $line = $matches[1];
Deletions:
Revision [13737]
Edited on 2006-04-06 06:01:52 by DudeliDumidi [Typo? corrected in BuildAliasesArray]Additions:
~&Changed the GetMembers function because it didn't work for me. I think $current is not correct here. --DudeliDumidi
Deletions:
Revision [13736]
Edited on 2006-04-06 06:01:28 by DudeliDumidi [Typo? corrected in BuildAliasesArray]Additions:
// old: foreach (explode (',', $current) as $item) $list[] = trim($item);
foreach (explode (',', $groups[$line]) as $item) $list[] = trim($item);
~&Changed the GetMembers function because it didn't work for me. I think $current is not correct here. --DudeliDumdi
foreach (explode (',', $groups[$line]) as $item) $list[] = trim($item);
~&Changed the GetMembers function because it didn't work for me. I think $current is not correct here. --DudeliDumdi
Deletions:
Additions:
Check it at ACLsWithUserGroups --ChristianBarthelemy
Deletions:
Additions:
=====Group-Management=====
thanks for the kind permission given by [[VictorManuelVarela victor manuel varela]], who achieved the [[WakkaWiki:WakkaAliases 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 && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
foreach (explode (',', $current) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
}
$result = $list;
} while ($replaced);
}
return array_unique($result);
}
function IsMember($group, $user = "") {
if (!$user) $user = $this->GetUserName();
if (in_array($user, $this->GetMembers($group))) return true;
}
?>%%
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
%%(php)<?
function Run($tag, $method = "")
{
// do our stuff!
if (!$this->method = trim($method)) $this->method = "show";
if (!$this->tag = trim($tag)) $this->Redirect($this->href("", $this->config["root_page"]));
$this->BuildGroupsArray();
if ((!$this->GetUser() && isset($_COOKIE["name"])) && ($user = $this->LoadUser($_COOKIE["name"], $_COOKIE["password"]))) $this->SetUser($user);
$this->SetPage($this->LoadPage($tag, (isset($_REQUEST["time"]) ? $_REQUEST["time"] :'')));
$this->LogReferrer();
$this->ACLs = $this->LoadAllACLs($this->tag);
$this->ReadInterWikiConfig();
if(!($this->GetMicroTime()%3)) $this->Maintenance();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
{
print($this->Method($this->method));
}
elseif (preg_match('/\.(gif|jpg|png)$/', $this->method))
{
header('Location: images/' . $this->method);
}
elseif (preg_match('/\.css$/', $this->method))
{
header('Location: css/' . $this->method);
}
else
{
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
print($this->Header().$this->Method($this->method).$this->Footer());
}
}
?>%%
the second one every time, the hasaccess() function needs an acl list
%%(php)<?
function HasAccess($privilege, $tag = "", $user = "")
{
// set defaults
if (!$tag) $tag = $this->GetPageTag();
if (!$user) $user = $this->GetUserName();
// if current user is owner, return true. owner can do anything!
if ($this->UserIsOwner($tag)) return true;
// see whether user is registered and logged in
if ($this->GetUser()) $registered = true;
// load acl
if ($tag == $this->GetPageTag())
{
$acl = $this->ACLs[$privilege."_acl"];
}
else
{
$tag_ACLs = $this->LoadAllACLs($tag);
$acl = $tag_ACLs[$privilege."_acl"];
}
// replace group names with the respective member list
$acl["list"] = $this->ReplaceGroups($acl["list"]);
// fine fine... now go through acl
foreach (explode("\n", $acl) as $line)
{
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches))
{
$negate = 1;
$line = $matches[1];
}
else
{
$negate = 0;
}
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
// if there's still anything left... lines with just a "!" don't count!
if ($line)
{
switch ($line[0])
{
// everyone
case "*":
return !$negate;
// only registered users
case "+":
// return ($registered) ? !$negate : false;
return ($registered) ? !$negate : $negate;
// aha! a user entry.
default:
if ($line == $user)
{
return !$negate;
}
}
}
}
// tough luck.
return false;
}
?>%%
now we can hook in the isAdmin() function (**caution:** wikka then expects a group in $wakka->config["admins"]!):
%%(php)<?
function IsAdmin() { return $this->IsMember($this->config["admins"]); }
?>%%
and the wikka.config.php yet needs to be adjusted
%%(php)<?
'aliases' => array
('Administrators' => 'BillGates,JoseMariaAznar,GeorgeBush',
'DangerousPeople' => 'Administrators,DreckFehler',
'+' => 'WikkaGroups,MoreWikkaGroups'),
'admins' => 'Administrators',
?>%%
if the variable $wakka->config['aliases'] contains a **string** instead of an array, it is treated as a list of wikipages which maintain the group handling. in that case one of the pages should contain a group named "Administrators" (or whatever is defined in the config['admins'] variable). but to my understanding it's better for security reasons to leave the admin group in the config file (if not, make sure to restrict at least write access to the page that defines the admin group ;))
%%(php)<? 'aliases' => 'WikkaSystemGroups,WikkaGroups', ?>%%
a definition in a wikipage looks like this (whoever those spanish guys may be):
%%Superusers: ManoloCortes,PedroTriguero,JoseVera
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Check it at ACLsWithUserGroups
----
thanks for the kind permission given by [[VictorManuelVarela victor manuel varela]], who achieved the [[WakkaWiki:WakkaAliases 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 && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
foreach (explode (',', $current) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
}
$result = $list;
} while ($replaced);
}
return array_unique($result);
}
function IsMember($group, $user = "") {
if (!$user) $user = $this->GetUserName();
if (in_array($user, $this->GetMembers($group))) return true;
}
?>%%
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
%%(php)<?
function Run($tag, $method = "")
{
// do our stuff!
if (!$this->method = trim($method)) $this->method = "show";
if (!$this->tag = trim($tag)) $this->Redirect($this->href("", $this->config["root_page"]));
$this->BuildGroupsArray();
if ((!$this->GetUser() && isset($_COOKIE["name"])) && ($user = $this->LoadUser($_COOKIE["name"], $_COOKIE["password"]))) $this->SetUser($user);
$this->SetPage($this->LoadPage($tag, (isset($_REQUEST["time"]) ? $_REQUEST["time"] :'')));
$this->LogReferrer();
$this->ACLs = $this->LoadAllACLs($this->tag);
$this->ReadInterWikiConfig();
if(!($this->GetMicroTime()%3)) $this->Maintenance();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
{
print($this->Method($this->method));
}
elseif (preg_match('/\.(gif|jpg|png)$/', $this->method))
{
header('Location: images/' . $this->method);
}
elseif (preg_match('/\.css$/', $this->method))
{
header('Location: css/' . $this->method);
}
else
{
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
print($this->Header().$this->Method($this->method).$this->Footer());
}
}
?>%%
the second one every time, the hasaccess() function needs an acl list
%%(php)<?
function HasAccess($privilege, $tag = "", $user = "")
{
// set defaults
if (!$tag) $tag = $this->GetPageTag();
if (!$user) $user = $this->GetUserName();
// if current user is owner, return true. owner can do anything!
if ($this->UserIsOwner($tag)) return true;
// see whether user is registered and logged in
if ($this->GetUser()) $registered = true;
// load acl
if ($tag == $this->GetPageTag())
{
$acl = $this->ACLs[$privilege."_acl"];
}
else
{
$tag_ACLs = $this->LoadAllACLs($tag);
$acl = $tag_ACLs[$privilege."_acl"];
}
// replace group names with the respective member list
$acl["list"] = $this->ReplaceGroups($acl["list"]);
// fine fine... now go through acl
foreach (explode("\n", $acl) as $line)
{
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches))
{
$negate = 1;
$line = $matches[1];
}
else
{
$negate = 0;
}
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
// if there's still anything left... lines with just a "!" don't count!
if ($line)
{
switch ($line[0])
{
// everyone
case "*":
return !$negate;
// only registered users
case "+":
// return ($registered) ? !$negate : false;
return ($registered) ? !$negate : $negate;
// aha! a user entry.
default:
if ($line == $user)
{
return !$negate;
}
}
}
}
// tough luck.
return false;
}
?>%%
now we can hook in the isAdmin() function (**caution:** wikka then expects a group in $wakka->config["admins"]!):
%%(php)<?
function IsAdmin() { return $this->IsMember($this->config["admins"]); }
?>%%
and the wikka.config.php yet needs to be adjusted
%%(php)<?
'aliases' => array
('Administrators' => 'BillGates,JoseMariaAznar,GeorgeBush',
'DangerousPeople' => 'Administrators,DreckFehler',
'+' => 'WikkaGroups,MoreWikkaGroups'),
'admins' => 'Administrators',
?>%%
if the variable $wakka->config['aliases'] contains a **string** instead of an array, it is treated as a list of wikipages which maintain the group handling. in that case one of the pages should contain a group named "Administrators" (or whatever is defined in the config['admins'] variable). but to my understanding it's better for security reasons to leave the admin group in the config file (if not, make sure to restrict at least write access to the page that defines the admin group ;))
%%(php)<? 'aliases' => 'WikkaSystemGroups,WikkaGroups', ?>%%
a definition in a wikipage looks like this (whoever those spanish guys may be):
%%Superusers: ManoloCortes,PedroTriguero,JoseVera
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Check it at ACLsWithUserGroups
----
Deletions:
thanks for the kind permission given by victor manuel varela, who achieved the [[WakkaWiki:WakkaAliases 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 && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
foreach (explode (',', $current) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
}
$result = $list;
} while ($replaced);
}
return array_unique($result);
}
function IsMember($group, $user = "") {
if (!$user) $user = $this->GetUserName();
if (in_array($user, $this->GetMembers($group))) return true;
}
?>%%
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
%%(php)<?
function Run($tag, $method = "")
{
// do our stuff!
if (!$this->method = trim($method)) $this->method = "show";
if (!$this->tag = trim($tag)) $this->Redirect($this->href("", $this->config["root_page"]));
$this->BuildGroupsArray();
if ((!$this->GetUser() && isset($_COOKIE["name"])) && ($user = $this->LoadUser($_COOKIE["name"], $_COOKIE["password"]))) $this->SetUser($user);
$this->SetPage($this->LoadPage($tag, (isset($_REQUEST["time"]) ? $_REQUEST["time"] :'')));
$this->LogReferrer();
$this->ACLs = $this->LoadAllACLs($this->tag);
$this->ReadInterWikiConfig();
if(!($this->GetMicroTime()%3)) $this->Maintenance();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
{
print($this->Method($this->method));
}
elseif (preg_match('/\.(gif|jpg|png)$/', $this->method))
{
header('Location: images/' . $this->method);
}
elseif (preg_match('/\.css$/', $this->method))
{
header('Location: css/' . $this->method);
}
else
{
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
print($this->Header().$this->Method($this->method).$this->Footer());
}
}
?>%%
the second one every time, the hasaccess() function needs an acl list
%%(php)<?
function HasAccess($privilege, $tag = "", $user = "")
{
// set defaults
if (!$tag) $tag = $this->GetPageTag();
if (!$user) $user = $this->GetUserName();
// if current user is owner, return true. owner can do anything!
if ($this->UserIsOwner($tag)) return true;
// see whether user is registered and logged in
if ($this->GetUser()) $registered = true;
// load acl
if ($tag == $this->GetPageTag())
{
$acl = $this->ACLs[$privilege."_acl"];
}
else
{
$tag_ACLs = $this->LoadAllACLs($tag);
$acl = $tag_ACLs[$privilege."_acl"];
}
// replace group names with the respective member list
$acl["list"] = $this->ReplaceGroups($acl["list"]);
// fine fine... now go through acl
foreach (explode("\n", $acl) as $line)
{
// check for inversion character "!"
if (preg_match("/^[!](.*)$/", $line, $matches))
{
$negate = 1;
$line = $matches[1];
}
else
{
$negate = 0;
}
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
// if there's still anything left... lines with just a "!" don't count!
if ($line)
{
switch ($line[0])
{
// everyone
case "*":
return !$negate;
// only registered users
case "+":
// return ($registered) ? !$negate : false;
return ($registered) ? !$negate : $negate;
// aha! a user entry.
default:
if ($line == $user)
{
return !$negate;
}
}
}
}
// tough luck.
return false;
}
?>%%
now we can hook in the isAdmin() function (**caution:** wikka then expects a group in $wakka->config["admins"]!):
%%(php)<?
function IsAdmin() { return $this->IsMember($this->config["admins"]); }
?>%%
and the wikka.config.php yet needs to be adjusted
%%(php)<?
'aliases' => array
('Administrators' => 'BillGates,JoseMariaAznar,GeorgeBush',
'DangerousPeople' => 'Administrators,DreckFehler',
'+' => 'WikkaGroups,MoreWikkaGroups'),
'admins' => 'Administrators',
?>%%
if the variable $wakka->config['aliases'] contains a **string** instead of an array, it is treated as a list of wikipages which maintain the group handling. in that case one of the pages should contain a group named "Administrators" (or whatever is defined in the config['admins'] variable). but to my understanding it's better for security reasons to leave the admin group in the config file (if not, make sure to restrict at least write access to the page that defines the admin group ;))
%%(php)<? 'aliases' => 'WikkaSystemGroups,WikkaGroups', ?>%%
a definition in a wikipage looks like this (whoever those spanish guys may be):
%%Superusers: ManoloCortes,PedroTriguero,JoseVera
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Check it at ACLsWithUserGroups
----
Additions:
CategoryUserContributions
Deletions:
Additions:
Check it at ACLsWithUserGroups
Deletions:
%%(php)
// returns true if $who is member of $group
function CheckGroupMember($who, $group)
$thegroup=$this->LoadPage($group);
if ($thegroup) {
$search = "+".$who."+"; // In the GroupListPages, the participants logins have to be embbeded inside '+' signs
return substr_count($thegroup["body"], $search);
else return false;
%%
Then change HasAccess function:
from:
%%(php)
// aha! a user entry.
%%
to:
%%(php)
// aha! a user entry.
// this may be a UserGroup so we check if $user is part of the group
else if (($this->CheckGroupMember($user, $line)))
%%
Additions:
- Then he would write in this page all the user logins he wants to be part of the group (embeded inside plus signs to avoid confusions: +UserLogin1+UserLogin2+).
Deletions:
Revision [4039]
Edited on 2005-01-05 23:07:38 by ChristianBarthelemy [And here is the code for my alternate proposal]Deletions:
Revision [4038]
Edited on 2005-01-05 23:06:24 by ChristianBarthelemy [And here is the code for my alternate solution]Additions:
%%(php)
%%(php)
%%(php)
%%(php)
%%(php)
Deletions:
%%php
%%php
Revision [4037]
Edited on 2005-01-05 23:05:11 by ChristianBarthelemy [Here is the code for my proposal]Additions:
So in wikka.php add the CheckGroupMember function (after TrimACLs function for example):
%%php
// returns true if $who is member of $group
function CheckGroupMember($who, $group)
$thegroup=$this->LoadPage($group);
if ($thegroup) {
$search = "+".$who."+"; // In the GroupListPages, the participants logins have to be embbeded inside '+' signs
echo substr_count($thegroup["body"], $search);
return substr_count($thegroup["body"], $search);
else return false;
%%
Then change HasAccess function:
from:
%%php
// aha! a user entry.
%%
to:
%%php
// aha! a user entry.
// this may be a UserGroup so we check if $user is part of the group
else if (($this->CheckGroupMember($user, $line)))
%%
%%php
// returns true if $who is member of $group
function CheckGroupMember($who, $group)
$thegroup=$this->LoadPage($group);
if ($thegroup) {
$search = "+".$who."+"; // In the GroupListPages, the participants logins have to be embbeded inside '+' signs
echo substr_count($thegroup["body"], $search);
return substr_count($thegroup["body"], $search);
else return false;
%%
Then change HasAccess function:
from:
%%php
// aha! a user entry.
%%
to:
%%php
// aha! a user entry.
// this may be a UserGroup so we check if $user is part of the group
else if (($this->CheckGroupMember($user, $line)))
%%
Revision [4029]
Edited on 2005-01-05 22:11:35 by ChristianBarthelemy [New approach on User Groups management]Additions:
====Another approach====
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group.
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
I though about a simple way to deal with GroupManagement - my concept may be different: Give the power to the users and Keep it simple.
- The idea is that anyuser could define a new group by creating a dedicated WikiPage: something like ""MyProjectGroup"".
- Then he would write in this page all the user logins he wants to be part of the group.
- He would decide through the ACLs of this page who can manage the group list.
- Then he may use this page name in the ACLs of any page in order to manage the access authorizations.
- The only code needed should be that ""HasAccess"" function has to be modified in order to search if the user is part of the group or not.
Additions:
=====Group-Management=====
loopTwo: PongUser,loopOne # will not mess up the group handling%%
----
CategoryDevelopment
loopTwo: PongUser,loopOne # will not mess up the group handling%%
----
CategoryDevelopment
Deletions:
Additions:
thanks for the kind permission given by victor manuel varela, who achieved the [[WakkaWiki:WakkaAliases basic concept]].
Deletions:
Additions:
// stripping comments
if (preg_match("/^(.*)?#/", $line, $matches) $line = $matches[1];
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
if (preg_match("/^(.*)?#/", $line, $matches) $line = $matches[1];
loopOne: PingUser,loopTwo # these two groups
loopTwo: PongUser,loopOne # will not mess up the group handling%%
Deletions:
loopTwo: PongUser,loopOne%%
Additions:
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 && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
foreach (explode (',', $current) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
$result = $list;
} while ($replaced);
return array_unique($result);
if (in_array($user, $this->GetMembers($group))) return true;
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo
loopTwo: PongUser,loopOne%%
$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 && $groups = $this->config['aliases']) {
$result = array(trim($group));
do {
$replaced = false; $list = array();
foreach ($result as $line) {
if (isset($groups[$line])) {
foreach (explode (',', $current) as $item) $list[] = trim($item);
$replaced = true;
$groups[$line] = ''; // include a group only once!
} else $list[] = trim($line);
$result = $list;
} while ($replaced);
return array_unique($result);
if (in_array($user, $this->GetMembers($group))) return true;
Webmasters: JordiDan,LaraGarrido
loopOne: PingUser,loopTwo
loopTwo: PongUser,loopOne%%
Deletions:
do {
$list = array();
$replaced = false;
foreach (explode("\n", $acl) as $line) {
$line = trim($line);
if (preg_match("/^[!](.*)$/", $line, $matches)) {
$negate = "!";
} else $negate = "";
if (isset($aliases[$line])) {
if ($aliases[$line]) foreach (explode(",", $aliases[$line]) as $item) $list[] = $negate.trim($item);
$replaced = true;
$aliases[$line] = ""; // include a group only once!
} else $list[] = $line;
$acl = join("\n", $list);
} while ($replaced);
return $acl;
$memberarray = explode(",", $this->config["aliases"][$group]);
foreach ($memberarray as $member) if (trim($member) == $user) return true;
Webmasters: JordiDan,LaraGarrido%%
**note:** the admin group so far //must not// contain other groups, as groups in general can. although i consider it as useless to grant entire groups of groups admin access, this should be seen as an inconsistency. please bear that issue in mind if you want to use the code above. a modification is underway.
Revision [1033]
Edited on 2004-08-22 15:38:53 by DreckFehler [yep! found a little inconsistency. ;)]Additions:
**note:** the admin group so far //must not// contain other groups, as groups in general can. although i consider it as useless to grant entire groups of groups admin access, this should be seen as an inconsistency. please bear that issue in mind if you want to use the code above. a modification is underway.
Deletions:
Additions:
thanks for the kind permission given by victor manuel varela, who achieved the [[WakkaWiki:WakkaAliases|basic concept]].
the following changes have been made to the wakkaaliases:
the following changes have been made to the wakkaaliases:
Deletions:
anyway, thanks for the kind permission given by victor manuel varela, who achieved the basic concept.
the following changes have been made:
Additions:
the first function will be called in the run() routine ([[http://wikka.jsnx.com/GroupManagement/diff?a=1009&b=1008 see diff for changes]], codebase is wikka 1.1.3.8)
Deletions:
Additions:
$this->BuildGroupsArray();
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
// replace group names with the respective member list
$acl["list"] = $this->ReplaceGroups($acl["list"]);
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
Webmasters: JordiDan,LaraGarrido%%
if (preg_match('/\.(xml|cgi|php)$/', $this->method)) // this tweak is not related to the group management, but quite handy ;)
header('Last-Modified: '.gmdate("r", strtotime($this->page["time"]))); // just another little fix
// replace group names with the respective member list
$acl["list"] = $this->ReplaceGroups($acl["list"]);
// cut off comment (allows comments in one line after an acl item)
if (preg_match("/^(.*)[#].*$/", $line, $matches)) $line = trim($matches[1]);
Webmasters: JordiDan,LaraGarrido%%
Deletions:
// comments
case "#":
break;
Webmasters: JordiDan,LaraGarrido%%