summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-03-30 21:27:49 -0400
committerFrederic Guillot <fred@kanboard.net>2015-03-30 21:27:49 -0400
commit01f9ee3410bb4f6878033b353f5a0731397632d0 (patch)
treeabf46f22cca9ac8d6aa410336ff5d5682708c6e0 /app
parentb17f4b28ca948d223f12ceab96e38c018f32c6fd (diff)
Add Gravatar integration
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Config.php2
-rw-r--r--app/Core/Helper.php17
-rw-r--r--app/Locale/fr_FR/translations.php1
-rw-r--r--app/Model/Comment.php3
-rw-r--r--app/Model/ProjectActivity.php7
-rw-r--r--app/Schema/Mysql.php8
-rw-r--r--app/Schema/Postgres.php6
-rw-r--r--app/Schema/Sqlite.php8
-rw-r--r--app/Template/comment/show.php4
-rw-r--r--app/Template/config/integrations.php5
-rw-r--r--app/Template/event/comment_create.php2
-rw-r--r--app/Template/event/comment_update.php2
-rw-r--r--app/Template/event/subtask_create.php2
-rw-r--r--app/Template/event/subtask_update.php2
-rw-r--r--app/Template/event/task_assignee_change.php2
-rw-r--r--app/Template/event/task_close.php2
-rw-r--r--app/Template/event/task_create.php2
-rw-r--r--app/Template/event/task_move_column.php2
-rw-r--r--app/Template/event/task_move_position.php2
-rw-r--r--app/Template/event/task_open.php2
-rw-r--r--app/Template/event/task_update.php2
21 files changed, 75 insertions, 8 deletions
diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index bb6e860a..3c884191 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -44,7 +44,7 @@ class Config extends Base
$values += array('subtask_restriction' => 0, 'subtask_time_tracking' => 0, 'subtask_forecast' => 0);
}
else if ($redirect === 'integrations') {
- $values += array('integration_slack_webhook' => 0, 'integration_hipchat' => 0);
+ $values += array('integration_slack_webhook' => 0, 'integration_hipchat' => 0, 'integration_gravatar' => 0);
}
if ($this->config->save($values)) {
diff --git a/app/Core/Helper.php b/app/Core/Helper.php
index 013bf0f2..29003416 100644
--- a/app/Core/Helper.php
+++ b/app/Core/Helper.php
@@ -770,4 +770,21 @@ class Helper
return 'fa-file-o';
}
+
+ /**
+ * Display gravatar image
+ *
+ * @access public
+ * @param string $email
+ * @param string $alt
+ * @return string
+ */
+ public function avatar($email, $alt = '')
+ {
+ if (! empty($email) && $this->config->get('integration_gravatar') == 1) {
+ return '<img class="avatar" src="https://www.gravatar.com/avatar/'.md5(strtolower($email)).'?s=25" alt="'.$this->e($alt).'" title="'.$this->e($alt).'">';
+ }
+
+ return '';
+ }
}
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index d389b0e1..ac21f387 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -834,4 +834,5 @@ return array(
'Room API ID or name' => 'Nom ou identifiant du salon de discussion',
'Room notification token' => 'Jeton de sécurité du salon de discussion',
'Help on Hipchat integration' => 'Aide sur l\'intégration avec Hipchat',
+ 'Enable Gravatar images' => 'Activer les images Gravatar',
);
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index a36f2b45..844f0c89 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -47,7 +47,8 @@ class Comment extends Base
self::TABLE.'.user_id',
self::TABLE.'.comment',
User::TABLE.'.username',
- User::TABLE.'.name'
+ User::TABLE.'.name',
+ User::TABLE.'.email'
)
->join(User::TABLE, 'id', 'user_id')
->orderBy(self::TABLE.'.date', 'ASC')
diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php
index c5fbbd38..ae593da8 100644
--- a/app/Model/ProjectActivity.php
+++ b/app/Model/ProjectActivity.php
@@ -85,18 +85,19 @@ class ProjectActivity extends Base
->columns(
self::TABLE.'.*',
User::TABLE.'.username AS author_username',
- User::TABLE.'.name AS author_name'
+ User::TABLE.'.name AS author_name',
+ User::TABLE.'.email'
)
->in('project_id', $project_ids)
->join(User::TABLE, 'id', 'creator_id')
->desc(self::TABLE.'.id')
->limit($limit);
- if(!is_null($start)){
+ if (!is_null($start)){
$query->gte('date_creation', $start);
}
- if(!is_null($end)){
+ if (!is_null($end)){
$query->lte('date_creation', $end);
}
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index f0e0d6b2..4ea7b041 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -6,7 +6,13 @@ use PDO;
use Core\Security;
use Model\Link;
-const VERSION = 59;
+const VERSION = 60;
+
+function version_60($pdo)
+{
+ $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
+ $rq->execute(array('integration_gravatar', '0'));
+}
function version_59($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index f7a0453d..93d8e869 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -8,6 +8,12 @@ use Model\Link;
const VERSION = 40;
+function version_41($pdo)
+{
+ $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
+ $rq->execute(array('integration_gravatar', '0'));
+}
+
function version_40($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 3ad045e6..3683acb6 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -6,7 +6,13 @@ use Core\Security;
use PDO;
use Model\Link;
-const VERSION = 58;
+const VERSION = 59;
+
+function version_59($pdo)
+{
+ $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
+ $rq->execute(array('integration_gravatar', '0'));
+}
function version_58($pdo)
{
diff --git a/app/Template/comment/show.php b/app/Template/comment/show.php
index 23389c06..98c29441 100644
--- a/app/Template/comment/show.php
+++ b/app/Template/comment/show.php
@@ -1,9 +1,11 @@
<div class="comment <?= isset($preview) ? 'comment-preview' : '' ?>" id="comment-<?= $comment['id'] ?>">
<p class="comment-title">
+ <?php if (! empty($comment['email'])): ?>
+ <?= $this->avatar($comment['email'], $comment['name'] ?: $comment['username']) ?>
+ <?php endif ?>
<span class="comment-username"><?= $this->e($comment['name'] ?: $comment['username']) ?></span> @ <span class="comment-date"><?= dt('%B %e, %Y at %k:%M %p', $comment['date']) ?></span>
</p>
-
<div class="comment-inner">
<?php if (! isset($preview)): ?>
diff --git a/app/Template/config/integrations.php b/app/Template/config/integrations.php
index 6f90e0ab..e11b62f8 100644
--- a/app/Template/config/integrations.php
+++ b/app/Template/config/integrations.php
@@ -6,6 +6,11 @@
<?= $this->formCsrf() ?>
+ <h3><?= t('Gravatar') ?></h3>
+ <div class="listing">
+ <?= $this->formCheckbox('integration_gravatar', t('Enable Gravatar images'), 1, $values['integration_gravatar'] == 1) ?>
+ </div>
+
<h3><img src="assets/img/hipchat-icon.png"/> <?= t('Hipchat') ?></h3>
<div class="listing">
<?= $this->formCheckbox('integration_hipchat', t('Send notifications to Hipchat'), 1, $values['integration_hipchat'] == 1) ?>
diff --git a/app/Template/event/comment_create.php b/app/Template/event/comment_create.php
index fd046fd1..79238aba 100644
--- a/app/Template/event/comment_create.php
+++ b/app/Template/event/comment_create.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s commented the task %s',
$this->e($author),
diff --git a/app/Template/event/comment_update.php b/app/Template/event/comment_update.php
index 7149bacf..5d22a2ce 100644
--- a/app/Template/event/comment_update.php
+++ b/app/Template/event/comment_update.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s updated a comment on the task %s',
$this->e($author),
diff --git a/app/Template/event/subtask_create.php b/app/Template/event/subtask_create.php
index 1cc7585c..4f33069a 100644
--- a/app/Template/event/subtask_create.php
+++ b/app/Template/event/subtask_create.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s created a subtask for the task %s',
$this->e($author),
diff --git a/app/Template/event/subtask_update.php b/app/Template/event/subtask_update.php
index be06f7f5..19fe2e56 100644
--- a/app/Template/event/subtask_update.php
+++ b/app/Template/event/subtask_update.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s updated a subtask for the task %s',
$this->e($author),
diff --git a/app/Template/event/task_assignee_change.php b/app/Template/event/task_assignee_change.php
index 22ed936b..38e2bca7 100644
--- a/app/Template/event/task_assignee_change.php
+++ b/app/Template/event/task_assignee_change.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?php $assignee = $task['assignee_name'] ?: $task['assignee_username'] ?>
diff --git a/app/Template/event/task_close.php b/app/Template/event/task_close.php
index b5ad4d1d..afedbef3 100644
--- a/app/Template/event/task_close.php
+++ b/app/Template/event/task_close.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s closed the task %s',
$this->e($author),
diff --git a/app/Template/event/task_create.php b/app/Template/event/task_create.php
index de9a7e0d..4b920234 100644
--- a/app/Template/event/task_create.php
+++ b/app/Template/event/task_create.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s created the task %s',
$this->e($author),
diff --git a/app/Template/event/task_move_column.php b/app/Template/event/task_move_column.php
index e56e92d7..e97a3ab7 100644
--- a/app/Template/event/task_move_column.php
+++ b/app/Template/event/task_move_column.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s moved the task %s to the column "%s"',
$this->e($author),
diff --git a/app/Template/event/task_move_position.php b/app/Template/event/task_move_position.php
index 412a9401..2ed4ffe8 100644
--- a/app/Template/event/task_move_position.php
+++ b/app/Template/event/task_move_position.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s moved the task %s to the position #%d in the column "%s"',
$this->e($author),
diff --git a/app/Template/event/task_open.php b/app/Template/event/task_open.php
index 353f8dac..9a408449 100644
--- a/app/Template/event/task_open.php
+++ b/app/Template/event/task_open.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s opened the task %s',
$this->e($author),
diff --git a/app/Template/event/task_update.php b/app/Template/event/task_update.php
index 24b17446..0f81870b 100644
--- a/app/Template/event/task_update.php
+++ b/app/Template/event/task_update.php
@@ -1,3 +1,5 @@
+<?= $this->avatar($email, $author) ?>
+
<p class="activity-title">
<?= e('%s updated the task %s',
$this->e($author),