fix tables names
This commit is contained in:
parent
76cc3b53bd
commit
d8738bf4de
5 changed files with 41 additions and 17 deletions
21
_init.php
Normal file
21
_init.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief cinecturlink2, 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 initCinecturlink2
|
||||
{
|
||||
public const CINECTURLINK_TABLE_NAME = 'cinecturlink2';
|
||||
public const CATEGORY_TABLE_NAME = 'cinecturlink2_cat';
|
||||
}
|
|
@ -23,7 +23,7 @@ if (version_compare($old_version, $new_version, '>=')) {
|
|||
|
||||
try {
|
||||
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s->cinecturlink2
|
||||
$s->{initCinecturlink2::CINECTURLINK_TABLE_NAME}
|
||||
->link_id('bigint', 0, false)
|
||||
->blog_id('varchar', 32, false)
|
||||
->cat_id('bigint', 0, true)
|
||||
|
@ -49,7 +49,7 @@ try {
|
|||
->index('idx_cinecturlink2_user_id', 'btree', 'user_id')
|
||||
->index('idx_cinecturlink2_type', 'btree', 'link_type');
|
||||
|
||||
$s->cinecturlink2_cat
|
||||
$s->{initCinecturlink2::CATEGORY_TABLE_NAME}
|
||||
->cat_id('bigint', 0, false)
|
||||
->blog_id('varchar', 32, false)
|
||||
->cat_title('varchar', 255, false)
|
||||
|
|
|
@ -31,7 +31,7 @@ $this->addUserAction(
|
|||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
'cinecturlink2',
|
||||
initCinecturlink2::CINECTURLINK_TABLE_NAME,
|
||||
/* desc */
|
||||
sprintf(__('delete %s table'), 'cinecturlink2')
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ $this->addUserAction(
|
|||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
'cinecturlink2_cat',
|
||||
initCinecturlink2::CATEGORY_TABLE_NAME,
|
||||
/* desc */
|
||||
sprintf(__('delete %s table'), 'cinecturlink2_cat')
|
||||
);
|
||||
|
@ -86,7 +86,7 @@ $this->addDirectAction(
|
|||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
'cinecturlink2',
|
||||
initCinecturlink2::CINECTURLINK_TABLE_NAME,
|
||||
/* desc */
|
||||
sprintf(__('delete %s table'), 'cinecturlink2')
|
||||
);
|
||||
|
@ -97,7 +97,7 @@ $this->addDirectAction(
|
|||
/* action */
|
||||
'delete',
|
||||
/* ns */
|
||||
'cinecturlink2_cat',
|
||||
initCinecturlink2::CATEGORY_TABLE_NAME,
|
||||
/* desc */
|
||||
sprintf(__('delete %s table'), 'cinecturlink2_cat')
|
||||
);
|
||||
|
|
|
@ -25,6 +25,8 @@ class cinecturlink2
|
|||
public $con;
|
||||
/** @var string Cinecturlink table name */
|
||||
public $table;
|
||||
/** @var string Cinecturlink category table name */
|
||||
public $cat_table;
|
||||
/** @var string Blog ID */
|
||||
public $blog;
|
||||
|
||||
|
@ -36,7 +38,8 @@ class cinecturlink2
|
|||
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
|
||||
|
||||
$this->con = dcCore::app()->con;
|
||||
$this->table = dcCore::app()->prefix . 'cinecturlink2';
|
||||
$this->table = dcCore::app()->prefix . initCinecturlink2::CINECTURLINK_TABLE_NAME;
|
||||
$this->cat_table = dcCore::app()->prefix . initCinecturlink2::CATEGORY_TABLE_NAME;
|
||||
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
|
||||
}
|
||||
|
||||
|
@ -68,8 +71,8 @@ class cinecturlink2
|
|||
}
|
||||
|
||||
$strReq .= 'FROM ' . $this->table . ' L ' .
|
||||
'INNER JOIN ' . dcCore::app()->prefix . 'user U ON U.user_id = L.user_id ' .
|
||||
'LEFT OUTER JOIN ' . $this->table . '_cat C ON L.cat_id = C.cat_id ';
|
||||
'INNER JOIN ' . dcCore::app()->prefix . dcAuth::USER_TABLE_NAME . ' U ON U.user_id = L.user_id ' .
|
||||
'LEFT OUTER JOIN ' . $this->cat_table . ' C ON L.cat_id = C.cat_id ';
|
||||
|
||||
if (!empty($params['from'])) {
|
||||
$strReq .= $params['from'] . ' ';
|
||||
|
@ -278,7 +281,7 @@ class cinecturlink2
|
|||
'C.cat_pos, C.cat_creadt, C.cat_upddt ';
|
||||
}
|
||||
|
||||
$strReq .= 'FROM ' . $this->table . '_cat C ';
|
||||
$strReq .= 'FROM ' . $this->cat_table . ' C ';
|
||||
|
||||
if (!empty($params['from'])) {
|
||||
$strReq .= $params['from'] . ' ';
|
||||
|
@ -343,7 +346,7 @@ class cinecturlink2
|
|||
*/
|
||||
public function addCategory(cursor $cur)
|
||||
{
|
||||
$this->con->writeLock($this->table . '_cat');
|
||||
$this->con->writeLock($this->cat_table);
|
||||
|
||||
try {
|
||||
if ($cur->cat_title == '') {
|
||||
|
@ -404,7 +407,7 @@ class cinecturlink2
|
|||
}
|
||||
|
||||
$this->con->execute(
|
||||
'DELETE FROM ' . $this->table . '_cat ' .
|
||||
'DELETE FROM ' . $this->cat_table . ' ' .
|
||||
'WHERE cat_id = ' . $id . ' ' .
|
||||
"AND blog_id = '" . $this->blog . "' "
|
||||
);
|
||||
|
@ -426,7 +429,7 @@ class cinecturlink2
|
|||
private function getNextCatId()
|
||||
{
|
||||
return $this->con->select(
|
||||
'SELECT MAX(cat_id) FROM ' . $this->table . '_cat '
|
||||
'SELECT MAX(cat_id) FROM ' . $this->cat_table . ' '
|
||||
)->f(0) + 1;
|
||||
}
|
||||
|
||||
|
@ -438,7 +441,7 @@ class cinecturlink2
|
|||
private function getNextCatPos()
|
||||
{
|
||||
return $this->con->select(
|
||||
'SELECT MAX(cat_pos) FROM ' . $this->table . '_cat ' .
|
||||
'SELECT MAX(cat_pos) FROM ' . $this->cat_table . ' ' .
|
||||
"WHERE blog_id = '" . $this->blog . "' "
|
||||
)->f(0) + 1;
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ if ($part == 'cats') {
|
|||
$i = 0;
|
||||
foreach ($catorder as $id) {
|
||||
$i++;
|
||||
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
|
||||
$cur = dcCore::app()->con->openCursor($C2->cat_table);
|
||||
$cur->cat_pos = $i;
|
||||
$C2->updCategory($id, $cur);
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ if ($part == 'cat') {
|
|||
if ($exists) {
|
||||
throw new Exception(__('Category with same name already exists.'));
|
||||
}
|
||||
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
|
||||
$cur = dcCore::app()->con->openCursor($C2->cat_table);
|
||||
$cur->cat_title = $cattitle;
|
||||
$cur->cat_desc = $catdesc;
|
||||
|
||||
|
@ -373,7 +373,7 @@ if ($part == 'cat') {
|
|||
if ($exists) {
|
||||
throw new Exception(__('Category with same name already exists.'));
|
||||
}
|
||||
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
|
||||
$cur = dcCore::app()->con->openCursor($C2->cat_table);
|
||||
$cur->cat_title = $cattitle;
|
||||
$cur->cat_desc = $catdesc;
|
||||
|
||||
|
|
Loading…
Reference in a new issue