public function componentArchivedProjects()
 {
     if (!isset($this->target)) {
         $this->projects = TBGProject::getAllRootProjects(true);
         $this->project_count = count($this->projects);
     } elseif ($this->target == 'team') {
         $this->team = TBGContext::factory()->TBGTeam($this->id);
         $projects = array();
         foreach (TBGProject::getAllByOwner($this->team) as $project) {
             $projects[$project->getID()] = $project;
         }
         foreach (TBGProject::getAllByLeader($this->team) as $project) {
             $projects[$project->getID()] = $project;
         }
         foreach (TBGProject::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 = TBGContext::factory()->TBGClient($this->id);
         $projects = TBGProject::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 = TBGContext::factory()->TBGProject($this->id);
         $this->projects = $this->parent->getChildren(true);
     }
     $this->project_count = count($this->projects);
 }
Exemple #2
0
 /**
  * Configure projects
  * 
  * @param TBGRequest $request The request object
  */
 public function runConfigureProjects(TBGRequest $request)
 {
     $this->active_projects = TBGProject::getAllRootProjects(false);
     $this->archived_projects = TBGProject::getAllRootProjects(true);
 }
Exemple #3
0
 /**
  * Frontpage
  *  
  * @param TBGRequest $request
  */
 public function runIndex(TBGRequest $request)
 {
     if (TBGSettings::isSingleProjectTracker()) {
         if (($projects = TBGProject::getAllRootProjects(false)) && ($project = array_shift($projects))) {
             $this->forward(TBGContext::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())));
         }
     }
     $this->forward403unless($this->getUser()->hasPageAccess('home'));
     $this->links = TBGContext::getMainLinks();
     $this->show_project_list = TBGSettings::isFrontpageProjectListVisible();
     $this->show_project_config_link = $this->getUser()->canAccessConfigurationPage(TBGSettings::CONFIGURATION_SECTION_PROJECTS);
     if ($this->show_project_list || $this->show_project_config_link) {
         $projects = TBGProject::getAllRootProjects(false);
         foreach ($projects as $k => $project) {
             if (!$project->hasAccess()) {
                 unset($projects[$k]);
             }
         }
         $this->projects = $projects;
         $this->project_count = count($this->projects);
     }
 }
 public static function populateBreadcrumbs()
 {
     $childbreadcrumbs = array();
     if (self::$_selected_project instanceof TBGProject) {
         $t = self::$_selected_project;
         $hierarchy_breadcrumbs = array();
         $projects_processed = array();
         while ($t instanceof TBGProject) {
             if (array_key_exists($t->getKey(), $projects_processed)) {
                 // We have a cyclic dependency! Oh no!
                 // If this happens, throw an exception
                 throw new Exception(TBGContext::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.'));
                 continue;
             } else {
                 $all_projects = array_merge(TBGProject::getAllRootProjects(true), TBGProject::getAllRootProjects(false));
                 // If this is a root project, display a list of other root projects, then t is null
                 if (!$t->hasParent() && count($all_projects) > 1) {
                     $itemsubmenulinks = array();
                     foreach ($all_projects 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);
                     $projects_processed[$t->getKey()] = $t;
                     $t = null;
                     continue;
                 } elseif (!$t->hasParent()) {
                     $hierarchy_breadcrumbs[] = array($t, null);
                     $projects_processed[$t->getKey()] = $t;
                     $t = null;
                     continue;
                 } else {
                     // What we want to do here is to build a list of the children of the parent unless we are the only one
                     $parent = $t->getParent();
                     $children = $parent->getChildren();
                     $itemsubmenulinks = null;
                     if ($parent->hasChildren() && count($children) > 1) {
                         $itemsubmenulinks = array();
                         foreach ($children 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);
                     $projects_processed[$t->getKey()] = $t;
                     $t = $parent;
                     continue;
                 }
             }
         }
         $clientsubmenulinks = null;
         if (self::$_selected_project->hasClient()) {
             $clientsubmenulinks = array();
             foreach (TBGClient::getAll() as $client) {
                 if ($client->hasAccess()) {
                     $clientsubmenulinks[] = array('url' => self::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName());
                 }
             }
             self::setCurrentClient(self::$_selected_project->getClient());
         }
         if (mb_strtolower(TBGSettings::getTBGname()) != mb_strtolower(self::$_selected_project->getName()) || self::isClientContext()) {
             self::getResponse()->addBreadcrumb(TBGSettings::getTBGName(), self::getRouting()->generate('home'));
             if (self::isClientContext()) {
                 self::getResponse()->addBreadcrumb(self::getCurrentClient()->getName(), self::getRouting()->generate('client_dashboard', array('client_id' => self::getCurrentClient()->getID())), $clientsubmenulinks);
             }
         }
         // 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(TBGSettings::getTBGName(), self::getRouting()->generate('home'));
     }
 }
 public function componentFilter()
 {
     $pkey = TBGContext::isProjectContext() ? TBGContext::getCurrentProject()->getID() : null;
     $i18n = TBGContext::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' => TBGStatus::getAll());
     $filters['category'] = array('description' => $i18n->__('Category'), 'options' => TBGCategory::getAll());
     $filters['priority'] = array('description' => $i18n->__('Priority'), 'options' => TBGPriority::getAll());
     $filters['severity'] = array('description' => $i18n->__('Severity'), 'options' => TBGSeverity::getAll());
     $filters['reproducability'] = array('description' => $i18n->__('Reproducability'), 'options' => TBGReproducability::getAll());
     $filters['resolution'] = array('description' => $i18n->__('Resolution'), 'options' => TBGResolution::getAll());
     $filters['issuetype'] = array('description' => $i18n->__('Issue type'), 'options' => TBGIssuetype::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 (TBGContext::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 = TBGProject::getIncludingAllSubprojectsAsArray(TBGContext::getCurrentProject());
         foreach ($projects as $project) {
             if ($project->getID() == TBGContext::getCurrentProject()->getID()) {
                 continue;
             }
             $filters['subprojects']['options'][$project->getID()] = "{$project->getName()} ({$project->getKey()})";
         }
     } else {
         $projects = array();
         foreach (TBGProject::getAllRootProjects() as $project) {
             TBGProject::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;
 }