本文整理汇总了PHP中Factory::getServiceService方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getServiceService方法的具体用法?PHP Factory::getServiceService怎么用?PHP Factory::getServiceService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::getServiceService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view_se
function view_se()
{
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");
}
$id = $_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);
$serv = \Factory::getServiceService();
$params['authenticated'] = false;
if ($user != null) {
$params['authenticated'] = true;
}
$params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
$se = $serv->getService($id);
// Does current viewer have edit permissions over object ?
$params['ShowEdit'] = false;
if ($user != null && count($serv->authorizeAction(\Action::EDIT_OBJECT, $se, $user)) >= 1) {
$params['ShowEdit'] = true;
}
$title = $se->getHostName() . " - " . $se->getServiceType()->getName();
$params['se'] = $se;
$params['sGroups'] = $se->getServiceGroups();
$params['Scopes'] = $serv->getScopesWithParentScopeInfo($se);
// Show upcoming downtimes and downtimes that started within the last thirty days
$downtimes = $serv->getDowntimes($id, 31);
$params['Downtimes'] = $downtimes;
show_view("service/view_service.php", $params, $title);
}
示例2: search_ses
function search_ses()
{
if (!isset($_REQUEST['term'])) {
return "";
} else {
$searchTerm = strip_tags(trim($_REQUEST['term']));
}
if (1 === preg_match("/[';\"]/", $searchTerm)) {
throw new Exception("Invalid char in search term");
}
if (substr($searchTerm, 0, 1) != '%') {
$searchTerm = '%' . $searchTerm;
}
if (substr($searchTerm, -1) != '%') {
$searchTerm = $searchTerm . '%';
}
require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
try {
$ses = \Factory::getServiceService()->getSes($searchTerm, null, null, null, null, null, null, null, null, null, null, null, true);
} catch (Exception $ex) {
show_view('error.php', $ex->getMessage() . "<br /><br />Please contact the " . "<a href=\"index.php?Page_Type=Static_HTML&Page=Help_And_Contact\">" . "GOCDB support team</a> if you need help with this issue.");
}
$params = array('ses' => $ses);
show_view('service_group/se_search.php', $params, null, true);
}
示例3: submit
function submit(\EndpointLocation $endpoint, \Service $service, \User $user = null)
{
$serv = \Factory::getServiceService();
try {
$serv->deleteEndpoint($endpoint, $user);
} catch (\Exception $e) {
show_view('error.php', $e->getMessage());
die;
}
$params['endpoint'] = $endpoint;
$params['service'] = $service;
show_view('/service/deleted_service_endpoint.php', $params);
}
示例4: se_downtimes
function se_downtimes()
{
if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
throw new Exception("An id must be specified");
}
$serviceService = \Factory::getServiceService();
$se = $serviceService->getService($_REQUEST['id']);
$downtimes = $serviceService->getDowntimes($_REQUEST['id'], null);
$params['se'] = $se;
$params['downtimes'] = $downtimes;
$title = "Downtimes for " . $se->getHostName();
show_view('service/se_downtimes.php', $params, $title);
return;
}
示例5: view_site
function view_site()
{
require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
require_once __DIR__ . '/../utils.php';
require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
$serv = \Factory::getSiteService();
$servServ = \Factory::getServiceService();
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
throw new Exception("An id must be specified");
}
$siteId = $_GET['id'];
$site = $serv->getSite($siteId);
$allRoles = $site->getRoles();
$roles = array();
foreach ($allRoles as $role) {
if ($role->getStatus() == \RoleStatus::GRANTED) {
$roles[] = $role;
}
}
//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['UserIsAdmin'] = false;
if (!is_null($user)) {
$params['UserIsAdmin'] = $user->isAdmin();
}
$params['authenticated'] = false;
if ($user != null) {
$params['authenticated'] = true;
}
// Does current viewer have edit permissions over Site ?
$params['ShowEdit'] = false;
if (count($serv->authorizeAction(\Action::EDIT_OBJECT, $site, $user)) >= 1) {
$params['ShowEdit'] = true;
}
$params['Scopes'] = $serv->getScopesWithParentScopeInfo($site);
$params['ServicesAndScopes'] = array();
foreach ($site->getServices() as $service) {
$params['ServicesAndScopes'][] = array('Service' => $service, 'Scopes' => $servServ->getScopesWithParentScopeInfo($service));
}
$params['Downtimes'] = $serv->getDowntimes($site->getId(), 31);
$params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
$title = $site->getShortName();
$params['site'] = $site;
$params['roles'] = $roles;
// Add RoleActionRecords to params
$params['RoleActionRecords'] = \Factory::getRoleService()->getRoleActionRecordsById_Type($site->getId(), 'site');
show_view("site/view_site.php", $params, $title);
}
示例6: draw
/**
* Draws a form to add a new service 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 service property.");
}
if (!isset($_REQUEST['se']) || !is_numeric($_REQUEST['se'])) {
throw new Exception("An id must be specified");
}
$serv = \Factory::getServiceService();
$service = $serv->getService($_REQUEST['se']);
//get service by id
//Check user has permissions to add service property
$serv->validateAddEditDeleteActions($user, $service);
$params['serviceid'] = $_REQUEST['se'];
show_view("service/add_service_property.php", $params);
}
示例7: delete
/**
* Controller for a delete service request
* @return null
*/
function delete()
{
$dn = Get_User_Principle();
$user = \Factory::getUserService()->getUserByPrinciple($dn);
if ($user == null) {
throw new \Exception("Unregistered users can't delete services. ");
}
//Check the portal is not in read only mode, returns exception if it is and user is not an admin
checkPortalIsNotReadOnlyOrUserIsAdmin($user);
if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
throw new Exception("An id must be specified");
}
$serv = \Factory::getServiceService();
$se = $serv->getService($_REQUEST['id']);
$serv->deleteService($se, $user);
show_view('service/service_deleted.php');
}
示例8: submit
function submit(\ServiceProperty $property, \Service $service, \User $user = null)
{
if (is_null($user)) {
throw new Exception("Unregistered users can't delete a service property.");
}
$params['prop'] = $property;
$params['service'] = $service;
//remove site property
try {
$serv = \Factory::getServiceService();
$serv->deleteServiceProperty($service, $user, $property);
} catch (\Exception $e) {
show_view('error.php', $e->getMessage());
die;
}
show_view('/service/deleted_service_property.php', $params);
}
示例9: submit
/**
* Processes an edit endpoint request from a web request
* @param \User $user current user
* return null
*/
function submit(\User $user = null)
{
try {
$newValues = getEndpointDataFromWeb();
$serviceID = $newValues['SERVICEENDPOINT']['SERVICE'];
$endpointID = $newValues['SERVICEENDPOINT']['ENDPOINTID'];
$serv = \Factory::getServiceService();
$endpoint = $serv->getEndpoint($endpointID);
$service = $serv->getService($serviceID);
$serv->editEndpoint($service, $user, $endpoint, $newValues);
$params['serviceid'] = $serviceID;
$params['endpointid'] = $endpointID;
show_view('service/service_endpoint_updated.php', $params);
} catch (Exception $e) {
show_view('error.php', $e->getMessage());
die;
}
}
示例10: submit
/**
* Validates the user's input, removes the services and
* returns the object ID of the removed service
* @global array $_REQUEST only set if the browser has sent parameters
* @param \User $user current User
* @return null
*/
function submit(\User $user = null)
{
$serv = \Factory::getServiceGroupService();
if (!isset($_REQUEST['sgId']) || !is_numeric($_REQUEST['sgId'])) {
throw new Exception("An id must be specified");
}
if (!isset($_REQUEST['seId']) || !is_numeric($_REQUEST['seId'])) {
throw new Exception("An id must be specified");
}
// The service group to remove SEs from
$sg = $serv->getServiceGroup($_REQUEST['sgId']);
$se = \Factory::getServiceService()->getService($_REQUEST['seId']);
try {
/* If the service is siteless and was created under this
* service group then we delete it */
if (is_null($se->getParentSite())) {
// TODO: v5 implementation
// If 0 was returned above then the SE doesn't have a hosting site
// $hostingVSite = \Factory::getServiceService()->
// getHostVirtualSite($endpointId, $gridId);
// /* If this service group created the endpoint then delete
// * it */
// if($hostingVSite == $vSiteId) {
// $db = ConnectionFactory::getNewConnection();
// $promAPI = PromAPIFactory::getPromAPI($db);
// $returned_object_id = $promAPI->DeleteObject($endpointId, $gridId, null);
// if(!$promAPI->commit()) throw new Exception("Could not commit");
// ConnectionFactory::managedClose($db);
// show_view('vsite/return_removed_se.php', array('removedSe' => $_REQUEST['endpointId']), null, true);
// die();
// }
}
/* If the SE isn't siteless and created under this service group
* remove it as normal */
$serv->removeService($sg, $se, $user);
} catch (Exception $e) {
show_view('error.php', $e->getMessage());
die;
}
show_view('service_group/return_removed_se.php', array('se' => $se), null, true);
die;
}
示例11: 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 = getSerPropDataFromWeb();
$serviceID = $newValues['SERVICEPROPERTIES']['SERVICE'];
$propID = $newValues['SERVICEPROPERTIES']['PROP'];
if ($newValues['SERVICEPROPERTIES']['NAME'] == null || $newValues['SERVICEPROPERTIES']['VALUE'] == null) {
show_view('error.php', "A property name and value must be provided.");
die;
}
$property = \Factory::getServiceService()->getProperty($propID);
$service = \Factory::getServiceService()->getService($serviceID);
$service = \Factory::getServiceService()->editServiceProperty($service, $user, $property, $newValues);
$params['serviceid'] = $serviceID;
show_view('service/service_property_updated.php', $params);
} catch (Exception $e) {
show_view('error.php', $e->getMessage());
die;
}
}
示例12: submit
/**
* Processes an edit endpoint property request from a web request
* @param \User $user current user
* return null
*/
function submit(\User $user = null)
{
try {
$newValues = getEndpointPropDataFromWeb();
$endpointID = $newValues['ENDPOINTPROPERTIES']['ENDPOINTID'];
$propID = $newValues['ENDPOINTPROPERTIES']['PROP'];
if ($newValues['ENDPOINTPROPERTIES']['NAME'] == null || $newValues['ENDPOINTPROPERTIES']['VALUE'] == null) {
show_view('error.php', "A property name and value must be provided.");
die;
}
$property = \Factory::getServiceService()->getEndpointProperty($propID);
$service = $property->getParentEndpoint()->getService();
\Factory::getServiceService()->editEndpointProperty($service, $user, $property, $newValues);
$params['endpointid'] = $endpointID;
show_view('service/endpoint_property_updated.php', $params);
} catch (Exception $e) {
show_view('error.php', $e->getMessage());
die;
}
}
示例13: draw
/**
* 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);
}
示例14: drawSEs
function drawSEs()
{
define("RECORDS_PER_PAGE", 30);
require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
$seServ = \Factory::getServiceService();
$exServ = \Factory::getExtensionsService();
$startRecord = 1;
if (isset($_REQUEST['record'])) {
$startRecord = $_REQUEST['record'];
}
// Validation, ensure start record >= 1
if ($startRecord < 1) {
$startRecord = 1;
}
$searchTerm = "";
if (!empty($_REQUEST['searchTerm'])) {
$searchTerm = $_REQUEST['searchTerm'];
}
//strip leading and trailing whitespace off search term
$searchTerm = strip_tags(trim($searchTerm));
if (1 === preg_match("/[';\"]/", $searchTerm)) {
throw new Exception("Invalid char in search term");
}
$serviceType = "";
if (isset($_REQUEST['serviceType'])) {
$serviceType = $_REQUEST['serviceType'];
}
$production = "";
if (isset($_REQUEST['production'])) {
$production = $_REQUEST['production'];
}
$monitored = "";
if (isset($_REQUEST['monitored'])) {
$monitored = $_REQUEST['monitored'];
}
$scope = "";
if (isset($_REQUEST['scope'])) {
$scope = $_REQUEST['scope'];
}
$ngi = "";
if (isset($_REQUEST['ngi'])) {
$ngi = $_REQUEST['ngi'];
}
//must be done before the if certstatus in the block that sets $certStatus
$showClosed = false;
if (isset($_REQUEST['showClosed'])) {
$showClosed = true;
}
$servKeyNames = "";
if (isset($_REQUEST['servKeyNames'])) {
$servKeyNames = $_REQUEST['servKeyNames'];
}
$servKeyValues = "";
if (isset($_REQUEST['selectedServKeyValue'])) {
$servKeyValues = $_REQUEST['selectedServKeyValue'];
}
$certStatus = "";
if (!empty($_REQUEST['certificationStatus'])) {
$certStatus = $_REQUEST['certificationStatus'];
//set show closed as true if production status selected is 'closed' - otherwise
// there will be no results
if ($certStatus == 'Closed') {
$showClosed = true;
}
}
$thisPage = 'index.php?Page_Type=Services';
if ($serviceType != "") {
$thisPage .= '&serviceType=' . $serviceType;
}
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;
}
//.........这里部分代码省略.........
示例15: draw
/**
* 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);
}