lite.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * 获取待审批的需求。
  4. * Get reviewing stories.
  5. *
  6. * @param string $orderBy
  7. * @param bool $checkExists
  8. * @access public
  9. * @return array|bool
  10. */
  11. public function getReviewingStories($orderBy = 'id_desc', $checkExists = false, $type = 'story')
  12. {
  13. $this->app->loadLang($type);
  14. $stories = $this->dao->select("t1.id, t1.title, 'story' AS type, t1.type AS storyType, t1.openedDate AS time, t1.status, t1.product, 0 AS project, t1.parent")->from(TABLE_STORY)->alias('t1')
  15. ->leftJoin(TABLE_STORYREVIEW)->alias('t2')->on('t1.id = t2.story and t1.version = t2.version')
  16. ->leftJoin(TABLE_PROJECTSTORY)->alias('t3')->on('t1.id = t3.story')
  17. ->leftJoin(TABLE_PROJECT)->alias('t4')->on('t3.project = t4.id')
  18. ->where('t1.deleted')->eq(0)
  19. ->beginIF(!$this->app->user->admin)->andWhere('t1.product')->in($this->app->user->view->products)->fi()
  20. ->andWhere('t2.reviewer')->eq($this->app->user->account)
  21. ->andWhere('t2.result')->eq('')
  22. ->andWhere('t1.type')->eq($type)
  23. ->andWhere('t1.vision')->eq($this->config->vision)
  24. ->andWhere('t1.status')->eq('reviewing')
  25. ->andWhere('t4.deleted')->eq('0')
  26. ->orderBy($orderBy)
  27. ->beginIF($checkExists)->limit(1)->fi()
  28. ->fetchAll('id');
  29. if($checkExists)
  30. {
  31. return !empty($stories);
  32. }
  33. $actions = $this->dao->select('objectID,`date`')->from(TABLE_ACTION)->where('objectType')->eq('story')->andWhere('objectID')->in(array_keys($stories))->andWhere('action')->eq('submitreview')->orderBy('`date`')->fetchPairs();
  34. $projects = $this->dao->select('story,project')->from(TABLE_PROJECTSTORY)->where('story')->in(array_keys($stories))->fetchPairs();
  35. foreach($projects as $storyID => $projectID) $stories[$storyID]->project = $projectID;
  36. foreach($actions as $storyID => $date) $stories[$storyID]->time = $date;
  37. return array_values($stories);
  38. }