a8750d506952a81c72f1086dc2de4565e9fb99b3
[atutor.git] / mods / wiki / plugins / auth / auth_perm_ring.php
1 <?php
2
3 /*
4
5   This authentication plugin maps wiki actions and/or page names to the ring
6   level model:
7   ring 0 is for admin functionality (superuser)
8   ring 1 for advanced / privileged functions (moderators)
9   ring 2 are all standard/default things (editors)
10   ring 3 only allows access to a small subset of the wiki (browsing only)
11     
12 */
13
14
15 $ewiki_perm_rings = array_merge(
16    array(
17         "view"          => 3,
18         "info"          => 3,
19         "links"         => 3,
20         "edit"          => 2,
21         "calendar"      => 2,
22         "upload"        => 2,
23         "view/SecretPage" => 1,
24         "delete"        => 1,
25         "control"       => 0,
26         "admin"         => 0,
27         "*"             => 2,   #- anything else requires this ring level
28    ),
29    (array)@$ewiki_perm_rings
30 );
31
32
33
34 $ewiki_plugins["auth_perm"][0] = "ewiki_auth_handler_ring_permissions";
35
36
37 function ewiki_auth_handler_ring_permissions($id, $data, $action, $required_ring) {
38
39    global $ewiki_plugins, $ewiki_ring, $ewiki_perm_rings;
40
41    if ("ALWAYS_DO_THIS" || ($required_ring===false)) {
42
43       $id = strtolower($id);
44       $action = strtolower($action);
45
46       foreach ($ewiki_perm_rings as $string => $ring) {
47
48          $string = strtolower($string);
49
50          if (($string == "*") ||
51              ($string == $id) ||
52              ($string == $action) ||
53              ($string == "$action/$id") ||
54              (strtok($string, "/") == $action)  )
55          {
56             $required_ring = $ring;
57             break;
58          }
59  
60      }
61
62    }
63
64    return(($required_ring===false) || isset($ewiki_ring) && ($ewiki_ring <= $required_ring));
65 }
66
67
68 ?>