1<?php
2
3class Kiwiki_Functions {
4
5
6    /**
7     * Edit icon button
8     */
9    public static function _edit_icon($what){
10        global $ACT;
11        if ($ACT == 'show'){
12            $editicon = (new \dokuwiki\Menu\KiwikiEdit())->getListItems('kiwiki-',true);
13
14            if (!empty($what)){
15                $editicon = preg_replace('/<a(.*)href="([^"]*)"(.*)>/','<a$1href="'.DOKU_BASE.'doku.php?id='.$what.'&do=edit"$3>',$editicon);
16            }
17            return $editicon;
18        }
19    }
20
21
22    /**
23     * Go bottom button
24     */
25
26    public static function html_bottombtn() {
27        global $lang;
28
29        return '<a class="nolink" href="#dokuwiki__bottom">'
30            .'<button class="button" onclick="window.scrollTo(0, 0)" title="'. $lang['btn_bottom'] .'">'
31            . $lang['btn_bottom']
32            .'</button></a>';
33    }
34
35    /**
36     * Custom ACL Informations in footer
37     * Original code from Chris75
38     * https://forum.dokuwiki.org/d/21636-acl-deny-a-user-group-to-a-namespace/13
39     */
40
41     public static function tpl_aclinfo() {
42        global $ID, $AUTH_ACL, $INFO;
43
44        if ((auth_quickaclcheck($ID) == 0) ||(!$INFO['editable']))
45            return; // no rights to view, no rights to get this info
46
47        $page_acls = array();
48        $namespaces = array();
49
50        $ns = getNS($ID);
51        while ($ns) {
52        array_unshift($namespaces,$ns . ':*');
53        $ns = getNS($ns);
54        }
55        array_unshift($namespaces,'*'); // root
56
57        $namespaces[] = $ID;
58
59        // check matches
60        foreach ($namespaces as $level) {
61            $matches = preg_grep('/^'.preg_quote($level,'/').'\s+\S+\s+\d+\s*$/',$AUTH_ACL);
62            $this_acls = array();
63            foreach($matches as $match){
64            $match = preg_replace('/#.*$/','',$match); //ignore comments
65            $acl   = preg_split('/\s+/',$match);
66            $this_acls[urldecode($acl[1])] = $acl[2];
67            if ($acl[1] == "@ALL")  // overwrites stuff from upper level
68                $page_acls = array();
69            }
70            $page_acls =  array_merge($page_acls,$this_acls);
71        }
72
73        // check if visible to everyone:
74        /*if (($page_acls['@ALL'] !== false) && $page_acls['@ALL'] > 0)
75        return; // page is visible to everyone*/
76
77        $list = array();
78        foreach ($page_acls as $user => $right) {
79            if ($right > 0 && $user != "@admin" ) // admins can see everything
80                array_push($list,$user);
81        }
82        if (count($list)) {
83            sort($list);
84            print tpl_getLang('Visible to');
85            print join(', ',$list);
86        }
87
88        // Uncomment this, if you want to display users/groups who cannot access this page, too:
89        $list = array();
90        foreach ($page_acls as $user => $right) {
91            if ($right == 0)
92                array_push($list,$user);
93        }
94        if (count($list)) {
95            sort($list);
96            print " • ";
97            print tpl_getLang('Hidden to');
98            print join(', ',$list);
99        }
100    }
101}
102