Commit 014563d0 authored by Johan Cwiklinski's avatar Johan Cwiklinski Committed by Johan Cwiklinski

Drop use_rich_text parameter, closes #4138

parent a4bca634
......@@ -7,6 +7,10 @@ The present file will list all changes made to the project; according to the
### API changes
#### Deprecated
- Remove `$CFG_GLPI['use_rich_text']` parameter. Will now be `true` per default.
#### Removed
- Drop ability to use `JOIN` in `DBmysqlIterator::buildQuery()`
......
......@@ -4785,7 +4785,6 @@ class CommonDBTM extends CommonGLPI {
* - force_update (default false) update the content field of the object
* - content_field (default content) the field who receive the main text
* (with images)
* - use_rich_text (default false) to force the use of rich text
*
* @return array the input param transformed
**/
......@@ -4794,8 +4793,7 @@ class CommonDBTM extends CommonGLPI {
$default_options = [
'force_update' => false,
'content_field' => 'content',
'use_rich_text' => false
'content_field' => 'content'
];
$options = array_merge($default_options, $options);
......@@ -4910,15 +4908,11 @@ class CommonDBTM extends CommonGLPI {
// manage content transformation
if (isset($input[$options['content_field']])) {
if ($CFG_GLPI["use_rich_text"] or $options['use_rich_text']) {
$input[$options['content_field']]
= Toolbox::convertTagToImage($input[$options['content_field']],
$this,
$docadded);
} else {
$input[$options['content_field']]
= Html::setSimpleTextContent($input[$options['content_field']]);
}
$input[$options['content_field']] = Toolbox::convertTagToImage(
$input[$options['content_field']],
$this,
$docadded
);
if (isset($this->input['_forcenotif'])) {
$input['_forcenotif'] = $this->input['_forcenotif'];
......
......@@ -2772,8 +2772,8 @@ abstract class CommonITILObject extends CommonDBTM {
'massiveaction' => false,
'datatype' => 'text'
];
if ($this->getType() == 'Ticket'
&& $CFG_GLPI["use_rich_text"]) {
if ($this->getType() == 'Ticket') {
//why for Ticket only?
$newtab['htmltext'] = true;
}
$tab[] = $newtab;
......
......@@ -1375,19 +1375,15 @@ abstract class CommonITILTask extends CommonDBTM {
$rand_text = mt_rand();
$content_id = "content$rand_text";
$cols = 90;
$rows = 6;
if ($CFG_GLPI["use_rich_text"]) {
$cols = 100;
$rows = 10;
}
$cols = 100;
$rows = 10;
Html::textarea(['name' => 'content',
'value' => $this->fields["content"],
'rand' => $rand_text,
'editor_id' => $content_id,
'enable_fileupload' => true,
'enable_richtext' => $CFG_GLPI["use_rich_text"],
'enable_richtext' => true,
'cols' => $cols,
'rows' => $rows]);
......
......@@ -852,42 +852,29 @@ class Config extends CommonDBTM {
$rand);
echo "</td>";
echo "<td><label for='dropdown_use_rich_text$rand'>" . __('Use rich text for helpdesk') . "</label></td><td>";
$id = 'alert'.mt_rand();
$param['on_change'] = '$("#'.$id.'").html("");
if ($(this).val() == 0) {
$("#'.$id.'").html("<br>'.__('You will lose the formatting of your data').'");
}';
$param['rand'] = $rand;
Dropdown::showYesNo("use_rich_text", $CFG_GLPI["use_rich_text"], -1, $param);
echo "<span class='red' id='".$id."'></span>";
echo "</td></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td><label for='dropdown_documentcategories_id_forticket$rand'>" . __('Default heading when adding a document to a ticket') . "</label></td><td>";
DocumentCategory::dropdown(['value' => $CFG_GLPI["documentcategories_id_forticket"],
'name' => "documentcategories_id_forticket",
'rand' => $rand]);
echo "</td>";
echo "<td><label for='dropdown_default_software_helpdesk_visible$rand'>" . __('By default, a software may be linked to a ticket') . "</label></td><td>";
echo "</td></tr>";
echo "<tr class='tab_bg_2'><td><label for='dropdown_default_software_helpdesk_visible$rand'>" . __('By default, a software may be linked to a ticket') . "</label></td><td>";
Dropdown::showYesNo("default_software_helpdesk_visible",
$CFG_GLPI["default_software_helpdesk_visible"],
-1,
['rand' => $rand]);
echo "</td></tr>";
echo "</td>";
echo "<tr class='tab_bg_2'>";
echo "<td><label for='dropdown_keep_tickets_on_delete$rand'>" . __('Keep tickets when purging hardware in the inventory') . "</label></td><td>";
Dropdown::showYesNo("keep_tickets_on_delete", $CFG_GLPI["keep_tickets_on_delete"], -1, ['rand' => $rand]);
echo "</td><td><label for='dropdown_use_check_pref$rand'>".__('Show personnal information in new ticket form (simplified interface)');
echo "</label></td><td>";
echo "</td></tr><tr class='tab_bg_2'><td><label for='dropdown_use_check_pref$rand'>".__('Show personnal information in new ticket form (simplified interface)');
echo "</label></td>";
echo "<td>";
Dropdown::showYesNo('use_check_pref', $CFG_GLPI['use_check_pref'], -1, ['rand' => $rand]);
echo "</td></tr>";
echo "</td>";
echo "<tr class='tab_bg_2'>";
echo "<td><label for='dropdown_use_anonymous_helpdesk$rand'>" .__('Allow anonymous ticket creation (helpdesk.receiver)') . "</label></td><td>";
Dropdown::showYesNo("use_anonymous_helpdesk", $CFG_GLPI["use_anonymous_helpdesk"], -1, ['rand' => $rand]);
echo "</td><td><label for='dropdown_use_anonymous_followups$rand'>" . __('Allow anonymous followups (receiver)') . "</label></td><td>";
echo "</td></tr><tr class='tab_bg_2'><td><label for='dropdown_use_anonymous_followups$rand'>" . __('Allow anonymous followups (receiver)') . "</label></td><td>";
Dropdown::showYesNo("use_anonymous_followups", $CFG_GLPI["use_anonymous_followups"], -1, ['rand' => $rand]);
echo "</td></tr>";
......
......@@ -846,16 +846,14 @@ class Document extends CommonDBTM {
'datatype' => 'string'
];
if ($CFG_GLPI['use_rich_text']) {
$tab[] = [
'id' => '6',
'table' => $this->getTable(),
'field' => 'tag',
'name' => __('Tag'),
'datatype' => 'text',
'massiveaction' => false
];
}
$tab[] = [
'id' => '6',
'table' => $this->getTable(),
'field' => 'tag',
'name' => __('Tag'),
'datatype' => 'text',
'massiveaction' => false
];
$tab[] = [
'id' => '7',
......
......@@ -776,16 +776,16 @@ class Document_Item extends CommonDBRelation{
$canedit = $item->canAddItem('Document') && Document::canView();
$columns = ['name' => __('Name'),
'entity' => __('Entity'),
'filename' => __('File'),
'link' => __('Web link'),
'headings' => __('Heading'),
'mime' => __('MIME type')];
if ($CFG_GLPI['use_rich_text']) {
$columns['tag'] = __('Tag');
}
$columns['assocdate'] = __('Date');
$columns = [
'name' => __('Name'),
'entity' => __('Entity'),
'filename' => __('File'),
'link' => __('Web link'),
'headings' => __('Heading'),
'mime' => __('MIME type'),
'tag' => __('Tag'),
'assocdate' => __('Date')
];
if (isset($_GET["order"]) && ($_GET["order"] == "ASC")) {
$order = "ASC";
......@@ -958,11 +958,9 @@ class Document_Item extends CommonDBRelation{
$data["documentcategories_id"]);
echo "</td>";
echo "<td class='center'>".$data["mime"]."</td>";
if ($CFG_GLPI['use_rich_text']) {
echo "<td class='center'>";
echo !empty($data["tag"]) ? Document::getImageTag($data["tag"]) : '';
echo "</td>";
}
echo "<td class='center'>";
echo !empty($data["tag"]) ? Document::getImageTag($data["tag"]) : '';
echo "</td>";
echo "<td class='center'>".Html::convDateTime($data["assocdate"])."</td>";
echo "</tr>";
$i++;
......
......@@ -4848,10 +4848,6 @@ class Html {
static function fileForRichText($options = []) {
global $CFG_GLPI;
if (!$CFG_GLPI["use_rich_text"]) {
return '';
}
$p['editor_id'] = '';
$p['name'] = 'filename';
$p['filecontainer'] = 'fileupload_info';
......
......@@ -489,13 +489,9 @@ class ITILSolution extends CommonDBTM {
echo "<div class='item_content $long_text'>";
if ($CFG_GLPI["use_rich_text"]) {
echo "<div class='rich_text_container'>";
echo html_entity_decode($content);
echo "</div>";
} else {
echo "<p>$content</p>";
}
echo "<div class='rich_text_container'>";
echo html_entity_decode($content);
echo "</div>";
if (!empty($long_text)) {
echo "<p class='read_more'>";
......
......@@ -249,9 +249,12 @@ class KnowbaseItem extends CommonDBVisible {
function post_addItem() {
// add documents (and replace inline pictures)
$this->input = $this->addFiles($this->input, ['force_update' => true,
'content_field' => 'answer',
'use_rich_text' => true]);
$this->input = $this->addFiles(
$this->input, [
'force_update' => true,
'content_field' => 'answer'
]
);
if (isset($this->input["_visibility"])
&& isset($this->input["_visibility"]['_type'])
......@@ -632,8 +635,10 @@ class KnowbaseItem extends CommonDBVisible {
function prepareInputForUpdate($input) {
// add documents (and replace inline pictures)
$input = $this->addFiles($input, ['content_field' => 'answer',
'use_rich_text' => true]);
$input = $this->addFiles(
$input,
['content_field' => 'answer']
);
// set title for question if empty
if (isset($input["name"]) && empty($input["name"])) {
......
......@@ -804,12 +804,12 @@ class MailCollector extends CommonDBTM {
// Clean mail content
$striptags = true;
if ($CFG_GLPI["use_rich_text"] && !isset($tkt['tickets_id'])) {
if (!isset($tkt['tickets_id'])) {
$striptags = false;
}
$tkt['content'] = $this->cleanMailContent(Html::entities_deep($tkt['content']), $striptags);
if ($is_html && !isset($tkt['tickets_id']) && $CFG_GLPI["use_rich_text"]) {
if ($is_html && !isset($tkt['tickets_id'])) {
$tkt['content'] = nl2br($tkt['content']);
}
......
......@@ -989,7 +989,7 @@ class Ticket extends CommonITILObject {
$this->getFromDB($input['id']);
// Clean new lines before passing to rules
if ($CFG_GLPI["use_rich_text"] && isset($input["content"])) {
if (isset($input["content"])) {
$input["content"] = preg_replace('/\\\\r\\\\n/', "\n", $input['content']);
$input["content"] = preg_replace('/\\\\n/', "\n", $input['content']);
}
......@@ -1331,10 +1331,8 @@ class Ticket extends CommonITILObject {
if (isset($input['_filename'])) {
$input['content'] = $input['content'];
$input['_disablenotif'] = true;
} else if ($CFG_GLPI["use_rich_text"]) {
if (!isset($input['_filename'])) {
$input['_donotadddocs'] = true;
}
} else {
$input['_donotadddocs'] = true;
}
}
......@@ -1873,11 +1871,6 @@ class Ticket extends CommonITILObject {
if (isset($input["content"])) {
$input["content"] = preg_replace('/\\\\r\\\\n/', "\\n", $input['content']);
$input["content"] = preg_replace('/\\\\n/', "\\n", $input['content']);
if (!$CFG_GLPI['use_rich_text']) {
$input["content"] = Html::entity_decode_deep($input["content"]);
$input["content"] = Html::entity_decode_deep($input["content"]);
$input["content"] = Html::clean($input["content"]);
}
}
$input = $rules->processAllRules($input,
......@@ -3078,8 +3071,8 @@ class Ticket extends CommonITILObject {
],
'datatype' => 'text'
];
if ($this->getType() == 'Ticket'
&& $CFG_GLPI["use_rich_text"]) {
if ($this->getType() == 'Ticket') {
//Why for Ticket only?
$newtab['htmltext'] = true;
}
$tab[] = $newtab;
......@@ -4054,8 +4047,8 @@ class Ticket extends CommonITILObject {
$rand = mt_rand();
$rand_text = mt_rand();
$cols = 90;
$rows = 6;
$cols = 100;
$rows = 10;
$content_id = "content$rand";
echo "<td class='center middle'>";
......@@ -4063,24 +4056,13 @@ class Ticket extends CommonITILObject {
if (!$ticket_template) {
$content = Html::cleanPostForTextArea($options['content']);
}
if ($CFG_GLPI["use_rich_text"]) {
$content = Html::setRichTextContent($content_id, $content, $rand);
$cols = 100;
$rows = 10;
} else {
$content = $content;
}
$content = Html::setRichTextContent($content_id, $content, $rand);
echo "<div id='content$rand_text'>";
echo "<textarea id='$content_id' name='content' cols='$cols' rows='$rows'
" . ($tt->isMandatoryField('content') ? " required='required'" : '') .">".
$content."</textarea></div>";
if (!$CFG_GLPI["use_rich_text"]) {
echo Html::scriptBlock("$(document).ready(function() { $('#$content_id').autogrow(); });");
}
Html::file(['editor_id' => $content_id,
'showtitle' => false,
'multiple' => true]);
......@@ -5095,7 +5077,7 @@ class Ticket extends CommonITILObject {
echo $tt->getBeginHiddenFieldValue('content');
$rand = mt_rand();
$rand_text = mt_rand();
$rows = 6;
$rows = 10;
$content_id = "content$rand";
$content = $this->fields['content'];
......@@ -5103,24 +5085,18 @@ class Ticket extends CommonITILObject {
$content = Html::cleanPostForTextArea($content);
}
if ($CFG_GLPI["use_rich_text"]) {
$content = Html::setRichTextContent($content_id,
$content,
$rand,
!$canupdate);
$rows = 10;
} else {
$content = Html::setSimpleTextContent($this->fields["content"]);
}
$content = Html::setRichTextContent(
$content_id,
$content,
$rand,
!$canupdate
);
echo "<div id='content$rand_text'>";
if ($CFG_GLPI['use_rich_text'] || $canupdate || $can_requester) {
if ($canupdate || $can_requester) {
echo "<textarea id='$content_id' name='content' style='width:100%' rows='$rows'".
($tt->isMandatoryField('content') ? " required='required'" : '') . ">" .
$content."</textarea></div>";
if (!$CFG_GLPI["use_rich_text"]) {
echo Html::scriptBlock("$(document).ready(function() { $('#$content_id').autogrow(); });");
}
} else {
echo Toolbox::getHtmlToDisplay($content);
}
......@@ -6960,13 +6936,9 @@ class Ticket extends CommonITILObject {
}
echo "</p>";
if ($CFG_GLPI["use_rich_text"]) {
echo "<div class='rich_text_container'>";
echo html_entity_decode($content);
echo "</div>";
} else {
echo "<p>$content</p>";
}
echo "<div class='rich_text_container'>";
echo html_entity_decode($content);
echo "</div>";
if (!empty($long_text)) {
echo "<p class='read_more'>";
......@@ -7162,15 +7134,9 @@ class Ticket extends CommonITILObject {
echo Html::setSimpleTextContent($this->fields['name']);
echo "</div>";
if ($CFG_GLPI["use_rich_text"]) {
echo "<div class='rich_text_container'>";
echo Html::setRichTextContent('', $this->fields['content'], '', true);
echo "</div>";
} else {
echo "<div>";
echo Toolbox::getHtmlToDisplay(Html::setSimpleTextContent($this->fields['content']));
echo "</div>";
}
echo "<div class='rich_text_container'>";
echo Html::setRichTextContent('', $this->fields['content'], '', true);
echo "</div>";
echo "</div>"; // h_content TicketContent
......
......@@ -657,10 +657,8 @@ class TicketFollowup extends CommonDBTM {
}
}
$width = '100%';
if ($CFG_GLPI['use_rich_text']) {
$width = '50%';
}
$cols = 100;
$rows = 10;
if ($tech) {
$this->showFormHeader($options);
......@@ -669,23 +667,16 @@ class TicketFollowup extends CommonDBTM {
$rand_text = mt_rand();
$content_id = "content$rand";
$cols = 90;
$rows = 6;
echo "<tr class='tab_bg_1'>";
echo "<td rowspan='3'>".__('Description')."</td>";
echo "<td rowspan='3' style='width:65%'>";
if ($CFG_GLPI["use_rich_text"]) {
$cols = 100;
$rows = 10;
}
Html::textarea(['name' => 'content',
'value' => $this->fields["content"],
'rand' => $rand_text,
'editor_id' => $content_id,
'enable_fileupload' => true,
'enable_richtext' => $CFG_GLPI["use_rich_text"],
'enable_richtext' => true,
'cols' => $cols,
'rows' => $rows]);
......@@ -728,16 +719,12 @@ class TicketFollowup extends CommonDBTM {
echo "<td class='middle right'>".__('Description')."</td>";
echo "<td class='center middle'>";
if ($CFG_GLPI["use_rich_text"]) {
$cols = 100;
$rows = 10;
}
Html::textarea(['name' => 'content',
'value' => $this->fields["content"],
'rand' => $rand_text,
'editor_id' => $content_id,
'enable_fileupload' => true,
'enable_richtext' => $CFG_GLPI["use_rich_text"],
'enable_richtext' => true,
'cols' => $cols,
'rows' => $rows]);
......@@ -1017,13 +1004,9 @@ class TicketFollowup extends CommonDBTM {
$content = NOT_AVAILABLE;
}
if ($CFG_GLPI["use_rich_text"]) {
echo "<div class='rich_text_container'>";
echo html_entity_decode($content);
echo "</div>";
} else {
echo autolink($content);;
}
echo "<div class='rich_text_container'>";
echo html_entity_decode($content);
echo "</div>";
echo "</div>"; // boxnotetext
echo "</div>"; // boxnotecontent
......
......@@ -2799,20 +2799,11 @@ class Toolbox {
* @return html content
**/
static function cleanTagOrImage($content, array $tags) {
global $CFG_GLPI;
// RICH TEXT : delete img tag
if ($CFG_GLPI["use_rich_text"]) {
$content = Html::entity_decode_deep($content);
$content = Html::entity_decode_deep($content);
foreach ($tags as $tag) {
$content = preg_replace("/<img.*alt=['|\"]".$tag."['|\"][^>]*\>/", "<p></p>", $content);
}
} else { // SIMPLE TEXT : delete tag
foreach ($tags as $tag) {
$content = preg_replace('/'.Document::getImageTag($tag).'/', '\r\n', $content);
}
foreach ($tags as $tag) {
$content = preg_replace("/<img.*alt=['|\"]".$tag."['|\"][^>]*\>/", "<p></p>", $content);
}
return $content;
......
......@@ -1328,7 +1328,6 @@ INSERT INTO `glpi_configs` VALUES ('147','core','pdffont','helvetica');
INSERT INTO `glpi_configs` VALUES ('148','core','keep_devices_when_purging_item','0');
INSERT INTO `glpi_configs` VALUES ('149','core','maintenance_mode','0');
INSERT INTO `glpi_configs` VALUES ('150','core','maintenance_text','');
INSERT INTO `glpi_configs` VALUES ('151','core','use_rich_text','0');
INSERT INTO `glpi_configs` VALUES ('152','core','attach_ticket_documents_to_mail','0');
INSERT INTO `glpi_configs` VALUES ('153','core','backcreated','0');
INSERT INTO `glpi_configs` VALUES ('154','core','task_state','1');
......
......@@ -115,6 +115,10 @@ function update93to94() {
}
/** /Add business rules on assets */
/** Drop use_rich_text parameter */
Config::deleteConfigurationValues('core', ['use_rich_text']);
/** /Drop use_rich_text parameter */
// ************ Keep it at the end **************
$migration->executeMigration();
......
......@@ -38,15 +38,6 @@ use \DbTestCase;
class Ticket extends DbTestCase {
public function afterTestMethod($method) {
global $CFG_GLPI;
//make sure rich text has been reset to false
$CFG_GLPI['use_rich_text'] = 0;
parent::afterTestMethod($method);
}
public function ticketProvider() {
return [
'single requester' => [
......@@ -1554,28 +1545,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'This is a title',
'content' => 'This is a content'
],
'rich' => false
], [
'input' => [
'name' => '',
'content' => "This is a content\nwith a carriage return"
],
'expected' => [
'name' => 'This is a content with a carriage return',
'content' => 'This is a content\nwith a carriage return'
],
'rich' => false
], [
'input' => [
'name' => '',
'content' => "This is a content\r\nwith a carriage return"
],
'expected' => [
'name' => 'This is a content with a carriage return',
'content' => 'This is a content\nwith a carriage return'
],
'rich' => false
]
], [
'input' => [
'name' => '',
......@@ -1584,8 +1554,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'This is a content',
'content' => 'This is a content'
],
'rich' => true
]
], [
'input' => [
'name' => '',
......@@ -1594,8 +1563,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'This is a content with a carriage return',
'content' => 'This is a content\nwith a carriage return'
],
'rich' => true
]
], [
'input' => [
'name' => '',
......@@ -1604,8 +1572,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'This is a content with a carriage return',
'content' => 'This is a content\nwith a carriage return'
],
'rich' => true
]
], [
'input' => [
'name' => '',
......@@ -1614,8 +1581,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'This is a content with a carriage return',
'content' => '<p>This is a content\nwith a carriage return</p>',
],
'rich' => true
]
], [
'input' => [
'name' => '',
......@@ -1624,8 +1590,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'This is a content with a carriage return',
'content' => '&lt;p&gt;This is a content\nwith a carriage return&lt;/p&gt;'
],
'rich' => true
]
], [
'input' => [
'name' => '',
......@@ -1634,8 +1599,7 @@ class Ticket extends DbTestCase {
'expected' => [
'name' => 'Test for buggy \\\' character',
'content' => 'Test for buggy \\\' character',
],
'rich' => false
]
]
];
}
......@@ -1643,10 +1607,9 @@ class Ticket extends DbTestCase {
/**
* @dataProvider inputProvider
*/
public function testPrepareInputForAdd($input, $expected, $rich) {
public function testPrepareInputForAdd($input, $expected) {
global $CFG_GLPI;
$CFG_GLPI['use_rich_text'] = $rich;
$this
->if($this->newTestedInstance)
->then
......
......@@ -10,7 +10,6 @@ Following accounts are available:
UPDATE glpi_configs SET value = 1 WHERE name = 'use_public_faq';
UPDATE glpi_configs SET value = 1 WHERE name = 'translate_dropdowns';
UPDATE glpi_configs SET value = 1 WHERE name = 'translate_kb';
UPDATE glpi_configs SET value = 1 WHERE name = 'use_rich_text';
-- all profile rights
UPDATE glpi_profilerights SET rights = 0 WHERE name = 'password_update';
-- admin profile rights
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment