3 $AuthFunction = 'AuthPlatal';
5 $Conditions['logged'] = logged();
6 $Conditions['identified'] = identified();
7 $Conditions['has_perms'] = has_perms();
8 $Conditions['public'] = 'true';
9 $Conditions['only_public'] = !identified();
11 function authPerms($pagename, $key, $could=false
)
13 $words = explode(' ', $key);
16 foreach ($words as $word) {
18 if ($word == 'and:') {
22 $parts = explode(':', $word);
25 if ($cond == 'identified' && $could) {
28 $iauth = CondText($pagename, 'if '.$cond.' '.$param, true
);
39 function TryAllAuths($pagename, $level, $page_read, $group_read)
41 global $DefaultPasswords;
42 if (isset($page_read['passwd'.$level]) && $page_read['passwd'.$level] != '*') {
43 return array('page', $page_read['passwd'.$level]);
45 if (isset($group_read['passwd'.$level]) && $group_read['passwd'.$level] != '*') {
46 return array('group', $group_read['passwd'.$level]);
48 if (isset($DefaultPasswords[$level])) {
49 return array('site', $DefaultPasswords[$level]);
51 return array('none', '');
54 function AuthPlatal($pagename, $level, $authprompt, $since)
60 $page_read = ReadPage($pagename, $since);
61 $groupattr = FmtPageName('$Group/GroupAttributes', $pagename);
62 $group_read = ReadPage($groupattr, $since);
64 $levels = array('read', 'attr', 'edit', 'upload');
66 foreach ($levels as $l)
68 list($from, $pass) = TryAllAuths($pagename, $l, $page_read, $group_read);
70 $pwsources[$l] = $from;
73 if (!isset($Conditions['canedit'])) {
74 $Conditions['canedit'] = authPerms($pagename, $passwds['edit'], true
);
76 if (!isset($Conditions['canattr'])) {
77 $Conditions['canattr'] = authPerms($pagename, $passwds['attr'], true
);
80 if (authPerms($pagename, $passwds[$level]))
82 $page_read['=passwd'] = $passwds;
83 $page_read['=pwsource'] = $pwsources;
87 if ($authprompt && !identified())
89 new_skinned_page('wiki.tpl', AUTH_MDP
);
93 new_skinned_page('', AUTH_MDP
);
95 $page->trig('Erreur : page Wiki inutilisable sur plat/al');
97 $page->trig("Tu n'as pas le droit d'accéder à ce service");
99 // don't return false or pmwiki will send an exit breaking smarty page