public static function findIssues($filters = array(), $results_per_page = 30, $offset = 0, $groupby = null, $grouporder = null, $sortfields = array(tables\Issues::LAST_UPDATED => 'asc')) { $issues = array(); list($rows, $count, $ids) = tables\Issues::getTable()->findIssues($filters, $results_per_page, $offset, $groupby, $grouporder, $sortfields); if ($rows) { if (framework\Context::isProjectContext()) { framework\Context::getCurrentProject()->preloadValues(); } tables\IssueCustomFields::getTable()->preloadValuesByIssueIDs($ids); tables\IssueAffectsBuild::getTable()->preloadValuesByIssueIDs($ids); tables\IssueAffectsEdition::getTable()->preloadValuesByIssueIDs($ids); tables\IssueAffectsComponent::getTable()->preloadValuesByIssueIDs($ids); tables\Comments::getTable()->preloadIssueCommentCounts($ids); tables\IssueFiles::getTable()->preloadIssueFileCounts($ids); $user_ids = array(); foreach ($rows as $key => $row) { try { $issue = new Issue($row->get(tables\Issues::ID), $row); $user_ids[$row['issues.posted_by']] = true; $issues[] = $issue; unset($rows[$key]); } catch (\Exception $e) { } } if (count($user_ids)) { tables\Users::getTable()->preloadUsers(array_keys($user_ids)); } foreach ($issues as $key => $issue) { if (!$issue->hasAccess() || $issue->getProject()->isDeleted()) { unset($issues[$key]); } } tables\IssueCustomFields::getTable()->clearPreloadedValues(); tables\IssueAffectsBuild::getTable()->clearPreloadedValues(); tables\IssueAffectsEdition::getTable()->clearPreloadedValues(); tables\IssueAffectsComponent::getTable()->clearPreloadedValues(); tables\Comments::getTable()->clearPreloadedIssueCommentCounts(); tables\IssueFiles::getTable()->clearPreloadedIssueFileCounts(); } return array($issues, $count); }
public function componentBulkWorkflow() { $workflow_items = array(); $project = null; $issues = array(); $first = true; foreach ($this->issue_ids as $issue_id) { $issue = new entities\Issue($issue_id); $issues[$issue_id] = $issue; if ($first) { $workflow_items = $issue->getAvailableWorkflowTransitions(); $project = $issue->getProject(); $first = false; } else { $transitions = $issue->getAvailableWorkflowTransitions(); foreach ($workflow_items as $transition_id => $transition) { if (!array_key_exists($transition_id, $transitions)) { unset($workflow_items[$transition_id]); } } if ($issue->getProject()->getID() != $project->getID()) { $project = null; break; } } if (!count($workflow_items)) { break; } } $this->issues = $issues; $this->project = $project; $this->available_transitions = $workflow_items; }
/** * Turns a string into a months/weeks/days/hours/minutes/points array * * @param string $string The string to convert * @param Issue $issue * * @return array */ public static function convertFancyStringToTime($string, self $issue) { $retarr = common\Timeable::getZeroedUnitsWithPoints(); $string = mb_strtolower(trim($string)); $time_arr = preg_split('/(\\,|\\/|and|or|plus)/', $string); foreach ($time_arr as $time_elm) { $time_parts = explode(' ', trim($time_elm)); if (is_array($time_parts) && count($time_parts) > 1) { switch (true) { case mb_stristr($time_parts[1], 'month'): if ($issue->getProject()->hasTimeUnit('months')) { $retarr['months'] = (int) trim($time_parts[0]); } break; case mb_stristr($time_parts[1], 'week'): if ($issue->getProject()->hasTimeUnit('weeks')) { $retarr['weeks'] = (int) trim($time_parts[0]); } break; case mb_stristr($time_parts[1], 'day'): if ($issue->getProject()->hasTimeUnit('days')) { $retarr['days'] = (int) trim($time_parts[0]); } break; case mb_stristr($time_parts[1], 'hour'): if ($issue->getProject()->hasTimeUnit('hours')) { $retarr['hours'] = trim($time_parts[0]); } break; case mb_stristr($time_parts[1], 'minute'): if ($issue->getProject()->hasTimeUnit('minutes')) { $retarr['minutes'] = trim($time_parts[0]); } break; case mb_stristr($time_parts[1], 'point'): $retarr['points'] = (int) trim($time_parts[0]); break; } } } return $retarr; }