Project:
Segue
Code Location:
git://github.com/adamfranco/segue-1.x.gitmaster
/
permissions.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<? /* $Id$ */ // holds permissions functions and checks for people's permissions in accessing certain pages define("SITE",0); define("SECTION",1); define("PAGE",2); define("STORY",3); define("ADD",0); define("EDIT",1); define("DELETE",2); define("VIEW",3); define("DISCUSS",4); /****************************************************************************** * PERMISSIONS OBJECT ******************************************************************************/ class permissions { // defines function ADD() {return 0;} function EDIT() {return 1;} function DELETE() {return 2;} function VIEW() {return 3;} function DISCUSS() {return 4;} // for this function to work, the form within which this is called MUST // be named 'addform' function outputForm(&$o,$d=0,$canAddEditors=true) { global $cfg; $sitename = $o->owning_site; if ($_SESSION[settings][edit] && !$o->builtPermissions) $o->buildPermissionsArray(); // ---- Editor actions ---- if ($_REQUEST[edaction] == 'add') { if (isgroup($_REQUEST[edname])) { $classes = group::getClassesFromName($_REQUEST[edname]); foreach ($classes as $class) { $o->addEditor($class); } } else { $o->addEditor($_REQUEST[edname]); } } if ($_REQUEST[edaction] == 'del') { $o->delEditor($_REQUEST[edname]); } printc("\n<input type='hidden' name='edaction' value='' />"); printc("\n<input type='hidden' name='edname' value='' />"); if ($className = $sitename) { print "<script type='text/javascript'>"; print "\n// <![CDATA["; print "\nfunction addClassEditor() {"; print "\n f = document.addform;"; print "\n f.edaction.value='add';"; print "\n f.edname.value='$className';"; print "\n f.submit();"; print "\n}"; print "\n// ]]>"; print "\n</script>"; } $a = array(0=>4,1=>1); printc("\n<style type='text/css'>th, .td0, .td1 {font-size: 10px;}</style>"); printc("\n<table width='100%' style='border: 1px solid gray'>"); printc("\n<tr><th width='50%'>name</th> <th colspan='".($a[$d])."' width='30%'>permissions</th>"); if ($canAddEditors) { printc("<th>del</th>"); } printc("</tr>"); printc("\n<tr><th> </th>".(($d)?"<th>discuss</th>":"<th>add</th><th>edit</th><th>delete</th><th>view</th>")); if ($canAddEditors) { printc("<th> </th>"); } printc("</tr>"); if (($edlist = $o->getEditors())) { $permissions = $o->getPermissions(); if (count($edlist)) { $color = 0; foreach ($edlist as $e) { // :: hack :: // this is needed until "anonymous" discussion is enabled. could be v 2.0 //if ($e == 'everyone') continue; // :: /hack :: printc("\n<tr><td class='td$color' align='left'>"); if ($e == "everyone") printc("Everyone (will override other entries)</td>"); else if ($e == "institute") printc($cfg[inst_name]." Users</td>"); else printc(ldapfname($e)." ($e)</td>"); for ($i = 0; $i<5; $i++) { $skip = 0;$nob=0; if ($d && $i<4) $skip = 1; if (!$d && $i==4) $skip = 1; if (!$d && (($e == 'everyone' || $e == 'institute') && $i!=3)) $nob=1; if (!$skip) { printc("\n<td class='td$color' align='center'>"); if ($nob) printc(" "); else printc("\n<input type='checkbox' name='permissions[$e][$i]' value='1'".(($permissions[$e][$i])?" checked='checked'":"")." />"); printc("</td>"); } if ($skip || $nob) { printc("\n<input type='hidden' name='permissions[$e][$i]' value='".$permissions[$e][$i]."' />"); } } printc("</td>"); if ($canAddEditors) { printc("\n<td class='td$color' align='center'>"); if ($e == 'everyone' || $e == 'institute') printc(" "); else printc("<a href='#' onclick='delEditor(\"$e\");'>remove</a>"); printc("</td>"); } printc("</tr>"); $color = 1-$color; } } } else printc("\n<tr><td class='td1' > </td><td class='td1' colspan=".($a[$d]+1).">no editors added</td></tr>"); if ($canAddEditors) { printc("\n<tr><th colspan=".($a[$d]+1).">"); $className= array(); if (isgroup($sitename)) { $className = $sitename; } else { $className = $sitename; } if (is_array($className)) { foreach ($className as $class) { if (!in_array($class,$edlist)) { printc("<a href='#' onclick='addClassEditor();'>Add students in ".$sitename."</a><br />"); break; } else { printc(" "); } } } printc("</th><th><a href='add_editor.php?$sid' target='addeditor' onclick='doWindow(\"addeditor\",400,250);'>add editor</a></th></tr>"); } printc("\n</table>"); // if ($_SESSION[settings][edit]) printc("<a href='editor_access.php?$sid&site=".$sitename."' onclick='doWindow(\"permissions\",600,400)' target='permissions'>Permissions as of last save</a>"); } }
