diff --git a/_init.php b/_init.php new file mode 100644 index 0000000..36e9d4d --- /dev/null +++ b/_init.php @@ -0,0 +1,21 @@ +=')) { 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) diff --git a/_uninstall.php b/_uninstall.php index 7cde231..2b47b2e 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -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') ); diff --git a/inc/class.cinecturlink2.php b/inc/class.cinecturlink2.php index 007ec41..35dc984 100644 --- a/inc/class.cinecturlink2.php +++ b/inc/class.cinecturlink2.php @@ -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; } diff --git a/index.php b/index.php index bf49e77..21fe5bf 100644 --- a/index.php +++ b/index.php @@ -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;