fix query

This commit is contained in:
joyqi 2023-12-29 12:59:33 +08:00
parent 6b2c5b19e1
commit 7edd3f9659
3 changed files with 33 additions and 7 deletions

View File

@ -562,12 +562,12 @@ class Archive extends Contents
/** 定时发布功能 */
if (!$selectPlugged) {
if ($this->parameter->preview) {
$select = $this->select();
} else {
$select = $this->select('table.contents.*');
if (!$this->parameter->preview) {
if ('post' == $this->parameter->type || 'page' == $this->parameter->type) {
if ($this->user->hasLogin()) {
$select = $this->select()->where(
$select->where(
'table.contents.status = ? OR table.contents.status = ?
OR (table.contents.status = ? AND table.contents.authorId = ?)',
'publish',
@ -576,7 +576,7 @@ class Archive extends Contents
$this->user->uid
);
} else {
$select = $this->select()->where(
$select->where(
'table.contents.status = ? OR table.contents.status = ?',
'publish',
'hidden'
@ -584,14 +584,14 @@ class Archive extends Contents
}
} else {
if ($this->user->hasLogin()) {
$select = $this->select()->where(
$select->where(
'table.contents.status = ? OR (table.contents.status = ? AND table.contents.authorId = ?)',
'publish',
'private',
$this->user->uid
);
} else {
$select = $this->select()->where('table.contents.status = ?', 'publish');
$select->where('table.contents.status = ?', 'publish');
}
}
$select->where('table.contents.created < ?', $this->options->time);

View File

@ -2,6 +2,7 @@
namespace Widget\Contents;
use Typecho\Config;
use Typecho\Db\Exception;
use Widget\Base\Contents;
use Widget\Base\TreeTrait;
@ -20,6 +21,18 @@ class From extends Contents
___directory as ___treeDirectory;
}
/**
* @param Config $parameter
* @return void
*/
protected function initParameter(Config $parameter)
{
$parameter->setDefault([
'cid' => null,
'query' => null,
]);
}
/**
* @return void
* @throws Exception

View File

@ -2,6 +2,7 @@
namespace Widget\Metas;
use Typecho\Config;
use Typecho\Db\Exception;
use Widget\Base\Metas;
use Widget\Base\TreeTrait;
@ -14,6 +15,18 @@ class From extends Metas
initParameter as initTreeParameter;
}
/**
* @param Config $parameter
* @return void
*/
protected function initParameter(Config $parameter)
{
$parameter->setDefault([
'mid' => null,
'query' => null,
]);
}
/**
* @return void
* @throws Exception