* Fix doc menu of execution.

This commit is contained in:
zhujinyong
2021-04-02 22:11:46 +08:00
parent 1484a837b3
commit 9f2fb440fc
6 changed files with 140 additions and 49 deletions
+73 -27
View File
@@ -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);