Exemplo n.º 1
0
/**
 * Checks witht the config service if the portal is in read only mode and if 
 * it is throws an exception
 * @throws \Exception
 */
function checkPortalIsNotReadOnly()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    if (\Factory::getConfigService()->IsPortalReadOnly()) {
        throw new \Exception("The portal is currently in read only mode, changes can not be made.");
    }
}
Exemplo n.º 2
0
function Get_Standard_Top_Section_HTML($title = null)
{
    require_once __DIR__ . "/../../static_php/standard_header.php";
    $HTML = "";
    $HTML .= get_standard_header($title);
    // container for the page
    $HTML .= "<div class=\"page_container\">";
    // menu bar
    $HTML .= "<div class=\"left_box_menu\"\">";
    $HTML .= Get_File_Contents(__DIR__ . "/../../static_html/goc5_logo.html");
    //Insert a portal is in read only warning message, if it is
    if (\Factory::getConfigService()->IsPortalReadOnly()) {
        $HTML .= Get_File_Contents(__DIR__ . "/../../static_html/read_only_warning.html");
    }
    require_once "menu.php";
    $HTML .= draw_menu("main_menu");
    $HTML .= "</div>";
    //$HTML .= "<h3 class=\"spacer\">Test</h3>";
    $HTML .= Get_Search_Box_HTML();
    $HTML .= Get_User_Info_Box_HTML();
    $HTML .= Get_bottom_logos_Box_HTML();
    // right side of the page
    $HTML .= "<div class=\"right_box\">";
    // logout button (if set - does not always need to be rendered)
    if (!empty(\Factory::$properties['LOGOUTURL'])) {
        $HTML .= "<div style='text-align: right;'>";
        //$HTML .= '<a href="'.htmlspecialchars(\Factory::$properties['LOGOUTURL']).'"><b><font colour="red">Logout</font></b></a>';
        $HTML .= '<a href="' . htmlspecialchars(\Factory::$properties['LOGOUTURL']) . '"><b><font class="btn btn-danger btn-xs">Logout</font></b></a>';
        $HTML .= "</div>";
    }
    return $HTML;
}
Exemplo n.º 3
0
/**
 * Draws the add NGI form
 * @return null
 */
function draw()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    //Check the user has permission to see the page, will throw exception
    //if correct permissions are lacking
    checkUserIsAdmin();
    //Get the list of scopes to chose from and the minimum number that need to be selected
    $params['Scopes'] = \Factory::getScopeService()->getDefaultScopesSelectedArray();
    $params['NumberOfScopesRequired'] = \Factory::getConfigService()->getMinimumScopesRequired('ngi');
    //show the add NGI view
    show_view("admin/add_ngi.php", $params, "Add NGI");
}
Exemplo n.º 4
0
function view_user()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../../components/Get_User_Principle.php';
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        throw new Exception("An id must be specified");
    }
    $userId = $_GET['id'];
    $user = \Factory::getUserService()->getUser($userId);
    if ($user === null) {
        throw new Exception("No user with that ID");
    }
    $params['user'] = $user;
    // get the targetUser's roles
    $roles = \Factory::getRoleService()->getUserRoles($user, \RoleStatus::GRANTED);
    //$user->getRoles();
    $callingUser = \Factory::getUserService()->getUserByPrinciple(Get_User_Principle());
    // can the calling user revoke the targetUser's roles?
    if ($user != $callingUser) {
        foreach ($roles as $r) {
            //$ownedEntityDetail = $r->getOwnedEntity()->getName(). ' ('. $r->getOwnedEntity()->getType().')';
            $authorisingRoleNames = \Factory::getRoleService()->authorizeAction(\Action::REVOKE_ROLE, $r->getOwnedEntity(), $callingUser);
            if (count($authorisingRoleNames) >= 1) {
                $allAuthorisingRoleNames = '';
                foreach ($authorisingRoleNames as $arName) {
                    $allAuthorisingRoleNames .= $arName . ', ';
                }
                $allAuthorisingRoleNames = substr($allAuthorisingRoleNames, 0, strlen($allAuthorisingRoleNames) - 2);
                $r->setDecoratorObject('[' . $allAuthorisingRoleNames . '] ');
            }
        }
    } else {
        // current user is viewing their own roles, so they can revoke their own roles
        foreach ($roles as $r) {
            $r->setDecoratorObject('[Self revoke own role]');
        }
    }
    // Check to see if the current calling user has permission to edit the target user
    try {
        \Factory::getUserService()->editUserAuthorization($user, $callingUser);
        $params['ShowEdit'] = true;
    } catch (Exception $e) {
        $params['ShowEdit'] = false;
    }
    /* @var $authToken \org\gocdb\security\authentication\IAuthentication */
    $authToken = Get_User_AuthToken();
    $params['authAttributes'] = $authToken->getDetails();
    $params['roles'] = $roles;
    $params['portalIsReadOnly'] = \Factory::getConfigService()->IsPortalReadOnly();
    $title = $user->getFullName();
    show_view("user/view_user.php", $params, $title);
}
Exemplo n.º 5
0
 function process()
 {
     header('Content-Type: application/xml');
     //Type is GET request for XML info
     $this->parseGET();
     $xml = $this->getXml();
     // returns the portal URL as defined in conf file
     $portal_url = \Factory::getConfigService()->GetPortalURL();
     //$portal_url = "https://URL/";
     $xml = str_replace("#GOCDB_BASE_PORTAL_URL#", $portal_url, $xml);
     echo $xml;
     //echo('<test>val</test>');
 }
