myEditedDocs;?>
diff --git a/module/doc/control.php b/module/doc/control.php
index ec02fc78ab..112edb6961 100755
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -1142,7 +1142,7 @@ class doc extends control
public function view($docID = 0, $version = 0, $appendLib = 0)
{
$doc = $this->doc->getById($docID);
- if(!$doc)
+ if(!$doc or !isset($doc->id))
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => '404 Not found'));
return print(js::error($this->lang->notFound) . js::locate($this->inlink('index')));
@@ -1151,7 +1151,6 @@ class doc extends control
$lib = $this->doc->getLibById($doc->lib);
if(!empty($lib) and $lib->deleted == '1') $appendLib = $doc->id;
-
$objectType = isset($lib->type) ? $lib->type : 'custom';
$type = $objectType == 'execution' && $this->app->tab != 'execution' ? 'project' : $objectType;
$objectID = zget($doc, $type, 0);
@@ -1162,9 +1161,6 @@ class doc extends control
/* Get doc. */
if($docID)
{
- $doc = $this->doc->getById($docID, $version, true);
- if(!$doc) return print(js::error($this->lang->notFound));
-
$this->doc->createAction($docID, 'view');
$this->doc->removeEditing($doc);
if($doc->keywords)
diff --git a/module/doc/model.php b/module/doc/model.php
index c958e291d6..dcb5c0cd2d 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -766,7 +766,7 @@ class docModel extends model
echo(js::alert($this->lang->doc->accessDenied));
$loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login";
if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(inlink('index')));
- return print(js::locate('back'));
+ helper::end(print(js::locate('back')));
}
$docs = $this->processCollector(array($doc->id => $doc));
@@ -1320,6 +1320,8 @@ class docModel extends model
*/
public function checkPrivDoc($object)
{
+ if(!isset($object->lib)) return false;
+
$libType = $this->dao->select('type')->from(TABLE_DOCLIB)->where('id')->eq($object->lib)->fetch('type');
if($this->app->user->admin and $libType != 'mine') return true;
@@ -2807,7 +2809,7 @@ class docModel extends model
public function checkAutoloadPage($doc)
{
$autoloadPage = true;
- if(!empty($doc) and $doc->type == 'url')
+ if(isset($doc->type) and $doc->type == 'url')
{
if(empty($doc->content)) return false;
@@ -2990,6 +2992,7 @@ class docModel extends model
$docIDList = $this->getPrivDocs($lib->id);
$docs = $this->dao->select('*, title as name')->from(TABLE_DOC)
->where('id')->in($docIDList)
+ ->andWhere("(status = 'normal' or (status = 'draft' and addedBy='{$this->app->user->account}'))")
->andWhere('deleted')->eq(0)
->andWhere('module')->eq(0)
->fetchAll('id');
@@ -3145,7 +3148,7 @@ class docModel extends model
*/
public function printCreateBtn($lib, $type, $objectID, $moduleID, $from = '')
{
- if(!common::hasPriv('doc', 'create')) return null;
+ if(!common::hasPriv('doc', 'create') or !isset($lib->id)) return null;
$class = $from == 'list' ? 'btn-info' : 'btn-primary';
$html = "
";
diff --git a/module/doc/view/myspace.html.php b/module/doc/view/myspace.html.php
index 6ed9f3b87a..fd2a4d5f4f 100644
--- a/module/doc/view/myspace.html.php
+++ b/module/doc/view/myspace.html.php
@@ -41,7 +41,7 @@
echo html::a(helper::createLink('doc', 'createLib', "type=mine"), ' ' . $this->lang->doc->createLib, '', 'class="btn btn-secondary iframe" data-width="800px"');
}
- if($libID and common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, 'mine', 0, 0);
+ if($libID and common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, 'mine', 0, $moduleID);
?>