| 1 |
<?php |
| 2 |
/** |
| 3 |
* GroupSelectionFrom.php |
| 4 |
* |
| 5 |
* Shows the group selection form 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 |
use UserAccessManager\Controller\Backend\ObjectMembership\ObjectController; |
| 17 |
use UserAccessManager\Object\ObjectHandler; |
| 18 |
use UserAccessManager\UserGroup\AssignmentInformation; |
| 19 |
use UserAccessManager\UserGroup\DynamicUserGroup; |
| 20 |
use UserAccessManager\UserGroup\UserGroup; |
| 21 |
|
| 22 |
?> |
| 23 |
<input type="hidden" name="uam_update_groups" value="1"/> |
| 24 |
<ul class="uam_group_selection"> |
| 25 |
<?php |
| 26 |
/** |
| 27 |
* @var ObjectController $controller |
| 28 |
*/ |
| 29 |
|
| 30 |
$groupsFormName = $controller->getGroupsFormName(); |
| 31 |
$objectType = $controller->getObjectInformation()->getObjectType(); |
| 32 |
$objectId = $controller->getObjectInformation()->getObjectId(); |
| 33 |
$userGroups = $controller->getFilteredUserGroups(); |
| 34 |
$controller->sortUserGroups($userGroups); |
| 35 |
$dateUtil = $controller->getDateUtil(); |
| 36 |
|
| 37 |
/** |
| 38 |
* @var UserGroup[] $userGroups |
| 39 |
*/ |
| 40 |
foreach ($userGroups as $userGroup) { |
| 41 |
$userGroup->setIgnoreDates(true); |
| 42 |
$fromDate = null; |
| 43 |
$toDate = null; |
| 44 |
$isLockedRecursive = false; |
| 45 |
$attributes = ''; |
| 46 |
|
| 47 |
/** |
| 48 |
* @var AssignmentInformation $assignmentInformation |
| 49 |
*/ |
| 50 |
if ($userGroup->isObjectMember($objectType, $objectId, $assignmentInformation) === true) { |
| 51 |
$attributes .= 'checked="checked" '; |
| 52 |
$fromDate = $assignmentInformation->getFromDate(); |
| 53 |
$toDate = $assignmentInformation->getToDate(); |
| 54 |
$isLockedRecursive = $userGroup->isLockedRecursive($objectType, $objectId); |
| 55 |
$attributes .= ($isLockedRecursive === true) ? ' disabled="disabled"' : ''; |
| 56 |
} elseif ($controller->isNewObject() |
| 57 |
&& $userGroup->isDefaultGroupForObjectType($objectType, $fromTime, $toTime) === true |
| 58 |
) { |
| 59 |
$attributes .= 'checked="checked" '; |
| 60 |
$fromDate = $dateUtil->getDateFromTime($fromTime); |
| 61 |
$toDate = $dateUtil->getDateFromTime($toTime); |
| 62 |
} elseif ($userGroup instanceof DynamicUserGroup |
| 63 |
&& $userGroup->getId() !== DynamicUserGroup::USER_TYPE . '|0' |
| 64 |
) { |
| 65 |
continue; |
| 66 |
} |
| 67 |
|
| 68 |
?> |
| 69 |
<li> |
| 70 |
<input type="checkbox" |
| 71 |
id="<?php echo $groupsFormName; ?>-<?php echo $userGroup->getId(); ?>" <?php echo $attributes; ?> |
| 72 |
value="<?php echo $userGroup->getId(); ?>" |
| 73 |
name="<?php echo $groupsFormName; ?>[<?php echo $userGroup->getId(); ?>][id]"/> |
| 74 |
<label for="<?php echo $groupsFormName; ?>-<?php echo $userGroup->getId(); ?>" class="selectit" |
| 75 |
style="display:inline;"> |
| 76 |
<?php echo htmlentities($userGroup->getName()) . ($isLockedRecursive === true ? ' [LR]' : ''); ?> |
| 77 |
</label> |
| 78 |
<span class="uam_flyout"> |
| 79 |
<button type="button" |
| 80 |
class="uam_group_info_link uam_flyout_toggle button-link" |
| 81 |
aria-expanded="false" |
| 82 |
aria-haspopup="true"><?php echo TXT_UAM_INFO; ?></button> |
| 83 |
<?php include 'GroupInfo.php'; ?> |
| 84 |
</span> |
| 85 |
<?php |
| 86 |
$dateText = TXT_UAM_GROUP_ASSIGNMENT_TIME; |
| 87 |
|
| 88 |
if ($fromDate !== null) { |
| 89 |
$dateText = TXT_UAM_GROUP_FROM_DATE . ' ' . $dateUtil->formatDate($fromDate); |
| 90 |
} |
| 91 |
|
| 92 |
if ($toDate !== null) { |
| 93 |
$dateText = ($dateText !== TXT_UAM_GROUP_ASSIGNMENT_TIME) ? $dateText . '<br>' : ''; |
| 94 |
$dateText .= TXT_UAM_GROUP_TO_DATE . ' ' . $dateUtil->formatDate($toDate); |
| 95 |
} |
| 96 |
|
| 97 |
if ($isLockedRecursive === false) { |
| 98 |
$formPrefix = $groupsFormName . '-' . $userGroup->getId(); |
| 99 |
?> |
| 100 |
<span class="uam_flyout"> |
| 101 |
<button type="button" |
| 102 |
class="uam_group_date uam_flyout_toggle button-link" |
| 103 |
aria-expanded="false" |
| 104 |
aria-haspopup="true" |
| 105 |
data-empty-label="<?php echo htmlentities(TXT_UAM_GROUP_ASSIGNMENT_TIME); ?>" |
| 106 |
aria-controls="<?php echo $formPrefix; ?>-date-form"><?php echo $dateText; ?></button> |
| 107 |
<div class="uam_group_date_form uam_flyout_panel" id="<?php echo $formPrefix; ?>-date-form"> |
| 108 |
<div> |
| 109 |
<label class="uam_date_label" for="<?php echo $formPrefix; ?>-fromDate"> |
| 110 |
<?php echo TXT_UAM_GROUP_FROM_DATE; ?> |
| 111 |
</label> |
| 112 |
<input type="datetime-local" |
| 113 |
id="<?php echo $formPrefix; ?>-fromDate" |
| 114 |
name="<?php echo "{$groupsFormName}[{$userGroup->getId()}][fromDate]"; ?>" |
| 115 |
value="<?php echo $dateUtil->formatDateForDatetimeInput($fromDate); ?>"/> |
| 116 |
</div> |
| 117 |
<div> |
| 118 |
<label class="uam_date_label" for="<?php echo $formPrefix; ?>-toDate"> |
| 119 |
<?php echo TXT_UAM_GROUP_TO_DATE; ?> |
| 120 |
</label> |
| 121 |
<input type="datetime-local" |
| 122 |
id="<?php echo $formPrefix; ?>-toDate" |
| 123 |
name="<?php echo "{$groupsFormName}[{$userGroup->getId()}][toDate]"; ?>" |
| 124 |
value="<?php echo $dateUtil->formatDateForDatetimeInput($toDate); ?>"/> |
| 125 |
</div> |
| 126 |
<p class="uam_group_date_actions"> |
| 127 |
<button type="button" class="uam_clear_dates button-link button-link-delete"> |
| 128 |
<?php echo TXT_UAM_GROUP_REMOVE_ASSIGNMENT_TIME; ?> |
| 129 |
</button> |
| 130 |
</p> |
| 131 |
</div> |
| 132 |
</span> |
| 133 |
<?php |
| 134 |
} |
| 135 |
?> |
| 136 |
</li> |
| 137 |
<?php |
| 138 |
} |
| 139 |
?> |
| 140 |
</ul> |
| 141 |
<?php |
| 142 |
if ($controller->getObjectInformation()->getObjectType() !== |
| 143 |
ObjectHandler::GENERAL_USER_OBJECT_TYPE |
| 144 |
&& $controller->checkUserAccess() === true |
| 145 |
) { |
| 146 |
?> |
| 147 |
<div class="uam_dynamic_groups"> |
| 148 |
<label for="uam_dynamic_groups"><?php echo TXT_UAM_ADD_DYNAMIC_GROUP; ?></label> |
| 149 |
<input id="uam_dynamic_groups" |
| 150 |
type="text" |
| 151 |
autocomplete="off" |
| 152 |
value="" |
| 153 |
placeholder="<?php echo htmlentities(TXT_UAM_ADD_DYNAMIC_GROUP_PLACEHOLDER); ?>" |
| 154 |
aria-describedby="uam_dynamic_groups_description" |
| 155 |
data-date-label="<?php echo htmlentities(TXT_UAM_GROUP_ASSIGNMENT_TIME); ?>" |
| 156 |
data-from-label="<?php echo htmlentities(TXT_UAM_GROUP_FROM_DATE); ?>" |
| 157 |
data-to-label="<?php echo htmlentities(TXT_UAM_GROUP_TO_DATE); ?>" |
| 158 |
data-clear-label="<?php echo htmlentities(TXT_UAM_GROUP_REMOVE_ASSIGNMENT_TIME); ?>"> |
| 159 |
<p class="description" id="uam_dynamic_groups_description"> |
| 160 |
<?php echo TXT_UAM_ADD_DYNAMIC_GROUP_DESCRIPTION; ?> |
| 161 |
</p> |
| 162 |
</div> |
| 163 |
<?php |
| 164 |
} |