summaryrefslogtreecommitdiff
path: root/plugins/TimeMachine/Plugin.php
blob: 374f0f5338afc9ba1b9cc1243b76b7efbd997e00 (plain)
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
<?php
namespace Kanboard\Plugin\TimeMachine;

use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use Kanboard\Plugin\TimeMachine\Action\SubtaskTimerMoveTaskColumn;
use Kanboard\Plugin\TimeMachine\Model\SubtaskTimeTrackingModel;

class Plugin extends Base
{
    /**
     *
     */
    public function initialize()
    {
        /***** AnalyticTimes *****/
        $this->hook->on('template:layout:js',
            array(
                'template' => 'plugins/TimeMachine/Assets/js/components/chart-project-time-machine.js'
            )
        );
        $this->template->hook->attach('template:analytic:sidebar', 'TimeMachine:analytic/sidebar');
        $this->helper->register('analyticsTimes', '\Kanboard\Plugin\TimeMachine\Helper\AnalyticsTimes');

        /***** SubTaskTimeTracking *****/
        $this->helper->register('subTaskTimeTracking', '\Kanboard\Plugin\TimeMachine\Helper\SubTaskTimeTracking');
        $this->helper->register('subTaskTimeTrackingValidator', '\Kanboard\Plugin\TimeMachine\Validator\SubTaskTimeTrackingValidator');
        // Sub task time tracking Model extended
        $this->container['subtaskTimeTrackingModel'] = $this->container->factory(function ($c) {
            return new SubtaskTimeTrackingModel($c);
        });

        $this->template->setTemplateOverride('subtask/menu', 'TimeMachine:subtask/menu');
        $this->template->setTemplateOverride('subtask/edit', 'TimeMachine:subtask/edit');
        
        // Override SubTaskTimerMoveTaskColumn to create subTask with user connected (User who move card)
        $this->actionManager->register(new SubtaskTimerMoveTaskColumn($this->container));
    }

    /**
     *
     */
    public function onStartup()
    {
        Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
    }

    /**
     * @return string
     */
    public function getPluginName()
    {
        return 'TimeMachine';
    }

    /**
     * @return string
     */
    public function getPluginDescription()
    {
        return t('Plugin to add time machine : Back to the Future (more analytics datas, edit form on subtask time tracking)');
    }

    /**
     * @return string
     */
    public function getPluginAuthor()
    {
        return 'yvalentin';
    }

    /**
     * @return string
     */
    public function getPluginVersion()
    {
        return '1.0.1';
    }

    /**
     * @return string
     */
    public function getPluginHomepage()
    {
        return 'https://gitlab.com/yv-kanboard-plugin/time-machine';
    }

    /**
     * @return string
     */
    public function getCompatibleVersion()
    {
        return '>=1.2.6';
    }
}