/** * Delete user * * @param integer $id */ public function deleteAction($id) { $user = User::find($id); // Make sure the user exists if (!$user) { return $this->show404(); } // Delete user if ($user->delete()) { Request::redirectTo('/admin/users'); } }
public function indexAction() { // Check if the form has been submitted if (Request::method() == 'post') { foreach (Request::$post['settings'] as $setting => $value) { // Get setting $setting = Setting::find('setting', $setting); // If found, set value and save if ($setting) { $setting->value = $value; $setting->save(); } } // Redirect Request::redirectTo('/admin/settings'); } }
/** * Password page. */ public function passwordAction() { // Check if form has been submitted if (Request::method() == 'post') { // Verify current password if ($this->user->verifyPassword(Request::$post['current_password'])) { // Update users password $this->user->updatePassword(Request::$post['new_password']); // Save and redirect if ($this->user->save()) { Request::redirectTo('/account/password'); } } else { $this->user->addError('password', l('errors.current_password_is_invalid')); } } }
/** * Delete status. * * @param integer $id */ public function deleteAction($id) { $status = Status::find($id); // Make sure the status exists if (!$status) { return $this->show404(); } // Delete user if ($status->delete()) { Request::redirectTo('/admin/statuses'); } }
/** * Update ticket. * * @param integer $id */ public function updateAction($id) { if (Request::method() != 'post') { Request::redirectTo('/'); } // Get the ticket $ticket = Ticket::find($id); // Ticket changes $changes = []; foreach (['department', 'status', 'priority'] as $property) { if ($ticket->{$property . '_id'} != Request::$post[$property]) { $change = ['property' => $property]; switch ($property) { case 'department': case 'status': $class = "\\Ticketer\\Models\\" . Inflector::classify($property); $change['from'] = $class::find($ticket->{"{$property}_id"})->name; $change['to'] = $class::find(Request::$post[$property])->name; break; case 'priority': $change['from'] = getPriorityName($ticket->priority_id); $change['to'] = getPriorityName(Request::$post['priority']); break; } $changes[] = $change; } } // Update ticket properties $ticket->set(['department_id' => Request::$post['department'], 'status_id' => Request::$post['status'], 'priority_id' => Request::$post['priority']]); // Ticket reply $reply = new TicketReply(['message' => Request::$post['message'], 'user_id' => $this->currentUser->id, 'ticket_id' => $ticket->id, 'changes' => json_encode($changes)]); if (count($changes) or Request::$post['message'] != '') { if ($reply->save() and $ticket->save()) { Request::redirectTo($ticket->href()); } } else { Request::redirectTo($ticket->href()); } $this->set(compact('ticket', 'reply')); $this->render['view'] = 'tickets/view'; }
/** * Logout page. */ public function logoutAction() { setcookie('ticketer', NULL, time(), '/'); Request::redirectTo('/'); }
/** * Redirects to the specified path. */ public function redirectTo($path) { Request::redirectTo($path); }
/** * Delete department * * @param integer $id */ public function deleteAction($id) { $department = Department::find($id); // Make sure the department exists if (!$department) { return $this->show404(); } // Delete user if ($department->delete()) { Request::redirectTo('/admin/departments'); } }