PluginProbe
User Access Manager / 2.1.10
User Access Manager v2.1.10
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 / View / UserGroups / UserGroupList.php

UserGroupList.php in User Access Manager 2.1.10, at src/View/UserGroups/UserGroupList.php

164 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * UserGroupList.php
4 *
5 * Shows the user group edit list 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\Backend\UserGroupController $controller
18 */
19
20 /**
21 * @param string $name
22 * @param string $sortingParameter
23 *
24 * @return string
25 */
26 $createHeaderColumn = function ($name, $sortingParameter) use ($controller) {
27 $isSorted = $controller->getRequestParameter('orderby') === $sortingParameter;
28 $class = $isSorted === true ? 'sorted' : 'sortable';
29 $sortOrder = $isSorted === true ? $controller->getRequestParameter('order') : 'asc';
30
31 $inner = "<span>{$name}</span><span class=\"sorting-indicator\"></span>";
32 $link = "<a href=\"{$controller->getSortUrl($sortingParameter)}\" >{$inner}</a>";
33 return "<th scope=\"col\" class=\"{$class} {$sortOrder}\">{$link}</th>";
34 }
35
36 ?>
37 <form method="post" action="<?php echo $controller->getRequestUrl(); ?>">
38 <?php $controller->createNonceField('uamDeleteGroup'); ?>
39 <input type="hidden" value="delete_user_group" name="uam_action"/>
40 <div class="tablenav">
41 <div class="alignleft">
42 <input type="submit" class="button-secondary delete" name="deleteit"
43 value="<?php echo TXT_UAM_DELETE; ?>"/>
44 </div>
45 <br class="clear"/>
46 </div>
47 <table class="widefat">
48 <thead>
49 <tr class="thead">
50 <th scope="col"></th>
51 <?php echo $createHeaderColumn(TXT_UAM_NAME, 'name'); ?>
52 <?php echo $createHeaderColumn(TXT_UAM_DESCRIPTION, 'description'); ?>
53 <?php echo $createHeaderColumn(TXT_UAM_READ_ACCESS, 'readAccess'); ?>
54 <?php echo $createHeaderColumn(TXT_UAM_WRITE_ACCESS, 'writeAccess'); ?>
55 <th scope="col"><?php echo TXT_UAM_GROUP_ROLE; ?></th>
56 <?php echo $createHeaderColumn(TXT_UAM_IP_RANGE, 'ipRange'); ?>
57 </tr>
58 </thead>
59 <tbody>
60 <?php
61 $currentAdminPage = $controller->getRequestParameter('page');
62 $userGroups = $controller->getUserGroups();
63 foreach ($userGroups as $userGroup) {
64 ?>
65 <tr class="alternate" id="group-<?php echo $userGroup->getId(); ?>">
66 <th class="check-column">
67 <label>
68 <input type="checkbox" value="<?php echo $userGroup->getId(); ?>" name="delete[]"/>
69 </label>
70 </th>
71 <td>
72 <strong>
73 <?php
74 $link = "?page={$currentAdminPage}&amp;uam_action=edit_user_group"
75 ."&amp;userGroupId={$userGroup->getId()}";
76 ?>
77 <a href="<?php echo $link; ?>">
78 <?php echo htmlentities($userGroup->getName()); ?>
79 </a>
80 </strong>
81 </td>
82 <td><?php echo htmlentities($userGroup->getDescription()) ?></td>
83 <td>
84 <?php
85 if ($userGroup->getReadAccess() === 'all') {
86 echo TXT_UAM_ALL;
87 } elseif ($userGroup->getReadAccess() === 'group') {
88 echo TXT_UAM_ONLY_GROUP_USERS;
89 }
90 ?>
91 </td>
92 <td>
93 <?php
94 if ($userGroup->getWriteAccess() === 'all') {
95 echo TXT_UAM_ALL;
96 } elseif ($userGroup->getWriteAccess() === 'group') {
97 echo TXT_UAM_ONLY_GROUP_USERS;
98 } elseif ($userGroup->getWriteAccess() === 'none') {
99 echo TXT_UAM_NONE;
100 }
101 ?>
102 </td>
103 <td>
104 <?php
105 $roleNames = $controller->getRoleNames();
106 $groupRoles = $userGroup->getAssignedObjectsByType(
107 \UserAccessManager\Object\ObjectHandler::GENERAL_ROLE_OBJECT_TYPE
108 );
109
110 if (count($groupRoles) > 0) {
111 ?>
112 <ul style="margin: 0;">
113 <?php
114 foreach ($groupRoles as $key => $role) {
115 ?>
116 <li><?php echo isset($roleNames[$key]) ? $roleNames[$key] : $key; ?></li>
117 <?php
118 }
119 ?>
120 </ul>
121 <?php
122 } else {
123 echo TXT_UAM_NONE;
124 }
125 ?>
126 </td>
127 <td>
128 <?php
129 $ipRanges = $userGroup->getIpRangeArray();
130
131 if (count($ipRanges) > 0) {
132 ?>
133 <ul>
134 <?php
135 foreach ($ipRanges as $ipRange) {
136 ?>
137 <li><?php echo htmlentities($ipRange); ?></li>
138 <?php
139 }
140 ?>
141 </ul>
142 <?php
143 } else {
144 echo TXT_UAM_NONE;
145 }
146 ?>
147 </td>
148 </tr>
149 <?php
150 }
151 ?>
152 </tbody>
153 </table>
154 <div class="tablenav">
155 <div class="alignleft">
156 <input type="submit"
157 class="button-secondary delete"
158 name="deleteit"
159 value="<?php echo TXT_UAM_DELETE; ?>"/>
160 </div>
161 <br class="clear"/>
162 </div>
163 </form>
164