15
15
* need to inherit from this class
16
16
*/
17
17
class syntax_plugin_aclinfo extends DokuWiki_Syntax_Plugin {
18
+ /** @var helper_plugin_aclinfo */
19
+ protected $ helper ;
20
+
21
+ /**
22
+ * syntax_plugin_aclinfo constructor.
23
+ */
24
+ public function __construct () {
25
+ $ this ->helper = plugin_load ('helper ' , 'aclinfo ' );
26
+ }
18
27
19
28
/**
20
29
* What kind of syntax are we?
@@ -59,7 +68,6 @@ function handle($match, $state, $pos, Doku_Handler $handler){
59
68
*/
60
69
function render ($ format , Doku_Renderer $ R , $ data ) {
61
70
global $ INFO ;
62
- global $ AUTH_ACL ;
63
71
64
72
if ($ format != 'xhtml ' ) return false ;
65
73
@@ -69,47 +77,17 @@ function render($format, Doku_Renderer $R, $data) {
69
77
$ page = $ data [0 ];
70
78
}
71
79
72
- $ subjects = array ();
73
-
74
- /*
75
- * Get the permissions for @ALL in the beginning, we will use it
76
- * to compare and filter other permissions that are lower.
77
- */
78
- $ allperm = auth_aclcheck ($ page , '' , array ('ALL ' ));
80
+ $ info = $ this ->helper ->getACLInfo ($ page );
79
81
80
82
$ R ->listu_open ();
81
83
82
84
/*
83
85
* Go through each entry of the ACL rules.
84
86
*/
85
- foreach ($ AUTH_ACL as $ rule ){
86
- $ rule = preg_replace ('/#.*$/ ' , '' , $ rule ); // Ignore comments
87
- $ subject = preg_split ('/[ \t]+/ ' , $ rule )[1 ];
88
- $ subject = urldecode ($ subject );
89
- $ groups = array ();
90
- $ user = '' ;
91
-
92
- // Skip if we already checked this user/group
93
- if (in_array ($ subject , $ subjects ))
94
- continue ;
95
-
96
- $ subjects [] = $ subject ;
97
-
98
- // Check if this entry is about a user or a group (starting with '@')
99
- if (substr ($ subject , 0 , 1 ) === '@ ' )
100
- $ groups [] = substr ($ subject , 1 );
101
- else
102
- $ user = $ subject ;
103
-
104
- $ perm = auth_aclcheck ($ page , $ user , $ groups );
105
-
106
- // Skip permissions of 0 or if lower than @ALL
107
- if ($ perm == AUTH_NONE || ($ subject != '@ALL ' && $ perm <= $ allperm ))
108
- continue ;
109
-
87
+ foreach ($ info as $ entry ){
110
88
$ R ->listitem_open (1 );
111
89
$ R ->listcontent_open ();
112
- $ R ->cdata (sprintf ( $ this ->getLang ( ' perm ' . $ perm ), $ subject ));
90
+ $ R ->cdata ($ this ->helper -> getACLInfoString ( $ entry ));
113
91
$ R ->listcontent_close ();
114
92
$ R ->listitem_close ();
115
93
}
0 commit comments