'groupID' => $this->group->groupID,
'group' => $this->group,
'action' => 'edit',
- 'availableUserGroups' => UserGroup::getAccessibleGroups(),
+ 'availableUserGroups' => UserGroup::getSortedAccessibleGroups(),
'groupIsEveryone' => $this->group->groupType == UserGroup::EVERYONE,
'groupIsGuest' => $this->group->groupType == UserGroup::GUESTS,
'groupIsUsers' => $this->group->groupType == UserGroup::USERS,
/**
* Returns a list of all available user groups.
*
- * @return array
+ * @return UserGroup[]
*/
protected function getAvailableGroups() {
- $userGroups = UserGroup::getAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
-
- // work-around for PHP 5.3.3 randomly failing in uasort()
- foreach ($userGroups as $userGroup) {
- $userGroup->getName();
- }
-
- uasort($userGroups, function(UserGroup $groupA, UserGroup $groupB) {
- return strcasecmp($groupA->getName(), $groupB->getName());
- });
-
- return $userGroups;
+ return UserGroup::getSortedAccessibleGroups([], [UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
}
/**
// manually inject user group data for listing of group members
if ($this->groupID && $objectType->objectType == 'com.woltlab.wcf.userGroup') {
+ $userGroups = UserGroup::getSortedAccessibleGroups([], [UserGroup::EVERYONE, UserGroup::GUESTS]);
/** @var UserGroupCondition $processor */
-
- $userGroups = UserGroup::getAccessibleGroups([], [UserGroup::EVERYONE, UserGroup::GUESTS]);
-
- uasort($userGroups, function(UserGroup $groupA, UserGroup $groupB) {
- return strcmp($groupA->getName(), $groupB->getName());
- });
-
$processor->setUserGroups($userGroups);
$processor->setData(new Condition(null, [
'conditionData' => serialize(['groupIDs' => [$this->groupID]])
return $groups;
}
+ /**
+ * Returns a sorted list of accessible groups.
+ *
+ * @param integer[] $groupTypes
+ * @param integer[] $invalidGroupTypes
+ * @return UserGroup[]
+ * @since 5.2
+ */
+ public static function getSortedAccessibleGroups(array $groupTypes = [], array $invalidGroupTypes = []) {
+ $userGroups = self::getAccessibleGroups($groupTypes, $invalidGroupTypes);
+
+ uasort($userGroups, function(UserGroup $groupA, UserGroup $groupB) {
+ return strcasecmp($groupA->getName(), $groupB->getName());
+ });
+
+ return $userGroups;
+ }
+
/**
* Returns true if the current group is an admin-group.
* Every group that may access EVERY group is an admin-group.