/**
  * Update a release.
  * 
  * @param  int    $releaseID 
  * @access public
  * @return void
  */
 public function update($releaseID)
 {
     $oldRelease = $this->getByID($releaseID);
     $release = fixer::input('post')->stripTags('name')->setDefault('stories', '')->setDefault('bugs', '')->join('stories', ',')->join('bugs', ',')->get();
     $this->dao->update(TABLE_RELEASE)->data($release)->autoCheck()->batchCheck($this->config->release->edit->requiredFields, 'notempty')->check('name', 'unique', "id != {$releaseID}")->where('id')->eq((int) $releaseID)->exec();
     $this->dao->update(TABLE_STORY)->set('stage')->eq('released')->where('id')->in($release->stories)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldRelease, $release);
     }
 }
예제 #2
0
파일: model.php 프로젝트: huokedu/zentao
 public function update($assetID)
 {
     $skipFields = '';
     $skipFields .= $this->loadModel('custom')->dealWithCustomArrayField();
     $oldAsset = $this->getAssetById($assetID);
     $now = helper::now();
     $address = fixer::input('post')->get('address');
     $extendaddress = fixer::input('post')->get('extendaddress');
     $devicenumber = fixer::input('post')->get('devicenumber');
     $code = fixer::input('post')->get('code');
     $module = $this->loadModel('info')->getAllChildId(fixer::input('post')->cleanInt('module')->setDefault('module', 0)->get('module'), 'asset');
     $result1 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('address')->eq($extendaddress)->andWhere('address')->ne('IP Format Error')->andWhere('address')->ne('Conflict!')->andWhere('address')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
     $result2 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('extendaddress')->eq($address)->andWhere('extendaddress')->ne('IP Format Error')->andWhere('extendaddress')->ne('Conflict!')->andWhere('extendaddress')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
     $asset = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->setDefault('lenddate', '0000-00-00')->setDefault('returndate', '0000-00-00')->setDefault('product', '0')->setDefault('project', '0')->setIF(!(strlen(trim($extendaddress)) == 0) && !validater::checkIP($extendaddress), 'extendaddress', 'IP Format Error')->setIF(!(strlen(trim($address)) == 0) && !validater::checkIP($address), 'address', 'IP Format Error')->removeIF(trim($address) == trim($extendaddress), 'extendaddress')->setIF($result1, 'extendaddress', 'Conflict!')->setIF($result2, 'address', 'Conflict!')->get();
     $condition = "`lib` = '{$asset->lib}' AND module = '{$asset->module}' and id != '{$assetID}'";
     $conditionaddress = $condition . " and address != 'IP Format Error' and address != 'Conflict!'";
     $conditionextaddress = $condition . " and extendaddress != 'IP Format Error' and extendaddress != 'Conflict!'";
     $this->dao->update(TABLE_INFOASSET)->data($asset)->autoCheck($skipFields)->batchCheck($this->config->asset->edit->requiredFields, 'notempty')->check('hostname', 'unique', $condition)->checkIF(!(strlen(trim($address)) == 0), 'address', 'unique', $conditionaddress)->checkIF(!(strlen(trim($extendaddress)) == 0), 'extendaddress', 'unique', $conditionextaddress)->checkIF(!(strlen(trim($devicenumber)) == 0), 'devicenumber', 'unique', $condition)->checkIF(!(strlen(trim($code)) == 0), 'code', 'unique', $condition)->where('id')->eq((int) $assetID)->exec();
     $asset->editedCount = $asset->editedCount - 1;
     if (!dao::isError()) {
         return common::createChanges($oldAsset, $asset);
     }
 }
예제 #3
0
파일: model.php 프로젝트: huokedu/zentao
 public function updateLib($libID, $type)
 {
     $libID = (int) $libID;
     $oldLib = $this->getLibById($libID);
     $lib = fixer::input('post')->stripTags('name')->add('type', $type)->setIF('$defaultlib==on', 'defaultlib', '1')->setIF('$defaultlib==off', 'defaultlib', '0')->get();
     //检测默认库
     $oldDefaultLibID = $this->getDefaultLibId();
     if ($libID == $oldDefaultLibID) {
         $lib->defaultlib = 1;
     } else {
         if ($lib->defaultlib = 1) {
             $this->clearDefaultLib($type);
         }
     }
     $condition = "type = '{$type}' and id != '{$libID}'";
     $this->dao->update(TABLE_INFOLIB)->data($lib)->autoCheck()->batchCheck($this->config->info->editLib->requiredFields, 'notempty')->check('name', 'unique', $condition)->where('id')->eq($libID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldLib, $lib);
     }
 }
예제 #4
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Update a test task.
  * 
  * @param  int   $taskID 
  * @access public
  * @return void
  */
 public function update($taskID)
 {
     $oldTask = $this->getById($taskID);
     $task = fixer::input('post')->stripTags('name')->get();
     $this->dao->update(TABLE_TESTTASK)->data($task)->autoCheck()->batchcheck($this->config->testtask->edit->requiredFields, 'notempty')->where('id')->eq($taskID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldTask, $task);
     }
 }
 /**
  * Assign a bug to a user again.
  * 
  * @param  int    $bugID 
  * @access public
  * @return void
  */
 public function assign($bugID)
 {
     $now = helper::now();
     $oldBug = $this->getById($bugID);
     $bug = fixer::input('post')->setDefault('lastEditedBy', $this->app->user->account)->setDefault('lastEditedDate', $now)->remove('comment')->get();
     $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq($bugID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldBug, $bug);
     }
 }
