Skip to content

Commit

Permalink
fix: compatibility with GLPI 9.4
Browse files Browse the repository at this point in the history
rich text switch removed, and always enabled

fix #1022

Signed-off-by: btry <tbugier@teclib.com>
  • Loading branch information
btry committed Jul 10, 2018
1 parent 0902184 commit 6dfaae9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions inc/form_answer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ public function getFullForm() {
$output = '';
$eol = '\r\n';

if ($CFG_GLPI['use_rich_text']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$output .= '<h1>' . __('Form data', 'formcreator') . '</h1>';
} else {
$output .= __('Form data', 'formcreator') . $eol;
Expand Down Expand Up @@ -1110,7 +1110,7 @@ public function getFullForm() {

// Get and display current section if needed
if ($last_section != $question_line['section_name']) {
if ($CFG_GLPI['use_rich_text']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$output .= '<h2>' . Toolbox::addslashes_deep($question_line['section_name']) . '</h2>';
} else {
$output .= $eol . Toolbox::addslashes_deep($question_line['section_name']) . $eol;
Expand All @@ -1131,7 +1131,7 @@ public function getFullForm() {

if ($question_line['fieldtype'] != 'description') {
$question_no++;
if ($CFG_GLPI['use_rich_text']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$output .= '<div>';
$output .= '<b>' . $question_no . ') ##question_' . $question_line['id'] . '## : </b>';
$output .= '##answer_' . $question_line['id'] . '##';
Expand Down
8 changes: 4 additions & 4 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function showForm($options=[]) {
echo '<td><strong>' . __('Description') . ' <span style="color:red;">*</span></strong></td>';
echo '<td colspan="3">';
echo '<textarea name="comment" style="width:700px;" rows="15">' . $this->fields['comment'] . '</textarea>';
if ($CFG_GLPI["use_rich_text"]) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI["use_rich_text"]) {
Html::initEditorSystem('comment');
}
echo '</td>';
Expand Down Expand Up @@ -850,7 +850,7 @@ public function prepareInputForUpdate($input) {
return [];
}

if ($CFG_GLPI['use_rich_text']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$input['comment'] = Html::entity_decode_deep($input['comment']);
}

Expand Down Expand Up @@ -1114,13 +1114,13 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
if (strpos($data['content'], '##FULLFORM##') !== false) {
$data['content'] = str_replace('##FULLFORM##', $formanswer->getFullForm(), $data['content']);
}
if ($CFG_GLPI['use_rich_text']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
// replace HTML P tags with DIV tags
$data['content'] = str_replace(['<p>', '</p>'], ['<div>', '</div>'], $data['content']);
}

$data['content'] = $this->parseTags($data['content'], $formanswer);
if ($CFG_GLPI['use_rich_text']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$data['content'] = htmlentities($data['content']);
}
$data['_users_id_recipient'] = $_SESSION['glpiID'];
Expand Down

0 comments on commit 6dfaae9

Please sign in to comment.