* Fix bug #17995.
This commit is contained in:
+6
-12
@@ -319,21 +319,15 @@ class api extends control
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
if($type == 'demo')
|
||||
{
|
||||
$libID = $this->api->createDemoData($this->post->name, $this->post->baseUrl);
|
||||
return $this->sendSuccess(array('locate' => $this->createLink('api', 'index', "libID=$libID")));
|
||||
}
|
||||
$libID = $type == 'demo' ? $this->api->createDemoData($this->post->name, $this->post->baseUrl) : $this->doc->createApiLib();
|
||||
if(dao::isError()) return $this->sendError(dao::getError());
|
||||
|
||||
/* save api doc library */
|
||||
$libID = $this->doc->createApiLib();
|
||||
if(dao::isError())
|
||||
{
|
||||
return $this->sendError(dao::getError());
|
||||
}
|
||||
/* If the created api library of imported zentao api library, return directly. */
|
||||
if($type == 'demo') return $this->sendSuccess(array('locate' => $this->createLink('api', 'index', "libID=$libID")));
|
||||
|
||||
/* Record action for create api library. */
|
||||
$this->action->create('docLib', $libID, 'Created');
|
||||
|
||||
/* save doc library success */
|
||||
return $this->sendSuccess(array('locate' => $this->createLink('api', 'index', "libID=$libID")));
|
||||
}
|
||||
|
||||
|
||||
@@ -742,6 +742,9 @@ class apiModel extends model
|
||||
*/
|
||||
public function createDemoData($name, $baseUrl, $version = '16.0')
|
||||
{
|
||||
/* Replace the doc lib name to api lib name. */
|
||||
$this->lang->doclib->name = $this->lang->doclib->apiLibName;
|
||||
|
||||
$firstAccount = $this->dao->select('account')->from(TABLE_USER)->orderBy('id_asc')->limit(1)->fetch('account');
|
||||
$currentAccount = isset($this->app->user->account) ? $this->app->user->account : $firstAccount;
|
||||
|
||||
@@ -752,7 +755,10 @@ class apiModel extends model
|
||||
$lib->baseUrl = $baseUrl;
|
||||
$lib->acl = 'open';
|
||||
$lib->users = ',' . $currentAccount . ',';
|
||||
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
|
||||
$this->dao->insert(TABLE_DOCLIB)->data($lib)->autoCheck()
|
||||
->batchCheck($this->config->api->createlib->requiredFields, 'notempty')
|
||||
->check('name', 'unique', "`type` = 'api'")
|
||||
->exec();
|
||||
|
||||
$libID = $this->dao->lastInsertID();
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class docModel extends model
|
||||
*/
|
||||
public function createApiLib()
|
||||
{
|
||||
/* replace doc library name */
|
||||
/* Replace doc library name. */
|
||||
$this->lang->doclib->name = $this->lang->doclib->apiLibName;
|
||||
|
||||
$data = fixer::input('post')
|
||||
|
||||
Reference in New Issue
Block a user