Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deleting groups with no users
  • Loading branch information
Tom Rawcliffe committed Mar 28, 2012
1 parent cbcce88 commit 3a4fd18
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion application/Controller/Group.inc.php
Expand Up @@ -105,6 +105,7 @@ protected function processForm(Form_Group $form, Model_Group $group)
$group->deleteMembers();

$matches = preg_split('/[\n\r]+/', $form->getElementValue('members'));
$userCount = 0;

foreach ($matches as $username)
{
Expand All @@ -122,12 +123,17 @@ protected function processForm(Form_Group $form, Model_Group $group)
$groupUser->setGroupId($group->getId());
$groupUser->setUserId($user->getId());
$groupUser->save();

$userCount++;
}
}


$group->deleteTimeslots();

if (!$userCount) {
$group->delete();
}

if (is_array($form->getElementValue('timeslots')))
{
foreach ($form->getElementValue('timeslots') as $time)
Expand Down

0 comments on commit 3a4fd18

Please sign in to comment.