예제 #6
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Batch close story.
  * 
  * @access public
  * @return void
  */
 public function batchClose()
 {
     /* Init vars. */
     $stories = array();
     $allChanges = array();
     $now = helper::now();
     $storyIDList = $this->post->storyIDList ? $this->post->storyIDList : array();
     /* Adjust whether the post data is complete, if not, remove the last element of $storyIDList. */
     if ($this->session->showSuhosinInfo) {
         array_pop($storyIDList);
     }
     if (!empty($storyIDList)) {
         foreach ($storyIDList as $storyID) {
             $oldStory = $this->getById($storyID);
             $story->lastEditedBy = $this->app->user->account;
             $story->lastEditedDate = $now;
             $story->closedBy = $this->app->user->account;
             $story->closedDate = $now;
             $story->assignedTo = 'closed';
             $story->assignedDate = $now;
             $story->status = 'closed';
             $story->closedReason = $this->post->closedReasons[$storyID];
             $story->duplicateStory = $this->post->duplicateStoryIDList[$storyID] ? $this->post->duplicateStoryIDList[$storyID] : $oldStory->duplicateStory;
             $story->childStories = $this->post->childStoriesIDList[$storyID] ? $this->post->childStoriesIDList[$storyID] : $oldStory->childStories;
             if ($story->closedReason == 'done') {
                 $story->stage = 'released';
             }
             if ($story->closedReason != 'done') {
                 $story->plan = 0;
             }
             $stories[$storyID] = $story;
             unset($story);
         }
         foreach ($stories as $storyID => $story) {
             $oldStory = $this->getById($storyID);
             $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->batchCheck($this->config->story->close->requiredFields, 'notempty')->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty')->checkIF($story->closedReason == 'subdivided', 'childStories', 'notempty')->where('id')->eq($storyID)->exec();
             if (!dao::isError()) {
                 $allChanges[$storyID] = common::createChanges($oldStory, $story);
             } else {
                 die(js::error('story#' . $storyID . dao::getError(true)));
             }
         }
     }
     return $allChanges;
 }
예제 #7
0
파일: model.php 프로젝트: ppmon/ppm
 /**
  * Close product.
  * 
  * @param  int    $productID.
  * @access public
  * @return void
  */
 public function close($productID)
 {
     $oldProduct = $this->getById($productID);
     $now = helper::now();
     $product = fixer::input('post')->setDefault('status', 'closed')->remove('comment')->get();
     $this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck()->where('id')->eq((int) $productID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldProduct, $product);
     }
 }
