summaryrefslogtreecommitdiff
path: root/app/Controller/TaskHelper.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-05 20:31:27 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-05 20:31:27 -0500
commite9fedf3e5cd63aea4da7a71f6647ee427c62fa49 (patch)
treeabc2de5aebace4a2d7c94805552264dab6b10bc7 /app/Controller/TaskHelper.php
parent346b8312e5ac877ce3192c2db3a26b500018bbb5 (diff)
Rewrite of the authentication and authorization system
Diffstat (limited to 'app/Controller/TaskHelper.php')
-rw-r--r--app/Controller/TaskHelper.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/app/Controller/TaskHelper.php b/app/Controller/TaskHelper.php
new file mode 100644
index 00000000..236af33e
--- /dev/null
+++ b/app/Controller/TaskHelper.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Task Ajax Helper
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class TaskHelper extends Base
+{
+ /**
+ * Render Markdown text and reply with the HTML Code
+ *
+ * @access public
+ */
+ public function preview()
+ {
+ $payload = $this->request->getJson();
+
+ if (empty($payload['text'])) {
+ $this->response->html('<p>'.t('Nothing to preview...').'</p>');
+ }
+
+ $this->response->html($this->helper->text->markdown($payload['text']));
+ }
+
+ /**
+ * Task autocompletion (Ajax)
+ *
+ * @access public
+ */
+ public function autocomplete()
+ {
+ $search = $this->request->getStringParam('term');
+ $projects = $this->projectPermission->getActiveProjectIds($this->userSession->getId());
+
+ if (empty($projects)) {
+ $this->response->json(array());
+ }
+
+ $filter = $this->taskFilterAutoCompleteFormatter
+ ->create()
+ ->filterByProjects($projects)
+ ->excludeTasks(array($this->request->getIntegerParam('exclude_task_id')));
+
+ // Search by task id or by title
+ if (ctype_digit($search)) {
+ $filter->filterById($search);
+ } else {
+ $filter->filterByTitle($search);
+ }
+
+ $this->response->json($filter->format());
+ }
+}