* change getList to getByList

* add getByList in story module.
This commit is contained in:
wyd621
2014-03-24 02:24:56 +00:00
parent b66c834b43
commit 8086d79e70
5 changed files with 34 additions and 13 deletions
+1 -1
View File
@@ -840,7 +840,7 @@ class bug extends control
/* Reset $_POST. Do not unset that because the function of close need that in model. */
$_POST = array();
$bugs = $this->bug->getList($bugIDList);
$bugs = $this->bug->getByList($bugIDList);
foreach($bugs as $bugID => $bug)
{
if($bug->status != 'resolved')
+3 -3
View File
@@ -202,7 +202,7 @@ class bugModel extends model
* @access public
* @return array
*/
public function getList($bugIDList = 0)
public function getByList($bugIDList = 0)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('deleted')->eq(0)
@@ -423,7 +423,7 @@ class bugModel extends model
public function batchConfirm($bugIDList)
{
$now = helper::now();
$bugs = $this->getList($bugIDList);
$bugs = $this->getByList($bugIDList);
foreach($bugIDList as $bugID)
{
if($bugs[$bugID]->confirmed) continue;
@@ -483,7 +483,7 @@ class bugModel extends model
public function batchResolve($bugIDList, $resolution, $resolvedBuild)
{
$now = helper::now();
$bugs = $this->getList($bugIDList);
$bugs = $this->getByList($bugIDList);
foreach($bugIDList as $bugID)
{
$oldBug = $bugs[$bugID];
+28 -7
View File
@@ -57,6 +57,21 @@ class storyModel extends model
return $story;
}
/**
* Get stories by idList.
*
* @param int|array|string $storyIDList
* @access public
* @return array
*/
public function getByList($storyIDList = 0)
{
return $this->dao->select('*')->from(TABLE_STORY)
->where('deleted')->eq(0)
->beginIF($storyIDList)->andWhere('id')->in($storyIDList)->fi()
->fetchAll('id');
}
/**
* Get affected things.
*
@@ -374,9 +389,10 @@ class storyModel extends model
/* Init $stories. */
if(!empty($storyIDList))
{
$oldStories = $this->getByList($storyIDList);
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
$story = new stdclass();
$story->lastEditedBy = $this->app->user->account;
@@ -408,7 +424,7 @@ class storyModel extends model
foreach($stories as $storyID => $story)
{
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
$this->dao->update(TABLE_STORY)->data($story)
->autoCheck()
@@ -510,9 +526,11 @@ class storyModel extends model
$date = helper::today();
$actions = array();
$this->loadModel('action');
$oldStories = $this->getByList($storyIDList);
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
if($oldStory->status != 'draft' and $oldStory->status != 'changed') continue;
$story = new stdClass();
@@ -591,9 +609,10 @@ class storyModel extends model
/* Adjust whether the post data is complete, if not, remove the last element of $storyIDList. */
if($this->session->showSuhosinInfo) array_pop($storyIDList);
$oldStories = $this->getByList($storyIDList);
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
if($oldStory->status == 'closed') continue;
$story = new stdclass();
@@ -620,7 +639,7 @@ class storyModel extends model
{
if(!$story->closedReason) continue;
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
$this->dao->update(TABLE_STORY)->data($story)
->autoCheck()
@@ -653,9 +672,10 @@ class storyModel extends model
{
$now = helper::now();
$allChanges = array();
$oldStories = $this->getByList($storyIDList);
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
$story = new stdclass();
$story->lastEditedBy = $this->app->user->account;
@@ -681,9 +701,10 @@ class storyModel extends model
{
$now = helper::now();
$allChanges = array();
$oldStories = $this->getByList($storyIDList);
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
$oldStory = $oldStories[$storyID];
if($oldStory->status == 'draft') continue;
$story = new stdclass();
+1 -1
View File
@@ -641,7 +641,7 @@ class task extends control
unset($_POST['taskIDList']);
$this->loadModel('action');
$tasks = $this->task->getList($taskIDList);
$tasks = $this->task->getByList($taskIDList);
foreach($tasks as $taskID => $task)
{
if($task->status == 'wait' or $task->status == 'doing')
+1 -1
View File
@@ -684,7 +684,7 @@ class taskModel extends model
* @access public
* @return array
*/
public function getList($taskIDList = 0)
public function getByList($taskIDList = 0)
{
return $this->dao->select('*')->from(TABLE_TASK)
->where('deleted')->eq(0)