Exemplo n.º 6
0
function startPage()
{
    require_once __DIR__ . '/../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../components/Get_User_Principle.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $roles = \Factory::getRoleService()->getPendingRolesUserCanApprove($user);
    $configServ = \Factory::getConfigService();
    $showMap = $configServ->getShowMapOnStartPage();
    $apiKey = $configServ->getGoogleAPIKey();
    $params = array('roles' => $roles, 'googleAPIKey' => $apiKey, 'showMap' => $showMap);
    $title = "GOCDB";
    show_view('start_page.php', $params, $title, null);
}
/**
 * Controller for a new_service request
 * @global array $_POST only set if the browser has POSTed data
 * @return null
 */
function add_new_se_to_service_group()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    // Check to see whether to show the link to "add a new SE to this virtual site"
    if (!Factory::getConfigService()->IsOptionalFeatureSet("siteless_services")) {
        throw new Exception("This feature isn't enabled on this GOCDB " . "instance. Configuration keyword: siteless_services");
    }
    if ($_POST) {
        // If we receive a POST request it's to add a new SE
        submit_form();
    } else {
        // If there is no post data, draw the New SE form
        draw_form();
    }
}
Exemplo n.º 8
0
/**
 * Draws the edit ngi form using the object ID passed in $_REQUEST
 * @param \User $user current user
 * @return null
 */
function draw(\User $user = null)
{
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    $serv = \Factory::getNgiService();
    $ngi = $serv->getNgi($_REQUEST['id']);
    // Old way: //$serv->edit Authorization($ngi, $user);
    if (count($serv->authorizeAction(Action::EDIT_OBJECT, $ngi, $user)) == 0) {
        throw new Exception('You do not have permission to edit this NGI');
    }
    $params = array('ngi' => $ngi);
    $params['scopes'] = \Factory::getScopeService()->getScopesSelectedArray($ngi->getScopes());
    $params['numberOfScopesRequired'] = \Factory::getConfigService()->getMinimumScopesRequired('ngi');
    show_view('ngi/edit_ngi.php', $params);
}
Exemplo n.º 9
0
/**
 * Checks config service and returns true if the portal is in read only mode (and
 * the user is not a GOCDB admin.) Used to hide features of the portal used for
 * editing entities when in read only mode.
 *
 * @param \user $user
 *            current user
 * @return boolean
 */
