diff options
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Ical.php | 59 | ||||
-rw-r--r-- | app/Controller/User.php | 29 |
2 files changed, 82 insertions, 6 deletions
diff --git a/app/Controller/Ical.php b/app/Controller/Ical.php index 55cc64a6..52e10fa1 100644 --- a/app/Controller/Ical.php +++ b/app/Controller/Ical.php @@ -2,7 +2,9 @@ namespace Controller; +use Model\TaskFilter; use Model\Task as TaskModel; +use Eluceo\iCal\Component\Calendar as iCalendar; /** * iCalendar controller @@ -13,6 +15,35 @@ use Model\Task as TaskModel; class Ical extends Base { /** + * Get user iCalendar + * + * @access public + */ + public function user() + { + $token = $this->request->getStringParam('token'); + $user = $this->user->getByToken($token); + + // Token verification + if (empty($user)) { + $this->forbidden(true); + } + + // Common filter + $filter = $this->taskFilter + ->create() + ->filterByOwner($user['id']); + + // Calendar properties + $calendar = new iCalendar('Kanboard'); + $calendar->setName($user['name'] ?: $user['username']); + $calendar->setDescription($user['name'] ?: $user['username']); + $calendar->setPublishedTTL('PT1H'); + + $this->renderCalendar($filter, $calendar); + } + + /** * Get project iCalendar * * @access public @@ -27,24 +58,40 @@ class Ical extends Base $this->forbidden(true); } - $start = $this->request->getStringParam('start', strtotime('-1 month')); - $end = $this->request->getStringParam('end', strtotime('+2 months')); - // Common filter $filter = $this->taskFilter ->create() ->filterByProject($project['id']); + // Calendar properties + $calendar = new iCalendar('Kanboard'); + $calendar->setName($project['name']); + $calendar->setDescription($project['name']); + $calendar->setPublishedTTL('PT1H'); + + $this->renderCalendar($filter, $calendar); + } + + /** + * Common method to render iCal events + * + * @access private + */ + private function renderCalendar(TaskFilter $filter, iCalendar $calendar) + { + $start = $this->request->getStringParam('start', strtotime('-1 month')); + $end = $this->request->getStringParam('end', strtotime('+2 months')); + // Tasks if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') { - $calendar = $filter->copy()->filterByCreationDateRange($start, $end)->addDateTimeIcalEvents('date_creation', 'date_completed'); + $filter->copy()->filterByCreationDateRange($start, $end)->addDateTimeIcalEvents('date_creation', 'date_completed', $calendar); } else { - $calendar = $filter->copy()->filterByStartDateRange($start, $end)->addDateTimeIcalEvents('date_started', 'date_completed'); + $filter->copy()->filterByStartDateRange($start, $end)->addDateTimeIcalEvents('date_started', 'date_completed', $calendar); } // Tasks with due date - $calendar = $filter->copy()->filterByDueDateRange($start, $end)->addAllDayIcalEvents('date_due', $calendar); + $filter->copy()->filterByDueDateRange($start, $end)->addAllDayIcalEvents('date_due', $calendar); $this->response->contentType('text/calendar; charset=utf-8'); echo $calendar->render(); diff --git a/app/Controller/User.php b/app/Controller/User.php index 37f10969..c8496418 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -249,6 +249,35 @@ class User extends Base } /** + * Public access management + * + * @access public + */ + public function share() + { + $user = $this->getUser(); + $switch = $this->request->getStringParam('switch'); + + if ($switch === 'enable' || $switch === 'disable') { + + $this->checkCSRFParam(); + + if ($this->user->{$switch.'PublicAccess'}($user['id'])) { + $this->session->flash(t('User updated successfully.')); + } else { + $this->session->flashError(t('Unable to update this user.')); + } + + $this->response->redirect($this->helper->url('user', 'share', array('user_id' => $user['id']))); + } + + $this->response->html($this->layout('user/share', array( + 'user' => $user, + 'title' => t('Public access'), + ))); + } + + /** * Password modification * * @access public |