DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:superacl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
plugin:superacl [2010-10-12 00:58] – [Current edition] grammar: loose --> lose 96.49.203.55plugin:superacl [2013-10-24 17:56] qianhd
Line 1: Line 1:
 +test!!! can i edit this page with out check by admin??
 +
 ====== DokuWiki Plugin: superacl ====== ====== DokuWiki Plugin: superacl ======
  
Line 7: Line 9:
 type       : admin type       : admin
 lastupdate : 2008-05-25 lastupdate : 2008-05-25
-compatible : 2006-11-06, 2007-06-26, 2008-05-05+compatible : 2010-11-07, 2006-11-06, 2007-06-26, 2008-05-05
 depends    :  depends    : 
 conflicts  conflicts 
Line 24: Line 26:
 ==== Download / Installation ==== ==== Download / Installation ====
  
-Download the plugin here (manually or via Plugin Manager): http://pb.wh4f.de/dokuwiki/superacl2.zip //:!: Use this download only for DokuWiki 2008-05-05!//+Download the plugin here (manually or via Plugin Manager): http://pb.wh4f.de/dokuwiki/superacl2.zip //:!: Use this download only for DokuWiki 2008-05-05 and newer!//
  
 ===== Former edition ===== ===== Former edition =====
Line 48: Line 50:
 /** /**
  * Global ACL overview  * Global ACL overview
- + *
  * Borrowed a lot of code from the aclPlugin  * Borrowed a lot of code from the aclPlugin
  *  *
Line 66: Line 68:
  */  */
 class admin_plugin_superacl extends DokuWiki_Admin_Plugin { class admin_plugin_superacl extends DokuWiki_Admin_Plugin {
-  
-        function admin_plugin_superacl(){ 
-            $this->setupLocale(); 
-        } 
- 
  
 +    function admin_plugin_superacl(){
 +        $this->setupLocale();
 +    }
  
     /**     /**
Line 77: Line 77:
      */      */
     function getInfo(){     function getInfo(){
-      return array( +        return array( 
-        'author' => 'Pascal Bihler', +            'author' => 'Pascal Bihler', 
-        'email'  => 'bihler@iai.uni-bonn.de', +            'email'  => 'bihler@iai.uni-bonn.de', 
-        'date'   => '2008-03-18', +            'date'   => '2008-03-18', 
-        'name'   => 'SuperACL', +            'name'   => 'SuperACL', 
-        'desc'   => 'Manage Access Control Lists for all workspaces', +            'desc'   => 'Manage Access Control Lists for all workspaces', 
-        'url'    => 'http://www.dokuwiki.org/plugin:superacl', +            'url'    => 'http://www.dokuwiki.org/plugin:superacl', 
-      );+        );
     }     }
  
Line 105: Line 105:
      */      */
     function getMenuSort() {     function getMenuSort() {
-      return 1;+        return 1;
     }     }
  
Line 112: Line 112:
      */      */
     function handle() {     function handle() {
-      global $AUTH_ACL;+        global $AUTH_ACL;
  
-      $cmd   = $_REQUEST['acl_cmd']; +        $cmd   = $_REQUEST['acl_cmd']; 
-      $scope = $_REQUEST['acl_scope']; +        $scope = $_REQUEST['acl_scope']; 
-      $type  = $_REQUEST['acl_type']; +        $type  = $_REQUEST['acl_type']; 
-      $user  = $_REQUEST['acl_user']; +        $user  = $_REQUEST['acl_user']; 
-      $perm  = $_REQUEST['acl_perm'];+        $perm  = $_REQUEST['acl_perm'];
  
-      if(is_array($perm)){ +        if(is_array($perm)){ 
-        //use the maximum +            //use the maximum 
-        sort($perm); +            sort($perm); 
-        $perm = array_pop($perm); +            $perm = array_pop($perm); 
-      }else{ +        }else{ 
-        $perm = 0; +            $perm = 0; 
-      }+        }
  
-      //sanitize +        //sanitize 
-      $user  = auth_nameencode($user); +        $user  = auth_nameencode($user); 
-      if($type == '@') $user = '@'.$user; +        if($type == '@') $user = '@'.$user; 
-      if($user == '@all') $user = '@ALL'; //special group! (now case insensitive) +        if($user == '@all') $user = '@ALL'; //special group! (now case insensitive) 
-      $perm  = (int) $perm; +        $perm  = (int) $perm; 
-      if($perm > AUTH_DELETE) $perm = AUTH_DELETE; +        if($perm > AUTH_DELETE) $perm = AUTH_DELETE; 
-      //FIXME sanitize scope!!!+        //FIXME sanitize scope!!!
  
-      //nothing to do? +        //nothing to do? 
-      if(empty($cmd) || empty($scope) || empty($user)) return;+        if(empty($cmd) || empty($scope) || empty($user)) return;
  
  
-      if($cmd == 'save'){ +        if($cmd == 'save'){ 
-        $this->admin_acl_del($scope, $user); +            $this->admin_acl_del($scope, $user); 
-        $this->admin_acl_add($scope, $user, $perm); +            $this->admin_acl_add($scope, $user, $perm); 
-      }elseif($cmd == 'delete'){ +        }elseif($cmd == 'delete'){ 
-        $this->admin_acl_del($scope, $user); +            $this->admin_acl_del($scope, $user); 
-      }+        }
  
-      // reload ACL config +        // reload ACL config 
-      $AUTH_ACL = file(DOKU_CONF.'acl.auth.php');+        $AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
     }     }
  
Line 162: Line 162:
     function html() {     function html() {
  
-      print $this->locale_xhtml('intro'); +        print $this->locale_xhtml('intro');
-             +
-      ptln('<div id="acl__manager">'); +
-      ptln('<table class="inline">');+
  
-      //namespace selector +        ptln('<div id="acl__manager">'); 
-      $this->admin_superacl_select_ns(); +        ptln('<table class="inline">'); 
-       + 
-      //new +        //namespace selector 
-      $this->admin_superacl_html_new();+        $this->admin_superacl_select_ns(); 
 + 
 +        //new 
 +        $this->admin_superacl_html_new(); 
 + 
 +        //current config 
 +        $acls = $this->get_superacl_config($this->get_selected_ns()); 
 +        foreach ($acls as $id => $acl){ 
 +            $this->admin_superacl_html_current($id,$acl); 
 +        }
  
-      //current config 
-      $acls = $this->get_superacl_config($this->get_selected_ns()); 
-      foreach ($acls as $id => $acl){ 
-        $this->admin_superacl_html_current($id,$acl); 
-      } 
-       
  
-      ptln('</table>'); +        ptln('</table>'); 
-      ptln('</div>');+        ptln('</div>');
     }     }
  
  /**  /**
-+ *
  * Get current selected namespace (or namespace of $ID as alternative)  * Get current selected namespace (or namespace of $ID as alternative)
-+ *
  */  */
-  function get_selected_ns() { +    function get_selected_ns() { 
-      global $ID; +        global $ID; 
-       + 
-         $id  = $_REQUEST['superacl_ns']; +        $id  = $_REQUEST['superacl_ns']; 
-       + 
-      if (! $id) $id = getNS($ID); +        if (! $id) $id = getNS($ID); 
-      if (! $id) $id = '*'; +        if (! $id) $id = '*'; 
-       + 
-      return $id; +        return $id; 
-  }+    }
  
  /**  /**
-+ *
  * Get current selected acl_scope (or namespace of Selected NS as alternative)  * Get current selected acl_scope (or namespace of Selected NS as alternative)
-+ *
  */  */
-  function get_acl_scope() { +    function get_acl_scope() { 
-       + 
-         $scope  = $_REQUEST['acl_scope']; +        $scope  = $_REQUEST['acl_scope']; 
-       + 
-      if (! $scope) $scope = $this->get_selected_ns() . ':*'; +        if (! $scope) $scope = $this->get_selected_ns() . ':*'; 
-      if (! $scope) $scope = '*'; +        if (! $scope) $scope = '*'; 
-       + 
-      return $scope; +        return $scope; 
-  }+    }
  
     /**     /**
Line 226: Line 226:
      */      */
     function get_superacl_config($id){     function get_superacl_config($id){
-      global $AUTH_ACL; +        global $AUTH_ACL;
-      +
  
-      $acl_config=array(); 
  
-      // match exact name +        $acl_config=array();
-      $pages = $this->get_pages($id); +
-       +
-      foreach ($pages as $page_id) { +
-          if ($id != '*'+
-            $page_id = $id . ':' . $page_id; +
-       $matches = preg_grep('/^'.$page_id.'\s+.*/',$AUTH_ACL); +
-       if(count($matches)){ +
-         foreach($matches as $match){ +
-           $match = preg_replace('/#.*$/','',$match); //ignore comments +
-           $acl   = preg_split('/\s+/',$match); +
-           //0 is pagename, 1 is user, 2 is acl +
-           $acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]); +
-         } +
-       } +
-      }+
  
-      $specific_found=array(); +        // match exact name 
-       +        $pages = $this->get_pages($id)
-      // match ns       + 
-      for(;$id !== false; $id = getNS($id)){ +        foreach ($pages as $page_id) { 
-     $id_pattern str_replace('+', '\\+',str_replace('*''\\*'$id))+            if ($id != '*') $page_id = $id . ':$page_id
-        $matches = preg_grep('/^'.$id_pattern.':\*\s+.*/',$AUTH_ACL); +            $matches = preg_grep('/^'.$page_id.'\s+.*/',$AUTH_ACL); 
-         +            if(count($matches)){ 
-        if(count($matches)){ +                foreach($matches as $match){ 
-          foreach($matches as $match){ +                    $match = preg_replace('/#.*$/','',$match); //ignore comments 
-            $match = preg_replace('/#.*$/','',$match); //ignore comments +                    $acl   = preg_split('/\s+/',$match); 
-            $acl   = preg_split('/\s+/',$match); +                    //0 is pagename, 1 is user, 2 is acl 
-            //0 is pagename, 1 is user, 2 is acl +                    $acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]); 
-            $acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]); +                } 
-            $specific_found[]=$acl[1]; +            }
-          }+
         }         }
-      } 
  
-      //include *-config +        $specific_found=array(); 
-      $matches = preg_grep('/^\*\s+.*/',$AUTH_ACL); + 
-      if(count($matches)){ +        // match ns 
-        foreach($matches as $match){ +        for(;$id !== false; $id = getNS($id)){ 
-          $match = preg_replace('/#.*$/','',$match); //ignore comments +            $id_pattern = str_replace('+', '\\+',str_replace('*', '\\*', $id)); 
-          $acl   = preg_split('/\s+/',$match); +            $matches = preg_grep('/^'.$id_pattern.':\*\s+.*/',$AUTH_ACL); 
-          // only include * for this user if not already found in ns + 
-          if(!in_array($acl[1], $specific_found)){ +            if(count($matches)){ 
-            //0 is pagename, 1 is user, 2 is acl +                foreach($matches as $match){ 
-            $acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]); +                    $match = preg_replace('/#.*$/','',$match); //ignore comments 
-          }+                    $acl   = preg_split('/\s+/',$match); 
 +                    //0 is pagename, 1 is user, 2 is acl 
 +                    $acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]); 
 +                    $specific_found[]=$acl[1]; 
 +                } 
 +            } 
 +        } 
 + 
 +        //include *-config 
 +        $matches = preg_grep('/^\*\s+.*/',$AUTH_ACL); 
 +        if(count($matches)){ 
 +            foreach($matches as $match){ 
 +                $match = preg_replace('/#.*$/','',$match); //ignore comments 
 +                $acl   = preg_split('/\s+/',$match); 
 +                // only include * for this user if not already found in ns 
 +                if(!in_array($acl[1], $specific_found)){ 
 +                    //0 is pagename, 1 is user, 2 is acl 
 +                    $acl_config[$acl[0]][] = array( 'name' => $acl[1], 'perm' => $acl[2]); 
 +                } 
 +            }
         }         }
