-
Notifications
You must be signed in to change notification settings - Fork 5
/
module.combodo-approval-extended.php
executable file
·174 lines (160 loc) · 7.17 KB
/
module.combodo-approval-extended.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
// Copyright (C) 2012 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'combodo-approval-extended/1.5.0',
array(
// Identification
//
'label' => 'Enhanced Approval Schemes',
'category' => 'feature',
// Setup
//
'dependencies' => array(
'approval-base/2.5.1',
'itop-service-mgmt/3.2.0||itop-service-mgmt-provider/3.2.0',
'itop-request-mgmt-itil/3.2.0||itop-request-mgmt/3.2.0',
'combodo-sla-computation/2.3.0',
),
'mandatory' => false,
'visible' => true,
'installer' => 'ApprovalExtendedInstaller',
// Components
//
'datamodel' => array(
'model.combodo-approval-extended.php',
'main.combodo-approval-extended.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
'settings' => array(
// Module specific settings go here, if any
'target_state' => 'new',
'bypass_profiles' => 'Administrator, Service Manager',
'reuse_previous_answers' => true
),
)
);
if (!class_exists('ApprovalExtendedInstaller'))
{
// Module installation handler
//
class ApprovalExtendedInstaller extends ModuleInstallerAPI
{
public static function BeforeWritingConfig(Config $oConfiguration)
{
// If you want to override/force some configuration values, do it here
return $oConfiguration;
}
/**
* Handler called before creating or upgrading the database schema
* @param $oConfiguration Config The new configuration of the application
* @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
* @param $sCurrentVersion string Current version number of the module
*/
public static function BeforeDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
{
}
/**
* Handler called after the creation/update of the database schema
* @param $oConfiguration Config The new configuration of the application
* @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install)
* @param $sCurrentVersion string Current version number of the module
*/
public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
{
if (version_compare($sPreviousVersion, '1.2.0', '<'))
{
SetupLog::Info("Upgrading combodo-approval-extended from '$sPreviousVersion' to '$sCurrentVersion'. Starting with 1.2.0, the extension requires a set of trigger/actions that will created into the DB...");
$oTrigger = MetaModel::NewObject('TriggerOnApprovalRequest');
$oTrigger->Set('description', 'Approval requested');
$oTrigger->Set('target_class', 'UserRequest');
$oTrigger->DBInsert();
$oAction = MetaModel::NewObject('ActionEmailApprovalRequest');
$oAction->Set('name', 'Approval request (EN)');
$oAction->Set('description', 'Sample message, automatically created when upgrading');
$oAction->Set('status', 'enabled');
$oAction->Set('from', ActionEmailApprovalRequest::GetDefaultEmailSender());
$oAction->Set('subject', 'Your approval is requested: $this->ref$');
$oAction->Set('subject_reminder', 'Your approval is requested: $this->ref$ (reminder)');
$oAction->Set('body', '<h3>Your approval is requested: $this->html(ref)$</h3>
<p>Dear $approver->html(friendlyname)$, please take some time to approve or reject ticket $this->html(ref)$</p>
<b>Caller</b>: $this->html(caller_id_friendlyname)$<br>
<b>Title</b>: $this->html(title)$<br>
<b>Service</b>: $this->html(service_name)$<br>
<b>Service subcategory</b>: $this->html(servicesubcategory_name)$<br>
<b>Description</b>:<br>
$this->html(description)$<br>
<b>Additional information</b>:<br>
<div>$this->html(service_details)$</div>
<p>$approval_link$</p>'
);
$oAction->DBInsert();
$oAction = MetaModel::NewObject('ActionEmailApprovalRequest');
$oAction->Set('name', 'Approval request (FR)');
$oAction->Set('description', 'Sample message, automatically created when upgrading');
$oAction->Set('status', 'enabled');
$oAction->Set('from', ActionEmailApprovalRequest::GetDefaultEmailSender());
$oAction->Set('subject', 'Votre approbation est attendue : $this->ref$');
$oAction->Set('subject_reminder', 'Votre approbation est attendue : $this->ref$ (relance)');
$oAction->Set('body', '<h3>Votre approbation est attendue : $this->html(ref)$</h3>
<p>Cher $approver->html(friendlyname)$, merci de prendre le temps d\'approuver le ticket $this->html(ref)$</p>
<b>Demandeur</b> : $this->html(caller_id_friendlyname)$<br>
<b>Titre</b> : $this->html(title)$<br>
<b>Service</b> : $this->html(service_name)$<br>
<b>Sous catégorie de service</b> : $this->html(servicesubcategory_name)$<br>
<b>Description</b> :<br>
$this->html(description)$<br>
<b>Informations complémentaires</b> :<br>
<div>$this->html(service_details)$</div>
<p>$approval_link$</p>
');
$oAction->DBInsert();
$oAction = MetaModel::NewObject('ActionEmailApprovalRequest');
$oAction->Set('name', 'Approval request (DE)');
$oAction->Set('description', 'Sample message, automatically created when upgrading');
$oAction->Set('status', 'enabled');
$oAction->Set('from', ActionEmailApprovalRequest::GetDefaultEmailSender());
$oAction->Set('subject', 'Ihre Freigabeanfrage wurde erstellt $this->ref$');
$oAction->Set('subject_reminder', 'Ihre Freigabeanfrage wurde erstellt $this->ref$ (Erinnerung)');
$oAction->Set('body', '<h3>Ihre Freigabeanfrage wurde erstellt $this->ref$</h3>
<p>Sehr geehrte/r $approver->html(friendlyname)$, bitte nehmen sie sich etwas Zeit, um Ticket $this->html(ref)$ zu bearbeiten</p>
<h3>Titel : $this->html(title)$</h3>
<p>Beschreibung:</p>
$this->html(description)$
<p>Ersteller: $this->html(caller_id_friendlyname)$</p>
<p>Service: $this->html(service_name)$</p>
<p>Servicekategorie: $this->html(servicesubcategory_name)$</p>
<p>Details:</p>
<div>$this->html(service_details)$</div>
<p>$approval_link$</p>
');
$oAction->DBInsert();
SetupLog::Info("... sample trigger/actions successfully created.");
}
}
}
}