From 01f9ee3410bb4f6878033b353f5a0731397632d0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 30 Mar 2015 21:27:49 -0400 Subject: Add Gravatar integration --- app/Controller/Config.php | 2 +- app/Core/Helper.php | 17 +++++++++++++++++ app/Locale/fr_FR/translations.php | 1 + app/Model/Comment.php | 3 ++- app/Model/ProjectActivity.php | 7 ++++--- app/Schema/Mysql.php | 8 +++++++- app/Schema/Postgres.php | 6 ++++++ app/Schema/Sqlite.php | 8 +++++++- app/Template/comment/show.php | 4 +++- app/Template/config/integrations.php | 5 +++++ app/Template/event/comment_create.php | 2 ++ app/Template/event/comment_update.php | 2 ++ app/Template/event/subtask_create.php | 2 ++ app/Template/event/subtask_update.php | 2 ++ app/Template/event/task_assignee_change.php | 2 ++ app/Template/event/task_close.php | 2 ++ app/Template/event/task_create.php | 2 ++ app/Template/event/task_move_column.php | 2 ++ app/Template/event/task_move_position.php | 2 ++ app/Template/event/task_open.php | 2 ++ app/Template/event/task_update.php | 2 ++ assets/css/app.css | 6 +++++- assets/css/src/base.css | 5 +++++ 23 files changed, 85 insertions(+), 9 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 ''.$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 @@

+ + avatar($comment['email'], $comment['name'] ?: $comment['username']) ?> + e($comment['name'] ?: $comment['username']) ?> @

-
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 @@ formCsrf() ?> +

+
+ formCheckbox('integration_gravatar', t('Enable Gravatar images'), 1, $values['integration_gravatar'] == 1) ?> +
+

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

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 @@ +avatar($email, $author) ?> +

e($author), diff --git a/assets/css/app.css b/assets/css/app.css index 79d61c6b..e3797b1d 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -62,7 +62,11 @@ hr { .chosen-select { min-height: 27px; /* Reserve some space to avoid re-layout due to chosen */ } -/* links */ + +.avatar { + float: left; + margin-right: 10px; +}/* links */ a { color: #3366CC; border: none; diff --git a/assets/css/src/base.css b/assets/css/src/base.css index d92df612..10a3ee8e 100644 --- a/assets/css/src/base.css +++ b/assets/css/src/base.css @@ -46,3 +46,8 @@ hr { .chosen-select { min-height: 27px; /* Reserve some space to avoid re-layout due to chosen */ } + +.avatar { + float: left; + margin-right: 10px; +} \ No newline at end of file -- cgit v1.2.3