+// for read pages: will come only once so we have to be careful
+// and translate any auth from the wiki to smarty auth
+function AuthPlatal($pagename, $level, $authprompt, $since)
+{
+ global $Conditions;
+ $authUser = false;
+ $authPage = false;
+
+ $page_read = ReadPage($pagename, $since);
+ $groupattr = FmtPageName('$Group/GroupAttributes', $pagename);
+ $group_read = ReadPage($groupattr, $since);
+
+ $levels = array('read', 'attr', 'edit', 'upload');
+
+ foreach ($levels as $l)
+ {
+ list($from, $pass) = TryAllAuths($pagename, $l, $page_read, $group_read);
+ $passwds[$l] = $pass;
+ $pwsources[$l] = $from;
+ }
+
+ $canedit = authPerms($pagename, $passwds['edit'], true, true);
+ $canattr = authPerms($pagename, $passwds['attr'], true, true);
+ $panel = "{if ($canedit) or ($canattr)}\n";
+ $panel .= ">>frame<<\n";
+ $panel .= "[[{\$FullName} |Voir la page]]\\\\\n";
+ $panel .= "{if ($canedit)}\n";
+ $panel .= "[[{\$FullName}?action=edit |Editer]]\\\\\n";
+ $panel .= "[[{\$FullName}?action=diff |Historique]]\\\\\n";
+ $panel .= "[[{\$FullName}?action=upload |Upload]]\\\\\n";
+ $panel .= "{/if}{if ($canattr)}\n";
+ $panel .= "[[{\$FullName}?action=attr |Droits]]\\\\\n";
+ $panel .= "[[{\$Group}/GroupAttributes?action=attr|Droits du groupe]]\\\\\n";
+ $panel .= "{/if}\n";
+ $panel .= ">><<\n";
+ $panel .= "{/if}\n";
+
+ if ((identified() && has_perms()) || authPerms($pagename, $passwds[$level]))
+ {
+ $page_read['=passwd'] = $passwds;
+ $page_read['=pwsource'] = $pwsources;
+ // if try to read, add the permission limitation as a smarty if tag
+ if ($level == 'read')
+ {
+ $page_read['text'] = auth_pmwiki_to_smarty($page_read['text'], $passwds['read']);
+ $page_read['text'] = $panel.$page_read['text'];
+ }
+// print_r($page_read); die();
+ return $page_read;
+ }
+
+ // if we arrive here, the user doesn't have enough permission to access page
+
+ // maybe it is because he is not identified
+ if ($authprompt && !identified())
+ {
+ new_identification_page();
+ }
+
+ global $page;
+ new_identification_page();
+ if (has_perms()) {
+ $page->trig('Erreur : page Wiki inutilisable sur plat/al');
+ } else {
+ $page->trig("Tu n'as pas le droit d'accéder à ce service");
+ }
+ $page->run();
+ // don't return false or pmwiki will send an exit breaking smarty page
+ return 1;
+}