diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index 848b1a7125..8d74467e20 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -328,7 +328,7 @@ $lang->doc->menu->my = array('link' => "{$lang->doc->my}|doc|browse|libID $lang->doc->menu->collect = array('link' => "{$lang->doc->favorite}|doc|browse|libID=0&browseTyp=collectedbyme", 'alias' => 'collect'); $lang->doc->menu->product = array('link' => "{$lang->doc->product}|doc|objectLibs|type=product", 'alias' => 'product'); $lang->doc->menu->project = array('link' => "{$lang->doc->project}|doc|objectLibs|type=project", 'alias' => 'project'); -$lang->doc->menu->custom = array('link' => "{$lang->doc->custom}|doc|objectLibs|libID=0"); +$lang->doc->menu->custom = array('link' => "{$lang->doc->custom}|doc|objectLibs|type=custom"); $lang->doc->dividerMenu = ',product,'; diff --git a/module/doc/control.php b/module/doc/control.php index 9cd806c13f..9dd44c254a 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -304,13 +304,15 @@ class doc extends control /** * Create a doc. * + * @param string $objectType + * @param int $objectID * @param int|string $libID * @param int $moduleID * @param string $docType * @access public * @return void */ - public function create($type, $objectID, $libID, $moduleID = 0, $docType = '') + public function create($objectType, $objectID, $libID, $moduleID = 0, $docType = '') { if(!empty($_POST)) { @@ -330,9 +332,8 @@ class doc extends control if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; $this->action->create('doc', $docID, 'Created', $fileAction); - $vars = "libID=" . (int)$this->post->lib . "&browseType=byModule&moduleID=" . (int)$this->post->module . "&orderBy=id_desc&from=$this->from"; - $link = $this->createLink('doc', 'browse', $vars); - if($this->app->getViewType() == 'xhtml') $link = $this->createLink('doc', 'view', "docID=$docID"); + $params = "type=$objectType&objectID=$objectID&libID=$libID&docID=" . $docResult['id']; + $link = $this->createLink('doc', 'objectLibs', $params); $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link)); } @@ -393,10 +394,13 @@ class doc extends control * * @param int $docID * @param bool $comment + * @param string $objectType + * @param int $objectID + * @param int $libID * @access public * @return void */ - public function edit($docID, $comment = false) + public function edit($docID, $comment = false, $objectType = '', $objectID = 0, $libID = 0) { if(!empty($_POST)) { @@ -415,7 +419,16 @@ class doc extends control $actionID = $this->action->create('doc', $docID, $action, $fileAction . $this->post->comment); if(!empty($changes)) $this->action->logHistory($actionID, $changes); } - $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('doc', 'view', "docID=$docID"))); + + if($objectType) + { + $link = $this->createLink('doc', 'objectLibs', "type=$objectType&objectID=$objectID&libID=$libID&docID=$docID"); + } + else + { + $link = $this->createLink('doc', 'view', "docID=$docID"); + } + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link)); } /* Get doc and set menu. */ @@ -436,6 +449,10 @@ class doc extends control { $this->project->setMenu($lib->project); } + else + { + $this->app->rawMethod = $objectType; + } /* Set my menu. */ if($this->app->openApp == 'my') @@ -517,10 +534,11 @@ class doc extends control * * @param int $docID * @param string $confirm yes|no + * @param string $from * @access public * @return void */ - public function delete($docID, $confirm = 'no') + public function delete($docID, $confirm = 'no', $from = 'list') { if($confirm == 'no') { @@ -542,9 +560,17 @@ class doc extends control { $response['result'] = 'success'; $response['message'] = ''; + + if($from == 'lib') + { + $pos = strpos($this->session->docList, 'docID'); + $link = $pos !== false ? substr($this->session->docList, 0, $pos - 1) : $this->session->docList; + $response['locate'] = $link; + } } $this->send($response); } + die(js::locate($this->session->docList, 'parent')); } } @@ -882,34 +908,53 @@ class doc extends control $this->session->set('docList', $this->app->getURI(true), 'doc'); $objects = $this->doc->getOrderedObjects($type); - if($type == 'product') + + if($type == 'custom') { - $objectID = $this->product->saveState($objectID, $objects); - $table = TABLE_PRODUCT; - - $libs = $this->doc->getLibsByObject('product', $objectID); - - if($libID == 0) $libID = key($libs); - $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID); - - $this->app->rawMethod = 'product'; + $libs = $this->doc->getLibs('custom'); + $this->app->rawMethod = 'custom'; } - else - { - $objectID = $this->project->saveState($objectID, $objects); - $table = TABLE_PROJECT; + else{ + if($type == 'product') + { + $objectID = $this->product->saveState($objectID, $objects); + $table = TABLE_PRODUCT; - $libs = $this->doc->getLibsByObject('project', $objectID); + $libs = $this->doc->getLibsByObject('product', $objectID); - if($libID == 0) $libID = key($libs); - $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID); + if($libID == 0) $libID = key($libs); + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID); - $this->app->rawMethod = 'project'; + $this->app->rawMethod = 'product'; + } + else if($type == 'project') + { + $objectID = $this->project->saveState($objectID, $objects); + $table = TABLE_PROJECT; + + $libs = $this->doc->getLibsByObject('project', $objectID); + + if($libID == 0) $libID = key($libs); + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID); + + $this->app->rawMethod = 'project'; + } + else if($type == 'execution') + { + $table = TABLE_EXECUTION; + $libs = $this->doc->getLibsByObject('execution', $objectID); + + if($libID == 0) $libID = key($libs); + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs, $libID); + + $this->app->rawMethod = 'project'; + } + + $object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch(); + if(empty($object)) $this->locate($this->createLink($type, 'create', '', '', '', $this->session->project)); } if(!$libID) $libID = key($libs); - $object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch(); - if(empty($object)) $this->locate($this->createLink($type, 'create', '', '', '', $this->session->project)); $openApp = $this->app->openApp; if($openApp != 'doc') $this->loadModel($openApp)->setMenu($objectID); @@ -948,6 +993,7 @@ class doc extends control $this->view->doc = $docID ? $doc : ''; $this->view->type = $type; $this->view->object = $object; + $this->view->objectType = $type; $this->view->libID = $libID; $this->view->lib = isset($libs[$libID]) ? $libs[$libID] : array(); $this->view->libs = $this->doc->getLibsByObject($type, $objectID); diff --git a/module/doc/css/objectlibs.css b/module/doc/css/objectlibs.css index ff4def431c..a308869be7 100644 --- a/module/doc/css/objectlibs.css +++ b/module/doc/css/objectlibs.css @@ -11,7 +11,8 @@ .main-col .detail-title {display: flex;} .main-col .detail-title .title {margin-right: 10px;} .main-col .detail-title .info {flex: 1 1 0;} -.main-col .detail-title .actions i {font-size: 15px; color: #8c8c8c; margin-left: 2px;} -#sidebar {width: 250px;} -#sidebar>.cell {width: 220px;} +.main-col .detail-title .actions i {font-size: 15px; color: #8c8c8c; margin-left: 5px;} +#sidebar {width: 280px;} +#sidebar>.cell {width: 265px;} #sidebar>.sidebar-toggle {left: 5px; right: auto;} +.hide-sidebar #sidebar>.sidebar-toggle>.icon:before {content: "\e314";} diff --git a/module/doc/js/objectlibs.js b/module/doc/js/objectlibs.js new file mode 100644 index 0000000000..fae47aeda7 --- /dev/null +++ b/module/doc/js/objectlibs.js @@ -0,0 +1,10 @@ +function ajaxDeleteDoc(link, replaceID, notice) +{ + if(confirm(notice)) + { + $.get(link, function(data) + { + location.href = JSON.parse(data).locate; + }) + } +} diff --git a/module/doc/model.php b/module/doc/model.php index f55b87bb17..a30c47487f 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -535,10 +535,13 @@ class docModel extends model /* Fix bug #2929. strip_tags($this->post->contentMarkdown, $this->config->allowedTags)*/ $doc->contentMarkdown = $this->post->contentMarkdown; if($doc->acl == 'private') $doc->users = $this->app->user->account; - $condition = "lib = '$doc->lib' AND module = $doc->module"; - $result = $this->loadModel('common')->removeDuplicate('doc', $doc, $condition); - if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']); + if($doc->title) + { + $condition = "lib = '$doc->lib' AND module = $doc->module"; + $result = $this->loadModel('common')->removeDuplicate('doc', $doc, $condition); + if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']); + } $lib = $this->getLibByID($doc->lib); $doc = $this->loadModel('file')->processImgURL($doc, $this->config->doc->editor->create['id'], $this->post->uid); @@ -1218,6 +1221,32 @@ class docModel extends model } } } + elseif($objectType == 'execution') + { + $executions = $this->dao->select('*')->from(TABLE_EXECUTION) + ->where('deleted')->eq(0) + ->andWhere('type')->eq('execution') + ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() + ->orderBy('order_asc') + ->fetchAll('id'); + + $orderedExecutions = array(); + foreach($executions as $id => $execution) + { + if($execution->status != 'done' and $execution->status != 'closed' and $execution->PM == $this->app->user->account) + { + $myObjects[$id] = $execution->name; + } + else if($execution->status != 'done' and $execution->status != 'closed' and !($execution->PM == $this->app->user->account)) + { + $normalObjects[$id] = $execution->name; + } + else if($execution->status == 'done' or $execution->status == 'closed') + { + $closedObjects[$id] = $execution->name; + } + } + } return $myObjects + $normalObjects + $closedObjects; } @@ -1666,13 +1695,13 @@ class docModel extends model /** * Build document module index page create document button. * - * @param string $type + * @param string $objectType * @param int $objectID * @param int $libID * @access public * @return string */ - public function buildCreateButton4Doc($type, $objectID, $libID) + public function buildCreateButton4Doc($objectType, $objectID, $libID) { $html = ""; @@ -1864,14 +1893,17 @@ EOF; $output = ''; - $output = "
"; if(!empty($libs)) { @@ -1880,7 +1912,7 @@ EOF; $output .= "
"; foreach($libs as $key => $lib) { - $output .= html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$key"), $lib->name); + $output .= html::a(inlink('objectLibs', "type=$type&objectID=$objectID&libID=$key"), $lib->name, '', "data-app='{$this->app->openApp}'"); } $output .= "
"; } @@ -1931,6 +1963,8 @@ EOF; if(isset($moduleDocs[0])) { + if(!isset($treeMenu[0])) $treeMenu[0] = ''; + foreach($moduleDocs[0] as $doc) { if(!$docID) $docID = $doc->id; diff --git a/module/doc/view/content.html.php b/module/doc/view/content.html.php index bf5c9fc490..fb4999a23f 100644 --- a/module/doc/view/content.html.php +++ b/module/doc/view/content.html.php @@ -12,18 +12,18 @@
id"), '', '', "title='{$lang->doc->edit}'"); + if(common::hasPriv('doc', 'edit')) echo html::a(inlink('edit', "docID=$doc->id&comment=false&objectType=$objectType&objectID=$object->id&libID=$libID"), '', '', "title='{$lang->doc->edit}'"); if(common::hasPriv('doc', 'delete')) { - $deleteURL = $this->createLink('doc', 'delete', "docID=$doc->id&confirm=yes"); - echo html::a("javascript:ajaxDelete(\"$deleteURL\", \"docList\", confirmDelete)", '', '', "title='{$lang->doc->delete}'"); + $deleteURL = $this->createLink('doc', 'delete', "docID=$doc->id&confirm=yes&from=lib"); + echo html::a("javascript:ajaxDeleteDoc(\"$deleteURL\", \"docList\", confirmDelete)", '', '', "title='{$lang->doc->delete}'"); } ?> collector, ',' . $this->app->user->account . ',') !== false ? 'icon-star text-yellow' : 'icon-star-empty';?> id&objectType=doc");?>" title="doc->collect;?>" class='ajaxCollect'>
-
+
type == 'url') {