1<?php
2/**
3 * AJAX call handler for ACL plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 */
8
9//fix for Opera XMLHttpRequests
10if(!count($_POST) && $HTTP_RAW_POST_DATA){
11  parse_str($HTTP_RAW_POST_DATA, $_POST);
12}
13
14if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../');
15require_once(DOKU_INC.'inc/init.php');
16require_once(DOKU_INC.'inc/common.php');
17require_once(DOKU_INC.'inc/pageutils.php');
18require_once(DOKU_INC.'inc/auth.php');
19//close sesseion
20session_write_close();
21
22$ID    = getID();
23
24if(!auth_isadmin) die('for admins only');
25require_once(DOKU_INC.'inc/pluginutils.php');
26require_once(DOKU_INC.'inc/html.php');
27$acl = plugin_load('admin','acl');
28$acl->handle();
29
30$ajax = $_REQUEST['ajax'];
31header('Content-Type: text/html; charset=utf-8');
32
33if($ajax == 'info'){
34    $acl->_html_info();
35}elseif($ajax == 'tree'){
36    require_once(DOKU_INC.'inc/search.php');
37    global $conf;
38    global $ID;
39
40    $dir = $conf['datadir'];
41    $ns  = $_REQUEST['ns'];
42    if($ns == '*'){
43        $ns ='';
44    }
45    $lvl = count(explode(':',$ns));
46    $ns  = utf8_encodeFN(str_replace(':','/',$ns));
47
48    $data = array();
49    search($data,$conf['datadir'],'search_index',array('ns' => $ns),$ns);
50
51    foreach($data as $item){
52        $item['level'] = $lvl+1;
53        echo $acl->_html_li_acl($item);
54        echo '<div class="li">';
55        echo $acl->_html_list_acl($item);
56        echo '</div>';
57        echo '</li>';
58    }
59}
60
61