/** * Homepage of the testset index view. Display environments and images grouped by testsets. * * @param sfWebRequest $request */ public function executeProjectTestset(sfWebRequest $request) { // Set referer $this->getUser()->setReferer($request->getUri()); // Get project group id from project group name defined in app.yml $this->projectGroupId = Doctrine_Core::getTable("sfGuardGroup")->getProjectGroupId(sfConfig::get('app_project_group')); if ($this->projectGroupId == null) { throw new ErrorException("Unable to retrieve project group configuration! Application might need additional configuration or data!", 500); } // Get security level of current user $userSecurityLevel = $this->getUser()->isAuthenticated() ? $userSecurityLevel = $this->getUser()->getGuardUser()->getProfile()->getSecurityLevel() : 0; // Get list of all projects (Android, Tizen, Yocto, Linux, ...) $this->projects = Doctrine_Core::getTable("Project")->getBasicProjects($this->projectGroupId, $userSecurityLevel); // Set current project from URL parameters if ($request->getParameter("project")) { $this->currentProject = Doctrine_Core::getTable("Project")->getBasicProjectBySlug($request->getParameter("project")); $this->forward404Unless($this->currentProject != null, "This project does not exist anymore or you lack sufficient privileges!"); $this->forward404Unless(in_array($this->currentProject, $this->projects), "This project is not accessible anymore or you lack sufficient privileges!"); } else { $this->currentProject = $this->projects[0]; } // Check if at least one project has been found and user is not authenticated if (!$this->getUser()->isAuthenticated() && $this->currentProject == null) { $this->getUser()->setFlash("error", "Your security level is not sufficient to visualize projects. Please login with appropriate credentials!"); $this->redirect("sf_guard_signin"); } // Set current filter $this->currentFilter = $request->getParameter("filter", "recent"); $filter = $this->currentFilter == "all" ? false : true; // Get list of all products (Smartphone, Tablet, Netbook, Laptop, ...) $this->products = Doctrine_Core::getTable("Project")->getBasicProducts($this->projectGroupId, $this->currentProject["id"]); // Get list of all test environments and images with build ids $this->imagesForEnvironments = Doctrine_Core::getTable("Project")->getImagesForEnvironmentsForTestsets($this->projectGroupId, $this->currentProject["id"], MiscUtils::arrayColumn($this->products, 'id', true), $filter); // ...convert data retrieved from database if (count($this->imagesForEnvironments) > 0) { $arrayProducts = array(); $previousProduct = null; $previousTestset = null; $previousEnvironment = null; $previousImage = null; foreach ($this->imagesForEnvironments as $data) { if ($data["product_id"] != $previousProduct) { $arrayProducts[$data["product_id"]] = array("product_id" => $data["product_id"], "testsets" => array()); $previousProduct = $data["product_id"]; $previousTestset = null; $previousEnvironment = null; $previousImage = null; } if ($data["ts_testset"] != $previousTestset) { $arrayProducts[$data["product_id"]]["testsets"][$data["ts_testset"]] = array("ts_testset" => $data["ts_testset"], "ts_testset_slug" => $data["ts_testset_slug"], "environments" => array()); $previousTestset = $data["ts_testset"]; $previousEnvironment = null; $previousImage = null; } if ($data["te_name"] != $previousEnvironment) { $arrayProducts[$data["product_id"]]["testsets"][$data["ts_testset"]]["environments"][$data["te_name"]] = array("te_id" => $data["te_id"], "te_name" => $data["te_name"], "te_slug" => $data["te_slug"], "images" => array()); $previousEnvironment = $data["te_name"]; $previousImage = null; } if ($data["i_name"] != $previousImage) { $arrayProducts[$data["product_id"]]["testsets"][$data["ts_testset"]]["environments"][$data["te_name"]]["images"][$data["i_name"]] = array("i_id" => $data["i_id"], "i_name" => $data["i_name"], "i_slug" => $data["i_slug"]); $previousImage = $data["i_name"]; } } $this->imagesForEnvironments = $arrayProducts; } else { $this->imagesForEnvironments = array(); } }