* [misc] add ajax method to set html to doc generated by new editor.

This commit is contained in:
sunhao
2024-11-28 10:52:57 +08:00
committed by 丁永亮
parent 18c6b1316d
commit 8ffbec74c1
+26
View File
@@ -1610,6 +1610,32 @@ class doc extends control
echo json_encode($docs);
}
/**
* Ajax: Migrate doc.
* Ajax: 迁移文档。
*
* @param int $docID
* @access public
* @return void
*/
public function ajaxMigrateDoc(int $docID)
{
if(!common::hasPriv('doc', 'edit')) return $this->send(array('result' => 'fail', 'message' => $this->lang->doc->errorPrivilege));
if(empty($_POST)) return $this->send(array('result' => 'fail', 'message' => $this->lang->error->unsupportedReq));
$doc = $this->doc->getByID($docID);
if(empty($doc)) return $this->send(array('result' => 'fail', 'message' => $this->lang->notFound));
if(!$this->doc->checkPrivDoc($doc)) return $this->send(array('result' => 'fail', 'message' => $this->lang->doc->errorPrivilege));
$html = $this->post->html;
$result = $this->doc->migrateDoc($docID, $doc->version, $html);
if(!$result) return $this->send(array('result' => 'fail', 'message' => $this->lang->saveFailed));
$this->send(array('result' => 'success'));
}
/**
* Ajax: Get doc data.
* Ajax: 获取文档数据。