* [task#143694,doing,2h] Add the function of doc template scope.

This commit is contained in:
xieqiyu
2025-05-22 10:28:26 +08:00
committed by 刘刚
parent 75629717bf
commit fb142ab705
3 changed files with 122 additions and 0 deletions
+34
View File
@@ -2517,6 +2517,40 @@ class doc extends control
*/
public function manageScope()
{
$scopePairs = $this->doc->getTemplateScopePairs();
if(!empty($_POST))
{
$scopes = $this->post->scopes;
$oldScopes = $newScopes = array();
foreach($scopes as $id => $name)
{
if(strpos((string)$id, 'id') !== false)
{
$scopeID = str_replace('id', '', $id);
$oldScopes[$scopeID] = $name;
}
else
{
$newScopes[$id] = $name;
}
}
$deletedScopes = array_diff_key($scopePairs, $oldScopes);
if(!empty($deletedScopes)) $this->doc->deleteTemplateScopes($deletedScopes);
if(dao::isError()) return $this->sendError(array('message' => dao::getError()));
if(!empty($oldScopes)) $this->doc->updateTemplateScopes($oldScopes);
if(dao::isError()) return $this->sendError(array('message' => dao::getError()));
if(!empty($newScopes)) $this->doc->insertTemplateScopes($newScopes);
if(dao::isError()) return $this->sendError(array('message' => dao::getError()));
return $this->sendSuccess(array('closeModal' => true));
}
$this->view->scopePairs = $scopePairs;
$this->display();
}
}