-
Notifications
You must be signed in to change notification settings - Fork 0
/
WikiGroups.php
169 lines (147 loc) · 4.18 KB
/
WikiGroups.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
165
166
167
168
169
<?php
/*
moziloWiki - WikiGroups.php
A lightweight group management for moziloWiki. Feel free to
change it to your personal purposes.
Arvid Zimmermann 2006 <[email protected]>
*/
require_once("Properties.php");
require_once("CSV.php");
class WikiGroups {
// the arrays which contain the group data
var $mygroups = array();
var $groups;
var $groupdata;
// 0: unrestricted user, possibly with user management rights (admin)
// 1: user which can change every wiki content (registered user)
// 2: user which only can read and search (guest)
function __construct() {
global $USRMGT_GROUPS;
global $USRMGT_GROUPDATA;
$this->groups = new CSV($USRMGT_GROUPS);
$this->groupdata = new Properties($USRMGT_GROUPDATA);
$this->loadWikiGroups();
}
// load data from files
function loadWikiGroups() {
$groups = $this->groups->toArray();
foreach ($groups as $groupid) {
if ($groupid == "")
continue;
$anonymous = $this->groupdata->get("$groupid.anonymous");
$changepw = $this->groupdata->get("$groupid.changepw");
$editcontent = $this->groupdata->get("$groupid.editcontent");
$editusers = $this->groupdata->get("$groupid.editusers");
$member = $this->groupdata->get("$groupid.member");
$name = $this->groupdata->get("$groupid.name");
$this->mygroups[$groupid] = array($anonymous, $changepw, $editcontent, $editusers, $member, $name);
}
}
// return the given group's right to login multiple
function isAnonymous($number) {
$groupdata = $this->getGroupData($number);
if (!$groupdata == null)
if ($groupdata[0] == "true")
return true;
else
return false;
// return false, if the group doesn't exist
else
return false;
}
// return the given group's right to change pw
function canChangePw($number) {
$groupdata = $this->getGroupData($number);
if (!$groupdata == null)
if ($groupdata[1] == "true")
return true;
else
return false;
// return false, if the group doesn't exist
else
return false;
}
// return the given group's right to edit content
function canEditContent($number) {
$groupdata = $this->getGroupData($number);
if (!$groupdata == null)
if ($groupdata[2] == "true")
return true;
else
return false;
// return false, if the group doesn't exist
else
return false;
}
// return the given group's right to edit users
function canEditUsers($number) {
$groupdata = $this->getGroupData($number);
if (!$groupdata == null)
if ($groupdata[3] == "true")
return true;
else
return false;
// return false, if the group doesn't exist
else
return false;
}
// return the given group's member name
function getMemberName($number) {
$groupdata = $this->getGroupData($number);
if (!$groupdata == null)
return $groupdata[4];
// return null, if the group doesn't exist
else
return null;
}
// return the given group's name
function getName($number) {
$groupdata = $this->getGroupData($number);
if (!$groupdata == null)
return $groupdata[5];
// return null, if the group doesn't exist
else
return null;
}
// return the given group's full data
function getGroupData($number) {
if (isSet($this->mygroups[$number]) && $this->mygroups[$number])
return $this->mygroups[$number];
// return null, if the group doesn't exist
else
return null;
}
// return number of existent groups
function getGroupCount() {
return sizeof($this->mygroups);
}
// return a sorted array of all groups
function getAllGroups() {
asort($this->mygroups);
return $this->mygroups;
}
// return a group's right
function getGroupRight($group, $right) {
return $this->groupdata->get($group.".".$right);
}
// add group
function addGroup($groupid, $anonymous, $changepw, $editcontent, $editusers, $member, $name, $replace) {
return false;
// --------------
// STILL TO DO!
// --------------
// - wenn anonymous, dann nicht alle anderen
// - wenn changepw, dann editcontent
// - wenn editcontent, dann changepw
// - wenn editusers, dann editcontent und changepw
}
// delete group
function deleteGroup($groupid) {
return false;
// --------------
// STILL TO DO!
// --------------
// nur, wenn kein benutzer dieser gruppe angehört!
}
}
?>