diff --git a/module/doc/config.php b/module/doc/config.php index bd3cd15bda..6bfa361ad2 100644 --- a/module/doc/config.php +++ b/module/doc/config.php @@ -23,11 +23,11 @@ $config->doc->markdown->create = array('id' => 'contentMarkdown', 'tools' => 'wi $config->doc->search['module'] = 'doc'; $config->doc->search['fields']['title'] = $lang->doc->title; $config->doc->search['fields']['id'] = $lang->doc->id; -$config->doc->search['fields']['keywords'] = $lang->doc->keywords; $config->doc->search['fields']['product'] = $lang->doc->product; $config->doc->search['fields']['project'] = $lang->doc->project; -$config->doc->search['fields']['module'] = $lang->doc->module; $config->doc->search['fields']['lib'] = $lang->doc->lib; +$config->doc->search['fields']['module'] = $lang->doc->module; +$config->doc->search['fields']['keywords'] = $lang->doc->keywords; $config->doc->search['fields']['addedBy'] = $lang->doc->addedBy; $config->doc->search['fields']['addedDate'] = $lang->doc->addedDate; $config->doc->search['fields']['editedBy'] = $lang->doc->editedBy; @@ -37,7 +37,7 @@ $config->doc->search['fields']['version'] = $lang->doc->version; $config->doc->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->doc->search['params']['keywords'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->doc->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => ''); -$config->doc->search['params']['module'] = array('operator' => '=', 'control' => 'select', 'values' => ''); +$config->doc->search['params']['module'] = array('operator' => 'belong', 'control' => 'select', 'values' => ''); $config->doc->search['params']['project'] = array('operator' => '=', 'control' => 'select', 'values' => ''); $config->doc->search['params']['lib'] = array('operator' => '=', 'control' => 'select', 'values' => '' ); $config->doc->search['params']['addedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); diff --git a/module/doc/model.php b/module/doc/model.php index 0f34e81c22..aba5cadfb6 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -221,11 +221,21 @@ class docModel extends model { if($this->session->docQuery == false) $this->session->set('docQuery', ' 1 = 1'); } - $docQuery = str_replace("`product` = 'all'", '1', $this->session->docQuery); // Search all producti. + + $libCond = strpos($this->session->docQuery, "`lib` = ") !== false; + $allLibCond = strpos($this->session->docQuery, "`lib` = 'all'") !== false; + + $docQuery = str_replace("`product` = 'all'", '1', $this->session->docQuery); // Search all product. $docQuery = str_replace("`project` = 'all'", '1', $docQuery); // Search all project. + $docQuery = str_replace("`lib` = 'all'", '1', $docQuery); // Search all lib. + $condition = $this->buildConditionSQL(); - $docs = $this->dao->select('*')->from(TABLE_DOC)->where($docQuery) + $libIdList = $this->dao->select('id')->from(TABLE_DOCLIB)->beginIF($condition)->where("($condition)")->fi()->get(); + + $docs = $this->dao->select('*')->from(TABLE_DOC)->where($docQuery) ->beginIF($condition)->andWhere("($condition)")->fi() + ->beginIF(!$libCond)->andWhere("lib")->eq($libID)->fi() + ->beginIF($allLibCond and $condition)->andWhere("lib in ($libIdList)")->fi() ->andWhere('deleted')->eq(0) ->orderBy($sort)->page($pager) ->fetchAll(); @@ -464,7 +474,7 @@ class docModel extends model $this->config->doc->search['queryID'] = $queryID; $this->config->doc->search['params']['product']['values'] = array(''=>'') + $this->loadModel('product')->getPairs('nocode') + array('all'=>$this->lang->doc->allProduct); $this->config->doc->search['params']['project']['values'] = array(''=>'') + $this->loadModel('project')->getPairs('nocode') + array('all'=>$this->lang->doc->allProject); - $this->config->doc->search['params']['lib']['values'] = array(''=>'') + $libs; + $this->config->doc->search['params']['lib']['values'] = array(''=>'', $libID => $libs[$libID], 'all' => $this->lang->doclib->all); /* Get the modules. */ $moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($libID . 'doc', $startModuleID = 0); @@ -606,20 +616,6 @@ class docModel extends model return false; } - /** - * Get doc link. - * - * @param string $module - * @param string $method - * @param string $extra - * @access public - * @return string - */ - public function getDocLink($module, $method, $extra = '') - { - return helper::createLink($module, $method, "libID=%s"); - } - /** * Get all libs by type. * diff --git a/module/doc/view/index.html.php b/module/doc/view/index.html.php index 5590221b80..590fd65487 100644 --- a/module/doc/view/index.html.php +++ b/module/doc/view/index.html.php @@ -13,12 +13,13 @@
- $libs):?> + $libs):?> +
id"); + if($libID == 'project') $libLink = inlink('allLibs', "type=project&product=$object->id"); if($libID == 'files') $libLink = inlink('showFiles', "type=$type&objectID=$object->id"); ?> diff --git a/module/project/model.php b/module/project/model.php index c160476651..11057ae0ff 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -269,6 +269,7 @@ class projectModel extends model } /* Create doc lib. */ + $this->app->loadLang('doc'); $lib = new stdclass(); $lib->project = $projectID; $lib->name = $this->lang->doclib->main['project']; diff --git a/module/search/model.php b/module/search/model.php index 2ca4c460c9..8a9218a776 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -68,10 +68,6 @@ class searchModel extends model /* Set and or. */ $andOr = strtoupper($this->post->$andOrName); if($andOr != 'AND' and $andOr != 'OR') $andOr = 'AND'; - $where .= " $andOr "; - - /* Set filed name. */ - $where .= '`' . $this->post->$fieldName . '` '; /* Set operator. */ $value = $this->post->$valueName; @@ -81,35 +77,40 @@ class searchModel extends model /* Escape char. */ $value = str_replace(array('\\', '%', '_'), array('\\\\', '\\%', '\\_'), $value); + /* Set condition. */ + $condition = ''; if($operator == "include") { - $where .= ' LIKE ' . $this->dbh->quote("%$value%"); + $condition = ' LIKE ' . $this->dbh->quote("%$value%"); } elseif($operator == "notinclude") { - $where .= ' NOT LIKE ' . $this->dbh->quote("%$value%"); + $condition = ' NOT LIKE ' . $this->dbh->quote("%$value%"); } elseif($operator == 'belong') { if($this->post->$fieldName == 'module') { $allModules = $this->loadModel('tree')->getAllChildId($value); - if($allModules) $where .= helper::dbIN($allModules); + if($allModules) $condition = helper::dbIN($allModules); } elseif($this->post->$fieldName == 'dept') { $allDepts = $this->loadModel('dept')->getAllChildId($value); - $where .= helper::dbIN($allDepts); + $condition = helper::dbIN($allDepts); } else { - $where .= ' = ' . $this->dbh->quote($value) . ' '; + $condition = ' = ' . $this->dbh->quote($value) . ' '; } } else { - $where .= $operator . ' ' . $this->dbh->quote($value) . ' '; + $condition = $operator . ' ' . $this->dbh->quote($value) . ' '; } + + /* Set filed name. */ + if($condition) $where .= " $andOr " . '`' . $this->post->$fieldName . '` ' . $condition; } $where .=" ))"; @@ -334,7 +335,7 @@ class searchModel extends model } /** - * Get records by the conditon. + * Get records by the condition. * * @param string $module * @param string $moduleIdList