-      } 
  
-      //sort +        //sort 
-      //FIXME: better sort algo: first sort by key, then sort by first value +        //FIXME: better sort algo: first sort by key, then sort by first value 
-      krsort($acl_config, SORT_STRING);+        krsort($acl_config, SORT_STRING);
  
-      return($acl_config);+        return($acl_config);
     }     }
  
Line 294: Line 293:
      */      */
     function admin_acl_add($acl_scope, $acl_user, $acl_level){     function admin_acl_add($acl_scope, $acl_user, $acl_level){
-      $acl_config = join("",file(DOKU_CONF.'acl.auth.php'));+        $acl_config = join("",file(DOKU_CONF.'acl.auth.php'));
  
-      // max level for pagenames is edit +        // max level for pagenames is edit 
-      if(strpos($acl_scope,'*') === false) { +        if(strpos($acl_scope,'*') === false) { 
-        if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT; +            if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT; 
-      }+        }
  
-      $new_acl = "$acl_scope\t$acl_user\t$acl_level\n";+        $new_acl = "$acl_scope\t$acl_user\t$acl_level\n";
  
-      $new_config = $acl_config.$new_acl;+        $new_config = $acl_config.$new_acl;
  
-      return io_saveFile(DOKU_CONF.'acl.auth.php', $new_config);+        return io_saveFile(DOKU_CONF.'acl.auth.php', $new_config);
     }     }
  