예제 #8
0
파일: model.php 프로젝트: XMGmen/zentao
 /**
  * Create from import 
  * 
  * @param  int    $productID 
  * @access public
  * @return void
  */
 public function createFromImport($productID)
 {
     $this->loadModel('action');
     $this->loadModel('story');
     $this->loadModel('file');
     $now = helper::now();
     $data = fixer::input('post')->get();
     if (!empty($_POST['id'])) {
         $oldSteps = $this->dao->select('t2.*')->from(TABLE_CASE)->alias('t1')->leftJoin(TABLE_CASESTEP)->alias('t2')->on('t1.id = t2.case')->where('t1.id')->in($_POST['id'])->andWhere('t1.product')->eq($productID)->andWhere('t1.version=t2.version')->orderBy('t2.id')->fetchGroup('case');
         $oldCases = $this->dao->select('*')->from(TABLE_CASE)->where('id')->in($_POST['id'])->fetchAll('id');
     }
     $cases = array();
     foreach ($data->product as $key => $product) {
         $caseData = new stdclass();
         $caseData->product = $product;
         $caseData->module = $data->module[$key];
         $caseData->story = (int) $data->story[$key];
         $caseData->title = $data->title[$key];
         $caseData->pri = (int) $data->pri[$key];
         $caseData->type = $data->type[$key];
         $caseData->status = $data->status[$key];
         $caseData->stage = join(',', $data->stage[$key]);
         $caseData->frequency = 1;
         $caseData->precondition = $data->precondition[$key];
         if (isset($this->config->testcase->create->requiredFields)) {
             $requiredFields = explode(',', $this->config->testcase->create->requiredFields);
             foreach ($requiredFields as $requiredField) {
                 $requiredField = trim($requiredField);
                 if (empty($caseData->{$requiredField})) {
                     die(js::alert(sprintf($this->lang->testcase->noRequire, $key, $this->lang->testcase->{$requiredField})));
                 }
             }
         }
         $cases[$key] = $caseData;
     }
     foreach ($cases as $key => $caseData) {
         if (!empty($_POST['id'][$key])) {
             $caseID = $data->id[$key];
             $stepChanged = false;
             $steps = array();
             $oldStep = isset($oldSteps[$caseID]) ? $oldSteps[$caseID] : array();
             $oldCase = $oldCases[$caseID];
             /* Remove the empty setps in post. */
             $steps = array();
             if (isset($_POST['desc'][$key])) {
                 foreach ($this->post->desc[$key] as $id => $desc) {
                     $desc = trim($desc);
                     if (empty($desc)) {
                         continue;
                     }
                     $step = new stdclass();
                     $step->desc = $desc;
                     $step->expect = trim($this->post->expect[$key][$id]);
                     $steps[] = $step;
                 }
             }
             /* If step count changed, case changed. */
             if (!$oldStep != !$steps or count($oldStep) != count($steps)) {
                 $stepChanged = true;
             } else {
                 /* Compare every step. */
                 foreach ($oldStep as $id => $oldStep) {
                     if (trim($oldStep->desc) != trim($steps[$id]->desc) or trim($oldStep->expect) != $steps[$id]->expect) {
                         $stepChanged = true;
                         break;
                     }
                 }
             }
             $version = $stepChanged ? $oldCase->version + 1 : $oldCase->version;
             $caseData->version = $version;
             $changes = common::createChanges($oldCase, $caseData);
             if (!$changes and !$stepChanged) {
                 continue;
             }
             if ($changes or $stepChanged) {
                 $caseData->lastEditedBy = $this->app->user->account;
                 $caseData->lastEditedDate = $now;
                 $this->dao->update(TABLE_CASE)->data($caseData)->where('id')->eq($caseID)->autoCheck()->exec();
                 if ($stepChanged) {
                     foreach ($steps as $id => $step) {
                         $step = (array) $step;
                         if (empty($step['desc'])) {
                             continue;
                         }
                         $stepData = new stdclass();
                         $stepData->case = $caseID;
                         $stepData->version = $version;
                         $stepData->desc = htmlspecialchars($step['desc']);
                         $stepData->expect = htmlspecialchars($step['expect']);
                         $this->dao->insert(TABLE_CASESTEP)->data($stepData)->autoCheck()->exec();
                     }
                 }
                 $oldCase->steps = $this->joinStep($oldStep);
                 $caseData->steps = $this->joinStep($steps);
                 $changes = common::createChanges($oldCase, $caseData);
                 $actionID = $this->action->create('case', $caseID, 'Edited');
                 $this->action->logHistory($actionID, $changes);
             }
         } else {
             $caseData->version = 1;
             $caseData->openedBy = $this->app->user->account;
             $caseData->openedDate = $now;
             $this->dao->insert(TABLE_CASE)->data($caseData)->autoCheck()->exec();
             if (!dao::isError()) {
                 $caseID = $this->dao->lastInsertID();
                 foreach ($this->post->desc[$key] as $id => $desc) {
                     $desc = trim($desc);
                     if (empty($desc)) {
                         continue;
                     }
                     $stepData = new stdclass();
                     $stepData->case = $caseID;
                     $stepData->version = 1;
                     $stepData->desc = htmlspecialchars($desc);
                     $stepData->expect = htmlspecialchars($this->post->expect[$key][$id]);
                     $this->dao->insert(TABLE_CASESTEP)->data($stepData)->autoCheck()->exec();
                 }
                 $this->action->create('case', $caseID, 'Opened');
             }
         }
     }
     unlink($this->session->importFile);
     unset($_SESSION['importFile']);
 }
예제 #9
0
파일: model.php 프로젝트: XMGmen/zentao
 /**
  * Batch update todos.
  * 
  * @access public
  * @return array
  */
 public function batchUpdate()
 {
     $todos = array();
     $allChanges = array();
     $data = fixer::input('post')->get();
     $todoIDList = $this->post->todoIDList ? $this->post->todoIDList : array();
     /* Adjust whether the post data is complete, if not, remove the last element of $todoIDList. */
     if ($this->session->showSuhosinInfo) {
         array_pop($taskIDList);
     }
     if (!empty($todoIDList)) {
         /* Initialize todos from the post data. */
         foreach ($todoIDList as $todoID) {
             $todo = new stdclass();
             $todo->date = $data->dates[$todoID];
             $todo->type = $data->types[$todoID];
             $todo->pri = $data->pris[$todoID];
             $todo->status = $data->status[$todoID];
             $todo->name = $todo->type == 'custom' ? $data->names[$todoID] : '';
             $todo->begin = $data->begins[$todoID];
             $todo->end = $data->ends[$todoID];
             if ($todo->type == 'task') {
                 $todo->idvalue = isset($data->tasks[$todoID]) ? $data->tasks[$todoID] : 0;
             }
             if ($todo->type == 'bug') {
                 $todo->idvalue = isset($data->bugs[$todoID]) ? $data->bugs[$todoID] : 0;
             }
             $todos[$todoID] = $todo;
         }
         foreach ($todos as $todoID => $todo) {
             $oldTodo = $this->getById($todoID);
             if ($oldTodo->type != 'custom') {
                 $oldTodo->name = '';
             }
             $this->dao->update(TABLE_TODO)->data($todo)->autoCheck()->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')->checkIF($todo->type == 'bug', 'idvalue', 'notempty')->checkIF($todo->type == 'task', 'idvalue', 'notempty')->where('id')->eq($todoID)->exec();
             if ($oldTodo->status != 'done' and $todo->status == 'done') {
                 $this->loadModel('action')->create('todo', $todoID, 'finished', '', 'done');
             }
             if (!dao::isError()) {
                 $allChanges[$todoID] = common::createChanges($oldTodo, $todo);
             } else {
                 die(js::error('todo#' . $todoID . dao::getError(true)));
             }
         }
     }
     return $allChanges;
 }
