diff --git a/module/doc/model.php b/module/doc/model.php index 8271ac6020..44abb3b41f 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -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. * diff --git a/module/doc/test/model/getpreandnextdoc.php b/module/doc/test/model/getpreandnextdoc.php deleted file mode 100755 index d034e149d5..0000000000 --- a/module/doc/test/model/getpreandnextdoc.php +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env php -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不存在的数据 \ No newline at end of file