Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 44 lines (37 sloc) 1.33 KB
* Change the manager of a group.
* @since 8/28/09
* @package
* @copyright Copyright &copy; 2009, Middlebury College
* @license GNU General Public License (GPL)
if (!isset($_POST['group_id']) || !$_POST['group_id'])
throw new InvalidArgumentException("No group_id passed");
$groupId = base64_decode_fix($_POST['group_id'], true);
if (!$groupId)
throw new InvalidArgumentException("Invalid group_id passed");
$userId = base64_decode_fix($_POST['new_manager'], true);
if (!$userId)
throw new InvalidArgumentException("Invalid user_id passed");
// Verify that the current user really can manage the group.
$groups = $ldap->read('(objectclass=group)', $groupId, array('managedby', 'member'));
if (count($groups) != 1)
throw new Exception("Could not find the group specified");
$group = $groups[0];
if (!canModifyGroup($group))
throw new PermissionDeniedException("You are not authorized to manage this group.");
// Delete the group
if (!empty($group['managedby'][0])) {
$ldap->delAttribute($groupId, 'managedby', $group['managedby'][0]);
$ldap->addAttribute($groupId, 'managedby', $userId);
// Print out its HTML for insertion into the document
header('Content-Type: text/html');
$group['managedby'][0] = $userId;
printGroupHtml($ldap, $group);