diff --git a/app/Controller/ProjectTagController.php b/app/Controller/ProjectTagController.php index 815363293..397ac0aaf 100644 --- a/app/Controller/ProjectTagController.php +++ b/app/Controller/ProjectTagController.php @@ -121,4 +121,30 @@ class ProjectTagController extends BaseController $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); } + + public function confirmMakeGlobalTag() + { + $project = $this->getProject(); + $tag = $this->getProjectTag($project); + + $this->response->html($this->template->render('project_tag/make_global', array( + 'tag' => $tag, + 'project' => $project, + ))); + } + + public function makeGlobalTag(){ + if ($this->userSession->isAdmin()) { + $project = $this->getProject(); + $tag = $this->getProjectTag($project); + + if ($this->tagModel->update($tag['id'], $tag['name'], $tag['color_id'], 0)) { + $this->flash->success(t('Tag updated successfully.')); + } else { + $this->flash->failure(t('Unable to update this tag.')); + } + + $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); + } + } } diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index b8e5e1f80..8f442d259 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -1411,4 +1411,6 @@ return array( 'Task limits apply to each swimlane individually' => 'Aufgabenlimit gilt pro Swimlane', 'Task limits are applied to each swimlane individually' => 'Aufgabenlimit gilt pro Swimlane', 'Task limits are applied across swimlanes' => 'Aufgabenlimit gilt Swimlane übergreifend', + 'Change to global tag' => 'Zu globalem Schlagwort machen', + 'Do you really want to make the tag "%s" global?' => 'Das Schlagwort "%s" wirklich global machen?', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index f1da30b34..81b61fb82 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -1411,4 +1411,6 @@ return array( 'Task limits apply to each swimlane individually' => 'Les limites de tâches s\'appliquent à chaque swimlane individuellement', 'Task limits are applied to each swimlane individually' => 'Les limites de tâches sont appliquées à chaque swimlane individuellement', 'Task limits are applied across swimlanes' => 'Les limites de tâches sont appliquées entre les swimlanes', + // 'Change to global tag' => '', + // 'Do you really want to make the tag "%s" global?' => '', ); diff --git a/app/Model/TagModel.php b/app/Model/TagModel.php index 94aaf9744..c2abd2c13 100644 --- a/app/Model/TagModel.php +++ b/app/Model/TagModel.php @@ -160,12 +160,20 @@ class TagModel extends Base * @param string $tag * @return bool */ - public function update($tag_id, $tag, $color_id = null) + public function update($tag_id, $tag, $color_id = null, $project_id = null) { - return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array( - 'name' => $tag, - 'color_id' => $color_id, - )); + if($project_id !== null){ + return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array( + 'name' => $tag, + 'color_id' => $color_id, + 'project_id' => $project_id + )); + } else { + return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array( + 'name' => $tag, + 'color_id' => $color_id + )); + } } /** diff --git a/app/Template/project_tag/index.php b/app/Template/project_tag/index.php index 1322bf233..b1825b74d 100644 --- a/app/Template/project_tag/index.php +++ b/app/Template/project_tag/index.php @@ -24,6 +24,11 @@
  • modal->medium('edit', t('Edit'), 'ProjectTagController', 'edit', array('tag_id' => $tag['id'], 'project_id' => $project['id'])) ?>
  • + user->isAdmin()): ?> +
  • + modal->confirm('globe', t('Change to global tag'), 'ProjectTagController', 'confirmMakeGlobalTag', array('tag_id' => $tag['id'], 'project_id' => $project['id'])) ?> +
  • +
  • modal->confirm('trash-o', t('Remove'), 'ProjectTagController', 'confirm', array('tag_id' => $tag['id'], 'project_id' => $project['id'])) ?>
  • diff --git a/app/Template/project_tag/make_global.php b/app/Template/project_tag/make_global.php new file mode 100644 index 000000000..13a40c50d --- /dev/null +++ b/app/Template/project_tag/make_global.php @@ -0,0 +1,15 @@ + + +
    +

    + +

    + + modal->confirmButtons( + 'ProjectTagController', + 'makeGlobalTag', + array('tag_id' => $tag['id'], 'project_id' => $project['id']) + ) ?> +