function do_editgroups() { $user_id = KTUtil::arrayGet($_REQUEST, 'user_id'); $oUser = User::get($user_id); $old_search = KTUtil::arrayGet($_REQUEST, 'old_search'); if (PEAR::isError($oUser) || $oUser === false) { $this->errorRedirectToMain(_kt('No such user.'), sprintf("old_search=%s&do_search=1", $old_search)); } $this->aBreadcrumbs[] = array('name' => $oUser->getName()); $this->oPage->setBreadcrumbDetails(_kt('edit groups')); $this->oPage->setTitle(sprintf(_kt("Edit %s's groups"), $oUser->getName())); // generate a list of groups this user is authorised to assign. /* FIXME there is a nasty side-effect: if a user cannot assign a group * to a user, and that user _had_ that group pre-edit, * then their privileges are revoked. * is there _any_ way to fix that? */ $aInitialGroups = GroupUtil::listGroupsForUser($oUser); $aAllGroups = GroupUtil::listGroups(); $aUserGroups = array(); $aFreeGroups = array(); foreach ($aInitialGroups as $oGroup) { $aUserGroups[$oGroup->getId()] = $oGroup; } foreach ($aAllGroups as $oGroup) { if (!array_key_exists($oGroup->getId(), $aUserGroups)) { $aFreeGroups[$oGroup->getId()] = $oGroup; } } $oJSONWidget = new KTJSONLookupWidget(_kt('Groups'), _kt('Select the groups which this user should belong to from the left-hand list and then click the <strong>right pointing arrows</strong>. Once you have added all the groups that you require, press <strong>save changes</strong>.'), 'groups', '', $this->oPage, false, null, null, array('action' => 'getGroups', 'assigned' => $aUserGroups, 'multi' => 'true', 'size' => '8')); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/principals/usergroups"); $aTemplateData = array("context" => $this, "unused_groups" => $aFreeGroups, "user_groups" => $aUserGroups, "edit_user" => $oUser, "widget" => $oJSONWidget, 'old_search' => $old_search); return $oTemplate->render($aTemplateData); }
<?php require_once "../../../config/dmsDefaults.php"; require_once KT_LIB_DIR . '/groups/GroupUtil.php'; foreach (GroupUtil::listGroups() as $oGroup) { print $oGroup->getName() . "\n"; }