예제 #10
0
파일: model.php 프로젝트: ppmon/ppm
 /**
  * Batch update plan.
  * 
  * @param  int    $productID 
  * @access public
  * @return array
  */
 public function batchUpdate($productID)
 {
     $data = fixer::input('post')->get();
     $oldPlans = $this->getByIDList($data->id);
     $plans = array();
     foreach ($data->id as $planID) {
         $plan = new stdclass();
         $plan->title = $data->title[$planID];
         $plan->begin = $data->begin[$planID];
         $plan->end = $data->end[$planID];
         if (empty($plan->title)) {
             die(js::alert(sprintf($this->lang->productplan->errorNoTitle, $planID)));
         }
         if (empty($plan->begin)) {
             die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID)));
         }
         if (empty($plan->end)) {
             die(js::alert(sprintf($this->lang->productplan->errorNoEnd, $planID)));
         }
         if ($plan->begin > $plan->end) {
             die(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID)));
         }
         $plans[$planID] = $plan;
     }
     $changes = array();
     foreach ($plans as $planID => $plan) {
         $change = common::createChanges($oldPlans[$planID], $plan);
         if ($change) {
             $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->where('id')->eq($planID)->exec();
             if (dao::isError()) {
                 die(js::error(dao::getError()));
             }
             $changes[$planID] = $change;
         }
     }
     return $changes;
 }
예제 #11
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Update a build.
  * 
  * @param  int    $buildID 
  * @access public
  * @return void
  */
 public function update($buildID)
 {
     $oldBuild = $this->getByID($buildID);
     $build = fixer::input('post')->stripTags('name')->setDefault('stories', '')->setDefault('bugs', '')->join('stories', ',')->join('bugs', ',')->remove('allchecker')->get();
     $this->dao->update(TABLE_BUILD)->data($build)->autoCheck()->batchCheck($this->config->build->edit->requiredFields, 'notempty')->where('id')->eq((int) $buildID)->check('name', 'unique', "id != {$buildID}")->exec();
     if (!dao::isError()) {
         return common::createChanges($oldBuild, $build);
     }
 }
 /**
  * update a todo.
  * 
  * @param  int    $todoID 
  * @access public
  * @return void
  */
 public function update($todoID)
 {
     $oldTodo = $this->getById($todoID);
     if (!in_array($oldTodo->type, array('sqlreview', 'custom', 'meeting', 'cultivate', 'other'))) {
         $oldTodo->name = '';
     }
     $todo = fixer::input('post')->cleanInt('date, pri, begin, end, private')->specialChars('type,name')->setIF(!in_array($this->post->type, array('sqlreview', 'custom', 'meeting', 'cultivate', 'other')), 'name', '')->setIF($this->post->begin == false, 'begin', '2400')->setIF($this->post->end == false, 'end', '2400')->setDefault('private', 0)->get();
     $this->dao->update(TABLE_TODO)->data($todo)->autoCheck()->checkIF($todo->type == 'custom', $this->config->todo->edit->requiredFields, 'notempty')->where('id')->eq($todoID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldTodo, $todo);
     }
 }
예제 #13
0
파일: model.php 프로젝트: laiello/zentaoms
 /**
  * Import task from Bug. 
  * 
  * @param  int    $projectID 
  * @access public
  * @return void
  */
 public function importBug($projectID)
 {
     $this->loadModel('bug');
     $bugLang = $this->app->loadLang('bug');
     $this->loadModel('task');
     $this->loadModel('story');
     $now = helper::now();
     $BugToTasks = fixer::input('post')->get();
     foreach ($BugToTasks->import as $key => $value) {
         $bug = $this->bug->getById($key);
         $task->project = $projectID;
         $task->story = $bug->story;
         $task->storyVersion = $bug->story;
         $task->fromBug = $key;
         $task->name = $bug->title;
         $task->type = 'devel';
         $task->pri = $BugToTasks->pri[$key];
         $task->consumed = 0;
         $task->status = 'wait';
         $task->statusCustom = strpos(taskModel::CUSTOM_STATUS_ORDER, 'wait') + 1;
         $task->desc = $bugLang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID={$key}"), sprintf('%03d', $key));
         $task->openedDate = $now;
         $task->openedBy = $this->app->user->account;
         if (!empty($BugToTasks->estimate[$key])) {
             $task->estimate = $BugToTasks->estimate[$key];
             $task->left = $task->estimate;
         }
         if (!empty($BugToTasks->assignedTo[$key])) {
             $task->assignedTo = $BugToTasks->assignedTo[$key];
             $task->assignedDate = $now;
         }
         $this->dao->insert(TABLE_TASK)->data($task)->checkIF($BugToTasks->estimate[$key] != '', 'estimate', 'float')->exec();
         if (dao::isError()) {
             echo js::error(dao::getError());
             die(js::reload('parent'));
         }
         $taskID = $this->dao->lastInsertID();
         if ($task->story != false) {
             $this->story->setStage($task->story);
         }
         $actionID = $this->loadModel('action')->create('task', $taskID, 'Opened', '');
         $mails[$key]->taskID = $taskID;
         $mails[$key]->actionID = $actionID;
         $this->action->create('bug', $key, 'Totask', '', $taskID);
         $this->dao->update(TABLE_BUG)->set('toTask')->eq($taskID)->where('id')->eq($key)->exec();
         if ($task->assignedTo and $task->assignedTo != $bug->assignedTo) {
             $newBug = new stdClass();
             $newBug->lastEditedBy = $this->app->user->account;
             $newBug->lastEditedDate = $now;
             $newBug->assignedTo = $task->assignedTo;
             $newBug->assignedDate = $now;
             $this->dao->update(TABLE_BUG)->data($newBug)->where('id')->eq($key)->exec();
             if (dao::isError()) {
                 die(js::error(dao::getError()));
             }
             $changes = common::createChanges($bug, $newBug);
             $actionID = $this->action->create('bug', $key, 'Assigned', '', $newBug->assignedTo);
             $this->action->logHistory($actionID, $changes);
         }
     }
     return $mails;
 }
