diff options
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Action.php | 8 | ||||
-rw-r--r-- | app/Controller/Base.php | 1 | ||||
-rw-r--r-- | app/Controller/Task.php | 65 | ||||
-rw-r--r-- | app/Controller/User.php | 64 |
4 files changed, 114 insertions, 24 deletions
diff --git a/app/Controller/Action.php b/app/Controller/Action.php index 11dc3b29..797bbfa2 100644 --- a/app/Controller/Action.php +++ b/app/Controller/Action.php @@ -33,10 +33,10 @@ class Action extends Base 'available_events' => $this->action->getAvailableEvents(), 'available_params' => $this->action->getAllActionParameters(), 'columns_list' => $this->board->getColumnsList($project['id']), - 'users_list' => $this->project->getUsersList($project['id'], false), + 'users_list' => $this->project->getUsersList($project['id']), 'projects_list' => $this->project->getList(false), 'colors_list' => $this->task->getColors(), - 'categories_list' => $this->category->getList($project['id'], false), + 'categories_list' => $this->category->getList($project['id']), 'menu' => 'projects', 'title' => t('Automatic actions') ))); @@ -64,10 +64,10 @@ class Action extends Base 'values' => $values, 'action_params' => $action->getActionRequiredParameters(), 'columns_list' => $this->board->getColumnsList($project['id']), - 'users_list' => $this->project->getUsersList($project['id'], false), + 'users_list' => $this->project->getUsersList($project['id']), 'projects_list' => $this->project->getList(false), 'colors_list' => $this->task->getColors(), - 'categories_list' => $this->category->getList($project['id'], false), + 'categories_list' => $this->category->getList($project['id']), 'project' => $project, 'menu' => 'projects', 'title' => t('Automatic actions') diff --git a/app/Controller/Base.php b/app/Controller/Base.php index 13fb9b91..25a72f15 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -20,6 +20,7 @@ use Model\LastLogin; * @property \Model\Config $config * @property \Model\File $file * @property \Model\Google $google + * @property \Model\GitHub $gitHub * @property \Model\LastLogin $lastLogin * @property \Model\Ldap $ldap * @property \Model\Project $project diff --git a/app/Controller/Task.php b/app/Controller/Task.php index d44ba268..15482afc 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -162,17 +162,24 @@ class Task extends Base $task['score'] = $task['score'] ?: ''; - $this->response->html($this->template->layout('task_edit', array( - 'values' => $task, - 'errors' => array(), - 'task' => $task, - 'columns_list' => $this->board->getColumnsList($task['project_id']), - 'users_list' => $this->project->getUsersList($task['project_id']), - 'colors_list' => $this->task->getColors(), - 'categories_list' => $this->category->getList($task['project_id']), - 'menu' => 'tasks', - 'title' => t('Edit a task') - ))); + $params = array( + 'values' => $task, + 'errors' => array(), + 'task' => $task, + 'columns_list' => $this->board->getColumnsList($task['project_id']), + 'users_list' => $this->project->getUsersList($task['project_id']), + 'colors_list' => $this->task->getColors(), + 'categories_list' => $this->category->getList($task['project_id']), + 'ajax' => $this->request->isAjax(), + 'menu' => 'tasks', + 'title' => t('Edit a task') + ); + if ($this->request->isAjax()) { + $this->response->html($this->template->load('task_edit', $params)); + } + else { + $this->response->html($this->template->layout('task_edit', $params)); + } } /** @@ -191,7 +198,13 @@ class Task extends Base if ($this->task->update($values)) { $this->session->flash(t('Task updated successfully.')); - $this->response->redirect('?controller=task&action=show&task_id='.$values['id']); + + if ($this->request->getIntegerParam('ajax')) { + $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']); + } + else { + $this->response->redirect('?controller=task&action=show&task_id='.$values['id']); + } } else { $this->session->flashError(t('Unable to update your task.')); @@ -357,13 +370,20 @@ class Task extends Base { $task = $this->getTask(); - $this->response->html($this->taskLayout('task_edit_description', array( - 'values' => $task, - 'errors' => array(), - 'task' => $task, - 'menu' => 'tasks', - 'title' => t('Edit the description') - ))); + $params = array( + 'values' => $task, + 'errors' => array(), + 'task' => $task, + 'ajax' => $this->request->isAjax(), + 'menu' => 'tasks', + 'title' => t('Edit the description') + ); + if ($this->request->isAjax()) { + $this->response->html($this->template->load('task_edit_description', $params)); + } + else { + $this->response->html($this->taskLayout('task_edit_description', $params)); + } } /** @@ -387,7 +407,12 @@ class Task extends Base $this->session->flashError(t('Unable to update your task.')); } - $this->response->redirect('?controller=task&action=show&task_id='.$task['id']); + if ($this->request->getIntegerParam('ajax')) { + $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']); + } + else { + $this->response->redirect('?controller=task&action=show&task_id='.$task['id']); + } } $this->response->html($this->taskLayout('task_edit_description', array( diff --git a/app/Controller/User.php b/app/Controller/User.php index fca33b28..d30c6fd2 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -299,4 +299,68 @@ class User extends Base $this->response->redirect('?controller=user'); } + + /** + * GitHub authentication + * + * @access public + */ + public function gitHub() + { + $code = $this->request->getStringParam('code'); + + if ($code) { + $profile = $this->gitHub->getGitHubProfile($code); + + if (is_array($profile)) { + + // If the user is already logged, link the account otherwise authenticate + if ($this->acl->isLogged()) { + + if ($this->gitHub->updateUser($this->acl->getUserId(), $profile)) { + $this->session->flash(t('Your GitHub account was successfully linked to your profile.')); + } + else { + $this->session->flashError(t('Unable to link your GitHub Account.')); + } + + $this->response->redirect('?controller=user'); + } + else if ($this->gitHub->authenticate($profile['id'])) { + $this->response->redirect('?controller=app'); + } + else { + $this->response->html($this->template->layout('user_login', array( + 'errors' => array('login' => t('GitHub authentication failed')), + 'values' => array(), + 'no_layout' => true, + 'title' => t('Login') + ))); + } + } + } + + $this->response->redirect($this->gitHub->getAuthorizationUrl()); + } + + /** + * Unlink a GitHub account + * + * @access public + */ + public function unlinkGitHub() + { + $this->checkCSRFParam(); + + $this->gitHub->revokeGitHubAccess(); + + if ($this->gitHub->unlink($this->acl->getUserId())) { + $this->session->flash(t('Your GitHub account is no longer linked to your profile.')); + } + else { + $this->session->flashError(t('Unable to unlink your GitHub Account.')); + } + + $this->response->redirect('?controller=user'); + } } |