/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { // Check if we get the person $this->_person = new midcom_db_person($args[0]); $this->_person->require_do('midgard:update'); if ($this->_person->id != midcom_connection::get_user()) { midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface'); } $this->_account = new midcom_core_account($this->_person); if (!$this->_account->get_username()) { // Account needs to be created first, relocate return new midcom_response_relocate("view/" . $this->_person->guid . "/"); } $data['controller'] = midcom_helper_datamanager2_handler::get_delete_controller(); switch ($data['controller']->process_form()) { case 'delete': if (!$this->_account->delete()) { throw new midcom_error("Failed to delete account for {$this->_person->guid}, last Midgard error was: " . midcom_connection::get_error_string()); } //Fall-through //Fall-through case 'cancel': return new midcom_response_relocate('view/' . $this->_person->guid . "/"); } $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/legacy.css"); midcom::get('head')->enable_jquery(); midcom::get('head')->set_pagetitle("{$this->_person->firstname} {$this->_person->lastname}"); $this->_prepare_request_data(); $this->_update_breadcrumb_line('delete account'); // Add toolbar items org_openpsa_helpers::dm2_savecancel($this, 'delete'); }
/** * Function to delete account * * @return boolean indicates success */ public function delete_account() { $this->_account = midcom_core_account::get($this->_person); return $this->_account->delete(); }