/** * Retrieves the new project's data from a portal request and submit it to the * services layer's project functions. * @return null */ function submit() { require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php'; //Get the posted NGI data $newValues = getProjectDataFromWeb(); //get the user data for the add NGI function (so it can check permissions) $dn = Get_User_Principle(); $user = \Factory::getUserService()->getUserByPrinciple($dn); try { //function will through error if user does not have the correct permissions $project = \Factory::getProjectService()->addProject($newValues, $user); $params = array('Name' => $project->getName(), 'ID' => $project->getId()); show_view("admin/added_project.php", $params); } catch (Exception $e) { show_view('error.php', $e->getMessage()); die; } }
/** * Retrieves the project edit from a portal request and submit it to the * services layer's vsite functions. * @param \User $user Current user * @return null */ function submit(\User $user = null) { require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php'; //get the post data $newValues = getProjectDataFromWeb(); //get the project service and the project being edited $serv = \Factory::getProjectService(); $unalteredProject = $serv->getProject($newValues['ID']); try { //function will throw error if user does not have the correct permissions $alteredProject = $serv->editProject($unalteredProject, $newValues, $user); $params = array('Name' => $alteredProject->getName(), 'Description' => $alteredProject->getDescription(), 'ID' => $alteredProject->getId()); show_view("project/edited_project.php", $params); } catch (Exception $e) { show_view('error.php', $e->getMessage()); die; } }