* Fix bug #33333.
This commit is contained in:
@@ -480,6 +480,8 @@ class api extends control
|
||||
if($api === false) return $this->sendError(dao::getError());
|
||||
|
||||
$this->action->create('api', $api->id, 'Created');
|
||||
|
||||
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
|
||||
return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID={$api->id}")));
|
||||
}
|
||||
|
||||
|
||||
@@ -1303,6 +1303,7 @@ class doc extends control
|
||||
|
||||
$apiObjectType = $type == 'product' || $type == 'project' ? $type : '';
|
||||
$apiObjectID = $apiObjectType ? $objectID : 0;
|
||||
$apiLibs = $apiObjectType ? $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID) : array();
|
||||
|
||||
$this->view->title = $title;
|
||||
$this->view->type = $type;
|
||||
@@ -1320,7 +1321,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 = $type == 'execution' ? array() : $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID);
|
||||
$this->view->apiLibID = key($apiLibs);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -14,15 +14,20 @@ $(function()
|
||||
*/
|
||||
function redirectParentWindow(objectType, libID, docType)
|
||||
{
|
||||
config.onlybody = 'no';
|
||||
if(objectType == 'api')
|
||||
{
|
||||
var link = createLink('api', 'create', 'libID=' + libID) + '#app=doc';
|
||||
}
|
||||
else
|
||||
{
|
||||
var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=0&libID=' + libID + '&moduleID=0&docType=' + docType + '&fromGlobal=true') + '#app=doc';
|
||||
parent.$.closeModal(function()
|
||||
{
|
||||
new parent.$.zui.ModalTrigger({
|
||||
iframe : createLink('api', 'create', 'libID=' + libID),
|
||||
width: '85%'
|
||||
}).show();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
config.onlybody = 'no';
|
||||
var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=0&libID=' + libID + '&moduleID=0&docType=' + docType + '&fromGlobal=true') + '#app=doc';
|
||||
window.parent.$.apps.open(link);
|
||||
}
|
||||
|
||||
|
||||
@@ -2906,4 +2906,60 @@ class docModel extends model
|
||||
$libTree = array_values($libTree[$type]);
|
||||
return $libTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print create document button.
|
||||
*
|
||||
* @param object $lib
|
||||
* @param type $type project|product|custom
|
||||
* @param int $objectID
|
||||
* @param int $moduleID
|
||||
* @param int $apiLibID
|
||||
* @param string $from list
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID = 0, $from = '')
|
||||
{
|
||||
$libType = isset($lib->type) && $lib->type == 'api' ? 'api' : 'lib';
|
||||
|
||||
$class = $from == 'list' ? 'btn-info' : 'btn-primary';
|
||||
$html = "<div class='dropdown btn-group createDropdown'>";
|
||||
$html .= html::a(helper::createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html", '', true), "<i class='icon icon-plus'></i> {$this->lang->doc->create}", '', "class='btn $class iframe'");
|
||||
$html .= "<button type='button' class='btn $class dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
|
||||
$html .= "<ul class='dropdown-menu pull-right'>";
|
||||
|
||||
foreach($this->lang->doc->createList as $typeKey => $typeName)
|
||||
{
|
||||
if($this->config->edition != 'max' and $typeKey == 'template') continue;
|
||||
if($typeKey == 'api' and (!common::hasPriv('api', 'create') or !$apiLibID)) continue;
|
||||
if($typeKey != 'api' and !common::hasPriv('doc', 'create')) continue;
|
||||
|
||||
$class = ($typeKey != 'template') ? 'iframe' : '';
|
||||
$attr = "data-app='{$this->app->tab}'";
|
||||
$module = $typeKey == 'api' ? 'api' : 'doc';
|
||||
$method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create';
|
||||
|
||||
$params = "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=$typeKey";
|
||||
if($typeKey == 'api')
|
||||
{
|
||||
$attr .= " data-width=85%";
|
||||
$params = "libID=$apiLibID&moduleID=$moduleID";
|
||||
}
|
||||
if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html&fromGlobal=&from=template";
|
||||
|
||||
$html .= "<li>";
|
||||
$html .= html::a(helper::createLink($module, $method, $params, '', $class ? true : false), $typeName, '', "class='$class' $attr");
|
||||
$html .= "</li>";
|
||||
|
||||
$printDivider = false;
|
||||
if($typeKey == 'template') $printDivider = true;
|
||||
if($this->config->edition != 'max' and $typeKey == 'api') $printDivider = true;
|
||||
if($this->config->edition != 'max' and !$apiLibID and $typeKey == 'html') $printDivider = true;
|
||||
if($printDivider) $html .= '<li class="divider"></li>';
|
||||
}
|
||||
|
||||
$html .= '</ul></div>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,44 +27,9 @@
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->doc->noDoc;?></span>
|
||||
<?php
|
||||
if($browseType != 'bySearch' and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs))))
|
||||
if($browseType != 'bySearch' and $libID and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !$apiLibID)))
|
||||
{
|
||||
if($libID)
|
||||
{
|
||||
$html = "<div class='dropdown btn-group createDropdown'>";
|
||||
$html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), "<i class='icon icon-plus'></i> {$lang->doc->create}", '', "class='btn btn-info iframe'");
|
||||
$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={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
|
||||
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
|
||||
if($typeKey == 'template') $params = "objectType={$lib->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>";
|
||||
|
||||
$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>';
|
||||
echo $html;
|
||||
}
|
||||
echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID, 'list');
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
|
||||
@@ -35,44 +35,9 @@
|
||||
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') or (common::hasPriv('api', 'create') and !empty($apiLibs)))
|
||||
if($libID and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !$apiLibID)))
|
||||
{
|
||||
if($libID)
|
||||
{
|
||||
$html = "<div class='dropdown btn-group createDropdown'>";
|
||||
$html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), "<i class='icon icon-plus'></i> {$lang->doc->create}", '', "class='btn btn-primary iframe'");
|
||||
$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={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
|
||||
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
|
||||
if($typeKey == 'template') $params = "objectType={$libType}&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>";
|
||||
|
||||
$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>';
|
||||
echo $html;
|
||||
}
|
||||
echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user