function portalIsReadOnlyAndUserIsNotAdmin(\user $user = null)
{
    require_once __DIR__ . '/../../../lib/Gocdb_Services/Factory.php';
    // this block is required to deal with unregistered users (where $user is null)
    $userIsAdmin = false;
    if (!is_null($user)) {
        if ($user->isAdmin()) {
            // sub query required becauser ->isAdmin can't be called on null
            $userIsAdmin = true;
        }
    }
    if (\Factory::getConfigService()->IsPortalReadOnly() and !$userIsAdmin) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 10
0
function draw($user)
{
    try {
        //\Factory::getServiceGroupService()->addAuthorization($user);
        if (is_null($user)) {
            throw new \Exception("Unregistered users can't create service groups.");
        }
        // If the user is registered they're allowed to add a service group
        $configService = \Factory::getConfigService();
        $scopes = \Factory::getScopeService()->getDefaultScopesSelectedArray();
        $numberScopesRequired = $configService->getMinimumScopesRequired('service_group');
        $params = array('scopes' => $scopes, 'numberOfScopesRequired' => $numberScopesRequired);
        show_view("service_group/add_service_group.php", $params);
    } catch (Exception $e) {
        show_view("error.php", $e->getMessage());
        die;
    }
}
Exemplo n.º 11
0
function add_menu_item($menu_item)
{
    //Get user in order to correctly display GOCDB admin menu Items
    include_once __DIR__ . '/../Get_User_Principle.php';
    $dn = Get_User_Principle();
    $userserv = \Factory::getUserService();
    $user = $userserv->getUserByPrinciple($dn);
    if ($user == null) {
        $userisadmin = false;
    } else {
        $userisadmin = $user->isAdmin();
    }
    //Find out if the portal is currently read only from local_info.xml
    $portalIsReadOnly = \Factory::getConfigService()->IsPortalReadOnly();
    foreach ($menu_item->children() as $key => $value) {
        $html = "";
        switch ($key) {
            case "show_on_instance":
                $show = strtolower($value);
                break;
            case "name":
                $name = $value;
                break;
            case "link":
                $link = $value;
                break;
            case "spacer":
                // John C: modified this so that we could use show_on_instance for spacers
                foreach ($menu_item as $child_name => $child_value) {
                    if ($child_name == "show_on_instance") {
                        // If the spacer has a show_on_instance type that we want to show, then show it
                        if ($child_value == "all" or $child_value == "write_enabled" and (!$portalIsReadOnly or $userisadmin) or $child_value == "admin" and $userisadmin) {
                            return "</ul><h4 class='menu_title'>{$value}</h4><ul class=\"Smaller_Left_Padding Smaller_Top_Margin\">";
                        }
                    }
                }
                return;
        }
    }
    if ($show == "all" or $show == "write_enabled" and (!$portalIsReadOnly or $userisadmin) or $show == "admin" and $userisadmin) {
        $html .= "<li class=\"Menu_Item\">" . "<a href=\"" . $link . "\"><span class=\"menu_link\">" . $name . "</span></a></li>";
    }
    return $html;
}
Exemplo n.º 12
0
/**
 * Draws the edit site form using the object ID passed in $_REQUEST
 * @param \User $user current user
 * @throws Exception
 * @return null
 */
function draw(\User $user = null)
{
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        throw new Exception("An id must be specified");
    }
    $serv = \Factory::getSiteService();
    $site = $serv->getSite($_GET['id']);
    /*Old way: try { \Factory::getSiteService()->edit Authorization($site, $user);
      } catch(Exception $e) { show_view('error.php', $e->getMessage()); die(); }*/
    if (count($serv->authorizeAction(Action::EDIT_OBJECT, $site, $user)) == 0) {
        throw new Exception('You do not have permission to edit this Site');
    }
    //else { print_r($serv->authorizeAction(Action::EDIT_OBJECT, $site, $user));}
    $countries = $serv->getCountries();
    //$timezones = $serv->getTimezones(); // Deprecated - don't use the lookup values in the GocDB
    $timezones = DateTimeZone::listIdentifiers();
    // get the standard values
    $prodStatuses = $serv->getProdStatuses();
    //Remove SC and PPS infrastructures from drop down list (unless site has one of them). TODO: Delete this block once they no longer exist
    $SCInfrastructure = $serv->getProdStatusByName('SC');
    $PPSInfrastructure = $serv->getProdStatusByName('PPS');
    $hackprodStatuses = array();
    foreach ($prodStatuses as $ps) {
        if ($ps != $SCInfrastructure and $ps != $PPSInfrastructure or $ps == $site->getInfrastructure()) {
            $hackprodStatuses[] = $ps;
        }
    }
    $prodStatuses = $hackprodStatuses;
    //delete up to here once pps and sc infrastructures have been removed from database
    $scopes = \Factory::getScopeService()->getScopesSelectedArray($site->getScopes());
    //get parent scope ids to generate warning message in view
    $parentScopeIds = array();
    foreach ($site->getNgi()->getScopes() as $scope) {
        $parentScopeIds[] = $scope->getId();
    }
    $configServ = \Factory::getConfigService();
    $numberScopesRequired = $configServ->getMinimumScopesRequired('site');
    $params = array("site" => $site, "timezones" => $timezones, "countries" => $countries, "prodStatuses" => $prodStatuses, "scopes" => $scopes, "numberOfScopesRequired" => $numberScopesRequired, "parentScopeIds" => $parentScopeIds);
    show_view('site/edit_site.php', $params);
}
Exemplo n.º 13
0
/**
 * Draw the edit site form. 
 * @param \User $user
 * @throws \Exception
 */
