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.php331
1 files changed, 171 insertions, 160 deletions
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php
index a295692f2..3a2857f62 100644
--- a/lib/plugins/acl/admin.php
+++ b/lib/plugins/acl/admin.php
@@ -1,4 +1,6 @@
<?php
+
+use dokuwiki\Extension\AdminPlugin;
use dokuwiki\Utf8\Sort;
/**
@@ -14,10 +16,10 @@ use dokuwiki\Utf8\Sort;
* All DokuWiki plugins to extend the admin function
* need to inherit from this class
*/
-class admin_plugin_acl extends DokuWiki_Admin_Plugin
+class admin_plugin_acl extends AdminPlugin
{
- public $acl = null;
- protected $ns = null;
+ public $acl;
+ protected $ns;
/**
* The currently selected item, associative array with id and type.
* Populated from (in this order):
@@ -26,10 +28,10 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
* $ns
* $ID
*/
- protected $current_item = null;
+ protected $current_item;
protected $who = '';
- protected $usersgroups = array();
- protected $specials = array();
+ protected $usersgroups = [];
+ protected $specials = [];
/**
* return prompt for admin menu
@@ -73,27 +75,29 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
}
if ($INPUT->str('current_ns')) {
- $this->current_item = array('id' => cleanID($INPUT->str('current_ns')), 'type' => 'd');
+ $this->current_item = ['id' => cleanID($INPUT->str('current_ns')), 'type' => 'd'];
} elseif ($INPUT->str('current_id')) {
- $this->current_item = array('id' => cleanID($INPUT->str('current_id')), 'type' => 'f');
+ $this->current_item = ['id' => cleanID($INPUT->str('current_id')), 'type' => 'f'];
} elseif ($this->ns) {
- $this->current_item = array('id' => $this->ns, 'type' => 'd');
+ $this->current_item = ['id' => $this->ns, 'type' => 'd'];
} else {
- $this->current_item = array('id' => $ID, 'type' => 'f');
+ $this->current_item = ['id' => $ID, 'type' => 'f'];
}
// user or group choosen?
$who = trim($INPUT->str('acl_w'));
if ($INPUT->str('acl_t') == '__g__' && $who) {
- $this->who = '@'.ltrim($auth->cleanGroup($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') &&
- $INPUT->str('acl_t') != '__u__' &&
- $INPUT->str('acl_t') != '__g__') {
+ } elseif (
+ $INPUT->str('acl_t') &&
+ $INPUT->str('acl_t') != '__u__' &&
+ $INPUT->str('acl_t') != '__g__'
+ ) {
$this->who = $INPUT->str('acl_t');
} elseif ($who) {
$this->who = $who;
@@ -108,7 +112,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
if ($this->ns == '*') {
$scope = '*';
} else {
- $scope = $this->ns.':*';
+ $scope = $this->ns . ':*';
}
} else {
$scope = $ID;
@@ -131,7 +135,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
unset($acl[$where][$who]);
}
// prepare lines
- $lines = array();
+ $lines = [];
// keep header
foreach ($AUTH_ACL as $line) {
if ($line[0] == '#') {
@@ -143,9 +147,9 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
// re-add all rules
foreach ($acl as $where => $opt) {
foreach ($opt as $who => $perm) {
- if ($who[0]=='@') {
- if ($who!='@ALL') {
- $who = '@'.ltrim($auth->cleanGroup($who), '@');
+ if ($who[0] == '@') {
+ if ($who != '@ALL') {
+ $who = '@' . ltrim($auth->cleanGroup($who), '@');
}
} elseif ($who != '%USER%' && $who != '%GROUP%') { #keep wildcard as is
$who = $auth->cleanUser($who);
@@ -155,7 +159,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
}
}
// save it
- io_saveFile($config_cascade['acl']['default'], join('', $lines));
+ io_saveFile($config_cascade['acl']['default'], implode('', $lines));
}
// reload ACL config
@@ -177,31 +181,31 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
*/
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_manager">';
+ echo '<h1>' . $this->getLang('admin_acl') . '</h1>';
+ echo '<div class="level1">';
- echo '<div id="acl__tree">'.NL;
+ echo '<div id="acl__tree">';
$this->makeExplorer();
- echo '</div>'.NL;
+ echo '</div>';
- echo '<div id="acl__detail">'.NL;
+ echo '<div id="acl__detail">';
$this->printDetail();
- echo '</div>'.NL;
- echo '</div>'.NL;
+ echo '</div>';
+ echo '</div>';
echo '<div class="clearer"></div>';
- echo '<h2>'.$this->getLang('current').'</h2>'.NL;
- echo '<div class="level2">'.NL;
+ echo '<h2>' . $this->getLang('current') . '</h2>';
+ echo '<div class="level2">';
$this->printAclTable();
- echo '</div>'.NL;
+ echo '</div>';
- echo '<div class="footnotes"><div class="fn">'.NL;
- echo '<sup><a id="fn__1" class="fn_bot" href="#fnt__1">1)</a></sup>'.NL;
- echo '<div class="content">'.$this->getLang('p_include').'</div>';
+ echo '<div class="footnotes"><div class="fn">';
+ echo '<sup><a id="fn__1" class="fn_bot" href="#fnt__1">1)</a></sup>';
+ echo '<div class="content">' . $this->getLang('p_include') . '</div>';
echo '</div></div>';
- echo '</div>'.NL;
+ echo '</div>';
}
/**
@@ -211,10 +215,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
*/
protected function getLinkOptions($addopts = null)
{
- $opts = array(
- 'do'=>'admin',
- 'page'=>'acl',
- );
+ $opts = ['do' => 'admin', 'page' => 'acl'];
if ($this->ns) $opts['ns'] = $this->ns;
if ($this->who) $opts['acl_w'] = $this->who;
@@ -233,26 +234,31 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
global $ID;
global $lang;
- $ns = $this->ns;
+ $ns = $this->ns;
if (empty($ns)) {
$ns = dirname(str_replace(':', '/', $ID));
- if ($ns == '.') $ns ='';
+ if ($ns == '.') $ns = '';
} elseif ($ns == '*') {
- $ns ='';
+ $ns = '';
}
- $ns = utf8_encodeFN(str_replace(':', '/', $ns));
+ $ns = utf8_encodeFN(str_replace(':', '/', $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'].']'));
+ array_unshift($data, [
+ 'level' => 0,
+ 'id' => '*',
+ 'type' => 'd',
+ 'open' => 'true',
+ 'label' => '[' . $lang['mediaroot'] . ']'
+ ]);
echo html_buildlist(
$data,
'acl',
- array($this, 'makeTreeItem'),
- array($this, 'makeListItem')
+ [$this, 'makeTreeItem'],
+ [$this, 'makeListItem']
);
}
@@ -270,18 +276,18 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
global $conf;
// read tree structure from pages and media
- $data = array();
- 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 = [];
+ search($data, $conf['datadir'], 'search_index', ['ns' => $folder], $limit);
+ $media = [];
+ search($media, $conf['mediadir'], 'search_index', ['ns' => $folder, 'nofiles' => true], $limit);
$data = array_merge($data, $media);
unset($media);
// combine by sorting and removing duplicates
- usort($data, array($this, 'treeSort'));
+ usort($data, [$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
}
@@ -311,14 +317,14 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
// if one of the components is the last component and is a file
// and the other one is either of a deeper level or a directory,
// the file has to come after the deeper level or directory
- if (empty($a_ids) && $a['type'] == 'f' && (count($b_ids) || $b['type'] == 'd')) return 1;
- if (empty($b_ids) && $b['type'] == 'f' && (count($a_ids) || $a['type'] == 'd')) return -1;
+ if ($a_ids === [] && $a['type'] == 'f' && (count($b_ids) || $b['type'] == 'd')) return 1;
+ if ($b_ids === [] && $b['type'] == 'f' && (count($a_ids) || $a['type'] == 'd')) return -1;
return $cur_result;
}
}
// The two ids seem to be equal. One of them might however refer
// to a page, one to a namespace, the namespace needs to be first.
- if (empty($a_ids) && empty($b_ids)) {
+ if ($a_ids === [] && $b_ids === []) {
if ($a['type'] == $b['type']) return 0;
if ($a['type'] == 'f') return 1;
return -1;
@@ -327,8 +333,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
// that obviously needs to be after the namespace
// Or it is the namespace that contains the other part and should be
// before that other part.
- if (empty($a_ids)) return ($a['type'] == 'd') ? -1 : 1;
- if (empty($b_ids)) return ($b['type'] == 'd') ? 1 : -1;
+ if ($a_ids === []) return ($a['type'] == 'd') ? -1 : 1;
+ if ($b_ids === []) return ($b['type'] == 'd') ? 1 : -1;
return 0; //shouldn't happen
}
@@ -342,25 +348,28 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
{
global $ID;
- echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
+ echo '<form action="' . wl() . '" method="post" accept-charset="utf-8"><div class="no">';
echo '<div id="acl__user">';
- echo $this->getLang('acl_perms').' ';
- $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 $this->getLang('acl_perms') . ' ';
+ $inl = $this->makeSelect();
+ echo sprintf(
+ '<input type="text" name="acl_w" class="edit" value="%s" />',
+ ($inl) ? '' : hsc(ltrim($this->who, '@'))
+ );
+ echo '<button type="submit">' . $this->getLang('btn_select') . '</button>';
+ echo '</div>';
echo '<div id="acl__info">';
$this->printInfo();
echo '</div>';
- echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
- echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
- echo '<input type="hidden" name="do" value="admin" />'.NL;
- echo '<input type="hidden" name="page" value="acl" />'.NL;
- echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
- echo '</div></form>'.NL;
+ echo '<input type="hidden" name="ns" value="' . hsc($this->ns) . '" />';
+ echo '<input type="hidden" name="id" value="' . hsc($ID) . '" />';
+ echo '<input type="hidden" name="do" value="admin" />';
+ echo '<input type="hidden" name="page" value="acl" />';
+ echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
+ echo '</div></form>';
}
/**
@@ -403,18 +412,18 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
echo '<fieldset>';
if (is_null($current)) {
- echo '<legend>'.$this->getLang('acl_new').'</legend>';
+ echo '<legend>' . $this->getLang('acl_new') . '</legend>';
} else {
- echo '<legend>'.$this->getLang('acl_mod').'</legend>';
+ echo '<legend>' . $this->getLang('acl_mod') . '</legend>';
}
echo $this->makeCheckboxes($current, empty($this->ns), 'acl');
if (is_null($current)) {
- echo '<button type="submit" name="cmd[save]">'.$lang['btn_save'].'</button>'.NL;
+ echo '<button type="submit" name="cmd[save]">' . $lang['btn_save'] . '</button>';
} 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;
+ echo '<button type="submit" name="cmd[save]">' . $lang['btn_update'] . '</button>';
+ echo '<button type="submit" name="cmd[del]">' . $lang['btn_delete'] . '</button>';
}
echo '</fieldset>';
@@ -431,14 +440,14 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
global $auth;
$who = $this->who;
- $ns = $this->ns;
+ $ns = $this->ns;
// prepare where to check
if ($ns) {
if ($ns == '*') {
- $check='*';
+ $check = '*';
} else {
- $check=$ns.':*';
+ $check = $ns . ':*';
}
} else {
$check = $ID;
@@ -446,13 +455,13 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
// prepare who to check
if ($who[0] == '@') {
- $user = '';
- $groups = array(ltrim($who, '@'));
+ $user = '';
+ $groups = [ltrim($who, '@')];
} else {
$user = $who;
$info = $auth->getUserData($user);
if ($info === false) {
- $groups = array();
+ $groups = [];
} else {
$groups = $info['grps'];
}
@@ -462,7 +471,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
$perm = auth_aclcheck($check, $user, $groups);
// build array of named permissions
- $names = array();
+ $names = [];
if ($perm) {
if ($ns) {
if ($perm >= AUTH_DELETE) $names[] = $this->getLang('acl_perm16');
@@ -480,24 +489,22 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
echo '<p>';
if ($user) {
if ($ns) {
- printf($this->getLang('p_user_ns'), hsc($who), hsc($ns), join(', ', $names));
+ printf($this->getLang('p_user_ns'), hsc($who), hsc($ns), implode(', ', $names));
} else {
- printf($this->getLang('p_user_id'), hsc($who), hsc($ID), join(', ', $names));
+ printf($this->getLang('p_user_id'), hsc($who), hsc($ID), implode(', ', $names));
}
+ } elseif ($ns) {
+ printf($this->getLang('p_group_ns'), hsc(ltrim($who, '@')), hsc($ns), implode(', ', $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));
- }
+ printf($this->getLang('p_group_id'), hsc(ltrim($who, '@')), hsc($ID), implode(', ', $names));
}
echo '</p>';
// add note if admin
if ($perm == AUTH_ADMIN) {
- echo '<p>'.$this->getLang('p_isadmin').'</p>';
+ echo '<p>' . $this->getLang('p_isadmin') . '</p>';
} elseif (is_null($current)) {
- echo '<p>'.$this->getLang('p_inherited').'</p>';
+ echo '<p>' . $this->getLang('p_inherited') . '</p>';
}
}
@@ -516,36 +523,36 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
if (!empty($item['label'])) {
$base = $item['label'];
} else {
- $base = ':'.$item['id'];
- $base = substr($base, strrpos($base, ':')+1);
+ $base = ':' . $item['id'];
+ $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['type'] == 'd') {
if ($item['open']) {
- $img = DOKU_BASE.'lib/images/minus.gif';
- $alt = '−';
+ $img = DOKU_BASE . 'lib/images/minus.gif';
+ $alt = '−';
} else {
- $img = DOKU_BASE.'lib/images/plus.gif';
- $alt = '+';
+ $img = DOKU_BASE . 'lib/images/plus.gif';
+ $alt = '+';
}
- $ret .= '<img src="'.$img.'" alt="'.$alt.'" />';
- $ret .= '<a href="'.
- wl('', $this->getLinkOptions(array('ns'=> $item['id'], 'sectok'=>getSecurityToken()))).
- '" class="idx_dir'.$cl.'">';
+ $ret .= '<img src="' . $img . '" alt="' . $alt . '" />';
+ $ret .= '<a href="' .
+ wl('', $this->getLinkOptions(['ns' => $item['id'], 'sectok' => getSecurityToken()])) .
+ '" class="idx_dir' . $cl . '">';
$ret .= $base;
$ret .= '</a>';
} else {
- $ret .= '<a href="'.
- wl('', $this->getLinkOptions(array('id'=> $item['id'], 'ns'=>'', 'sectok'=>getSecurityToken()))).
- '" class="wikilink1'.$cl.'">';
+ $ret .= '<a href="' .
+ wl('', $this->getLinkOptions(['id' => $item['id'], 'ns' => '', 'sectok' => getSecurityToken()])) .
+ '" class="wikilink1' . $cl . '">';
$ret .= noNS($item['id']);
$ret .= '</a>';
}
@@ -561,7 +568,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
public function makeListItem($item)
{
return '<li class="level' . $item['level'] . ' ' .
- ($item['open'] ? 'open' : 'closed') . '">';
+ ($item['open'] ? 'open' : 'closed') . '">';
}
@@ -574,12 +581,12 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
{
global $AUTH_ACL;
global $conf;
- $acl_config=array();
- $usersgroups = array();
+ $acl_config = [];
+ $usersgroups = [];
// get special users and groups
$this->specials[] = '@ALL';
- $this->specials[] = '@'.$conf['defaultgroup'];
+ $this->specials[] = '@' . $conf['defaultgroup'];
if ($conf['manager'] != '!!not set!!') {
$this->specials = array_merge(
$this->specials,
@@ -630,51 +637,51 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
global $lang;
global $ID;
- echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
+ echo '<form action="' . wl() . '" method="post" accept-charset="utf-8"><div class="no">';
if ($this->ns) {
- echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
+ echo '<input type="hidden" name="ns" value="' . hsc($this->ns) . '" />';
} else {
- echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
+ echo '<input type="hidden" name="id" value="' . hsc($ID) . '" />';
}
- echo '<input type="hidden" name="acl_w" value="'.hsc($this->who).'" />'.NL;
- echo '<input type="hidden" name="do" value="admin" />'.NL;
- echo '<input type="hidden" name="page" value="acl" />'.NL;
- echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
+ echo '<input type="hidden" name="acl_w" value="' . hsc($this->who) . '" />';
+ echo '<input type="hidden" name="do" value="admin" />';
+ echo '<input type="hidden" name="page" value="acl" />';
+ echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
echo '<div class="table">';
echo '<table class="inline">';
echo '<tr>';
- echo '<th>'.$this->getLang('where').'</th>';
- echo '<th>'.$this->getLang('who').'</th>';
- 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 '<th>' . $this->getLang('where') . '</th>';
+ echo '<th>' . $this->getLang('who') . '</th>';
+ 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) {
echo '<tr>';
echo '<td>';
if (substr($where, -1) == '*') {
- echo '<span class="aclns">'.hsc($where).'</span>';
+ echo '<span class="aclns">' . hsc($where) . '</span>';
$ispage = false;
} else {
- echo '<span class="aclpage">'.hsc($where).'</span>';
+ echo '<span class="aclpage">' . hsc($where) . '</span>';
$ispage = true;
}
echo '</td>';
echo '<td>';
if ($who[0] == '@') {
- echo '<span class="aclgroup">'.hsc($who).'</span>';
+ echo '<span class="aclgroup">' . hsc($who) . '</span>';
} else {
- echo '<span class="acluser">'.hsc($who).'</span>';
+ echo '<span class="acluser">' . hsc($who) . '</span>';
}
echo '</td>';
echo '<td>';
- echo $this->makeCheckboxes($perm, $ispage, 'acl['.$where.']['.$who.']');
+ echo $this->makeCheckboxes($perm, $ispage, 'acl[' . $where . '][' . $who . ']');
echo '</td>';
echo '<td class="check">';
- echo '<input type="checkbox" name="del['.hsc($where).'][]" value="'.hsc($who).'" />';
+ echo '<input type="checkbox" name="del[' . hsc($where) . '][]" value="' . hsc($who) . '" />';
echo '</td>';
echo '</tr>';
}
@@ -682,12 +689,12 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
echo '<tr>';
echo '<th class="action" colspan="4">';
- echo '<button type="submit" name="cmd[update]">'.$lang['btn_update'].'</button>';
+ echo '<button type="submit" name="cmd[update]">' . $lang['btn_update'] . '</button>';
echo '</th>';
echo '</tr>';
echo '</table>';
echo '</div>';
- echo '</div></form>'.NL;
+ echo '</div></form>';
}
/**
@@ -703,7 +710,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
if ($this->ns == '*') {
$check = '*';
} else {
- $check = $this->ns.':*';
+ $check = $this->ns . ':*';
}
} else {
$check = $ID;
@@ -749,7 +756,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
global $config_cascade;
$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);
}
@@ -769,16 +776,18 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
if ($ispage && $setperm > AUTH_EDIT) $setperm = AUTH_EDIT;
- foreach (array(AUTH_NONE,AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm) {
- $label += 1;
+ foreach ([AUTH_NONE, AUTH_READ, AUTH_EDIT, AUTH_CREATE, AUTH_UPLOAD, AUTH_DELETE] as $perm) {
+ ++$label;
//general checkbox attributes
- $atts = array( 'type' => 'radio',
- 'id' => 'pbox'.$label,
- 'name' => $name,
- 'value' => $perm );
+ $atts = [
+ 'type' => 'radio',
+ 'id' => 'pbox' . $label,
+ 'name' => $name,
+ 'value' => $perm
+ ];
//dynamic attributes
- if (!is_null($setperm) && $setperm == $perm) $atts['checked'] = 'checked';
+ if (!is_null($setperm) && $setperm == $perm) $atts['checked'] = 'checked';
if ($ispage && $perm > AUTH_EDIT) {
$atts['disabled'] = 'disabled';
$class = ' class="disabled"';
@@ -787,10 +796,10 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
}
//build code
- $ret .= '<label for="pbox'.$label.'"'.$class.'>';
- $ret .= '<input '.buildAttributes($atts).' />&#160;';
- $ret .= $this->getLang('acl_perm'.$perm);
- $ret .= '</label>'.NL;
+ $ret .= '<label for="pbox' . $label . '"' . $class . '>';
+ $ret .= '<input ' . buildAttributes($atts) . ' />&#160;';
+ $ret .= $this->getLang('acl_perm' . $perm);
+ $ret .= '</label>';
}
return $ret;
}
@@ -806,9 +815,11 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
$usel = '';
$gsel = '';
- if ($this->who &&
- !in_array($this->who, $this->usersgroups) &&
- !in_array($this->who, $this->specials)) {
+ if (
+ $this->who &&
+ !in_array($this->who, $this->usersgroups) &&
+ !in_array($this->who, $this->specials)
+ ) {
if ($this->who[0] == '@') {
$gsel = ' selected="selected"';
} else {
@@ -818,46 +829,46 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin
$inlist = true;
}
- echo '<select name="acl_t" class="edit">'.NL;
- echo ' <option value="__g__" class="aclgroup"'.$gsel.'>'.$this->getLang('acl_group').'</option>'.NL;
- echo ' <option value="__u__" class="acluser"'.$usel.'>'.$this->getLang('acl_user').'</option>'.NL;
+ echo '<select name="acl_t" class="edit">';
+ echo ' <option value="__g__" class="aclgroup"' . $gsel . '>' . $this->getLang('acl_group') . '</option>';
+ echo ' <option value="__u__" class="acluser"' . $usel . '>' . $this->getLang('acl_user') . '</option>';
if (!empty($this->specials)) {
- echo ' <optgroup label="&#160;">'.NL;
+ echo ' <optgroup label="&#160;">';
foreach ($this->specials as $ug) {
if ($ug == $this->who) {
- $sel = ' selected="selected"';
+ $sel = ' selected="selected"';
$inlist = true;
} else {
$sel = '';
}
if ($ug[0] == '@') {
- echo ' <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
+ echo ' <option value="' . hsc($ug) . '" class="aclgroup"' . $sel . '>' . hsc($ug) . '</option>';
} else {
- echo ' <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
+ echo ' <option value="' . hsc($ug) . '" class="acluser"' . $sel . '>' . hsc($ug) . '</option>';
}
}
- echo ' </optgroup>'.NL;
+ echo ' </optgroup>';
}
if (!empty($this->usersgroups)) {
- echo ' <optgroup label="&#160;">'.NL;
+ echo ' <optgroup label="&#160;">';
foreach ($this->usersgroups as $ug) {
if ($ug == $this->who) {
- $sel = ' selected="selected"';
+ $sel = ' selected="selected"';
$inlist = true;
} else {
$sel = '';
}
if ($ug[0] == '@') {
- echo ' <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
+ echo ' <option value="' . hsc($ug) . '" class="aclgroup"' . $sel . '>' . hsc($ug) . '</option>';
} else {
- echo ' <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
+ echo ' <option value="' . hsc($ug) . '" class="acluser"' . $sel . '>' . hsc($ug) . '</option>';
}
}
- echo ' </optgroup>'.NL;
+ echo ' </optgroup>';
}
- echo '</select>'.NL;
+ echo '</select>';
return $inlist;
}
}