fix tables names
parent
00fe904b35
commit
2217d70dd8
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief postWidgetText, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
class initPostWidgetText
|
||||||
|
{
|
||||||
|
public const PWT_TABLE_NAME = 'post_option';
|
||||||
|
}
|
23
_install.php
23
_install.php
|
@ -14,18 +14,19 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_version = dcCore::app()->plugins->moduleInfo('postWidgetText', 'version');
|
|
||||||
$old_version = dcCore::app()->getVersion('postWidgetText');
|
|
||||||
|
|
||||||
if (version_compare($old_version, $new_version, '>=')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
# Grab info
|
||||||
|
$mod_id = basename(__DIR__);
|
||||||
|
|
||||||
|
# check installed version
|
||||||
|
if (version_compare(dcCore::app()->getVersion($mod_id), $new_version, '>=')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# Table is the same for plugins
|
# Table is the same for plugins
|
||||||
# pollsFactory, postTask, postWidgetText
|
# pollsFactory, postTask, postWidgetText
|
||||||
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||||
$s->post_option
|
$s->{initPostWidgetText::PWT_TABLE_NAME}
|
||||||
->option_id('bigint', 0, false)
|
->option_id('bigint', 0, false)
|
||||||
->post_id('bigint', 0, false)
|
->post_id('bigint', 0, false)
|
||||||
->option_creadt('timestamp', 0, false, 'now()')
|
->option_creadt('timestamp', 0, false, 'now()')
|
||||||
|
@ -64,14 +65,14 @@ try {
|
||||||
);
|
);
|
||||||
|
|
||||||
# Transfert records from old table to the new one
|
# Transfert records from old table to the new one
|
||||||
if (dcCore::app()->getVersion('postWidgetText') !== null
|
if (dcCore::app()->getVersion($mod_id) !== null
|
||||||
&& version_compare(dcCore::app()->getVersion('postWidgetText'), '0.5', '<')
|
&& version_compare(dcCore::app()->getVersion($mod_id), '0.5', '<')
|
||||||
) {
|
) {
|
||||||
require_once __DIR__ . '/inc/patch.0.5.php';
|
require_once __DIR__ . '/inc/patch.0.5.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set module version
|
# Set module version
|
||||||
dcCore::app()->setVersion('postWidgetText', $new_version);
|
dcCore::app()->setVersion($mod_id, $new_version);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ class postWidgetText
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->con = dcCore::app()->con;
|
$this->con = dcCore::app()->con;
|
||||||
$this->table = dcCore::app()->prefix . 'post_option';
|
$this->table = dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME;
|
||||||
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
|
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,8 +186,8 @@ class adminPostWidgetText
|
||||||
'postwidgettext',
|
'postwidgettext',
|
||||||
'SELECT option_type, option_content, ' .
|
'SELECT option_type, option_content, ' .
|
||||||
'option_content_xhtml, W.post_id ' .
|
'option_content_xhtml, W.post_id ' .
|
||||||
'FROM ' . dcCore::app()->prefix . 'post_option W ' .
|
'FROM ' . dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME . ' W ' .
|
||||||
'LEFT JOIN ' . dcCore::app()->prefix . 'post P ' .
|
'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
|
||||||
'ON P.post_id = W.post_id ' .
|
'ON P.post_id = W.post_id ' .
|
||||||
"WHERE P.blog_id = '" . $blog_id . "' " .
|
"WHERE P.blog_id = '" . $blog_id . "' " .
|
||||||
"AND W.option_type = 'postwidgettext' "
|
"AND W.option_type = 'postwidgettext' "
|
||||||
|
@ -200,8 +200,8 @@ class adminPostWidgetText
|
||||||
'postwidgettext',
|
'postwidgettext',
|
||||||
'SELECT option_type, option_content, ' .
|
'SELECT option_type, option_content, ' .
|
||||||
'option_content_xhtml, W.post_id ' .
|
'option_content_xhtml, W.post_id ' .
|
||||||
'FROM ' . dcCore::app()->prefix . 'post_option W ' .
|
'FROM ' . dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME . ' W ' .
|
||||||
'LEFT JOIN ' . dcCore::app()->prefix . 'post P ' .
|
'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
|
||||||
'ON P.post_id = W.post_id ' .
|
'ON P.post_id = W.post_id ' .
|
||||||
"WHERE W.option_type = 'postwidgettext' "
|
"WHERE W.option_type = 'postwidgettext' "
|
||||||
);
|
);
|
||||||
|
@ -210,7 +210,7 @@ class adminPostWidgetText
|
||||||
public static function importInit($bk, dcCore $core)
|
public static function importInit($bk, dcCore $core)
|
||||||
{
|
{
|
||||||
$bk->cur_postwidgettext = dcCore::app()->con->openCursor(
|
$bk->cur_postwidgettext = dcCore::app()->con->openCursor(
|
||||||
dcCore::app()->prefix . 'post_option'
|
dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME
|
||||||
);
|
);
|
||||||
$bk->postwidgettext = new postWidgetText();
|
$bk->postwidgettext = new postWidgetText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,16 @@
|
||||||
*/
|
*/
|
||||||
$records = dcCore::app()->con->select(
|
$records = dcCore::app()->con->select(
|
||||||
'SELECT W.*, P.post_lang, P.post_format FROM ' . dcCore::app()->prefix . 'post_wtext W ' .
|
'SELECT W.*, P.post_lang, P.post_format FROM ' . dcCore::app()->prefix . 'post_wtext W ' .
|
||||||
'LEFT JOIN ' . dcCore::app()->prefix . 'post P ON P.post_id=W.post_id '
|
'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ON P.post_id=W.post_id '
|
||||||
);
|
);
|
||||||
if (!$records->isEmpty()) {
|
if (!$records->isEmpty()) {
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'post_option');
|
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME);
|
||||||
while ($records->fetch()) {
|
while ($records->fetch()) {
|
||||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . 'post_option');
|
dcCore::app()->con->writeLock(dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = dcCore::app()->con->select(
|
$id = dcCore::app()->con->select(
|
||||||
'SELECT MAX(option_id) FROM ' . dcCore::app()->prefix . 'post_option'
|
'SELECT MAX(option_id) FROM ' . dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME
|
||||||
)->f(0) + 1;
|
)->f(0) + 1;
|
||||||
|
|
||||||
$cur->clean();
|
$cur->clean();
|
||||||
|
|
Loading…
Reference in New Issue