function draw(\User $user = null)
{
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    $id = $_REQUEST['id'];
    $serv = \Factory::getServiceService();
    $se = $serv->getService($id);
    if (count(Factory::getServiceService()->authorizeAction(\Action::EDIT_OBJECT, $se, $user)) == 0) {
        throw new \Exception("You do not have permission over {$se}.");
    }
    $configservice = \Factory::getConfigService();
    //get parent scope ids to generate warning message in view
    $params["parentScopeIds"] = array();
    foreach ($se->getParentSite()->getScopes() as $scope) {
        $params["parentScopeIds"][] = $scope->getId();
    }
    $params['se'] = $se;
    $params['serviceTypes'] = $serv->getServiceTypes();
    $params['scopes'] = \Factory::getScopeService()->getScopesSelectedArray($se->getScopes());
    $params['numberOfScopesRequired'] = $configservice->getMinimumScopesRequired('service');
    show_view('service/edit_service.php', $params);
}
Exemplo n.º 14
0
/**
 * Draws a form for the user to add services to a service group
 * @global array $_REQUEST only set if the browser has sent parameters
 * @param \User $user current user
 * @return null
 */
function draw(\User $user = null)
{
    $serv = \Factory::getServiceGroupService();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    // The service group to add SEs to
    $sg = $serv->getServiceGroup($_REQUEST['id']);
    // Check the user is authorized to perform this operation
    //try { $serv->editAuthorization($sg, $user); } catch(Exception $e) {
    //    show_view('error.php', $e->getMessage()); die(); }
    if (count($serv->authorizeAction(\Action::EDIT_OBJECT, $sg, $user)) == 0) {
        show_view('error.php', 'You do not have permission to edit this ServiceGroup');
        die;
    }
    // Check to see whether to show the link to "add a new SE to this virtual site"
    if (\Factory::getConfigService()->IsOptionalFeatureSet("siteless_services")) {
        $siteLessServices = true;
    } else {
        $siteLessServices = false;
    }
    $params = array('sg' => $sg, 'siteLessServices' => $siteLessServices);
    show_view('service_group/add_ses.php', $params);
}
Exemplo n.º 15
0
/**
 * Processes a role request submission
 * @param type $roleName
 * @param type $entityId
 * @param \User $user current user
 * @throws Exception
 */
