From e6f547abcfe684658a7498391db72d13b6aa7d9a Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 20 Sep 2015 18:24:15 -0400 Subject: Move timetable to a plugin Plugin repository: https://github.com/kanboard/plugin-timetable --- app/Controller/Timetable.php | 39 -------------- app/Controller/Timetableday.php | 88 ------------------------------- app/Controller/Timetableextra.php | 16 ------ app/Controller/Timetableoff.php | 107 -------------------------------------- app/Controller/Timetableweek.php | 99 ----------------------------------- 5 files changed, 349 deletions(-) delete mode 100644 app/Controller/Timetable.php delete mode 100644 app/Controller/Timetableday.php delete mode 100644 app/Controller/Timetableextra.php delete mode 100644 app/Controller/Timetableoff.php delete mode 100644 app/Controller/Timetableweek.php (limited to 'app/Controller') diff --git a/app/Controller/Timetable.php b/app/Controller/Timetable.php deleted file mode 100644 index 65edb44c..00000000 --- a/app/Controller/Timetable.php +++ /dev/null @@ -1,39 +0,0 @@ -getUser(); - $from = $this->request->getStringParam('from', date('Y-m-d')); - $to = $this->request->getStringParam('to', date('Y-m-d', strtotime('next week'))); - $timetable = $this->timetable->calculate($user['id'], new DateTime($from), new DateTime($to)); - - $this->response->html($this->layout('timetable/index', array( - 'user' => $user, - 'timetable' => $timetable, - 'values' => array( - 'from' => $from, - 'to' => $to, - 'controller' => 'timetable', - 'action' => 'index', - 'user_id' => $user['id'], - ), - ))); - } -} diff --git a/app/Controller/Timetableday.php b/app/Controller/Timetableday.php deleted file mode 100644 index c8f7ac8a..00000000 --- a/app/Controller/Timetableday.php +++ /dev/null @@ -1,88 +0,0 @@ -getUser(); - - $this->response->html($this->layout('timetable_day/index', array( - 'timetable' => $this->timetableDay->getByUser($user['id']), - 'values' => $values + array('user_id' => $user['id']), - 'errors' => $errors, - 'user' => $user, - ))); - } - - /** - * Validate and save - * - * @access public - */ - public function save() - { - $values = $this->request->getValues(); - list($valid, $errors) = $this->timetableDay->validateCreation($values); - - if ($valid) { - - if ($this->timetableDay->create($values['user_id'], $values['start'], $values['end'])) { - $this->session->flash(t('Time slot created successfully.')); - $this->response->redirect($this->helper->url->to('timetableday', 'index', array('user_id' => $values['user_id']))); - } - else { - $this->session->flashError(t('Unable to save this time slot.')); - } - } - - $this->index($values, $errors); - } - - /** - * Confirmation dialag box to remove a row - * - * @access public - */ - public function confirm() - { - $user = $this->getUser(); - - $this->response->html($this->layout('timetable_day/remove', array( - 'slot_id' => $this->request->getIntegerParam('slot_id'), - 'user' => $user, - ))); - } - - /** - * Remove a row - * - * @access public - */ - public function remove() - { - $this->checkCSRFParam(); - $user = $this->getUser(); - - if ($this->timetableDay->remove($this->request->getIntegerParam('slot_id'))) { - $this->session->flash(t('Time slot removed successfully.')); - } - else { - $this->session->flash(t('Unable to remove this time slot.')); - } - - $this->response->redirect($this->helper->url->to('timetableday', 'index', array('user_id' => $user['id']))); - } -} diff --git a/app/Controller/Timetableextra.php b/app/Controller/Timetableextra.php deleted file mode 100644 index 7c6fe265..00000000 --- a/app/Controller/Timetableextra.php +++ /dev/null @@ -1,16 +0,0 @@ -getUser(); - - $paginator = $this->paginator - ->setUrl($this->controller_url, 'index', array('user_id' => $user['id'])) - ->setMax(10) - ->setOrder('date') - ->setDirection('desc') - ->setQuery($this->{$this->model}->getUserQuery($user['id'])) - ->calculate(); - - $this->response->html($this->layout($this->template_dir.'/index', array( - 'values' => $values + array('user_id' => $user['id']), - 'errors' => $errors, - 'paginator' => $paginator, - 'user' => $user, - ))); - } - - /** - * Validate and save - * - * @access public - */ - public function save() - { - $values = $this->request->getValues(); - list($valid, $errors) = $this->{$this->model}->validateCreation($values); - - if ($valid) { - - if ($this->{$this->model}->create( - $values['user_id'], - $values['date'], - isset($values['all_day']) && $values['all_day'] == 1, - $values['start'], - $values['end'], - $values['comment'])) { - - $this->session->flash(t('Time slot created successfully.')); - $this->response->redirect($this->helper->url->to($this->controller_url, 'index', array('user_id' => $values['user_id']))); - } - else { - $this->session->flashError(t('Unable to save this time slot.')); - } - } - - $this->index($values, $errors); - } - - /** - * Confirmation dialag box to remove a row - * - * @access public - */ - public function confirm() - { - $user = $this->getUser(); - - $this->response->html($this->layout($this->template_dir.'/remove', array( - 'slot_id' => $this->request->getIntegerParam('slot_id'), - 'user' => $user, - ))); - } - - /** - * Remove a row - * - * @access public - */ - public function remove() - { - $this->checkCSRFParam(); - $user = $this->getUser(); - - if ($this->{$this->model}->remove($this->request->getIntegerParam('slot_id'))) { - $this->session->flash(t('Time slot removed successfully.')); - } - else { - $this->session->flash(t('Unable to remove this time slot.')); - } - - $this->response->redirect($this->helper->url->to($this->controller_url, 'index', array('user_id' => $user['id']))); - } -} diff --git a/app/Controller/Timetableweek.php b/app/Controller/Timetableweek.php deleted file mode 100644 index b8ce00e7..00000000 --- a/app/Controller/Timetableweek.php +++ /dev/null @@ -1,99 +0,0 @@ -getUser(); - - if (empty($values)) { - - $day = $this->timetableDay->getByUser($user['id']); - - $values = array( - 'user_id' => $user['id'], - 'start' => isset($day[0]['start']) ? $day[0]['start'] : null, - 'end' => isset($day[0]['end']) ? $day[0]['end'] : null, - ); - } - - $this->response->html($this->layout('timetable_week/index', array( - 'timetable' => $this->timetableWeek->getByUser($user['id']), - 'values' => $values, - 'errors' => $errors, - 'user' => $user, - ))); - } - - /** - * Validate and save - * - * @access public - */ - public function save() - { - $values = $this->request->getValues(); - list($valid, $errors) = $this->timetableWeek->validateCreation($values); - - if ($valid) { - - if ($this->timetableWeek->create($values['user_id'], $values['day'], $values['start'], $values['end'])) { - $this->session->flash(t('Time slot created successfully.')); - $this->response->redirect($this->helper->url->to('timetableweek', 'index', array('user_id' => $values['user_id']))); - } - else { - $this->session->flashError(t('Unable to save this time slot.')); - } - } - - $this->index($values, $errors); - } - - /** - * Confirmation dialag box to remove a row - * - * @access public - */ - public function confirm() - { - $user = $this->getUser(); - - $this->response->html($this->layout('timetable_week/remove', array( - 'slot_id' => $this->request->getIntegerParam('slot_id'), - 'user' => $user, - ))); - } - - /** - * Remove a row - * - * @access public - */ - public function remove() - { - $this->checkCSRFParam(); - $user = $this->getUser(); - - if ($this->timetableWeek->remove($this->request->getIntegerParam('slot_id'))) { - $this->session->flash(t('Time slot removed successfully.')); - } - else { - $this->session->flash(t('Unable to remove this time slot.')); - } - - $this->response->redirect($this->helper->url->to('timetableweek', 'index', array('user_id' => $user['id']))); - } -} -- cgit v1.2.3