Skip to content

Commit

Permalink
Added more info in config format
Browse files Browse the repository at this point in the history
Added possibility to rename PM DB (default to wf_workflow)
Fixes #53
Fixes #50
+ other fixes
Changed version to 3.2.8
  • Loading branch information
tomolimo committed Mar 19, 2018
1 parent c558979 commit 128b704
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 8 deletions.
15 changes: 14 additions & 1 deletion front/processmaker.helpdesk.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ function processMakerShowCase( $ID, $from_helpdesk ) {
$buffer = htmlspecialchars($buffer, ENT_NOQUOTES);
// will restore '&lt;' to '<' and '&gt;' to '>'
// so that only the already escaped entites will get the double encoding
$buffer = str_replace(['&lt;', '&gt;'], ['<', '>'], $buffer);
// will also change </b> end of bold into a local identifier
$endOfBold = 'end_of_bold'.rand();
$buffer = str_replace(['&lt;', '&gt;', '</b>'], ['<', '>', $endOfBold], $buffer);

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

// add an input for processId in the form
// echo "<input type='hidden' name='processId' value='".$caseInfo->processId."'>";
$res = $xpath->query('//form[@name="helpdeskform"]');
$input = $res->item(0)->appendChild(new DOMElement('input'));
$input->setAttribute('name', 'processId');
$input->setAttribute('type', 'hidden');
$input->setAttribute('value', $caseInfo->processId);

// special case for content textarea which is in the same tr than the file upload
$res = $xpath->query('//*[@name="content"]/ancestor::div[1] | //*[@name="content"]/ancestor::tr[1]/td[1]');
foreach($res as $elt) {
Expand Down Expand Up @@ -644,6 +654,9 @@ function processMakerShowCase( $ID, $from_helpdesk ) {

$buffer = $dom->saveHTML();

// revert back </b>
$buffer = str_replace($endOfBold, '</b>', $buffer);

// will revert back any char converted above
$buffer = mb_convert_encoding($buffer, 'UTF-8', 'HTML-ENTITIES');
echo $buffer;
Expand Down
7 changes: 7 additions & 0 deletions front/tracking.injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
if( isset( $_REQUEST['_glpi_csrf_token'] ) ) {
define('GLPI_KEEP_CSRF_TOKEN', true) ;
}
$PM_POST = $_POST;
$PM_REQUEST = $_REQUEST;
$PM_GET = $_GET;
include( "../../../inc/includes.php" );

if (empty($_POST["_type"])
Expand Down Expand Up @@ -58,4 +61,8 @@
// prepare environment for std tracking.injector.php
// switch to front dir
chdir(GLPI_ROOT."/front");
// revert back $_POST, $_GET and $_REQUEST
$_GET = $PM_GET;
$_POST = $PM_POST;
$_REQUEST = $PM_REQUEST;
include (GLPI_ROOT . "/front/tracking.injector.php");
8 changes: 8 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function plugin_processmaker_install() {
`pm_group_guid` VARCHAR(32) NULL DEFAULT NULL,
`comment` TEXT NULL,
`pm_dbserver_name` VARCHAR(255) NULL DEFAULT 'localhost',
`pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow',
`pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL,
`pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL,
`domain` VARCHAR(50) NULL DEFAULT '',
Expand Down Expand Up @@ -164,6 +165,13 @@ function plugin_processmaker_install() {
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
}

if (!arFieldExists("glpi_plugin_processmaker_configs", "pm_dbname" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow' AFTER `pm_dbserver_name`;
;";
$DB->query($query) or die("error adding field pm_dbname to glpi_plugin_processmaker_configs" . $DB->error());
}

if (arTableExists("glpi_plugin_processmaker_profiles")) {
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;";
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());
Expand Down
27 changes: 26 additions & 1 deletion inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,16 @@ static function getCommonDomain($url1, $url2) {
static function showConfigForm($item) {
global $LANG, $PM_DB, $CFG_GLPI;

$setup_ok = false;

$ui_theme = array(
'glpi_classic' => 'glpi_classic',
'glpi_neoclassic' => 'glpi_neoclassic'
);

$config = self::getInstance();

$config->showFormHeader();
$config->showFormHeader(['colspan' => 4]);

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

echo "<tr class='tab_bg_1'>";
echo "<td >" . __('Database name') . "</td>";
echo "<td ><input type='text' size=50 name='pm_dbname' value='".$config->fields["pm_dbname"]."'>";
echo "</td></tr>\n";

echo "<tr class='tab_bg_1'>";
echo "<td >" . __('SQL user') . "</td>";
echo "<td ><input type='text' name='pm_dbserver_user' value='".$config->fields["pm_dbserver_user"]."'>";
Expand Down Expand Up @@ -310,6 +318,23 @@ function parseUrl( url ) {
Dropdown::showYesNo("maintenance", $config->fields['maintenance']);
echo "</td></tr>";

echo "<tr><td colspan='4'></td></tr>";

echo "<tr><th colspan='4'>".__('Processmaker system information')."</th></tr>";
if ($setup_ok) {
$info = $pm->systemInformation( );
echo '<tr><td>'._('Version').'</td><td>'.$info->version.'</td></tr>';
echo '<tr><td>'._('Web server').'</td><td>'.$info->webServer.'</td></tr>';
echo '<tr><td>'._('Server name').'</td><td>'.$info->serverName.'</td></tr>';
echo '<tr><td>'._('PHP version').'</td><td>'.$info->phpVersion.'</td></tr>';
echo '<tr><td>'._('DB version').'</td><td>'.$info->databaseVersion.'</td></tr>';
echo '<tr><td>'._('DB server IP').'</td><td>'.$info->databaseServerIp.'</td></tr>';
echo '<tr><td>'._('DB name').'</td><td>'.$info->databaseName.'</td></tr>';
echo '<tr><td>'._('User browser').'</td><td>'.$info->userBrowser.'</td></tr>';
echo '<tr><td>'._('User IP').'</td><td>'.$info->userIp.'</td></tr>';
} else {
echo '<tr><td>'._('Version').'</td><td>'.__('Not yet!').'</td></tr>';
}
$config->showFormButtons(array('candel'=>false));

return false;
Expand Down
2 changes: 1 addition & 1 deletion inc/db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function __construct() {
$this->dbhost = $config->fields['pm_dbserver_name'];
$this->dbuser = $config->fields['pm_dbserver_user'];
$this->dbpassword = Toolbox::decrypt($config->fields['pm_dbserver_passwd'], GLPIKEY);
$this->dbdefault = "wf_".$config->fields['pm_workspace'];
$this->dbdefault = $config->fields['pm_dbname'];
parent::__construct();
}
}
Expand Down
37 changes: 35 additions & 2 deletions inc/processmaker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,24 @@ function caseList( ) {
}
}

/**
* Summary of systemInformation
* returns information about the PM system
* Embedded systemInformation() PM web service call (definition: http://wiki.processmaker.com/index.php/ProcessMaker_WSDL_Web_Services#systemInformation.28.29)
* A session must be open before with login()
* @return an object containing information, or false when exception occured
*/
function systemInformation( ) {
try {
$pmSystemInfo = $this->pmSoapClient->systemInformation( array( 'sessionId' => $_SESSION["pluginprocessmaker"]["session"]["id"]) );
return $pmSystemInfo;
}
catch (Exception $e) {
Toolbox::logDebug( $e );
return false;
}
}

/**
* Summary of reassignCase
* 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.
Expand Down Expand Up @@ -1380,7 +1398,10 @@ public static function plugin_item_add_processmaker($parm) {
if (property_exists( $pmRouteCaseResponse, 'routing' )) {
// now tries to get some variables to setup content for new task and to append text to solved task
$txtForTasks = $myProcessMaker->getVariables( $myCase->getID(), array( "GLPI_ITEM_APPEND_TO_TASK",
"GLPI_ITEM_SET_STATUS" ) );
"GLPI_ITEM_SET_STATUS",
"GLPI_TICKET_FOLLOWUP_CONTENT",
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE",
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" ) );
$itemSetStatus = '';
if (array_key_exists( 'GLPI_ITEM_SET_STATUS', $txtForTasks )) {
$itemSetStatus = $txtForTasks[ 'GLPI_ITEM_SET_STATUS' ];
Expand All @@ -1390,14 +1411,26 @@ public static function plugin_item_add_processmaker($parm) {
} else {
$txtToAppendToTask = '';
}
$createFollowup = false; // by default
if (array_key_exists( 'GLPI_TICKET_FOLLOWUP_CONTENT', $txtForTasks ) && $txtForTasks[ 'GLPI_TICKET_FOLLOWUP_CONTENT' ] != '') {
$createFollowup = true;
}

// reset those variables
$resultSave = $myProcessMaker->sendVariables( $myCase->getID(), array( "GLPI_ITEM_APPEND_TO_TASK" => '',
"GLPI_ITEM_SET_STATUS" => '' ) );
"GLPI_ITEM_SET_STATUS" => '',
"GLPI_TICKET_FOLLOWUP_CONTENT" => '',
"GLPI_TICKET_FOLLOWUP_IS_PRIVATE" => '',
"GLPI_TICKET_FOLLOWUP_REQUESTTYPES_ID" => '' ) );

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

// create a followup if requested
if ($createFollowup && $itemType == 'Ticket') {
$myProcessMaker->addTicketFollowup( $itemId, $txtForTasks );
}

// and create GLPI tasks for the newly created PM tasks.
foreach ($pmRouteCaseResponse->routing as $route) {
$myProcessMaker->addTask( $myCase->fields['itemtype'],
Expand Down
4 changes: 2 additions & 2 deletions processmaker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
</authors>
<versions>
<version>
<num>3.2.5</num>
<num>3.2.8</num>
<compatibility>9.2</compatibility>
</version>
<version>
<num>3.2.5</num>
<num>3.2.8</num>
<compatibility>9.1</compatibility>
</version>
</versions>
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function plugin_version_processmaker() {
global $LANG;

return array ('name' => 'Process Maker',
'version' => '3.2.5',
'version' => '3.2.8',
'author' => 'Olivier Moron',
'homepage' => 'https://github.com/tomolimo/processmaker',
'minGlpiVersion' => '9.1');
Expand Down

0 comments on commit 128b704

Please sign in to comment.