-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmodule.combodo-pmp-light.php
executable file
·155 lines (141 loc) · 4.38 KB
/
module.combodo-pmp-light.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
151
152
153
154
155
<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
*/
//
// iTop module definition file
//
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'combodo-pmp-light/1.1.3',
array(
// Identification
//
'label' => 'Project Management light module',
'category' => 'business',
// Setup
//
'dependencies' => array(
'itop-tickets/2.7.0',
'itop-config-mgmt/2.0.0',
'itop-object-copier/1.3.4',
'combodo-gantt-view/1.0.2',
),
'mandatory' => false,
'visible' => true,
'installer' => 'PMPLightInstaller',
// Components
//
'datamodel' => array(
'src/Attribute/AttributePercentageCompletion.php',
'model.combodo-pmp-light.php',
),
'webservice' => array(),
'data.struct' => array(// add your 'structure' definition XML files here,
),
'data.sample' => array(// add your sample data XML files here,
),
// Documentation
//
'doc.manual_setup' => '', // hyperlink to manual setup documentation, if any
'doc.more_information' => '', // hyperlink to more information, if any
// Default settings
//
'settings' => array(// Module specific settings go here, if any
),
)
);
if (!class_exists('PMPLightInstaller'))
{
// Module installation handler
//
class PMPLightInstaller extends ModuleInstallerAPI
{
/**
* @inheritdoc
*/
public static function BeforeWritingConfig(Config $oConfiguration)
{
// Rule to add to the object copier configuration
//create a delivrable from a project
$aNewRule = array(
'source_scope' => 'SELECT Project WHERE status NOT IN (\'closed\',\'monitored\',\'cancel\')',
'allowed_profiles' => 'Project Manager,Administrator',
'menu_label' => Dict::s('Class:Project/CreateDeliverable'),
'form_label' => Dict::s('Class:Project/CreateDeliverableForm'),
'report_label' => Dict::s('Class:Project/ReportLabel'),
'dest_class' => 'WBS',
'preset' =>
array(
0 => 'copy(id,project_id)',
1 => 'set(start_date,$current_date$ $current_time$)',
2 => 'copy(agent_id,wbs_owner_id)',
),
'retrofit' =>
array(),
);
// Retrieving object copier rules from conf parameters
// Note: We don't do anything if object copier is not installed, otherwise its configuration will be set when installed.
$aExistingRules = $oConfiguration->GetModuleSetting('itop-object-copier', 'rules', array());
if (!empty($aExistingRules))
{
$bFound = false;
foreach ($aExistingRules as $aExistingRule)
{
if (isset($aExistingRule['menu_label']) && ($aExistingRule['menu_label'] === $aNewRule['menu_label']))
{
$bFound = true;
break;
}
}
// Add rule only if not already existing
if ($bFound === false)
{
$aExistingRules[] = $aNewRule;
$oConfiguration->SetModuleSetting('itop-object-copier', 'rules', $aExistingRules);
}
}
//duplicate a project with delivrable
$aNewRule = array(
'id' => 'CopyProjectLight',
'source_scope' => 'SELECT Project WHERE status NOT IN (\'closed\',\'monitored\')',
'allowed_profiles' => 'Project Manager,Administrator',
'menu_label' => Dict::s('Class:Project/DuplicateProject'),
'form_label' => Dict::s('Class:Project/DuplicateProjectForm'),
'report_label' => Dict::s('Class:Project/ReportLabel'),
'dest_class' => 'Project',
'preset' =>
array (
0 => 'clone_scalars(*)',
1 => 'clone(contacts_list,functionalcis_list)',
2 => 'call_method(Copydeliverablestodeliverables)',
),
'retrofit' =>
array (),
);
// Retrieving object copier rules from conf parameters
// Note: We don't do anything if object copier is not installed, otherwise its configuration will be set when installed.
$aExistingRules = $oConfiguration->GetModuleSetting('itop-object-copier', 'rules', array());
if (!empty($aExistingRules))
{
$bFound = false;
foreach ($aExistingRules as $aExistingRule)
{
if (isset($aExistingRule['menu_label']) && ($aExistingRule['menu_label'] === $aNewRule['menu_label']))
{
$bFound = true;
break;
}
}
// Add rule only if not already existing
if ($bFound === false)
{
$aExistingRules[] = $aNewRule;
$oConfiguration->SetModuleSetting('itop-object-copier', 'rules', $aExistingRules);
}
}
return $oConfiguration;
}
}
}