aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/acl/admin.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/acl/admin.php')
-rw-r--r--lib/plugins/acl/admin.php430
1 files changed, 235 insertions, 195 deletions
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php
index 4ee0fde7e..b0b0ffc85 100644
--- a/lib/plugins/acl/admin.php
+++ b/lib/plugins/acl/admin.php
@@ -7,16 +7,15 @@
* @author Anika Henke <anika@selfthinker.org> (concepts)
* @author Frank Schubert <frank@schokilade.de> (old version)
*/
-// must be run within Dokuwiki
-if(!defined('DOKU_INC')) die();
/**
* All DokuWiki plugins to extend the admin function
* need to inherit from this class
*/
-class admin_plugin_acl extends DokuWiki_Admin_Plugin {
- var $acl = null;
- var $ns = null;
+class admin_plugin_acl extends DokuWiki_Admin_Plugin
+{
+ public $acl = null;
+ protected $ns = null;
/**
* The currently selected item, associative array with id and type.
* Populated from (in this order):
@@ -25,22 +24,24 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
* $ns
* $ID
*/
- var $current_item = null;
- var $who = '';
- var $usersgroups = array();
- var $specials = array();
+ protected $current_item = null;
+ protected $who = '';
+ protected $usersgroups = array();
+ protected $specials = array();
/**
* return prompt for admin menu
*/
- function getMenuText($language) {
+ public function getMenuText($language)
+ {
return $this->getLang('admin_acl');
}
/**
* return sort order for position in admin menu
*/
- function getMenuSort() {
+ public function getMenuSort()
+ {
return 1;
}
@@ -51,7 +52,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function handle() {
+ public function handle()
+ {
global $AUTH_ACL;
global $ID;
global $auth;
@@ -62,9 +64,9 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
$AUTH_ACL = file($config_cascade['acl']['default']);
// namespace given?
- if($INPUT->str('ns') == '*'){
+ if ($INPUT->str('ns') == '*') {
$this->ns = '*';
- }else{
+ } else {
$this->ns = cleanID($INPUT->str('ns'));
}
@@ -80,78 +82,78 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
// user or group choosen?
$who = trim($INPUT->str('acl_w'));
- if($INPUT->str('acl_t') == '__g__' && $who){
- $this->who = '@'.ltrim($auth->cleanGroup($who),'@');
- }elseif($INPUT->str('acl_t') == '__u__' && $who){
- $this->who = ltrim($who,'@');
- if($this->who != '%USER%' && $this->who != '%GROUP%'){ #keep wildcard as is
+ if ($INPUT->str('acl_t') == '__g__' && $who) {
+ $this->who = '@'.ltrim($auth->cleanGroup($who), '@');
+ } elseif ($INPUT->str('acl_t') == '__u__' && $who) {
+ $this->who = ltrim($who, '@');
+ if ($this->who != '%USER%' && $this->who != '%GROUP%') { #keep wildcard as is
$this->who = $auth->cleanUser($this->who);
}
- }elseif($INPUT->str('acl_t') &&
+ } elseif ($INPUT->str('acl_t') &&
$INPUT->str('acl_t') != '__u__' &&
- $INPUT->str('acl_t') != '__g__'){
+ $INPUT->str('acl_t') != '__g__') {
$this->who = $INPUT->str('acl_t');
- }elseif($who){
+ } elseif ($who) {
$this->who = $who;
}
// handle modifications
- if($INPUT->has('cmd') && checkSecurityToken()){
+ if ($INPUT->has('cmd') && checkSecurityToken()) {
$cmd = $INPUT->extract('cmd')->str('cmd');
// scope for modifications
- if($this->ns){
- if($this->ns == '*'){
+ if ($this->ns) {
+ if ($this->ns == '*') {
$scope = '*';
- }else{
+ } else {
$scope = $this->ns.':*';
}
- }else{
+ } else {
$scope = $ID;
}
- if($cmd == 'save' && $scope && $this->who && $INPUT->has('acl')){
+ if ($cmd == 'save' && $scope && $this->who && $INPUT->has('acl')) {
// handle additions or single modifications
- $this->_acl_del($scope, $this->who);
- $this->_acl_add($scope, $this->who, $INPUT->int('acl'));
- }elseif($cmd == 'del' && $scope && $this->who){
+ $this->deleteACL($scope, $this->who);
+ $this->addACL($scope, $this->who, $INPUT->int('acl'));
+ } elseif ($cmd == 'del' && $scope && $this->who) {
// handle single deletions
- $this->_acl_del($scope, $this->who);
- }elseif($cmd == 'update'){
+ $this->deleteACL($scope, $this->who);
+ } elseif ($cmd == 'update') {
$acl = $INPUT->arr('acl');
// handle update of the whole file
- foreach($INPUT->arr('del') as $where => $names){
+ foreach ($INPUT->arr('del') as $where => $names) {
// remove all rules marked for deletion
- foreach($names as $who)
+ foreach ($names as $who)
unset($acl[$where][$who]);
}
// prepare lines
$lines = array();
// keep header
- foreach($AUTH_ACL as $line){
- if($line{0} == '#'){
+ foreach ($AUTH_ACL as $line) {
+ if ($line{0} == '#') {
$lines[] = $line;
- }else{
+ } else {
break;
}
}
// re-add all rules
- foreach($acl as $where => $opt){
- foreach($opt as $who => $perm){
+ foreach ($acl as $where => $opt) {
+ foreach ($opt as $who => $perm) {
if ($who[0]=='@') {
if ($who!='@ALL') {
- $who = '@'.ltrim($auth->cleanGroup($who),'@');
+ $who = '@'.ltrim($auth->cleanGroup($who), '@');
}
- } elseif ($who != '%USER%' && $who != '%GROUP%'){ #keep wildcard as is
+ } elseif ($who != '%USER%' && $who != '%GROUP%') { #keep wildcard as is
$who = $auth->cleanUser($who);
}
- $who = auth_nameencode($who,true);
+ $who = auth_nameencode($who, true);
$lines[] = "$where\t$who\t$perm\n";
}
}
// save it
- io_saveFile($config_cascade['acl']['default'], join('',$lines));
+ io_saveFile($config_cascade['acl']['default'], join('', $lines));
}
// reload ACL config
@@ -159,7 +161,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
}
// initialize ACL array
- $this->_init_acl_config();
+ $this->initAclConfig();
}
/**
@@ -171,24 +173,25 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
* @author Frank Schubert <frank@schokilade.de>
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function html() {
+ public function html()
+ {
echo '<div id="acl_manager">'.NL;
echo '<h1>'.$this->getLang('admin_acl').'</h1>'.NL;
echo '<div class="level1">'.NL;
echo '<div id="acl__tree">'.NL;
- $this->_html_explorer();
+ $this->makeExplorer();
echo '</div>'.NL;
echo '<div id="acl__detail">'.NL;
- $this->_html_detail();
+ $this->printDetail();
echo '</div>'.NL;
echo '</div>'.NL;
echo '<div class="clearer"></div>';
echo '<h2>'.$this->getLang('current').'</h2>'.NL;
echo '<div class="level2">'.NL;
- $this->_html_table();
+ $this->printAclTable();
echo '</div>'.NL;
echo '<div class="footnotes"><div class="fn">'.NL;
@@ -204,15 +207,16 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _get_opts($addopts=null){
+ protected function getLinkOptions($addopts = null)
+ {
$opts = array(
'do'=>'admin',
'page'=>'acl',
);
- if($this->ns) $opts['ns'] = $this->ns;
- if($this->who) $opts['acl_w'] = $this->who;
+ if ($this->ns) $opts['ns'] = $this->ns;
+ if ($this->who) $opts['acl_w'] = $this->who;
- if(is_null($addopts)) return $opts;
+ if (is_null($addopts)) return $opts;
return array_merge($opts, $addopts);
}
@@ -221,54 +225,61 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_explorer(){
+ protected function makeExplorer()
+ {
global $conf;
global $ID;
global $lang;
$ns = $this->ns;
- if(empty($ns)){
- $ns = dirname(str_replace(':','/',$ID));
- if($ns == '.') $ns ='';
- }elseif($ns == '*'){
+ if (empty($ns)) {
+ $ns = dirname(str_replace(':', '/', $ID));
+ if ($ns == '.') $ns ='';
+ } elseif ($ns == '*') {
$ns ='';
}
- $ns = utf8_encodeFN(str_replace(':','/',$ns));
+ $ns = utf8_encodeFN(str_replace(':', '/', $ns));
- $data = $this->_get_tree($ns);
+ $data = $this->makeTree($ns);
// wrap a list with the root level around the other namespaces
array_unshift($data, array( 'level' => 0, 'id' => '*', 'type' => 'd',
'open' =>'true', 'label' => '['.$lang['mediaroot'].']'));
- echo html_buildlist($data,'acl',
- array($this,'_html_list_acl'),
- array($this,'_html_li_acl'));
-
+ echo html_buildlist(
+ $data,
+ 'acl',
+ array($this, 'makeTreeItem'),
+ array($this, 'makeListItem')
+ );
}
/**
* get a combined list of media and page files
*
+ * also called via AJAX
+ *
* @param string $folder an already converted filesystem folder of the current namespace
- * @param string $limit limit the search to this folder
+ * @param string $limit limit the search to this folder
+ * @return array
*/
- function _get_tree($folder,$limit=''){
+ public function makeTree($folder, $limit = '')
+ {
global $conf;
// read tree structure from pages and media
$data = array();
- search($data,$conf['datadir'],'search_index',array('ns' => $folder),$limit);
+ search($data, $conf['datadir'], 'search_index', array('ns' => $folder), $limit);
$media = array();
- search($media,$conf['mediadir'],'search_index',array('ns' => $folder, 'nofiles' => true),$limit);
- $data = array_merge($data,$media);
+ search($media, $conf['mediadir'], 'search_index', array('ns' => $folder, 'nofiles' => true), $limit);
+ $data = array_merge($data, $media);
unset($media);
// combine by sorting and removing duplicates
- usort($data,array($this,'_tree_sort'));
+ usort($data, array($this, 'treeSort'));
$count = count($data);
- if($count>0) for($i=1; $i<$count; $i++){
- if($data[$i-1]['id'] == $data[$i]['id'] && $data[$i-1]['type'] == $data[$i]['type']) {
+ if ($count>0) for ($i=1; $i<$count; $i++) {
+ if ($data[$i-1]['id'] == $data[$i]['id'] && $data[$i-1]['type'] == $data[$i]['type']) {
unset($data[$i]);
$i++; // duplicate found, next $i can't be a duplicate, so skip forward one
}
@@ -281,7 +292,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* Sorts the combined trees of media and page files
*/
- function _tree_sort($a,$b){
+ public function treeSort($a, $b)
+ {
// handle the trivial cases first
if ($a['id'] == '') return -1;
if ($b['id'] == '') return 1;
@@ -315,6 +327,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
// before that other part.
if (empty($a_ids)) return ($a['type'] == 'd') ? -1 : 1;
if (empty($b_ids)) return ($b['type'] == 'd') ? 1 : -1;
+ return 0; //shouldn't happen
}
/**
@@ -323,20 +336,21 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_detail(){
+ protected function printDetail()
+ {
global $ID;
echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
echo '<div id="acl__user">';
echo $this->getLang('acl_perms').' ';
- $inl = $this->_html_select();
- echo '<input type="text" name="acl_w" class="edit" value="'.(($inl)?'':hsc(ltrim($this->who,'@'))).'" />'.NL;
+ $inl = $this->makeSelect();
+ echo '<input type="text" name="acl_w" class="edit" value="'.(($inl)?'':hsc(ltrim($this->who, '@'))).'" />'.NL;
echo '<button type="submit">'.$this->getLang('btn_select').'</button>'.NL;
echo '</div>'.NL;
echo '<div id="acl__info">';
- $this->_html_info();
+ $this->printInfo();
echo '</div>';
echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
@@ -349,23 +363,26 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
/**
* Print info and editor
+ *
+ * also loaded via Ajax
*/
- function _html_info(){
+ public function printInfo()
+ {
global $ID;
- if($this->who){
- $current = $this->_get_exact_perm();
+ if ($this->who) {
+ $current = $this->getExactPermisson();
// explain current permissions
- $this->_html_explain($current);
+ $this->printExplanation($current);
// load editor
- $this->_html_acleditor($current);
- }else{
+ $this->printAclEditor($current);
+ } else {
echo '<p>';
- if($this->ns){
- printf($this->getLang('p_choose_ns'),hsc($this->ns));
- }else{
- printf($this->getLang('p_choose_id'),hsc($ID));
+ if ($this->ns) {
+ printf($this->getLang('p_choose_ns'), hsc($this->ns));
+ } else {
+ printf($this->getLang('p_choose_id'), hsc($ID));
}
echo '</p>';
@@ -378,21 +395,22 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_acleditor($current){
+ protected function printAclEditor($current)
+ {
global $lang;
echo '<fieldset>';
- if(is_null($current)){
+ if (is_null($current)) {
echo '<legend>'.$this->getLang('acl_new').'</legend>';
- }else{
+ } else {
echo '<legend>'.$this->getLang('acl_mod').'</legend>';
}
- echo $this->_html_checkboxes($current,empty($this->ns),'acl');
+ echo $this->makeCheckboxes($current, empty($this->ns), 'acl');
- if(is_null($current)){
+ if (is_null($current)) {
echo '<button type="submit" name="cmd[save]">'.$lang['btn_save'].'</button>'.NL;
- }else{
+ } else {
echo '<button type="submit" name="cmd[save]">'.$lang['btn_update'].'</button>'.NL;
echo '<button type="submit" name="cmd[del]">'.$lang['btn_delete'].'</button>'.NL;
}
@@ -405,7 +423,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_explain($current){
+ protected function printExplanation($current)
+ {
global $ID;
global $auth;
@@ -413,69 +432,69 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
$ns = $this->ns;
// prepare where to check
- if($ns){
- if($ns == '*'){
+ if ($ns) {
+ if ($ns == '*') {
$check='*';
- }else{
+ } else {
$check=$ns.':*';
}
- }else{
+ } else {
$check = $ID;
}
// prepare who to check
- if($who{0} == '@'){
+ if ($who{0} == '@') {
$user = '';
- $groups = array(ltrim($who,'@'));
- }else{
+ $groups = array(ltrim($who, '@'));
+ } else {
$user = $who;
$info = $auth->getUserData($user);
- if($info === false){
+ if ($info === false) {
$groups = array();
- }else{
+ } else {
$groups = $info['grps'];
}
}
// check the permissions
- $perm = auth_aclcheck($check,$user,$groups);
+ $perm = auth_aclcheck($check, $user, $groups);
// build array of named permissions
$names = array();
- if($perm){
- if($ns){
- if($perm >= AUTH_DELETE) $names[] = $this->getLang('acl_perm16');
- if($perm >= AUTH_UPLOAD) $names[] = $this->getLang('acl_perm8');
- if($perm >= AUTH_CREATE) $names[] = $this->getLang('acl_perm4');
+ if ($perm) {
+ if ($ns) {
+ if ($perm >= AUTH_DELETE) $names[] = $this->getLang('acl_perm16');
+ if ($perm >= AUTH_UPLOAD) $names[] = $this->getLang('acl_perm8');
+ if ($perm >= AUTH_CREATE) $names[] = $this->getLang('acl_perm4');
}
- if($perm >= AUTH_EDIT) $names[] = $this->getLang('acl_perm2');
- if($perm >= AUTH_READ) $names[] = $this->getLang('acl_perm1');
+ if ($perm >= AUTH_EDIT) $names[] = $this->getLang('acl_perm2');
+ if ($perm >= AUTH_READ) $names[] = $this->getLang('acl_perm1');
$names = array_reverse($names);
- }else{
+ } else {
$names[] = $this->getLang('acl_perm0');
}
// print permission explanation
echo '<p>';
- if($user){
- if($ns){
- printf($this->getLang('p_user_ns'),hsc($who),hsc($ns),join(', ',$names));
- }else{
- printf($this->getLang('p_user_id'),hsc($who),hsc($ID),join(', ',$names));
+ if ($user) {
+ if ($ns) {
+ printf($this->getLang('p_user_ns'), hsc($who), hsc($ns), join(', ', $names));
+ } else {
+ printf($this->getLang('p_user_id'), hsc($who), hsc($ID), join(', ', $names));
}
- }else{
- if($ns){
- printf($this->getLang('p_group_ns'),hsc(ltrim($who,'@')),hsc($ns),join(', ',$names));
- }else{
- printf($this->getLang('p_group_id'),hsc(ltrim($who,'@')),hsc($ID),join(', ',$names));
+ } else {
+ if ($ns) {
+ printf($this->getLang('p_group_ns'), hsc(ltrim($who, '@')), hsc($ns), join(', ', $names));
+ } else {
+ printf($this->getLang('p_group_id'), hsc(ltrim($who, '@')), hsc($ID), join(', ', $names));
}
}
echo '</p>';
// add note if admin
- if($perm == AUTH_ADMIN){
+ if ($perm == AUTH_ADMIN) {
echo '<p>'.$this->getLang('p_isadmin').'</p>';
- }elseif(is_null($current)){
+ } elseif (is_null($current)) {
echo '<p>'.$this->getLang('p_inherited').'</p>';
}
}
@@ -488,46 +507,57 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_list_acl($item){
+ protected function makeTreeItem($item)
+ {
$ret = '';
// what to display
- if(!empty($item['label'])){
+ if (!empty($item['label'])) {
$base = $item['label'];
- }else{
+ } else {
$base = ':'.$item['id'];
- $base = substr($base,strrpos($base,':')+1);
+ $base = substr($base, strrpos($base, ':')+1);
}
// highlight?
- if( ($item['type']== $this->current_item['type'] && $item['id'] == $this->current_item['id'])) {
+ if (($item['type']== $this->current_item['type'] && $item['id'] == $this->current_item['id'])) {
$cl = ' cur';
} else {
$cl = '';
}
// namespace or page?
- if($item['type']=='d'){
- if($item['open']){
+ if ($item['type']=='d') {
+ if ($item['open']) {
$img = DOKU_BASE.'lib/images/minus.gif';
$alt = '−';
- }else{
+ } else {
$img = DOKU_BASE.'lib/images/plus.gif';
$alt = '+';
}
$ret .= '<img src="'.$img.'" alt="'.$alt.'" />';
- $ret .= '<a href="'.wl('',$this->_get_opts(array('ns'=>$item['id'],'sectok'=>getSecurityToken()))).'" class="idx_dir'.$cl.'">';
+ $ret .= '<a href="'.
+ wl('', $this->getLinkOptions(array('ns'=> $item['id'], 'sectok'=>getSecurityToken()))).
+ '" class="idx_dir'.$cl.'">';
$ret .= $base;
$ret .= '</a>';
- }else{
- $ret .= '<a href="'.wl('',$this->_get_opts(array('id'=>$item['id'],'ns'=>'','sectok'=>getSecurityToken()))).'" class="wikilink1'.$cl.'">';
+ } else {
+ $ret .= '<a href="'.
+ wl('', $this->getLinkOptions(array('id'=> $item['id'], 'ns'=>'', 'sectok'=>getSecurityToken()))).
+ '" class="wikilink1'.$cl.'">';
$ret .= noNS($item['id']);
$ret .= '</a>';
}
return $ret;
}
-
- function _html_li_acl($item){
+ /**
+ * List Item formatter
+ *
+ * @param array $item
+ * @return string
+ */
+ public function makeListItem($item)
+ {
return '<li class="level' . $item['level'] . ' ' .
($item['open'] ? 'open' : 'closed') . '">';
}
@@ -538,7 +568,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _init_acl_config(){
+ public function initAclConfig()
+ {
global $AUTH_ACL;
global $conf;
$acl_config=array();
@@ -547,20 +578,24 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
// get special users and groups
$this->specials[] = '@ALL';
$this->specials[] = '@'.$conf['defaultgroup'];
- if($conf['manager'] != '!!not set!!'){
- $this->specials = array_merge($this->specials,
- array_map('trim',
- explode(',',$conf['manager'])));
+ if ($conf['manager'] != '!!not set!!') {
+ $this->specials = array_merge(
+ $this->specials,
+ array_map(
+ 'trim',
+ explode(',', $conf['manager'])
+ )
+ );
}
$this->specials = array_filter($this->specials);
$this->specials = array_unique($this->specials);
sort($this->specials);
- foreach($AUTH_ACL as $line){
- $line = trim(preg_replace('/#.*$/','',$line)); //ignore comments
- if(!$line) continue;
+ foreach ($AUTH_ACL as $line) {
+ $line = trim(preg_replace('/#.*$/', '', $line)); //ignore comments
+ if (!$line) continue;
- $acl = preg_split('/[ \t]+/',$line);
+ $acl = preg_split('/[ \t]+/', $line);
//0 is pagename, 1 is user, 2 is acl
$acl[1] = rawurldecode($acl[1]);
@@ -568,7 +603,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
// store non-special users and groups for later selection dialog
$ug = $acl[1];
- if(in_array($ug,$this->specials)) continue;
+ if (in_array($ug, $this->specials)) continue;
$usersgroups[] = $ug;
}
@@ -585,14 +620,15 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_table(){
+ protected function printAclTable()
+ {
global $lang;
global $ID;
echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
- if($this->ns){
+ if ($this->ns) {
echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
- }else{
+ } else {
echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
}
echo '<input type="hidden" name="acl_w" value="'.hsc($this->who).'" />'.NL;
@@ -607,29 +643,29 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
echo '<th>'.$this->getLang('perm').'<sup><a id="fnt__1" class="fn_top" href="#fn__1">1)</a></sup></th>';
echo '<th>'.$lang['btn_delete'].'</th>';
echo '</tr>';
- foreach($this->acl as $where => $set){
- foreach($set as $who => $perm){
+ foreach ($this->acl as $where => $set) {
+ foreach ($set as $who => $perm) {
echo '<tr>';
echo '<td>';
- if(substr($where,-1) == '*'){
+ if (substr($where, -1) == '*') {
echo '<span class="aclns">'.hsc($where).'</span>';
$ispage = false;
- }else{
+ } else {
echo '<span class="aclpage">'.hsc($where).'</span>';
$ispage = true;
}
echo '</td>';
echo '<td>';
- if($who{0} == '@'){
+ if ($who{0} == '@') {
echo '<span class="aclgroup">'.hsc($who).'</span>';
- }else{
+ } else {
echo '<span class="acluser">'.hsc($who).'</span>';
}
echo '</td>';
echo '<td>';
- echo $this->_html_checkboxes($perm,$ispage,'acl['.$where.']['.$who.']');
+ echo $this->makeCheckboxes($perm, $ispage, 'acl['.$where.']['.$who.']');
echo '</td>';
echo '<td class="check">';
@@ -655,21 +691,22 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _get_exact_perm(){
+ protected function getExactPermisson()
+ {
global $ID;
- if($this->ns){
- if($this->ns == '*'){
+ if ($this->ns) {
+ if ($this->ns == '*') {
$check = '*';
- }else{
+ } else {
$check = $this->ns.':*';
}
- }else{
+ } else {
$check = $ID;
}
- if(isset($this->acl[$check][$this->who])){
+ if (isset($this->acl[$check][$this->who])) {
return $this->acl[$check][$this->who];
- }else{
+ } else {
return null;
}
}
@@ -679,13 +716,14 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Frank Schubert <frank@schokilade.de>
*/
- function _acl_add($acl_scope, $acl_user, $acl_level){
+ public function addACL($acl_scope, $acl_user, $acl_level)
+ {
global $config_cascade;
- $acl_user = auth_nameencode($acl_user,true);
+ $acl_user = auth_nameencode($acl_user, true);
// max level for pagenames is edit
- if(strpos($acl_scope,'*') === false) {
- if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT;
+ if (strpos($acl_scope, '*') === false) {
+ if ($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT;
}
$new_acl = "$acl_scope\t$acl_user\t$acl_level\n";
@@ -698,11 +736,12 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Frank Schubert <frank@schokilade.de>
*/
- function _acl_del($acl_scope, $acl_user){
+ public function deleteACL($acl_scope, $acl_user)
+ {
global $config_cascade;
- $acl_user = auth_nameencode($acl_user,true);
+ $acl_user = auth_nameencode($acl_user, true);
- $acl_pattern = '^'.preg_quote($acl_scope,'/').'[ \t]+'.$acl_user.'[ \t]+[0-8].*$';
+ $acl_pattern = '^'.preg_quote($acl_scope, '/').'[ \t]+'.$acl_user.'[ \t]+[0-8].*$';
return io_deleteFromFile($config_cascade['acl']['default'], "/$acl_pattern/", true);
}
@@ -713,15 +752,16 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
* @author Frank Schubert <frank@schokilade.de>
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_checkboxes($setperm,$ispage,$name){
+ protected function makeCheckboxes($setperm, $ispage, $name)
+ {
global $lang;
static $label = 0; //number labels
$ret = '';
- if($ispage && $setperm > AUTH_EDIT) $setperm = AUTH_EDIT;
+ if ($ispage && $setperm > AUTH_EDIT) $setperm = AUTH_EDIT;
- foreach(array(AUTH_NONE,AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm){
+ foreach (array(AUTH_NONE,AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm) {
$label += 1;
//general checkbox attributes
@@ -730,11 +770,11 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
'name' => $name,
'value' => $perm );
//dynamic attributes
- if(!is_null($setperm) && $setperm == $perm) $atts['checked'] = 'checked';
- if($ispage && $perm > AUTH_EDIT){
+ if (!is_null($setperm) && $setperm == $perm) $atts['checked'] = 'checked';
+ if ($ispage && $perm > AUTH_EDIT) {
$atts['disabled'] = 'disabled';
$class = ' class="disabled"';
- }else{
+ } else {
$class = '';
}
@@ -752,21 +792,21 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _html_select(){
+ protected function makeSelect()
+ {
$inlist = false;
$usel = '';
$gsel = '';
- if($this->who &&
- !in_array($this->who,$this->usersgroups) &&
- !in_array($this->who,$this->specials)){
-
- if($this->who{0} == '@'){
+ if ($this->who &&
+ !in_array($this->who, $this->usersgroups) &&
+ !in_array($this->who, $this->specials)) {
+ if ($this->who{0} == '@') {
$gsel = ' selected="selected"';
- }else{
+ } else {
$usel = ' selected="selected"';
}
- }else{
+ } else {
$inlist = true;
}
@@ -775,17 +815,17 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
echo ' <option value="__u__" class="acluser"'.$usel.'>'.$this->getLang('acl_user').'</option>'.NL;
if (!empty($this->specials)) {
echo ' <optgroup label="&#160;">'.NL;
- foreach($this->specials as $ug){
- if($ug == $this->who){
+ foreach ($this->specials as $ug) {
+ if ($ug == $this->who) {
$sel = ' selected="selected"';
$inlist = true;
- }else{
+ } else {
$sel = '';
}
- if($ug{0} == '@'){
+ if ($ug{0} == '@') {
echo ' <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
- }else{
+ } else {
echo ' <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
}
}
@@ -793,17 +833,17 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
}
if (!empty($this->usersgroups)) {
echo ' <optgroup label="&#160;">'.NL;
- foreach($this->usersgroups as $ug){
- if($ug == $this->who){
+ foreach ($this->usersgroups as $ug) {
+ if ($ug == $this->who) {
$sel = ' selected="selected"';
$inlist = true;
- }else{
+ } else {
$sel = '';
}
- if($ug{0} == '@'){
+ if ($ug{0} == '@') {
echo ' <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
- }else{
+ } else {
echo ' <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
}
}