예제 #14
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Update a project.
  * 
  * @param  int    $projectID 
  * @access public
  * @return array
  */
 public function update($projectID)
 {
     $oldProject = $this->getById($projectID);
     $team = $this->getTeamMemberPairs($projectID);
     $this->lang->project->team = $this->lang->project->teamname;
     $projectID = (int) $projectID;
     $project = fixer::input('post')->stripTags('name, code, team')->setIF($this->post->begin == '0000-00-00', 'begin', '')->setIF($this->post->end == '0000-00-00', 'end', '')->setIF($this->post->acl != 'custom', 'whitelist', '')->join('whitelist', ',')->remove('products')->get();
     $this->dao->update(TABLE_PROJECT)->data($project)->autoCheck($skipFields = 'begin,end')->batchcheck($this->config->project->edit->requiredFields, 'notempty')->checkIF($project->begin != '', 'begin', 'date')->checkIF($project->end != '', 'end', 'date')->checkIF($project->end != '', 'end', 'gt', $project->begin)->check('name', 'unique', "id!={$projectID}")->check('code', 'unique', "id!={$projectID}")->where('id')->eq($projectID)->limit(1)->exec();
     foreach ($project as $fieldName => $value) {
         if ($fieldName == 'PO' or $fieldName == 'PM' or $fieldName == 'QM' or $fieldName == 'RM') {
             if (!empty($value) and !isset($team[$value])) {
                 $member->project = (int) $projectID;
                 $member->account = $value;
                 $member->join = helper::today();
                 $member->role = $fieldName;
                 $member->days = $project->days;
                 $member->hours = $this->config->project->defaultWorkhours;
                 $this->dao->insert(TABLE_TEAM)->data($member)->exec();
             }
         }
     }
     if (!dao::isError()) {
         return common::createChanges($oldProject, $project);
     }
 }
예제 #15
0
파일: model.php 프로젝트: caiwenhao/zentao
 /**
  * Update a release.
  * 
  * @param  int    $releaseID 
  * @access public
  * @return void
  */
 public function update($releaseID)
 {
     $oldRelease = $this->getByID($releaseID);
     $branch = $oldRelease->branch;
     if ($oldRelease->build != $this->post->build) {
         $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch');
     }
     $release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags)->add('branch', (int) $branch)->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')->check('name', 'unique', "id != {$releaseID} AND product = {$release->product} AND deleted = '0'")->where('id')->eq((int) $releaseID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldRelease, $release);
     }
 }
 /**
  * Update a case.
  * 
  * @param  int    $caseID 
  * @access public
  * @return void
  */
 public function update($caseID)
 {
     $oldCase = $this->getById($caseID);
     $now = helper::now();
     $stepChanged = false;
     $steps = array();
     //---------------- Judge steps changed or not.-------------------- */
     /* Remove the empty setps in post. */
     foreach ($this->post->steps as $key => $desc) {
         $desc = trim($desc);
         if (!empty($desc)) {
             $steps[] = array('desc' => $desc, 'expect' => trim($this->post->expects[$key]));
         }
     }
     /* If step count changed, case changed. */
     if (count($oldCase->steps) != count($steps)) {
         $stepChanged = true;
     } else {
         /* Compare every step. */
         foreach ($oldCase->steps as $key => $oldStep) {
             if (trim($oldStep->desc) != trim($steps[$key]['desc']) or trim($oldStep->expect) != $steps[$key]['expect']) {
                 $stepChanged = true;
                 break;
             }
         }
     }
     $version = $stepChanged ? $oldCase->version + 1 : $oldCase->version;
     $case = fixer::input('post')->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->add('version', $version)->setIF($this->post->story != false and $this->post->story != $oldCase->story, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story))->setDefault('story', 0)->specialChars('title')->join('stage', ',')->remove('comment,steps,expects,files,labels')->get();
     $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')->where('id')->eq((int) $caseID)->exec();
     if (!$this->dao->isError()) {
         if ($stepChanged) {
             foreach ($this->post->steps as $stepID => $stepDesc) {
                 if (empty($stepDesc)) {
                     continue;
                 }
                 $step->case = $caseID;
                 $step->version = $version;
                 $step->desc = htmlspecialchars($stepDesc);
                 $step->expect = htmlspecialchars($this->post->expects[$stepID]);
                 $this->dao->insert(TABLE_CASESTEP)->data($step)->autoCheck()->exec();
             }
         }
         /* Join the steps to diff. */
         if ($stepChanged) {
             $oldCase->steps = $this->joinStep($oldCase->steps);
             $case->steps = $this->joinStep($this->getById($caseID, $version)->steps);
         } else {
             unset($oldCase->steps);
         }
         return common::createChanges($oldCase, $case);
     }
 }