function submitRoleRequest($roleName, $entityId, \User $user = null)
{
    // validate the enityId is numeric
    if (!is_numeric($entityId)) {
        throw new Exception('Invalid entityId');
    }
    // Get the owned entity instance
    $entity = \Factory::getOwnedEntityService()->getOwnedEntityById($entityId);
    // Create a new Role linking user, entity and roletype. The addRole
    // perfoms role validation and throws exceptios accordingly.
    $newRole = \Factory::getRoleService()->addRole($roleName, $user, $entity);
    if (\Factory::getConfigService()->getSendEmails()) {
        \Factory::getNotificationService()->roleRequest($entity);
    }
    show_view('political_role/new_request.php');
}
Exemplo n.º 16
0
 /**
  * Gets the name of the default scope from the config service 
  * and returns it as a string value. 
  * @return $scopes
  */
 private function defaultScope()
 {
     $configService = \Factory::getConfigService();
     $scopes = $configService->getDefaultScopeName();
     if ($scopes == null || trim($scopes) == "") {
         return null;
     } else {
         return $scopes;
     }
 }
Exemplo n.º 17
0
 /**
  * Check that the amount of queries the user has entered is not greater
  * than the limit set in local_info.xml
  * @param Array $parsedQueries
  * @return boolean
  */
 private function checkLimit($parsedQueries)
 {
     $configService = \Factory::getConfigService();
     $limit = $configService->getExtensionsLimit();
     if (count($parsedQueries) < $limit) {
         return true;
     } else {
         throw new \InvalidArgumentException("You have exceeded the max amount of quieries allowed. Max allowed is: " . $limit);
     }
 }
Exemplo n.º 18
0
/**
 *  Draws a form to add a new site
 * @param \User $user current user 
 * @return null
 */
function draw(\User $user = null)
{
    if (is_null($user)) {
        throw new Exception("Unregistered users can't add a new site");
    }
    $siteService = \Factory::getSiteService();
    //try { $siteService->addAuthorization($user);
    //} catch(Exception $e) { show_view('error.php', $e->getMessage()); die(); }
    if ($user->isAdmin()) {
        // if user is admin, then get all NGIs
        $userNGIs = \Factory::getNgiService()->getNGIs();
    } else {
        // otherwise, get only the NGIs the non-admin user has roles over that support add_site
        $userNGIs = \Factory::getNgiService()->getNGIsBySupportedAction(Action::NGI_ADD_SITE, $user);
        if (count($userNGIs) == 0) {
            show_view('error.php', "You do not have permission to add a new site." . " To add a new site you require a managing role over an NGI");
            die;
        }
    }
    $countries = $siteService->getCountries();
    //$timezones = $siteService->getTimezones(); // Deprecated - don't use the lookup values in the GocDB
    $timezones = DateTimeZone::listIdentifiers();
    $prodStatuses = $siteService->getProdStatuses();
    //Remove SC and PPS infrastructures from drop down list. TODO: Delete this block once they no longer exist
    $SCInfrastructure = $siteService->getProdStatusByName('SC');
    $PPSInfrastructure = $siteService->getProdStatusByName('PPS');
    $hackprodStatuses = array();
    foreach ($prodStatuses as $ps) {
        if ($ps != $SCInfrastructure and $ps != $PPSInfrastructure) {
            $hackprodStatuses[] = $ps;
        }
    }
    $prodStatuses = $hackprodStatuses;
    //delete up to here once pps and sc infrastructures have been removed from database
    $certStatuses = $siteService->getCertStatuses();
    $scopes = \Factory::getScopeService()->getDefaultScopesSelectedArray();
    $numberOfScopesRequired = \Factory::getConfigService()->getMinimumScopesRequired('site');
    //$dDashNgis = \Factory::getUserService()->getDDashNgis($user);
    $params = array('ngis' => $userNGIs, 'countries' => $countries, 'timezones' => $timezones, 'prodStatuses' => $prodStatuses, 'certStatuses' => $certStatuses, 'scopes' => $scopes, 'numberOfScopesRequired' => $numberOfScopesRequired);
    //Check that there is at least one NGI available before allowing an add site.
    if ($params['ngis'] == null) {
        show_view('error.php', "GocDB requires one or more NGI's to be able to add a site.");
    }
    show_view("site/add_site.php", $params);
    die;
}
Exemplo n.º 19
0
 public function getGoogleMapXMLString()
 {
     $sites = $this->getSitesWithGeoInfo();
     $portalUrl = \Factory::getConfigService()->GetPortalURL();
     $xml = new \SimpleXMLElement("<map></map>");
     foreach ($sites as $site) {
         $xmlSite = $xml->addChild('Site');
         $xmlSite->addAttribute('ShortName', $site->getShortName());
         $xmlSite->addAttribute('OfficialName', $site->getOfficialName());
         $sitePortalUrl = $portalUrl . '/index.php?Page_Type=Site&id=' . $site->getId();
         $xmlSite->addAttribute('PortalURL', htmlspecialchars($sitePortalUrl));
         $xmlSite->addAttribute('Description', htmlspecialchars($site->getDescription()));
         $xmlSite->addAttribute('Latitude', $site->getLatitude());
         $xmlSite->addAttribute('Longitude', $site->getLongitude());
     }
     $dom_sxe = dom_import_simplexml($xml);
     $dom = new \DOMDocument('1.0');
     $dom->encoding = 'UTF-8';
     $dom_sxe = $dom->importNode($dom_sxe, true);
     $dom_sxe = $dom->appendChild($dom_sxe);
     $dom->formatOutput = true;
     $xmlString = $dom->saveXML();
     return $xmlString;
 }
