Skip to content
This repository was archived by the owner on Apr 5, 2020. It is now read-only.

Commit ef41967

Browse files
committed
Update plugin to latest KB changes
1 parent fcbdd16 commit ef41967

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

Notification/Jabber.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Fabiang\Xmpp\Protocol\Message;
99
use Fabiang\Xmpp\Protocol\Presence;
1010
use Kanboard\Core\Base;
11-
use Kanboard\Notification\NotificationInterface;
11+
use Kanboard\Core\Notification\NotificationInterface;
1212

1313
/**
1414
* Jabber Notification
@@ -29,10 +29,10 @@ class Jabber extends Base implements NotificationInterface
2929
public function notifyUser(array $user, $event_name, array $event_data)
3030
{
3131
try {
32-
$jid = $this->userMetadata->get($user['id'], 'jabber_jid');
32+
$jid = $this->userMetadataModel->get($user['id'], 'jabber_jid');
3333

3434
if (! empty($jid)) {
35-
$project = $this->project->getById($event_data['task']['project_id']);
35+
$project = $this->projectModel->getById($event_data['task']['project_id']);
3636
$client = $this->getClient();
3737

3838
$message = new Message;
@@ -59,13 +59,13 @@ public function notifyUser(array $user, $event_name, array $event_data)
5959
public function notifyProject(array $project, $event_name, array $event_data)
6060
{
6161
try {
62-
$room = $this->projectMetadata->get($project['id'], 'jabber_room');
62+
$room = $this->projectMetadataModel->get($project['id'], 'jabber_room');
6363

6464
if (! empty($room)) {
6565
$client = $this->getClient();
6666

6767
$channel = new Presence;
68-
$channel->setTo($room)->setNickName($this->config->get('jabber_nickname'));
68+
$channel->setTo($room)->setNickname($this->configModel->get('jabber_nickname'));
6969
$client->send($channel);
7070

7171
$message = new Message;
@@ -90,10 +90,10 @@ public function notifyProject(array $project, $event_name, array $event_data)
9090
*/
9191
public function getClient()
9292
{
93-
$options = new Options($this->config->get('jabber_server'));
94-
$options->setUsername($this->config->get('jabber_username'));
95-
$options->setPassword($this->config->get('jabber_password'));
96-
$options->setTo($this->config->get('jabber_domain'));
93+
$options = new Options($this->configModel->get('jabber_server'));
94+
$options->setUsername($this->configModel->get('jabber_username'));
95+
$options->setPassword($this->configModel->get('jabber_password'));
96+
$options->setTo($this->configModel->get('jabber_domain'));
9797
$options->setLogger($this->logger);
9898

9999
return new Client($options);
@@ -106,22 +106,23 @@ public function getClient()
106106
* @param array $project
107107
* @param string $event_name
108108
* @param array $event_data
109+
* @return string
109110
*/
110111
public function getMessage(array $project, $event_name, array $event_data)
111112
{
112113
if ($this->userSession->isLogged()) {
113114
$author = $this->helper->user->getFullname();
114-
$title = $this->notification->getTitleWithAuthor($author, $event_name, $event_data);
115+
$title = $this->notificationModel->getTitleWithAuthor($author, $event_name, $event_data);
115116
} else {
116-
$title = $this->notification->getTitleWithoutAuthor($event_name, $event_data);
117+
$title = $this->notificationModel->getTitleWithoutAuthor($event_name, $event_data);
117118
}
118119

119120
$payload = '['.$project['name'].'] ';
120121
$payload .= $title;
121122
$payload .= ' '.$event_data['task']['title'];
122123

123-
if ($this->config->get('application_url') !== '') {
124-
$payload .= ' '.$this->helper->url->to('task', 'show', array('task_id' => $event_data['task']['id'], 'project_id' => $project['id']), '', true);
124+
if ($this->configModel->get('application_url') !== '') {
125+
$payload .= ' '.$this->helper->url->to('TaskViewController', 'show', array('task_id' => $event_data['task']['id'], 'project_id' => $project['id']), '', true);
125126
}
126127

127128
return $payload;

Plugin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public function initialize()
2121
$this->template->hook->attach('template:project:integrations', 'jabber:project/integration');
2222
$this->template->hook->attach('template:user:integrations', 'jabber:user/integration');
2323

24-
$this->userNotificationType->setType('jabber', t('Jabber'), '\Kanboard\Plugin\Jabber\Notification\Jabber');
25-
$this->projectNotificationType->setType('jabber', t('Jabber'), '\Kanboard\Plugin\Jabber\Notification\Jabber');
24+
$this->userNotificationTypeModel->setType('jabber', t('Jabber'), '\Kanboard\Plugin\Jabber\Notification\Jabber');
25+
$this->projectNotificationTypeModel->setType('jabber', t('Jabber'), '\Kanboard\Plugin\Jabber\Notification\Jabber');
2626
}
2727

2828
public function onStartup()
2929
{
30-
Translator::load($this->language->getCurrentLanguage(), __DIR__.'/Locale');
30+
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
3131
}
3232

3333
public function getPluginDescription()
@@ -42,7 +42,7 @@ public function getPluginAuthor()
4242

4343
public function getPluginVersion()
4444
{
45-
return '1.0.4';
45+
return '1.0.5';
4646
}
4747

4848
public function getPluginHomepage()

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ Author
1414
Installation
1515
------------
1616

17-
- Create a folder **plugins/Jabber**
18-
- Copy all files under this directory
17+
You have the choice between 3 methods:
18+
19+
1. Install the plugin from the Kanboard plugin manager in one click
20+
2. Download the zip file and decompress everything under the directory `plugins/Jabber`
21+
3. Clone this repository into the folder `plugins/Jabber`
22+
23+
Note: Plugin folder is case-sensitive.
1924

2025
Configuration
2126
-------------

0 commit comments

Comments
 (0)