Line 314: Line 313:
      */      */
     function admin_acl_del($acl_scope, $acl_user){     function admin_acl_del($acl_scope, $acl_user){
-      $acl_config = file(DOKU_CONF.'acl.auth.php');+        $acl_config = file(DOKU_CONF.'acl.auth.php');
  
-      $acl_pattern = '^'.preg_quote($acl_scope,'/').'\s+'.$acl_user.'\s+[0-8].*$';+        $acl_pattern = '^'.preg_quote($acl_scope,'/').'\s+'.$acl_user.'\s+[0-8].*$';
  
-      // save all non!-matching #FIXME invert is available from 4.2.0 only! +        // save all non!-matching #FIXME invert is available from 4.2.0 only! 
-      $new_config = preg_grep("/$acl_pattern/", $acl_config, PREG_GREP_INVERT);+        $new_config = preg_grep("/$acl_pattern/", $acl_config, PREG_GREP_INVERT);
  
-      return io_saveFile(DOKU_CONF.'acl.auth.php', join('',$new_config));+        return io_saveFile(DOKU_CONF.'acl.auth.php', join('',$new_config));
     }     }
  
Line 336: Line 335:
      */      */
     function admin_superacl_html_dropdown($id){     function admin_superacl_html_dropdown($id){
-      $cur = $id; +        $cur = $id; 
-      $ret = ''; +        $ret = ''; 
-      $selected_id = $this->get_acl_scope(); +        $selected_id = $this->get_acl_scope(); 
-      $opt = array();+        $opt = array();
  
-      //prepare all options (in reversed order) +        //prepare all options (in reversed order) 
-      $pages = array(); +        $pages = array(); 
-      if ($this->getConf('use_ajax')) {       +        if ($this->getConf('use_ajax')) { 
-          $ret .= sprintf('<input type="hidden" id="superacl__aclid" value="%s"/>',$id); +            $ret .= sprintf('<input type="hidden" id="superacl__aclid" value="%s"/>',$id); 
-          $ret .= sprintf('<input type="hidden" id="superacl__pageselid" value="%s"/>',$selected_id); +            $ret .= sprintf('<input type="hidden" id="superacl__pageselid" value="%s"/>',$selected_id); 
-          $ret .= sprintf('<input type="hidden" id="superacl__page_text" value="%s"/>',$this->lang['page']); +            $ret .= sprintf('<input type="hidden" id="superacl__page_text" value="%s"/>',$this->lang['page']); 
-          $ret .= sprintf('<input type="hidden" id="superacl__namespace_text" value="%s"/>',$this->lang['namespace']); +            $ret .= sprintf('<input type="hidden" id="superacl__namespace_text" value="%s"/>',$this->lang['namespace']); 
-       +        } else { 
-      } else {  +            // pages in this namespace 
-       // pages in this namespace +            $pages = array_reverse($this->get_pages($id)); 
-       $pages = array_reverse($this->get_pages($id)); +        }
-      }+
  
-      // add pages in list +        // add pages in list 
-      foreach ($pages as $page_id) { +        foreach ($pages as $page_id) { 
-          $page_id = ($id != '*' ? $id . ':' : '') . $page_id; +            $page_id = ($id != '*' ? $id . ':' : '') . $page_id; 
-          $opt[] = array('value'=> $page_id,  +            $opt[] = array( 
-                         'text'=> $page_id.' ('.$this->lang['page'].')'); +                'value'=> $page_id, 
-          if ($page_id ==  $selected_id) +                'text'=> $page_id.' ('.$this->lang['page'].')' 
-            $opt[count($opt)-1]['sel'] = true; +            ); 
-      } +            if ($page_id ==  $selected_id) $opt[count($opt)-1]['sel'] = true; 
-       +        }
-      // add selected page (if not in list above) +
-      if (!($pages) && ($this->is_page($selected_id))) { +
-         $opt[] = array('value'=> $selected_id,  +
-                         'text'=> $selected_id.' ('.$this->lang['page'].')', +
-                         'sel' => true); +
-      } +
-       +
-       +
-      // additional namespaces +
-      for(; $id !== false && $id != '*'; $id=getNS($id)){ +
-        $opt[] = array('value'=> $id.':*', 'text'=> $id.':* ('.$this->lang['namespace'].')'); +
-        if ($id.':*' ==  $selected_id) +
-          $opt[count($opt)-1]['sel'] = true; +
-       +
-      }+
  
-      // the top namespace +        // add selected page (if not in list above) 
-      $opt[] = array('value'=> '*', 'text'=> '('.$this->lang['namespace'].')');+        if (!($pages) && ($this->is_page($selected_id))) { 
 +            $opt[] = array( 
 +                'value'=> $selected_id, 
 +                'text'=> $selected_id.' ('.$this->lang['page'].')'
 +                'sel' => true 
 +            ); 
 +        }
  
-       
  
-      // flip options +        // additional namespaces 
-      $opt = array_reverse($opt);+        for(; $id !== false && $id != '*'; $id=getNS($id)){ 
 +            $opt[] array('value'=> $id.':*', 'text'=> $id.':* ('.$this->lang['namespace'].')'); 
 +            if ($id.':*' ==  $selected_id) $opt[count($opt)-1]['sel'] = true; 
 +        }
  
-      // create HTML +        // the top namespace 
-      $att = array( 'name'  => 'acl_scope', +        $opt[] = array( 
-       'id' => 'superacl__pageselect', +            'value'=> '*', 
-                    'class' => 'edit', +            'text'=> '* ('.$this->lang['namespace'].')' 
-                    'title' => $this->lang['page'].'/'.$this->lang['namespace']); +        );
-      $ret .'<select '.html_attbuild($att).'>'; +
-      foreach($opt as $o){ +
-        $ret .= '<option value="'.$o['value'].'"'.($o['sel'] ? ' selected="selected"' : '').'>'.$o['text'].'</option>'; +
-      } +
-      $ret .= '</select>';+
  
-      return $ret;+ 
 + 
 +        // flip options 
 +        $opt = array_reverse($opt); 
 + 
 +        // create HTML 
 +        $att = array( 
 +            'name'  => 'acl_scope', 
 +            'id' => 'superacl__pageselect', 
 +            'class' => 'edit', 
 +            'title' => $this->lang['page'].'/'.$this->lang['namespace'
 +        ); 
 + 
 +        $ret .= '<select '.html_attbuild($att).'>'; 
 +        foreach($opt as $o){ 
 +            $ret .= '<option value="'.$o['value'].'"'.($o['sel'] ? ' selected="selected"' : '').'>'.$o['text'].'</option>'; 
 +        } 
 +        $ret .= '</select>'; 
 + 
 +        return $ret;
     }     }
-    +
     /**     /**
      * Decides, if a id is a page      * Decides, if a id is a page
      * */      * */
     function is_page($id){     function is_page($id){
-      return (id != "") && ! (substr($id,-1) == '*');+        return (id != "") && ! (substr($id,-1) == '*');
     }     }
-    +
      /**      /**
      * creates dropdown with all namespaces      * creates dropdown with all namespaces
Line 414: Line 419:
      */      */
     function admin_superacl_html_ns_dropdown($id){     function admin_superacl_html_ns_dropdown($id){
-      global $ID; +        global $ID; 
-      $ret = ''; +        $ret = ''; 
-      $opt = array(); +        $opt = array();
-       +
-       +
-      $namespaces = array(); +
-       +
-      if ($this->getConf('use_ajax')) { +
-       $ret .= sprintf('<input type="hidden" id="superacl__pageid" value="%s"/>',$ID); +
-       $ret .= sprintf('<input type="hidden" id="superacl__nsselid" value="%s"/>',$id); +
-      } else { +
-          $namespaces = $this->get_namespaces(); +
-   } +
-      +
-      // add namespaces of current page to the list of namespaces (even if the namespaces doesn't exist yet +
-      for($ns_id = getNS($ID); $ns_id !== false; $ns_id = getNS($ns_id)){ +
-          if (!in_array($ns_id,$namespaces)) +
-             $namespaces[] = $ns_id; +
-      } +
-       +
-      // add selected namespace, if not in list above +
-     if ($id && !in_array($id,$namespaces)) +
-             $namespaces[] = $id; +
-       +
-      sort($namespaces); +
-       +
-      $namespaces = array_reverse($namespaces); +
-      foreach ($namespaces as $ns_id) { +
-          if ($ns_id == "*") continue; +
-           +
-          $opt[] = array('value'=> $ns_id, 'text'=> $ns_id.':*'); +
-          if ($ns_id == $id) // set sel on current selected namespcase  +
-      $opt[count($opt)-1]['sel'] = true;  +
-      } +
-       +
-      $opt[] = array('value'=> '*', 'text'=> '*');+
  
  
-      // flip options +        $namespaces array();
-      $opt array_reverse($opt);  +
-      +
  
-      // create HTML +        if ($this->getConf('use_ajax')) { 
-      $att = array'name'  => 'superacl_ns', +            $ret .= sprintf('<input type="hiddenid="superacl__pageid" value="%s"/>',$ID); 
-                    'id' => 'superacl__nsselect', +            $ret .= sprintf('<input type="hiddenid="superacl__nsselidvalue="%s"/>',$id)
-                    'class' => 'edit', +        else { 
-                    'title' => $this->lang['page'].'/'.$this->lang['namespace']); +            $namespaces $this->get_namespaces(); 
-      $ret .= '<select '.html_attbuild($att).' onchange="submit();">'+        }
-      foreach($opt as $o){ +
-        $ret .= '<option value="'.$o['value'].'"'.($o['sel'] ? ' selected="selected"' : '').'>'.$o['text'].'</option>'+
-      +
-      $ret .'</select>';+
  
-      return $ret;+        // add namespaces of current page to the list of namespaces (even if the namespaces doesn't exist yet 
 +        for($ns_id = getNS($ID); $ns_id !== false; $ns_id = getNS($ns_id)){ 
 +            if (!in_array($ns_id,$namespaces)) $namespaces[] = $ns_id; 
 +        } 
 + 
 +        // add selected namespace, if not in list above 
 +        if ($id && !in_array($id,$namespaces)) $namespaces[] = $id; 
 + 
 +        sort($namespaces); 
 + 
 +        $namespaces = array_reverse($namespaces); 
 +        foreach ($namespaces as $ns_id) { 
 +            if ($ns_id == "*") continue; 
 + 
 +            $opt[] = array('value'=> $ns_id, 'text'=> $ns_id.':*'); 
 +            if ($ns_id == $id) { // set sel on current selected namespcase 
 +                $opt[count($opt)-1]['sel'] = true; 
 +            } 
 +        } 
 + 
 +        $opt[] = array('value'=> '*', 'text'=> '*'); 
 + 
 + 
 +        // flip options 
 +        $opt = array_reverse($opt); 
 + 
 + 
 +        // create HTML 
 +        $att = array( 
 +            'name'  => 'superacl_ns', 
 +            'id' => 'superacl__nsselect', 
 +            'class' => 'edit', 
 +            'title' => $this->lang['page'].'/'.$this->lang['namespace'
 +        ); 
 + 
 +        $ret .= '<select '.html_attbuild($att).' onchange="submit();">'; 
 +        foreach($opt as $o){ 
 +            $ret .= '<option value="'.$o['value'].'"'.($o['sel'] ? ' selected="selected"' : '').'>'.$o['text'].'</option>'; 
 +        } 
 +        $ret .= '</select>'; 
 + 
 +        return $ret;
     }     }
-    +
     /**     /**
-     * print form to select namespace to modify  +     * print form to select namespace to modify 
-     +     *
      * @author Pascal Bihler <bihler@iai.uni-bonn.de>      * @author Pascal Bihler <bihler@iai.uni-bonn.de>
-     +     *
      */      */
      function admin_superacl_select_ns() {      function admin_superacl_select_ns() {
-       global $ID; +        global $ID; 
-       global $lang;+        global $lang;
  
-      // table headers +        // table headers 
-      ptln('<tr>',2); +        ptln('<tr>',2); 
-      ptln('  <th class="leftalign" colspan="3">'.$this->lang['acl_select'].'</th>',2); +        ptln('  <th class="leftalign" colspan="3">'.$this->lang['acl_select'].'</th>',2); 
-      ptln('</tr>',2);+        ptln('</tr>',2);
  
-      ptln('<tr>',2);+        ptln('<tr>',2);
  
-      ptln('<td class="centeralign" colspan="3">',4);+        ptln('<td class="centeralign" colspan="3">',4);
  
-      ptln('  <form method="post" action="'.wl($ID).'"><div class="no">',4); +        ptln('  <form method="post" action="'.wl($ID).'"><div class="no">',4); 
-      ptln('    <input type="hidden" name="do"   value="admin" />',4); +        ptln('    <input type="hidden" name="do"   value="admin" />',4); 
-      ptln('    <input type="hidden" name="page" value="superacl" />',4); +        ptln('    <input type="hidden" name="page" value="superacl" />',4); 
-      ptln('    <input type="hidden" name="acl_cmd" value="select_ns" />',4); +        ptln('    <input type="hidden" name="acl_cmd" value="select_ns" />',4); 
-       + 
-      //scope select +        //scope select 
-      ptln($this->lang['acl_perms'],4); +        ptln($this->lang['acl_perms'],4); 
-      ptln($this->admin_superacl_html_ns_dropdown($this->get_selected_ns()),4); +        ptln($this->admin_superacl_html_ns_dropdown($this->get_selected_ns()),4); 
-       + 
-      ptln('    <input type="submit" class="button" value="'.$lang['btn_update'].'" />',4); +        ptln('    <input type="submit" class="button" value="'.$lang['btn_update'].'" />',4); 
-      ptln('  </div></form>'); +        ptln('  </div></form>'); 
-      ptln('</td>',4); +        ptln('</td>',4); 
-      ptln('</tr>',2); +        ptln('</tr>',2);
-         +
      }      }
-     +
  
     /**     /**
Line 514: Line 520:
      */      */
     function admin_superacl_html_new(){     function admin_superacl_html_new(){
-      global $ID; +        global $ID; 
-      global $lang;+        global $lang;
  
-      // table headers +        // table headers 
-      ptln('<tr>',2); +        ptln('<tr>',2); 
-      ptln('  <th class="leftalign" colspan="3">'.$this->lang['acl_new'].'</th>',2); +        ptln('  <th class="leftalign" colspan="3">'.$this->lang['acl_new'].'</th>',2); 
-      ptln('</tr>',2);+        ptln('</tr>',2);
  
-      ptln('<tr>',2);+        ptln('<tr>',2);
  
-      ptln('<td class="centeralign" colspan="3">',4);+        ptln('<td class="centeralign" colspan="3">',4);
  
-      ptln('  <form method="post" action="'.wl($ID).'"><div class="no">',4); +        ptln('  <form method="post" action="'.wl($ID).'"><div class="no">',4); 
-      ptln('    <input type="hidden" name="do"   value="admin" />',4); +        ptln('    <input type="hidden" name="do"   value="admin" />',4); 
-      ptln('    <input type="hidden" name="page" value="superacl" />',4); +        ptln('    <input type="hidden" name="page" value="superacl" />',4); 
-      ptln('    <input type="hidden" name="acl_cmd" value="save" />',4); +        ptln('    <input type="hidden" name="acl_cmd" value="save" />',4); 
-      ptln('    <input type="hidden" name="superacl_ns" value="' . $this->get_selected_ns() . '" />',4);+        ptln('    <input type="hidden" name="superacl_ns" value="' . $this->get_selected_ns() . '" />',4);
  
 +        //scope select
 +        ptln($this->lang['acl_perms'],4);
 +        ptln($this->admin_superacl_html_dropdown($this->get_selected_ns()),4);
  
 +        $att = array(
 +            'name'  => 'acl_type',
 +            'class' => 'edit',
 +            'title' => $this->lang['acl_user'].'/'.$this->lang['acl_group']
 +        );
 +        ptln('    <select '.html_attbuild($att).'>',4);
 +        ptln('      <option value="@">'.$this->lang['acl_group'].'</option>',4);
 +        ptln('      <option value="">'.$this->lang['acl_user'].'</option>',4);
 +        ptln('    </select>',4);
  
- +        $att = array( 
- +            'name'  => 'acl_user', 
-      //scope select +            'type'  => 'text', 
-      ptln($this->lang['acl_perms'],4); +            'class' => 'edit', 
-      ptln($this->admin_superacl_html_dropdown($this->get_selected_ns()),4); +            'title' => $this->lang['acl_user'].'/'.$this->lang['acl_group'] 
- +        ); 
-      $att = array( 'name'  => 'acl_type', +        ptln('    <input '.html_attbuild($att).' />',4); 
-                    'class' => 'edit', +        ptln('    <br />'); 
-                    'title' => $this->lang['acl_user'].'/'.$this->lang['acl_group']); +        ptln(     $this->admin_acl_html_checkboxes(0,false),8); 
-      ptln('    <select '.html_attbuild($att).'>',4); +        ptln('    <input type="submit" class="button" value="'.$lang['btn_save'].'" />',4); 
-      ptln('      <option value="@">'.$this->lang['acl_group'].'</option>',4); +        ptln('  </div></form>'); 
-      ptln('      <option value="">'.$this->lang['acl_user'].'</option>',4); +        ptln('</td>',4); 
-      ptln('    </select>',4); +        ptln('</tr>',2);
- +
-      $att = array( 'name'  => 'acl_user', +
-                    'type'  => 'text', +
-                    'class' => 'edit', +
-                    'title' => $this->lang['acl_user'].'/'.$this->lang['acl_group']); +
-      ptln('    <input '.html_attbuild($att).' />',4); +
-      ptln('    <br />'); +
- +
-      ptln(     $this->admin_acl_html_checkboxes(0,false),8); +
- +
-      ptln('    <input type="submit" class="button" value="'.$lang['btn_save'].'" />',4); +
-      ptln('  </div></form>'); +
-      ptln('</td>',4); +
-      ptln('</tr>',2);+
     }     }
  
Line 571: Line 575:
      */      */
     function admin_superacl_html_current($id,$permissions){     function admin_superacl_html_current($id,$permissions){
-      global $lang; +        global $lang; 
-      global $ID;+        global $ID;
  
-      //is it a page? +        //is it a page? 
-      $idpage = $this->is_page($id);+        $ispage = $this->is_page($id);
  
-      // table headers +        // table headers 
-      ptln('  <tr>'); +        ptln('  <tr>'); 
-      ptln('    <th class="leftalign" colspan="3">'); +        ptln('    <th class="leftalign" colspan="3">'); 
-      ptln($this->lang['acl_perms'],6); +        ptln($this->lang['acl_perms'],6); 
-      if($ispage){ +        if($ispage){ 
-        ptln($this->lang['page'],6); +            ptln($this->lang['page'],6); 
-      }else{ +        }else{ 
-        ptln($this->lang['namespace'],6); +            ptln($this->lang['namespace'],6); 
-      +        
-      ptln('<em>'.$id.'</em>',6); +        ptln('<em>'.$id.'</em>',6); 
-      ptln('    </th>'); +        ptln('    </th>'); 
-      ptln('  </tr>');+        ptln('  </tr>');
  
-      sort($permissions);+        sort($permissions);
  
-      foreach ($permissions as $conf){+        foreach ($permissions as $conf){
         //userfriendly group/user display         //userfriendly group/user display
         $conf['name'] = rawurldecode($conf['name']);         $conf['name'] = rawurldecode($conf['name']);
         if(substr($conf['name'],0,1)=="@"){         if(substr($conf['name'],0,1)=="@"){
-          $group = $this->lang['acl_group']; +            $group = $this->lang['acl_group']; 
-          $name  = substr($conf['name'],1); +            $name  = substr($conf['name'],1); 
-          $type  = '@';+            $type  = '@';
         }else{         }else{
-          $group = $this->lang['acl_user']; +            $group = $this->lang['acl_user']; 
-          $name  = $conf['name']; +            $name  = $conf['name']; 
-          $type  = '';+            $type  = '';
         }         }
  
Line 642: Line 646:
  
         ptln('</tr>',2);         ptln('</tr>',2);
-      }+        }
  
     }     }
Line 654: Line 658:
      */      */
     function admin_acl_html_checkboxes($setperm,$ispage){     function admin_acl_html_checkboxes($setperm,$ispage){
-      global $lang;+        global $lang;
  
-      static $label = 0; //number labels +        static $label = 0; //number labels 
-      $ret = '';+        $ret = '';
  
-      foreach(array(AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm){ +        foreach(array(AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm){ 
-        $label += 1;+            $label += 1;
  
-        //general checkbox attributes +            //general checkbox attributes 
-        $atts = array( 'type'  => 'checkbox', +            $atts = array( 
-                       'id'    => 'pbox'.$label, +                'type'  => 'checkbox', 
-                       'name'  => 'acl_perm[]', +                'id'    => 'pbox'.$label, 
-                       'value' => $perm ); +                'name'  => 'acl_perm[]', 
-        //dynamic attributes +                'value' => $perm 
-        if($setperm >= $perm) $atts['checked' = 'checked'; +            ); 
-        $atts['onchange'] = "superacl_autoselect_permissions(this);"; +            //dynamic attributes 
-        if($ispage && $perm > AUTH_EDIT) $atts['disabled'] = 'disabled';+            if($setperm >= $perm) $atts['checked' = 'checked'; 
 +            $atts['onchange'] = "superacl_autoselect_permissions(this);"; 
 +            if($ispage && $perm > AUTH_EDIT) $atts['disabled'] = 'disabled';
  
-        //build code +            //build code 
-        $ret .= '<label for="pbox'.$label.'" title="'.$this->lang['acl_perm'.$perm].'">'; +            $ret .= '<label for="pbox'.$label.'" title="'.$this->lang['acl_perm'.$perm].'">'; 
-        $ret .= '<input '.html_attbuild($atts).' />'; +            $ret .= '<input '.html_attbuild($atts).' />'; 
-        $ret .= $this->lang['acl_perm'.$perm]; +            $ret .= $this->lang['acl_perm'.$perm]; 
-        $ret .= "</label>\n"; +            $ret .= "</label>\n"; 
-      +        
-      return $ret;+        return $ret;
     }     }
-    +
     function get_pages($tns='') {     function get_pages($tns='') {
         return $this->_getlist($tns,false,false,true);         return $this->_getlist($tns,false,false,true);
     }     }
-    +
     function get_namespaces($tns='') {     function get_namespaces($tns='') {
         return $this->_getlist($tns,true,true,false);         return $this->_getlist($tns,true,true,false);
     }     }
-    /inspired from addnewpageplugin:  +    /** 
-     function _getlist ($tns='',$recursive = true, $namespaces=true,$pages=false) { +     inspired from addnewpageplugin: 
- require_once(DOKU_INC.'inc/search.php'); +     */ 
- global $conf; +    function _getlist ($tns='',$recursive = true, $namespaces=true,$pages=false) { 
- +        require_once(DOKU_INC.'inc/search.php'); 
 +        global $conf; 
         if ($tns == '*') $tns = '';         if ($tns == '*') $tns = '';
-  + 
- if (!is_dir($tns)) +        if (!is_dir($tns)) $tns  = str_replace(':','/',$tns); 
- $tns  = str_replace(':','/',$tns); + 
-  +        $data = array(); 
- $data = array(); + 
-  + 
-  +        search($data,$conf['datadir'] ."/" . $tns,'search_index',array('ns' => '')); 
- search($data,$conf['datadir'] ."/" . $tns,'search_index',array('ns' => '')); + 
-   +        $data2 = array(); 
- $data2 = array(); +        foreach($data as $k => $v) { 
- foreach($data as $k => $v) { +            if ($v['type']=='d') { //Namespace 
- if ($v['type']=='d') { //Namespace +                if ($namespaces) array_push($data2,$v['id']); 
-     if ($namespaces) +                 
-     array_push($data2,$v['id']); +                if ($recursive) { 
- if ($recursive) { +                    $r=$this->_getlist($tns.'/'.$v['id'],$recursive,$namespaces,$pages); 
- $r=$this->_getlist($tns.'/'.$v['id'],$recursive,$namespaces,$pages); +                    foreach ($r as $vv) { 
- foreach ($r as $vv) { +                        array_push($data2,$v['id'].':'.$vv); 
- array_push($data2,$v['id'].':'.$vv); +                    
- +                
- +            } elseif ($v['type']=='f') { //Page 
- } elseif ($v['type']=='f') { //Page +                if ($pages) array_push($data2,$v['id']); 
-     if ($pages) +            
-     array_push($data2,$v['id']); +        
- +        return $data2; 
- + }
- return $data2; +
-+
  
 } }
Line 726: Line 732:
  
 **ajax.php:** **ajax.php:**
 +
 +FIXME move this to action.php where it can hook the [[devel:event:ajax_call_unknown]] event.
  
 <code php ajax.php> <code php ajax.php>
Line 737: Line 745:
 //fix for Opera XMLHttpRequests //fix for Opera XMLHttpRequests
 if(!count($_POST) && $HTTP_RAW_POST_DATA){ if(!count($_POST) && $HTTP_RAW_POST_DATA){
-  parse_str($HTTP_RAW_POST_DATA, $_POST);+    parse_str($HTTP_RAW_POST_DATA, $_POST);
 } }
 + 
 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
 require_once(DOKU_INC.'inc/init.php'); require_once(DOKU_INC.'inc/init.php');
Line 748: Line 756:
 //close session //close session
 session_write_close(); session_write_close();
 + 
 // check, if user is admin (or at least manager) // check, if user is admin (or at least manager)
 if (! auth_ismanager()) { if (! auth_ismanager()) {
- exit;+    exit;
 } }
 + 
 if ($_POST["q"] == "namespaces") { if ($_POST["q"] == "namespaces") {
-   get_namespace_list();+    get_namespace_list();
 } elseif ($_POST["q"] == "pages") { } elseif ($_POST["q"] == "pages") {
-   get_pages_list();+    get_pages_list();
 } }
 + 
 function get_namespace_list() { function get_namespace_list() {
-   
- $ID = $_POST["pageid"]; 
- $selid = $_POST["selid"]; 
  
-      $opt = array(); +    $ID = $_POST["pageid"]; 
-       +    $selid = $_POST["selid"];
-  // all namespace +
-     $namespaces = get_namespaces(); +
-      +
-      // add namespaces of current page to the list of namespaces (even if the namespaces doesn't exist yet +
-      for($ns_id = getNS($ID); $ns_id !== false; $ns_id = getNS($ns_id)){ +
-          if (!in_array($ns_id,$namespaces)) +
-             $namespaces[] = $ns_id+
-      } +
-      sort($namespaces); +
-       +
-      $namespaces array_reverse($namespaces); +
-      foreach ($namespaces as $ns_id) { +
-          $opt[] = array('value'=> $ns_id, 'text'=> $ns_id.':*'); +
-          if ($ns_id == $selid) // set sel on current selected namespcase  +
-      $opt[count($opt)-1]['sel'] = true;  +
-      } +
-       +
-      $opt[] = array('value'=> '*', 'text'=> '*');+
  
 +    $opt = array();
  
-      // flip options +    // all namespace 
-      $opt array_reverse($opt); +    $namespaces get_namespaces();
  
 +    // add namespaces of current page to the list of namespaces (even if the namespaces doesn't exist yet
 +    for($ns_id = getNS($ID); $ns_id !== false; $ns_id = getNS($ns_id)){
 +        if (!in_array($ns_id,$namespaces)) $namespaces[] = $ns_id;
 +    }
 +    sort($namespaces);
  
- /now construct a json */ +    $namespaces = array_reverse($namespaces); 
-  $json new JSON();+    foreach ($namespaces as $ns_id) { 
 +        $opt[] = array('value'=> $ns_id, 'text'=> $ns_id.':*'); 
 +        if ($ns_id == $selid) { // set sel on current selected namespcase  
 +            $opt[count($opt)-1]['sel'] = true; 
 +        } 
 +    }
  
-   +    $opt[] = array('value'=> '*', 'text'='*');
-  //header('Content-Type: application/json'); +
-  header('Content-Type: text/javascript'); +
-  print $json->encode($opt); +
-}+
  
  
 +    // flip options
 +    $opt = array_reverse($opt); 
 +
 +
 +    /* now construct a json */
 +    $json = new JSON();
 +
 +
 +    //header('Content-Type: application/json');
 +    header('Content-Type: text/javascript');
 +    print $json->encode($opt);
 +}
 + 
 + 
 function get_pages_list() { function get_pages_list() {
  
- $id = $_POST["aclid"]; +    $id = $_POST["aclid"]; 
- $selected_id = $_POST["selid"]; +    $selected_id = $_POST["selid"]; 
- +
     $opt = array();     $opt = array();
-  
- $pages = array_reverse(get_pages($id)); 
  
-      // add pages in list +    $pages = array_reverse(get_pages($id)); 
-      foreach ($pages as $page_id) { + 
-          $page_id = ($id != '*' ? $id . ':' : '') . $page_id; +    // add pages in list 
-          $opt[] = array('value'=> $page_id,  +    foreach ($pages as $page_id) { 
-                         'text'=> $page_id.' ('.$_POST['page_text'].')'); +        $page_id = ($id != '*' ? $id . ':' : '') . $page_id; 
-          if ($page_id ==  $selected_id) +        $opt[] = array( 
-            $opt[count($opt)-1]['sel'] = true; +            'value'=> $page_id,  
-      }       +            'text'=> $page_id.' ('.$_POST['page_text'].')' 
-       +        ); 
-      // additional namespaces +        if ($page_id ==  $selected_id) $opt[count($opt)-1]['sel'] = true; 
-      for(; $id !== false && $id != '*'; $id=getNS($id)){+    }       
 + 
 +    // additional namespaces 
 +    for(; $id !== false && $id != '*'; $id=getNS($id)){
         $opt[] = array('value'=> $id.':*', 'text'=> $id.':* ('.$_POST['ns_text'].')');         $opt[] = array('value'=> $id.':*', 'text'=> $id.':* ('.$_POST['ns_text'].')');
-        if ($id.':*' ==  $selected_id) +        if ($id.':*' ==  $selected_id) $opt[count($opt)-1]['sel'] = true; 
-          $opt[count($opt)-1]['sel'] = true; +    }
-       +
-      }+
  
-      // the top namespace +    // the top namespace 
-      $opt[] = array('value'=> '*', 'text'=> '* ('.$_POST['ns_text'].')');+    $opt[] = array('value'=> '*', 'text'=> '* ('.$_POST['ns_text'].')');
  
-      +    // flip options 
 +    $opt = array_reverse($opt);
  
-      // flip options +    /* now construct a json */ 
-      $opt = array_reverse($opt); +    $json = new JSON(); 
-  + 
-  +    //header('Content-Type: application/json'); 
-  /* now construct a json */ +    header('Content-Type: text/javascript'); 
-   $json = new JSON(); +    print $json->encode($opt);
-  +
-    +
-   //header('Content-Type: application/json'); +
-   header('Content-Type: text/javascript'); +
-   print $json->encode($opt);+
 } }
  
-    function get_pages($tns='') { +function get_pages($tns='') { 
-        return _getlist($tns,false,false,true); +    return _getlist($tns,false,false,true); 
-    } +}
-     +
-   +
-   function get_namespaces($tns='') { +
-        return _getlist($tns,true,true,false); +
-    } +
-    // inspired from addnewpageplugin:  +
-     function _getlist ($tns='',$recursive = true, $namespaces=true,$pages=false) { +
- require_once(DOKU_INC.'inc/search.php'); +
- global $conf; +
-  +
-        if ($tns == '*') $tns = '';+
    
- if (!is_dir($tns)) +  
- $tns  = str_replace(':','/',$tns); +function get_namespaces($tns='') { 
-  +    return _getlist($tns,true,true,false); 
- $data = array(); +
-  + 
-  +// inspired from addnewpageplugin:  
- search($data,$conf['datadir'] ."/" . $tns,'search_index',array('ns' => '')); +function _getlist ($tns='',$recursive = true, $namespaces=true,$pages=false) { 
-   +    require_once(DOKU_INC.'inc/search.php'); 
- $data2 = array(); +    global $conf; 
- foreach($data as $k => $v) { + 
- if ($v['type']=='d') { //Namespace +    if ($tns == '*') $tns = ''; 
-     if ($namespaces) + 
-     array_push($data2,$v['id']); +    if (!is_dir($tns)) $tns  = str_replace(':','/',$tns); 
- if ($recursive) { + 
- $r=_getlist($tns.'/'.$v['id'],$recursive,$namespaces,$pages); +    $data = array(); 
- foreach ($r as $vv) { + 
- array_push($data2,$v['id'].':'.$vv); +    search($data,$conf['datadir'] ."/" . $tns,'search_index',array('ns' => '')); 
- + 
- +    $data2 = array(); 
- } elseif ($v['type']=='f') { //Page +    foreach($data as $k => $v) { 
-     if ($pages) +        if ($v['type']=='d') { //Namespace 
-     array_push($data2,$v['id']); +            if ($namespaces) array_push($data2,$v['id']); 
- +             
- +            if ($recursive) { 
- return $data2; +                $r=_getlist($tns.'/'.$v['id'],$recursive,$namespaces,$pages); 
-+                foreach ($r as $vv) { 
 +                    array_push($data2,$v['id'].':'.$vv); 
 +                
 +            
 +        } elseif ($v['type']=='f') { //Page 
 +            if ($pages) array_push($data2,$v['id']); 
 +        
 +    
 +    return $data2; 
 +
 ?> ?>
 </code> </code>
Line 903: Line 904:
      if (!id || id.length<4 || id.substring(0,4) != baseLabel) continue;      if (!id || id.length<4 || id.substring(0,4) != baseLabel) continue;
      label = parseInt(id.substring(4));      label = parseInt(id.substring(4));
-     if (caller.checked && label < callerLabel)  //check lower rights, too + //check lower rights, too 
-         e.checked = true; +     if (caller.checked && label < callerLabel) e.checked = true; 
-     else if (! caller.checked && label > callerLabel) //uncheck upper rights too + //uncheck upper rights too 
-         e.checked = false;+     else if (! caller.checked && label > callerLabel) e.checked = false;
  }  }
 } }
Line 922: Line 923:
  // fill namespace selector  // fill namespace selector
  if ($('superacl__nsselid')) {  if ($('superacl__nsselid')) {
-  
  var ajax_superaclns = new ajax_superacl_class();  var ajax_superaclns = new ajax_superacl_class();
-  
  ajax_superaclns.sack = new sack(DOKU_BASE + 'lib/plugins/superacl/ajax.php');  ajax_superaclns.sack = new sack(DOKU_BASE + 'lib/plugins/superacl/ajax.php');
  ajax_superaclns.sack.AjaxFailedAlert = '';  ajax_superaclns.sack.AjaxFailedAlert = '';
  ajax_superaclns.sack.encodeURIString = false;  ajax_superaclns.sack.encodeURIString = false;
- 
  ajax_superaclns.exec = function() {  ajax_superaclns.exec = function() {
  pageid = $("superacl__pageid").value;  pageid = $("superacl__pageid").value;
Line 934: Line 932:
  ajax_superaclns.sack.runAJAX('q=namespaces&pageid=' + encodeURI(pageid) + '&selid=' + encodeURI(ns_selid));  ajax_superaclns.sack.runAJAX('q=namespaces&pageid=' + encodeURI(pageid) + '&selid=' + encodeURI(ns_selid));
  };  };
-  
  ajax_superaclns.sack.onCompletion = function() {  ajax_superaclns.sack.onCompletion = function() {
  var data = eval(ajax_superaclns.sack.response);  var data = eval(ajax_superaclns.sack.response);
- if(data === ''+ if(data === '') return;    
-    return; +
-    } +
-     +
-   +
  // add namespaces to select box  // add namespaces to select box
  select = $('superacl__nsselect');  select = $('superacl__nsselect');
  for(i = 0; i < data.length; ++i) {  for(i = 0; i < data.length; ++i) {
-   option = new Option(data[i].text, data[i].value, data[i].sel, data[i].sel); + option = new Option(data[i].text, data[i].value, data[i].sel, data[i].sel); 
-   select.options[i] = option; + select.options[i] = option;
  }  }
  };  };
- 
         ajax_superaclns.exec();         ajax_superaclns.exec();
     }     }
Line 956: Line 948:
     if ($('superacl__aclid')) {     if ($('superacl__aclid')) {
       var ajax_superaclpage = new ajax_superacl_class();       var ajax_superaclpage = new ajax_superacl_class();
-  
  ajax_superaclpage.sack = new sack(DOKU_BASE + 'lib/plugins/superacl/ajax.php');  ajax_superaclpage.sack = new sack(DOKU_BASE + 'lib/plugins/superacl/ajax.php');
  ajax_superaclpage.sack.AjaxFailedAlert = '';  ajax_superaclpage.sack.AjaxFailedAlert = '';
  ajax_superaclpage.sack.encodeURIString = false;  ajax_superaclpage.sack.encodeURIString = false;
- 
  ajax_superaclpage.exec = function() {  ajax_superaclpage.exec = function() {
  acl_id = $("superacl__aclid").value;  acl_id = $("superacl__aclid").value;
Line 966: Line 956:
  page_text = $("superacl__page_text").value;  page_text = $("superacl__page_text").value;
  ns_text = $("superacl__namespace_text").value;  ns_text = $("superacl__namespace_text").value;
- ajax_superaclpage.sack.runAJAX('q=pages&aclid=' + encodeURI(acl_id) + + ajax_superaclpage.sack.runAJAX( 
-                                '&selid=' + encodeURI(page_selid) + + 'q=pages&aclid=' + encodeURI(acl_id) + 
-                                '&page_text=' + encodeURI(page_text) + + '&selid=' + encodeURI(page_selid) + 
-                                '&ns_text=' + encodeURI(ns_text) );+ '&page_text=' + encodeURI(page_text) + 
 + '&ns_text=' + encodeURI(ns_text)  
 + );
  };  };
-  
  ajax_superaclpage.sack.onCompletion = function() {  ajax_superaclpage.sack.onCompletion = function() {
  var data = eval(ajax_superaclpage.sack.response);  var data = eval(ajax_superaclpage.sack.response);
- if(data === ''+ if(data === '') return;
-    return; +
-    } +
-     +
-   +
  // add namespaces to select box  // add namespaces to select box
  select = $('superacl__pageselect');  select = $('superacl__pageselect');
  for(i = 0; i < data.length; ++i) {  for(i = 0; i < data.length; ++i) {
-   option = new Option(data[i].text, data[i].value, data[i].sel, data[i].sel); + option = new Option(data[i].text, data[i].value, data[i].sel, data[i].sel); 
-   select.options[i] = option; + select.options[i] = option;
  
  };  };
- 
         ajax_superaclpage.exec();         ajax_superaclpage.exec();
     }     }
Line 995: Line 981:
  
 ==== Patches ==== ==== Patches ====
 +
 +=== Incompatible with "WeatherWax" ====
 +https://www.dokuwiki.org/changes#release_candidate_weatherwax
  
  
Line 1015: Line 1004:
  
 <del>$idpage</del> $ispage  = $this->is_page($id); <del>$idpage</del> $ispage  = $this->is_page($id);
 +> Ok, fixed
 +
 +
 +=== Overriding the ACL Admin Task ===
  
 +Would it be possible to override the ACL task item in the first section of the Administration screen (the list with the big icons) ? --- [[user>petsagouris|George Petsagourakis]] //2011/02/13 13:05//
plugin/superacl.txt · Last modified: 2014-03-20 18:23 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki