From 18a60f895cd0e26ac829864717f0a5de7784204a Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 10 Apr 2023 16:06:01 +0800 Subject: [PATCH] * code for task #89909. --- module/doc/control.php | 26 +++++-- module/doc/model.php | 110 ++++++++++++++++++++---------- module/doc/view/lefttree.html.php | 2 +- 3 files changed, 95 insertions(+), 43 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 4455e65b54..011f93dce0 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -67,7 +67,7 @@ class doc extends control * @access public * @return void */ - public function mySpace($type = 'mine', $libID = 0, $moduleID = 0, $browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function mySpace($type = 'mine', $libID = 0, $moduleID = 0, $browseType = 'all', $param = 0, $orderBy = 'status,id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Save session, load module. */ $uri = $this->app->getURI(true); @@ -99,15 +99,25 @@ class doc extends control /* Append id for secend sort. */ $sort = common::appendOrder($orderBy); + $docs = array(); + if($type == 'mine') + { + $docs = $this->doc->getDocs($libID, $moduleID, $browseType, $orderBy, $pager); + } + elseif($type == 'view' or $type == 'collect' or $type == 'createdby') + { + $docs = $this->doc->getMineList($type, $browseType, $orderBy, $pager); + } + $this->view->moduleID = $moduleID; - $this->view->docs = $this->doc->getDocsByBrowseType($browseType, $queryID, $moduleID, $sort, $pager); + $this->view->docs = $docs; $this->view->users = $this->user->getPairs('noletter'); $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; $this->view->param = $param; $this->view->libID = $libID; $this->view->lib = $this->doc->getLibById($libID); - $this->view->libTree = $this->doc->getLibTree($type != 'mine' ? 0 : $libID, $libs, 'mine', 0); + $this->view->libTree = $this->doc->getLibTree($type != 'mine' ? 0 : $libID, $libs, 'mine', $moduleID); $this->view->pager = $pager; $this->view->type = $type; $this->view->objectID = 0; @@ -1320,7 +1330,6 @@ class doc extends control $this->view->exportMethod = $libType == 'api' ? 'export' : $type . '2export'; $this->view->apiLibID = key($apiLibs); - $this->display(); } @@ -1392,8 +1401,13 @@ class doc extends control $spaceList = $this->lang->doc->spaceList; $typeList = $this->lang->doc->types; - if(!common::hasPriv('doc', 'create')) unset($spaceList['mine'], $spaceList['custom'], $typeList['doc']); - if(!common::hasPriv('api', 'create')) unset($spaceList['api'], $typeList['api']); + if(!common::hasPriv('doc', 'create')) unset($spaceList['mine'], $spaceList['custom'], $typeList['doc']); + if(!common::hasPriv('doc', 'mySpace')) unset($spaceList['mine']); + if(!common::hasPriv('doc', 'productSpace')) unset($spaceList['product']); + if(!common::hasPriv('doc', 'projectSpace')) unset($spaceList['project']); + if(!common::hasPriv('doc', 'tableContents')) unset($spaceList['custom']); + if(!common::hasPriv('api', 'index')) unset($spaceList['api']); + if(!common::hasPriv('api', 'create')) unset($spaceList['api'], $typeList['api']); $products = $this->loadModel('product')->getPairs(); $projects = $this->project->getPairsByProgram('', 'all', false, 'order_asc', 'kanban'); diff --git a/module/doc/model.php b/module/doc/model.php index cd64176a8c..89846b99bf 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -482,43 +482,9 @@ class docModel extends model if(empty($docs)) return array(); /* Get projects, executions and products by docIdList. */ - list($projects, $executions, $products) = $this->getObjectsByDoc(array_keys($docs)); - $mineLibs = $this->getAllLibsByType('mine'); - $customLibs = $this->getAllLibsByType('custom'); $docContents = $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->in(array_keys($docs))->orderBy('version,doc')->fetchAll('doc'); - - $modules = array(); - $objects = array('product' => 'products', 'execution' => 'executions', 'project' => 'projects'); - $this->loadModel('tree'); foreach($docs as $index => $doc) { - if(!isset($modules[$doc->lib])) $modules[$doc->lib] = $this->tree->getOptionMenu($doc->lib, 'doc', 0, 0, 'nodeleted', 'all', ' > '); - $doc->moduleName = zget($modules[$doc->lib], $doc->module); - $doc->moduleName = ltrim($doc->moduleName, '/'); - $doc->libName = zget($allLibs, $doc->lib); - foreach($objects as $type => $object) - { - if(!empty($doc->{$type})) - { - $doc->objectID = $doc->{$type}; - $doc->objectName = ${$object}[$doc->{$type}]; - $doc->objectType = $type; - break; - } - } - if(isset($mineLibs[$doc->lib])) - { - $doc->objectID = 0; - $doc->objectName = $this->lang->doc->person; - $doc->objectType = 'mine'; - } - elseif(isset($customLibs[$doc->lib])) - { - $doc->objectID = 0; - $doc->objectName = $this->lang->doc->team; - $doc->objectType = 'custom'; - } - $docs[$index]->fileSize = 0; if(isset($files[$index])) { @@ -638,7 +604,7 @@ class docModel extends model * @param string $orderBy * @param object $pager * @access public - * @return void + * @return array */ public function getDocs($libID, $module, $browseType, $orderBy, $pager = null) { @@ -656,6 +622,73 @@ class docModel extends model return $docs; } + /** + * Get mine list. + * + * @param string $type view|collect|createdBy + * @param string $browseType all|draft + * @param string $orderBy + * @param object $pager + * @access public + * @return array + */ + public function getMineList($type, $browseType, $orderBy, $pager = null) + { + if($type == 'view' or $type == 'collect') + { + $docs = $this->dao->select('DISTINCT t1.*,t3.name as libName,t3.type as objectType')->from(TABLE_DOC)->alias('t1') + ->leftJoin(TABLE_DOCACTION)->alias('t2')->on("t1.id=t2.doc") + ->leftJoin(TABLE_DOCLIB)->alias('t3')->on("t1.lib=t3.id") + ->where('t1.deleted')->eq(0) + ->andWhere('t1.vision')->eq($this->config->vision) + ->andWhere('t2.action')->eq($type) + ->andWhere('t2.actor')->eq($this->app->user->account) + ->beginIF($browseType == 'all')->andWhere("(t1.status = 'normal' or (t1.status = 'draft' and t1.addedBy='{$this->app->user->account}'))")->fi() + ->beginIF($browseType == 'draft')->andWhere('t1.status')->eq('draft')->fi() + ->orderBy($orderBy) + ->page($pager, 't1.id') + ->fetchAll('id'); + } + elseif($type == 'createdby') + { + $docs = $this->dao->select('DISTINCT t1.*,t2.name as libName,t2.type as objectType')->from(TABLE_DOC)->alias('t1') + ->leftJoin(TABLE_DOCLIB)->alias('t2')->on("t1.lib=t2.id") + ->where('t1.deleted')->eq(0) + ->andWhere('t1.vision')->eq($this->config->vision) + ->andWhere('t1.addedBy')->eq($this->app->user->account) + ->beginIF($browseType == 'draft')->andWhere('t1.status')->eq('draft')->fi() + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); + } + + $this->loadModel('tree'); + $objects = array(); + $modules = array(); + list($objects['project'], $objects['execution'], $objects['product']) = $this->getObjectsByDoc(array_keys($docs)); + foreach($docs as $docID => $doc) + { + if(!isset($modules[$doc->lib])) $modules[$doc->lib] = $this->tree->getOptionMenu($doc->lib, 'doc', 0, 0, 'nodeleted', 'all', ' > '); + $doc->moduleName = zget($modules[$doc->lib], $doc->module); + $doc->moduleName = ltrim($doc->moduleName, '/'); + + $doc->objectID = zget($doc, $doc->objectType, 0); + $doc->objectName = ''; + if(isset($objects[$doc->objectType])) + { + $doc->objectName = $objects[$doc->objectType][$doc->objectID]; + } + else + { + if($doc->objectType == 'mine') $doc->objectName = $this->lang->doc->person; + if($doc->objectType == 'custom') $doc->objectName = $this->lang->doc->team; + } + } + + $docs = $this->processCollector($docs); + return $docs; + } + /** * Get priv docs. * @@ -3034,6 +3067,7 @@ class docModel extends model $myLib->objectID = 0; $myLib->active = 0; $myLib->hasAction = false; + $myLib->active = $libID ? 1 : 0; $myLib->children = $libTree; $myView = new stdclass(); @@ -3063,7 +3097,11 @@ class docModel extends model $myCreation->hasAction = false; $myCreation->active = zget($this->app->rawParams, 'type', '') == 'createdBy' ? 1 : 0; - $libTree = array($myLib, $myView, $myCollection, $myCreation); + $libTree = array(); + $libTree[] = $myLib; + if(common::hasPriv('doc', 'myView')) $libTree[] = $myView; + if(common::hasPriv('doc', 'myCollection')) $libTree[] = $myCollection; + if(common::hasPriv('doc', 'myCreation')) $libTree[] = $myCreation; } return $libTree; } diff --git a/module/doc/view/lefttree.html.php b/module/doc/view/lefttree.html.php index 25199c0572..4886815796 100644 --- a/module/doc/view/lefttree.html.php +++ b/module/doc/view/lefttree.html.php @@ -445,7 +445,7 @@ $(function() methodName = 'showFiles'; linkParams = 'type=' + objectType + '&objectID=' + objectID; } - else if(objectType == 'mine' || objectType == 'view' || objectType == 'collect' || objectType == 'createdBy') + else if(objectType == 'mine' || objectType == 'view' || objectType == 'collect' || objectType == 'createdby') { var mySpaceType = 'mine'; if(type == 'view' || type == 'collect' || type == 'createdBy') mySpaceType = type;