public function delete($thread_id = false) { if ($thread_id === false) { $this->error = "No thread ID was received."; return false; } $this->db->where('id', $thread_id)->delete('comments_threads'); return parent::delete($thread_id); }
/** * Delete a particular permission from the database. * * @param integer $id Permission ID to delete. * * @return boolean True if the permission was deleted successfully, else false. */ public function delete($id = 0) { // Delete the record. $deleted = parent::delete($id); if ($deleted !== true) { return false; } // If the delete succeeded, delete the role_permissions for this $id. $this->role_permission_model->delete_for_permission($id); return true; }
function delete($id = 0, $purge = false) { if ($purge === true) { // temporarily set the soft_deletes to true. $this->soft_deletes = false; } // delete the ercord $deleted = parent::delete($id); // if the delete was successful then delete the role_permissions for this permission_id if (TRUE === $deleted) { // now delete the role_permissions for this permission $this->role_permission_model->delete_for_permission($id); } return $deleted; }
function delete($id = 0, $purge = false) { if ($purge === true) { // temporarily set the soft_deletes to true. $this->soft_deletes = false; } // We might not be allowed to delete this role. if ($this->can_delete_role($id) == false) { $this->error = 'This role can not be deleted.'; return false; } // delete the ercord $deleted = parent::delete($id); if (TRUE === $deleted) { // now delete the role_permissions for this permission $this->role_permission_model->delete_for_role($id); } return $deleted; }
/** * Deletes a role. By default, it will perform a soft_delete and * leave the permissions untouched. However, if $purge == TRUE, then * all permissions related to this role are also deleted. * * @access public * * @param int $id An integer with the role_id to delete. * @param bool $purge If FALSE, will perform a soft_delete. If TRUE, will remove the role and related permissions from db. * * @return bool TRUE/FALSE */ function delete($id = 0, $purge = FALSE) { if ($purge === TRUE) { // temporarily set the soft_deletes to TRUE. $this->soft_deletes = FALSE; } // We might not be allowed to delete this role. if ($this->can_delete_role($id) == FALSE) { $this->error = 'This role can not be deleted.'; return FALSE; } // get the name for management deletion later $role = $this->role_model->find($id); // delete the record $deleted = parent::delete($id); if ($deleted === TRUE) { // Now update the users to the default role if (!class_exists('User_model')) { $this->load->model('users/User_model', 'user_model'); } $this->user_model->set_to_default_role($id); // now delete the role_permissions for this permission $this->role_permission_model->delete_for_role($id); // now delete the manage permission for this role $prefix = $this->db->dbprefix; if (!class_exists('Permission_model')) { $this->load->model('permissions/permission_model'); } $perm = $this->permission_model->find_by('name', 'Permissions.' . ucwords($role->role_name) . '.Manage'); if ($perm) { // remove the role_permissions for this permission $this->db->query("DELETE FROM {$prefix}role_permissions WHERE permission_id='" . $perm->permission_id . "';"); if ($deleted === TRUE && $purge === TRUE) { $this->db->query("DELETE FROM {$prefix}permissions WHERE (name = 'Permissions." . ucwords($role->role_name) . ".Manage')"); } else { $this->db->query("UPDATE {$prefix}permissions SET status = 'inactive' WHERE (name = 'Permissions." . ucwords($role->role_name) . ".Manage')"); } } } //end if return $deleted; }
public function delete($id = 0, $purge = false) { if ($purge === true) { // temporarily set the soft_deletes to true. $this->soft_deletes = false; } return parent::delete($id); }
/** * Perform a standard delete, but also allow a record to be purged. * * @param integer $id The ID of the user to delete. * @param boolean $purge If true, the account will be purged from the system. * If false, performs a standard delete (with soft-deletes enabled). * * @return boolean True on success, else false. */ public function delete($id = 0, $purge = false) { // Temporarily store the current setting for soft-deletes. $tempSoftDeletes = $this->soft_deletes; if ($purge === true) { // Temporarily set the soft_deletes to false to purge the account. $this->soft_deletes = false; } // Reset soft-deletes after deleting the account. $result = parent::delete($id); $this->soft_deletes = $tempSoftDeletes; return $result; }
/** * Delete a particular permission from the database * * @access public * * @param int $id Permission ID to delete * * @return bool TRUE if the permission was deleted successfully, else FALSE */ function delete($id = 0) { // delete the ercord $deleted = parent::delete($id); // if the delete was successful then delete the role_permissions for this permission_id if (TRUE === $deleted) { $this->role_permission_model->delete_for_permission($id); } return $deleted; }
/** * Deletes a role. By default, it will perform a soft_delete and * leave the permissions untouched. However, if $purge == TRUE, then * all permissions related to this role are also deleted. * * @access public * * @param int $id An integer with the role_id to delete. * @param bool $purge If FALSE, will perform a soft_delete. If TRUE, will remove the role and related permissions from db. * * @return bool TRUE/FALSE */ function delete($id = 0, $purge = FALSE) { // We might not be allowed to delete this role. if ($this->can_delete_role($id) == FALSE) { $this->error = 'This role can not be deleted.'; return FALSE; } if ($this->default_role_id() == $id) { $this->error = 'The default role can not be deleted.'; return FALSE; } if ($purge === TRUE) { // temporarily set the soft_deletes to TRUE. $this->soft_deletes = FALSE; } // get the name for management deletion later $role = $this->role_model->find($id); // delete the record $deleted = parent::delete($id); if ($deleted === TRUE) { // Now update the users to the default role if (!class_exists('User_model')) { $this->load->model('users/User_model', 'user_model'); } $this->user_model->set_to_default_role($id); // now delete the role_permissions for this role $this->role_permission_model->delete_for_role($id); // now delete the manage permission for this role $permission_name = 'Permissions.' . ucwords($role->role_name) . '.Manage'; if (!class_exists('Permission_model')) { $this->load->model('permissions/permission_model'); } $perm = $this->permission_model->find_by('name', $permission_name); if ($perm) { // remove the role_permissions for this permission $this->db->delete('role_permissions', array('permission_id' => $perm->permission_id)); if ($purge === TRUE) { $this->db->delete('permissions', array('name' => $permission_name)); } else { $this->db->update('permissions', array('status' => 'inactive'), array('name' => $permission_name)); } } } //end if return $deleted; }
/** * Performs a standard delete, but also allows for purging of a record. * * @access public * * @param int $id An INT with the record ID to delete. * @param bool $purge If FALSE, will perform a soft-delete. If TRUE, will permanently delete the record. * * @return bool TRUE/FALSE */ public function delete($id = 0, $purge = FALSE) { if ($purge === TRUE) { // temporarily set the soft_deletes to TRUE. $this->soft_deletes = FALSE; } return parent::delete($id); }
/** * Deletes a role. * * By default, it will perform a soft_delete and leave the permissions * untouched. However, if $purge == true, then all permissions related to * this role are also deleted. * * @param int $id An integer with the role_id to delete. * @param bool $purge If false, will perform a soft_delete. If true, will * remove the role and related permissions from db. * * @return bool true on successful delete, else false */ function delete($id = 0, $purge = false) { // Can this role be deleted? if ($this->can_delete_role($id) == false) { $this->error = 'This role can not be deleted.'; return false; } if ($this->default_role_id() == $id) { $this->error = 'The default role can not be deleted.'; return false; } if ($purge === true) { // Temporarily disable soft deletes. $tempSoftDeletes = $this->soft_deletes; $this->soft_deletes = false; } // Get the name for permission deletion later $role = $this->role_model->find($id); // Delete the record $deleted = parent::delete($id); if ($deleted === true) { // Update the users to the default role if (!class_exists('user_model')) { $this->load->model('users/user_model'); } $this->user_model->set_to_default_role($id); // Delete the role_permissions for this role if (!class_exists('role_permission_model')) { $this->load->model('roles/role_permission_model'); } $this->role_permission_model->delete_for_role($id); // Delete the manage permission for this role $permission_name = 'Permissions.' . ucwords($role->role_name) . '.Manage'; if (!class_exists('permission_model')) { $this->load->model('permissions/permission_model'); } $perm = $this->permission_model->find_by('name', $permission_name); if ($perm) { // The permission_model's update/delete will remove the // role_permissions for this permission if ($purge === true) { $this->permission_model->delete_by_name($permission_name); } else { $this->permission_model->update(array('name' => $permission_name), array('status' => 'inactive')); } } } // Restore soft_deletes if ($purge === true) { $this->soft_deletes = $tempSoftDeletes; } return $deleted; }
function delete($id = 0, $purge = false) { if ($purge === true) { // temporarily set the soft_deletes to true. $this->soft_deletes = false; } // We might not be allowed to delete this role. if ($this->can_delete_role($id) == false) { $this->error = 'This role can not be deleted.'; return false; } // get the name for management deletion later $role = $this->role_model->find($id); // delete the record $deleted = parent::delete($id); if ($deleted === TRUE && $purge === TRUE) { // now delete the role_permissions for this permission $this->role_permission_model->delete_for_role($id); // now delete the manage permission for this role $prefix = $this->db->dbprefix; if (!class_exists('Permission_model')) { $this->load->model('permissions/permission_model'); } $perm = $this->permission_model->find_by('name', 'Permissions.' . ucwords($role->role_name) . '.Manage'); if ($perm) { $this->db->query("DELETE FROM {$prefix}permissions WHERE (name = 'Permissions." . ucwords($role->role_name) . ".Manage')"); $this->db->query("DELETE FROM {$prefix}role_permissions WHERE permission_id='" . $perm->permission_id . "';"); } } return $deleted; }
/** * Delete a particular permission from the database * * @param int $id Permission ID to delete * * @return bool true if the permission was deleted successfully, else false */ function delete($id = 0) { // Delete the record $deleted = parent::delete($id); // If the delete succeeded, delete the role_permissions for this $id if ($deleted === true) { $this->role_permission_model->delete_for_permission($id); } return $deleted; }