Added possibility to set notification for tasks (and of course notification templates)
Added two new events per tasks (new and update) Added possibility to send spontaneous emails Fixed various CS typos Set version to 3.6.3 fixes #77
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
GLPI plugin that provides an interface with a customized ProcessMaker server (https://github.com/tomolimo/processmaker-server).
|
||||
|
||||
version 3.4.x is compatible with GLPI 9.2 and needs ProcessMaker either 3.0.1.8-RE-1.12 (https://github.com/tomolimo/processmaker-server/releases/tag/3.0.1.8-RE-1.12) or 3.3.0-RE-1.0 (https://github.com/tomolimo/processmaker-server/releases/tag/3.3.0-RE-1.0)
|
||||
version 3.4.x is compatible with GLPI 9.2 and needs ProcessMaker either 3.0.1.8-RE-1.12 (https://github.com/tomolimo/processmaker-server/releases/tag/3.0.1.8-RE-1.12) or 3.3.0-RE-1.x (https://github.com/tomolimo/processmaker-server/releases/tag/3.3.0-RE-1.5)
|
||||
|
||||
version 3.5.x is compatible with GLPI 9.3 and needs ProcessMaker 3.3.0-RE-1.x (https://github.com/tomolimo/processmaker-server/releases/latest)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ $result = PluginProcessmakerProcess::getSqlSearchResult(false, $search);
|
||||
|
||||
//if ($DB->numrows($result)) {
|
||||
// while ($data = $DB->fetch_array($result)) {
|
||||
if ($result->numrows()) {
|
||||
//if ($result->numrows()) {
|
||||
foreach ($result as $data) {
|
||||
$process_entities = PluginProcessmakerProcess::getEntitiesForProfileByProcess($data["id"], $_SESSION['glpiactiveprofile']['id'], true);
|
||||
$can_add = $data['max_cases_per_item'] == 0 || !isset($count_cases_per_item[$data["id"]]) || $count_cases_per_item[$data["id"]] < $data['max_cases_per_item'];
|
||||
@@ -82,7 +82,7 @@ if ($result->numrows()) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
$ret['results'] = $processes;
|
||||
$ret['count'] = $count;
|
||||
|
||||
@@ -79,13 +79,13 @@ $users = [];
|
||||
$count = 0;
|
||||
//if ($DB->numrows($result)) {
|
||||
// while ($data = $DB->fetch_assoc($result)) {
|
||||
if ($res->numrows()) {
|
||||
//if ($res->numrows()) {
|
||||
foreach ($res as $data) {
|
||||
$users[$data["id"]] = $dbu->formatUserName($data["id"], $data["name"], $data["realname"],
|
||||
$data["firstname"]);
|
||||
$logins[$data["id"]] = $data["name"];
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
if (!function_exists('dpuser_cmp')) {
|
||||
function dpuser_cmp($a, $b) {
|
||||
|
||||
@@ -14,7 +14,7 @@ switch ($_POST["action"]) {
|
||||
$case = new PluginProcessmakerCase;
|
||||
if ($case->getFromGUID($resultCase->caseId)) {
|
||||
$link = $case->getLinkURL();
|
||||
$task = new PluginProcessmakerTask();
|
||||
$task = new PluginProcessmakerTask($_POST['itemtype'].'Task');
|
||||
|
||||
$task->getFromDBByRequest([
|
||||
'WHERE' => [
|
||||
|
||||
@@ -265,27 +265,50 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
*/
|
||||
public function reassignTask ($delIndex, $newDelIndex, $delThread, $newDelThread, $newTech) {
|
||||
global $DB;
|
||||
$res = $DB->request('glpi_plugin_processmaker_tasks', [
|
||||
'AND' => [
|
||||
'plugin_processmaker_cases_id' => $this->getID(),
|
||||
'del_index' => $delIndex,
|
||||
'del_thead' => $delThread
|
||||
]
|
||||
]);
|
||||
//$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE plugin_processmaker_cases_id={$this->getID()} AND del_index=$delIndex AND del_thread=$delThread; ";
|
||||
//$res = $DB->query($query);
|
||||
//if ($DB->numrows($res) > 0) {
|
||||
// $row = $DB->fetch_array( $res );
|
||||
if ($row = $res->next()) {
|
||||
$glpi_task = new $row['itemtype'];
|
||||
$glpi_task->getFromDB( $row['items_id'] );
|
||||
|
||||
$itilobject_itemtype = $this->fields['itemtype']; //str_replace( 'Task', '', $row['itemtype'] );
|
||||
$dbu = new DbUtils;
|
||||
$pm_task_row = $dbu->getAllDataFromTable(PluginProcessmakerTask::getTable(), ['plugin_processmaker_cases_id' => $this->getID(), 'del_index' => $delIndex, 'del_thread' => $delThread]);
|
||||
if ($pm_task_row && count($pm_task_row) == 1) {
|
||||
$pm_task_row = array_shift($pm_task_row);
|
||||
$glpi_task = new $pm_task_row['itemtype'];
|
||||
$glpi_task->getFromDB( $pm_task_row['items_id'] );
|
||||
|
||||
$itilobject_itemtype = $this->fields['itemtype'];
|
||||
$foreignkey = getForeignKeyFieldForItemType( $itilobject_itemtype );
|
||||
|
||||
PluginProcessmakerProcessmaker::addWatcher( $itilobject_itemtype, $glpi_task->fields[ $foreignkey ], $newTech );
|
||||
|
||||
$glpi_task->update( [ 'id' => $row['items_id'], $foreignkey => $glpi_task->fields[ $foreignkey ], 'users_id_tech' => $newTech ]);
|
||||
$donotif = PluginProcessmakerNotificationTargetProcessmaker::saveNotificationState(false); // do not send notification yet
|
||||
$glpi_task->update( ['id' => $glpi_task->getID(), $foreignkey => $glpi_task->fields[$foreignkey], 'users_id_tech' => $newTech, 'update' => true] );
|
||||
PluginProcessmakerNotificationTargetProcessmaker::restoreNotificationState($donotif);
|
||||
|
||||
// Notification management
|
||||
// search if at least one active notification is existing for that pm task with that event 'task_update_'.$glpi_task->fields['taskcategories_id']
|
||||
$res = PluginProcessmakerNotificationTargetTask::getNotifications('task_update', $glpi_task->fields['taskcategories_id'], $this->fields['entities_id']);
|
||||
if ($res['notifications'] && count($res['notifications']) > 0) {
|
||||
$pm_task = new PluginProcessmakerTask($pm_task_row['itemtype']);
|
||||
$pm_task->getFromDB($pm_task_row['items_id']);
|
||||
NotificationEvent::raiseEvent($res['event'],
|
||||
$pm_task,
|
||||
['plugin_processmaker_cases_id' => $this->getID(),
|
||||
'itemtype' => $pm_task_row['itemtype'],
|
||||
'task_id' => $glpi_task->getID(),
|
||||
'old_users_id_tech' => $glpi_task->oldvalues['users_id_tech'],
|
||||
'is_private' => isset($glpi_task->fields['is_private']) ? $glpi_task->fields['is_private'] : 0,
|
||||
'entities_id' => $this->fields['entities_id'],
|
||||
'case' => $this
|
||||
]);
|
||||
} else {
|
||||
$item = new $itilobject_itemtype;
|
||||
$item->getFromDB($glpi_task->fields[$foreignkey]);
|
||||
NotificationEvent::raiseEvent('update_task',
|
||||
$item,
|
||||
['plugin_processmaker_cases_id' => $this->getID(),
|
||||
'itemtype' => $pm_task_row['itemtype'],
|
||||
'task_id' => $glpi_task->getID(),
|
||||
'is_private' => isset($glpi_task->fields['is_private']) ? $glpi_task->fields['is_private'] : 0
|
||||
]);
|
||||
}
|
||||
|
||||
// then update the delIndex and delThread
|
||||
//$query = "UPDATE glpi_plugin_processmaker_tasks SET del_index = $newDelIndex, del_thread = $newDelThread WHERE id={$row['id']}; ";
|
||||
@@ -294,7 +317,7 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
'del_index' => $newDelIndex,
|
||||
'del_thread' => $newDelThread
|
||||
], [
|
||||
'id' => $row['id']
|
||||
'id' => $pm_task_row['id']
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -694,14 +717,14 @@ class PluginProcessmakerCase extends CommonDBTM {
|
||||
$condition[] = ['is_active' => 1];
|
||||
if ($itemtype == 'Ticket') {
|
||||
$condition[] = ['is_incident' => 1];
|
||||
$is_itemtype = "AND is_incident=1";
|
||||
//$is_itemtype = "AND is_incident=1";
|
||||
if ($item->fields['type'] == Ticket::DEMAND_TYPE) {
|
||||
$condition[] = ['is_request' => 1];
|
||||
$is_itemtype = "AND is_request=1";
|
||||
//$is_itemtype = "AND is_request=1";
|
||||
}
|
||||
} else {
|
||||
$condition[] = ['is_'.strtolower($itemtype) => 1];
|
||||
$is_itemtype = "AND is_".strtolower($itemtype)."=1";
|
||||
//$is_itemtype = "AND is_".strtolower($itemtype)."=1";
|
||||
}
|
||||
PluginProcessmakerProcess::dropdown(['value' => 0,
|
||||
'entity' => $item->fields['entities_id'],
|
||||
|
||||
@@ -326,9 +326,6 @@ class PluginProcessmakerConfig extends CommonDBTM {
|
||||
foreach ($res as $row) {
|
||||
$pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'];
|
||||
}
|
||||
//foreach ($PM_DB->request( $query ) as $row) {
|
||||
// $pmGroups[ $row['CON_ID'] ] = $row['CON_VALUE'];
|
||||
//}
|
||||
Dropdown::showFromArray( 'pm_group_guid', $pmGroups, ['value' => $config->fields['pm_group_guid']] );
|
||||
} else {
|
||||
echo "<font color='red'>".__('Not connected');
|
||||
|
||||
120
inc/notificationtargetcase.class.php
Normal file
120
inc/notificationtargetcase.class.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/*
|
||||
* @version $Id: notificationtargettaskcategory.class.php tomolimo $
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
*/
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access directly to this file");
|
||||
}
|
||||
|
||||
// Class NotificationTarget
|
||||
class PluginProcessmakerNotificationTargetCase extends PluginProcessmakerNotificationTargetProcessmaker {
|
||||
|
||||
// type
|
||||
const EMAIL_RECIPIENTS = 200;
|
||||
|
||||
// user type
|
||||
const RECIPIENTS = 1;
|
||||
|
||||
/**
|
||||
* Summary of getEvents
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEvents() {
|
||||
return ['send_email' => __('Send email', 'processmaker')];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of addAdditionalTargets
|
||||
* @param mixed $event
|
||||
*/
|
||||
function addAdditionalTargets($event = '') {
|
||||
$this->notification_targets = [];
|
||||
$this->notification_targets_labels = [];
|
||||
$this->addTarget(self::RECIPIENTS, __('eMail recipients', 'processmaker'), self::EMAIL_RECIPIENTS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of addSpecificTargets
|
||||
* @param mixed $data
|
||||
* @param mixed $options
|
||||
*/
|
||||
function addSpecificTargets($data, $options) {
|
||||
|
||||
// test if we are in the good notification
|
||||
// then in this case add the targets from the ['recipients']
|
||||
if (isset($options['glpi_send_email'])) {
|
||||
// normalize $options['glpi_send_email'] to an array of email parameters
|
||||
$options['glpi_send_email'] = isset($options['glpi_send_email']['notifications_id']) ? [$options['glpi_send_email']] : $options['glpi_send_email'];
|
||||
|
||||
foreach($options['glpi_send_email'] as $params) {
|
||||
if (isset($params['notifications_id'])
|
||||
&& $params['notifications_id'] == $data['notifications_id']) {
|
||||
//Look for all targets whose type is Notification::ITEM_USER
|
||||
switch ($data['type']) {
|
||||
case self::EMAIL_RECIPIENTS:
|
||||
|
||||
switch ($data['items_id']) {
|
||||
|
||||
case self::RECIPIENTS :
|
||||
$this->addUsers($params);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no target is added to $this, then the notification will not be sent.
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add users from $options['glpi_send_email']['to']
|
||||
*
|
||||
* @param array $email_param should contain 'recipients'
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function addUsers($email_param = []) {
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
if (isset($email_param['recipients'])) {
|
||||
$id_list = []; // for users with ids
|
||||
$email_list = []; // for standalone emails
|
||||
|
||||
// normalize into array the recipient list
|
||||
$email_param['recipients'] = is_array($email_param['recipients']) ? $email_param['recipients'] : [$email_param['recipients']];
|
||||
foreach ($email_param['recipients'] as $user) {
|
||||
if (is_numeric($user)) {
|
||||
$id_list[] = intval($user);
|
||||
} else {
|
||||
$email_list[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->getDistinctUserSql()."
|
||||
FROM `glpi_users` ".
|
||||
$this->getProfileJoinSql()."
|
||||
WHERE `glpi_users`.`id` IN (".implode(',', $id_list).")";
|
||||
|
||||
foreach ($DB->request($query) as $data) {
|
||||
$this->addToRecipientsList($data);
|
||||
}
|
||||
|
||||
foreach($email_list as $email){
|
||||
$this->addToRecipientsList([
|
||||
'email' => $email,
|
||||
'language' => $CFG_GLPI["language"],
|
||||
'users_id' => -1
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
168
inc/notificationtargetprocessmaker.class.php
Normal file
168
inc/notificationtargetprocessmaker.class.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProcessmakerNotificationTargetProcessmaker short summary.
|
||||
*
|
||||
* PluginProcessmakerNotificationTargetProcessmaker description.
|
||||
*
|
||||
* Common notificationtarget class for cases and tasks
|
||||
*
|
||||
* @version 1.0
|
||||
* @author MoronO
|
||||
*/
|
||||
class PluginProcessmakerNotificationTargetProcessmaker extends NotificationTarget {
|
||||
|
||||
/**
|
||||
* Summary of saveNotificationState
|
||||
* @param mixed $donotif
|
||||
* @return mixed
|
||||
*/
|
||||
static function saveNotificationState($donotif) {
|
||||
global $CFG_GLPI;
|
||||
$savenotif = $CFG_GLPI["use_notifications"];
|
||||
if (!$donotif) {
|
||||
$CFG_GLPI["use_notifications"] = false;
|
||||
}
|
||||
return $savenotif;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of restoreNotificationState
|
||||
* @param mixed $savenotif
|
||||
*/
|
||||
static function restoreNotificationState($savenotif) {
|
||||
global $CFG_GLPI;
|
||||
$CFG_GLPI["use_notifications"] = $savenotif;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of getSubjectPrefix
|
||||
* @param mixed $event
|
||||
* @return string
|
||||
*/
|
||||
function getSubjectPrefix($event = '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of getTags
|
||||
*/
|
||||
public function getTags() {
|
||||
|
||||
$tags = ['process.category' => __('Process category', 'processmaker'),
|
||||
'process.categoryid' => __('Process category id', 'processmaker'),
|
||||
'process.categorycomment' => __('Process category comment', 'processmaker'),
|
||||
'case.id' => __('Case id', 'processmaker'),
|
||||
'case.title' => __('Case title', 'processmaker'),
|
||||
'case.description' => __('Case description', 'processmaker'),
|
||||
'case.url' => __('URL'),
|
||||
'var.XXX' => __('Case variable \'XXX\'', 'processmaker'),
|
||||
'array.YYY' => __('List of values in \'YYY\' array', 'processmaker'),
|
||||
'array.numberofYYY' => __('Number of rows in \'YYY\' array', 'processmaker'),
|
||||
'array.YYY.colname' => __('Value for colname in case array \'YYY\'', 'processamker')
|
||||
];
|
||||
|
||||
foreach ($tags as $tag => $label) {
|
||||
$elt= ['tag' => $tag,
|
||||
'label' => $label,
|
||||
'value' => true];
|
||||
if ($tag == 'var.XXX') {
|
||||
$elt['allowed_values'] = [__('XXX is to be replaced by any case variable names', 'processmaker')];
|
||||
}
|
||||
if ($tag == 'array.YYY') {
|
||||
$elt['allowed_values'] = [__('YYY is to be replaced by any array variables', 'processmaker')];
|
||||
$elt['foreach'] = true;
|
||||
}
|
||||
$this->addTagToList($elt);
|
||||
}
|
||||
|
||||
asort($this->tag_descriptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all data needed for template processing
|
||||
**/
|
||||
public function addDataForTemplate($event, $options = []) {
|
||||
global $PM_DB, $CFG_GLPI;
|
||||
|
||||
$excluded = ['_VAR_CHANGED_',
|
||||
'PIN',
|
||||
'APPLICATION',
|
||||
'PROCESS',
|
||||
'TASK',
|
||||
'INDEX',
|
||||
'USER_LOGGED',
|
||||
'USR_USERNAME',
|
||||
'APP_NUMBER',
|
||||
'GLPI_.*',
|
||||
'SYS_.*'
|
||||
];
|
||||
|
||||
$process = new PluginProcessmakerProcess;
|
||||
|
||||
$process->getFromDB($options['case']->fields['plugin_processmaker_processes_id']);
|
||||
$taskcat_id = $process->fields['taskcategories_id'];
|
||||
|
||||
// set defaults to all
|
||||
foreach ($this->tags as $key => $val) {
|
||||
$this->data["##$key##"] = "-";
|
||||
}
|
||||
|
||||
// get case variable values
|
||||
$res = $PM_DB->query("SELECT APP_DATA, APP_TITLE, APP_DESCRIPTION FROM APPLICATION WHERE APP_NUMBER = ".$options['case']->fields['id']);
|
||||
if ($res && $PM_DB->numrows($res) == 1) {
|
||||
// get all the case variables from $PM_DB
|
||||
$caserow = $PM_DB->fetch_assoc($res);
|
||||
$case_variables = unserialize($caserow['APP_DATA']);
|
||||
$excluded_re = '/^(' . implode('|', $excluded) . ')$/u';
|
||||
foreach ($case_variables as $key => $val) {
|
||||
if (!preg_match($excluded_re, $key)) {
|
||||
if (is_array($val)) {
|
||||
// add numberof for count of rows
|
||||
$this->data["##array.numberof$key##"] = count($val);
|
||||
// get the keys/vals of the sub-array
|
||||
foreach ($val as $row) {
|
||||
foreach ($row as $col_name => $col_val) {
|
||||
$this->data["array.$key"][]["##array.$key.$col_name##"] = $col_val;
|
||||
$this->data["##lang.array.$key.$col_name##"] = $col_name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->data["##var.$key##"] = $val;
|
||||
$this->data["##lang.var.$key##"] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->data['##case.title##'] = $caserow['APP_TITLE'];
|
||||
$this->data['##case.description##'] = $caserow['APP_DESCRIPTION'];
|
||||
}
|
||||
|
||||
// case id
|
||||
$this->data['##case.id##'] = $options['case']->fields['id'];
|
||||
|
||||
// case URL
|
||||
$this->data['##case.url##'] = $CFG_GLPI["url_base"]."/index.php?redirect=".urlencode("/plugins/processmaker/front/case.form.php?id=".$options['case']->fields['id']);
|
||||
|
||||
// parent task information: meta data on process
|
||||
// will get parent of task which is the process task category
|
||||
$tmp_taskcatinfo['name'] = DropdownTranslation::getTranslatedValue( $taskcat_id, 'TaskCategory', 'name');
|
||||
$tmp_taskcatinfo['comment'] = DropdownTranslation::getTranslatedValue( $taskcat_id, 'TaskCategory', 'comment');
|
||||
// process title
|
||||
$this->data['##process.categoryid##'] = $taskcat_id;
|
||||
$this->data['##process.category##'] = $tmp_taskcatinfo['name'];
|
||||
$this->data['##process.categorycomment##'] = $tmp_taskcatinfo['comment'];
|
||||
|
||||
// add labels
|
||||
$this->getTags();
|
||||
foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
|
||||
if (!isset($this->data[$tag])) {
|
||||
$this->data[$tag] = $values['label'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
320
inc/notificationtargettask.class.php
Normal file
320
inc/notificationtargettask.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -190,7 +190,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
] );
|
||||
}
|
||||
// here we should take into account translations if any
|
||||
if ( isset($taskArray[ $taskGUID ])) {
|
||||
if (isset($taskArray[ $taskGUID ])) {
|
||||
foreach ($taskArray[ $taskGUID ] as $langTask => $taskL) {
|
||||
// look for 'name' field
|
||||
if ($loc_id = DropdownTranslation::getTranslationID( $taskCat->getID(), 'TaskCategory', 'name', $langTask )) {
|
||||
@@ -318,7 +318,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
);
|
||||
//$query = "SELECT * FROM `".PluginProcessmakerCase::getTable()."` WHERE `plugin_processmaker_processes_id` = ".$key;
|
||||
//$res = $DB->query($query);
|
||||
if ($DB->numrows($res) === 0) {
|
||||
if ($res->numrows() === 0) {
|
||||
// and if no will delete the process
|
||||
$proc->delete(['id' => $key]);
|
||||
// delete main taskcat
|
||||
@@ -815,13 +815,13 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
* @param $count true if execute an count(*),
|
||||
* @param $search pattern
|
||||
*
|
||||
* @return mysql result set.
|
||||
* @return DBmysqlIterator.
|
||||
**/
|
||||
static function getSqlSearchResult ($count = true, $search = []) {
|
||||
global $DB, $CFG_GLPI;
|
||||
$query = [];
|
||||
$where = '';
|
||||
$orderby = '';
|
||||
//$where = '';
|
||||
//$orderby = '';
|
||||
|
||||
if (isset($_REQUEST['condition']) && isset($_SESSION['glpicondition'][$_REQUEST['condition']])) {
|
||||
//$where = ' WHERE '.$_SESSION['glpicondition'][$_REQUEST['condition']]; //glpi_plugin_processmaker_processes.is_active=1 ';
|
||||
@@ -838,7 +838,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
//$orderby = " ORDER BY glpi_plugin_processmaker_processes.name ASC";
|
||||
}
|
||||
|
||||
if (!empty($search) && $search!=$CFG_GLPI["ajax_wildcard"]) {
|
||||
if (!empty($search) && $search != $CFG_GLPI["ajax_wildcard"]) {
|
||||
$query['WHERE']['AND']['OR']['glpi_plugin_processmaker_processes.name'] = $search;
|
||||
$query['WHERE']['AND']['OR']['glpi_plugin_processmaker_processes.comment'] = $search;
|
||||
//$where .= " AND (glpi_plugin_processmaker_processes.name $search
|
||||
@@ -847,7 +847,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
$query['FROM'] = 'glpi_plugin_processmaker_processes';
|
||||
//$query = "SELECT $fields FROM glpi_plugin_processmaker_processes ".$where." ".$orderby.";";
|
||||
//return $DB->query($query);
|
||||
$r= $DB->request($query);
|
||||
//$r= $DB->request($query);
|
||||
return $DB->request($query);
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
* @return mixed
|
||||
*/
|
||||
static function getProcessName($pid, $link = 0) {
|
||||
global $DB;
|
||||
global $DB, $CFG_GLPI;
|
||||
$process='';
|
||||
if ($link==2) {
|
||||
$process = ["name" => "",
|
||||
@@ -872,8 +872,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
//if ($result && $DB->numrows($result)==1) {
|
||||
// $data = $DB->fetch_assoc($result);
|
||||
if ($res && $res->numrows() == 1) {
|
||||
$processname = $res['name'];//$data["name"];
|
||||
if ($link==2) {
|
||||
// $processname = $res['name'];//$data["name"];
|
||||
$data = $res->next();
|
||||
$processname = $data["name"];
|
||||
if ($link == 2) {
|
||||
$process["name"] = $processname;
|
||||
$process["link"] = $CFG_GLPI["root_doc"]."/plugins/processmaker/front/process.form.php?id=".$pid;
|
||||
$process["comment"] = __('Name')." : ".$processname."<br>".__('Comments').
|
||||
@@ -908,10 +910,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
]
|
||||
]
|
||||
]);
|
||||
$query = "SELECT `entities_id`, `is_recursive`
|
||||
FROM `glpi_plugin_processmaker_processes_profiles`
|
||||
WHERE `plugin_processmaker_processes_id` = '$processes_id'
|
||||
AND `profiles_id` = '$profiles_id'";
|
||||
//$query = "SELECT `entities_id`, `is_recursive`
|
||||
// FROM `glpi_plugin_processmaker_processes_profiles`
|
||||
// WHERE `plugin_processmaker_processes_id` = '$processes_id'
|
||||
// AND `profiles_id` = '$profiles_id'";
|
||||
|
||||
$entities = [];
|
||||
//foreach ($DB->request($query) as $data) {
|
||||
@@ -961,6 +963,5 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
||||
echo "</p>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -89,8 +89,8 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
]
|
||||
]
|
||||
]);
|
||||
$query = "SELECT `$selfTable`.`items_id` as taskID from $selfTable
|
||||
WHERE `$selfTable`.`del_thread_status` = '".self::OPEN."' AND `$selfTable`.`plugin_processmaker_cases_id` = '$case_id';";
|
||||
//$query = "SELECT `$selfTable`.`items_id` as taskID from $selfTable
|
||||
// WHERE `$selfTable`.`del_thread_status` = '".self::OPEN."' AND `$selfTable`.`plugin_processmaker_cases_id` = '$case_id';";
|
||||
|
||||
//$query = "SELECT $itemTypeTaskTable.id as taskID from $itemTypeTaskTable
|
||||
// INNER JOIN $selfTable on $selfTable.items_id=$itemTypeTaskTable.id
|
||||
@@ -183,7 +183,7 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
]
|
||||
]
|
||||
);
|
||||
$query = "SELECT * FROM `glpi_plugin_processmaker_tasks` WHERE `plugin_processmaker_cases_id`={$case->fields['id']} AND `del_thread_status`='OPEN'";
|
||||
//$query = "SELECT * FROM `glpi_plugin_processmaker_tasks` WHERE `plugin_processmaker_cases_id`={$case->fields['id']} AND `del_thread_status`='OPEN'";
|
||||
//foreach ($DB->request($query) as $task) {
|
||||
foreach ($res as $task) {
|
||||
$tasks[$task['del_index']] = $task;
|
||||
@@ -233,7 +233,7 @@ class PluginProcessmakerTask extends CommonITILTask
|
||||
]);
|
||||
//$res = $PM_DB->query("SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='{$case->fields['case_guid']}' AND DEL_INDEX_PARENT={$task->delIndex} AND SA_STATUS='ACTIVE'");
|
||||
//if ($res && $PM_DB->numrows($res) == 1) {
|
||||
if ($row = $res->next() && $res->numrows() == 1) {
|
||||
if ($res->numrows() == 1 && $row = $res->next()) {
|
||||
//$row = $PM_DB->fetch_assoc($res);
|
||||
$loc_case = new PluginProcessmakerCase;
|
||||
$loc_case->getFromGUID($row['APP_UID']);
|
||||
|
||||
@@ -18,11 +18,19 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
{
|
||||
|
||||
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
|
||||
return __('Task List', 'processmaker');
|
||||
if ($item->getType() == 'TaskCategory') {
|
||||
$pmtaskcat = new PluginProcessmakerTaskCategory;
|
||||
if ($pmtaskcat->getFromDBbyCategory($item->fields['id'])) {
|
||||
return __('Process task', 'processmaker');
|
||||
} else {
|
||||
return ''; // means no tab
|
||||
}
|
||||
}
|
||||
return __('Task list', 'processmaker');
|
||||
}
|
||||
|
||||
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
static function displayTabContentForProcess(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
self::title($item);
|
||||
@@ -62,9 +70,9 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
'pm.plugin_processmaker_processes_id' => $item->getId()
|
||||
]
|
||||
]);
|
||||
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`is_start`, gl.name, gl.completename, gl.`comment`, pm.is_active, pm.is_subprocess FROM glpi_plugin_processmaker_taskcategories AS pm
|
||||
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
||||
WHERE pm.plugin_processmaker_processes_id=".$item->getID().";";
|
||||
//$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`is_start`, gl.name, gl.completename, gl.`comment`, pm.is_active, pm.is_subprocess FROM glpi_plugin_processmaker_taskcategories AS pm
|
||||
// LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
||||
// WHERE pm.plugin_processmaker_processes_id=".$item->getID().";";
|
||||
|
||||
//foreach ($DB->request($query) as $taskCat) {
|
||||
foreach ($res as $taskCat) {
|
||||
@@ -111,19 +119,125 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print a good title for task categories tab
|
||||
* add button for re-synchro of taskcategory list (only if rigths are w)
|
||||
* @return nothing (display)
|
||||
**/
|
||||
* Summary of displayTabContentForTaskCategory
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $tabnum
|
||||
* @param mixed $withtemplate
|
||||
* @return boolean
|
||||
*/
|
||||
static function displayTabContentForTaskCategory(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
global $DB, $CFG_GLPI;
|
||||
|
||||
$is_taskcat = false;
|
||||
$processes_id = 0;
|
||||
$pmtaskcat = new PluginProcessmakerTaskCategory;
|
||||
$is_taskcat = $pmtaskcat->getFromDBbyCategory($item->fields['id']);
|
||||
$processes_id = $pmtaskcat->fields['plugin_processmaker_processes_id'];
|
||||
|
||||
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
|
||||
|
||||
echo "<tr><th colspan='8'>".__('Process task', 'processmaker')."</th></tr>";
|
||||
echo "<tr><th>".__('Process name', 'processmaker')."</th>";
|
||||
echo "<th>".__('Task name', 'processmaker')."</th>";
|
||||
|
||||
echo "<th>".__('Complete name')."</th>" .
|
||||
"<th>".__('Start', 'processmaker')."</th>" .
|
||||
"<th>".__('Task GUID', 'processmaker')."</th>" .
|
||||
"<th>".__('Comments')."</th>" .
|
||||
"<th>".__('Active')."</th>" .
|
||||
"<th>".__('Sub-process', 'processmaker')."</th>" .
|
||||
"</tr>";
|
||||
|
||||
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`is_start`, glp.name as 'pname', gl.name, gl.completename, gl.`comment`, pm.is_active, pm.is_subprocess FROM glpi_plugin_processmaker_taskcategories AS pm
|
||||
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
||||
LEFT JOIN glpi_taskcategories AS glp ON glp.id=gl.taskcategories_id
|
||||
WHERE pm.taskcategories_id=".$item->getID().";";
|
||||
|
||||
foreach ($DB->request($query) as $taskCat) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
|
||||
echo "<td class='b'><a href='";
|
||||
echo Toolbox::getItemTypeFormURL('PluginProcessmakerProcess') . "?id=" . $processes_id . "'>" . $taskCat['pname'];
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (" . $processes_id . ")";
|
||||
}
|
||||
echo "</a></td>";
|
||||
echo "<td class='b'>";
|
||||
echo $taskCat['name'];
|
||||
|
||||
if ($_SESSION["glpiis_ids_visible"]) {
|
||||
echo " (" . $taskCat['taskcategories_id'] . ")";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "<td>" . $taskCat['completename'] . "</td>";
|
||||
|
||||
echo "<td class='center'>";
|
||||
if ($taskCat['is_start']) {
|
||||
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
|
||||
__('Start', 'processmaker')."\">";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "<td >".$taskCat['pm_task_guid']."</td>";
|
||||
|
||||
echo "<td>".$taskCat['comment']."</td>";
|
||||
|
||||
echo "<td class='center'>";
|
||||
if ($taskCat['is_active']) {
|
||||
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
|
||||
__('Active')."\">";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='center'>";
|
||||
if ($taskCat['is_subprocess']) {
|
||||
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
|
||||
__('Sub-process', 'processmaker')."\">";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table></div>";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Summary of displayTabContentForItem
|
||||
* @param CommonGLPI $item
|
||||
* @param mixed $tabnum
|
||||
* @param mixed $withtemplate
|
||||
* @return boolean
|
||||
*/
|
||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
|
||||
$ret = false;
|
||||
switch ($item->getType()) {
|
||||
case 'PluginProcessmakerProcess':
|
||||
$ret = self::displayTabContentForProcess($item, $tabnum, $withtemplate);
|
||||
break;
|
||||
case 'TaskCategory':
|
||||
$ret = self::displayTabContentForTaskCategory($item, $tabnum, $withtemplate);
|
||||
break;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a good title for task categories tab
|
||||
* add button for re-synchro of taskcategory list (only if rigths are w)
|
||||
* @return nothing (display)
|
||||
**/
|
||||
static function title(CommonGLPI $item) {
|
||||
global $CFG_GLPI;
|
||||
|
||||
$buttons = [];
|
||||
$title = __('Synchronize Task List', 'processmaker');
|
||||
|
||||
if (Session::haveRight('plugin_processmaker_config', UPDATE)) {
|
||||
$buttons["process.form.php?refreshtask=1&id=".$item->getID()] = $title;
|
||||
$title = __('Synchronize Task List', 'processmaker');
|
||||
$buttons = ["process.form.php?refreshtask=1&id=".$item->getID() => $title];
|
||||
$pic = $CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/gears.png";
|
||||
if ($item->fields['maintenance']) {
|
||||
$pic = $CFG_GLPI["root_doc"] . "/plugins/processmaker/pics/verysmall-under_maintenance.png";
|
||||
|
||||
@@ -23,7 +23,7 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
* @param $used array: Already used items ID: not to display in dropdown
|
||||
* @param $search pattern
|
||||
*
|
||||
* @return mysql result set.
|
||||
* @return DBmysqlIterator
|
||||
**/
|
||||
static function getSqlSearchResult ($taskId, $count = true, $right = "all", $entity_restrict = -1, $value = 0,
|
||||
$used = [], $search = '', $limit = '') {
|
||||
@@ -104,12 +104,12 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
|
||||
//$where .= " AND `glpi_users`.`id` NOT IN (";
|
||||
if (is_numeric($value)) {
|
||||
$first = false;
|
||||
//$first = false;
|
||||
//$where .= $value;
|
||||
$used[] = $value;
|
||||
//$query2['WHERE']['AND']['NOT']['glpi_users.id'] = $value;
|
||||
} else {
|
||||
$first = true;
|
||||
//$first = true;
|
||||
}
|
||||
//$query2['WHERE']['AND']['NOT']['glpi_users.id'] = $used;
|
||||
//foreach ($used as $val) {
|
||||
@@ -258,7 +258,7 @@ class PluginProcessmakerUser extends CommonDBTM {
|
||||
* - used : array / Already used items ID: not to display in dropdown (default empty)
|
||||
* - on_change : string / value to transmit to "onChange"
|
||||
*
|
||||
* @param $options possible options
|
||||
* @param $options array of possible options
|
||||
*
|
||||
* @return int (print out an HTML select box)
|
||||
**/
|
||||
|
||||
@@ -9,4 +9,5 @@ function processmaker_install() {
|
||||
// add configuration singleton
|
||||
$query = "INSERT INTO `glpi_plugin_processmaker_configs` (`id`) VALUES (1);";
|
||||
$DB->query( $query ) or die("error creating default record in glpi_plugin_processmaker_configs" . $DB->error());
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$(function () {
|
||||
$(function () {
|
||||
$(document).ajaxComplete(function (event, jqXHR, ajaxOptions) {
|
||||
//debugger;
|
||||
var pattern = /##processmaker.*(##|...)/g;
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
}
|
||||
$('input[type="checkbox"][value="PluginProcessmakerTask"]').parents('li').first().hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -27,17 +27,17 @@
|
||||
<version>
|
||||
<num>3.3.8</num>
|
||||
<compatibility>9.1</compatibility>
|
||||
</version>
|
||||
<version>
|
||||
<num>3.4.12</num>
|
||||
<compatibility>9.2</compatibility>
|
||||
</version>
|
||||
<version>
|
||||
<num>3.4.10</num>
|
||||
<compatibility>9.2</compatibility>
|
||||
</version>
|
||||
<version>
|
||||
<num>3.5.2</num>
|
||||
<num>3.5.3</num>
|
||||
<compatibility>9.3</compatibility>
|
||||
</version>
|
||||
<version>
|
||||
<num>3.6.2</num>
|
||||
<num>3.6.3</num>
|
||||
<compatibility>9.4</compatibility>
|
||||
</version>
|
||||
</versions>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// used for case cancellation
|
||||
define("CANCEL", 256);
|
||||
define('PROCESSMAKER_VERSION', '3.6.2');
|
||||
define('PROCESSMAKER_VERSION', '3.6.3');
|
||||
|
||||
// Init the hooks of the plugins -Needed
|
||||
function plugin_init_processmaker() {
|
||||
@@ -14,9 +14,11 @@ function plugin_init_processmaker() {
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerProcessmaker');
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerCase', ['addtabon' => $objects]);
|
||||
Plugin::registerClass('PluginProcessmakerCase', ['addtabon' => $objects, 'notificationtemplates_types' => true]);
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerTaskCategory');
|
||||
Plugin::registerClass('PluginProcessmakerTask', ['notificationtemplates_types' => true]);
|
||||
|
||||
Plugin::registerClass('PluginProcessmakerTaskCategory', ['addtabon' => 'TaskCategory']);
|
||||
|
||||
if (Session::haveRightsOr("config", [READ, UPDATE])) {
|
||||
Plugin::registerClass('PluginProcessmakerConfig', ['addtabon' => 'Config']);
|
||||
|
||||
Reference in New Issue
Block a user