/** * Delete handler for users. * Route * /user/:sid/delete */ public function user_delete_by_id($uid) { verify_csrf_get(); if (!has_permission('delete any account')) { show_403(); } $user = $this->user_model->get($uid); if (!$user) { show_404(); } // The user is not actually delete. // It stays in the database with it's status set to deleted (99) $user->status = User_entity::STATUS_DELETED; if ($this->user_model->save($user)) { Status_msg::success('User successfully deleted.'); } else { Status_msg::error('An error occurred while deleting the user.'); } redirect('/users'); }
/** * Change the status of the surveys * @param $sid * Survey sid * @param $status * The survey new status. * * Route - /survey/:sid/change_status/:status */ public function survey_change_status($sid, $status) { verify_csrf_get(); $survey = $this->survey_model->get($sid); if (!$survey) { show_404(); } else { if (!has_permission('change status any survey')) { show_403(); } } if (!$survey->is_allowed_status_change($status)) { show_error('Invalid status.'); } $survey->status = (int) $status; // Save. if ($this->survey_model->save($survey)) { Status_msg::success('Status successfully changed.'); } else { Status_msg::error('An error occurred when saving the survey. Please try again.'); } redirect($survey->get_url_view()); }