diff options
Diffstat (limited to 'app')
27 files changed, 216 insertions, 15 deletions
diff --git a/app/Controller/Config.php b/app/Controller/Config.php index 57f586ae..bb6e860a 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); + $values += array('integration_slack_webhook' => 0, 'integration_hipchat' => 0); } if ($this->config->save($values)) { diff --git a/app/Core/HttpClient.php b/app/Core/HttpClient.php index 96860152..e1d90858 100644 --- a/app/Core/HttpClient.php +++ b/app/Core/HttpClient.php @@ -47,8 +47,9 @@ class HttpClient } $headers = array( - 'Connection: close', 'User-Agent: '.self::HTTP_USER_AGENT, + 'Content-Type: application/json', + 'Connection: close', ); $context = stream_context_create(array( diff --git a/app/Integration/Hipchat.php b/app/Integration/Hipchat.php new file mode 100644 index 00000000..036925f7 --- /dev/null +++ b/app/Integration/Hipchat.php @@ -0,0 +1,53 @@ +<?php + +namespace Integration; + +/** + * Hipchat Webhook + * + * @package integration + * @author Frederic Guillot + */ +class Hipchat extends Base +{ + /** + * Send message to the Hipchat room + * + * @access public + * @param integer $project_id Project id + * @param integer $task_id Task id + * @param string $event_name Event name + * @param array $data Event data + */ + public function notify($project_id, $task_id, $event_name, array $event) + { + $project = $this->project->getbyId($project_id); + + $event['event_name'] = $event_name; + $event['author'] = $this->user->getFullname($this->session['user']); + + $html = '<img src="http://kanboard.net/assets/img/favicon-32x32.png"/>'; + $html .= '<strong>'.$project['name'].'</strong><br/>'; + $html .= $this->projectActivity->getTitle($event); + + if ($this->config->get('application_url')) { + $html .= '<br/><a href="'.$this->config->get('application_url'); + $html .= $this->helper->u('task', 'show', array('task_id' => $task_id, 'project_id' => $project_id)).'">'; + $html .= t('view the task on Kanboard').'</a>'; + } + + $payload = array( + 'message' => $html, + 'color' => 'yellow', + ); + + $url = sprintf( + '%s/v2/room/%s/notification?auth_token=%s', + $this->config->get('integration_hipchat_api_url'), + $this->config->get('integration_hipchat_room_id'), + $this->config->get('integration_hipchat_room_token') + ); + + $this->httpClient->post($url, $payload); + } +} diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index 9af5dcb8..a13aa3af 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index dda991c7..1ec93d44 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index a857493f..33c062c6 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index ae238224..856914ad 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index e2425892..d389b0e1 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -825,8 +825,13 @@ return array( 'Reference currency' => 'Devise de référence', 'The currency rate have been added successfully.' => 'Le taux de change a été ajouté avec succès.', 'Unable to add this currency rate.' => 'Impossible d\'ajouter ce taux de change', - 'Send notifications to a Slack channel' => 'Envoyer des notifications sur un channel Slack', + 'Send notifications to a Slack channel' => 'Envoyer les notifications sur un salon de discussion Slack', 'Webhook URL' => 'URL du webhook', 'Help on Slack integration' => 'Aide sur l\'intégration avec Slack', '%s remove the assignee of the task %s' => '%s a enlevé la personne assignée à la tâche %s', + 'Send notifications to Hipchat' => 'Envoyer les notifications vers Hipchat', + 'API URL' => 'URL de l\'api', + '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', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 70ab8898..29792417 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 5924ed0c..e8d4c4d1 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index f7d225af..52d5413d 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index 0efbc7f3..b53f9c83 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 97c185c3..42a3dff7 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index bca27142..b18f2143 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 8b84fc1f..b77960d3 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index a04a31af..0514faa4 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index b5e6a629..dede7364 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index f45b24cb..86a4f79c 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index d46e71a4..eb971798 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index b6be113d..70175e5f 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -827,4 +827,9 @@ return array( // 'Webhook URL' => '', // 'Help on Slack integration' => '', // '%s remove the assignee of the task %s' => '', + // 'Send notifications to Hipchat' => '', + // 'API URL' => '', + // 'Room API ID or name' => '', + // 'Room notification token' => '', + // 'Help on Hipchat integration' => '', ); diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index dc0b8b42..f0e0d6b2 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -6,7 +6,16 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 58; +const VERSION = 59; + +function version_59($pdo) +{ + $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)'); + $rq->execute(array('integration_hipchat', '0')); + $rq->execute(array('integration_hipchat_api_url', 'https://api.hipchat.com')); + $rq->execute(array('integration_hipchat_room_id', '')); + $rq->execute(array('integration_hipchat_room_token', '')); +} function version_58($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index ea7b84d1..f7a0453d 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -6,7 +6,16 @@ use PDO; use Core\Security; use Model\Link; -const VERSION = 39; +const VERSION = 40; + +function version_40($pdo) +{ + $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)'); + $rq->execute(array('integration_hipchat', '0')); + $rq->execute(array('integration_hipchat_api_url', 'https://api.hipchat.com')); + $rq->execute(array('integration_hipchat_room_id', '')); + $rq->execute(array('integration_hipchat_room_token', '')); +} function version_39($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 1ffd9405..3ad045e6 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -6,7 +6,16 @@ use Core\Security; use PDO; use Model\Link; -const VERSION = 57; +const VERSION = 58; + +function version_58($pdo) +{ + $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)'); + $rq->execute(array('integration_hipchat', '0')); + $rq->execute(array('integration_hipchat_api_url', 'https://api.hipchat.com')); + $rq->execute(array('integration_hipchat_room_id', '')); + $rq->execute(array('integration_hipchat_room_token', '')); +} function version_57($pdo) { diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php index 5f6298aa..6a12ea5a 100644 --- a/app/ServiceProvider/ClassProvider.php +++ b/app/ServiceProvider/ClassProvider.php @@ -75,6 +75,7 @@ class ClassProvider implements ServiceProviderInterface 'GitlabWebhook', 'GithubWebhook', 'BitbucketWebhook', + 'Hipchat', 'SlackWebhook', ) ); diff --git a/app/Subscriber/ProjectActivitySubscriber.php b/app/Subscriber/ProjectActivitySubscriber.php index d2e85166..42314637 100644 --- a/app/Subscriber/ProjectActivitySubscriber.php +++ b/app/Subscriber/ProjectActivitySubscriber.php @@ -42,14 +42,32 @@ class ProjectActivitySubscriber extends Base implements EventSubscriberInterface $values ); - if ($this->config->get('integration_slack_webhook') == 1) { - $this->slackWebhook->notify( - $values['task']['project_id'], - $values['task']['id'], - $event_name, - $values - ); - } + $this->sendSlackNotification($event_name, $values); + $this->sendHipchatNotification($event_name, $values); + } + } + + private function sendSlackNotification($event_name, array $values) + { + if ($this->config->get('integration_slack_webhook') == 1) { + $this->slackWebhook->notify( + $values['task']['project_id'], + $values['task']['id'], + $event_name, + $values + ); + } + } + + private function sendHipchatNotification($event_name, array $values) + { + if ($this->config->get('integration_hipchat') == 1) { + $this->hipchat->notify( + $values['task']['project_id'], + $values['task']['id'], + $event_name, + $values + ); } } diff --git a/app/Template/config/integrations.php b/app/Template/config/integrations.php index 104ebc16..6f90e0ab 100644 --- a/app/Template/config/integrations.php +++ b/app/Template/config/integrations.php @@ -6,6 +6,22 @@ <?= $this->formCsrf() ?> + <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) ?> + + <?= $this->formLabel(t('API URL'), 'integration_hipchat_api_url') ?> + <?= $this->formText('integration_hipchat_api_url', $values, $errors) ?> + + <?= $this->formLabel(t('Room API ID or name'), 'integration_hipchat_room_id') ?> + <?= $this->formText('integration_hipchat_room_id', $values, $errors) ?> + + <?= $this->formLabel(t('Room notification token'), 'integration_hipchat_room_token') ?> + <?= $this->formText('integration_hipchat_room_token', $values, $errors) ?> + + <p class="form-help"><a href="http://kanboard.net/documentation/hipchat" target="_blank"><?= t('Help on Hipchat integration') ?></a></p> + </div> + <h3><i class="fa fa-slack fa-fw"></i> <?= t('Slack') ?></h3> <div class="listing"> <?= $this->formCheckbox('integration_slack_webhook', t('Send notifications to a Slack channel'), 1, $values['integration_slack_webhook'] == 1) ?> diff --git a/app/Template/project/integrations.php b/app/Template/project/integrations.php index 194bd672..4f6553ad 100644 --- a/app/Template/project/integrations.php +++ b/app/Template/project/integrations.php @@ -8,7 +8,7 @@ <p class="form-help"><a href="http://kanboard.net/documentation/github-webhooks" target="_blank"><?= t('Help on Github webhooks') ?></a></p> </div> -<h3><i class="fa fa-git fa-fw"></i> <?= t('Gitlab webhooks') ?></h3> +<h3><img src="assets/img/gitlab-icon.png"/> <?= t('Gitlab webhooks') ?></h3> <div class="listing"> <input type="text" class="auto-select" readonly="readonly" value="<?= $this->getCurrentBaseUrl().$this->u('webhook', 'gitlab', array('token' => $webhook_token, 'project_id' => $project['id'])) ?>"/><br/> <p class="form-help"><a href="http://kanboard.net/documentation/gitlab-webhooks" target="_blank"><?= t('Help on Gitlab webhooks') ?></a></p> |