From: Reini U. <ru...@us...> - 2004-11-23 13:06:41
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5867 Modified Files: PagePerm.php WikiGroup.php Log Message: several fixes and suggestions by Charles Corrigan: * fix GROUP_BOGO_USER check * allow group pages to have the link to the user page in [ ] brackets * fix up the implementation of GroupWikiPage::getMembersOf and allow the user page to be linked in [ ] brackets * added _OWNER and _CREATOR to special wikigroups * check against those two for group membership also, not only the user. Index: PagePerm.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/PagePerm.php,v retrieving revision 1.36 retrieving revision 1.37 diff -u -2 -b -p -d -r1.36 -r1.37 --- PagePerm.php 21 Nov 2004 11:59:16 -0000 1.36 +++ PagePerm.php 23 Nov 2004 13:06:30 -0000 1.37 @@ -397,12 +397,16 @@ class PagePermission { return $user->isAuthenticated(); if ($group === ACL_OWNER) { + if (!$user->isAuthenticated()) return false; $page = $request->getPage(); - return ($user->isAuthenticated() and - $page->getOwner() === $user->UserName()); + $owner = $page->getOwner(); + return ($owner === $user->UserName() + or $member->isMember($owner)); } if ($group === ACL_CREATOR) { + if (!$user->isAuthenticated()) return false; $page = $request->getPage(); - return ($user->isAuthenticated() and - $page->getCreator() === $user->UserName()); + $creator = $page->getCreator(); + return ($creator === $user->UserName() + or $member->isMember($creator)); } /* Or named groups or usernames. @@ -719,4 +723,13 @@ class PagePermission { // $Log$ +// Revision 1.37 2004/11/23 13:06:30 rurban +// several fixes and suggestions by Charles Corrigan: +// * fix GROUP_BOGO_USER check +// * allow group pages to have the link to the user page in [ ] brackets +// * fix up the implementation of GroupWikiPage::getMembersOf and allow the +// user page to be linked in [ ] brackets +// * added _OWNER and _CREATOR to special wikigroups +// * check against those two for group membership also, not only the user. +// // Revision 1.36 2004/11/21 11:59:16 rurban // remove final \n to be ob_cache independent Index: WikiGroup.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiGroup.php,v retrieving revision 1.48 retrieving revision 1.49 diff -u -2 -b -p -d -r1.48 -r1.49 --- WikiGroup.php 19 Nov 2004 19:22:03 -0000 1.48 +++ WikiGroup.php 23 Nov 2004 13:06:30 -0000 1.49 @@ -152,5 +152,7 @@ class WikiGroup{ GROUP_SIGNED, GROUP_AUTHENTICATED, - GROUP_ADMIN); + GROUP_ADMIN, + GROUP_OWNER, + GROUP_CREATOR); } /** untranslated */ @@ -162,5 +164,7 @@ class WikiGroup{ "_SIGNED", "_AUTHENTICATED", - "_ADMIN"); + "_ADMIN", + "_OWNER", + "_CREATOR"); } @@ -322,5 +326,5 @@ class WikiGroup{ case GROUP_BOGOUSER: foreach ($all as $u) { - if (isWikiWord($user)) $users[] = $u; + if (isWikiWord($u)) $users[] = $u; } return $users; @@ -509,5 +513,5 @@ class GroupWikiPage extends WikiGroup{ } $contents = $group_revision->getContent(); - $match = '/^\s*[\*\#]+\s*' . $this->username . '\s*$/'; + $match = '/^\s*[\*\#]+\s*\[?' . $this->username . '\]?\s*$/'; foreach ($contents as $line){ if (preg_match($match, $line)) { @@ -560,28 +564,20 @@ class GroupWikiPage extends WikiGroup{ return $this->getSpecialMembersOf($group); - trigger_error("GroupWikiPage::getMembersOf is not yet implimented", - E_USER_WARNING); - return array(); - /* - * Waiting for a reliable way to check if a string is a username. - $request = $this->request; - $user = $this->user; - $group_page = $request->getPage($group); + $group_page = $GLOBALS['request']->getPage($group); $group_revision = $group_page->getCurrentRevision(); if ($group_revision->hasDefaultContents()) { - trigger_error("Group $group does not exist", E_USER_WARNING); - return false; + trigger_error(sprintf(_("Group %s does not exist"),$group), E_USER_WARNING); + return array(); } $contents = $group_revision->getContent(); - $match = '/^(\s*[\*\#]+\s*)(\w+)(\s*)$/'; + // This is not really a reliable way to check if a string is a username. But better than nothing. + $match = '/^(\s*[\*\#]+\s*\[?)(\w+)(\]?\s*)$/'; $members = array(); - foreach($contents as $line){ - $matches = array(); - if(preg_match($match, $line, $matches)){ + foreach ($contents as $line){ + if (preg_match($match, $line, $matches)){ $members[] = $matches[2]; } } return $members; - */ } } @@ -1097,4 +1093,13 @@ class GroupLdap extends WikiGroup { // $Log$ +// Revision 1.49 2004/11/23 13:06:30 rurban +// several fixes and suggestions by Charles Corrigan: +// * fix GROUP_BOGO_USER check +// * allow group pages to have the link to the user page in [ ] brackets +// * fix up the implementation of GroupWikiPage::getMembersOf and allow the +// user page to be linked in [ ] brackets +// * added _OWNER and _CREATOR to special wikigroups +// * check against those two for group membership also, not only the user. +// // Revision 1.48 2004/11/19 19:22:03 rurban // ModeratePage part1: change status |