summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/User.php22
-rw-r--r--app/Core/Markdown.php80
-rw-r--r--app/Helper/Text.php7
-rw-r--r--app/ServiceProvider/RouteProvider.php1
-rw-r--r--app/Template/user/profile.php8
5 files changed, 105 insertions, 13 deletions
diff --git a/app/Controller/User.php b/app/Controller/User.php
index aa548647..0968d5a5 100644
--- a/app/Controller/User.php
+++ b/app/Controller/User.php
@@ -58,6 +58,28 @@ class User extends Base
}
/**
+ * Public user profile
+ *
+ * @access public
+ */
+ public function profile()
+ {
+ $user = $this->user->getById($this->request->getIntegerParam('user_id'));
+
+ if (empty($user)) {
+ $this->notfound();
+ }
+
+ $this->response->html(
+ $this->template->layout('user/profile', array(
+ 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'title' => $user['name'] ?: $user['username'],
+ 'user' => $user,
+ )
+ ));
+ }
+
+ /**
* Display a form to create a new user
*
* @access public
diff --git a/app/Core/Markdown.php b/app/Core/Markdown.php
index f08c486a..827fd0df 100644
--- a/app/Core/Markdown.php
+++ b/app/Core/Markdown.php
@@ -3,7 +3,7 @@
namespace Kanboard\Core;
use Parsedown;
-use Kanboard\Helper\Url;
+use Pimple\Container;
/**
* Specific Markdown rules for Kanboard
@@ -14,22 +14,51 @@ use Kanboard\Helper\Url;
*/
class Markdown extends Parsedown
{
- private $link;
- private $helper;
+ /**
+ * Link params for tasks
+ *
+ * @access private
+ * @var array
+ */
+ private $link = array();
- public function __construct($link, Url $helper)
+ /**
+ * Container
+ *
+ * @access private
+ * @var Container
+ */
+ private $container;
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @param Container $container
+ * @param array $link
+ */
+ public function __construct(Container $container, array $link)
{
$this->link = $link;
- $this->helper = $helper;
+ $this->container = $container;
$this->InlineTypes['#'][] = 'TaskLink';
- $this->inlineMarkerList .= '#';
+ $this->InlineTypes['@'][] = 'UserLink';
+ $this->inlineMarkerList .= '#@';
}
- protected function inlineTaskLink($Excerpt)
+ /**
+ * Handle Task Links
+ *
+ * Replace "#123" by a link to the task
+ *
+ * @access public
+ * @param array $Excerpt
+ * @return array
+ */
+ protected function inlineTaskLink(array $Excerpt)
{
- // Replace task #123 by a link to the task
if (! empty($this->link) && preg_match('!#(\d+)!i', $Excerpt['text'], $matches)) {
- $url = $this->helper->href(
+ $url = $this->container['helper']->url->href(
$this->link['controller'],
$this->link['action'],
$this->link['params'] + array('task_id' => $matches[1])
@@ -40,7 +69,38 @@ class Markdown extends Parsedown
'element' => array(
'name' => 'a',
'text' => $matches[0],
- 'attributes' => array('href' => $url)));
+ 'attributes' => array('href' => $url)
+ ),
+ );
+ }
+ }
+
+ /**
+ * Handle User Mentions
+ *
+ * Replace "@username" by a link to the user
+ *
+ * @access public
+ * @param array $Excerpt
+ * @return array
+ */
+ protected function inlineUserLink(array $Excerpt)
+ {
+ if (preg_match('/^@([^\s]+)/', $Excerpt['text'], $matches)) {
+ $user_id = $this->container['user']->getIdByUsername($matches[1]);
+
+ if (! empty($user_id)) {
+ $url = $this->container['helper']->url->href('user', 'profile', array('user_id' => $user_id));
+
+ return array(
+ 'extent' => strlen($matches[0]),
+ 'element' => array(
+ 'name' => 'a',
+ 'text' => $matches[0],
+ 'attributes' => array('href' => $url, 'class' => 'user-mention-link'),
+ ),
+ );
+ }
}
}
}
diff --git a/app/Helper/Text.php b/app/Helper/Text.php
index d2075fe4..59bfd997 100644
--- a/app/Helper/Text.php
+++ b/app/Helper/Text.php
@@ -3,14 +3,15 @@
namespace Kanboard\Helper;
use Kanboard\Core\Markdown;
+use Kanboard\Core\Base;
/**
- * Text helpers
+ * Text Helpers
*
* @package helper
* @author Frederic Guillot
*/
-class Text extends \Kanboard\Core\Base
+class Text extends Base
{
/**
* Markdown transformation
@@ -21,7 +22,7 @@ class Text extends \Kanboard\Core\Base
*/
public function markdown($text, array $link = array())
{
- $parser = new Markdown($link, $this->helper->url);
+ $parser = new Markdown($this->container, $link);
$parser->setMarkupEscaped(MARKDOWN_ESCAPE_HTML);
return $parser->text($text);
}
diff --git a/app/ServiceProvider/RouteProvider.php b/app/ServiceProvider/RouteProvider.php
index 26ab488a..b7dba8e5 100644
--- a/app/ServiceProvider/RouteProvider.php
+++ b/app/ServiceProvider/RouteProvider.php
@@ -153,6 +153,7 @@ class RouteProvider implements ServiceProviderInterface
// Users
$container['router']->addRoute('users', 'user', 'index');
+ $container['router']->addRoute('user/profile/:user_id', 'user', 'profile', array('user_id'));
$container['router']->addRoute('user/show/:user_id', 'user', 'show', array('user_id'));
$container['router']->addRoute('user/show/:user_id/timesheet', 'user', 'timesheet', array('user_id'));
$container['router']->addRoute('user/show/:user_id/last-logins', 'user', 'last', array('user_id'));
diff --git a/app/Template/user/profile.php b/app/Template/user/profile.php
new file mode 100644
index 00000000..176a1491
--- /dev/null
+++ b/app/Template/user/profile.php
@@ -0,0 +1,8 @@
+<section id="main">
+ <br>
+ <ul class="listing">
+ <li><?= t('Username:') ?> <strong><?= $this->e($user['username']) ?></strong></li>
+ <li><?= t('Name:') ?> <strong><?= $this->e($user['name']) ?: t('None') ?></strong></li>
+ <li><?= t('Email:') ?> <strong><?= $this->e($user['email']) ?: t('None') ?></strong></li>
+ </ul>
+</section> \ No newline at end of file