* finish task #2335.

This commit is contained in:
wangyidong
2015-11-02 15:30:43 +08:00
parent 1807788f9d
commit 5d7126f5ca
14 changed files with 58 additions and 15 deletions

View File

@@ -43,7 +43,7 @@ class actionModel extends model
$action->actor = $actor;
$action->action = $actionType;
$action->date = helper::now();
$action->comment = trim(strip_tags($comment, $this->config->allowedTags));
$action->comment = $this->loadModel('file')->pasteImage(trim(strip_tags($comment, $this->config->allowedTags)));
$action->extra = $extra;
/* Get product and project for this object. */
@@ -810,9 +810,10 @@ class actionModel extends model
*/
public function updateComment($actionID)
{
$comment = $this->loadModel('file')->pasteImage(trim(strip_tags($this->post->lastComment, $this->config->allowedTags)));
$this->dao->update(TABLE_ACTION)
->set('date')->eq(helper::now())
->set('comment')->eq(trim(strip_tags($this->post->lastComment, $this->config->allowedTags)))
->set('comment')->eq($comment)
->where('id')->eq($actionID)
->exec();
}

View File

@@ -59,11 +59,12 @@ class bugModel extends model
$result = $this->loadModel('common')->removeDuplicate('bug', $bug, "product={$bug->product}");
if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']);
$bug = $this->loadModel('file')->processEditor($bug, $this->config->bug->editor->create['id']);
$this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec();
if(!dao::isError())
{
$bugID = $this->dao->lastInsertID();
$this->loadModel('file')->saveUpload('bug', $bugID);
$this->file->saveUpload('bug', $bugID);
return array('status' => 'created', 'id' => $bugID);
}
return false;
@@ -419,6 +420,7 @@ class bugModel extends model
->remove('comment,files,labels')
->get();
$bug = $this->loadModel('file')->processEditor($bug, $this->config->bug->editor->edit['id']);
$this->dao->update(TABLE_BUG)->data($bug)
->autoCheck()
->batchCheck($this->config->bug->edit->requiredFields, 'notempty')

View File

@@ -177,11 +177,12 @@ class buildModel extends model
->remove('resolvedBy,allchecker,files,labels')
->get();
$build = $this->loadModel('file')->processEditor($build, $this->config->build->editor->create['id']);
$this->dao->insert(TABLE_BUILD)->data($build)->autoCheck()->batchCheck($this->config->build->create->requiredFields, 'notempty')->check('name', 'unique', "product = {$build->product}")->exec();
if(!dao::isError())
{
$buildID = $this->dao->lastInsertID();
$this->loadModel('file')->saveUpload('build', $buildID);
$this->file->saveUpload('build', $buildID);
return $buildID;
}
}
@@ -200,6 +201,7 @@ class buildModel extends model
->remove('allchecker,resolvedBy,files,labels')
->get();
$build = $this->loadModel('file')->processEditor($build, $this->config->build->editor->edit['id']);
$this->dao->update(TABLE_BUILD)->data($build)
->autoCheck()
->batchCheck($this->config->build->edit->requiredFields, 'notempty')

View File

@@ -122,6 +122,7 @@ function initKindeditor(afterInit)
var html = K(doc.body).html();
if(html.search(/<img src="data:.+;base64,/) > -1)
{
K(doc.body).html(html.replace(/<img src="data:.+;base64,.*".*\/>/, ''));
$.post(createLink('file', 'ajaxPasteImage'), {editor: html}, function(data){K(doc.body).html(data);});
}
}, 80);

View File

@@ -193,6 +193,7 @@ class docModel extends model
$result = $this->loadModel('common')->removeDuplicate('doc', $doc, $condition);
if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']);
$doc = $this->loadModel('file')->processEditor($doc, $this->config->doc->editor->create['id']);
$this->dao->insert(TABLE_DOC)
->data($doc)
->autoCheck()
@@ -233,6 +234,7 @@ class docModel extends model
->get();
$condition = "lib = '$doc->lib' AND module = $doc->module AND id != $docID";
$doc = $this->loadModel('file')->processEditor($doc, $this->config->doc->editor->edit['id']);
$this->dao->update(TABLE_DOC)->data($doc)
->autoCheck()
->batchCheck($this->config->doc->edit->requiredFields, 'notempty')

View File

@@ -251,6 +251,7 @@ class fileModel extends model
*/
public function pasteImage($data)
{
if(empty($data)) return '';
$data = str_replace('\"', '"', $data);
ini_set('pcre.backtrack_limit', strlen($data));
@@ -414,4 +415,23 @@ class fileModel extends model
if($zip->extract(PCLZIP_OPT_PATH, $filePath) == 0) return false;
return $filePath;
}
/**
* Process editor.
*
* @param object $data
* @param string $editorList
* @access public
* @return object
*/
public function processEditor($data, $editorList)
{
foreach(explode(',', $editorList) as $editorID)
{
$editorID = trim($editorID);
if(empty($editorID) or !isset($data->$editorID)) continue;
$data->$editorID = $this->pasteImage($data->$editorID);
}
return $data;
}
}

