Skip to content

Commit 128b704

Browse files
committed
Added more info in config format
Added possibility to rename PM DB (default to wf_workflow) Fixes tomolimo#53 Fixes tomolimo#50 + other fixes Changed version to 3.2.8
1 parent c558979 commit 128b704

8 files changed

+94
-8
lines changed

front/processmaker.helpdesk.form.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
588588
$buffer = htmlspecialchars($buffer, ENT_NOQUOTES);
589589
// will restore '&lt;' to '<' and '&gt;' to '>'
590590
// so that only the already escaped entites will get the double encoding
591-
$buffer = str_replace(['&lt;', '&gt;'], ['<', '>'], $buffer);
591+
// will also change </b> end of bold into a local identifier
592+
$endOfBold = 'end_of_bold'.rand();
593+
$buffer = str_replace(['&lt;', '&gt;', '</b>'], ['<', '>', $endOfBold], $buffer);
592594

593595
// will convert any UTF-8 char that can't be expressed in ASCII into an HTML entity
594596
$buffer = mb_convert_encoding($buffer, 'HTML-ENTITIES');
@@ -604,6 +606,14 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
604606
$elt->setAttribute( 'style', 'display:none;');
605607
}
606608

609+
// add an input for processId in the form
610+
// echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
611+
$res = $xpath->query('//form[@name="helpdeskform"]');
612+
$input = $res->item(0)->appendChild(new DOMElement('input'));
613+
$input->setAttribute('name', 'processId');
614+
$input->setAttribute('type', 'hidden');
615+
$input->setAttribute('value', $caseInfo->processId);
616+
607617
// special case for content textarea which is in the same tr than the file upload
608618
$res = $xpath->query('//*[@name="content"]/ancestor::div[1] | //*[@name="content"]/ancestor::tr[1]/td[1]');
609619
foreach($res as $elt) {
@@ -644,6 +654,9 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
644654

645655
$buffer = $dom->saveHTML();
646656

657+
// revert back </b>
658+
$buffer = str_replace($endOfBold, '</b>', $buffer);
659+
647660
// will revert back any char converted above
648661
$buffer = mb_convert_encoding($buffer, 'UTF-8', 'HTML-ENTITIES');
649662
echo $buffer;

front/tracking.injector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
if( isset( $_REQUEST['_glpi_csrf_token'] ) ) {
88
define('GLPI_KEEP_CSRF_TOKEN', true) ;
99
}
10+
$PM_POST = $_POST;
11+
$PM_REQUEST = $_REQUEST;
12+
$PM_GET = $_GET;
1013
include( "../../../inc/includes.php" );
1114

1215
if (empty($_POST["_type"])
@@ -58,4 +61,8 @@
5861
// prepare environment for std tracking.injector.php
5962
// switch to front dir
6063
chdir(GLPI_ROOT."/front");
64+
// revert back $_POST, $_GET and $_REQUEST
65+
$_GET = $PM_GET;
66+
$_POST = $PM_POST;
67+
$_REQUEST = $PM_REQUEST;
6168
include (GLPI_ROOT . "/front/tracking.injector.php");

hook.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function plugin_processmaker_install() {
123123
`pm_group_guid` VARCHAR(32) NULL DEFAULT NULL,
124124
`comment` TEXT NULL,
125125
`pm_dbserver_name` VARCHAR(255) NULL DEFAULT 'localhost',
126+
`pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow',
126127
`pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL,
127128
`pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL,
128129
`domain` VARCHAR(50) NULL DEFAULT '',
@@ -164,6 +165,13 @@ function plugin_processmaker_install() {
164165
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
165166
}
166167

168+
if (!arFieldExists("glpi_plugin_processmaker_configs", "pm_dbname" )) {
169+
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
170+
ADD COLUMN `pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow' AFTER `pm_dbserver_name`;
171+
;";
172+
$DB->query($query) or die("error adding field pm_dbname to glpi_plugin_processmaker_configs" . $DB->error());
173+
}
174+
167175
if (arTableExists("glpi_plugin_processmaker_profiles")) {
168176
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;";
169177
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());

inc/config.class.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ static function getCommonDomain($url1, $url2) {
143143
static function showConfigForm($item) {
144144
global $LANG, $PM_DB, $CFG_GLPI;
145145

146+
$setup_ok = false;
147+
146148
$ui_theme = array(
147149
'glpi_classic' => 'glpi_classic',
148150
'glpi_neoclassic' => 'glpi_neoclassic'
149151
);
150152

151153
$config = self::getInstance();
152154

153-
$config->showFormHeader();
155+
$config->showFormHeader(['colspan' => 4]);
154156

155157
echo "<tr class='tab_bg_1'>";
156158
echo "<td >".$LANG['processmaker']['config']['URL']."</td><td >";
@@ -220,6 +222,7 @@ function parseUrl( url ) {
220222
&& $config->fields["pm_admin_user"] != ''
221223
&& ($pm->login(true))) {
222224
echo "<font color='green'>".__('Test successful');
225+
$setup_ok = true;
223226
} else {
224227
echo "<font color='red'>".__('Test failed')."<br>".print_r($pm->lasterror, true);
225228
}
@@ -232,6 +235,11 @@ function parseUrl( url ) {
232235
echo "<td ><input type='text' size=50 name='pm_dbserver_name' value='".$config->fields["pm_dbserver_name"]."'>";
233236
echo "</td></tr>\n";
234237

238+
echo "<tr class='tab_bg_1'>";
239+
echo "<td >" . __('Database name') . "</td>";
240+
echo "<td ><input type='text' size=50 name='pm_dbname' value='".$config->fields["pm_dbname"]."'>";
241+
echo "</td></tr>\n";
242+
235243
echo "<tr class='tab_bg_1'>";
236244
echo "<td >" . __('SQL user') . "</td>";
237245
echo "<td ><input type='text' name='pm_dbserver_user' value='".$config->fields["pm_dbserver_user"]."'>";
@@ -310,6 +318,23 @@ function parseUrl( url ) {
310318
Dropdown::showYesNo("maintenance", $config->fields['maintenance']);
311319
echo "</td></tr>";
312320

321+
echo "<tr><td colspan='4'></td></tr>";
322+
323+
echo "<tr><th colspan='4'>".__('Processmaker system information')."</th></tr>";
324+
if ($setup_ok) {
325+
$info = $pm->systemInformation( );
326+
echo '<tr><td>'._('Version').'</td><td>'.$info->version.'</td></tr>';
327+
echo '<tr><td>'._('Web server').'</td><td>'.$info->webServer.'</td></tr>';
328+
echo '<tr><td>'._('Server name').'</td><td>'.$info->serverName.'</td></tr>';
329+
echo '<tr><td>'._('PHP version').'</td><td>'.$info->phpVersion.'</td></tr>';
330+
echo '<tr><td>'._('DB version').'</td><td>'.$info->databaseVersion.'</td></tr>';
331+
echo '<tr><td>'._('DB server IP').'</td><td>'.$info->databaseServerIp.'</td></tr>';
332+
echo '<tr><td>'._('DB name').'</td><td>'.$info->databaseName.'</td></tr>';
333+
echo '<tr><td>'._('User browser').'</td><td>'.$info->userBrowser.'</td></tr>';
334+
echo '<tr><td>'._('User IP').'</td><td>'.$info->userIp.'</td></tr>';
335+
} else {
336+
echo '<tr><td>'._('Version').'</td><td>'.__('Not yet!').'</td></tr>';
337+
}
313338
$config->showFormButtons(array('candel'=>false));
314339

315340
return false;

inc/db.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function __construct() {
1818
$this->dbhost = $config->fields['pm_dbserver_name'];
1919
$this->dbuser = $config->fields['pm_dbserver_user'];
2020
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
21-
$this->dbdefault = "wf_".$config->fields['pm_workspace'];
21+
$this->dbdefault = $config->fields['pm_dbname'];
2222
parent::__construct();
2323
}
2424
}

inc/processmaker.class.php

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,24 @@ function caseList( ) {
451451
}
452452
}
453453

454+
/**
455+
* Summary of systemInformation
456+
* returns information about the PM system
457+
* Embedded systemInformation() PM web service call (definition: http://wiki.processmaker.com/index.php/ProcessMaker_WSDL_Web_Services#systemInformation.28.29)
458+
* A session must be open before with login()
459+
* @return an object containing information, or false when exception occured
460+
*/
461+
function systemInformation( ) {
462+
try {
463+
$pmSystemInfo = $this->pmSoapClient->systemInformation( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
464+
return $pmSystemInfo;
465+
}
466+
catch (Exception $e) {
467+
Toolbox::logDebug( $e );
468+
return false;
469+
}
470+
}
471+
454472
/**
455473
* Summary of reassignCase
456474
* reassigns a case to a different user. Note that the logged-in user needs to have the PM_REASSIGNCASE permission in his/her role in order to be able to reassign the case.
@@ -1380,7 +1398,10 @@ public static function plugin_item_add_processmaker($parm) {
13801398
if (property_exists( $pmRouteCaseResponse, 'routing' )) {
13811399
// now tries to get some variables to setup content for new task and to append text to solved task
13821400
$txtForTasks = $myProcessMaker->getVariables( $myCase->getID(), array( "GLPI_ITEM_APPEND_TO_TASK",
1383-
"GLPI_ITEM_SET_STATUS" ) );
1401+
"GLPI_ITEM_SET_STATUS",
1402+
"GLPI_TICKET_FOLLOWUP_CONTENT",
1403+
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE",
1404+
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" ) );
13841405
$itemSetStatus = '';
13851406
if (array_key_exists( 'GLPI_ITEM_SET_STATUS', $txtForTasks )) {
13861407
$itemSetStatus = $txtForTasks[ 'GLPI_ITEM_SET_STATUS' ];
@@ -1390,14 +1411,26 @@ public static function plugin_item_add_processmaker($parm) {
13901411
} else {
13911412
$txtToAppendToTask = '';
13921413
}
1414+
$createFollowup = false; // by default
1415+
if (array_key_exists( 'GLPI_TICKET_FOLLOWUP_CONTENT', $txtForTasks ) && $txtForTasks[ 'GLPI_TICKET_FOLLOWUP_CONTENT' ] != '') {
1416+
$createFollowup = true;
1417+
}
13931418

13941419
// reset those variables
13951420
$resultSave = $myProcessMaker->sendVariables( $myCase->getID(), array( "GLPI_ITEM_APPEND_TO_TASK" => '',
1396-
"GLPI_ITEM_SET_STATUS" => '' ) );
1421+
"GLPI_ITEM_SET_STATUS" => '',
1422+
"GLPI_TICKET_FOLLOWUP_CONTENT" => '',
1423+
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE" => '',
1424+
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" => '' ) );
13971425

13981426
// routing has been done, then solve 1st task
13991427
$myProcessMaker->solveTask( $myCase->getID(), $parm->input['processmaker_delindex'], array( 'txtToAppend' => $txtToAppendToTask, 'notif' => false) );
14001428

1429+
// create a followup if requested
1430+
if ($createFollowup && $itemType == 'Ticket') {
1431+
$myProcessMaker->addTicketFollowup( $itemId, $txtForTasks );
1432+
}
1433+
14011434
// and create GLPI tasks for the newly created PM tasks.
14021435
foreach ($pmRouteCaseResponse->routing as $route) {
14031436
$myProcessMaker->addTask( $myCase->fields['itemtype'],

processmaker.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
</authors>
2424
<versions>
2525
<version>
26-
<num>3.2.5</num>
26+
<num>3.2.8</num>
2727
<compatibility>9.2</compatibility>
2828
</version>
2929
<version>
30-
<num>3.2.5</num>
30+
<num>3.2.8</num>
3131
<compatibility>9.1</compatibility>
3232
</version>
3333
</versions>

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function plugin_version_processmaker() {
119119
global $LANG;
120120

121121
return array ('name' => 'Process Maker',
122-
'version' => '3.2.5',
122+
'version' => '3.2.8',
123123
'author' => 'Olivier Moron',
124124
'homepage' => 'https://github.com/tomolimo/processmaker',
125125
'minGlpiVersion' => '9.1');

0 commit comments

Comments
 (0)