summaryrefslogtreecommitdiff
path: root/app/Controller/UserAjaxController.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controller/UserAjaxController.php')
-rw-r--r--app/Controller/UserAjaxController.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/Controller/UserAjaxController.php b/app/Controller/UserAjaxController.php
new file mode 100644
index 00000000..ed180471
--- /dev/null
+++ b/app/Controller/UserAjaxController.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Kanboard\Controller;
+
+use Kanboard\Filter\UserNameFilter;
+use Kanboard\Formatter\UserAutoCompleteFormatter;
+use Kanboard\Model\UserModel;
+
+/**
+ * User Ajax Controller
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class UserAjaxController extends BaseController
+{
+ /**
+ * User auto-completion (Ajax)
+ *
+ * @access public
+ */
+ public function autocomplete()
+ {
+ $search = $this->request->getStringParam('term');
+ $filter = $this->userQuery->withFilter(new UserNameFilter($search));
+ $filter->getQuery()->asc(UserModel::TABLE.'.name')->asc(UserModel::TABLE.'.username');
+ $this->response->json($filter->format(new UserAutoCompleteFormatter($this->container)));
+ }
+
+ /**
+ * User mention auto-completion (Ajax)
+ *
+ * @access public
+ */
+ public function mention()
+ {
+ $project_id = $this->request->getStringParam('project_id');
+ $query = $this->request->getStringParam('q');
+ $users = $this->projectPermissionModel->findUsernames($project_id, $query);
+ $this->response->json($users);
+ }
+
+ /**
+ * Check if the user is connected
+ *
+ * @access public
+ */
+ public function status()
+ {
+ $this->response->text('OK');
+ }
+}