Changed way of preventing notifications, use_mailing replaced by use_notifications due to 9.2 compatibility
Fixes #41 Added initialization for $tasks array Fixes #42 Set version to 3.2.2
This commit is contained in:
@@ -51,7 +51,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
//$config = PluginProcessmakerConfig::getInstance() ;
|
//$config = PluginProcessmakerConfig::getInstance() ;
|
||||||
//$database = $config->fields['pm_workspace'] ;
|
//$database = $config->fields['pm_workspace'] ;
|
||||||
$translates = false;
|
$translates = false;
|
||||||
$mapLangs = array( );
|
$mapLangs = [];
|
||||||
// if (class_exists('DropdownTranslation')) {
|
// if (class_exists('DropdownTranslation')) {
|
||||||
// to force rights to add translations
|
// to force rights to add translations
|
||||||
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name';
|
$_SESSION['glpi_dropdowntranslations']['TaskCategory']['name'] = 'name';
|
||||||
@@ -67,8 +67,8 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
|
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
|
||||||
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
|
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
|
||||||
WHERE TASK.TAS_TYPE = 'NORMAL' AND TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
|
WHERE TASK.TAS_TYPE = 'NORMAL' AND TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
|
||||||
$taskArray = array();
|
$taskArray = [];
|
||||||
$defaultLangTaskArray=array();
|
$defaultLangTaskArray = [];
|
||||||
foreach ($PM_DB->request( $query ) as $task) {
|
foreach ($PM_DB->request( $query ) as $task) {
|
||||||
if ($task['CON_LANG'] == $lang) {
|
if ($task['CON_LANG'] == $lang) {
|
||||||
$defaultLangTaskArray[ $task['TAS_UID'] ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'];
|
$defaultLangTaskArray[ $task['TAS_UID'] ][ $task['CON_CATEGORY'] ] = $task['CON_VALUE'];
|
||||||
@@ -82,6 +82,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
|
|
||||||
$pmtask = new PluginProcessmakerTaskCategory;
|
$pmtask = new PluginProcessmakerTaskCategory;
|
||||||
$currentasksinprocess = getAllDatasFromTable($pmtask->getTable(), 'is_active = 1 AND processes_id = '.$this->getID());
|
$currentasksinprocess = getAllDatasFromTable($pmtask->getTable(), 'is_active = 1 AND processes_id = '.$this->getID());
|
||||||
|
$tasks=[];
|
||||||
foreach($currentasksinprocess as $task){
|
foreach($currentasksinprocess as $task){
|
||||||
$tasks[$task['pm_task_guid']] = $task;
|
$tasks[$task['pm_task_guid']] = $task;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -931,7 +931,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
* 0 : nothing to do
|
* 0 : nothing to do
|
||||||
*/
|
*/
|
||||||
static function cronPMTaskActions($task) {
|
static function cronPMTaskActions($task) {
|
||||||
global $DB, $CFG_GLPI, $PM_DB;
|
global $DB, $PM_DB;
|
||||||
|
|
||||||
if (!isset($PM_DB)) {
|
if (!isset($PM_DB)) {
|
||||||
$PM_DB = new PluginProcessmakerDB;
|
$PM_DB = new PluginProcessmakerDB;
|
||||||
@@ -976,13 +976,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
throw new Exception("Can't claim case");
|
throw new Exception("Can't claim case");
|
||||||
}
|
}
|
||||||
|
|
||||||
$donotif = $CFG_GLPI["use_mailing"];
|
// do not send notifications
|
||||||
$CFG_GLPI["use_mailing"] = false;
|
$donotif = self::saveNotification(false);
|
||||||
|
|
||||||
// now manage tasks associated with item
|
// now manage tasks associated with item
|
||||||
$pm->claimTask( $postdata['APP_UID'], $postdata['DEL_INDEX'], $taskaction['users_id'] );
|
$pm->claimTask( $postdata['APP_UID'], $postdata['DEL_INDEX'], $taskaction['users_id'] );
|
||||||
|
|
||||||
$CFG_GLPI["use_mailing"] = $donotif;
|
self::restoreNotification($donotif);
|
||||||
|
|
||||||
}
|
}
|
||||||
$myCase = new PluginProcessmakerCase;
|
$myCase = new PluginProcessmakerCase;
|
||||||
@@ -1449,27 +1449,24 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
* @return boolean true if added,
|
* @return boolean true if added,
|
||||||
*/
|
*/
|
||||||
public static function addWatcher( $itemType, $itemId, $techId ) {
|
public static function addWatcher( $itemType, $itemId, $techId ) {
|
||||||
global $CFG_GLPI; // currently use $CFG_GLPI to disable notif
|
if ($techId && $itemType != '' && $itemId > 0) {
|
||||||
//$plug = new Plugin;
|
|
||||||
if ($techId && $itemType != '' && $itemId > 0) { //!$plug->isActivated('arbehaviours') &&
|
|
||||||
$glpi_item = getItemForItemtype( $itemType );
|
$glpi_item = getItemForItemtype( $itemType );
|
||||||
$glpi_item->getFromDB( $itemId );
|
$glpi_item->getFromDB( $itemId );
|
||||||
|
|
||||||
// then we should check if this user has rights on the item, if not then we must add it to the watcher list!
|
// then we should check if this user has rights on the item, if not then we must add it to the watcher list!
|
||||||
$glpi_item = getItemForItemtype( $itemType );
|
$glpi_item = getItemForItemtype( $itemType );
|
||||||
$glpi_item->getFromDB( $itemId );
|
$glpi_item->getFromDB( $itemId );
|
||||||
//$user_entities = Profile_User::getUserEntities( $techId, true, true );
|
|
||||||
//$user_can_view = in_array( $glpi_item->fields['entities_id'], $user_entities );
|
|
||||||
if (!$glpi_item->isUser( CommonITILActor::REQUESTER, $techId )
|
if (!$glpi_item->isUser( CommonITILActor::REQUESTER, $techId )
|
||||||
&& !$glpi_item->isUser( CommonITILActor::OBSERVER, $techId )
|
&& !$glpi_item->isUser( CommonITILActor::OBSERVER, $techId )
|
||||||
&& !$glpi_item->isUser( CommonITILActor::ASSIGN, $techId ) ) {
|
&& !$glpi_item->isUser( CommonITILActor::ASSIGN, $techId ) ) {
|
||||||
//&& !$user_can_view ) {
|
|
||||||
// then we must add this tech user to watcher list
|
// then we must add this tech user to watcher list
|
||||||
$glpi_item_user = getItemForItemtype( $glpi_item->getType() . "_User" );
|
$glpi_item_user = getItemForItemtype( $glpi_item->getType() . "_User" );
|
||||||
$donotif = $CFG_GLPI["use_mailing"];
|
|
||||||
$CFG_GLPI["use_mailing"] = false;
|
// do not send notifications
|
||||||
$glpi_item_user->add( array( $glpi_item::getForeignKeyField() => $glpi_item->getId(), 'users_id' => $techId, 'type' => CommonITILActor::OBSERVER, '_disablenotif' => true ) ); // , '_no_notif' => true
|
$donotif = self::saveNotification(false);
|
||||||
$CFG_GLPI["use_mailing"]= $donotif;
|
$glpi_item_user->add( array( $glpi_item::getForeignKeyField() => $glpi_item->getId(), 'users_id' => $techId, 'type' => CommonITILActor::OBSERVER, '_disablenotif' => true ) );
|
||||||
|
self::restoreNotification($donotif);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1496,7 +1493,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public function addTask( $itemType, $itemId, $caseInfo, $delIndex, $techId, $groupId, $pmTaskId, $options=array() ) {
|
public function addTask( $itemType, $itemId, $caseInfo, $delIndex, $techId, $groupId, $pmTaskId, $options=array() ) {
|
||||||
global $DB, $PM_DB, $LANG, $CFG_GLPI, $_SESSION;
|
global $DB, $PM_DB, $LANG, $_SESSION;
|
||||||
|
|
||||||
$default_options = array(
|
$default_options = array(
|
||||||
'txtTaskContent' => '',
|
'txtTaskContent' => '',
|
||||||
@@ -1610,13 +1607,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
$input['groups_id_tech'] = $groups_id_tech;
|
$input['groups_id_tech'] = $groups_id_tech;
|
||||||
}
|
}
|
||||||
|
|
||||||
$donotif = $CFG_GLPI["use_mailing"];
|
$donotif = self::saveNotification($options['notif']);
|
||||||
if (!$options['notif']) {
|
|
||||||
//$input['_no_notif'] = true;
|
|
||||||
$CFG_GLPI["use_mailing"] = false;
|
|
||||||
}
|
|
||||||
$glpi_task->add( Toolbox::addslashes_deep( $input ) );
|
$glpi_task->add( Toolbox::addslashes_deep( $input ) );
|
||||||
$CFG_GLPI["use_mailing"] = $donotif;
|
self::restoreNotification($donotif);
|
||||||
|
|
||||||
if ($glpi_task->getId() > 0) {
|
if ($glpi_task->getId() > 0) {
|
||||||
// stores link to task in DB
|
// stores link to task in DB
|
||||||
@@ -1625,6 +1618,24 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static function saveNotification($donotif) {
|
||||||
|
global $CFG_GLPI;
|
||||||
|
// $CFG_GLPI["use_notifications"] is available since 9.2
|
||||||
|
$savenotif = isset($CFG_GLPI["use_notifications"]) ? $CFG_GLPI["use_notifications"] : $CFG_GLPI["use_mailing"];
|
||||||
|
if (!$donotif) {
|
||||||
|
isset($CFG_GLPI["use_notifications"]) ? $CFG_GLPI["use_notifications"] = false : $CFG_GLPI["use_mailing"] = false;
|
||||||
|
}
|
||||||
|
return $savenotif;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static function restoreNotification($savenotif) {
|
||||||
|
global $CFG_GLPI;
|
||||||
|
// $CFG_GLPI["use_notifications"] is available since 9.2
|
||||||
|
isset($CFG_GLPI["use_notifications"]) ? $CFG_GLPI["use_notifications"] = $savenotif : $CFG_GLPI["use_mailing"] = $savenotif;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of add1stTask
|
* Summary of add1stTask
|
||||||
* adds a GLPI task to ticket
|
* adds a GLPI task to ticket
|
||||||
@@ -1714,7 +1725,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
* @param mixed $newTech
|
* @param mixed $newTech
|
||||||
*/
|
*/
|
||||||
public function reassignTask ( $caseId, $delIndex, $newDelIndex, $newTech) {
|
public function reassignTask ( $caseId, $delIndex, $newDelIndex, $newTech) {
|
||||||
global $DB, $CFG_GLPI; // $CFG_GLPI is only used to _disablenotif
|
global $DB;
|
||||||
|
|
||||||
$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE case_id='$caseId' and del_index=$delIndex; ";
|
$query = "SELECT * FROM glpi_plugin_processmaker_tasks WHERE case_id='$caseId' and del_index=$delIndex; ";
|
||||||
$res = $DB->query($query);
|
$res = $DB->query($query);
|
||||||
@@ -1726,23 +1737,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
$itemType = str_replace( 'Task', '', $row['itemtype'] );
|
$itemType = str_replace( 'Task', '', $row['itemtype'] );
|
||||||
$foreignkey = getForeignKeyFieldForItemType( $itemType );
|
$foreignkey = getForeignKeyFieldForItemType( $itemType );
|
||||||
|
|
||||||
//$glpi_item = getItemForItemtype( $itemType );
|
|
||||||
//$glpi_item->getFromDB( $glpi_task->fields[ getForeignKeyFieldForItemType( $itemType ) ] ) ;
|
|
||||||
|
|
||||||
//$plug = new Plugin;
|
|
||||||
//if( !$plug->isActivated('arbehaviours') ) { // check is done during Task update in this plugin
|
|
||||||
// $user_entities = Profile_User::getUserEntities( $newTech, true, true ) ;
|
|
||||||
// $user_can_view = in_array( $glpi_item->fields['entities_id'], $user_entities );
|
|
||||||
// if( !$glpi_item->isUser( CommonITILActor::REQUESTER, $newTech ) && !$glpi_item->isUser( CommonITILActor::OBSERVER, $newTech ) && !$glpi_item->isUser( CommonITILActor::ASSIGN, $newTech ) && !$user_can_view ) {
|
|
||||||
// // then we must add this tech user to watcher list
|
|
||||||
// $glpi_item_user = getItemForItemtype( "{$itemType}_User" );
|
|
||||||
// $donotif = $CFG_GLPI["use_mailing"] ;
|
|
||||||
// $CFG_GLPI["use_mailing"] = false;
|
|
||||||
// $glpi_item_user->add( array( $glpi_item->getForeignKeyField() => $glpi_item->getId() , 'users_id' => $newTech, 'type' => CommonITILActor::OBSERVER ) ) ; // , '_no_notif' => true
|
|
||||||
// $CFG_GLPI["use_mailing"] = $donotif;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
self::addWatcher( $itemType, $glpi_task->fields[ $foreignkey ], $newTech );
|
self::addWatcher( $itemType, $glpi_task->fields[ $foreignkey ], $newTech );
|
||||||
|
|
||||||
$glpi_task->update( array( 'id' => $row['items_id'], $foreignkey => $glpi_task->fields[ $foreignkey ], 'users_id_tech' => $newTech ));
|
$glpi_task->update( array( 'id' => $row['items_id'], $foreignkey => $glpi_task->fields[ $foreignkey ], 'users_id_tech' => $newTech ));
|
||||||
@@ -1771,7 +1765,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
* 'users_id_tech' => is the users_id of the tech that solved the task
|
* 'users_id_tech' => is the users_id of the tech that solved the task
|
||||||
*/
|
*/
|
||||||
public function solveTask( $caseId, $delIndex, $options=array() ) {
|
public function solveTask( $caseId, $delIndex, $options=array() ) {
|
||||||
global $DB, $CFG_GLPI;
|
global $DB;
|
||||||
|
|
||||||
// change current glpi_currenttime to be sure that date_mode for solved task will not be identical than date_mode of the newly started task
|
// change current glpi_currenttime to be sure that date_mode for solved task will not be identical than date_mode of the newly started task
|
||||||
$start_date = new DateTime( $_SESSION["glpi_currenttime"] );
|
$start_date = new DateTime( $_SESSION["glpi_currenttime"] );
|
||||||
@@ -1812,13 +1806,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
|
|||||||
'groups_id_tech' => 0,
|
'groups_id_tech' => 0,
|
||||||
'content' => $DB->escape($glpi_task->fields[ 'content' ].$options['txtToAppend'])
|
'content' => $DB->escape($glpi_task->fields[ 'content' ].$options['txtToAppend'])
|
||||||
);
|
);
|
||||||
$donotif = $CFG_GLPI["use_mailing"];
|
$donotif = self::saveNotification($options['notif']);
|
||||||
if (!$options['notif']) {
|
|
||||||
$CFG_GLPI["use_mailing"] = false;
|
|
||||||
// $params['_no_notif']=true;
|
|
||||||
}
|
|
||||||
$glpi_task->update( $params );
|
$glpi_task->update( $params );
|
||||||
$CFG_GLPI["use_mailing"]= $donotif;
|
self::restoreNotification($donotif);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore current glpi time
|
// restore current glpi time
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
if (!defined('GLPI_ROOT')) {
|
|
||||||
die("Sorry. You can't access directly to this file");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class manages the mail settings
|
|
||||||
*/
|
|
||||||
class ProcessmakerConfig extends CommonDBTM {
|
|
||||||
|
|
||||||
var $table = 'glpi_plugins_processmaker_config';
|
|
||||||
|
|
||||||
|
|
||||||
static function getTypeName($nb=0) {
|
|
||||||
global $LANG;
|
|
||||||
|
|
||||||
return 'Process Maker Plugin Configuration';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function defineTabs($options=array()) {
|
|
||||||
|
|
||||||
$ong = array();
|
|
||||||
$this->addStandardTab(__CLASS__, $ong, $options);
|
|
||||||
|
|
||||||
return $ong;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
|
|
||||||
global $LANG, $CFG_GLPI;
|
|
||||||
|
|
||||||
switch ($item->getType()) {
|
|
||||||
case __CLASS__ :
|
|
||||||
$tabs[1] = $LANG['common'][12];
|
|
||||||
return $tabs;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
|
||||||
global $CFG_GLPI;
|
|
||||||
|
|
||||||
if ($item->getType() == __CLASS__) {
|
|
||||||
switch ($tabnum) {
|
|
||||||
case 1 :
|
|
||||||
$item->showFormMailServerConfig();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print the mailing config form
|
|
||||||
*
|
|
||||||
* @param $ID integer ID of the item
|
|
||||||
* @param $options array
|
|
||||||
* - target filename : where to go when done.
|
|
||||||
* - tabs integer : ID of the tab to display
|
|
||||||
*
|
|
||||||
* @return Nothing (display)
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
function showForm($ID, $options=array()) {
|
|
||||||
global $LANG, $CFG_GLPI;
|
|
||||||
|
|
||||||
if (!Session::haveRight("config", UPDATE)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!$CFG_GLPI['use_mailing']) {
|
|
||||||
$options['colspan'] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getFromDB($ID);
|
|
||||||
$this->showTabs($options);
|
|
||||||
$this->addDivForTabs();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static function canCreate() {
|
|
||||||
return Session::haveRight('config', UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static function canView() {
|
|
||||||
return Session::haveRight('config', READ);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
</authors>
|
</authors>
|
||||||
<versions>
|
<versions>
|
||||||
<version>
|
<version>
|
||||||
<num>3.2.1</num>
|
<num>3.2.2</num>
|
||||||
<compatibility>9.2</compatibility>
|
<compatibility>9.2</compatibility>
|
||||||
</version>
|
</version>
|
||||||
<version>
|
<version>
|
||||||
<num>3.2.1</num>
|
<num>3.2.2</num>
|
||||||
<compatibility>9.1</compatibility>
|
<compatibility>9.1</compatibility>
|
||||||
</version>
|
</version>
|
||||||
</versions>
|
</versions>
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ function plugin_version_processmaker() {
|
|||||||
global $LANG;
|
global $LANG;
|
||||||
|
|
||||||
return array ('name' => 'Process Maker',
|
return array ('name' => 'Process Maker',
|
||||||
'version' => '3.2.1',
|
'version' => '3.2.2',
|
||||||
'author' => 'Olivier Moron',
|
'author' => 'Olivier Moron',
|
||||||
'homepage' => 'https://github.com/tomolimo/processmaker',
|
'homepage' => 'https://github.com/tomolimo/processmaker',
|
||||||
'minGlpiVersion' => '9.1');
|
'minGlpiVersion' => '9.1');
|
||||||
|
|||||||
Reference in New Issue
Block a user