/** * Method that get a project and returns the result of operation * * @param \Library\HttpRequest $rq * @return JSON */ public function executeGetItem(\Library\HttpRequest $rq, \Applications\PMTool\Models\Dao\Project $project = NULL) { // Init result $result = $this->InitResponseWS(); $project_id = intval($this->dataPost["project_id"]); $project_selected = NULL; if ($project !== NULL) { $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetUserSessionProject($this->app()->user(), $project->project_id()); } else { $project_selected = \Applications\PMTool\Helpers\ProjectHelper::GetAndStoreCurrentProject($this->app()->user(), $project_id); $sessionProject = \Applications\PMTool\Helpers\ProjectHelper::GetUserSessionProject($this->app()->user(), $project_selected->project_id()); } if (!$sessionProject[\Library\Enums\SessionKeys::ClientObject]) { $client = new \Applications\PMTool\Models\Dao\Client(); $client->setProject_id($sessionProject[\Library\Enums\SessionKeys::ProjectObject]->project_id()); $sessionProject[\Library\Enums\SessionKeys::ClientObject] = client; } $result["sessionProject"] = $sessionProject; \Applications\PMTool\Helpers\ProjectHelper::UpdateUserSessionProject($this->app()->user(), $sessionProject); if ($project == NULL) { $this->SendResponseWS($result, array("resx_file" => \Applications\PMTool\Resources\Enums\ResxFileNameKeys::Project, "resx_key" => $this->action(), "step" => $sessionProject != NULL ? "success" : "error")); } else { return $sessionProject; } }
public static function AddSessionProject($user, \Applications\PMTool\Models\Dao\Project $project) { $sessionProjects = $user->getAttribute(\Library\Enums\SessionKeys::UserSessionProjects); $sessionProjects[\Library\Enums\SessionKeys::ProjectKey . $project->project_id()] = self::MakeSessionProject($project); self::SetSessionProjects($user, $sessionProjects); }