PluginProbe
User Access Manager / 2.0.0
User Access Manager v2.0.0
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / UserAccessManager / View / AdminUserGroup.php

AdminUserGroup.php in User Access Manager 2.0.0, at src/UserAccessManager/View/AdminUserGroup.php

303 lines 12.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * AdminUserGroup.php
4 *
5 * Shows the user group page at the admin panel.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 * @copyright 2008-2017 Alexander Schneider
11 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 * @version SVN: $id$
13 * @link http://wordpress.org/extend/plugins/user-access-manager/
14 */
15
16 /**
17 * @var \UserAccessManager\Controller\AdminUserGroupController $controller
18 */
19 if ($controller->hasUpdateMessage()) {
20 ?>
21 <div class="updated">
22 <p><strong><?php echo $controller->getUpdateMessage(); ?></strong></p>
23 </div>
24 <?php
25 }
26
27 if ($controller->getRequestParameter('uam_action') === null
28 || $controller->getRequestParameter('uam_action') === 'delete_user_group'
29 ) {
30 ?>
31 <div class="wrap">
32 <form method="post" action="<?php echo $controller->getRequestUrl(); ?>">
33 <?php $controller->createNonceField('uamDeleteGroup'); ?>
34 <input type="hidden" value="delete_user_group" name="uam_action"/>
35 <h2><?php echo TXT_UAM_MANAGE_GROUP; ?></h2>
36 <div class="tablenav">
37 <div class="alignleft">
38 <input type="submit" class="button-secondary delete" name="deleteit"
39 value="<?php echo TXT_UAM_DELETE; ?>"/>
40 </div>
41 <br class="clear"/>
42 </div>
43 <table class="widefat">
44 <thead>
45 <tr class="thead">
46 <th scope="col"></th>
47 <th scope="col"><?php echo TXT_UAM_NAME; ?></th>
48 <th scope="col"><?php echo TXT_UAM_DESCRIPTION; ?></th>
49 <th scope="col"><?php echo TXT_UAM_READ_ACCESS; ?></th>
50 <th scope="col"><?php echo TXT_UAM_WRITE_ACCESS; ?></th>
51 <th scope="col"><?php echo TXT_UAM_GROUP_ROLE; ?></th>
52 <th scope="col"><?php echo TXT_UAM_IP_RANGE; ?></th>
53 </tr>
54 </thead>
55 <tbody>
56 <?php
57 $currentAdminPage = $controller->getRequestParameter('page');
58 $userGroups = $controller->getUserGroups();
59 foreach ($userGroups as $userGroup) {
60 ?>
61 <tr class="alternate" id="group-<?php echo $userGroup->getId(); ?>">
62 <th class="check-column" scope="row">
63 <label>
64 <input type="checkbox" value="<?php echo $userGroup->getId(); ?>" name="delete[]"/>
65 </label>
66 </th>
67 <td>
68 <strong>
69 <?php
70 $link = "?page={$currentAdminPage}&amp;uam_action=edit_user_group"
71 ."&amp;userGroupId={$userGroup->getId()}";
72 ?>
73 <a href="<?php echo $link; ?>">
74 <?php echo htmlentities($userGroup->getName()); ?>
75 </a>
76 </strong>
77 </td>
78 <td><?php echo htmlentities($userGroup->getDescription()) ?></td>
79 <td>
80 <?php
81 if ($userGroup->getReadAccess() === 'all') {
82 echo TXT_UAM_ALL;
83 } elseif ($userGroup->getReadAccess() === 'group') {
84 echo TXT_UAM_ONLY_GROUP_USERS;
85 }
86 ?>
87 </td>
88 <td>
89 <?php
90 if ($userGroup->getWriteAccess() === 'all') {
91 echo TXT_UAM_ALL;
92 } elseif ($userGroup->getWriteAccess() === 'group') {
93 echo TXT_UAM_ONLY_GROUP_USERS;
94 }
95 ?>
96 </td>
97 <td>
98 <?php
99 $roleNames = $controller->getRoleNames();
100 $groupRoles = $userGroup->getAssignedObjectsByType(
101 \UserAccessManager\ObjectHandler\ObjectHandler::GENERAL_ROLE_OBJECT_TYPE
102 );
103
104 if (count($groupRoles) > 0) {
105 ?>
106 <ul style="margin: 0;">
107 <?php
108 foreach ($groupRoles as $key => $role) {
109 ?>
110 <li><?php echo isset($roleNames[$key]) ? $roleNames[$key] : $key; ?></li>
111 <?php
112 }
113 ?>
114 </ul>
115 <?php
116 } else {
117 echo TXT_UAM_NONE;
118 }
119 ?>
120 </td>
121 <td>
122 <?php
123 if ($userGroup->getIpRange()) {
124 ?>
125 <ul>
126 <?php
127 foreach ($userGroup->getIpRange() as $ipRange) {
128 ?>
129 <li><?php echo htmlentities($ipRange); ?></li>
130 <?php
131 }
132 ?>
133 </ul>
134 <?php
135 } else {
136 echo TXT_UAM_NONE;
137 }
138 ?>
139 </td>
140 </tr>
141 <?php
142 }
143 ?>
144 </tbody>
145 </table>
146 <div class="tablenav">
147 <div class="alignleft">
148 <input type="submit" class="button-secondary delete" name="deleteit"
149 value="<?php echo TXT_UAM_DELETE; ?>"/>
150 </div>
151 <br class="clear"/>
152 </div>
153 </form>
154 </div>
155 <?php
156 }
157 ?>
158 <div class="wrap">
159 <h2>
160 <?php
161 if ($controller->getRequestParameter('uam_action') === 'editGroup') {
162 echo TXT_UAM_EDIT_GROUP;
163 } else {
164 echo TXT_UAM_ADD_GROUP;
165 }
166 ?>
167 </h2>
168 <form method="post" action="<?php echo $controller->getRequestUrl(); ?>">
169 <input type="hidden" value="insert_update_user_group" name="uam_action"/>
170 <?php
171 $userGroup = $controller->getUserGroup();
172 $controller->createNonceField('uamInsertUpdateGroup');
173 if ($userGroup->getId() !== null) {
174 ?>
175 <input type="hidden" value="<?php echo $userGroup->getId(); ?>" name="userGroupId"/>
176 <?php
177 }
178 ?>
179 <table class="form-table">
180 <tbody>
181 <tr class="form-field form-required">
182 <th valign="top" scope="row"><label for="userGroupName"><?php echo TXT_UAM_GROUP_NAME; ?></label></th>
183 <td>
184 <input type="text" size="40" value="<?php echo htmlentities($userGroup->getName()); ?>"
185 id="userGroupName" name="userGroupName"/><br/>
186 <?php echo TXT_UAM_GROUP_NAME_DESC; ?>
187 </td>
188 </tr>
189 <tr class="form-field form-required">
190 <th valign="top" scope="row"><label for="userGroupDescription"><?php echo TXT_UAM_GROUP_DESC; ?></label>
191 </th>
192 <td>
193 <input type="text" size="40" value="<?php echo htmlentities($userGroup->getDescription()); ?>"
194 id="userGroupDescription" name="userGroupDescription"/><br/>
195 <?php echo TXT_UAM_GROUP_DESC_DESC; ?>
196 </td>
197 </tr>
198 <tr class="form-field form-required">
199 <th valign="top" scope="row"><label for="ipRange"><?php echo TXT_UAM_GROUP_IP_RANGE; ?></label></th>
200 <td><input type="text" size="40" value="<?php echo htmlentities($userGroup->getIpRange(true)); ?>"
201 id="ipRange" name="ipRange"/><br/>
202 <?php echo TXT_UAM_GROUP_IP_RANGE_DESC; ?>
203 </td>
204 </tr>
205 <tr class="form-field form-required">
206 <th valign="top" scope="row"><label for="readAccess"><?php echo TXT_UAM_GROUP_READ_ACCESS; ?></label>
207 </th>
208 <td>
209 <select id="readAccess" name="readAccess">
210 <option value="group"
211 <?php
212 if ($userGroup->getReadAccess() === 'group') {
213 echo 'selected="selected"';
214 }
215 ?>
216 >
217 <?php echo TXT_UAM_ONLY_GROUP_USERS ?>
218 </option>
219 <option value="all"
220 <?php
221 if ($userGroup->getReadAccess() === 'all') {
222 echo 'selected="selected"';
223 }
224 ?>
225 >
226 <?php echo TXT_UAM_ALL ?>
227 </option>
228 </select><br/>
229 <?php echo TXT_UAM_GROUP_READ_ACCESS_DESC; ?>
230 </td>
231 </tr>
232 <tr class="form-field form-required">
233 <th valign="top" scope="row"><label for="writeAccess"><?php echo TXT_UAM_GROUP_WRITE_ACCESS; ?></label>
234 </th>
235 <td>
236 <select id="writeAccess" name="writeAccess">
237 <option value="group"
238 <?php
239 if ($userGroup->getWriteAccess() === 'group') {
240 echo 'selected="selected"';
241 }
242 ?>
243 >
244 <?php echo TXT_UAM_ONLY_GROUP_USERS ?>
245 </option>
246 <option value="all"
247 <?php
248 if ($userGroup->getWriteAccess() === 'all') {
249 echo 'selected="selected"';
250 }
251 ?>
252 >
253 <?php echo TXT_UAM_ALL ?>
254 </option>
255 </select><br/>
256 <?php echo TXT_UAM_GROUP_WRITE_ACCESS_DESC; ?>
257 </td>
258 </tr>
259 <tr>
260 <th valign="top" scope="row"><?php echo TXT_UAM_GROUP_ROLE; ?></th>
261 <td>
262 <ul class='uam_role'>
263 <?php
264 $groupRoles = $userGroup->getAssignedObjectsByType(
265 \UserAccessManager\ObjectHandler\ObjectHandler::GENERAL_ROLE_OBJECT_TYPE
266 );
267 $roleNames = $controller->getRoleNames();
268
269 foreach ($roleNames as $role => $name) {
270 if ($role !== 'administrator') {
271 ?>
272 <li class="selectit">
273 <input id="role-<?php echo $role; ?>" type="checkbox"
274 <?php
275 if (isset($groupRoles[$role]) === true) {
276 echo 'checked="checked"';
277 }
278 ?>
279 value="<?php echo $role; ?>" name="roles[]"/>
280 <label for="role-<?php echo $role; ?>">
281 <?php echo $name; ?>
282 </label>
283 </li>
284 <?php
285 }
286 }
287 ?>
288 </ul>
289 </td>
290 </tr>
291 </tbody>
292 </table>
293 <p class="submit">
294 <input type="submit" value="<?php
295 if ($userGroup->getId() !== null) {
296 echo TXT_UAM_UPDATE_GROUP;
297 } else {
298 echo TXT_UAM_ADD_GROUP;
299 }
300 ?>" name="submit" class="button"/>
301 </p>
302 </form>
303 </div>