- Remove unused method and unit test of doc::getPreAndNextDoc.

This commit is contained in:
tianshujie
2023-12-08 15:41:04 +08:00
parent b32ecfe8a5
commit 2376dbc499
2 changed files with 0 additions and 94 deletions
-57
View File
@@ -1889,63 +1889,6 @@ class docModel extends model
return $statistic;
}
/**
* Get the previous and next doc.
*
* @param int $docID
* @param int $libID
* @access public
* @return object
*/
public function getPreAndNextDoc($docID, $libID)
{
$sortedModules = 0;
$modules = $this->dao->select('id')->from(TABLE_MODULE)
->where('root')->eq($libID)
->andWhere('type')->eq('doc')
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`')
->fetchPairs();
if(!empty($modules)) $sortedModules = implode(',', array_keys($modules)) . ',0';
$query = $this->dao->select('t1.id,t1.title,t1.acl,t1.groups,t1.users,t1.addedBy,t1.lib,t2.type,t2.product,t2.project,t2.execution')->from(TABLE_DOC)->alias('t1')
->leftJoin(TABLE_DOCLIB)->alias('t2')->on('t1.lib=t2.id')
->where('t1.deleted')->eq(0)
->andWhere('t1.lib')->eq($libID)
->beginIF($this->config->doc->notArticleType)->andWhere('t1.type')->notIN($this->config->doc->notArticleType)->fi()
->get();
$query .= " order by field(module, $sortedModules)";
$stmt = $this->dbh->query($query);
$docs = $stmt->fetchAll();
$preAndNextDoc = new stdClass();
$preAndNextDoc->pre = '';
$preAndNextDoc->next = '';
$preDoc = false;
foreach($docs as $doc)
{
$doc->objectType = 'doc';
/* Get next object. */
if($preDoc === true and $this->checkPrivDoc($doc))
{
$preAndNextDoc->next = $doc;
break;
}
/* Get pre object. */
if($doc->id == $docID)
{
if($preDoc) $preAndNextDoc->pre = $preDoc;
$preDoc = true;
}
if($preDoc !== true and $this->checkPrivDoc($doc)) $preDoc = $doc;
}
return $preAndNextDoc;
}
/**
* Print doc child module.
*
@@ -1,37 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/doc.class.php';
su('admin');
/**
title=测试 docModel->getPreAndNextDoc();
cid=1
pid=1
*/
$doc = new docTest();
$docIDList = array(0, 1, 2, 1000);
$libIDList = array(0, 1, 2, 1000);
r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[0])) && p('pre,next') && e(','); // 查询空数据
r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID为空的数据
r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID为空的数据
r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID为空的数据
r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[0])) && p('pre,next') && e(','); // 查询文档库ID为空的数据
r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[0])) && p('pre,next') && e(','); // 查询文档库ID为空的数据
r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[0])) && p('pre,next') && e(','); // 查询文档库ID为空的数据
r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID为1并且文档库ID为1的数据
r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID为2并且文档库ID为1的数据
r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID不存在并且文档库ID为1的数据
r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID为1并且文档库ID为2的数据
r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID为2并且文档库ID为2的数据
r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID不存在并且文档库ID为2的数据
r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID为1并且文档库ID不存在的数据
r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID为2并且文档库ID不存在的数据
r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID不存在并且文档库ID不存在的数据