831 |
florian |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
4 |
// //
|
|
|
5 |
// Copyright (C) 2006 Phorum Development Team //
|
|
|
6 |
// http://www.phorum.org //
|
|
|
7 |
// //
|
|
|
8 |
// This program is free software. You can redistribute it and/or modify //
|
|
|
9 |
// it under the terms of either the current Phorum License (viewable at //
|
|
|
10 |
// phorum.org) or the Phorum License that was distributed with this file //
|
|
|
11 |
// //
|
|
|
12 |
// This program is distributed in the hope that it will be useful, //
|
|
|
13 |
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
|
|
|
14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
|
|
|
15 |
// //
|
|
|
16 |
// You should have received a copy of the Phorum License //
|
|
|
17 |
// along with this program. //
|
|
|
18 |
////////////////////////////////////////////////////////////////////////////////
|
|
|
19 |
|
|
|
20 |
if(!defined("PHORUM_CONTROL_CENTER")) return;
|
|
|
21 |
|
|
|
22 |
if (isset($PHORUM["args"]["group"])){
|
|
|
23 |
$perm = phorum_user_allow_moderate_group($PHORUM["args"]["group"]);
|
|
|
24 |
}
|
|
|
25 |
else{
|
|
|
26 |
$perm = $PHORUM["DATA"]["GROUP_MODERATOR"];
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
if (!$perm) {
|
|
|
30 |
phorum_redirect_by_url(phorum_get_url(PHORUM_CONTROLCENTER_URL));
|
|
|
31 |
exit();
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
// figure out what the user is trying to do, in this case we have a group to list (and maybe some commands)
|
|
|
35 |
if (isset($PHORUM["args"]["group"])){
|
|
|
36 |
// if adding a new user to the group
|
|
|
37 |
if (isset($_REQUEST["adduser"])){
|
|
|
38 |
$userid = phorum_db_user_check_field("username", $_REQUEST["adduser"]);
|
|
|
39 |
// load the users groups, add the new group, then save again
|
|
|
40 |
$groups = phorum_user_get_groups($userid);
|
|
|
41 |
// make sure the user isn't already a member of the group
|
|
|
42 |
if (!isset($groups[$PHORUM["args"]["group"]])){
|
|
|
43 |
$groups[$PHORUM["args"]["group"]] = PHORUM_USER_GROUP_APPROVED;
|
|
|
44 |
phorum_user_save_groups($userid, $groups);
|
|
|
45 |
$PHORUM["DATA"]["Message"] = $PHORUM["DATA"]["LANG"]["UserAddedToGroup"];
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
// if changing the existing members of the group
|
|
|
50 |
if (isset($_REQUEST["status"])){
|
|
|
51 |
foreach ($_REQUEST["status"] as $userid => $status){
|
|
|
52 |
// load the users groups, make the change, then save again
|
|
|
53 |
$groups = phorum_user_get_groups($userid);
|
|
|
54 |
// we can't set someone to be a moderator from here
|
|
|
55 |
if ($status != PHORUM_USER_GROUP_MODERATOR){
|
|
|
56 |
$groups[$PHORUM["args"]["group"]] = $status;
|
|
|
57 |
}
|
|
|
58 |
if ($status == PHORUM_USER_GROUP_REMOVE){
|
|
|
59 |
unset($groups[$PHORUM["args"]["group"]]);
|
|
|
60 |
}
|
|
|
61 |
phorum_user_save_groups($userid, $groups);
|
|
|
62 |
}
|
|
|
63 |
$PHORUM["DATA"]["Message"] = $PHORUM["DATA"]["LANG"]["ChangesSaved"];
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
$group = phorum_db_get_groups($PHORUM["args"]["group"]);
|
|
|
67 |
$PHORUM["DATA"]["GROUP"]["name"] = $group[$PHORUM["args"]["group"]]["name"];
|
|
|
68 |
$PHORUM["DATA"]["USERS"] = array();
|
|
|
69 |
$PHORUM["DATA"]["GROUP"]["url"] = phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $PHORUM["args"]["group"]);
|
|
|
70 |
|
|
|
71 |
$PHORUM["DATA"]["FILTER"] = array();
|
|
|
72 |
$PHORUM["DATA"]["FILTER"][] = array("name" => $PHORUM["DATA"]["LANG"]["None"],
|
|
|
73 |
"enable" => !(!isset($PHORUM["args"]["filter"])),
|
|
|
74 |
"url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $PHORUM["args"]["group"]));
|
|
|
75 |
$PHORUM["DATA"]["FILTER"][] = array("name" => $PHORUM["DATA"]["LANG"]["Approved"],
|
|
|
76 |
"enable" => !(isset($PHORUM["args"]["filter"]) && $PHORUM["args"]["filter"] == PHORUM_USER_GROUP_APPROVED),
|
|
|
77 |
"url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $PHORUM["args"]["group"], "filter=" . PHORUM_USER_GROUP_APPROVED));
|
|
|
78 |
$PHORUM["DATA"]["FILTER"][] = array("name" => $PHORUM["DATA"]["LANG"]["PermGroupModerator"],
|
|
|
79 |
"enable" => !(isset($PHORUM["args"]["filter"]) && $PHORUM["args"]["filter"] == PHORUM_USER_GROUP_MODERATOR),
|
|
|
80 |
"url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $PHORUM["args"]["group"], "filter=" . PHORUM_USER_GROUP_MODERATOR));
|
|
|
81 |
$PHORUM["DATA"]["FILTER"][] = array("name" => $PHORUM["DATA"]["LANG"]["Suspended"],
|
|
|
82 |
"enable" => !(isset($PHORUM["args"]["filter"]) && $PHORUM["args"]["filter"] == PHORUM_USER_GROUP_SUSPENDED),
|
|
|
83 |
"url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $PHORUM["args"]["group"], "filter=" . PHORUM_USER_GROUP_SUSPENDED));
|
|
|
84 |
$PHORUM["DATA"]["FILTER"][] = array("name" => $PHORUM["DATA"]["LANG"]["Unapproved"],
|
|
|
85 |
"enable" => !(isset($PHORUM["args"]["filter"]) && $PHORUM["args"]["filter"] == PHORUM_USER_GROUP_UNAPPROVED),
|
|
|
86 |
"url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $PHORUM["args"]["group"], "filter=" . PHORUM_USER_GROUP_UNAPPROVED));
|
|
|
87 |
|
|
|
88 |
$PHORUM["DATA"]["STATUS_OPTIONS"] = array();
|
|
|
89 |
$PHORUM["DATA"]["STATUS_OPTIONS"][] = array("value" => PHORUM_USER_GROUP_REMOVE, "name" => "< " . $PHORUM["DATA"]["LANG"]["RemoveFromGroup"] . " >");
|
|
|
90 |
$PHORUM["DATA"]["STATUS_OPTIONS"][] = array("value" => PHORUM_USER_GROUP_APPROVED, "name" => $PHORUM["DATA"]["LANG"]["Approved"]);
|
|
|
91 |
$PHORUM["DATA"]["STATUS_OPTIONS"][] = array("value" => PHORUM_USER_GROUP_UNAPPROVED, "name" => $PHORUM["DATA"]["LANG"]["Unapproved"]);
|
|
|
92 |
$PHORUM["DATA"]["STATUS_OPTIONS"][] = array("value" => PHORUM_USER_GROUP_SUSPENDED, "name" => $PHORUM["DATA"]["LANG"]["Suspended"]);
|
|
|
93 |
|
|
|
94 |
$groupmembers = phorum_db_get_group_members($PHORUM["args"]["group"]);
|
|
|
95 |
$usersingroup = array_keys($groupmembers);
|
|
|
96 |
$users = phorum_user_get($usersingroup);
|
|
|
97 |
$memberlist = array();
|
|
|
98 |
foreach ($groupmembers as $userid => $status){
|
|
|
99 |
// if we have a filter, check that the user is in it
|
|
|
100 |
if (isset($PHORUM["args"]["filter"])){
|
|
|
101 |
if ($PHORUM["args"]["filter"] != $status){
|
|
|
102 |
continue;
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
$disabled = false;
|
|
|
107 |
$statustext = "";
|
|
|
108 |
// moderators can't edit other moderators
|
|
|
109 |
if ($status == PHORUM_USER_GROUP_MODERATOR){
|
|
|
110 |
$disabled = true;
|
|
|
111 |
$statustext = $PHORUM["DATA"]["LANG"]["PermGroupModerator"];
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
$PHORUM["DATA"]["USERS"][$userid] = array("userid" => $userid,
|
|
|
115 |
"name" => $users[$userid]["username"],
|
|
|
116 |
"displayname" => $users[$userid]["username"],
|
|
|
117 |
"status" => $status,
|
|
|
118 |
"statustext" => $statustext,
|
|
|
119 |
"disabled" => $disabled,
|
|
|
120 |
"flag" => ($status < PHORUM_USER_GROUP_APPROVED),
|
|
|
121 |
"profile" => phorum_get_url(PHORUM_PROFILE_URL, $userid)
|
|
|
122 |
);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
$PHORUM["DATA"]["USERS"] = phorum_hook("user_list", $PHORUM["DATA"]["USERS"]);
|
|
|
126 |
|
|
|
127 |
// if the option to build a dropdown list is enabled, build the list of members that could be added
|
|
|
128 |
if ($PHORUM["enable_dropdown_userlist"]){
|
|
|
129 |
$userlist = phorum_user_get_list();
|
|
|
130 |
$PHORUM["DATA"]["NEWMEMBERS"] = array();
|
|
|
131 |
|
|
|
132 |
foreach ($userlist as $userid => $userinfo){
|
|
|
133 |
if (!in_array($userid, $usersingroup)){
|
|
|
134 |
$PHORUM["DATA"]["NEWMEMBERS"][] = $userinfo;
|
|
|
135 |
}
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
// if they aren't doing anything, show them a list of groups they can moderate
|
|
|
142 |
else{
|
|
|
143 |
$PHORUM["DATA"]["GROUPS"] = array();
|
|
|
144 |
$groups = phorum_user_get_moderator_groups();
|
|
|
145 |
// put these things in order so the user can read them
|
|
|
146 |
asort($groups);
|
|
|
147 |
foreach ($groups as $groupid => $groupname){
|
|
|
148 |
// get the group members who are unapproved, so we can count them
|
|
|
149 |
$members = phorum_db_get_group_members($groupid, PHORUM_USER_GROUP_UNAPPROVED);
|
|
|
150 |
$PHORUM["DATA"]["GROUPS"][] = array("id" => $groupid,
|
|
|
151 |
"name" => $groupname,
|
|
|
152 |
"unapproved" => count($members),
|
|
|
153 |
"unapproved_url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $groupid, "filter=" . PHORUM_USER_GROUP_UNAPPROVED),
|
|
|
154 |
"url" => phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL, "panel=" . PHORUM_CC_GROUP_MODERATION, "group=" . $groupid)
|
|
|
155 |
);
|
|
|
156 |
}
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
$template = "cc_groupmod";
|
|
|
160 |
?>
|