Exemplo n.º 20
0
/**
 *  Draw the add service form
 * @param \User $user current user 
 * @return null
 */
function draw($user)
{
    if (is_null($user)) {
        throw new Exception("Unregistered users can't add a service .");
    }
    /* Optional site parameter is set if a user clicked
     * "add SE to this site" on the view site page */
    $site = null;
    if (isset($_REQUEST['siteId'])) {
        $site = \Factory::getSiteService()->getSite($_REQUEST['siteId']);
        if ($site == null) {
            throw new Exception('Invalid site');
        }
        if (count(\Factory::getSiteService()->authorizeAction(\Action::SITE_ADD_SERVICE, $site, $user)) == 0) {
            throw new Exception('You do not have permission to add a service to this site');
        }
    }
    // Add sites which user has required action permission to array.
    $allUserSites = \Factory::getUserService()->getSitesFromRoles($user);
    $sites = array();
    foreach ($allUserSites as $s) {
        if (count(\Factory::getSiteService()->authorizeAction(\Action::SITE_ADD_SERVICE, $s, $user)) != 0) {
            $sites[] = $s;
        }
    }
    //For admin users, return all sites instead.
    if ($user->isAdmin()) {
        $sites = \Factory::getSiteService()->getSitesBy();
    }
    if (count($sites) == 0 and !$user->isAdmin()) {
        throw new Exception("You need at least one NGI or Site level role to add a new service.");
    }
    $serviceTypes = \Factory::getServiceService()->getServiceTypes();
    //If a site has been specified get scopes wit that sites scopes selected, otherwise get the default
    if (!is_null($serviceTypes) && $site instanceof \Site) {
        $scopes = \Factory::getScopeService()->getScopesSelectedArray($site->getScopes());
    } else {
        $scopes = \Factory::getScopeService()->getDefaultScopesSelectedArray();
    }
    //get the number of scopes that we require
    $numberScopesRequired = \Factory::getConfigService()->getMinimumScopesRequired('service');
    // remove the deprecated CE type (temp hack)
    foreach ($serviceTypes as $key => $st) {
        if ($st->getName() == "CE") {
            unset($serviceTypes[$key]);
        }
    }
    $params = array('sites' => $sites, 'serviceTypes' => $serviceTypes, 'scopes' => $scopes, 'site' => $site, 'numberOfScopesRequired' => $numberScopesRequired);
    //Check that there is at least one Site available before allowing a user to add a service.
    if ($params['sites'] == null) {
        show_view('error.php', "GocDB requires one or more Sites to be able to add a service.");
    }
    show_view("service/add_service.php", $params);
}
Exemplo n.º 21
0
 /**
  * sends a confimation email to the user
  * 
  * @param \User $user user who's dn is being changed
  * @param type $confirmationCode genersted confirmation code 
  * @param type $newDn new dn for $user
  * @throws \Exception
  */
 private function sendConfirmationEmail(\User $user, $confirmationCode, $newDn)
 {
     $portal_url = \Factory::getConfigService()->GetPortalURL();
     //echo $portal_url;
     //die();
     $link = $portal_url . "/index.php?Page_Type=User_Validate_DN_Change&c=" . $confirmationCode;
     $subject = "Validation of changes on your GOCDB account";
     $body = "Dear GOCDB User,\n\n" . "A request to retrieve and associate your GOCDB account and privileges with a " . "new account ID has just been made on GOCDB (e.g. you have a new certificate with a different DN)." . "\n\nThe new account ID is: {$newDn}" . "\n\nIf you wish to associate your GOCDB account with this account ID, please validate your request by clicking on the link below:\n" . "{$link}" . "\n\nIf you did not create this request in GOCDB, please immediately contact gocdb-admins@mailman.egi.eu";
     //If "sendmail_from" is set in php.ini, use second line ($headers = '';):
     $headers = "From: no-reply@goc.egi.eu";
     //$headers = "";
     //mail command returns boolean. False if message not accepted for delivery.
     if (!mail($user->getEmail(), $subject, $body, $headers)) {
         throw new \Exception("Unable to send email message");
     }
     //echo $body;
 }
