diff --git a/module/project/view/tasklist.html.php b/module/project/view/tasklist.html.php index a20ae55108..bbd1c9bdeb 100644 --- a/module/project/view/tasklist.html.php +++ b/module/project/view/tasklist.html.php @@ -112,7 +112,7 @@ if($canBatchEdit) { - $actionLink = $this->createLink('task', 'batchEdit', "projectID=$projectID&orderBy=$orderBy"); + $actionLink = $this->createLink('task', 'batchEdit', "projectID=$projectID"); echo html::commonButton($lang->edit, "onclick=\"changeAction('projectTaskForm', 'batchEdit', '$actionLink')\""); } if($canBatchClose) diff --git a/module/task/config.php b/module/task/config.php index 05179fe5cc..a64182a291 100644 --- a/module/task/config.php +++ b/module/task/config.php @@ -1,6 +1,7 @@ task = new stdclass(); $config->task->batchCreate = 10; +$config->task->batchEdit = 13; $config->task->create = new stdclass(); $config->task->edit = new stdclass(); diff --git a/module/task/control.php b/module/task/control.php index 9b92f586a5..938378fd79 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -261,11 +261,10 @@ class task extends control * Batch edit task. * * @param int $projectID - * @param string $orderBy * @access public * @return void */ - public function batchEdit($projectID = 0, $orderBy = '') + public function batchEdit($projectID = 0) { if($this->post->names) { @@ -302,12 +301,6 @@ class task extends control $taskIDList = $this->post->taskIDList ? $this->post->taskIDList : die(js::locate($this->session->taskList, 'parent')); - /* Initialize vars. */ - $orderBy = str_replace('status', 'statusCustom', $this->cookie->projectTaskOrder); - if(!$orderBy) $orderBy = 'statusCustom,id_desc'; - $columns = 13; - $showSuhosinInfo = false; - /* The tasks of project. */ if($projectID) { @@ -324,7 +317,7 @@ class task extends control else { $this->lang->task->menu = $this->lang->my->menu; - $this->lang->set('menugroup.task', 'my.task'); + $this->lang->set('menugroup.task', 'my'); $this->lang->task->menuOrder = $this->lang->my->menuOrder; $this->loadModel('my')->setMenu(); $this->view->title = $this->lang->task->batchEdit; @@ -335,7 +328,8 @@ class task extends control $tasks = $this->dao->select('*')->from(TABLE_TASK)->where('id')->in($taskIDList)->fetchAll('id'); /* Judge whether the editedTasks is too large and set session. */ - $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($tasks), $columns); + $showSuhosinInfo = false; + $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($tasks), $this->config->task->batchEdit); $this->app->session->set('showSuhosinInfo', $showSuhosinInfo); if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo; diff --git a/module/task/model.php b/module/task/model.php index 69ed5dbfac..9ee77f3ea6 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -226,118 +226,115 @@ class taskModel extends model $allChanges = array(); $now = helper::now(); $today = date(DT_DATE1); - $taskIDList = $this->post->taskIDList ? $this->post->taskIDList : array(); + $taskIDList = $this->post->taskIDList; /* Adjust whether the post data is complete, if not, remove the last element of $taskIDList. */ if($this->session->showSuhosinInfo) array_pop($taskIDList); /* Initialize tasks from the post data.*/ - if(!empty($taskIDList)) + foreach($taskIDList as $taskID) { - foreach($taskIDList as $taskID) + $oldTask = $this->getById($taskID); + + $task->name = htmlspecialchars($this->post->names[$taskID]); + $task->module = isset($this->post->modules[$taskID]) ? $this->post->modules[$taskID] : 0; + $task->type = $this->post->types[$taskID]; + $task->status = $this->post->statuses[$taskID]; + $task->assignedTo = $task->status == 'closed' ? 'closed' : $this->post->assignedTos[$taskID]; + $task->pri = $this->post->pris[$taskID]; + $task->estimate = $this->post->estimates[$taskID]; + $task->left = $this->post->lefts[$taskID]; + $task->finishedBy = $this->post->finishedBys[$taskID]; + $task->canceledBy = $this->post->canceledBys[$taskID]; + $task->closedBy = $this->post->closedBys[$taskID]; + $task->closedReason = $this->post->closedReasons[$taskID]; + $task->finishedDate = ""; + $task->canceledDate = ""; + $task->closedDate = ""; + $task->lastEditedBy = $this->app->user->account; + $task->lastEditedDate = $now; + if(isset($this->post->assignedTos[$taskID])) { - $oldTask = $this->getById($taskID); + $task->assignedDate = $this->post->assignedTos[$taskID] == $oldTask->assignedTo ? $oldTask->assignedDate : $now; + } - $task->name = htmlspecialchars($this->post->names[$taskID]); - $task->module = isset($this->post->modules[$taskID]) ? $this->post->modules[$taskID] : 0; - $task->type = $this->post->types[$taskID]; - $task->status = $this->post->statuses[$taskID]; - $task->assignedTo = $task->status == 'closed' ? 'closed' : $this->post->assignedTos[$taskID]; - $task->pri = $this->post->pris[$taskID]; - $task->estimate = $this->post->estimates[$taskID]; - $task->left = $this->post->lefts[$taskID]; - $task->finishedBy = $this->post->finishedBys[$taskID]; - $task->canceledBy = $this->post->canceledBys[$taskID]; - $task->closedBy = $this->post->closedBys[$taskID]; - $task->closedReason = $this->post->closedReasons[$taskID]; - $task->finishedDate = ""; - $task->canceledDate = ""; - $task->closedDate = ""; - $task->lastEditedBy = $this->app->user->account; - $task->lastEditedDate = $now; - if(isset($this->post->assignedTos[$taskID])) + if($this->post->consumeds[$taskID]) + { + $record = new stdclass(); + $record->account = $this->app->user->account; + $record->task = $taskID; + $record->date = $today; + $record->left = $task->left; + $record->consumed = $this->post->consumeds[$taskID]; + $this->dao->insert(TABLE_TASKESTIMATE)->data($record)->autoCheck()->exec(); + + $task->consumed = $oldTask->consumed + $record->consumed; + } + + switch($task->status) + { + case 'done': + { + $task->left = 0; + if(!$task->finishedBy) $task->finishedBy = $this->app->user->account; + if($task->closedReason) $task->closedDate = $now; + $task->finishedDate = $oldTask->status == 'done' ? $oldTask->finishedDate : $now; + } + break; + case 'cancel': { - $task->assignedDate = $this->post->assignedTos[$taskID] == $oldTask->assignedTo ? $oldTask->assignedDate : $now; + $task->assignedTo = $oldTask->openedBy; + $task->assignedDate = $now; + + if(!$task->canceledBy) $task->canceledBy = $this->app->user->account; + if(!$task->canceledDate) $task->canceledDate = $now; } - - if($this->post->consumeds[$taskID]) - { - $record = new stdclass(); - $record->account = $this->app->user->account; - $record->task = $taskID; - $record->date = $today; - $record->left = $task->left; - $record->consumed = $this->post->consumeds[$taskID]; - $this->dao->insert(TABLE_TASKESTIMATE)->data($record)->autoCheck()->exec(); - - $task->consumed = $oldTask->consumed + $record->consumed; - } - - switch($task->status) - { - case 'done': - { - $task->left = 0; - if(!$task->finishedBy) $task->finishedBy = $this->app->user->account; - if($task->closedReason) $task->closedDate = $now; - $task->finishedDate = $oldTask->status == 'done' ? $oldTask->finishedDate : $now; - } - break; - case 'cancel': - { - $task->assignedTo = $oldTask->openedBy; - $task->assignedDate = $now; - - if(!$task->canceledBy) $task->canceledBy = $this->app->user->account; - if(!$task->canceledDate) $task->canceledDate = $now; - } - break; - case 'closed': + break; + case 'closed': { if(!$task->closedBy) $task->closedBy = $this->app->user->account; if(!$task->closedDate) $task->closedDate = $now; } - break; - case 'wait': - { - if($task->consumed > 0 and $task->left > 0) $task->status = 'doing'; - if($task->left == $oldTask->left and $task->consumed == 0) $task->left = $task->estimate; - } - default:break; - } - if($task->assignedTo) $task->assignedDate = $now; + break; + case 'wait': + { + if($task->consumed > 0 and $task->left > 0) $task->status = 'doing'; + if($task->left == $oldTask->left and $task->consumed == 0) $task->left = $task->estimate; + } + default:break; + } + if($task->assignedTo) $task->assignedDate = $now; - $this->dao->update(TABLE_TASK)->data($task) - ->autoCheck() - ->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty') + $this->dao->update(TABLE_TASK)->data($task) + ->autoCheck() + ->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty') - ->checkIF($task->estimate != false, 'estimate', 'float') - ->checkIF($task->consumed != false, 'consumed', 'float') - ->checkIF($task->left != false, 'left', 'float') - ->checkIF($task->left == 0 and $task->status != 'cancel' and $task->status != 'closed' and $task->consumed != 0, 'status', 'equal', 'done') + ->checkIF($task->estimate != false, 'estimate', 'float') + ->checkIF($task->consumed != false, 'consumed', 'float') + ->checkIF($task->left != false, 'left', 'float') + ->checkIF($task->left == 0 and $task->status != 'cancel' and $task->status != 'closed' and $task->consumed != 0, 'status', 'equal', 'done') - ->batchCheckIF($task->status == 'wait' or $task->status == 'doing', 'finishedBy, finishedDate,canceledBy, canceledDate, closedBy, closedDate, closedReason', 'empty') + ->batchCheckIF($task->status == 'wait' or $task->status == 'doing', 'finishedBy, finishedDate,canceledBy, canceledDate, closedBy, closedDate, closedReason', 'empty') - ->checkIF($task->status == 'done', 'consumed', 'notempty') - ->checkIF($task->status == 'done' and $task->closedReason, 'closedReason', 'equal', 'done') - ->batchCheckIF($task->status == 'done', 'canceledBy, canceledDate', 'empty') + ->checkIF($task->status == 'done', 'consumed', 'notempty') + ->checkIF($task->status == 'done' and $task->closedReason, 'closedReason', 'equal', 'done') + ->batchCheckIF($task->status == 'done', 'canceledBy, canceledDate', 'empty') - ->checkIF($task->status == 'closed', 'closedReason', 'notempty') - ->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty') - ->where('id')->eq((int)$taskID) - ->exec(); + ->checkIF($task->status == 'closed', 'closedReason', 'notempty') + ->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty') + ->where('id')->eq((int)$taskID) + ->exec(); - if($task->status == 'done' and $task->closedReason) $this->dao->update(TABLE_TASK)->set('status')->eq('closed')->where('id')->eq($taskID)->exec(); + if($task->status == 'done' and $task->closedReason) $this->dao->update(TABLE_TASK)->set('status')->eq('closed')->where('id')->eq($taskID)->exec(); - if($oldTask->story != false) $this->loadModel('story')->setStage($oldTask->story); - if(!dao::isError()) - { - $allChanges[$taskID] = common::createChanges($oldTask, $task); - } - else - { - die(js::error('task#' . $taskID . dao::getError(true))); - } + if($oldTask->story != false) $this->loadModel('story')->setStage($oldTask->story); + if(!dao::isError()) + { + $allChanges[$taskID] = common::createChanges($oldTask, $task); + } + else + { + die(js::error('task#' . $taskID . dao::getError(true))); } } diff --git a/module/task/view/batchedit.html.php b/module/task/view/batchedit.html.php index 13eec9af32..0b852a85db 100755 --- a/module/task/view/batchedit.html.php +++ b/module/task/view/batchedit.html.php @@ -65,10 +65,16 @@