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
plugin:superacl [2011-02-10 12:00] – [Code] fixed a typo and tampered the code formatting 94.69.81.2plugin:superacl [2014-03-20 18:23] (current) Aleksandr
Line 1: Line 1:
-====== DokuWiki Plugin: superacl ======+====== SuperACL  Plugin ======
  
 ---- plugin ---- ---- plugin ----
Line 7: Line 7:
 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 
 similar    : acl similar    : acl
 tags       : acl, users, groups tags       : acl, users, groups
-downloadurl:http://pb.wh4f.de/dokuwiki/superacl2.zip+downloadurl: http://pb.wh4f.de/dokuwiki/superacl2.zip
 ---- ----
  
Line 24: Line 24:
 ==== 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 730: Line 730:
  
 **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 741: Line 743:
 //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 752: Line 754:
 //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); 
 + 
 +    /* now construct a json */ 
 +    $json = new JSON();
  
-      // flip options +    //header('Content-Type: application/json'); 
-      $opt = array_reverse($opt); +    header('Content-Type: text/javascript'); 
-  +    print $json->encode($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($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 907: Line 902:
      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 926: Line 921:
  // 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 938: Line 930:
  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 960: Line 946:
     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 970: Line 954:
  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 999: Line 979:
  
 ==== Patches ==== ==== Patches ====
 +
 +=== Incompatible with "WeatherWax" ====
 +https://www.dokuwiki.org/changes#release_candidate_weatherwax
  
  
Line 1019: Line 1002:
  
 <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.1297335628.txt.gz · Last modified: 2011-02-10 12:00 by 94.69.81.2

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