Esempio n. 1
0
 /**
  * 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');
     }
 }
Esempio n. 2
0
 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');
     }
 }
Esempio n. 3
0
 /**
  * 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'));
         }
     }
 }
Esempio n. 4
0
 /**
  * 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');
     }
 }
Esempio n. 5
0
 /**
  * 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';
 }
Esempio n. 6
0
 /**
  * Logout page.
  */
 public function logoutAction()
 {
     setcookie('ticketer', NULL, time(), '/');
     Request::redirectTo('/');
 }
Esempio n. 7
0
 /**
  * Redirects to the specified path.
  */
 public function redirectTo($path)
 {
     Request::redirectTo($path);
 }
Esempio n. 8
0
 /**
  * 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');
     }
 }