Exemplo n.º 22
0
/**
 * Draws the edit service group form
 * @param \User $user Current User
 * @return null
 */
function draw(\User $user = null)
{
    $serv = \Factory::getServiceGroupService();
    if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
        throw new Exception("An id must be specified");
    }
    // Get the service group
    $sg = $serv->getServiceGroup($_REQUEST['id']);
    //try { $serv->editAuthorization($sg, $user); } catch(Exception $e) {
    //	show_view('error.php', $e->getMessage()); die(); }
    if (count($serv->authorizeAction(\Action::EDIT_OBJECT, $sg, $user)) == 0) {
        show_view('error.php', 'You do not have permission to edit this ServiceGroup');
        die;
    }
    // If the user is registered they're allowed to add a service group
    $configService = \Factory::getConfigService();
    $scopes = \Factory::getScopeService()->getScopesSelectedArray($sg->getScopes());
    $numberScopesRequired = $configService->getMinimumScopesRequired('service_group');
    $params = array('serviceGroup' => $sg, 'scopes' => $scopes, 'numberOfScopesRequired' => $numberScopesRequired);
    show_view("service_group/edit_service_group.php", $params, "Edit " . $sg->getName());
}
Exemplo n.º 23
0
<?php

$services = $params['services'];
$configService = \Factory::getConfigService();
?>
<!-- Dynamically create a select list from a sites services -->
<label> Select Affected Services+Endpoints (Ctrl+click to select)</label> 
<select name="IMPACTED_IDS[]" id="Select_Services" size="10" class="form-control" onclick="" style="width:99%; margin-left:1%" onChange="selectServicesEndpoint()" multiple>
<?php 
foreach ($services as $service) {
    $count = 0;
    echo "<option value=\"s" . $service->getId() . "\" id=\"" . $service->getId() . "\" SELECTED>" . '(' . xssafe($service->getServiceType()->getName()) . ') ' . xssafe($service->getHostName()) . "</option>";
    foreach ($service->getEndpointLocations() as $endpoint) {
        if ($endpoint->getName() == '') {
            $name = xssafe('myEndpoint');
        } else {
            $name = xssafe($endpoint->getName());
        }
        //Option styling doesn't work well cross browser so just use 4 spaces to indent the branch
        echo "<option id=\"" . $service->getId() . "\" value=\"e" . $endpoint->getId() . "\" SELECTED>&nbsp&nbsp&nbsp&nbsp-" . $name . "</option>";
        $count++;
    }
}
?>
	
</select>