public function runListProjects(framework\Request $request) { $projects = entities\Project::getAll(); $return_array = array(); foreach ($projects as $project) { $return_array[$project->getKey()] = $project->getName(); } $this->projects = $return_array; }
/** * Pre-execute function * * @param \thebuggenie\core\framework\Request $request */ public function preExecute(framework\Request $request, $action) { $this->article = null; $this->article_name = $request->getRawParameter('article_name'); $this->article_id = (int) $request['article_id']; $this->special = false; if (!is_null($this->article_name) && mb_strpos($this->article_name, ':') !== false) { $this->article_name = $this->_getArticleNameDetails($this->article_name); } else { try { if ($project_key = $request['project_key']) { $this->selected_project = \thebuggenie\core\entities\Project::getByKey($project_key); } elseif ($project_id = (int) $request['project_id']) { $this->selected_project = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($project_id); } } catch (\Exception $e) { } } if (!$this->special) { if ($this->article_id) { $this->article = Articles::getTable()->selectById($this->article_id); } elseif ($this->article_name) { $this->article = Articles::getTable()->getArticleByName($this->article_name); } if (!$this->article instanceof Article) { $this->article = new Article(); if ($this->article_name) { $this->article->setName($this->article_name); } elseif ($request->hasParameter('parent_article_name')) { $parent_article_name = $request->getRawParameter('parent_article_name'); $this->article->setParentArticle(Articles::getTable()->getArticleByName($parent_article_name)); $this->_getArticleNameDetails($parent_article_name); if ($this->article->getParentArticle() instanceof Article) { if ($this->article->getParentArticle()->getArticleType() == Article::TYPE_WIKI) { $this->article->setName($this->article->getParentArticle()->getName() . ':'); } $this->article->setArticleType($this->article->getParentArticle()->getArticleType()); } } $this->article->setContentSyntax($this->getUser()->getPreferredWikiSyntax(true)); } } if ($this->selected_project instanceof \thebuggenie\core\entities\Project) { if (!$this->selected_project->hasAccess()) { $this->forward403(); } else { framework\Context::setCurrentProject($this->selected_project); } } }
/** * Pre-execute function * * @param framework\Request $request * @param string $action */ public function preExecute(framework\Request $request, $action) { try { if ($project_id = $request['project_id']) { $this->selected_project = entities\Project::getB2DBTable()->selectById($project_id); } elseif ($project_key = $request['project_key']) { $this->selected_project = entities\Project::getByKey($project_key); } } catch (\Exception $e) { } if (!$this->selected_project instanceof entities\Project) { return $this->return404(framework\Context::getI18n()->__('This project does not exist')); } framework\Context::setCurrentProject($this->selected_project); $this->project_key = $this->selected_project->getKey(); }
public function componentArchivedProjects() { if (!isset($this->target)) { $this->projects = entities\Project::getAllRootProjects(true); $this->project_count = count($this->projects); } elseif ($this->target == 'team') { $this->team = entities\Team::getB2DBTable()->selectById($this->id); $projects = array(); foreach (entities\Project::getAllByOwner($this->team) as $project) { $projects[$project->getID()] = $project; } foreach (entities\Project::getAllByLeader($this->team) as $project) { $projects[$project->getID()] = $project; } foreach (entities\Project::getAllByQaResponsible($this->team) as $project) { $projects[$project->getID()] = $project; } foreach ($this->team->getAssociatedProjects() as $project_id => $project) { $projects[$project_id] = $project; } $final_projects = array(); foreach ($projects as $project) { if ($project->isArchived()) { $final_projects[] = $project; } } $this->projects = $final_projects; } elseif ($this->target == 'client') { $this->client = entities\Client::getB2DBTable()->selectById($this->id); $projects = entities\Project::getAllByClientID($this->client->getID()); $final_projects = array(); foreach ($projects as $project) { if (!$project->isArchived()) { $final_projects[] = $project; } } $this->projects = $final_projects; } elseif ($this->target == 'project') { $this->parent = entities\Project::getB2DBTable()->selectById($this->id); $this->projects = $this->parent->getChildren(true); } $this->project_count = count($this->projects); }
/** * Save incoming email account * * @Route(url="/mailing/:project_key/incoming_account/*", name="save_incoming_account") * @param \thebuggenie\core\framework\Request $request * @return type */ public function runSaveIncomingAccount(framework\Request $request) { $project = null; if ($project_key = $request['project_key']) { try { $project = \thebuggenie\core\entities\Project::getByKey($project_key); } catch (\Exception $e) { } } if ($project instanceof \thebuggenie\core\entities\Project) { try { $account_id = $request['account_id']; $account = $account_id ? new \thebuggenie\modules\mailing\entities\IncomingEmailAccount($account_id) : new \thebuggenie\modules\mailing\entities\IncomingEmailAccount(); $account->setIssuetype((int) $request['issuetype']); $account->setProject($project); $account->setPort((int) $request['port']); $account->setName($request['name']); $account->setFoldername($request['folder']); $account->setKeepEmails($request['keepemail']); $account->setServer($request['servername']); $account->setUsername($request['username']); $account->setPassword($request['password']); $account->setSSL((bool) $request['ssl']); $account->setIgnoreCertificateValidation((bool) $request['ignore_certificate_validation']); $account->setUsePlaintextAuthentication((bool) $request['plaintext_authentication']); $account->setServerType((int) $request['account_type']); $account->save(); if (!$account_id) { return $this->renderComponent('mailing/incomingemailaccount', array('project' => $project, 'account' => $account)); } else { return $this->renderJSON(array('name' => $account->getName())); } } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $this->getI18n()->__('This is not a valid mailing account'))); } } else { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $this->getI18n()->__('This is not a valid project'))); } }
/** * The currently selected project in actions where there is one * * @access protected * @property entities\Project $selected_project */ public function preExecute(framework\Request $request, $action) { try { // Default to JSON if nothing is specified. $newFormat = $request->getParameter('format', 'json'); $this->getResponse()->setTemplate(mb_strtolower($action) . '.' . $newFormat . '.php'); $this->getResponse()->setupResponseContentType($newFormat); if ($project_key = $request['project_key']) { $this->selected_project = entities\Project::getByKey($project_key); } elseif ($project_id = (int) $request['project_id']) { $this->selected_project = entities\Project::getB2DBTable()->selectByID($project_id); } if ($this->selected_project instanceof entities\Project) { framework\Context::setCurrentProject($this->selected_project); } $this->render_detail = !isset($request['nodetail']); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(500); return $this->renderJSON(array('error' => 'An exception occurred: ' . $e)); } }
public static function populateBreadcrumbs() { $childbreadcrumbs = array(); if (self::$_selected_project instanceof Project) { $t = self::$_selected_project; $hierarchy_breadcrumbs = array(); $projects_processed = array(); while ($t instanceof Project) { if (array_key_exists($t->getKey(), $projects_processed)) { // We have a cyclic dependency! Oh no! // If this happens, throw an exception throw new \Exception(self::geti18n()->__('A loop has been found in the project heirarchy. Go to project configuration, and alter the subproject setting for this project so that this project is not a subproject of one which is a subproject of this one.')); } $projects_processed[$t->getKey()] = $t; $itemsubmenulinks = self::getResponse()->getPredefinedBreadcrumbLinks('project_summary', $t); if ($t->hasChildren()) { $itemsubmenulinks[] = array('separator' => true); foreach ($t->getChildren() as $child) { if (!$child->hasAccess()) { continue; } $itemsubmenulinks[] = array('url' => self::getRouting()->generate('project_dashboard', array('project_key' => $child->getKey())), 'title' => $child->getName()); } } $hierarchy_breadcrumbs[] = array($t, $itemsubmenulinks); if ($t->hasParent()) { $parent = $t->getParent(); $t = $t->getParent(); } else { $t = null; } } if (self::$_selected_project->hasClient()) { self::setCurrentClient(self::$_selected_project->getClient()); } if (mb_strtolower(Settings::getSiteHeaderName()) != mb_strtolower(self::$_selected_project->getName()) || self::isClientContext()) { self::getResponse()->addBreadcrumb(Settings::getSiteHeaderName(), self::getRouting()->generate('home'), self::getResponse()->getPredefinedBreadcrumbLinks('main_links', self::$_selected_project)); if (self::isClientContext()) { self::getResponse()->addBreadcrumb(self::getCurrentClient()->getName(), self::getRouting()->generate('client_dashboard', array('client_id' => self::getCurrentClient()->getID())), self::getResponse()->getPredefinedBreadcrumbLinks('client_list')); } } // Add root breadcrumb first, so reverse order $hierarchy_breadcrumbs = array_reverse($hierarchy_breadcrumbs); foreach ($hierarchy_breadcrumbs as $breadcrumb) { $class = null; if ($breadcrumb[0]->getKey() == self::getCurrentProject()->getKey()) { $class = 'selected_project'; } self::getResponse()->addBreadcrumb($breadcrumb[0]->getName(), self::getRouting()->generate('project_dashboard', array('project_key' => $breadcrumb[0]->getKey())), $breadcrumb[1], $class); } } else { self::getResponse()->addBreadcrumb(Settings::getSiteHeaderName(), self::getRouting()->generate('home'), self::getResponse()->getPredefinedBreadcrumbLinks('main_links')); } }
/** * * @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; } } } }
/** * Specify whether or not this item is locked / locked to category based on project new issues lock type * * @param Project $project */ public function setLockedFromProject(Project $project) { switch ($project->getIssuesLockType()) { case Project::ISSUES_LOCK_TYPE_PUBLIC_CATEGORY: $this->setLocked(false); $this->setLockedCategory(true); break; case Project::ISSUES_LOCK_TYPE_PUBLIC: $this->setLocked(false); $this->setLockedCategory(false); break; case Project::ISSUES_LOCK_TYPE_RESTRICTED: $this->setLocked(true); $this->setLockedCategory(false); break; } }
"> <input type="search" name="articlename" placeholder="<?php echo $quicksearch_title; ?> "> </form> </div> <?php if (count(\thebuggenie\core\entities\Project::getAll()) > (int) \thebuggenie\core\framework\Context::isProjectContext()) { ?> <div class="header"><?php echo __('Project wikis'); ?> </div> <?php foreach (\thebuggenie\core\entities\Project::getAll() as $project) { ?> <?php if (!$project->hasAccess() || isset($project_url) && $project->getID() == \thebuggenie\core\framework\Context::getCurrentProject()->getID()) { continue; } ?> <?php if (!$project->hasWikiURL()) { ?> <?php echo link_tag(make_url('publish_article', array('article_name' => ucfirst($project->getKey()) . ':MainPage')), $project->getName()); ?> <?php } else { ?>
public function getIncomingEmailAccountsForProject(Project $project) { return IncomingEmailAccount::getAllByProjectID($project->getID()); }
/** * Return if the user can assign scrum user stories * * @param \thebuggenie\core\entities\Project $project * * @return boolean */ public function canAssignScrumUserStories(\thebuggenie\core\entities\Project $project) { if ($project->isArchived()) { return false; } if ($this->canSaveConfiguration(framework\Settings::CONFIGURATION_SECTION_PROJECTS)) { return true; } if ($project->getOwner() instanceof User && $project->getOwner()->getID() == $this->getID()) { return true; } $retval = $this->hasPermission('canassignscrumuserstoriestosprints', $project->getID()); $retval = $retval !== null ? $retval : $this->hasPermission('candoscrumplanning', $project->getID()); $retval = $retval !== null ? $retval : $this->hasPermission('canassignscrumuserstoriestosprints', 0); $retval = $retval !== null ? $retval : $this->hasPermission('candoscrumplanning', 0); return (bool) ($retval !== null) ? $retval : false; }
public function hasProjectsAvailable() { return $this->getMaxProjects() ? Project::getProjectsCount() < $this->getMaxProjects() : true; }
/** * Return the associated project if any * * @return Project */ public function getProject() { return $this->getItemdata() ? \thebuggenie\core\entities\Project::getB2DBTable()->selectById((int) $this->getItemdata()) : null; }
public function runDeleteClient(framework\Request $request) { try { try { $client = entities\Client::getB2DBTable()->selectById($request['client_id']); } catch (\Exception $e) { } if (!$client instanceof entities\Client) { throw new \Exception($this->getI18n()->__("You cannot delete this client")); } if (entities\Project::getAllByClientID($client->getID()) !== null) { foreach (entities\Project::getAllByClientID($client->getID()) as $project) { $project->setClient(null); $project->save(); } } $client->delete(); return $this->renderJSON(array('success' => true, 'message' => $this->getI18n()->__('The client was deleted'))); } catch (\Exception $e) { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => $e->getMessage())); } }
public function componentFilter() { $pkey = framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getID() : null; $i18n = framework\Context::getI18n(); $this->selected_operator = isset($this->selected_operator) ? $this->selected_operator : '='; $this->key = isset($this->key) ? $this->key : null; $this->filter = isset($this->filter) ? $this->filter : null; if (in_array($this->filter, array('posted', 'last_updated'))) { $this->selected_value = $this->selected_value ? $this->selected_value : NOW; } else { $this->selected_value = isset($this->selected_value) ? $this->selected_value : 0; } $this->filter_info = isset($this->filter_info) ? $this->filter_info : null; $filters = array(); $filters['status'] = array('description' => $i18n->__('Status'), 'options' => entities\Status::getAll()); $filters['category'] = array('description' => $i18n->__('Category'), 'options' => entities\Category::getAll()); $filters['priority'] = array('description' => $i18n->__('Priority'), 'options' => entities\Priority::getAll()); $filters['severity'] = array('description' => $i18n->__('Severity'), 'options' => entities\Severity::getAll()); $filters['reproducability'] = array('description' => $i18n->__('Reproducability'), 'options' => entities\Reproducability::getAll()); $filters['resolution'] = array('description' => $i18n->__('Resolution'), 'options' => entities\Resolution::getAll()); $filters['issuetype'] = array('description' => $i18n->__('Issue type'), 'options' => entities\Issuetype::getAll()); $filters['component'] = array('description' => $i18n->__('Component'), 'options' => array()); $filters['build'] = array('description' => $i18n->__('Build'), 'options' => array()); $filters['edition'] = array('description' => $i18n->__('Edition'), 'options' => array()); $filters['milestone'] = array('description' => $i18n->__('Milestone'), 'options' => array()); if (framework\Context::isProjectContext()) { $filters['subprojects'] = array('description' => $i18n->__('Include subproject(s)'), 'options' => array('all' => $this->getI18n()->__('All subprojects'), 'none' => $this->getI18n()->__("Don't include subprojects (default, unless specified otherwise)"))); $projects = entities\Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject()); foreach ($projects as $project) { if ($project->getID() == framework\Context::getCurrentProject()->getID()) { continue; } $filters['subprojects']['options'][$project->getID()] = "{$project->getName()} ({$project->getKey()})"; } } else { $projects = array(); foreach (entities\Project::getAllRootProjects() as $project) { entities\Project::getSubprojectsArray($project, $projects); } } if (count($projects) > 0) { foreach ($projects as $project) { foreach ($project->getComponents() as $component) { $filters['component']['options'][] = $component; } foreach ($project->getBuilds() as $build) { $filters['build']['options'][] = $build; } foreach ($project->getEditions() as $edition) { $filters['edition']['options'][] = $edition; } foreach ($project->getMilestones() as $milestone) { $filters['milestone']['options'][] = $milestone; } } } $filters['posted_by'] = array('description' => $i18n->__('Posted by')); $filters['assignee_user'] = array('description' => $i18n->__('Assigned to user')); $filters['assignee_team'] = array('description' => $i18n->__('Assigned to team')); $filters['owner_user'] = array('description' => $i18n->__('Owned by user')); $filters['owner_team'] = array('description' => $i18n->__('Owned by team')); $filters['posted'] = array('description' => $i18n->__('Date reported')); $filters['last_updated'] = array('description' => $i18n->__('Date last updated')); $this->filters = $filters; }
public function componentProjectInfo() { $this->valid_subproject_targets = entities\Project::getValidSubprojects($this->project); }
echo __('Yes, behave as tracker for a single project'); ?> </option> <option value=0<?php if (!\thebuggenie\core\framework\Settings::isSingleProjectTracker()) { ?> selected<?php } ?> ><?php echo __('No, use regular index page'); ?> </option> </select> <?php echo config_explanation(__('In single project tracker mode, The Bug Genie will display the homepage for the first project as the main page instead of the regular index page') . "<br>" . (count(\thebuggenie\core\entities\Project::getAll()) > 1 ? '<br><b class="more_than_one_project_warning">' . __('More than one project exists. When in "single project" mode, accessing other projects than the first will become harder.') . '</b>' : '')); ?> </td> </tr> <tr> <td><label for="showprojectsoverview"><?php echo __('Show project list on frontpage'); ?> </label></td> <td> <select name="<?php echo \thebuggenie\core\framework\Settings::SETTING_SHOW_PROJECTS_OVERVIEW; ?> " id="showprojectsoverview" style="width: 300px;"<?php if ($access_level != \thebuggenie\core\framework\Settings::ACCESS_FULL) { ?>
/** * Partial backdrop loader * * @Route(name="get_partial_for_backdrop", url="/get/partials/:key/*") * @AnonymousRoute * * @param framework\Request $request * * @return bool */ public function runGetBackdropPartial(framework\Request $request) { if (!$request->isAjaxCall()) { return $this->return404($this->getI18n()->__('You need to enable javascript for The Bug Genie to work properly')); } try { $template_name = null; if ($request->hasParameter('issue_id')) { $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']); $options = array('issue' => $issue); } else { $options = array(); } switch ($request['key']) { case 'usercard': $template_name = 'main/usercard'; if ($user_id = $request['user_id']) { $user = entities\User::getB2DBTable()->selectById($user_id); $options['user'] = $user; } break; case 'login': $template_name = 'main/loginpopup'; $options = $request->getParameters(); $options['content'] = $this->getComponentHTML('login', array('section' => $request->getParameter('section', 'login'))); $options['mandatory'] = false; break; case 'uploader': $template_name = 'main/uploader'; $options = $request->getParameters(); $options['uploader'] = $request['uploader'] == 'dynamic' ? 'dynamic' : 'standard'; break; case 'attachlink': $template_name = 'main/attachlink'; break; case 'openid': $template_name = 'main/openid'; break; case 'notifications': $template_name = 'main/notifications'; $options['first_notification_id'] = $request['first_notification_id']; $options['last_notification_id'] = $request['last_notification_id']; break; case 'workflow_transition': $transition = entities\WorkflowTransition::getB2DBTable()->selectById($request['transition_id']); $template_name = $transition->getTemplate(); $options['transition'] = $transition; if ($request->hasParameter('issue_ids')) { $options['issues'] = array(); foreach ($request['issue_ids'] as $issue_id) { $options['issues'][$issue_id] = new entities\Issue($issue_id); } } else { $options['issue'] = new entities\Issue($request['issue_id']); } $options['show'] = true; $options['interactive'] = true; $options['project'] = $this->selected_project; break; case 'reportissue': $this->_loadSelectedProjectAndIssueTypeFromRequestForReportIssueAction($request); if ($this->selected_project instanceof entities\Project && !$this->selected_project->isLocked() && $this->getUser()->canReportIssues($this->selected_project)) { $template_name = 'main/reportissuecontainer'; $options['selected_project'] = $this->selected_project; $options['selected_issuetype'] = $this->selected_issuetype; $options['locked_issuetype'] = $this->locked_issuetype; $options['selected_milestone'] = $this->_getMilestoneFromRequest($request); $options['parent_issue'] = $this->_getParentIssueFromRequest($request); $options['board'] = $this->_getBoardFromRequest($request); $options['selected_build'] = $this->_getBuildFromRequest($request); $options['issuetypes'] = $this->issuetypes; $options['errors'] = array(); } else { throw new \Exception($this->getI18n()->__('You are not allowed to do this')); } break; case 'move_issue': $template_name = 'main/moveissue'; $options['multi'] = (bool) $request->getParameter('multi', false); break; case 'issue_permissions': $template_name = 'main/issuepermissions'; break; case 'issue_subscribers': $template_name = 'main/issuesubscribers'; break; case 'issue_spenttimes': $template_name = 'main/issuespenttimes'; $options['initial_view'] = $request->getParameter('initial_view', 'list'); break; case 'issue_spenttime': $template_name = 'main/issuespenttime'; $options['entry_id'] = $request->getParameter('entry_id'); break; case 'relate_issue': $template_name = 'main/relateissue'; break; case 'project_build': $template_name = 'project/build'; $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']); if ($request->hasParameter('build_id')) { $options['build'] = entities\Build::getB2DBTable()->selectById($request['build_id']); } break; case 'project_icons': $template_name = 'project/projecticons'; $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']); break; case 'project_workflow': $template_name = 'project/projectworkflow'; $options['project'] = entities\Project::getB2DBTable()->selectById($request['project_id']); break; case 'permissions': $options['key'] = $request['permission_key']; $target_module = $request['target_module'] !== 'core' ? $request['target_module'] : null; if ($details = framework\Context::getPermissionDetails($options['key'], null, $target_module)) { $template_name = 'configuration/permissionspopup'; $options['mode'] = $request['mode']; $options['module'] = $request['target_module']; $options['target_id'] = $request['target_id']; $options['item_name'] = $details['description']; $options['access_level'] = $request['access_level']; } break; case 'issuefield_permissions': $options['item_key'] = $request['item_key']; if ($details = framework\Context::getPermissionDetails($options['item_key'])) { $template_name = 'configuration/issuefieldpermissions'; $options['item_name'] = $details['description']; $options['item_id'] = $request['item_id']; $options['access_level'] = $request['access_level']; } break; case 'site_icons': $template_name = 'configuration/siteicons'; break; case 'project_config': $template_name = 'project/projectconfig_container'; $project = entities\Project::getB2DBTable()->selectById($request['project_id']); $options['project'] = $project; $options['section'] = $request->getParameter('section', 'info'); if ($request->hasParameter('edition_id')) { $edition = entities\Edition::getB2DBTable()->selectById($request['edition_id']); $options['edition'] = $edition; $options['selected_section'] = $request->getParameter('section', 'general'); } break; case 'issue_add_item': $issue = entities\Issue::getB2DBTable()->selectById($request['issue_id']); $template_name = 'main/issueadditem'; break; case 'client_users': $options['client'] = entities\Client::getB2DBTable()->selectById($request['client_id']); $template_name = 'main/clientusers'; break; case 'dashboard_config': $template_name = 'main/dashboardconfig'; $options['tid'] = $request['tid']; $options['target_type'] = $request['target_type']; $options['previous_route'] = $request['previous_route']; $options['mandatory'] = true; break; case 'archived_projects': $template_name = 'main/archivedprojects'; $options['mandatory'] = true; break; case 'team_archived_projects': $template_name = 'main/archivedprojects'; $options['target'] = 'team'; $options['id'] = $request['tid']; $options['mandatory'] = true; break; case 'client_archived_projects': $template_name = 'main/archivedprojects'; $options['target'] = 'client'; $options['id'] = $request['cid']; $options['mandatory'] = true; break; case 'project_archived_projects': $template_name = 'main/archivedprojects'; $options['target'] = 'project'; $options['id'] = $request['pid']; $options['mandatory'] = true; break; case 'bulk_workflow': $template_name = 'search/bulkworkflow'; $options['issue_ids'] = $request['issue_ids']; break; case 'confirm_username': $template_name = 'main/confirmusername'; $options['username'] = $request['username']; break; case 'add_dashboard_view': $template_name = 'main/adddashboardview'; break; case 'userscopes': if (!framework\Context::getScope()->isDefault()) { throw new \Exception($this->getI18n()->__('This is not allowed outside the default scope')); } $template_name = 'configuration/userscopes'; $options['user'] = new entities\User((int) $request['user_id']); break; case 'milestone': $template_name = 'project/milestone'; $options['project'] = \thebuggenie\core\entities\tables\Projects::getTable()->selectById($request['project_id']); if ($request->hasParameter('milestone_id')) { $options['milestone'] = \thebuggenie\core\entities\tables\Milestones::getTable()->selectById($request['milestone_id']); } break; default: $event = new \thebuggenie\core\framework\Event('core', 'get_backdrop_partial', $request['key']); $event->triggerUntilProcessed(); $options = $event->getReturnList(); $template_name = $event->getReturnValue(); } if ($template_name !== null) { return $this->renderJSON(array('content' => $this->getComponentHTML($template_name, $options))); } } catch (\Exception $e) { $this->getResponse()->cleanBuffer(); $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('error' => framework\Context::getI18n()->__('An error occured: %error_message', array('%error_message' => $e->getMessage())))); } $this->getResponse()->cleanBuffer(); $this->getResponse()->setHttpStatus(400); $error = framework\Context::isDebugMode() ? framework\Context::getI18n()->__('Invalid template or parameter') : $this->getI18n()->__('Could not show the requested popup'); return $this->renderJSON(array('error' => $error)); }
/** * Move issues from one step to another for a given issue type and conversions * @param \thebuggenie\core\entities\Project $project * @param \thebuggenie\core\entities\Issuetype $type * @param array $conversions * * $conversions should be an array containing arrays: * array ( * array(oldstep, newstep) * ... * ) */ public function convertIssueStepByIssuetype(\thebuggenie\core\entities\Project $project, \thebuggenie\core\entities\Issuetype $type, array $conversions) { foreach ($conversions as $conversion) { $crit = $this->getCriteria(); $crit->addWhere(self::PROJECT_ID, $project->getID()); $crit->addWhere(self::ISSUE_TYPE, $type->getID()); $crit->addWhere(self::WORKFLOW_STEP_ID, $conversion[0]); $crit->addUpdate(self::WORKFLOW_STEP_ID, $conversion[1]); $this->doUpdate($crit); } }
public static function getSubprojectsArray(Project $project, &$projects) { $projects[$project->getID()] = $project; foreach ($project->getChildProjects() as $subproject) { self::getSubprojectsArray($subproject, $projects); } }
public function runProjectWorkflowTable(framework\Request $request) { $this->selected_project = entities\Project::getB2DBTable()->selectById($request['project_id']); if ($request->isPost()) { try { $workflow_scheme = entities\WorkflowScheme::getB2DBTable()->selectById($request['new_workflow']); return $this->renderJSON(array('content' => $this->getComponentHTML('projectworkflow_table', array('project' => $this->selected_project, 'new_workflow' => $workflow_scheme)))); } catch (\Exception $e) { $this->getResponse()->setHTTPStatus(400); return $this->renderJSON(array('error' => framework\Context::geti18n()->__('This workflow scheme is not valid'))); } } }
/** * Check whether the user can access the specified project page * * @param string $page The page key * @param Project $project * * @return boolean */ public function hasProjectPageAccess($page, Project $project) { $retval = $this->hasPageAccess($page, $project->getID()); $retval = $retval === null ? $this->hasPageAccess('project_allpages', $project->getID()) : $retval; if ($retval === null) { if ($project->getOwner() instanceof User && $project->getOwner()->getID() == $this->getID()) { return true; } if ($project->getLeader() instanceof User && $project->getLeader()->getID() == $this->getID()) { return true; } } return $retval !== null ? $retval : framework\Settings::isPermissive(); }
/** * Get all the projects a team is associated with * * @return array */ public function getAssociatedProjects() { if ($this->_associated_projects === null) { $this->_associated_projects = array(); $project_ids = tables\ProjectAssignedTeams::getTable()->getProjectsByTeamID($this->getID()); foreach ($project_ids as $project_id) { $this->_associated_projects[$project_id] = \thebuggenie\core\entities\Project::getB2DBTable()->selectById($project_id); } } return $this->_associated_projects; }
protected function _getAllInNamespace($namespace, \thebuggenie\core\entities\Project $project = null) { $crit = $this->getCriteria(); if ($project instanceof \thebuggenie\core\entities\Project) { $crit->addWhere(self::NAME, "{$namespace}:" . ucfirst($project->getKey()) . ":%", Criteria::DB_LIKE); } else { $crit->addWhere(self::NAME, "{$namespace}:%", Criteria::DB_LIKE); foreach (\thebuggenie\core\entities\tables\Projects::getTable()->getAllIncludingDeleted() as $project) { if (trim($project->getKey()) == '') { continue; } $crit->addWhere(self::NAME, "{$namespace}:" . ucfirst($project->getKey()) . "%", Criteria::DB_NOT_LIKE); $crit->addWhere(self::NAME, ucfirst($project->getKey()) . ":%", Criteria::DB_NOT_LIKE); } } $crit->addWhere(self::SCOPE, framework\Context::getScope()->getID()); return $this->select($crit); }
public function runFilterGetDynamicChoices(framework\Request $request) { $subproject_ids = explode(',', $request['subprojects']); $existing_ids = $request['existing_ids']; $results = array(); $projects = $request['project_id'] != '' ? entities\Project::getAllByIDs(explode(',', $request['project_id'])) : entities\Project::getAll(); $items = array('build' => array(), 'edition' => array(), 'component' => array(), 'milestone' => array()); foreach ($projects as $project) { foreach ($project->getBuilds() as $build) { $items['build'][$build->getID()] = $build; } foreach ($project->getEditions() as $edition) { $items['edition'][$edition->getID()] = $edition; } foreach ($project->getComponents() as $component) { $items['component'][$component->getID()] = $component; } foreach ($project->getMilestones() as $milestone) { $items['milestone'][$milestone->getID()] = $milestone; } } $filters = array(); $filters['build'] = entities\SearchFilter::createFilter('build'); $filters['edition'] = entities\SearchFilter::createFilter('edition'); $filters['component'] = entities\SearchFilter::createFilter('component'); $filters['milestone'] = entities\SearchFilter::createFilter('milestone'); if (isset($existing_ids['build'])) { foreach (tables\Builds::getTable()->getByIDs($existing_ids['build']) as $build) { $items['build'][$build->getID()] = $build; } $filters['build']->setValue(join(',', $existing_ids['build'])); } if (isset($existing_ids['edition'])) { foreach (tables\Editions::getTable()->getByIDs($existing_ids['edition']) as $edition) { $items['edition'][$edition->getID()] = $edition; } $filters['edition']->setValue(join(',', $existing_ids['edition'])); } if (isset($existing_ids['component'])) { foreach (tables\Components::getTable()->getByIDs($existing_ids['component']) as $component) { $items['component'][$component->getID()] = $component; } $filters['component']->setValue(join(',', $existing_ids['component'])); } if (isset($existing_ids['milestone'])) { foreach (tables\Milestones::getTable()->getByIDs($existing_ids['milestone']) as $milestone) { $items['milestone'][$milestone->getID()] = $milestone; } $filters['milestone']->setValue(join(',', $existing_ids['milestone'])); } foreach (array('build', 'edition', 'component', 'milestone') as $k) { $results[$k] = $this->getComponentHTML('search/interactivefilterdynamicchoicelist', array('filter' => $filters[$k], 'items' => $items[$k])); } return $this->renderJSON(compact('results')); }
public function getProject() { $namespaces = $this->getNamespaces(); if (count($namespaces) > 0) { $key = $namespaces[0]; $project = Project::getByKey($key); return $project; } }
public function runAddCommitGitorious(framework\Request $request) { framework\Context::getResponse()->setContentType('text/plain'); framework\Context::getResponse()->renderHeaders(); $passkey = framework\Context::getRequest()->getParameter('passkey'); $project_id = framework\Context::getRequest()->getParameter('project_id'); $project = Project::getB2DBTable()->selectByID($project_id); // Validate access if (!$project) { echo 'Error: The project with the ID ' . $project_id . ' does not exist'; exit; } if (framework\Settings::get('access_method_' . $project->getID(), 'vcs_integration') == Vcs_integration::ACCESS_DIRECT) { echo 'Error: This project uses the CLI access method, and so access via HTTP has been disabled'; exit; } if (framework\Settings::get('access_passkey_' . $project->getID(), 'vcs_integration') != $passkey) { echo 'Error: The passkey specified does not match the passkey specified for this project'; exit; } // Validate data $data = html_entity_decode(framework\Context::getRequest()->getParameter('payload', null, false)); if (empty($data) || $data == null) { die('Error: No payload was provided'); } $entries = json_decode($data); if ($entries == null) { die('Error: The payload could not be decoded'); } $entries = json_decode($data); $previous = $entries->before; // Branch is stored in the ref $ref = $entries->ref; $parts = explode('/', $ref); if (count($parts) == 3) { $branch = $parts[2]; } else { $branch = null; } // Parse each commit individually foreach (array_reverse($entries->commits) as $commit) { $email = $commit->author->email; $author = $commit->author->name; $new_rev = $commit->id; $old_rev = $previous; $commit_msg = $commit->message; $time = strtotime($commit->timestamp); // Add commit echo Vcs_integration::processCommit($project, $commit_msg, $old_rev, $previous, $time, "", $author, $branch); $previous = $new_rev; exit; } }
public function getReplacedTargetID(\thebuggenie\core\entities\Project $project) { return str_replace('%project_key%', $project->getKey(), $this->_target_id); }
public function getAvailableValues() { switch ($this->getFilterKey()) { case 'issuetype': return framework\Context::isProjectContext() ? framework\Context::getCurrentProject()->getIssuetypeScheme()->getIssuetypes() : Issuetype::getAll(); case 'status': return Status::getAll(); case 'category': return Category::getAll(); case 'priority': return Priority::getAll(); case 'severity': return Severity::getAll(); case 'reproducability': return Reproducability::getAll(); case 'resolution': return Resolution::getAll(); case 'project_id': return \thebuggenie\core\entities\Project::getAll(); case 'build': return $this->_getAvailableBuildChoices(); case 'component': return $this->_getAvailableComponentChoices(); case 'edition': return $this->_getAvailableEditionChoices(); case 'milestone': return $this->_getAvailableMilestoneChoices(); case 'subprojects': $filters = array(); $projects = Project::getIncludingAllSubprojectsAsArray(framework\Context::getCurrentProject()); foreach ($projects as $project) { if ($project->getID() == framework\Context::getCurrentProject()->getID()) { continue; } $filters[$project->getID()] = $project; } return $filters; case 'owner_user': case 'assignee_user': case 'posted_by': return $this->_getAvailableUserChoices(); case 'owner_team': case 'assignee_team': return $this->_getAvailableTeamChoices(); default: $customdatatype = CustomDatatype::getByKey($this->getFilterKey()); if ($customdatatype instanceof \thebuggenie\core\entities\CustomDatatype && $customdatatype->hasCustomOptions()) { return $customdatatype->getOptions(); } else { switch ($this->getFilterType()) { case CustomDatatype::COMPONENTS_CHOICE: return $this->_getAvailableComponentChoices(); case CustomDatatype::RELEASES_CHOICE: return $this->_getAvailableBuildChoices(); case CustomDatatype::EDITIONS_CHOICE: return $this->_getAvailableEditionChoices(); case CustomDatatype::MILESTONE_CHOICE: return $this->_getAvailableMilestoneChoices(); case CustomDatatype::USER_CHOICE: return $this->_getAvailableUserChoices(); case CustomDatatype::TEAM_CHOICE: return $this->_getAvailableTeamChoices(); case CustomDatatype::CLIENT_CHOICE: return $this->_getAvailableClientChoices(); case CustomDatatype::STATUS_CHOICE: return Status::getAll(); default: return array(); } } } }