Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Problems Tasks #136

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function plugin_actualtime_preSolutionAdd(ITILSolution $solution)
{
global $DB, $CFG_GLPI;

if ($solution->input['itemtype'] == Ticket::getType() || $solution->input['itemtype'] == Change::getType()) {
if ($solution->input['itemtype'] == Ticket::getType() || $solution->input['itemtype'] == Change::getType() || $solution->input['itemtype'] == Problem::getType()) {

$parent = new $solution->input['itemtype']();
$taskitemtype = $parent->getTaskClass();
Expand Down
38 changes: 37 additions & 1 deletion inc/running.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,42 @@ static function listRunning()
$atable.'.actual_end' => null,
] + getEntitiesRestrictCriteria($changetable),
]);

//Problem
$problemtable = Problem::getTable();
$tasktable = ProblemTask::getTable();

$queryproblem = new \QuerySubQuery([
'SELECT' => [
$atable . '.*',
$tasktable . '.problems_id',
],
'FROM' => $atable,
'INNER JOIN' => [
$tasktable => [
'ON' => [
$tasktable => 'id',
$atable => 'items_id',[
'AND' => [
$atable.'.itemtype' => ProblemTask::getType()
]
]
]
],
$problemtable => [
'ON' => [
$problemtable => 'id',
$tasktable => 'problems_id'
]
],
],
'WHERE' => [
[
'NOT' => [$atable.'.actual_begin' => null],
],
$atable.'.actual_end' => null,
] + getEntitiesRestrictCriteria($problemtable),
]);

//Project
$projecttable = Project::getTable();
Expand Down Expand Up @@ -223,7 +259,7 @@ static function listRunning()
] + getEntitiesRestrictCriteria($projecttable),
]);

$union = new \QueryUnion([$queryticket, $querychange, $queryproject]);
$union = new \QueryUnion([$queryticket, $querychange, $queryproblem, $queryproject]);

$iteratortime = $DB->request(['FROM' => $union]);
if ($iteratortime->count() > 0) {
Expand Down
6 changes: 6 additions & 0 deletions inc/sourcetimer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PluginActualtimeSourcetimer extends CommonDBTM
const TICKET = 1024;
const CHANGE = 2048;
const PROJECT = 4096;
const PROBLEM = 8192;

public function getRights($interface = 'central')
{
Expand All @@ -46,6 +47,7 @@ public function getRights($interface = 'central')
self::TICKET => __('Modify tickets', 'actualtime'),
self::CHANGE => __('Modify changes', 'actualtime'),
self::PROJECT => __('Modify projects', 'actualtime'),
self::PROBLEM => __('Modify problems', 'actualtime'),
];
}
return [];
Expand All @@ -60,6 +62,9 @@ public static function checkItemtypeRight($itemtype)
case 'ChangeTask':
return Session::haveRight(self::$rightname, self::CHANGE);
break;
case 'ProblemTask':
return Session::haveRight(self::$rightname, self::PROBLEM);
break;
case 'ProjectTask':
return Session::haveRight(self::$rightname, self::PROJECT);
break;
Expand All @@ -75,6 +80,7 @@ public static function canModify($itemtype, $items_id)

switch ($itemtype) {
case 'TicketTask':
case 'ProblemTask':
case 'ChangeTask':
$task = new $itemtype();
if ($task->getFromDB($items_id)) {
Expand Down
2 changes: 2 additions & 0 deletions inc/task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ static public function postForm($params)

switch ($item->getType()) {
case 'ChangeTask':
case 'ProblemTask':
case 'TicketTask':
if ($item->getID()) {

Expand Down Expand Up @@ -986,6 +987,7 @@ static function postShowItem($params)
$config = new PluginActualtimeConfig();
switch ($item->getType()) {
case 'TicketTask':
case 'ProblemTask':
case 'ChangeTask':

$task_id = $item->getID();
Expand Down
9 changes: 7 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ function plugin_init_actualtime()
$PLUGIN_HOOKS['post_item_form']['actualtime'] = ['PluginActualtimeTask', 'postForm'];
$PLUGIN_HOOKS['show_item_stats']['actualtime'] = [
'Ticket' => 'plugin_actualtime_item_stats',
'Change' => 'plugin_actualtime_item_stats'
'Change' => 'plugin_actualtime_item_stats',
'Problem' => 'plugin_actualtime_item_stats'
];
$PLUGIN_HOOKS['pre_item_update']['actualtime'] = [
'TicketTask' => 'plugin_actualtime_item_update',
'ChangeTask' => 'plugin_actualtime_item_update',
'ProblemTask' => 'plugin_actualtime_item_update',
'ProjectTask' => 'plugin_actualtime_item_update',
];
$PLUGIN_HOOKS[Hooks::POST_SHOW_ITEM]['actualtime'] = 'plugin_actualtime_postshowitem';
Expand All @@ -92,11 +94,13 @@ function plugin_init_actualtime()
$PLUGIN_HOOKS['item_purge']['actualtime'] = [
'TicketTask' => 'plugin_actualtime_item_purge',
'ChangeTask' => 'plugin_actualtime_item_purge',
'ProblemTask' => 'plugin_actualtime_item_purge',
'ProjectTask' => 'plugin_actualtime_item_purge',
];
$PLUGIN_HOOKS[Hooks::ITEM_DELETE]['actualtime'] = [
'Ticket' => 'plugin_actualtime_parent_delete',
'Change' => 'plugin_actualtime_parent_delete',
'Problem' => 'plugin_actualtime_parent_delete',
'Project' => 'plugin_actualtime_project_delete',
];
$PLUGIN_HOOKS['pre_item_add']['actualtime'] = [
Expand All @@ -110,7 +114,8 @@ function plugin_init_actualtime()

$PLUGIN_HOOKS['item_add']['actualtime'] = [
'TicketTask' => 'plugin_actualtime_item_add',
'ChangeTask' => 'plugin_actualtime_item_add'
'ChangeTask' => 'plugin_actualtime_item_add',
'ProblemTask' => 'plugin_actualtime_item_add'
];

if (Session::haveRight('plugin_actualtime_running', READ)) {
Expand Down