From d88925a61a714fb57fe4ef3ff93848101ecd0cfa Mon Sep 17 00:00:00 2001 From: tomolimo Date: Fri, 4 May 2018 16:06:49 +0200 Subject: [PATCH] Fixed several bugs: - Changed setup to be able to have the setting of the plugin even when cron is running. - Changed body to html to get the height of the iframe content to be able to adjust the height of the iframe - Added some filter to be sure that only text will receive the click event - Inverted place of comment and txtTaskContent --- inc/processmaker.class.php | 75 +++++----------- js/cases.helpdesk.js | 2 +- js/cases.js | 4 +- setup.php | 179 ++++++++++++++++++------------------- 4 files changed, 113 insertions(+), 147 deletions(-) diff --git a/inc/processmaker.class.php b/inc/processmaker.class.php index eb3dfbb..e3302ec 100644 --- a/inc/processmaker.class.php +++ b/inc/processmaker.class.php @@ -1629,21 +1629,17 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { // manage task description $input['content'] = ""; // by default empty :) - if ($options['txtTaskContent'] != '') { - $input['content'] = $options['txtTaskContent']; - } else if (!$pmProcess->fields["hide_case_num_title"]) { - $input['content'] = $LANG['processmaker']['item']['task']['case'].$caseInfo->caseName; - } if ($pmProcess->fields["insert_task_comment"]) { - if ($input['content'] != '') { - $input['content'] .= "\n"; - } - $input['content'] .= $LANG['processmaker']['item']['task']['comment']; + $input['content'] .= $LANG['processmaker']['item']['task']['comment']."\n"; } - if ($input['content'] != '') { - $input['content'] .= "\n"; + + if ($options['txtTaskContent'] != '') { + $input['content'] .= $options['txtTaskContent']."\n"; + } else if (!$pmProcess->fields["hide_case_num_title"]) { + $input['content'] .= $LANG['processmaker']['item']['task']['case'].$caseInfo->caseName."\n"; } + $input['content'] .= $LANG['processmaker']['item']['task']['manage']; $input['is_private'] = 0; @@ -1954,22 +1950,16 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { return $launch; } - /** - * Summary of pre_show_item_processmakerticket - * @param $parm - */ - //private $pmCurrentCaseID = null ; - + /** + * Summary of pre_show_item_processmakerticket + * @param $params + */ public static function pre_show_item_processmakerticket($params) { - //global $LANG; - - //$plug = new Plugin; if (!is_array($params['item']) && is_subclass_of( $params['item'], 'CommonITILTask')) { // must check if Task is bound to a PM task $pmTask = new PluginProcessmakerTask($params['item']->getType()); if ($pmTask->getFromDBByQuery("WHERE itemtype='".$params['item']->getType()."' and items_id=".$params['item']->getId())) { - //echo 'Test' ; $params['item']->fields['can_edit'] = false; // to prevent task edition // replace ##ticket.url##_PluginProcessmakerCase$processmakercases by a setActiveTab to the Case panel @@ -1983,51 +1973,28 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { $params['item']->fields['content'] = str_replace( '##processmaker.taskcomment##', $taskComment, $params['item']->fields['content'] ); } $taskJSId = "viewitem".$params['item']->getType().$params['item']->getId().$params['options']['rand']; + + // special case for
which will provoke the rendering to be split into several

+ // add

which othervise will be missing + if (stripos($params['item']->fields['content'], '
') !== false) { + $params['item']->fields['content'] = str_ireplace('
', '

', $params['item']->fields['content']).'

'; + } + echo Html::scriptBlock( " - $('#$taskJSId').on('click', function ( ) { + $('#$taskJSId').find('.item_content').children().not('.read_more').on('click', function ( ) { //debugger; var tabindex = $('#tabspanel').next('div').find('a[href*=\"_glpi_tab=PluginProcessmaker\"]').parent().index(); $('#tabspanel').next('div').tabs( 'option', 'active', tabindex ); } ).css('cursor', 'pointer') ; "); - $params['item']->fields['content'] = str_replace( '##ticket.url##_PluginProcessmakerCase$processmakercases', "", $params['item']->fields['content'] ); //"".$LANG['processmaker']['item']['task']['manage_text']."" + + $params['item']->fields['content'] = str_replace( "\n##ticket.url##_PluginProcessmakerCase\$processmakercases", "", $params['item']->fields['content'] ); if (isset( $params['item']->fields['tr_id'] )) { $trID = $params['item']->fields['tr_id']; - //$params['item']->fields['content'] .= ""; } } } - - //if( ($plug = new Plugin) && !$plug->isActivated('arbehaviours') ) { - // if ($params['item']->getID() && is_subclass_of( $params['item'], 'CommonITILObject')) { - // // then we are in a ticket - // if (isset($_REQUEST['glpi_tab']) && $_SESSION['glpiactiveprofile']['interface'] != "helpdesk" ) { - // $data = self::multiexplode(array('$','_'), $_REQUEST['glpi_tab']); - // $itemtype = $data[0]; - // // Default set - // $tabnum = 1; - // if (isset($data[1])) { - // $tabnum = $data[1]; - // } - // elseif( $itemtype == -1 ) - // $tabnum = -1 ; - - // if( $data[0] == "processmaker" && $tabnum == 1 ) { - - // } - // if( ($data[0] == "Ticket" && $tabnum == 2) || $tabnum == -1) { - // // then we are showing the Solution tab - // // then we must prevent solving of ticket if a case is running - // if( !PluginProcessmakerCase::canSolve( $params['item'] ) ) { - // // then output a new div to hide solution - // $pmHideSolution = true ; - // echo "