Skip to content

Commit

Permalink
Update to benedmunds#248, delete_group() function created
Browse files Browse the repository at this point in the history
  • Loading branch information
adityamenon-exp committed Oct 22, 2012
1 parent 0449148 commit bcf6c82
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
6 changes: 4 additions & 2 deletions language/english/ion_auth_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
// Account Changes
$lang['update_successful'] = 'Account Information Successfully Updated';
$lang['update_unsuccessful'] = 'Unable to Update Account Information';
$lang['delete_successful'] = 'User Deleted';
$lang['delete_unsuccessful'] = 'Unable to Delete User';
$lang['delete_successful'] = 'User Deleted';
$lang['delete_unsuccessful'] = 'Unable to Delete User';

// Groups
$lang['group_creation_successful'] = 'Group created Successfully';
$lang['group_already_exists'] = 'Group name already taken';
$lang['group_update_successful'] = 'Group details updated';
$lang['group_delete_successful'] = 'Group deleted';
$lang['group_delete_unsuccessful'] = 'Unable to delete group';

// Email Subjects
$lang['email_forgotten_password_subject'] = 'Forgotten Password Verification';
Expand Down
38 changes: 38 additions & 0 deletions models/ion_auth_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,44 @@ public function update_group($group_id = FALSE, $group_name = FALSE, $group_desc
return TRUE;
}

/**
* delete_group
*
* @return bool
* @author aditya menon
**/
public function delete_group($group_id = FALSE)
{
// bail if mandatory param not set
if(!$group_id || empty($group_id))
{
return FALSE;
}

$this->trigger_events('pre_delete_group');

$this->db->trans_begin();

// remove all users from this group
$this->db->delete($this->tables['users_groups'], array('group_id' => $group_id));
// remove the group itself
$this->db->delete($this->tables['groups'], array('id' => $group_id));

if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
$this->trigger_events(array('post_delete_group', 'post_delete_group_unsuccessful'));
$this->set_error('group_delete_unsuccessful');
return FALSE;
}

$this->db->trans_commit();

$this->trigger_events(array('post_delete_group', 'post_delete_group_successful'));
$this->set_message('group_delete_successful');
return TRUE;
}

public function set_hook($event, $name, $class, $method, $arguments)
{
$this->_ion_hooks->{$event}[$name] = new stdClass;
Expand Down

0 comments on commit bcf6c82

Please sign in to comment.