/** * @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'); }
public function test_handler_lostpassword() { $data = $this->run_handler('org.openpsa.user', array('lostpassword')); $this->assertEquals('lostpassword', $data['handler_id']); $user = self::create_user(); $account = new midcom_core_account($user); $old_password = $account->get_password(); $formdata = array('username' => $account->get_username()); $this->set_dm2_formdata($data['controller'], $formdata); $data = $this->run_handler('org.openpsa.user', array('lostpassword')); $this->assertEquals(array(), $data['controller']->formmanager->form->_errors); $user->refresh(); $account = new midcom_core_account($user); $this->assertEquals('lostpassword', $data['handler_id']); $this->assertNotEquals($old_password, $account->get_password()); }
/** * Prepares group member data for JSON display */ public function get_row(midcom_core_dbaobject $user) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $entry['id'] = $user->id; $lastname = trim($user->lastname); if (empty($lastname)) { $lastname = $this->_l10n->get('person') . ' #' . $user->id; } $entry['lastname'] = "<a href='" . $prefix . 'person/' . $user->guid . "/'>" . $lastname . "</a>"; $entry['index_lastname'] = $lastname; $entry['firstname'] = "<a href='" . $prefix . 'person/' . $user->guid . "/' >" . $user->firstname . "</a>"; $entry['index_firstname'] = $user->firstname; $account = new midcom_core_account($user); $entry['username'] = "******" . $prefix . 'person/' . $user->guid . "/' >" . $account->get_username() . "</a>"; $entry['index_username'] = $account->get_username(); $entry['email'] = "<a href='mailto:" . $user->email . "' >" . $user->email . "</a>"; $entry['index_email'] = $user->email; return $entry; }
/** * Prepares user data for JSON display */ public function get_row(midcom_core_dbaobject $user) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $entry['id'] = $user->id; $lastname = trim($user->lastname); if (empty($lastname)) { $lastname = $this->_l10n->get('person') . ' #' . $user->id; } $entry['lastname'] = "<a href='" . $prefix . 'view/' . $user->guid . "/'>" . $lastname . "</a>"; $entry['index_lastname'] = $user->lastname; $entry['firstname'] = "<a href='" . $prefix . 'view/' . $user->guid . "/' >" . $user->firstname . "</a>"; $entry['index_firstname'] = $user->firstname; $account = new midcom_core_account($user); $entry['username'] = $account->get_username(); $entry['groups'] = array(); //get groups $mc_member = org_openpsa_contacts_member_dba::new_collector('uid', $user->id); $mc_member->add_constraint('gid.orgOpenpsaObtype', '<', org_openpsa_contacts_group_dba::MYCONTACTS); $mc_member->add_order('gid.official'); $mc_member->add_order('gid.name'); $gids = $mc_member->get_values('gid'); foreach ($gids as $gid) { try { $group = org_openpsa_contacts_group_dba::get_cached($gid); $entry['groups'][] = '<a href="' . $prefix . 'group/' . $group->guid . '/">' . $group->get_label() . '</a>'; } catch (midcom_error $e) { $e->log(); } } $entry['groups'] = implode(', ', $entry['groups']); return $entry; }