/** * Draws a form to move a site * @param \NGI $oldNgi NGI to which the site to be moved belongs * @return null */ function drawMoveSite(\NGI $oldNgi) { //Check the user has permission to see the page, will throw exception //if correct permissions are lacking checkUserIsAdmin(); //Get a list of sites and list of NGIs to select from $ngis = \Factory::getNgiService()->getNGIs(); $sites = $oldNgi->getSites(); //Put into an array to be passed to view $params = array('Ngis' => $ngis, 'sites' => $sites, 'OldNgi' => $oldNgi->getName()); show_view("admin/move_site.php", $params); }
/** * Creates an entry in the NGI archieve table, to enable auditing of * deletion. This code is designed to be run from within the try/catch * block within the single transaction of the delete NGI function. * Authorisation must have already been performed and the values come from * an existing object and so are assumed valid. May not work if unregistered * users are ever allowed to delete things. * @param \NGI $ngi * @param \User $user */ public function addNGIToArchive(\NGI $ngi, \User $user) { $archievedNgi = new \ArchivedNGI(); $archievedNgi->setDeletedBy($user->getCertificateDn()); $archievedNgi->setName($ngi->getName()); $archievedNgi->setOriginalCreationDate($ngi->getCreationDate()); $archievedNgi->setScopes($ngi->getScopeNamesAsString()); $projectNamesAsArray = array(); foreach ($ngi->getProjects() as $p) { $projectNamesAsArray[] = $p->getName(); } $projectNamesAsString = implode(", ", $projectNamesAsArray); $archievedNgi->setParentProjects($projectNamesAsString); $this->em->persist($archievedNgi); }
public static function createSampleNGI($label) { $doctrineNgi = new NGI(); $doctrineNgi->setName($label); $doctrineNgi->setDescription($label . 'description'); $doctrineNgi->setEmail($label . 'email'); $doctrineNgi->setRodEmail($label . 'rodEmail'); $doctrineNgi->setHelpdeskEmail($label . 'helpdeskEmail'); $doctrineNgi->setSecurityEmail($label . 'securityEmail'); return $doctrineNgi; }
public function addNgi(\NGI $ngi) { $this->ngis[] = $ngi; $ngi->addProject($this); }
public function moveSite(\Site $Site, \NGI $NGI, \User $user = null) { //Check the portal is not in read only mode, throws exception if it is $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user); //Throws exception if user is not an administrator $this->checkUserIsAdmin($user); $this->em->getConnection()->beginTransaction(); // suspend auto-commit try { //If the NGI or site have no ID - throw logic exception $site_id = $Site->getId(); if (empty($site_id)) { throw new LogicException('Site has no ID'); } $ngi_id = $NGI->getId(); if (empty($ngi_id)) { throw new LogicException('NGI has no ID'); } //find old NGI $old_NGI = $Site->getNgi(); //If the NGI has changed, then we move the site. if ($old_NGI != $NGI) { //Remove the site from the old NGI FIRST if it has an old NGI if (!empty($old_NGI)) { $old_NGI->getSites()->removeElement($Site); } //Add site to new NGI $NGI->addSiteDoJoin($Site); //$Site->setNgiDoJoin($NGI); //persist $this->em->merge($NGI); $this->em->merge($old_NGI); } //close if $this->em->flush(); $this->em->getConnection()->commit(); } catch (\Exception $e) { $this->em->getConnection()->rollback(); $this->em->close(); throw $e; } }
require_once __DIR__ . "/../bootstrap.php"; require_once __DIR__ . "/AddUtils.php"; /** * AddNGIs.php: Loads a list of NGIs from an XML file and inserts them into * the doctrine prototype. * XML format is the output from get_roc_list PI query. */ $ngisFileName = __DIR__ . "/" . $GLOBALS['dataDir'] . "/NGIs.xml"; $ngis = simplexml_load_file($ngisFileName); // Find the EGI project object $egiProject = $entityManager->getRepository('Project')->findOneBy(array("name" => "EGI")); //Find the EGI scope tag $egiScope = $entityManager->getRepository('Scope')->findOneBy(array("name" => "EGI")); foreach ($ngis as $xmlNgi) { $doctrineNgi = new NGI(); $name = ""; $email = ""; $rodEmail = ""; $helpdeskEmail = ""; $securityEmail = ""; $creationDate = new \DateTime("now"); foreach ($xmlNgi as $key => $value) { if ((string) $key == "NAME") { $name = (string) $value; } if ((string) $key == "EMAIL") { $email = (string) $value; } if ((string) $key == "DESCRIPTION") { $description = (string) $value;