xref: /dokuwiki/lib/plugins/acl/admin.php (revision c0c4ef9875d90979ed9d31ea1b6f2866aecaf565)
1<?php
2/**
3 * ACL administration functions
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 * @author     Anika Henke <anika@selfthinker.org> (concepts)
8 * @author     Frank Schubert <frank@schokilade.de> (old version)
9 */
10// must be run within Dokuwiki
11if(!defined('DOKU_INC')) die();
12
13/**
14 * All DokuWiki plugins to extend the admin function
15 * need to inherit from this class
16 */
17class admin_plugin_acl extends DokuWiki_Admin_Plugin {
18    var $acl = null;
19    var $ns  = null;
20    var $who = '';
21    var $usersgroups = array();
22    var $specials = array();
23
24    /**
25     * return some info
26     */
27    function getInfo(){
28        return array(
29            'author' => 'Andreas Gohr',
30            'email'  => 'andi@splitbrain.org',
31            'date'   => '2010-01-17',
32            'name'   => 'ACL Manager',
33            'desc'   => 'Manage Page Access Control Lists',
34            'url'    => 'http://dokuwiki.org/plugin:acl',
35        );
36    }
37
38    /**
39     * return prompt for admin menu
40     */
41    function getMenuText($language) {
42        return $this->getLang('admin_acl');
43    }
44
45    /**
46     * return sort order for position in admin menu
47     */
48    function getMenuSort() {
49        return 1;
50    }
51
52    /**
53     * handle user request
54     *
55     * Initializes internal vars and handles modifications
56     *
57     * @author Andreas Gohr <andi@splitbrain.org>
58     */
59    function handle() {
60        global $AUTH_ACL;
61        global $ID;
62        global $auth;
63
64        // fresh 1:1 copy without replacements
65        $AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
66
67
68        // namespace given?
69        if($_REQUEST['ns'] == '*'){
70            $this->ns = '*';
71        }else{
72            $this->ns = cleanID($_REQUEST['ns']);
73        }
74
75        // user or group choosen?
76        $who = trim($_REQUEST['acl_w']);
77        if($_REQUEST['acl_t'] == '__g__' && $who){
78            $this->who = '@'.ltrim($auth->cleanGroup($who),'@');
79        }elseif($_REQUEST['acl_t'] == '__u__' && $who){
80            $this->who = ltrim($auth->cleanUser($who),'@');
81        }elseif($_REQUEST['acl_t'] &&
82                $_REQUEST['acl_t'] != '__u__' &&
83                $_REQUEST['acl_t'] != '__g__'){
84            $this->who = $_REQUEST['acl_t'];
85        }elseif($who){
86            $this->who = $who;
87        }
88
89        // handle modifications
90        if(isset($_REQUEST['cmd']) && checkSecurityToken()){
91
92            // scope for modifications
93            if($this->ns){
94                if($this->ns == '*'){
95                    $scope = '*';
96                }else{
97                    $scope = $this->ns.':*';
98                }
99            }else{
100                $scope = $ID;
101            }
102
103            if(isset($_REQUEST['cmd']['save']) && $scope && $this->who && isset($_REQUEST['acl'])){
104                // handle additions or single modifications
105                $this->_acl_del($scope, $this->who);
106                $this->_acl_add($scope, $this->who, (int) $_REQUEST['acl']);
107            }elseif(isset($_REQUEST['cmd']['del']) && $scope && $this->who){
108                // handle single deletions
109                $this->_acl_del($scope, $this->who);
110            }elseif(isset($_REQUEST['cmd']['update'])){
111                // handle update of the whole file
112                foreach((array) $_REQUEST['del'] as $where => $names){
113                    // remove all rules marked for deletion
114                    foreach($names as $who)
115                        unset($_REQUEST['acl'][$where][$who]);
116                }
117                // prepare lines
118                $lines = array();
119                // keep header
120                foreach($AUTH_ACL as $line){
121                    if($line{0} == '#'){
122                        $lines[] = $line;
123                    }else{
124                        break;
125                    }
126                }
127                // re-add all rules
128                foreach((array) $_REQUEST['acl'] as $where => $opt){
129                    foreach($opt as $who => $perm){
130                        if ($who[0]=='@') {
131                            if ($who!='@ALL') {
132                                $who = '@'.ltrim($auth->cleanGroup($who),'@');
133                            }
134                        } else {
135                            $who = $auth->cleanUser($who);
136                        }
137                        $who = auth_nameencode($who,true);
138                        $lines[] = "$where\t$who\t$perm\n";
139                    }
140                }
141                // save it
142                io_saveFile(DOKU_CONF.'acl.auth.php', join('',$lines));
143            }
144
145            // reload ACL config
146            $AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
147        }
148
149        // initialize ACL array
150        $this->_init_acl_config();
151    }
152
153    /**
154     * ACL Output function
155     *
156     * print a table with all significant permissions for the
157     * current id
158     *
159     * @author  Frank Schubert <frank@schokilade.de>
160     * @author  Andreas Gohr <andi@splitbrain.org>
161     */
162    function html() {
163        global $ID;
164
165        echo '<div id="acl_manager">'.NL;
166        echo '<h1>'.$this->getLang('admin_acl').'</h1>'.NL;
167        echo '<div class="level1">'.NL;
168
169        echo '<div id="acl__tree">'.NL;
170        $this->_html_explorer($_REQUEST['ns']);
171        echo '</div>'.NL;
172
173        echo '<div id="acl__detail">'.NL;
174        $this->_html_detail();
175        echo '</div>'.NL;
176        echo '</div>'.NL;
177
178        echo '<div class="clearer"></div>';
179        echo '<h2>'.$this->getLang('current').'</h2>'.NL;
180        echo '<div class="level2">'.NL;
181        $this->_html_table();
182        echo '</div>'.NL;
183
184        echo '<div class="footnotes"><div class="fn">'.NL;
185        echo '<sup><a id="fn__1" class="fn_bot" name="fn__1" href="#fnt__1">1)</a></sup>'.NL;
186        echo $this->getLang('p_include');
187        echo '</div></div>';
188
189        echo '</div>'.NL;
190    }
191
192    /**
193     * returns array with set options for building links
194     *
195     * @author Andreas Gohr <andi@splitbrain.org>
196     */
197    function _get_opts($addopts=null){
198        global $ID;
199        $opts = array(
200                    'do'=>'admin',
201                    'page'=>'acl',
202                );
203        if($this->ns) $opts['ns'] = $this->ns;
204        if($this->who) $opts['acl_w'] = $this->who;
205
206        if(is_null($addopts)) return $opts;
207        return array_merge($opts, $addopts);
208    }
209
210    /**
211     * Display a tree menu to select a page or namespace
212     *
213     * @author Andreas Gohr <andi@splitbrain.org>
214     */
215    function _html_explorer(){
216        global $conf;
217        global $ID;
218        global $lang;
219
220        $dir = $conf['datadir'];
221        $ns  = $this->ns;
222        if(empty($ns)){
223            $ns = dirname(str_replace(':','/',$ID));
224            if($ns == '.') $ns ='';
225        }elseif($ns == '*'){
226            $ns ='';
227        }
228        $ns  = utf8_encodeFN(str_replace(':','/',$ns));
229
230        $data = $this->_get_tree($ns);
231
232        // wrap a list with the root level around the other namespaces
233        $item = array( 'level' => 0, 'id' => '*', 'type' => 'd',
234                   'open' =>'true', 'label' => '['.$lang['mediaroot'].']');
235
236        echo '<ul class="acltree">';
237        echo $this->_html_li_acl($item);
238        echo '<div class="li">';
239        echo $this->_html_list_acl($item);
240        echo '</div>';
241        echo html_buildlist($data,'acl',
242                            array($this,'_html_list_acl'),
243                            array($this,'_html_li_acl'));
244        echo '</li>';
245        echo '</ul>';
246
247    }
248
249    /**
250     * get a combined list of media and page files
251     *
252     * @param string $folder an already converted filesystem folder of the current namespace
253     * @param string $limit  limit the search to this folder
254     */
255    function _get_tree($folder,$limit=''){
256        global $conf;
257
258        // read tree structure from pages and media
259        $data = array();
260        search($data,$conf['datadir'],'search_index',array('ns' => $folder),$limit);
261        $media = array();
262        search($media,$conf['mediadir'],'search_index',array('ns' => $folder, 'nofiles' => true),$limit);
263        $data = array_merge($data,$media);
264        unset($media);
265
266        // combine by sorting and removing duplicates
267        usort($data,array($this,'_tree_sort'));
268        $count = count($data);
269        if($count>0) for($i=1; $i<$count; $i++){
270            if($data[$i]['type'] == 'f') break; // namespaces come first, we're done
271            if($data[$i-1]['id'] == $data[$i]['id']) unset($data[$i]);
272        }
273        return $data;
274    }
275
276    /**
277     * usort callback
278     *
279     * Sorts the combined trees of media and page files
280     */
281    function _tree_sort($a,$b){
282        if($a['type'] == 'd' && $b['type'] == 'f'){
283            return -1;
284        }elseif($a['type'] == 'f' && $b['type'] == 'd'){
285            return 1;
286        }else{
287            return strcmp($a['id'],$b['id']);
288        }
289    }
290
291    /**
292     * Display the current ACL for selected where/who combination with
293     * selectors and modification form
294     *
295     * @author Andreas Gohr <andi@splitbrain.org>
296     */
297    function _html_detail(){
298        global $conf;
299        global $ID;
300
301        echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
302
303        echo '<div id="acl__user">';
304        echo $this->getLang('acl_perms').' ';
305        $inl =  $this->_html_select();
306        echo '<input type="text" name="acl_w" class="edit" value="'.(($inl)?'':hsc(ltrim($this->who,'@'))).'" />'.NL;
307        echo '<input type="submit" value="'.$this->getLang('btn_select').'" class="button" />'.NL;
308        echo '</div>'.NL;
309
310        echo '<div id="acl__info">';
311        $this->_html_info();
312        echo '</div>';
313
314        echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
315        echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
316        echo '<input type="hidden" name="do" value="admin" />'.NL;
317        echo '<input type="hidden" name="page" value="acl" />'.NL;
318        echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
319        echo '</div></form>'.NL;
320    }
321
322    /**
323     * Print infos and editor
324     */
325    function _html_info(){
326        global $ID;
327
328        if($this->who){
329            $current = $this->_get_exact_perm();
330
331            // explain current permissions
332            $this->_html_explain($current);
333            // load editor
334            $this->_html_acleditor($current);
335        }else{
336            echo '<p>';
337            if($this->ns){
338                printf($this->getLang('p_choose_ns'),hsc($this->ns));
339            }else{
340                printf($this->getLang('p_choose_id'),hsc($ID));
341            }
342            echo '</p>';
343
344            echo $this->locale_xhtml('help');
345        }
346    }
347
348    /**
349     * Display the ACL editor
350     *
351     * @author Andreas Gohr <andi@splitbrain.org>
352     */
353    function _html_acleditor($current){
354        global $lang;
355
356        echo '<fieldset>';
357        if(is_null($current)){
358            echo '<legend>'.$this->getLang('acl_new').'</legend>';
359        }else{
360            echo '<legend>'.$this->getLang('acl_mod').'</legend>';
361        }
362
363
364        echo $this->_html_checkboxes($current,empty($this->ns),'acl');
365
366        if(is_null($current)){
367            echo '<input type="submit" name="cmd[save]" class="button" value="'.$lang['btn_save'].'" />'.NL;
368        }else{
369            echo '<input type="submit" name="cmd[save]" class="button" value="'.$lang['btn_update'].'" />'.NL;
370            echo '<input type="submit" name="cmd[del]" class="button" value="'.$lang['btn_delete'].'" />'.NL;
371        }
372
373        echo '</fieldset>';
374    }
375
376    /**
377     * Explain the currently set permissions in plain english/$lang
378     *
379     * @author Andreas Gohr <andi@splitbrain.org>
380     */
381    function _html_explain($current){
382        global $ID;
383        global $auth;
384
385        $who = $this->who;
386        $ns  = $this->ns;
387
388        // prepare where to check
389        if($ns){
390            if($ns == '*'){
391                $check='*';
392            }else{
393                $check=$ns.':*';
394            }
395        }else{
396            $check = $ID;
397        }
398
399        // prepare who to check
400        if($who{0} == '@'){
401            $user   = '';
402            $groups = array(ltrim($who,'@'));
403        }else{
404            $user = auth_nameencode($who);
405            $info = $auth->getUserData($user);
406            if($info === false){
407                $groups = array();
408            }else{
409                $groups = $info['grps'];
410            }
411        }
412
413        // check the permissions
414        $perm = auth_aclcheck($check,$user,$groups);
415
416        // build array of named permissions
417        $names = array();
418        if($perm){
419            if($ns){
420                if($perm >= AUTH_DELETE) $names[] = $this->getLang('acl_perm16');
421                if($perm >= AUTH_UPLOAD) $names[] = $this->getLang('acl_perm8');
422                if($perm >= AUTH_CREATE) $names[] = $this->getLang('acl_perm4');
423            }
424            if($perm >= AUTH_EDIT) $names[] = $this->getLang('acl_perm2');
425            if($perm >= AUTH_READ) $names[] = $this->getLang('acl_perm1');
426            $names = array_reverse($names);
427        }else{
428            $names[] = $this->getLang('acl_perm0');
429        }
430
431        // print permission explanation
432        echo '<p>';
433        if($user){
434            if($ns){
435                printf($this->getLang('p_user_ns'),hsc($who),hsc($ns),join(', ',$names));
436            }else{
437                printf($this->getLang('p_user_id'),hsc($who),hsc($ID),join(', ',$names));
438            }
439        }else{
440            if($ns){
441                printf($this->getLang('p_group_ns'),hsc(ltrim($who,'@')),hsc($ns),join(', ',$names));
442            }else{
443                printf($this->getLang('p_group_id'),hsc(ltrim($who,'@')),hsc($ID),join(', ',$names));
444            }
445        }
446        echo '</p>';
447
448        // add note if admin
449        if($perm == AUTH_ADMIN){
450            echo '<p>'.$this->getLang('p_isadmin').'</p>';
451        }elseif(is_null($current)){
452            echo '<p>'.$this->getLang('p_inherited').'</p>';
453        }
454    }
455
456
457    /**
458     * Item formatter for the tree view
459     *
460     * User function for html_buildlist()
461     *
462     * @author Andreas Gohr <andi@splitbrain.org>
463     */
464    function _html_list_acl($item){
465        global $ID;
466        $ret = '';
467        // what to display
468        if($item['label']){
469            $base = $item['label'];
470        }else{
471            $base = ':'.$item['id'];
472            $base = substr($base,strrpos($base,':')+1);
473        }
474
475        // highlight?
476        if( ($item['type']=='d' && $item['id'] == $this->ns) ||
477            ($item['type']!='d' && $item['id'] == $ID)) $cl = ' cur';
478
479        // namespace or page?
480        if($item['type']=='d'){
481            if($item['open']){
482                $img   = DOKU_BASE.'lib/images/minus.gif';
483                $alt   = '&minus;';
484            }else{
485                $img   = DOKU_BASE.'lib/images/plus.gif';
486                $alt   = '+';
487            }
488            $ret .= '<img src="'.$img.'" alt="'.$alt.'" />';
489            $ret .= '<a href="'.wl('',$this->_get_opts(array('ns'=>$item['id'],'sectok'=>getSecurityToken()))).'" class="idx_dir'.$cl.'">';
490            $ret .= $base;
491            $ret .= '</a>';
492        }else{
493            $ret .= '<a href="'.wl('',$this->_get_opts(array('id'=>$item['id'],'ns'=>'','sectok'=>getSecurityToken()))).'" class="wikilink1'.$cl.'">';
494            $ret .= noNS($item['id']);
495            $ret .= '</a>';
496        }
497        return $ret;
498    }
499
500
501    function _html_li_acl($item){
502            return '<li class="level'.$item['level'].'">';
503    }
504
505
506    /**
507     * Get current ACL settings as multidim array
508     *
509     * @author Andreas Gohr <andi@splitbrain.org>
510     */
511    function _init_acl_config(){
512        global $AUTH_ACL;
513        global $conf;
514        $acl_config=array();
515        $usersgroups = array();
516
517        // get special users and groups
518        $this->specials[] = '@ALL';
519        $this->specials[] = '@'.$conf['defaultgroup'];
520        if($conf['manager'] != '!!not set!!'){
521            $this->specials = array_merge($this->specials,
522                                          array_map('trim',
523                                                    explode(',',$conf['manager'])));
524        }
525        $this->specials = array_filter($this->specials);
526        $this->specials = array_unique($this->specials);
527        sort($this->specials);
528
529        foreach($AUTH_ACL as $line){
530            $line = trim(preg_replace('/#.*$/','',$line)); //ignore comments
531            if(!$line) continue;
532
533            $acl = preg_split('/\s+/',$line);
534            //0 is pagename, 1 is user, 2 is acl
535
536            $acl[1] = rawurldecode($acl[1]);
537            $acl_config[$acl[0]][$acl[1]] = $acl[2];
538
539            // store non-special users and groups for later selection dialog
540            $ug = $acl[1];
541            if(in_array($ug,$this->specials)) continue;
542            $usersgroups[] = $ug;
543        }
544
545        $usersgroups = array_unique($usersgroups);
546        sort($usersgroups);
547        ksort($acl_config);
548
549        $this->acl = $acl_config;
550        $this->usersgroups = $usersgroups;
551    }
552
553    /**
554     * Display all currently set permissions in a table
555     *
556     * @author Andreas Gohr <andi@splitbrain.org>
557     */
558    function _html_table(){
559        global $lang;
560        global $ID;
561
562        echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
563        if($this->ns){
564            echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
565        }else{
566            echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
567        }
568        echo '<input type="hidden" name="acl_w" value="'.hsc($this->who).'" />'.NL;
569        echo '<input type="hidden" name="do" value="admin" />'.NL;
570        echo '<input type="hidden" name="page" value="acl" />'.NL;
571        echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
572        echo '<table class="inline">';
573        echo '<tr>';
574        echo '<th>'.$this->getLang('where').'</th>';
575        echo '<th>'.$this->getLang('who').'</th>';
576        echo '<th>'.$this->getLang('perm').'<sup><a id="fnt__1" class="fn_top" name="fnt__1" href="#fn__1">1)</a></sup></th>';
577        echo '<th>'.$lang['btn_delete'].'</th>';
578        echo '</tr>';
579        foreach($this->acl as $where => $set){
580            foreach($set as $who => $perm){
581                echo '<tr>';
582                echo '<td>';
583                if(substr($where,-1) == '*'){
584                    echo '<span class="aclns">'.hsc($where).'</span>';
585                    $ispage = false;
586                }else{
587                    echo '<span class="aclpage">'.hsc($where).'</span>';
588                    $ispage = true;
589                }
590                echo '</td>';
591
592                echo '<td>';
593                if($who{0} == '@'){
594                    echo '<span class="aclgroup">'.hsc($who).'</span>';
595                }else{
596                    echo '<span class="acluser">'.hsc($who).'</span>';
597                }
598                echo '</td>';
599
600                echo '<td>';
601                echo $this->_html_checkboxes($perm,$ispage,'acl['.$where.']['.$who.']');
602                echo '</td>';
603
604                echo '<td align="center">';
605                echo '<input type="checkbox" name="del['.hsc($where).'][]" value="'.hsc($who).'" />';
606                echo '</td>';
607                echo '</tr>';
608            }
609        }
610
611        echo '<tr>';
612        echo '<th align="right" colspan="4">';
613        echo '<input type="submit" value="'.$lang['btn_update'].'" name="cmd[update]" class="button" />';
614        echo '</th>';
615        echo '</tr>';
616        echo '</table>';
617        echo '</div></form>'.NL;
618    }
619
620
621    /**
622     * Returns the permission which were set for exactly the given user/group
623     * and page/namespace. Returns null if no exact match is available
624     *
625     * @author Andreas Gohr <andi@splitbrain.org>
626     */
627    function _get_exact_perm(){
628        global $ID;
629        if($this->ns){
630            if($this->ns == '*'){
631                $check = '*';
632            }else{
633                $check = $this->ns.':*';
634            }
635        }else{
636            $check = $ID;
637        }
638
639        if(isset($this->acl[$check][$this->who])){
640            return $this->acl[$check][$this->who];
641        }else{
642            return null;
643        }
644    }
645
646    /**
647     * adds new acl-entry to conf/acl.auth.php
648     *
649     * @author  Frank Schubert <frank@schokilade.de>
650     */
651    function _acl_add($acl_scope, $acl_user, $acl_level){
652        $acl_config = file_get_contents(DOKU_CONF.'acl.auth.php');
653        $acl_user = auth_nameencode($acl_user,true);
654
655        // max level for pagenames is edit
656        if(strpos($acl_scope,'*') === false) {
657            if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT;
658        }
659
660
661        $new_acl = "$acl_scope\t$acl_user\t$acl_level\n";
662
663        $new_config = $acl_config.$new_acl;
664
665        return io_saveFile(DOKU_CONF.'acl.auth.php', $new_config);
666    }
667
668    /**
669     * remove acl-entry from conf/acl.auth.php
670     *
671     * @author  Frank Schubert <frank@schokilade.de>
672     */
673    function _acl_del($acl_scope, $acl_user){
674        $acl_config = file(DOKU_CONF.'acl.auth.php');
675        $acl_user = auth_nameencode($acl_user,true);
676
677        $acl_pattern = '^'.preg_quote($acl_scope,'/').'\s+'.$acl_user.'\s+[0-8].*$';
678
679        // save all non!-matching
680        $new_config = preg_grep("/$acl_pattern/", $acl_config, PREG_GREP_INVERT);
681
682        return io_saveFile(DOKU_CONF.'acl.auth.php', join('',$new_config));
683    }
684
685    /**
686     * print the permission radio boxes
687     *
688     * @author  Frank Schubert <frank@schokilade.de>
689     * @author  Andreas Gohr <andi@splitbrain.org>
690     */
691    function _html_checkboxes($setperm,$ispage,$name){
692        global $lang;
693
694        static $label = 0; //number labels
695        $ret = '';
696
697        if($ispage && $setperm > AUTH_EDIT) $perm = AUTH_EDIT;
698
699        foreach(array(AUTH_NONE,AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm){
700            $label += 1;
701
702            //general checkbox attributes
703            $atts = array( 'type'  => 'radio',
704                           'id'    => 'pbox'.$label,
705                           'name'  => $name,
706                           'value' => $perm );
707            //dynamic attributes
708            if(!is_null($setperm) && $setperm == $perm) $atts['checked']  = 'checked';
709            if($ispage && $perm > AUTH_EDIT){
710                $atts['disabled'] = 'disabled';
711                $class = ' class="disabled"';
712            }else{
713                $class = '';
714            }
715
716            //build code
717            $ret .= '<label for="pbox'.$label.'" title="'.$this->getLang('acl_perm'.$perm).'"'.$class.'>';
718            $ret .= '<input '.html_attbuild($atts).' />&nbsp;';
719            $ret .= $this->getLang('acl_perm'.$perm);
720            $ret .= '</label>'.NL;
721        }
722        return $ret;
723    }
724
725    /**
726     * Print a user/group selector (reusing already used users and groups)
727     *
728     * @author  Andreas Gohr <andi@splitbrain.org>
729     */
730    function _html_select(){
731        global $conf;
732        $inlist = false;
733
734        if($this->who &&
735           !in_array($this->who,$this->usersgroups) &&
736           !in_array($this->who,$this->specials)){
737
738            if($this->who{0} == '@'){
739                $gsel = ' selected="selected"';
740            }else{
741                $usel   = ' selected="selected"';
742            }
743        }else{
744            $usel = '';
745            $gsel = '';
746            $inlist = true;
747        }
748
749
750        echo '<select name="acl_t" class="edit">'.NL;
751        echo '  <option value="__g__" class="aclgroup"'.$gsel.'>'.$this->getLang('acl_group').':</option>'.NL;
752        echo '  <option value="__u__"  class="acluser"'.$usel.'>'.$this->getLang('acl_user').':</option>'.NL;
753        echo '  <optgroup label="&nbsp;">'.NL;
754        foreach($this->specials as $ug){
755            if($ug == $this->who){
756                $sel    = ' selected="selected"';
757                $inlist = true;
758            }else{
759                $sel = '';
760            }
761
762            if($ug{0} == '@'){
763                    echo '  <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
764            }else{
765                    echo '  <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
766            }
767        }
768        echo '  </optgroup>'.NL;
769        echo '  <optgroup label="&nbsp;">'.NL;
770        foreach($this->usersgroups as $ug){
771            if($ug == $this->who){
772                $sel    = ' selected="selected"';
773                $inlist = true;
774            }else{
775                $sel = '';
776            }
777
778            if($ug{0} == '@'){
779                    echo '  <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
780            }else{
781                    echo '  <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
782            }
783        }
784        echo '  </optgroup>'.NL;
785        echo '</select>'.NL;
786        return $inlist;
787    }
788}
789