45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
class AddevHtmlEntities extends Module
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->name = 'addevhtmlentities';
|
|
$this->author = 'AD-DEV';
|
|
$this->version = '1.0.1';
|
|
$this->description = $this->l('Removes HTML entities present in customer messages.');
|
|
$this->displayName = $this->l('Customer messages - HTML entities remover');
|
|
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
|
|
|
|
$this->bootstrap = true;
|
|
parent::__construct();
|
|
}
|
|
|
|
public function install()
|
|
{
|
|
$rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
|
SELECT `id_customer_message`, `message` FROM `'._DB_PREFIX_.'customer_message`
|
|
');
|
|
$update_sqls = [];
|
|
foreach($rows as $row) {
|
|
$id = (int)$row['id_customer_message'];
|
|
if ($id > 0) {
|
|
$decoded = strip_tags(html_entity_decode($row['message']));
|
|
$update_sqls[] = '
|
|
UPDATE `'._DB_PREFIX_.'customer_message`
|
|
SET `message`="'.pSQL($decoded).'"
|
|
WHERE `id_customer_message`='.$id.';
|
|
';
|
|
}
|
|
}
|
|
if (count($update_sqls) > 0) {
|
|
// die(var_export(
|
|
Db::getInstance(_PS_USE_SQL_SLAVE_)->query(
|
|
implode("\n", $update_sqls)
|
|
// ,true)
|
|
);
|
|
}
|
|
return parent::install();
|
|
}
|
|
}
|