diff --git a/module/doc/control.php b/module/doc/control.php index e3a8e262c1..74ab852b71 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -355,8 +355,10 @@ class doc extends control $this->view->position[] = html::a($this->createLink('doc', 'browse', "libID=$libID"), $lib->name); $this->view->position[] = $this->lang->doc->create; + $unclosed = strpos($this->config->doc->custom->showLibs, 'unclosed') !== false ? 'unclosedProject' : ''; + $this->view->libID = $libID; - $this->view->libs = $this->doc->getLibs($type = 'all', $extra = 'withObject'); + $this->view->libs = $this->doc->getLibs($type = 'all', $extra = "withObject,$unclosed", $libID); $this->view->libName = $this->dao->findByID($libID)->from(TABLE_DOCLIB)->fetch('name'); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0); $this->view->moduleID = $moduleID; diff --git a/module/doc/model.php b/module/doc/model.php index c7a7aee5fb..85cd23b6fe 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -148,11 +148,15 @@ class docModel extends model elseif($type == 'all') { /* Associated display Settings -> shows only unclosed projects.*/ - $stmt = $this->dao->select('distinct t1.*')->from(TABLE_DOCLIB)->alias('t1') - ->leftJoin(TABLE_PROJECT)->alias('t2')->on("t1.project = '' || t1.project = t2.id") - ->where('t1.deleted')->eq(0) - ->beginIF(strpos($this->config->doc->custom->showLibs,'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi() - ->orderBy('t1.order,t1.id desc') + $undoneSql = $this->dao->select('id')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('status')->notin('done,closed')->get(); + $stmt = $this->dao->select('*')->from(TABLE_DOCLIB) + ->where('deleted')->eq(0) + ->beginIF(strpos($extra, 'unclosedProject') !== false) + ->andWhere('project', true)->eq('0') + ->orWhere("project IN ($undoneSql)") + ->markRight(1) + ->fi() + ->orderBy('`order`,id desc') ->query(); } else