diff --git a/module/action/model.php b/module/action/model.php index a2dda98a2e..9cb6a5e9ab 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -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(); } diff --git a/module/bug/model.php b/module/bug/model.php index 34e8c70c3d..8e72b71a8d 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -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') diff --git a/module/build/model.php b/module/build/model.php index a229515afc..e395985979 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -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') diff --git a/module/common/view/kindeditor.html.php b/module/common/view/kindeditor.html.php index 25b8c93c8d..26f2a737ec 100755 --- a/module/common/view/kindeditor.html.php +++ b/module/common/view/kindeditor.html.php @@ -122,6 +122,7 @@ function initKindeditor(afterInit) var html = K(doc.body).html(); if(html.search(//, '')); $.post(createLink('file', 'ajaxPasteImage'), {editor: html}, function(data){K(doc.body).html(data);}); } }, 80); diff --git a/module/doc/model.php b/module/doc/model.php index 3f548986c5..8dfbb26408 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -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') diff --git a/module/file/model.php b/module/file/model.php index 3cb1d13679..cca958f6d0 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -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; + } } diff --git a/module/product/model.php b/module/product/model.php index d93d66a98e..0b58f8f956 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -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'") diff --git a/module/productplan/model.php b/module/productplan/model.php index 7de6634094..8adc8c1262 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -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() diff --git a/module/project/model.php b/module/project/model.php index c054a2cef1..2790d0ef2b 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -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') diff --git a/module/release/model.php b/module/release/model.php index a32e35d39b..2a2103db28 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -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') diff --git a/module/story/model.php b/module/story/model.php index 9066737227..ad8c1ba8ac 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -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(); diff --git a/module/task/model.php b/module/task/model.php index c1f8b33024..10b22fe85b 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -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') diff --git a/module/testtask/model.php b/module/testtask/model.php index 04338d29d8..39bf86825d 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -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) diff --git a/module/todo/model.php b/module/todo/model.php index c317e105f7..93184748d0 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -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)