* Rename design get pairs method and add required fields config.

This commit is contained in:
Yagami
2020-08-28 13:34:17 +08:00
parent ca5d8d8bd2
commit 1818e3eef1
2 changed files with 36 additions and 28 deletions
+5
View File
@@ -5,6 +5,11 @@ $config->design->editor->create = array('id' => 'desc', 'tools' => 'simpleT
$config->design->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
$config->design->editor->assignto = array('id' => 'comment', 'tools' => 'simpleTools');
$config->design->create = new stdclass();
$config->design->edit = new stdclass();
$config->design->create->requiredFields = 'name,type';
$config->design->edit->requiredFields = 'name,type';
$config->design->affectedFixedNum = 7;
global $lang;
+31 -28
View File
@@ -27,11 +27,14 @@ class designModel extends model
->add('createdDate', helper::now())
->add('program', $this->session->program)
->add('version', 1)
->remove('file,files,labels,children,toList')
->remove('files,labels')
->get();
$design = $this->loadModel('file')->processImgURL($design, 'desc', $this->post->uid);
$this->dao->insert(TABLE_DESIGN)->data($design)->autoCheck()->batchCheck('name,type', 'notempty')->exec();
$this->dao->insert(TABLE_DESIGN)->data($design)
->autoCheck()
->batchCheck($this->config->design->create->requiredFields, 'notempty')
->exec();
if(!dao::isError())
{
@@ -134,6 +137,31 @@ class designModel extends model
return false;
}
/**
* Assign a design.
*
* @param int $designID
* @access public
* @return array|bool
*/
public function assign($designID = 0)
{
$oldDesign = $this->getByID($designID);
$design = fixer::input('post')
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::today())
->setDefault('assignedDate', helper::today())
->stripTags($this->config->design->editor->assignto['id'], $this->config->allowedTags)
->remove('uid,comment,files,label')
->get();
$this->dao->update(TABLE_DESIGN)->data($design)->autoCheck()->where('id')->eq((int)$designID)->exec();
if(!dao::isError()) return common::createChanges($oldDesign, $design);
return false;
}
/**
* LinkCommit a design.
*
@@ -223,7 +251,7 @@ class designModel extends model
* @access public
* @return object
*/
public function getDesignPairs($productID = 0, $type = 'all')
public function getPairs($productID = 0, $type = 'all')
{
$designs = $this->dao->select('id, name')->from(TABLE_DESIGN)
->where('product')->eq($productID)
@@ -378,29 +406,4 @@ class designModel extends model
echo !common::hasPriv('design', 'assignTo', $design) ? "<span style='padding-left: 21px' class='{$btnTextClass}'>{$assignedToText}</span>" : $assignToHtml;
}
/**
* Assign a design.
*
* @param int $designID
* @access public
* @return array|bool
*/
public function assign($designID = 0)
{
$oldDesign = $this->getByID($designID);
$design = fixer::input('post')
->add('editedBy', $this->app->user->account)
->add('editedDate', helper::today())
->setDefault('assignedDate', helper::today())
->stripTags($this->config->design->editor->assignto['id'], $this->config->allowedTags)
->remove('uid,comment,files,label')
->get();
$this->dao->update(TABLE_DESIGN)->data($design)->autoCheck()->where('id')->eq((int)$designID)->exec();
if(!dao::isError()) return common::createChanges($oldDesign, $design);
return false;
}
}