-
Notifications
You must be signed in to change notification settings - Fork 16
/
Plugin.php
150 lines (124 loc) · 6.01 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
namespace Kanboard\Plugin\MetaMagik;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use Kanboard\Plugin\MetaMagik\Helper\MetaHelper;
use Kanboard\Plugin\MetaMagik\Export\MetaTaskExport;
use Kanboard\Plugin\MetaMagik\Model\NewTaskFinderModel;
use Kanboard\Plugin\MetaMagik\Model\NewTaskModificationModel;
use Kanboard\Plugin\MetaMagik\Model\NewTaskCreationModel;
use Kanboard\Plugin\MetaMagik\Analytics\CustomFieldAnalytics;
use Kanboard\Plugin\MetaMagik\Validator\NewTaskValidator;
use Kanboard\Plugin\MetaMagik\Filter\MetaFieldFilter;
use Kanboard\Plugin\MetaMagik\Filter\MetaValueFilter;
use Kanboard\Core\Security\Role;
use Kanboard\Plugin\MetaMagik\Api\Procedure\NewCreateTaskProcedure;
use Kanboard\Plugin\MetaMagik\Action\SetCustomField;
class Plugin extends Base
{
public function initialize()
{
$this->actionManager->register(new SetCustomField($this->container));
//Helpers
$this->helper->register('metaHelper', '\Kanboard\Plugin\MetaMagik\Helper\MetaHelper');
//Models
if (!file_exists('plugins/Group_assign')){
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
return new NewTaskFinderModel($c);
});
}
$this->container['taskModificationModel'] = $this->container->factory(function ($c) {
return new NewTaskModificationModel($c);
});
$this->container['taskCreationModel'] = $this->container->factory(function ($c) {
return new NewTaskCreationModel($c);
});
$this->container['taskValidator'] = $this->container->factory(function ($c) {
return new NewTaskValidator($c);
});
$this->hook->on('model:task:duplication:aftersave', function($hook_values) {
$meta = $this->taskMetadataModel->getAll($hook_values['source_task_id']);
foreach ($meta as $key => $value) { $this->taskMetadataModel->save($hook_values['destination_task_id'], [$key => $value]); }
});
$this->hook->on('model:task:project_duplication:aftersave', function($hook_values) {
$meta = $this->taskMetadataModel->getAll($hook_values['source_task_id']);
foreach ($meta as $key => $value) { $this->taskMetadataModel->save($hook_values['destination_task_id'], [$key => $value]); }
});
//Project
$this->template->hook->attach('template:project:sidebar', 'metaMagik:project/sidebar');
//Task
$this->template->hook->attach('template:task:sidebar:information', 'metaMagik:task/sidebar');
$this->template->hook->attach('template:board:task:icons', 'metaMagik:task/footer_icon');
$this->template->hook->attach('template:board:task:icons', 'metaMagik:task/meta_footers');
$this->template->hook->attach('template:task:form:first-column', 'metaMagik:task/rendermeta1');
$this->template->hook->attach('template:task:form:second-column', 'metaMagik:task/rendermeta2');
$this->template->hook->attach('template:task:form:third-column', 'metaMagik:task/rendermeta3');
$this->template->hook->attach('template:task:details:bottom', 'metaMagik:task/metasummary');
$this->template->hook->attach('template:analytic:sidebar', 'metaMagik:analytic/layout_hook');
$this->template->setTemplateOverride('export/tasks', 'metaMagik:export/tasks');
//Routes
$this->route->addRoute('export/metatasks/:project_id', 'NewExportController', 'tasks');
//Filters
$this->container->extend('taskLexer', function($taskLexer, $c) {
$taskLexer->withFilter(MetaFieldFilter::getInstance()->setDatabase($c['db']));
return $taskLexer;
});
$this->container->extend('taskLexer', function($taskLexer, $c) {
$taskLexer->withFilter(MetaValueFilter::getInstance()->setDatabase($c['db']));
return $taskLexer;
});
//User
$this->template->hook->attach('template:user:sidebar:information', 'metaMagik:user/sidebar');
// Add link to new plugin settings
$this->template->hook->attach('template:config:sidebar', 'metaMagik:config/sidebar');
//java
$this->hook->on('template:layout:js', array('template' => 'plugins/MetaMagik/Assets/js/meta-drag-and-drop.js'));
//css
$this->hook->on('template:layout:css', array('template' => 'plugins/MetaMagik/Assets/css/metamagik.css'));
//Roles
$this->projectAccessMap->add('metadata', 'index', Role::PROJECT_MEMBER);
$this->projectAccessMap->add('MetadataController', array('saveUser', 'saveTask', 'saveProject', 'removeUser', 'removeTask', 'removeProject', 'confirmUser', 'confirmTask', 'confirmProject', 'editUser', 'editTask', 'editProject'), Role::PROJECT_MEMBER);
$this->projectAccessMap->add('MetadataTypesController', '*', Role::PROJECT_MEMBER);
//API
$this->api->getProcedureHandler()->withClassAndMethod('createTaskMeta', new NewCreateTaskProcedure($this->container), 'createTaskMeta');
}
public function onStartup()
{
// Translation
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
}
public function getClasses()
{
return [
'Plugin\MetaMagik\Model' => [
'MetadataTypeModel',
],
'Plugin\MetaMagik\Export' => [
'MetaTaskExport',
],
'Plugin\MetaMagik\Analytics' => [
'CustomFieldAnalytics',
],
];
}
public function getPluginName()
{
return 'metaMagik';
}
public function getPluginDescription()
{
return t('Custom Task Fields and Manage Metadata');
}
public function getPluginAuthor()
{
return 'Craig Crosby + BlueTeck';
}
public function getPluginVersion()
{
return '1.5.6';
}
public function getPluginHomepage()
{
return 'https://github.com/creecros/MetaMagik';
}
}