protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::ISSUE_ID, Issues::getTable(), Issues::ID); parent::_addVarchar(self::TAG_NAME, 50); parent::_addInteger(self::ADDED, 10); }
public function componentMilestoneVirtualStatusDetails() { $this->statuses = \thebuggenie\core\entities\Status::getAll(); if ($this->milestone instanceof \thebuggenie\core\entities\Milestone) { $this->status_details = \thebuggenie\core\entities\tables\Issues::getTable()->getMilestoneDistributionDetails($this->milestone->getID()); } }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addBoolean(self::MUSTFIX); parent::_addForeignKeyColumn(self::PARENT_ID, Issues::getTable(), Issues::ID); parent::_addForeignKeyColumn(self::CHILD_ID, Issues::getTable(), Issues::ID); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::UID, Users::getTable(), Users::ID); parent::_addForeignKeyColumn(self::ISSUE_ID, Issues::getTable(), Issues::ID); parent::_addForeignKeyColumn(self::FILE_ID, Files::getTable(), Files::ID); parent::_addInteger(self::ATTACHED_AT, 10); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::ISSUE_ID, Issues::getTable(), Issues::ID); parent::_addForeignKeyColumn(self::CUSTOMFIELDS_ID, CustomFields::getTable(), CustomFields::ID); parent::_addForeignKeyColumn(self::CUSTOMFIELDOPTION_ID, CustomFieldOptions::getTable(), CustomFieldOptions::ID); parent::_addText(self::OPTION_VALUE, false); }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addBoolean(self::CONFIRMED); parent::_addForeignKeyColumn(self::EDITION, Editions::getTable(), Editions::ID); parent::_addForeignKeyColumn(self::ISSUE, Issues::getTable(), Issues::ID); parent::_addForeignKeyColumn(self::STATUS, ListTypes::getTable(), ListTypes::ID); }
public function getByIssueIDs($issue_ids) { $crit = $this->getCriteria(); $crit->addWhere(self::ISSUE, $issue_ids, Criteria::DB_IN); $crit->addJoin(Issues::getTable(), Issues::ID, self::ISSUE, array(), Criteria::DB_INNER_JOIN); $crit->addJoin(Editions::getTable(), Editions::ID, self::EDITION, array(), Criteria::DB_INNER_JOIN); $res = $this->doSelect($crit, false); return $res; }
public function getUserStarredIssues($user_id) { $crit = $this->getCriteria(); $crit->addWhere(self::UID, $user_id); $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID()); $crit->addJoin(Issues::getTable(), Issues::ID, self::ISSUE); $crit->addWhere(Issues::DELETED, 0); $res = $this->doSelect($crit); return $res; }
protected function _initialize() { parent::_setup(self::B2DBNAME, self::ID); parent::_addForeignKeyColumn(self::ISSUE_ID, Issues::getTable(), Issues::ID); parent::_addForeignKeyColumn(self::EDITED_BY, Users::getTable(), Users::ID); parent::_addInteger(self::EDITED_AT, 10); parent::_addInteger(self::ESTIMATED_MONTHS, 10); parent::_addInteger(self::ESTIMATED_WEEKS, 10); parent::_addInteger(self::ESTIMATED_DAYS, 10); parent::_addInteger(self::ESTIMATED_HOURS, 10); parent::_addFloat(self::ESTIMATED_POINTS); }
public function do_execute() { if (\thebuggenie\core\framework\Context::isInstallmode()) { $this->cliEcho("The Bug Genie is not installed\n", 'red'); } else { $this->cliEcho("Finding times to fix\n", 'white', 'bold'); $issuetimes = \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->getAllSpentTimesForFixing(); $error_issues = array(); foreach ($issuetimes as $issue_id => $times) { if (count($times) > 1) { $this->cliEcho("Fixing times spent for issue ID {$issue_id}, " . count($times) . " entries\n"); $prev_times = \thebuggenie\core\entities\common\Timeable::getZeroedUnitsWithPoints(); foreach ($times as $k => $row) { if ($row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_POINTS] < $prev_times['points'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_HOURS] < $prev_times['minutes'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_HOURS] < $prev_times['hours'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_DAYS] < $prev_times['days'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_WEEKS] < $prev_times['weeks'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_MONTHS] < $prev_times['months']) { $error_issues[] = $issue_id; } else { \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->fixRow($row, $prev_times); $prev_times['points'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_POINTS]; $prev_times['minutes'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_MINUTES]; $prev_times['hours'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_HOURS]; $prev_times['days'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_DAYS]; $prev_times['weeks'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_WEEKS]; $prev_times['months'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_MONTHS]; } } } } foreach (\thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->getAllSpentTimesForFixing() as $issue_id => $times) { foreach ($times as $row) { \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->fixHours($row); } \thebuggenie\core\entities\tables\Issues::getTable()->fixHours($issue_id); } if (count($error_issues) > 0) { $this->cliEcho("\n"); $this->cliEcho("All spent times have been attempted fixed, but there were some issues that could not be fixed automatically!\n"); $this->cliEcho("This happens if there has been adjustments in time spent, lowering the value for spent points, minutes, hours, days, weeks or months.\n\n"); $this->cliEcho("You should fix the issues manually (issue ids corresponding to issue_ids in the timesspent table): "); $this->cliEcho(join(', ', $error_issues) . "\n\n"); $this->cliEcho("Spent times fixed!\n\n", 'green'); } else { $this->cliEcho("All spent times fixed successfully!\n\n", 'green'); } $this->cliEcho("IMPORTANT: Don't run this task again!\n", 'white', 'bold'); } }
public function getUserStarredIssues($user_id) { $crit = $this->getCriteria(); $crit->addWhere(self::UID, $user_id); $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID()); $crit->addJoin(Issues::getTable(), Issues::ID, self::ISSUE); $crit->addWhere(Issues::DELETED, 0); $crit->addSelectionColumn(Issues::ID, 'issue_id'); $res = $this->doSelect($crit); $issues = array(); if ($res) { while ($row = $res->getNextRow()) { $issue_id = $row['issue_id']; $issues[$issue_id] = $issue_id; } } return $issues; }
/** * Poller for the planning page * * @Route(url="/boards/:board_id/poll/:mode") * * @param framework\Request $request */ public function runPoll(framework\Request $request) { $this->forward403unless($this->_checkProjectPageAccess('project_planning')); $last_refreshed = $request['last_refreshed']; $board = entities\tables\AgileBoards::getTable()->selectById($request['board_id']); $search_object = $board->getBacklogSearchObject(); if ($search_object instanceof \thebuggenie\core\entities\SavedSearch) { $search_object->setFilter('last_updated', \thebuggenie\core\entities\SearchFilter::createFilter('last_updated', array('o' => \b2db\Criteria::DB_GREATER_THAN_EQUAL, 'v' => $last_refreshed - 2))); } if ($request['mode'] == 'whiteboard') { $milestone_id = $request['milestone_id']; $ids = \thebuggenie\core\entities\tables\Issues::getTable()->getUpdatedIssueIDsByTimestampAndProjectIDAndMilestoneID($last_refreshed - 2, $this->selected_project->getID(), $milestone_id); } else { $ids = \thebuggenie\core\entities\tables\Issues::getTable()->getUpdatedIssueIDsByTimestampAndProjectIDAndIssuetypeID($last_refreshed - 2, $this->selected_project->getID()); $epic_ids = $board->getEpicIssuetypeID() ? \thebuggenie\core\entities\tables\Issues::getTable()->getUpdatedIssueIDsByTimestampAndProjectIDAndIssuetypeID($last_refreshed - 2, $this->selected_project->getID(), $board->getEpicIssuetypeID()) : array(); } $backlog_ids = array(); if ($search_object instanceof \thebuggenie\core\entities\SavedSearch) { foreach ($search_object->getIssues(true) as $backlog_issue) { foreach ($ids as $id_issue) { if ($id_issue['issue_id'] == $backlog_issue->getID()) { continue 2; } } $backlog_ids[] = array('issue_id' => $backlog_issue->getID(), 'last_updated' => $backlog_issue->getLastUpdatedTime()); } } return $this->renderJSON(compact('ids', 'backlog_ids', 'epic_ids', 'milestone_id')); }
/** * Return an array of issues posted by this user * * @param int $limit number of issues to be retrieved * * @return array */ public function getIssues($limit = null) { return tables\Issues::getTable()->getIssuesPostedByUser($this->getID(), $limit); }
protected function _upgradeFrom4dot1dot5(framework\Request $request) { set_time_limit(0); \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\Issue::getB2DBTable()); \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\IssueSpentTime::getB2DBTable()); \thebuggenie\core\entities\tables\IssueEstimates::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\IssueEstimatesTable::getTable()); $this->upgrade_complete = true; $this->current_version = '4.1.6'; }
/** * Move issues from one step to another for a given issue type and conversions * @param \thebuggenie\core\entities\Issuetype $issuetype * @param array $conversions * * $conversions should be an array containing arrays: * array ( * array(oldstep, newstep) * ... * ) */ public function convertIssueStepPerIssuetype(\thebuggenie\core\entities\Issuetype $issuetype, array $conversions) { tables\Issues::getTable()->convertIssueStepByIssuetype($this, $issuetype, $conversions); }
protected function moveDatatypes($project_id, $to_scope_id) { $this->cliEcho("Moving datatypes..."); $datatype_criteria = ListTypes::getTable()->getCriteria(); $datatype_criteria->addWhere('listtypes.scope', $to_scope_id); $to_scope_datatypes = []; $listtypes = ListTypes::getTable()->select($datatype_criteria); foreach ($listtypes as $listtype) { if (!array_key_exists($listtype->getItemtype(), $to_scope_datatypes)) { $to_scope_datatypes[$listtype->getItemtype()] = []; } $to_scope_datatypes[$listtype->getItemtype()][$listtype->getKey()] = $listtype; } $datatype_criteria = ListTypes::getTable()->getCriteria(); $datatype_criteria->addWhere('listtypes.scope', $this->from_scope); $todo_datatypes = []; $listtypes = ListTypes::getTable()->select($datatype_criteria); foreach ($listtypes as $listtype) { if (!array_key_exists($listtype->getItemtype(), $todo_datatypes)) { $todo_datatypes[$listtype->getItemtype()] = []; } if (array_key_exists($listtype->getKey(), $to_scope_datatypes[$listtype->getItemtype()])) { $todo_datatypes[$listtype->getItemtype()][$listtype->getId()] = $to_scope_datatypes[$listtype->getItemtype()][$listtype->getKey()]->getId(); } else { $new_listtype = clone $listtype; $new_listtype->setScope($to_scope_id); $new_listtype->save(); $todo_datatypes[$listtype->getItemtype()][$listtype->getId()] = $new_listtype->getId(); } } foreach ($todo_datatypes as $itemtype => $types) { switch ($itemtype) { case Datatype::STATUS: $field = 'issue.status'; break; case Datatype::CATEGORY: $field = 'issue.category'; break; case Datatype::ISSUETYPE: $field = 'issue.issuetype'; break; case Datatype::PRIORITY: $field = 'issue.priority'; break; case Datatype::REPRODUCABILITY: $field = 'issue.reproducability'; break; case Datatype::RESOLUTION: $field = 'issue.resolution'; break; case Datatype::SEVERITY: $field = 'issue.severity'; break; default: $field = false; } if ($field !== false) { foreach ($types as $current_type_id => $new_type_id) { $crit = Issues::getTable()->getCriteria(); $crit->addWhere('issues.project_id', $project_id); $crit->addWhere($field, $current_type_id); $crit->addUpdate($field, $new_type_id); Issues::getTable()->doUpdate($crit); } } } $this->cliEcho(" done\n"); }
public function getLast15IssueCountsByProjectID($project_id) { $retarr = array(); for ($cc = 15; $cc >= 0; $cc--) { $crit = $this->getCriteria(); $joinedtable = $crit->addJoin(Issues::getTable(), Issues::ID, self::TARGET); $crit->addWhere(self::TARGET_TYPE, self::TYPE_ISSUE); $crit->addWhere(self::CHANGE_TYPE, array(self::LOG_ISSUE_CREATED, self::LOG_ISSUE_CLOSE), Criteria::DB_IN); $crit->addWhere(Issues::PROJECT_ID, $project_id); $crit->addWhere(Issues::DELETED, false); $crit->addJoin(IssueTypes::getTable(), IssueTypes::ID, Issues::ISSUE_TYPE, array(), Criteria::DB_LEFT_JOIN, $joinedtable); $crit->addWhere(IssueTypes::ICON, 'bug_report'); $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID()); $ctn = $crit->returnCriterion(self::TIME, NOW - 86400 * ($cc + 1), Criteria::DB_GREATER_THAN_EQUAL); $ctn->addWhere(self::TIME, NOW - 86400 * $cc, Criteria::DB_LESS_THAN_EQUAL); $crit->addWhere($ctn); $crit2 = clone $crit; $crit->addWhere(self::CHANGE_TYPE, self::LOG_ISSUE_CLOSE); $crit2->addWhere(self::CHANGE_TYPE, self::LOG_ISSUE_CREATED); $retarr[0][$cc] = $this->doCount($crit); $retarr[1][$cc] = $this->doCount($crit2); } return $retarr; }
protected function _upgradeFrom3dot2(framework\Request $request) { set_time_limit(0); \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable()); \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable()); \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable()); \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable()); \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable()); \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable()); \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable()); \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable()); \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable()); \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable()); \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable()); \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable()); \thebuggenie\core\entities\Dashboard::getB2DBTable()->create(); \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable()); \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create(); \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create(); $transaction = \b2db\Core::startTransaction(); // Upgrade user passwords switch ($request['upgrade_passwords']) { case 'manual': $password = $request['manual_password']; foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) { $user->setPassword($password); $user->save(); } break; case 'auto': $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email'; foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) { if ($field == 'username' && trim($user->getUsername())) { $user->setPassword(trim($user->getUsername())); $user->save(); } elseif ($field == 'email' && trim($user->getEmail())) { $user->setPassword(trim($user->getEmail())); $user->save(); } } break; } $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1); $adminuser->setPassword($request['admin_password']); $adminuser->save(); // Add new settings framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1); foreach ($request->getParameter('status') as $scope_id => $status_id) { $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id); if ($scope instanceof \thebuggenie\core\entities\Scope) { $epic = new \thebuggenie\core\entities\Issuetype(); $epic->setName('Epic'); $epic->setIcon('epic'); $epic->setDescription('Issue type suited for entering epics'); $epic->setScope($scope_id); $epic->save(); framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id); foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) { $transition = new \thebuggenie\core\entities\WorkflowTransition(); $steps = $workflow->getSteps(); $step = array_shift($steps); $step->setLinkedStatusID((int) $status_id); $step->save(); $transition->setOutgoingStep($step); $transition->setName('Issue created'); $transition->setWorkflow($workflow); $transition->setScope($scope); $transition->setDescription('This is the initial transition for issues using this workflow'); $transition->save(); $workflow->setInitialTransition($transition); $workflow->save(); } \thebuggenie\core\entities\ActivityType::loadFixtures($scope); } } $transaction->commitAndEnd(); framework\Context::finishUpgrading(); foreach (framework\Context::getModules() as $module) { $module->upgrade(); } $this->upgrade_complete = true; }
/** * Delete this milestone */ protected function _preDelete() { tables\Issues::getTable()->clearMilestone($this->getID()); }
public function getLast15IssueCountsByProjectID($project_id) { $retarr = array(); for ($cc = 15; $cc >= 0; $cc--) { $crit = $this->getCriteria(); $crit->addJoin(Issues::getTable(), Issues::ID, self::TARGET, array(array(Issues::PROJECT_ID, $project_id), array(Issues::DELETED, false))); $crit->addWhere(self::CHANGE_TYPE, array(self::LOG_ISSUE_CREATED, self::LOG_ISSUE_CLOSE), Criteria::DB_IN); $crit->addWhere(self::TARGET_TYPE, self::TYPE_ISSUE); $crit->addWhere(Issues::DELETED, false); $crit->addWhere(Issues::PROJECT_ID, $project_id); $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID()); $ctn = $crit->returnCriterion(self::TIME, NOW - 86400 * ($cc + 1), Criteria::DB_GREATER_THAN_EQUAL); $ctn->addWhere(self::TIME, NOW - 86400 * $cc, Criteria::DB_LESS_THAN_EQUAL); $crit->addWhere($ctn); $closed_count = array(); $open_count = array(); if ($res = $this->doSelect($crit)) { while ($row = $res->getNextRow()) { if ($row[self::CHANGE_TYPE] == self::LOG_ISSUE_CLOSE) { $closed_count[$row->get(self::TARGET)] = true; } else { $open_count[$row->get(self::TARGET)] = true; } } } $retarr[0][$cc] = count($closed_count); $retarr[1][$cc] = count($open_count); } return $retarr; }
protected function _generateImageDetailsFromKey($mode = null) { $this->graphmode = null; $i18n = framework\Context::getI18n(); if ($mode == 'main') { $this->width = 695; $this->height = 310; } else { $this->width = 230; $this->height = 150; } switch ($this->key) { case 'issues_per_status': $this->graphmode = 'piechart'; $counts = tables\Issues::getTable()->getStatusCountByProjectID($this->selected_project->getID()); if ($this->image_number == 1) { $this->title = $i18n->__('Total number of issues per status type'); } elseif ($this->image_number == 2) { $this->title = $i18n->__('Open issues per status type'); } elseif ($this->image_number == 3) { $this->title = $i18n->__('Closed issues per status type'); } break; case 'issues_per_priority': $this->graphmode = 'piechart'; $counts = tables\Issues::getTable()->getPriorityCountByProjectID($this->selected_project->getID()); if ($this->image_number == 1) { $this->title = $i18n->__('Total number of issues per priority level'); } elseif ($this->image_number == 2) { $this->title = $i18n->__('Open issues per priority level'); } elseif ($this->image_number == 3) { $this->title = $i18n->__('Closed issues per priority level'); } break; case 'issues_per_category': $this->graphmode = 'piechart'; $counts = tables\Issues::getTable()->getCategoryCountByProjectID($this->selected_project->getID()); if ($this->image_number == 1) { $this->title = $i18n->__('Total number of issues per category'); } elseif ($this->image_number == 2) { $this->title = $i18n->__('Open issues per category'); } elseif ($this->image_number == 3) { $this->title = $i18n->__('Closed issues per category'); } break; case 'issues_per_resolution': $this->graphmode = 'piechart'; $counts = tables\Issues::getTable()->getResolutionCountByProjectID($this->selected_project->getID()); if ($this->image_number == 1) { $this->title = $i18n->__('Total number of issues per resolution'); } elseif ($this->image_number == 2) { $this->title = $i18n->__('Open issues per resolution'); } elseif ($this->image_number == 3) { $this->title = $i18n->__('Closed issues per resolution'); } break; case 'issues_per_reproducability': $this->graphmode = 'piechart'; $counts = tables\Issues::getTable()->getReproducabilityCountByProjectID($this->selected_project->getID()); if ($this->image_number == 1) { $this->title = $i18n->__('Total number of issues per reproducability level'); } elseif ($this->image_number == 2) { $this->title = $i18n->__('Open issues per reproducability level'); } elseif ($this->image_number == 3) { $this->title = $i18n->__('Closed issues per reproducability level'); } break; case 'issues_per_state': $this->graphmode = 'piechart'; $counts = tables\Issues::getTable()->getStateCountByProjectID($this->selected_project->getID()); if ($this->image_number == 1) { $this->title = $i18n->__('Total number of issues (open / closed)'); } break; default: throw new \Exception(__("unknown key '%key'", array('%key' => $this->key))); } $this->title = html_entity_decode($this->title); list($values, $labels, $colors) = $this->_calculateImageDetails($counts); $this->values = $values; $this->labels = $labels; $this->colors = $colors; }
/** * Milestone actions * * @Route(url="/:project_key/milestone/:milestone_id/actions/*", name='project_milestone') * * @param \thebuggenie\core\framework\Request $request */ public function runMilestone(framework\Request $request) { $milestone_id = $request['milestone_id'] ? $request['milestone_id'] : null; $milestone = new \thebuggenie\core\entities\Milestone($milestone_id); $action_option = str_replace($this->selected_project->getKey() . '/milestone/' . $request['milestone_id'] . '/', '', $request['url']); try { if (!($this->getUser()->canAddScrumSprints($this->selected_project) || $this->getUser()->canManageProjectReleases($this->selected_project) && $this->getUser()->canManageProject($this->selected_project))) { throw new \Exception($this->getI18n()->__("You don't have access to modify milestones")); } switch (true) { case $request->isDelete(): $milestone->delete(); $no_milestone = new \thebuggenie\core\entities\Milestone(0); $no_milestone->setProject($milestone->getProject()); return $this->renderJSON(array('issue_count' => $no_milestone->countIssues(), 'hours' => $no_milestone->getHoursEstimated(), 'points' => $no_milestone->getPointsEstimated())); case $request->isPost(): $this->_saveMilestoneDetails($request, $milestone); if ($request->hasParameter('issues') && $request['include_selected_issues']) { \thebuggenie\core\entities\tables\Issues::getTable()->assignMilestoneIDbyIssueIDs($milestone->getID(), $request['issues']); } $event = \thebuggenie\core\framework\Event::createNew('project', 'runMilestone::post', $milestone); $event->triggerUntilProcessed(); if ($event->isProcessed()) { $component = $event->getReturnValue(); } else { $component = $this->getComponentHTML('project/milestonebox', array('milestone' => $milestone, 'include_counts' => true)); } $message = framework\Context::getI18n()->__('Milestone saved'); return $this->renderJSON(array('message' => $message, 'component' => $component, 'milestone_id' => $milestone->getID())); case $action_option == 'details': \thebuggenie\core\framework\Context::performAction(new \thebuggenie\core\modules\project\controllers\Main(), 'project', 'MilestoneDetails'); return true; default: return $this->forward($this->getRouting()->generate('project_roadmap', array('project_key' => $this->selected_project->getKey()))); } } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }
public function getEpicIssues() { if ($this->_epic_issues === null) { $this->_epic_issues = \thebuggenie\core\entities\tables\Issues::getTable()->getOpenIssuesByProjectIDAndIssuetypeID($this->getProject()->getID(), $this->getEpicIssuetypeID()); } return $this->_epic_issues; }
/** * * @param \b2db\Criteria $crit * @param array|\thebuggenie\core\entities\SearchFilter $filters * @param \b2db\Criterion $ctn * @return null */ public function addToCriteria($crit, $filters, $ctn = null) { $filter_key = $this->getFilterKey(); if (in_array($this['operator'], array('=', '!=', '<=', '>=', '<', '>'))) { if ($filter_key == 'text') { if ($this['value'] != '') { $searchterm = mb_strpos($this['value'], '%') !== false ? $this['value'] : "%{$this['value']}%"; $issue_no = Issue::extractIssueNoFromNumber($this['value']); if ($this['operator'] == '=') { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_LIKE); } $ctn->addOr(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_LIKE); $ctn->addOr(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_LIKE); $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); if (is_numeric($issue_no)) { $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); if (is_numeric($issue_no)) { $ctn->addOr(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_LIKE); } else { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::TITLE, $searchterm, Criteria::DB_NOT_LIKE); } $ctn->addWhere(tables\Issues::DESCRIPTION, $searchterm, Criteria::DB_NOT_LIKE); $ctn->addWhere(tables\Issues::REPRODUCTION_STEPS, $searchterm, Criteria::DB_NOT_LIKE); $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); if (is_numeric($issue_no)) { $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); if (is_numeric($issue_no)) { $ctn->addWhere(tables\Issues::ISSUE_NO, $issue_no, Criteria::DB_EQUALS); } // $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $searchterm, Criteria::DB_NOT_LIKE); } return $ctn; } } elseif (in_array($filter_key, self::getValidSearchFilters())) { if ($filter_key == 'subprojects') { if (framework\Context::isProjectContext()) { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\Issues::PROJECT_ID, framework\Context::getCurrentProject()->getID()); } if ($this->hasValue()) { foreach ($this->getValues() as $value) { switch ($value) { case 'all': $subprojects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject()); foreach ($subprojects as $subproject) { if ($subproject->getID() == framework\Context::getCurrentProject()->getID()) { continue; } $ctn->addOr(tables\Issues::PROJECT_ID, $subproject->getID()); } break; case 'none': case '': break; default: $ctn->addOr(tables\Issues::PROJECT_ID, (int) $value); break; } } } return $ctn; } } elseif (in_array($filter_key, array('build', 'edition', 'component'))) { switch ($filter_key) { case 'component': $tbl = tables\IssueAffectsComponent::getTable(); $fk = tables\IssueAffectsComponent::ISSUE; break; case 'edition': $tbl = tables\IssueAffectsEdition::getTable(); $fk = tables\IssueAffectsEdition::ISSUE; break; case 'build': $tbl = tables\IssueAffectsBuild::getTable(); $fk = tables\IssueAffectsBuild::ISSUE; break; } $crit->addJoin($tbl, $fk, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.' . $filter_key, $this->getValues())), \b2db\Criteria::DB_INNER_JOIN); return null; } else { if ($filter_key == 'project_id' && in_array('subprojects', $filters)) { return null; } $values = $this->getValues(); $num_values = 0; if ($filter_key == 'status') { if ($this->hasValue('open')) { $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_OPEN); $num_values++; } if ($this->hasValue('closed')) { $num_values++; if (isset($c)) { $c->addWhere(tables\Issues::STATE, Issue::STATE_CLOSED); } else { $c = $crit->returnCriterion(tables\Issues::STATE, Issue::STATE_CLOSED); } } if (isset($c)) { if (count($values) == $num_values) { return $c; } else { $crit->addWhere($c); } } } $dbname = tables\Issues::getTable()->getB2DBName(); foreach ($values as $value) { $operator = $this['operator']; $or = true; if ($filter_key == 'status' && in_array($value, array('open', 'closed'))) { continue; } else { $field = $dbname . '.' . $filter_key; if ($operator == '!=' || in_array($filter_key, array('posted', 'last_updated'))) { $or = false; } } if ($ctn === null) { $ctn = $crit->returnCriterion($field, $value, urldecode($operator)); } elseif ($or) { $ctn->addOr($field, $value, urldecode($operator)); } else { $ctn->addWhere($field, $value, urldecode($operator)); } } return $ctn; } } elseif (CustomDatatype::doesKeyExist($filter_key)) { $customdatatype = CustomDatatype::getByKey($filter_key); if (in_array($this->getFilterType(), CustomDatatype::getInternalChoiceFieldsAsArray())) { $tbl = clone tables\IssueCustomFields::getTable(); $crit->addJoin($tbl, tables\IssueCustomFields::ISSUE_ID, tables\Issues::ID, array(array($tbl->getB2DBAlias() . '.customfields_id', $customdatatype->getID()), array($tbl->getB2DBAlias() . '.customfieldoption_id', $this->getValues())), \b2db\Criteria::DB_INNER_JOIN); return null; } else { foreach ($this->getValues() as $value) { if ($customdatatype->hasCustomOptions()) { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID()); $ctn->addWhere(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']); } else { $ctn->addOr(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID, $value, $this['operator']); } } else { if ($ctn === null) { $ctn = $crit->returnCriterion(tables\IssueCustomFields::CUSTOMFIELDS_ID, $customdatatype->getID()); $ctn->addWhere(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']); } else { $ctn->addOr(tables\IssueCustomFields::OPTION_VALUE, $value, $this['operator']); } } } return $ctn; } } } }
<?php echo link_tag(make_url('project_last_issues', array('project_key' => framework\Context::getCurrentProject()->getKey(), 'units' => 30, 'time_unit' => 'days')), image_tag('icon_savedsearch.png') . __('Issues reported last 30 days')); ?> <div class="header"><?php echo __('Recently watched issues'); ?> </div> <?php if (array_key_exists('viewissue_list', $_SESSION) && is_array($_SESSION['viewissue_list'])) { ?> <?php foreach ($_SESSION['viewissue_list'] as $k => $i_id) { ?> <?php try { $an_issue = \thebuggenie\core\entities\tables\Issues::getTable()->getIssueById($i_id); if (!$an_issue instanceof \thebuggenie\core\entities\Issue) { unset($_SESSION['viewissue_list'][$k]); continue; } } catch (\Exception $e) { unset($_SESSION['viewissue_list'][$k]); } echo link_tag(make_url('viewissue', array('project_key' => $an_issue->getProject()->getKey(), 'issue_no' => $an_issue->getFormattedIssueNo())), $an_issue->getFormattedTitle(true, false), array('title' => $an_issue->getFormattedTitle(true, true))); ?> <?php } ?> <?php } ?>
public function getCountsForBuild($build_id) { $crit = $this->getCriteria(); $crit->addWhere(self::BUILD, $build_id); $crit2 = clone $crit; $crit2->addJoin(Issues::getTable(), Issues::ID, self::ISSUE); $crit2->addWhere(Issues::STATE, \thebuggenie\core\entities\Issue::STATE_CLOSED); return array($this->doCount($crit), $this->doCount($crit2)); }
public function runProjectIssueCommitsMore(framework\Request $request) { $this->forward403unless($request->isPost()); $this->selected_project = Project::getByKey($request['project_key']); framework\Context::setCurrentProject($this->selected_project); if (framework\Context::getModule('vcs_integration')->getSetting('vcs_mode_' . framework\Context::getCurrentProject()->getID()) == Vcs_integration::MODE_DISABLED) { return $this->return404(framework\Context::getI18n()->__('VCS Integration has been disabled for this project')); } $issue = Issues::getTable()->getByProjectIDAndIssueNo($this->selected_project->getID(), $request['issue_no']); $links = IssueLink::getCommitsByIssue($issue, $request->getParameter('limit', 0), $request->getParameter('offset', 0)); return $this->renderJSON(array('content' => $this->getComponentHTML('vcs_integration/issuecommits', array("projectId" => $this->selected_project->getID(), "links" => $links)))); }
/** * Save changes made to the issue since last time * * @return boolean */ protected function _preSave($is_new) { parent::_preSave($is_new); if ($is_new) { if (!$this->_issue_no) { $this->_issue_no = tables\Issues::getTable()->getNextIssueNumberForProductID($this->getProject()->getID()); } if (!$this->_posted) { $this->_posted = NOW; } if (!$this->_last_updated) { $this->_last_updated = NOW; } if (!$this->_posted_by) { $this->_posted_by = framework\Context::getUser(); } $step = $this->getProject()->getWorkflowScheme()->getWorkflowForIssuetype($this->getIssueType())->getFirstStep(); $step->applyToIssue($this); return; } $this->_last_updated = NOW; }