예제 #17
0
파일: model.php 프로젝트: laiello/zentaoms
 /**
  * Batch update testcases.
  * 
  * @access public
  * @return array
  */
 public function batchUpdate()
 {
     $cases = array();
     $allChanges = array();
     $now = helper::now();
     $caseIDList = $this->post->caseIDList;
     /* Adjust whether the post data is complete, if not, remove the last element of $caseIDList. */
     if ($this->session->showSuhosinInfo) {
         array_pop($caseIDList);
     }
     /* Initialize cases from the post data.*/
     foreach ($caseIDList as $caseID) {
         $case->lastEditedBy = $this->app->user->account;
         $caee->lastEditedDate = $now;
         $case->pri = $this->post->pris[$caseID];
         $case->status = $this->post->statuses[$caseID];
         $case->module = $this->post->modules[$caseID];
         $case->title = htmlspecialchars($this->post->titles[$caseID]);
         $case->type = $this->post->types[$caseID];
         $case->stage = implode(',', $this->post->stages[$caseID]);
         $cases[$caseID] = $case;
         unset($case);
     }
     /* Update cases. */
     foreach ($cases as $caseID => $case) {
         $oldCase = $this->getByID($caseID);
         $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->edit->requiredFields, 'notempty')->where('id')->eq($caseID)->exec();
         if (!dao::isError()) {
             unset($oldCase->steps);
             $allChanges[$caseID] = common::createChanges($oldCase, $case);
         } else {
             die(js::error('case#' . $caseID . dao::getError(true)));
         }
     }
     return $allChanges;
 }
예제 #18
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Update a product.
  * 
  * @param  int    $productID 
  * @access public
  * @return array
  */
 public function update($productID)
 {
     $productID = (int) $productID;
     $oldProduct = $this->getById($productID);
     $product = fixer::input('post')->stripTags('name,code')->setIF($this->post->acl != 'custom', 'whitelist', '')->join('whitelist', ',')->get();
     $this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck()->batchCheck('name,code', 'notempty')->check('name', 'unique', "id != {$productID}")->check('code', 'unique', "id != {$productID}")->where('id')->eq($productID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldProduct, $product);
     }
 }
예제 #19
0
파일: model.php 프로젝트: caiwenhao/zentao
 /**
  * Update a build.
  * 
  * @param  int    $buildID 
  * @access public
  * @return void
  */
 public function update($buildID)
 {
     $oldBuild = $this->getByID($buildID);
     $build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags)->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')->where('id')->eq((int) $buildID)->check('name', 'unique', "id != {$buildID} AND product = {$build->product} AND deleted = '0'")->exec();
     if (!dao::isError()) {
         return common::createChanges($oldBuild, $build);
     }
 }
예제 #20
0
 /**
  * Close testtask.
  * 
  * @access public
  * @return void
  */
 public function close($taskID)
 {
     $oldTesttask = $this->getById($taskID);
     $testtask = fixer::input('post')->setDefault('status', 'done')->stripTags($this->config->testtask->editor->close['id'], $this->config->allowedTags)->remove('comment')->get();
     $this->dao->update(TABLE_TESTTASK)->data($testtask)->autoCheck()->where('id')->eq((int) $taskID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldTesttask, $testtask);
     }
 }
예제 #21
0
 /**
  * Batch update plan.
  * 
  * @param  int    $productID 
  * @access public
  * @return array
  */
 public function batchUpdate($productID)
 {
     $data = fixer::input('post')->skipSpecial('desc')->get();
     $oldPlans = $this->getByIDList($data->id);
     $this->app->loadClass('purifier', true);
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Cache.DefinitionImpl', null);
     $purifier = new HTMLPurifier($config);
     $plans = array();
     foreach ($data->id as $planID) {
         $plan = new stdclass();
         $plan->title = $data->title[$planID];
         $plan->desc = $purifier->purify($data->desc[$planID]);
         $plan->begin = $data->begin[$planID];
         $plan->end = $data->end[$planID];
         if (empty($plan->title)) {
             die(js::alert(sprintf($this->lang->productplan->errorNoTitle, $planID)));
         }
         if (empty($plan->begin)) {
             die(js::alert(sprintf($this->lang->productplan->errorNoBegin, $planID)));
         }
         if (empty($plan->end)) {
             die(js::alert(sprintf($this->lang->productplan->errorNoEnd, $planID)));
         }
         if ($plan->begin > $plan->end) {
             die(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID)));
         }
         $plans[$planID] = $plan;
     }
     $changes = array();
     foreach ($plans as $planID => $plan) {
         $change = common::createChanges($oldPlans[$planID], $plan);
         if ($change) {
             $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->where('id')->eq($planID)->exec();
             if (dao::isError()) {
                 die(js::error(dao::getError()));
             }
             $changes[$planID] = $change;
         }
     }
     return $changes;
 }
