doc->noDoc;?>
diff --git a/module/doc/config.php b/module/doc/config.php index a8c78892f1..626efc5a30 100644 --- a/module/doc/config.php +++ b/module/doc/config.php @@ -1,5 +1,5 @@ doc = new stdclass(); $config->doc->createlib = new stdclass(); @@ -35,28 +35,30 @@ $config->doc->iconList['word'] = 'word'; $config->doc->iconList['ppt'] = 'ppt'; $config->doc->iconList['excel'] = 'excel'; -$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']['product'] = $lang->doc->product; -$config->doc->search['fields']['execution'] = $lang->doc->execution; -$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; -$config->doc->search['fields']['editedDate'] = $lang->doc->editedDate; -$config->doc->search['fields']['version'] = $lang->doc->version; +$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']['product'] = $lang->doc->product; +if($app->rawMethod == 'contribute') $config->doc->search['fields']['project'] = $lang->doc->project; +$config->doc->search['fields']['execution'] = $lang->doc->execution; +$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; +$config->doc->search['fields']['editedDate'] = $lang->doc->editedDate; +$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' => 'belong', 'control' => 'select', 'values' => ''); -$config->doc->search['params']['execution'] = 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'); -$config->doc->search['params']['addedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); -$config->doc->search['params']['editedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); -$config->doc->search['params']['editedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); -$config->doc->search['params']['version'] = array('operator' => '=', 'control' => 'input', 'values' => ''); +$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' => 'belong', 'control' => 'select', 'values' => ''); +if($app->rawMethod == 'contribute') $config->doc->search['params']['project'] = array('operator' => '=', 'control' => 'select', 'values' => ''); +$config->doc->search['params']['execution'] = 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'); +$config->doc->search['params']['addedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); +$config->doc->search['params']['editedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); +$config->doc->search['params']['editedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); +$config->doc->search['params']['version'] = array('operator' => '=', 'control' => 'input', 'values' => ''); diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index c615e7a983..25738bfb22 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -156,6 +156,7 @@ global $config; /* Query condition list. */ $lang->doc->allProduct = 'All' . $lang->productCommon . 's'; $lang->doc->allExecutions = 'All' . $lang->executionCommon . 's'; +$lang->doc->allProjects = 'All' . $lang->projectCommon . 's'; $lang->doc->libTypeList['product'] = $lang->productCommon . ' Library'; if($config->systemMode == 'new') $lang->doc->libTypeList['project'] = 'Project Library'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index c3bbff2e37..112b990c3d 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -156,6 +156,7 @@ global $config; /* 查询条件列表 */ $lang->doc->allProduct = '所有' . $lang->productCommon; $lang->doc->allExecutions = '所有' . $lang->executionCommon; +$lang->doc->allProjects = '所有' . $lang->projectCommon; $lang->doc->libTypeList['product'] = $lang->productCommon . '文档库'; if($config->systemMode == 'new') $lang->doc->libTypeList['project'] = '项目文档库'; diff --git a/module/doc/model.php b/module/doc/model.php index a225a3f2ee..bd8dcd90f5 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -337,6 +337,44 @@ class docModel extends model { $docs = $this->getDocs(0, 0, $sort, $pager); } + elseif($browseType == 'bySearch') + { + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set('contributeDocQuery', $query->sql); + $this->session->set('contributeDocForm', $query->form); + } + else + { + $this->session->set('contributeDocQuery', ' 1 = 1'); + } + } + else + { + if($this->session->contributeDocQuery == false) $this->session->set('contributeDocQuery', ' 1 = 1'); + } + + $query = $this->getDocQuery($this->session->contributeDocQuery); + $docIDList = $this->dao->select('objectID')->from(TABLE_ACTION) + ->where('objectType')->eq('doc') + ->andWhere('actor')->eq($this->app->user->account) + ->andWhere('action')->eq('edited') + ->fetchAll('objectID'); + $docs = $this->dao->select('*')->from(TABLE_DOC) + ->where('deleted')->eq(0) + ->andWhere($query) + ->andWhere('lib')->in($allLibs) + ->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi() + ->andWhere('addedBy', 1)->eq($this->app->user->account) + ->orWhere('id')->in(array_keys($docIDList)) + ->markRight(1) + ->orderBy($sort) + ->page($pager) + ->fetchAll('id'); + } elseif($browseType == "openedbyme") { $docs = $this->dao->select('*')->from(TABLE_DOC) @@ -443,6 +481,51 @@ class docModel extends model return $docs; } + /** + * Replace all in query. + * + * @param string $query + * @access public + * @return string + */ + public function getDocQuery($query) + { + $allLibs = "`lib` = 'all'"; + if(strpos($query, $allLibs) !== false) + { + $libs = $this->loadModel('doc')->getLibs('all', 'withObject'); + $query = str_replace($allLibs, '1', $query); + $query = $query . ' AND `lib` ' . helper::dbIN($libs); + } + + $allProject = "`project` = 'all'"; + if(strpos($query, $allProject) !== false) + { + $projectIDList = $this->loadModel('bug')->getAllProjectIds(); + if(is_array($projectIDList)) $projectIDList = implode(',', $projectIDList); + $query = str_replace($allProject, '1', $query); + $query = $query . ' AND `project` in (' . $projectIDList . ')'; + } + + $allProduct = "`product` = 'all'"; + if(strpos($query, $allProduct) !== false) + { + $products = $this->app->user->view->products; + $query = str_replace($allProduct, '1', $query); + $query = $query . ' AND `product` ' . helper::dbIN($products); + } + + $allExecutions = "`execution` = 'all'"; + if(strpos($query, $allExecutions) !== false) + { + $executions = $this->loadModel('execution')->getPairs(); + $query = str_replace($allExecutions, '1', $query); + $query = $query . ' AND `execution` ' . helper::dbIN(array_keys($executions)); + } + + return $query; + } + /** * Get projects, executions and products by docIdList. * @@ -838,17 +921,35 @@ class docModel extends model */ public function buildSearchForm($libID, $libs, $queryID, $actionURL, $type) { + $this->loadModel('product'); + + if($this->app->rawMethod == 'contribute') + { + $this->config->doc->search['module'] = 'contributeDoc'; + $products = $this->product->getPairs(); + $this->config->doc->search['params']['project']['values'] = array('' => '') + $this->loadModel('project')->getPairsByProgram() + array('all' => $this->lang->doc->allProjects); + $this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs() + array('all' => $this->lang->doc->allExecutions); + $this->config->doc->search['params']['lib']['values'] = array('' => '') + $this->loadModel('doc')->getLibs('all', 'withObject') + array('all' => $this->lang->doclib->all); + + unset($this->config->doc->search['fields']['module']); + } + else + { + $products = $this->product->getPairs('nocode', $this->session->project); + $this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs($this->session->project, 'all', 'noclosed') + array('all' => $this->lang->doc->allExecutions); + $this->config->doc->search['params']['lib']['values'] = array('' => '', $libID => ($libID ? $libs[$libID] : 0), 'all' => $this->lang->doclib->all); + } + + $this->config->doc->search['actionURL'] = $actionURL; $this->config->doc->search['queryID'] = $queryID; - $this->config->doc->search['params']['product']['values'] = array('' => '') + $this->loadModel('product')->getPairs('nocode', $this->session->project) + array('all' => $this->lang->doc->allProduct); - $this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs($this->session->project, 'all', 'noclosed') + array('all' => $this->lang->doc->allExecutions); - $this->config->doc->search['params']['lib']['values'] = array('' => '', $libID => ($libID ? $libs[$libID] : 0), 'all' => $this->lang->doclib->all); + $this->config->doc->search['params']['product']['values'] = array('' => '') + $products + array('all' => $this->lang->doc->allProduct); /* Get the modules. */ $moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($libID, 'doc', $startModuleID = 0); $this->config->doc->search['params']['module']['values'] = $moduleOptionMenu; - if($type == 'index' || $type == 'objectLibs' || $libID == 0) + if($type == 'index' || $type == 'objectLibs' || ($this->app->rawMethod != 'contribute' and $libID == 0)) { unset($this->config->doc->search['fields']['module']); unset($this->config->doc->search['fields']['lib']); diff --git a/module/my/control.php b/module/my/control.php index 09fcef9907..9c6c3cea05 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -678,12 +678,26 @@ EOF; $this->display(); } - public function doc($type = 'openedbyme', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + /** + * doc page of my. + * + * @param string $type + * @param int $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID + * @access public + * @return void + */ + public function doc($type = 'openedbyme', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Save session, load lang. */ $uri = $this->app->getURI(true); - if($this->app->viewType != 'json') $this->session->set('docList', $uri, 'doc'); $this->loadModel('doc'); + if($this->app->viewType != 'json') $this->session->set('docList', $uri, 'doc'); + + $queryID = ($type == 'bySearch') ? (int)$param : 0; $this->session->set('productList', $uri, 'product'); $this->session->set('executionList', $uri, 'execution'); @@ -696,7 +710,10 @@ EOF; /* Append id for secend sort. */ $sort = common::appendOrder($orderBy); - $docs = $this->doc->getDocsByBrowseType($type, 0, 0, $sort, $pager); + $docs = $this->doc->getDocsByBrowseType($type, $queryID, 0, $sort, $pager); + + $actionURL = $this->createLink('my', $this->app->rawMethod, "mode=doc&browseType=bySearch&queryID=myQueryID"); + $this->loadModel('doc')->buildSearchForm(0, array(), $queryID, $actionURL, 'contribute'); /* Assign. */ $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->doc; diff --git a/module/my/view/doc.html.php b/module/my/view/doc.html.php index c74f57b6c2..207eeeea40 100644 --- a/module/my/view/doc.html.php +++ b/module/my/view/doc.html.php @@ -20,16 +20,19 @@ echo html::a(inlink($app->rawMethod, "mode=doc&type=editedbyme"), "{$lang->doc->editedByMe}" . ($type == 'editedbyme' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'editedbyme' ? ' btn-active-text' : '') . "'"); ?> + my->byQuery;?> -
doc->noDoc;?>