View File

@@ -239,9 +239,8 @@ class productModel extends model
->join('whitelist', ',')
->stripTags($this->config->product->editor->create['id'], $this->config->allowedTags)
->get();
$this->dao->insert(TABLE_PRODUCT)
->data($product)
->autoCheck()
$product = $this->loadModel('file')->processEditor($product, $this->config->product->editor->create['id']);
$this->dao->insert(TABLE_PRODUCT)->data($product)->autoCheck()
->batchCheck('name,code', 'notempty')
->check('name', 'unique', "deleted = '0'")
->check('code', 'unique', "deleted = '0'")
@@ -268,9 +267,8 @@ class productModel extends model
->join('whitelist', ',')
->stripTags($this->config->product->editor->edit['id'], $this->config->allowedTags)
->get();
$this->dao->update(TABLE_PRODUCT)
->data($product)
->autoCheck()
$product = $this->loadModel('file')->processEditor($product, $this->config->product->editor->edit['id']);
$this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck()
->batchCheck('name,code', 'notempty')
->check('name', 'unique', "id != $productID and deleted = '0'")
->check('code', 'unique', "id != $productID and deleted = '0'")

View File

@@ -118,6 +118,7 @@ class productplanModel extends model
public function create()
{
$plan = fixer::input('post')->stripTags($this->config->productplan->editor->create['id'], $this->config->allowedTags)->remove('delta')->get();
$plan = $this->loadModel('file')->processEditor($plan, $this->config->plan->editor->create['id']);
$this->dao->insert(TABLE_PRODUCTPLAN)
->data($plan)
->autoCheck()
@@ -138,6 +139,7 @@ class productplanModel extends model
{
$oldPlan = $this->getById($planID);
$plan = fixer::input('post')->stripTags($this->config->productplan->editor->edit['id'], $this->config->allowedTags)->remove('delta')->get();
$plan = $this->loadModel('file')->processEditor($plan, $this->config->plan->editor->edit['id']);
$this->dao->update(TABLE_PRODUCTPLAN)
->data($plan)
->autoCheck()

View File

@@ -221,6 +221,7 @@ class projectModel extends model
->stripTags($this->config->project->editor->create['id'], $this->config->allowedTags)
->remove('products, workDays, delta, branch')
->get();
$project = $this->loadModel('file')->processEditor($project, $this->config->project->editor->create['id']);
$this->dao->insert(TABLE_PROJECT)->data($project)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->project->create->requiredFields, 'notempty')
@@ -291,9 +292,10 @@ class projectModel extends model
->setIF($this->post->acl != 'custom', 'whitelist', '')
->setDefault('team', $this->post->name)
->join('whitelist', ',')
->stripTags($this->config->project->editor->create['id'], $this->config->allowedTags)
->stripTags($this->config->project->editor->edit['id'], $this->config->allowedTags)
->remove('products,branch')
->get();
$project = $this->loadModel('file')->processEditor($project, $this->config->project->editor->edit['id']);
$this->dao->update(TABLE_PROJECT)->data($project)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->project->edit->requiredFields, 'notempty')

View File

@@ -111,6 +111,7 @@ class releaseModel extends model
->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags)
->remove('build,files,labels')
->get();
$build = $this->loadModel('file')->processEditor($build, $this->config->release->editor->create['id']);
$this->dao->insert(TABLE_BUILD)->data($build)->autoCheck()->check('name','unique')->exec();
$buildID = $this->dao->lastInsertID();
}
@@ -125,6 +126,7 @@ class releaseModel extends model
->remove('allchecker,files,labels')
->get();
$release = $this->loadModel('file')->processEditor($release, $this->config->release->editor->create['id']);
$this->dao->insert(TABLE_RELEASE)->data($release)->autoCheck()->batchCheck($this->config->release->create->requiredFields, 'notempty')->check('name','unique')->exec();
if(!dao::isError())
@@ -150,6 +152,7 @@ class releaseModel extends model
$release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags)
->remove('files,labels,allchecker')
->get();
$release = $this->loadModel('file')->processEditor($release, $this->config->release->editor->edit['id']);
$this->dao->update(TABLE_RELEASE)->data($release)
->autoCheck()
->batchCheck($this->config->release->edit->requiredFields, 'notempty')

View File

