enhancePostContent/inc/lib.epc.update.php

51 lines
2.0 KiB
PHP
Raw Normal View History

2021-08-23 23:55:52 +00:00
<?php
2021-09-02 18:35:25 +00:00
/**
* @brief enhancePostContent, a plugin for Dotclear 2
2021-11-01 09:33:43 +00:00
*
2021-09-02 18:35:25 +00:00
* @package Dotclear
* @subpackage Plugin
2021-11-01 09:33:43 +00:00
*
2021-09-02 18:35:25 +00:00
* @author Jean-Christian Denis and Contributors
2021-11-01 09:33:43 +00:00
*
2021-09-02 18:35:25 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-10-31 22:22:34 +00:00
# Move old filters lists from settings to database
if ($old_version && version_compare('0.6.6', $old_version, '>=')) {
2021-11-01 09:33:43 +00:00
$f = $core->con->select('SELECT * FROM ' . $core->prefix . "setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
2021-08-23 23:55:52 +00:00
2021-10-31 22:22:34 +00:00
while ($f->fetch()) {
2021-11-01 09:33:43 +00:00
if (preg_match('#enhancePostContent_(.*?)List#', $f->setting_id, $m)) {
2021-10-31 22:22:34 +00:00
$curlist = @unserialize($f->setting_value);
if (is_array($curlist)) {
2021-11-01 09:33:43 +00:00
foreach ($curlist as $k => $v) {
2021-10-31 22:22:34 +00:00
$cur = $core->con->openCursor($core->prefix . 'epc');
$core->con->writeLock($core->prefix . 'epc');
2021-08-23 23:55:52 +00:00
2021-11-01 09:33:43 +00:00
$cur->epc_id = $core->con->select('SELECT MAX(epc_id) FROM ' . $core->prefix . 'epc' . ' ')->f(0) + 1;
$cur->blog_id = $f->blog_id;
2021-10-31 22:22:34 +00:00
$cur->epc_filter = strtolower($m[1]);
2021-11-01 09:33:43 +00:00
$cur->epc_key = $k;
$cur->epc_value = $v;
2021-08-23 23:55:52 +00:00
2021-10-31 22:22:34 +00:00
$cur->insert();
$core->con->unlock();
}
}
2021-11-01 09:33:43 +00:00
$core->con->execute('DELETE FROM ' . $core->prefix . "setting WHERE setting_id='" . $f->setting_id . "' AND setting_ns='enhancePostContent' AND blog_id='" . $f->blog_id . "' ");
}
2021-10-31 22:22:34 +00:00
}
2021-11-01 09:33:43 +00:00
# Move old filter name to filter id
2021-10-31 22:22:34 +00:00
} elseif ($old_version && version_compare('2021.10.05', $old_version, '>=')) {
$rs = $core->con->select('SELECT epc_id, epc_filter FROM ' . $core->prefix . 'epc');
2021-11-01 09:33:43 +00:00
while ($rs->fetch()) {
2021-10-31 22:22:34 +00:00
$cur = $core->con->openCursor($core->prefix . 'epc');
$cur->epc_filter = strtolower($rs->epc_filter);
2021-11-01 09:33:43 +00:00
$cur->update('WHERE epc_id = ' . $rs->epc_id . ' ');
2021-10-31 22:22:34 +00:00
$core->blog->triggerBlog();
}
2021-11-01 09:33:43 +00:00
}