* Adjust block test script.
This commit is contained in:
+90
-27
@@ -13,8 +13,8 @@ declare(strict_types=1);
|
||||
class blockModel extends model
|
||||
{
|
||||
/**
|
||||
* 检查然之请求时发起的hash是否匹配。
|
||||
* Check API for ranzhi.
|
||||
* 检查ZDOO请求时发起的哈希值是否匹配。
|
||||
* Check if the hash value matches when requesting ZDOO.
|
||||
*
|
||||
* @param string $hash
|
||||
* @access public
|
||||
@@ -34,8 +34,8 @@ class blockModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据区块ID获取区块信息.
|
||||
* Get a block by blockID.
|
||||
* 根据区块ID获取区块信息。
|
||||
* Get a block by id.
|
||||
*
|
||||
* @param int $blockID
|
||||
* @access public
|
||||
@@ -54,13 +54,68 @@ class blockModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取被永久关闭的区块数据。
|
||||
* getClosedBlockPairs
|
||||
*
|
||||
* @param int $closedBlock
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getClosedBlockPairs($closedBlock)
|
||||
{
|
||||
$blockPairs = array();
|
||||
if(empty($closedBlock)) return $blockPairs;
|
||||
|
||||
foreach(explode(',', $closedBlock) as $block)
|
||||
{
|
||||
$block = trim($block);
|
||||
if(empty($block)) continue;
|
||||
|
||||
list($moduleName, $blockKey) = explode('|', $block);
|
||||
if($moduleName == $blockKey)
|
||||
{
|
||||
$blockPairs[$block] = $this->lang->block->moduleList[$moduleName];
|
||||
}
|
||||
else
|
||||
{
|
||||
$blockName = $blockKey;
|
||||
if(isset($this->lang->block->modules[$moduleName]->availableBlocks[$blockKey])) $blockName = $this->lang->block->modules[$moduleName]->availableBlocks[$blockKey];
|
||||
if(isset($this->lang->block->availableBlocks[$blockKey])) $blockName = $this->lang->block->availableBlocks[$blockKey];
|
||||
$blockPairs[$block] = "{$this->lang->block->moduleList[$moduleName]}|{$blockName}";
|
||||
}
|
||||
}
|
||||
|
||||
return $blockPairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台信息区块参数信息。
|
||||
* get admin information block parameter information.
|
||||
*
|
||||
* @param string $startDate
|
||||
* @access public
|
||||
* @return array|false
|
||||
*/
|
||||
public function getAdminBlockList(string $startDate = ''): array|false
|
||||
{
|
||||
return $this->dao->select('code,params')->from(TABLE_BLOCK)
|
||||
->where('account')->eq('system')
|
||||
->andWhere('vision')->eq('rnd')
|
||||
->andWhere('dashboard')->eq('zentao')
|
||||
->andWhere('module')->eq('zentao')
|
||||
->andWhere('code')->in('plugin,patch,publicclass,news')
|
||||
->beginIF($startDate)->andWhere('createdDate')->ge($startDate)->fi()
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的区块列表。
|
||||
* Get block list of current user.
|
||||
* 获取区块列表.
|
||||
*
|
||||
* @param string $module
|
||||
* @param int $hidden
|
||||
* @access public
|
||||
* @return int[]|false
|
||||
* @return array|false
|
||||
*/
|
||||
public function getMyDashboard(string $dashboard, int $hidden = 0): array|false
|
||||
{
|
||||
@@ -68,12 +123,12 @@ class blockModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取隐藏的区块列表.
|
||||
* Get hidden blocks
|
||||
* 获取隐藏的区块列表。
|
||||
* Get hidden blocks.
|
||||
*
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return int[]|false
|
||||
* @return array|false
|
||||
*/
|
||||
public function getMyHiddenBlocks(string $dashboard): array|false
|
||||
{
|
||||
@@ -81,8 +136,8 @@ class blockModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应仪表盘下区块的最大排序号.
|
||||
* Get max order number by block dashboard.
|
||||
* 获取对应仪表盘下区块的最大排序号。
|
||||
* Get block max order number by dashboard.
|
||||
*
|
||||
* @param string $dashboard
|
||||
* @access public
|
||||
@@ -210,7 +265,7 @@ class blockModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区块是否已经初始化的状态.
|
||||
* 获取区块是否已经初始化的状态。
|
||||
* get block is initiated or not.
|
||||
*
|
||||
* @param string $dashboard
|
||||
@@ -219,7 +274,7 @@ class blockModel extends model
|
||||
*/
|
||||
public function getBlockInitStatus(string $dashboard): bool
|
||||
{
|
||||
$result = $this->dao->select('*')->from(TABLE_CONFIG)
|
||||
$result = $this->dao->select('value')->from(TABLE_CONFIG)
|
||||
->where('module')->eq($dashboard)
|
||||
->andWhere('owner')->eq($this->app->user->account)
|
||||
->andWhere('`section`')->eq('common')
|
||||
@@ -227,24 +282,24 @@ class blockModel extends model
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->fetch('value');
|
||||
|
||||
return $result ? true : false;
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查此区块是否为长区块。
|
||||
* Check whether long block.
|
||||
*
|
||||
* @param object $block
|
||||
* @param object $block
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function isLongBlock(object $block): bool
|
||||
{
|
||||
return (!empty($block->grid) and $block->grid >= 6) ? true : false;
|
||||
return (!empty($block->grid) and $block->grid >= 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化用户某个仪表盘下的区块数据.
|
||||
* 初始化用户某个仪表盘下的区块数据。
|
||||
* Init block when account use first.
|
||||
*
|
||||
* @param string $dashboard
|
||||
@@ -286,7 +341,7 @@ class blockModel extends model
|
||||
*
|
||||
* @param object $formData
|
||||
* @access public
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function create(object $formData): int|false
|
||||
{
|
||||
@@ -305,7 +360,7 @@ class blockModel extends model
|
||||
*
|
||||
* @param object $formData
|
||||
* @access public
|
||||
* @return void
|
||||
* @return int|false
|
||||
*/
|
||||
public function update(object $formData): int|false
|
||||
{
|
||||
@@ -326,7 +381,7 @@ class blockModel extends model
|
||||
* 对应仪表盘删除所有区块并更新为待初始化状态。
|
||||
* Reset dashboard blocks.
|
||||
*
|
||||
* @param string $dashboard
|
||||
* @param string $dashboard
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
@@ -345,26 +400,33 @@ class blockModel extends model
|
||||
->andWhere('`key`')->eq('blockInited')
|
||||
->exec();
|
||||
|
||||
return true;
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个区块。
|
||||
* Delete a block.
|
||||
* 根据ID删除一个区块或者根据代号删除多个区块。
|
||||
* Delete a block based on id or multiple blocks based on code.
|
||||
*
|
||||
* @param int $blockID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteBlock(int $blockID): bool
|
||||
public function deleteBlock(int $blockID = 0, string $module = '', string $code = ''): bool
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_BLOCK)
|
||||
->where('id')->eq($blockID)
|
||||
->where('1=1')
|
||||
->beginIF($blockID)
|
||||
->andWhere('id')->eq($blockID)
|
||||
->andWhere('account')->eq($this->app->user->account)
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->fi()
|
||||
->beginIF($module and $code)
|
||||
->andWhere('module')->eq($module)
|
||||
->andWhere('code')->eq($code)
|
||||
->fi()
|
||||
->exec();
|
||||
|
||||
return true;
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,6 +441,7 @@ class blockModel extends model
|
||||
public function setOrder(int $blockID, int $order): bool
|
||||
{
|
||||
$this->dao->update(TABLE_BLOCK)->set('order')->eq($order)->where('id')->eq($blockID)->exec();
|
||||
return true;
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user