@@ -142,11 +142,12 @@ class storyModel extends model
$result = $this->loadModel('common')->removeDuplicate('story', $story, "product={$story->product}");
if($result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']);
$story = $this->loadModel('file')->processEditor($story, $this->config->story->editor->create['id']);
$this->dao->insert(TABLE_STORY)->data($story, 'spec,verify')->autoCheck()->batchCheck($this->config->story->create->requiredFields, 'notempty')->exec();
if(!dao::isError())
{
$storyID = $this->dao->lastInsertID();
$this->loadModel('file')->saveUpload('story', $storyID, $extra = 1);
$this->file->saveUpload('story', $storyID, $extra = 1);
$data = new stdclass();
$data->story = $storyID;
@@ -351,8 +352,8 @@ class storyModel extends model
->stripTags($this->config->story->editor->change['id'], $this->config->allowedTags)
->remove('files,labels,comment,needNotReview')
->get();
$this->dao->update(TABLE_STORY)
->data($story, 'spec,verify')
$story = $this->loadModel('file')->processEditor($story, $this->config->story->editor->change['id']);
$this->dao->update(TABLE_STORY)->data($story, 'spec,verify')
->autoCheck()
->batchCheck($this->config->story->change->requiredFields, 'notempty')
->where('id')->eq((int)$storyID)->exec();

View File

@@ -24,6 +24,7 @@ class taskModel extends model
{
$tasksID = array();
$taskFile = '';
$this->loadModel('file');
foreach($this->post->assignedTo as $assignedTo)
{
if($this->post->type == 'affair' and empty($assignedTo)) continue;
@@ -56,6 +57,7 @@ class taskModel extends model
}
}
$task = $this->file->processEditor($task, $this->config->task->editor->create['id']);
$this->dao->insert(TABLE_TASK)->data($task)
->autoCheck()
->batchCheck($this->config->task->create->requiredFields, 'notempty')
@@ -74,7 +76,7 @@ class taskModel extends model
}
else
{
$taskFileTitle = $this->loadModel('file')->saveUpload('task', $taskID);
$taskFileTitle = $this->file->saveUpload('task', $taskID);
$taskFile = $this->dao->select('*')->from(TABLE_FILE)->where('id')->eq(key($taskFileTitle))->fetch();
unset($taskFile->id);
}
@@ -232,6 +234,8 @@ class taskModel extends model
->autoCheck()
->exec();
}
$task = $this->loadModel('file')->processEditor($task, $this->config->task->editor->edit['id']);
$this->dao->update(TABLE_TASK)->data($task)
->autoCheck()
->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty')

View File

@@ -42,6 +42,7 @@ class testtaskModel extends model
function create()
{
$task = fixer::input('post')->stripTags($this->config->testtask->editor->create['id'], $this->config->allowedTags)->get();
$task = $this->loadModel('file')->processEditor($task, $this->config->testtask->editor->create['id']);
$this->dao->insert(TABLE_TESTTASK)->data($task)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->testtask->create->requiredFields, 'notempty')
@@ -170,6 +171,7 @@ class testtaskModel extends model
{
$oldTask = $this->getById($taskID);
$task = fixer::input('post')->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)->get();
$task = $this->loadModel('file')->processEditor($task, $this->config->testtask->editor->edit['id']);
$this->dao->update(TABLE_TESTTASK)->data($task)
->autoCheck()
->batchcheck($this->config->testtask->edit->requiredFields, 'notempty')
@@ -215,6 +217,7 @@ class testtaskModel extends model
->stripTags($this->config->testtask->editor->close['id'], $this->config->allowedTags)
->remove('comment')->get();
$testtask = $this->loadModel('file')->processEditor($testtask, $this->config->testtask->editor->close['id']);
$this->dao->update(TABLE_TESTTASK)->data($testtask)
->autoCheck()
->where('id')->eq((int)$taskID)

View File

@@ -35,6 +35,7 @@ class todoModel extends model
->stripTags($this->config->todo->editor->create['id'], $this->config->allowedTags)
->remove('bug, task')
->get();
$todo = $this->loadModel('file')->processEditor($todo, $this->config->todo->editor->create['id']);
$this->dao->insert(TABLE_TODO)->data($todo)
->autoCheck()
->checkIF($todo->type == 'custom', $this->config->todo->create->requiredFields, 'notempty')
@@ -119,6 +120,7 @@ class todoModel extends model
->setDefault('private', 0)
->stripTags($this->config->todo->editor->edit['id'], $this->config->allowedTags)
->get();
$todo = $this->loadModel('file')->processEditor($todo, $this->config->todo->editor->edit['id']);
$this->dao->update(TABLE_TODO)->data($todo)
->autoCheck()
->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')->where('id')->eq($todoID)