* Fix bug #33296.
This commit is contained in:
@@ -1288,7 +1288,6 @@ class doc extends control
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$this->app->rawMethod = $rawMethod;
|
||||
|
||||
$this->view->libID = $libID;
|
||||
if($libType == 'api')
|
||||
{
|
||||
$this->loadModel('api');
|
||||
@@ -1306,12 +1305,16 @@ class doc extends control
|
||||
$this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $orderBy, $pager) : $this->doc->getDocs($libID, $moduleID, $orderBy, $pager);
|
||||
}
|
||||
|
||||
$apiObjectType = $type == 'product' || $type == 'project' ? $type : '';
|
||||
$apiObjectID = $apiObjectType ? $objectID : 0;
|
||||
|
||||
$this->view->title = $title;
|
||||
$this->view->type = $type;
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->param = $queryID;
|
||||
$this->view->users = $this->user->getPairs('noletter');
|
||||
$this->view->libTree = $libTree;
|
||||
$this->view->libID = $libID;
|
||||
$this->view->moduleID = $moduleID;
|
||||
$this->view->objectDropdown = $objectDropdown;
|
||||
$this->view->libType = $libType;
|
||||
@@ -1320,6 +1323,7 @@ class doc extends control
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->exportMethod = $type . '2export';
|
||||
$this->view->canExport = common::hasPriv('doc', $type . '2export');
|
||||
$this->view->apiLibs = $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -39,17 +39,20 @@ class docModel extends model
|
||||
* Get api Libraries.
|
||||
*
|
||||
* @param int $appendLib
|
||||
* @param string $appendLib
|
||||
* @param int $objectID
|
||||
* @return array
|
||||
* @author thanatos thanatos915@163.com
|
||||
*/
|
||||
public function getApiLibs($appendLib = 0)
|
||||
public function getApiLibs($appendLib = 0, $objectType = '', $objectID = 0)
|
||||
{
|
||||
$libs = $this->dao->select('*')->from(TABLE_DOCLIB)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('type')->eq('api')
|
||||
->beginIF(!empty($appendLib))->orWhere('id')->eq($appendLib)->fi()
|
||||
->beginIF(!empty($objectType))->andWhere($objectType)->eq($objectID)->fi()
|
||||
->orderBy('`order`_asc, id_desc')
|
||||
->fetchAll('id');
|
||||
|
||||
$libs = array_filter($libs, array($this, 'checkPrivLib'));
|
||||
return $libs;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->doc->noDoc;?></span>
|
||||
<?php
|
||||
if(common::hasPriv('doc', 'create') and $browseType != 'bySearch')
|
||||
if($browseType != 'bySearch' and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs))))
|
||||
{
|
||||
if($libID)
|
||||
{
|
||||
@@ -36,22 +36,30 @@
|
||||
$html .= "<button type='button' class='btn btn-info dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
|
||||
$html .= "<ul class='dropdown-menu pull-right'>";
|
||||
|
||||
$apiLibID = key($apiLibs);
|
||||
foreach($this->lang->doc->createList as $typeKey => $typeName)
|
||||
{
|
||||
if($config->edition != 'max' and $typeKey == 'template') continue;
|
||||
if($typeKey == 'api' and (!common::hasPriv('api', 'create') or empty($apiLibs))) continue;
|
||||
if($typeKey != 'api' and !common::hasPriv('doc', 'create')) continue;
|
||||
|
||||
$class = (strpos($this->config->doc->officeTypes, $typeKey) !== false or strpos($this->config->doc->textTypes, $typeKey) !== false) ? 'iframe' : '';
|
||||
$module = $typeKey == 'api' ? 'api' : 'doc';
|
||||
$method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create';
|
||||
|
||||
$params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
|
||||
if($typeKey == 'api') $params = "libID=$libID&moduleID=$moduleID";
|
||||
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
|
||||
if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html&fromGlobal=&from=template";
|
||||
|
||||
$html .= "<li>";
|
||||
$html .= html::a(helper::createLink($module, $method, $params, '', $class ? true : false), $typeName, '', "class='$class' data-app='{$this->app->tab}'");
|
||||
$html .= "</li>";
|
||||
if($typeKey == 'template') $html .= '<li class="divider"></li>';
|
||||
if($config->edition != 'max' and $typeKey == 'api') $html .= '<li class="divider"></li>';
|
||||
|
||||
$printDivider = false;
|
||||
if($typeKey == 'template') $printDivider = true;
|
||||
if($config->edition != 'max' and $typeKey == 'api') $printDivider = true;
|
||||
if($config->edition != 'max' and empty($apiLibs) and $typeKey == 'html') $printDivider = true;
|
||||
if($printDivider) $html .= '<li class="divider"></li>';
|
||||
}
|
||||
|
||||
$html .= '</ul></div>';
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
echo html::a(helper::createLink('doc', 'createLib', "type=$type&objectID=$objectID"), '<i class="icon icon-plus"></i> ' . $this->lang->doc->createLib, '', 'class="btn btn-secondary iframe"');
|
||||
}
|
||||
|
||||
if(common::hasPriv('doc', 'create'))
|
||||
if(common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs)))
|
||||
{
|
||||
if($libID)
|
||||
{
|
||||
@@ -42,22 +42,30 @@
|
||||
$html .= "<button type='button' class='btn btn-primary dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
|
||||
$html .= "<ul class='dropdown-menu pull-right'>";
|
||||
|
||||
$apiLibID = key($apiLibs);
|
||||
foreach($this->lang->doc->createList as $typeKey => $typeName)
|
||||
{
|
||||
if($config->edition != 'max' and $typeKey == 'template') continue;
|
||||
if($typeKey == 'api' and (!common::hasPriv('api', 'create') or empty($apiLibs))) continue;
|
||||
if($typeKey != 'api' and !common::hasPriv('doc', 'create')) continue;
|
||||
|
||||
$class = (strpos($this->config->doc->officeTypes, $typeKey) !== false or strpos($this->config->doc->textTypes, $typeKey) !== false) ? 'iframe' : '';
|
||||
$module = $typeKey == 'api' ? 'api' : 'doc';
|
||||
$method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create';
|
||||
|
||||
$params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
|
||||
if($typeKey == 'api') $params = "libID=$libID&moduleID=$moduleID";
|
||||
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
|
||||
if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html&fromGlobal=&from=template";
|
||||
|
||||
$html .= "<li>";
|
||||
$html .= html::a(helper::createLink($module, $method, $params, '', $class ? true : false), $typeName, '', "class='$class' data-app='{$this->app->tab}'");
|
||||
$html .= "</li>";
|
||||
if($typeKey == 'template') $html .= '<li class="divider"></li>';
|
||||
if($config->edition != 'max' and $typeKey == 'api') $html .= '<li class="divider"></li>';
|
||||
|
||||
$printDivider = false;
|
||||
if($typeKey == 'template') $printDivider = true;
|
||||
if($config->edition != 'max' and $typeKey == 'api') $printDivider = true;
|
||||
if($config->edition != 'max' and empty($apiLibs) and $typeKey == 'html') $printDivider = true;
|
||||
if($printDivider) $html .= '<li class="divider"></li>';
|
||||
}
|
||||
|
||||
$html .= '</ul></div>';
|
||||
|
||||
Reference in New Issue
Block a user