当前位置: 首页>>代码示例>>PHP>>正文


PHP Factory::getSiteService方法代码示例

本文整理汇总了PHP中Factory::getSiteService方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getSiteService方法的具体用法?PHP Factory::getSiteService怎么用?PHP Factory::getSiteService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Factory的用法示例。


在下文中一共展示了Factory::getSiteService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submit

/**
 * Processes an edit site request from a web request
 * return null
 * @param \User $user current user
 */
function submit(\User $user = null)
{
    // TODO use validate service
    $reason = $_REQUEST['COMMENT'];
    if (empty($reason)) {
        throw new Exception('A reason is required');
    }
    if (strlen($reason) > 300) {
        throw new Exception('Invalid reason - 300 char max');
    }
    try {
        require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
        try {
            $site = \Factory::getSiteService()->getSite($_REQUEST['SITEID']);
            $certStatus = \Factory::getCertStatusService()->getCertificationStatus($_REQUEST['CERTSTATUSID']);
            \Factory::getCertStatusService()->editCertificationStatus($site, $certStatus, $user, $reason);
        } catch (\Exception $e) {
            show_view('error.php', $e->getMessage());
            die;
        }
        $params = array('site' => $site);
        show_view('site/cert_status_edited.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:32,代码来源:edit_cert_status.php

示例2: show_xml

function show_xml()
{
    try {
        $xml = Factory::getSiteService()->getGoogleMapXMLString();
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage(), "Error");
    }
    $params['XML'] = $xml;
    show_view('sitesForGoogleMapXML.php', $params, null, true);
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:10,代码来源:sitesForGoogleMapXML.php

示例3: site_downtimes

function site_downtimes()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    $serv = \Factory::getSiteService();
    $site = $serv->getSite($_REQUEST['id']);
    $downtimes = $serv->getDowntimes($_REQUEST['id'], null);
    $params['site'] = $site;
    $params['downtimes'] = $downtimes;
    $title = "{$site} downtimes";
    show_view('site/site_downtimes.php', $params, $title);
    return;
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:12,代码来源:site_downtimes.php

示例4: view_ngi

function view_ngi()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
        throw new Exception("An id must be specified");
    }
    $ngiId = $_GET['id'];
    //get user for case that portal is read only and user is admin, so they can still see edit links
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    $params['UserIsAdmin'] = false;
    if (!is_null($user)) {
        $params['UserIsAdmin'] = $user->isAdmin();
    }
    $params['authenticated'] = false;
    if ($user != null) {
        $params['authenticated'] = true;
    }
    $ngiServ = \Factory::getNgiService();
    $siteServ = \Factory::getSiteService();
    $ngi = $ngiServ->getNgi($ngiId);
    // Does current viewer have edit permissions over NGI ?
    $params['ShowEdit'] = false;
    if (count($ngiServ->authorizeAction(\Action::EDIT_OBJECT, $ngi, $user)) >= 1) {
        $params['ShowEdit'] = true;
    }
    // Add ngi to params
    $params['ngi'] = $ngi;
    // Add all roles over ngi to params
    $allRoles = $ngi->getRoles();
    $roles = array();
    foreach ($allRoles as $role) {
        if ($role->getStatus() == \RoleStatus::GRANTED) {
            $roles[] = $role;
        }
    }
    $params['roles'] = $roles;
    // Add ngi's project to params
    $projects = $ngi->getProjects();
    $params['Projects'] = $projects;
    // Add sites and scopes to params
    $params['SitesAndScopes'] = array();
    foreach ($ngi->getSites() as $site) {
        $params['SitesAndScopes'][] = array('Site' => $site, 'Scopes' => $siteServ->getScopesWithParentScopeInfo($site));
    }
    // Add RoleActionRecords to params
    $params['RoleActionRecords'] = \Factory::getRoleService()->getRoleActionRecordsById_Type($ngi->getId(), 'ngi');
    show_view('ngi/view_ngi.php', $params, $ngi->getName());
    die;
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:53,代码来源:view_ngi.php

示例5: draw

/**
 *  Draws a form to add a new site property
 * @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 site property.");
    }
    $serv = \Factory::getSiteService();
    $site = $serv->getSite($_REQUEST['site']);
    //Check user has permissions to add site property
    $serv->validatePropertyActions($user, $site);
    $params = array('site' => $site);
    show_view("site/add_site_property.php", $params);
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:17,代码来源:add_site_property.php

示例6: submit

function submit(\SiteProperty $property, \User $user = null, \Site $site)
{
    $params['prop'] = $property;
    $params['site'] = $site;
    //remove site property
    try {
        $serv = \Factory::getSiteService();
        $serv->deleteSiteProperty($site, $user, $property);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view('/site/deleted_site_property.php', $params);
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:14,代码来源:delete_site_property.php

示例7: submit

function submit(\Site $site, \User $user = null)
{
    //Only administrators can delete sites, double check user is an administrator
    checkUserIsAdmin();
    //save name to display later
    $params['Name'] = $site->getName();
    //remove Site
    try {
        \Factory::getSiteService()->deleteSite($site, $user);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view('/site/deleted_site.php', $params);
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:15,代码来源:delete_site.php

示例8: getSitesServices

function getSitesServices()
{
    require_once __DIR__ . '/../utils.php';
    require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    if (!isset($_REQUEST['site_id']) || !is_numeric($_REQUEST['site_id'])) {
        throw new Exception("A site_id must be specified");
    }
    $site = \Factory::getSiteService()->getSite($_REQUEST['site_id']);
    $services = $site->getServices();
    $params['services'] = $services;
    show_view("downtime/view_services.php", $params, null, true);
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:15,代码来源:view_services.php

示例9: draw

/**
 *  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;
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:51,代码来源:add_site.php

示例10: submit

/**
 * Processes an edit site property request from a web request
 * @param \User $user current user
 * return null
 */
function submit(\User $user = null)
{
    try {
        $newValues = getSpDataFromWeb();
        $siteID = $newValues['SITEPROPERTIES']['SITE'];
        $propID = $newValues['SITEPROPERTIES']['PROP'];
        if ($newValues['SITEPROPERTIES']['NAME'] == null || $newValues['SITEPROPERTIES']['VALUE'] == null) {
            show_view('error.php', "A property name and value must be provided.");
            die;
        }
        $property = \Factory::getSiteService()->getProperty($propID);
        $site = \Factory::getSiteService()->getSite($siteID);
        $site = \Factory::getSiteService()->editSiteProperty($site, $user, $property, $newValues);
        $params['siteid'] = $siteID;
        show_view('site/site_property_updated.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:25,代码来源:edit_site_property.php

示例11: showAllSites

function showAllSites()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    $exServ = \Factory::getExtensionsService();
    // Do we really need to validate the URL parameter values, as the query
    // to the DB always uses bind variables to protect against injection?
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Validate.php';
    $validatorService = new \org\gocdb\services\Validate();
    $ngi = '%%';
    if (!empty($_GET['NGI'])) {
        $ngi = $_GET['NGI'];
        if (!$validatorService->validate('ngi', 'NAME', $ngi)) {
            throw new Exception("Invalid NGI parameter value");
        }
    }
    $prodStatus = '%%';
    if (!empty($_GET['prodStatus'])) {
        $prodStatus = $_GET['prodStatus'];
    }
    //must be done before the if certstatus in the block that sets $certStatus
    $showClosed = false;
    if (isset($_GET['showClosed'])) {
        $showClosed = true;
    }
    $certStatus = '%%';
    if (!empty($_GET['certStatus'])) {
        $certStatus = $_GET['certStatus'];
        //set show closed as true if production status selected is 'closed' - otherwise
        // there will be no results
        if ($certStatus == 'Closed') {
            $showClosed = true;
        }
    }
    // Site extension property key name
    $siteKeyNames = "";
    if (isset($_GET['siteKeyNames'])) {
        $siteKeyNames = $_GET['siteKeyNames'];
    }
    // Site extension property key value
    $siteKeyValues = "";
    if (isset($_GET['selectedSiteKeyValue'])) {
        $siteKeyValues = $_GET['selectedSiteKeyValue'];
    }
    $scope = '%%';
    if (!empty($_GET['scope'])) {
        $scope = $_GET['scope'];
    }
    $serv = \Factory::getSiteService();
    $params['scopes'] = \Factory::getScopeService()->getScopes();
    $params['sites'] = $serv->getSitesBy($ngi, $prodStatus, $certStatus, $scope, $showClosed, null, $siteKeyNames, $siteKeyValues);
    $params['NGIs'] = $serv->getNGIs();
    $params['prodStatuses'] = $serv->getProdStatuses();
    //Remove SC and PPS infrastructures from drop down list. TODO: Delete this block once they no longer exist
    $SCInfrastructure = $serv->getProdStatusByName('SC');
    $PPSInfrastructure = $serv->getProdStatusByName('PPS');
    $productionStatuses = array();
    foreach ($params['prodStatuses'] as $ps) {
        if ($ps != $SCInfrastructure and $ps != $PPSInfrastructure) {
            $productionStatuses[] = $ps;
        }
    }
    $params['prodStatuses'] = $productionStatuses;
    //delete up to here once pps and sc infrastructures have been removed from database
    /* Doctrine will provide keynames that are the same even when selecting distinct becase the object
     * is distinct even though the name is not unique. To avoid showing the same name repeatdly in the filter
     * we will load all the keynames into an array before making it unique
     */
    $keynames = array();
    foreach ($exServ->getSiteExtensionsKeyNames() as $extension) {
        $keynames[] = $extension->getKeyName();
    }
    $keynames = array_unique($keynames);
    $params['selectedNgi'] = $ngi;
    $params['certStatuses'] = $serv->getCertStatuses();
    $params['selectedProdStatus'] = $prodStatus;
    $params['selectedCertStatus'] = $certStatus;
    $params['selectedScope'] = $scope;
    $params['showClosed'] = $showClosed;
    $params['siteKeyNames'] = $keynames;
    $params['selectedSiteKeyNames'] = $siteKeyNames;
    $params['selectedSiteKeyValue'] = $siteKeyValues;
    show_view("site/view_all.php", $params, "Sites");
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:83,代码来源:view_all.php

示例12: drawSEs


//.........这里部分代码省略.........
    }
    if ($searchTerm != "") {
        $thisPage .= '&searchTerm=' . $searchTerm;
    }
    if ($production != "") {
        $thisPage .= '&production=' . $production;
    }
    if ($monitored != "") {
        $thisPage .= '&monitored=' . $monitored;
    }
    if ($scope != "") {
        $thisPage .= '&scope=' . $scope;
    }
    if ($ngi != "") {
        $thisPage .= '&ngi=' . $ngi;
    }
    if ($certStatus != "") {
        $thisPage .= '&certStatus=' . $certStatus;
    }
    if ($showClosed != "") {
        $thisPage .= '&showClosed=' . $showClosed;
    }
    if ($servKeyNames != "") {
        $thisPage .= '&servKeyNames=' . $servKeyNames;
    }
    if ($servKeyValues != "") {
        $thisPage .= '&servKeyValues=' . $servKeyValues;
    }
    if ($searchTerm != null || $searchTerm != "") {
        if (substr($searchTerm, 0, 1) != '%') {
            $searchTerm = '%' . $searchTerm;
        }
        if (substr($searchTerm, -1) != '%') {
            $searchTerm = $searchTerm . '%';
        }
    }
    $numResults = $seServ->getSesCount($searchTerm, $serviceType, $production, $monitored, $scope, $ngi, $certStatus, $showClosed, $servKeyNames, $servKeyValues, null, null, false);
    $firstLink = $thisPage . "&record=1";
    // Set the "previous" link
    if ($startRecord > RECORDS_PER_PAGE) {
        // Not showing the first page of results so enable the previous link
        $previousLink = $thisPage . "&record=" . ($startRecord - RECORDS_PER_PAGE);
    } else {
        // First page of results, disable previous button
        $previousLink = $thisPage . "&record=" . 0;
    }
    // Set the "Next" link
    // not the last page of results, normal next link
    if ($numResults - $startRecord > RECORDS_PER_PAGE) {
        $nextLink = $thisPage . "&record=" . ($startRecord + RECORDS_PER_PAGE);
    } else {
        // last page of results, disable next link
        $nextLink = $thisPage . '&record=' . ($numResults - RECORDS_PER_PAGE + 1);
    }
    $lastLink = $thisPage . "&record=" . ($numResults + 1 - RECORDS_PER_PAGE);
    // $startRecord + RECORDS_PER_PAGE "-1" because record 1 in the web portal == record 0 from DB
    $ses = $seServ->getSes($searchTerm, $serviceType, $production, $monitored, $scope, $ngi, $certStatus, $showClosed, $servKeyNames, $servKeyValues, $startRecord - 1, RECORDS_PER_PAGE, false);
    $endRecord = $startRecord + RECORDS_PER_PAGE - 1;
    /* Due to differences in counting, startRecord is still set to 1
     * even if there are zero results. If this is the case it's
     * zero here to display accurately in the portal.  */
    if (count($ses) == 0) {
        $startRecord = 0;
    }
    /* Doctrine will provide keynames that are the same even when selecting distinct becase the object
     * is distinct even though the name is not unique. To avoid showing the same name repeatdly in the filter
     * we will load all the keynames into an array before making it unique
     */
    $keynames = array();
    foreach ($exServ->getServiceExtensionsKeyNames() as $extension) {
        $keynames[] = $extension->getKeyName();
    }
    $keynames = array_unique($keynames);
    $serv = \Factory::getSiteService();
    $params['scopes'] = \Factory::getScopeService()->getScopes();
    $params['serviceTypes'] = $seServ->getServiceTypes();
    $params['servKeyNames'] = $keynames;
    $params['selectedServiceType'] = $serviceType;
    $params['searchTerm'] = $searchTerm;
    $params['services'] = $ses;
    $params['totalServices'] = $numResults;
    $params['startRecord'] = $startRecord;
    $params['endRecord'] = $endRecord;
    $params['firstLink'] = $firstLink;
    $params['previousLink'] = $previousLink;
    $params['nextLink'] = $nextLink;
    $params['lastLink'] = $lastLink;
    $params['ngis'] = \Factory::getNgiService()->getNGIs();
    $params['certStatuses'] = $serv->getCertStatuses();
    $params['showClosed'] = $showClosed;
    $params['selectedProduction'] = $production;
    $params['selectedMonitored'] = $monitored;
    $params['selectedScope'] = $scope;
    $params['selectedNgi'] = $ngi;
    $params['selectedClosed'] = $showClosed;
    $params['selectedCertStatus'] = $certStatus;
    $params['selectedServKeyNames'] = $servKeyNames;
    $params['selectedServKeyValue'] = $servKeyValues;
    show_view("service/view_all.php", $params, "Services");
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:101,代码来源:view_all.php

示例13: submit

/**
 * Processes an edit site request from a web request
 * @param \User $user current user
 * return null
 */
function submit(\User $user = null)
{
    try {
        $newValues = getSiteDataFromWeb();
        $siteId = \Factory::getSiteService()->getSite($newValues['ID']);
        $site = \Factory::getSiteService()->editSite($siteId, $newValues, $user);
        $params = array('site' => $site);
        show_view('site/site_updated.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:18,代码来源:edit_site.php

示例14: view_requests

function view_requests()
{
    require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
    require_once __DIR__ . '/../../components/Get_User_Principle.php';
    require_once __DIR__ . '/../utils.php';
    $dn = Get_User_Principle();
    $user = \Factory::getUserService()->getUserByPrinciple($dn);
    if ($user == null) {
        throw new Exception("Unregistered users can't view/request roles");
    }
    // Entites is a two-dimensional array that lists both the id and name of
    // OwnedEntities that a user can reqeust a role over (Projects, NGIs, Sites,
    // ServiceGroups). If an inner dimesional array does not contain an Object_ID
    // array key, then it is used as a section title in a pull-down list.
    $entities = array();
    $entities[] = array('Name' => 'Projects');
    $allProjects = \Factory::getProjectService()->getProjects();
    foreach ($allProjects as $proj) {
        $entities[] = array('Object_ID' => $proj->getId(), 'Name' => $proj->getName());
    }
    $entities[] = array('Name' => 'NGIs');
    $allNGIs = \Factory::getNgiService()->getNGIs();
    foreach ($allNGIs as $ngi) {
        $entities[] = array('Object_ID' => $ngi->getId(), 'Name' => $ngi->getName());
    }
    $entities[] = array('Name' => 'Sites');
    $allSites = \Factory::getSiteService()->getSitesBy();
    foreach ($allSites as $site) {
        $entities[] = array('Object_ID' => $site->getId(), 'Name' => $site->getShortName());
    }
    $entities[] = array('Name' => 'ServiceGroups');
    $allSGs = \Factory::getServiceGroupService()->getServiceGroups();
    foreach ($allSGs as $sg) {
        $entities[] = array('Object_ID' => $sg->getId(), 'Name' => $sg->getName());
    }
    // Current user's own pending roles
    $myPendingRoleRequests = \Factory::getRoleService()->getUserRoles($user, \RoleStatus::PENDING);
    // foreach role, lookup corresponding RoleActionRecord (if any) and populate
    // the role.decoratorObject with the roleActionRecord for subsequent display
    //    foreach($myPendingRoleRequests as $role){
    //       $rar = \Factory::getRoleService()->getRoleActionRecordByRoleId($role->getId());
    //       $role->setDecoratorObject($rar);
    //    }
    // Other roles current user can approve
    $otherRolesUserCanApprove = \Factory::getRoleService()->getPendingRolesUserCanApprove($user);
    // can the calling user grant or reject each role?
    foreach ($otherRolesUserCanApprove as $r) {
        $grantRejectRoleNamesArray = array();
        $grantRejectRoleNamesArray['grant'] = '';
        $grantRejectRoleNamesArray['deny'] = '';
        // get list of roles that allows user to to grant the role request
        $grantRoleAuthorisingRoleNames = \Factory::getRoleService()->authorizeAction(\Action::GRANT_ROLE, $r->getOwnedEntity(), $user);
        if (count($grantRoleAuthorisingRoleNames) >= 1) {
            $allAuthorisingRoleNames = '';
            foreach ($grantRoleAuthorisingRoleNames as $arName) {
                $allAuthorisingRoleNames .= $arName . ', ';
            }
            $allAuthorisingRoleNames = substr($allAuthorisingRoleNames, 0, strlen($allAuthorisingRoleNames) - 2);
            $grantRejectRoleNamesArray['grant'] = '[' . $allAuthorisingRoleNames . ']';
        }
        // get list of roles that allows user to reject the role request
        $denyRoleAuthorisingRoleNames = \Factory::getRoleService()->authorizeAction(\Action::REJECT_ROLE, $r->getOwnedEntity(), $user);
        if (count($denyRoleAuthorisingRoleNames) >= 1) {
            $allAuthorisingRoleNames = '';
            foreach ($denyRoleAuthorisingRoleNames as $arName) {
                $allAuthorisingRoleNames .= $arName . ', ';
            }
            $allAuthorisingRoleNames = substr($allAuthorisingRoleNames, 0, strlen($allAuthorisingRoleNames) - 2);
            $grantRejectRoleNamesArray['deny'] = '[' . $allAuthorisingRoleNames . ']';
        }
        // store array of role names in decorator object
        $r->setDecoratorObject($grantRejectRoleNamesArray);
    }
    $params = array();
    $params['entities'] = $entities;
    $params['myRequests'] = $myPendingRoleRequests;
    $params['allRequests'] = $otherRolesUserCanApprove;
    $params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
    show_view("political_role/view_requests.php", $params, "Role Requests");
    die;
}
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:81,代码来源:view_requests.php

示例15: roleRequest

 /**
  * This class will take an entity of either site, service group, NGI or Project.
  * It will then get the roles from the entity
  * and then get the users for each of those roles. Then using the authorizeAction function for the correct entity type it will
  * ascertain if a given user has the permission to grant a role. If they do there email address is added to an array. This array
  * of email addresses will then be sent a notification that they have a pending role request they can approve.
  *
  * If a site or NGI has no users with roles attached to it due to being newly created then this method will get the parent NGI and
  * send an email to those users to approve. It does this by passing the parent entity back into this method recursively.
  *
  *
  * @param Site/ServiceGroup/NGI/Project $entity            
  */
 public function roleRequest($entity)
 {
     $project = null;
     $emails = null;
     $projectIds = null;
     // Get the roles from the entity
     foreach ($entity->getRoles() as $role) {
         $roles[] = $role;
     }
     // Now for each role get the user
     foreach ($roles as $role) {
         // Call the correct authorize action service for the type of entity
         if ($entity instanceof \Site) {
             $enablingRoles = \Factory::getSiteService()->authorizeAction(\Action::GRANT_ROLE, $entity, $role->getUser());
             // If the site has no site adminstrators to approve the role request then send an email to the parent NGI users to approve the request
             if ($roles == null) {
                 $this->roleRequest($entity->getNgi());
                 // Recursivly call this function to send email to the NGI users
             }
         } else {
             if ($entity instanceof \ServiceGroup) {
                 $enablingRoles = \Factory::getServiceGroupService()->authorizeAction(\Action::GRANT_ROLE, $entity, $role->getUser());
             } else {
                 if ($entity instanceof \Project) {
                     $enablingRoles = \Factory::getProjectService()->authorizeAction(\Action::GRANT_ROLE, $entity, $role->getUser());
                 } else {
                     if ($entity instanceof \NGI) {
                         $enablingRoles = \Factory::getNgiService()->authorizeAction(\Action::GRANT_ROLE, $entity, $role->getUser());
                         $projects = $entity->getProjects();
                         // set project with the NGI's parent project and later recurse with this
                         // Only send emails to Project users if there are no users with grant_roles over the NGI
                         if ($roles == null) {
                             // Get the ID's of each project so we can remove duplicates
                             foreach ($projects as $project) {
                                 $projectIds[] = $project->getId();
                             }
                             $projectIds = array_unique($projectIds);
                         }
                     }
                 }
             }
         }
         // remove admin from enabling roles
         $position = array_search('GOCDB_ADMIN', $enablingRoles);
         if ($position != null) {
             unset($enablingRoles[$position]);
         }
         // Get the users email and add it to the array if they have an enabling role
         if (count($enablingRoles) > 0) {
             $emails[] = $role->getUser()->getEmail();
         }
     }
     /*
      * No users are able to grant the role or there are no users over this entity. In this case we will email the parent entity for approval
      */
     if ($emails == null || count($emails) == 0) {
         if ($entity instanceof \Site) {
             $this->roleRequest($entity->getNgi());
             // Recursivly call this function to send email to the NGI users
         } else {
             if ($entity instanceof \NGI) {
                 /*
                  * It is important to remove duplicate projects here otherwise we will spam the same addresses as we recursively call this method.
                  */
                 $projects = $entity->getProjects();
                 // set project with the NGI's parent project and later recurse with this
                 $projectIds = array();
                 // Get the ID's of each project so we can remove duplicates
                 foreach ($projects as $project) {
                     $projectIds[] = $project->getId();
                 }
                 $projectIds = array_unique($projectIds);
             }
         }
     } else {
         // If the entity has valid users who can approve the role then send the email notification.
         // Remove duplicate emails from array
         $emails = array_unique($emails);
         // Get the PortalURL to create an accurate link to the role approval view
         $localInfoLocation = __DIR__ . "/../../config/local_info.xml";
         $localInfoXML = simplexml_load_file($localInfoLocation);
         $webPortalURL = $localInfoXML->local_info->web_portal_url;
         // Email content
         $headers = "From: no-reply@goc.egi.eu";
         $subject = "GocDB: A Role request requires attention";
         $body = "Dear GOCDB User,\n\n" . "A user has requested a role that requires attention.\n\n" . "You can approve or deny this request here:\n\n" . $webPortalURL . "/index.php?Page_Type=Role_Requests\n\n" . "Note: This role may already have been approved or denied by another GocDB User";
         $sendMail = TRUE;
//.........这里部分代码省略.........
开发者ID:Tom-Byrne,项目名称:gocdb,代码行数:101,代码来源:NotificationService.php


注:本文中的Factory::getSiteService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。