1515 * need to inherit from this class
1616 */
1717class 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+ }
1827
1928 /**
2029 * What kind of syntax are we?
@@ -59,7 +68,6 @@ function handle($match, $state, $pos, Doku_Handler $handler){
5968 */
6069 function render ($ format , Doku_Renderer $ R , $ data ) {
6170 global $ INFO ;
62- global $ AUTH_ACL ;
6371
6472 if ($ format != 'xhtml ' ) return false ;
6573
@@ -69,47 +77,17 @@ function render($format, Doku_Renderer $R, $data) {
6977 $ page = $ data [0 ];
7078 }
7179
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 );
7981
8082 $ R ->listu_open ();
8183
8284 /*
8385 * Go through each entry of the ACL rules.
8486 */
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 ){
11088 $ R ->listitem_open (1 );
11189 $ R ->listcontent_open ();
112- $ R ->cdata (sprintf ( $ this ->getLang ( ' perm ' . $ perm ), $ subject ));
90+ $ R ->cdata ($ this ->helper -> getACLInfoString ( $ entry ));
11391 $ R ->listcontent_close ();
11492 $ R ->listitem_close ();
11593 }
0 commit comments