-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPlugin.php
More file actions
74 lines (63 loc) · 2.47 KB
/
Plugin.php
File metadata and controls
74 lines (63 loc) · 2.47 KB
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
<?php
namespace Kanboard\Plugin\PrivateTasks;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use Kanboard\Model\TaskModel;
use Kanboard\Core\Http\Route;
use Kanboard\Core\Security\Role;
class Plugin extends Base
{
public function initialize()
{
// Access
$this->projectAccessMap->add('TaskSecurityController', array('resetAll'), Role::APP_ADMIN);
$this->projectAccessMap->add('TaskSecurityController', array('project', 'checkMeta','enablePrivateTasks','disablePrivateTasks'), Role::PROJECT_MANAGER);
// Private Tasks Query
$this->hook->on('formatter:board:query', function (\PicoDb\Table &$query) {
$project_id = 0;
if(isset($_GET['project_id'])){
$project_id = $_GET['project_id']; // Project ID
}
if(in_array($project_id, json_decode($this->configModel->get('privateTasks_proj_priv_tasks'),true))){
// Private tasks is enabled
$userID = session_get('user')['id'];
$userRoleInProject = $this->helper->projectRole->getProjectUserRole($project_id);
if($userRoleInProject != "project-manager"){
$query->eq(TaskModel::TABLE.'.owner_id',$userID);
}
}
});
// Attach CSS
$this->hook->on('template:layout:css', array('template' => 'plugins/PrivateTasks/Template/css/private-tasks.css'));
// Settings Nav Bar
$this->template->hook->attach('template:project:sidebar', 'privateTasks:project/sidebar');
// Private Tasks Header Reminder
if(isset($_GET['project_id'])){
$this->template->hook->attach('template:project-header:view-switcher','privateTasks:project/private-status-header',['security'=>in_array($_GET['project_id'], json_decode($this->configModel->get('privateTasks_proj_priv_tasks'),true))]);
}
}
public function onStartup()
{
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
}
public function getPluginName()
{
return 'PrivateTasks';
}
public function getPluginDescription()
{
return t('Plugin to only show tasks assigned to you');
}
public function getPluginAuthor()
{
return 'Mark Ireland';
}
public function getPluginVersion()
{
return '1.0.0';
}
public function getPluginHomepage()
{
return 'https://github.com/moosethecoder/PrivateTasks';
}
}