-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plugin.php
85 lines (71 loc) · 2.1 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* IMAP User Authentication Plugin for Kanboard
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 2019 Jim Mason <[email protected]>
* @link https://github.com/RocketMan/plugin-imap-user-auth
* @license MIT
*/
namespace Kanboard\Plugin\IMAPUserAuth;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use Kanboard\Plugin\IMAPUserAuth\Auth\IMAPUserAuthProvider;
class Plugin extends Base
{
public function initialize()
{
$this->authenticationManager->register(
new IMAPUserAuthProvider($this));
$this->template->hook->attach('template:config:integrations',
'IMAPUserAuth:config');
}
public function onStartup()
{
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
}
public function getPluginName()
{
return 'IMAP User Authentication';
}
public function getPluginDescription()
{
return t('Login to Kanboard using your IMAP credentials');
}
public function getPluginAuthor()
{
return 'Jim Mason';
}
public function getPluginVersion()
{
return '1.0.3';
}
public function getPluginHomepage()
{
return 'https://github.com/RocketMan/plugin-imap-user-auth';
}
/**
* replace all instances of {PluginXXX} with the results of the
* evaluation $this->getPluginXXX()
*/
public function resolveMetadata($text)
{
return preg_replace_callback('/\{Plugin(.*?)\}/', function($matched) {
return call_user_func([$this, "getPlugin".$matched[1]]); }, $text);
}
/**
* resolve all metadata and Markdown hyperlinks in the supplied text
*/
public function resolveMarkdown($text)
{
return preg_replace('/\[(.*?)\]\((.*?)\)/', "<A HREF='$2'>$1</A>",
$this->resolveMetadata($text));
}
public function raiseException($messages)
{
$output = "";
foreach($messages as $message)
$output .= "<P>".$this->resolveMarkdown($message)."</P>";
throw new \LogicException($output);
}
}