예제 #22
0
파일: model.php 프로젝트: XMGmen/zentao
 /**
  * Update a doc.
  * 
  * @param  int    $docID 
  * @access public
  * @return void
  */
 public function update($docID)
 {
     $oldDoc = $this->getById($docID);
     $now = helper::now();
     $doc = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->setIF($this->post->lib == 'product', 'project', 0)->setIF($this->post->lib != 'product' and $this->post->lib != 'project', 'project', 0)->setIF($this->post->lib != 'product' and $this->post->lib != 'project', 'product', 0)->stripTags($this->config->doc->editor->edit['id'], $this->config->allowedTags)->encodeURL('url')->add('editedBy', $this->app->user->account)->add('editedDate', $now)->remove('comment,files, labels')->get();
     $condition = "lib = '{$doc->lib}' AND module = {$doc->module} AND id != {$docID}";
     $this->dao->update(TABLE_DOC)->data($doc)->autoCheck()->batchCheck($this->config->doc->edit->requiredFields, 'notempty')->check('title', 'unique', $condition)->where('id')->eq((int) $docID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldDoc, $doc);
     }
 }
예제 #23
0
파일: model.php 프로젝트: iamazhi/zentaopms
 /**
  * Update a build.
  * 
  * @param  int    $buildID 
  * @access public
  * @return void
  */
 public function update($buildID)
 {
     $oldBuild = $this->getByID($buildID);
     $build = fixer::input('post')->setDefault('stories', '')->setDefault('bugs', '')->join('stories', ',')->join('bugs', ',')->skipSpecial($this->config->build->editor->edit['id'])->remove('allchecker,resolvedBy,files,labels')->get();
     $this->dao->update(TABLE_BUILD)->data($build)->autoCheck()->batchCheck($this->config->build->edit->requiredFields, 'notempty')->where('id')->eq((int) $buildID)->check('name', 'unique', "id != {$buildID} AND product = {$build->product}")->exec();
     if (!dao::isError()) {
         $this->updateLinkedBug($build);
         return common::createChanges($oldBuild, $build);
     }
 }
예제 #24
0
파일: model.php 프로젝트: laiello/zentaoms
 /**
  * Batch change the stage of story.
  * 
  * @param  string    $stage 
  * @access public
  * @return array
  */
 public function batchChangeStage($storyIDList, $stage)
 {
     $now = helper::now();
     $allChanges = array();
     foreach ($storyIDList as $storyID) {
         $oldStory = $this->getById($storyID);
         if ($oldStory->status == 'draft') {
             continue;
         }
         $story = new stdclass();
         $story->lastEditedBy = $this->app->user->account;
         $story->lastEditedDate = $now;
         $story->stage = $stage;
         $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int) $storyID)->exec();
         if (!dao::isError()) {
             $allChanges[$storyID] = common::createChanges($oldStory, $story);
         }
     }
     return $allChanges;
 }
 /**
  * Activate a task.
  * 
  * @param  int      $taskID 
  * @access public
  * @return void
  */
 public function activate($taskID)
 {
     $oldTask = $this->getById($taskID);
     $task = fixer::input('post')->setDefault('left', 0)->setDefault('status', 'doing')->setDefault('finishedBy, canceledBy, closedBy, closedReason', '')->setDefault('finishedDate, canceledDate, closedDate', '0000-00-00')->setDefault('lastEditedBy', $this->app->user->account)->setDefault('lastEditedDate', helper::now())->remove('comment')->get();
     $this->setStatus($task);
     $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->check('left', 'notempty')->where('id')->eq((int) $taskID)->exec();
     if ($oldTask->story) {
         $this->loadModel('story')->setStage($oldTask->story);
     }
     if (!dao::isError()) {
         return common::createChanges($oldTask, $task);
     }
 }
예제 #26
0
파일: model.php 프로젝트: laiello/zentaoms
 /**
  * Update a plan
  * 
  * @param  int    $planID 
  * @access public
  * @return array
  */
 public function update($planID)
 {
     $oldPlan = $this->getById($planID);
     $plan = fixer::input('post')->stripTags('title')->get();
     $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->batchCheck($this->config->productplan->edit->requiredFields, 'notempty')->check('end', 'gt', $plan->begin)->where('id')->eq((int) $planID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldPlan, $plan);
     }
 }
예제 #27
0
파일: model.php 프로젝트: ppmon/ppm
 /**
  * Batch assign to.
  * 
  * @access public
  * @return array
  */
 public function batchAssignTo()
 {
     $now = helper::now();
     $allChanges = array();
     $storyIDList = $this->post->storyIDList;
     $assignedTo = $this->post->assignedTo;
     $oldStories = $this->getByList($storyIDList);
     foreach ($storyIDList as $storyID) {
         $oldStory = $oldStories[$storyID];
         if ($assignedTo == $oldStory->assignedTo) {
             continue;
         }
         $story = new stdclass();
         $story->lastEditedBy = $this->app->user->account;
         $story->lastEditedDate = $now;
         $story->assignedTo = $assignedTo;
         $story->assignedDate = $now;
         $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int) $storyID)->exec();
         if (!dao::isError()) {
             $allChanges[$storyID] = common::createChanges($oldStory, $story);
         }
     }
     return $allChanges;
 }
