/** * Removes this user from the group. * * @param string|int Group ID or group name * @return bool * @throws SentryUserException */ public function remove_from_group($id) { if (!$this->in_group($id)) { throw new \SentryUserException(__('sentry.user_not_in_group', array('group' => $id))); } $field = 'name'; if (is_numeric($id)) { $field = 'id'; } try { $group = new \Sentry_Group($id); } catch (SentryGroupNotFoundException $e) { throw new \SentryUserException($e->getMessage()); } $delete = DB::delete($this->table_usergroups)->where('user_id', $this->user['id'])->where('group_id', $group->get('id'))->execute($this->db_instance); // remove from array $field = 'name'; if (is_numeric($id)) { $field = 'id'; } foreach ($this->groups as $key => $group) { if ($group[$field] == $id) { unset($group); } } return (bool) $delete; }