protected function action_delete() { if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) { $u = new User(); $u->retrieve($_REQUEST['record']); $u->status = 'Inactive'; $u->employee_status = 'Terminated'; $u->save(); $u->mark_deleted($u->id); Log::info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}"); SugarApplication::redirect("index.php?module=Employees&action=index"); } else { sugar_die("Unauthorized access to administration."); } }
protected function action_delete() { if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) { $u = new User(); $u->retrieve($_REQUEST['record']); $u->status = 'Inactive'; $u->employee_status = 'Terminated'; $u->save(); $u->mark_deleted($u->id); $GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}"); $eapm = loadBean('EAPM'); $eapm->delete_user_accounts($_REQUEST['record']); $GLOBALS['log']->info("Removing user's External Accounts"); SugarApplication::redirect("index.php?module=Users&action=index"); } else { sugar_die("Unauthorized access to administration."); } }
public function testsaveAndOthers() { error_reporting(E_ERROR | E_PARSE); //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $user = new User(); $user->user_name = "test"; $user->first_name = "firstn"; $user->last_name = "lastn"; $user->email1 = "*****@*****.**"; $user->email2 = "*****@*****.**"; $result = $user->save(); //test for record ID to verify that record is saved $this->assertTrue(isset($user->id)); $this->assertEquals(36, strlen($user->id)); //test retrieve method $this->retrieve($user->id); //test retrieve_by_email_address method $this->retrieve_by_email_address($user->id); //test newPassword And findUserPassword methods $this->NewPasswordAndFindUserPassword($user->id); //test authenticate_user method $this->authenticate_user($user->id); //test load_user method $this->load_user($user->id); //test change_password method $this->change_password($user->id); //test getPreferredEmail method $this->getPreferredEmail($user->id); //test getUsersNameAndEmail method $this->getUsersNameAndEmail($user->id); //test getEmailInfo method $this->getEmailInfo($user->id); //change username and delete the user to avoid picking it up by password in future $user->user_name = "test_deleted"; $user->save(); $user->mark_deleted($user->id); }
/** * This method is called after the last test of this test class is run. * * Removes shared test resources */ public static function tearDownAfterClass() { self::$user->mark_deleted(self::$user_id); }