예제 #28
0
 /**
  * Import task from Bug. 
  * 
  * @param  int    $projectID 
  * @access public
  * @return void
  */
 public function importBug($projectID)
 {
     $this->loadModel('bug');
     $this->loadModel('task');
     $this->loadModel('story');
     $now = helper::now();
     $modules = $this->loadModel('tree')->getTaskOptionMenu($projectID);
     $bugToTasks = fixer::input('post')->get();
     $bugs = $this->bug->getByList(array_keys($bugToTasks->import));
     foreach ($bugToTasks->import as $key => $value) {
         $bug = $bugs[$key];
         $task = new stdClass();
         $task->project = $projectID;
         $task->story = $bug->story;
         $task->storyVersion = $bug->storyVersion;
         $task->module = isset($modules[$bug->module]) ? $bug->module : 0;
         $task->fromBug = $key;
         $task->name = $bug->title;
         $task->type = 'devel';
         $task->pri = $bugToTasks->pri[$key];
         $task->consumed = 0;
         $task->status = 'wait';
         $task->desc = $this->lang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID={$key}"), sprintf('%03d', $key));
         $task->openedDate = $now;
         $task->openedBy = $this->app->user->account;
         if (!empty($bugToTasks->estimate[$key])) {
             $task->estimate = $bugToTasks->estimate[$key];
             $task->left = $task->estimate;
         }
         if (!empty($bugToTasks->assignedTo[$key])) {
             $task->assignedTo = $bugToTasks->assignedTo[$key];
             $task->assignedDate = $now;
         }
         if (!$bug->confirmed) {
             $this->dao->update(TABLE_BUG)->set('confirmed')->eq(1)->where('id')->eq($bug->id)->exec();
         }
         $this->dao->insert(TABLE_TASK)->data($task)->checkIF($bugToTasks->estimate[$key] != '', 'estimate', 'float')->exec();
         if (dao::isError()) {
             echo js::error(dao::getError());
             die(js::reload('parent'));
         }
         $taskID = $this->dao->lastInsertID();
         if ($task->story != false) {
             $this->story->setStage($task->story);
         }
         $actionID = $this->loadModel('action')->create('task', $taskID, 'Opened', '');
         $mails[$key] = new stdClass();
         $mails[$key]->taskID = $taskID;
         $mails[$key]->actionID = $actionID;
         $this->action->create('bug', $key, 'Totask', '', $taskID);
         $this->dao->update(TABLE_BUG)->set('toTask')->eq($taskID)->where('id')->eq($key)->exec();
         /* activate bug if bug postponed. */
         if ($bug->status == 'resolved' && $bug->resolution == 'postponed') {
             $newBug = new stdclass();
             $newBug->lastEditedBy = $this->app->user->account;
             $newBug->lastEditedDate = $now;
             $newBug->assignedDate = $now;
             $newBug->status = 'active';
             $newBug->resolvedDate = '0000-00-00';
             $newBug->resolution = '';
             $newBug->resolvedBy = '';
             $newBug->resolvedBuild = '';
             $newBug->closedBy = '';
             $newBug->closedDate = '0000-00-00';
             $newBug->duplicateBug = '0';
             $this->dao->update(TABLE_BUG)->data($newBug)->autoCheck()->where('id')->eq($key)->exec();
             $this->dao->update(TABLE_BUG)->set('activatedCount = activatedCount + 1')->where('id')->eq($key)->exec();
             $actionID = $this->action->create('bug', $key, 'Activated');
             $changes = common::createChanges($bug, $newBug);
             $this->action->logHistory($actionID, $changes);
         }
         if (isset($task->assignedTo) and $task->assignedTo and $task->assignedTo != $bug->assignedTo) {
             $newBug = new stdClass();
             $newBug->lastEditedBy = $this->app->user->account;
             $newBug->lastEditedDate = $now;
             $newBug->assignedTo = $task->assignedTo;
             $newBug->assignedDate = $now;
             $this->dao->update(TABLE_BUG)->data($newBug)->where('id')->eq($key)->exec();
             if (dao::isError()) {
                 die(js::error(dao::getError()));
             }
             $changes = common::createChanges($bug, $newBug);
             $actionID = $this->action->create('bug', $key, 'Assigned', '', $newBug->assignedTo);
             $this->action->logHistory($actionID, $changes);
         }
     }
     return $mails;
 }
예제 #29
0
파일: model.php 프로젝트: laiello/zentaoms
 /**
  * Delete estimate. 
  * 
  * @param  int    $estimateID 
  * @access public
  * @return void
  */
 public function deleteEstimate($estimateID)
 {
     $estimate = $this->getEstimateById($estimateID);
     $task = $this->getById($estimate->task);
     $this->dao->delete()->from(TABLE_TASKESTIMATE)->where('id')->eq($estimateID)->exec();
     $lastEstimate = $this->dao->select('*')->from(TABLE_TASKESTIMATE)->where('task')->eq($estimate->task)->orderBy('id desc')->fetch();
     $consumed = $task->consumed - $estimate->consumed;
     $left = $lastEstimate->left;
     $oldStatus = $task->status;
     if ($left == 0) {
         $task->status = 'done';
     }
     $this->dao->update(TABLE_TASK)->set("consumed")->eq($consumed)->set('`left`')->eq($left)->set('status')->eq($task->status)->where('id')->eq($estimate->task)->exec();
     $oldTask = new stdClass();
     $newTask = new stdClass();
     $oldTask->consumed = $task->consumed;
     $newTask->consumed = $consumed;
     $oldTask->left = $task->left;
     $newTask->left = $left;
     $oldTask->status = $oldStatus;
     $newTask->status = $task->status;
     if (!dao::isError()) {
         return common::createChanges($oldTask, $newTask);
     }
 }