本文整理汇总了PHP中Factory::getDowntimeService方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getDowntimeService方法的具体用法?PHP Factory::getDowntimeService怎么用?PHP Factory::getDowntimeService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::getDowntimeService方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
/**
*
* @param \User $user current user
* @throws Exception
*/
function submit(\User $user = null)
{
//Check if this is a confirmed submit or intial submit
$confirmed = $_POST['CONFIRMED'];
if ($confirmed == true) {
//Downtime is confirmed, submit it
$downtimeInfo = json_decode($_POST['newValues'], TRUE);
$serv = \Factory::getDowntimeService();
$dt = $serv->getDowntime($downtimeInfo['DOWNTIME']['EXISTINGID']);
unset($downtimeInfo['DOWNTIME']['EXISTINGID']);
unset($downtimeInfo['isEdit']);
$params['dt'] = $serv->editDowntime($dt, $downtimeInfo, $user);
show_view("downtime/edited_downtime.php", $params);
} else {
//Show user confirmation screen with their input
$downtimeInfo = getDtDataFromWeb();
//Need to sort the impacted_ids into impacted services and impacted endpoints
$impactedids = $downtimeInfo['IMPACTED_IDS'];
$services = array();
$endpoints = array();
//For each impacted id sort between endpoints and services using the prepended letter
foreach ($impactedids as $id) {
if (strpos($id, 's') !== FALSE) {
//This is a service id
$services[] = str_replace('s', '', $id);
//trim off the identifying char before storing in array
} else {
//This is an endpoint id
$endpoints[] = str_replace('e', '', $id);
//trim off the identifying char before storing in array
}
}
unset($downtimeInfo['IMPACTED_IDS']);
//Delete the unsorted Ids from the downtime info
$downtimeInfo['Impacted_Endpoints'] = $endpoints;
$serv = \Factory::getServiceService();
/** For endpoint put into downtime we want the parent service also. If a user has selected
* endpoints but not the parent service here we will add the service to maintain the link beteween
* a downtime having both the service and the endpoint.
*/
foreach ($downtimeInfo['Impacted_Endpoints'] as $endpointIds) {
$endpoint = $serv->getEndpoint($endpointIds);
$services[] = $endpoint->getService()->getId();
}
//Remove any duplicate service ids and store the array of ids
$services = array_unique($services);
//Assign the impacted services and endpoints to their own arrays for us by the addDowntime method
$downtimeInfo['Impacted_Services'] = $services;
//Pass the edit variable so the confirm_add view works as the confirm edit view.
$downtimeInfo['isEdit'] = true;
show_view("downtime/confirm_add_downtime.php", $downtimeInfo);
}
}
示例2: view
function view()
{
require_once __DIR__ . '/../utils.php';
require_once __DIR__ . '/../../../web_portal/components/Get_User_Principle.php';
if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
throw new Exception("An id must be specified");
}
$downtime = \Factory::getDowntimeService()->getDowntime($_REQUEST['id']);
if ($downtime == null) {
throw new Exception('No downtime with id [' . $_REQUEST['id'] . ']');
}
$dn = Get_User_Principle();
$user = \Factory::getUserService()->getUserByPrinciple($dn);
$params['portalIsReadOnly'] = portalIsReadOnlyAndUserIsNotAdmin($user);
$params['downtime'] = $downtime;
$title = $downtime->getDescription();
show_view("downtime/view_downtime.php", $params, $title);
}
示例3: view
function view()
{
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);
$timePeriod = 1;
if (isset($_REQUEST['timePeriod'])) {
$timePeriod = $_REQUEST['timePeriod'];
}
$days = 7 * $timePeriod;
$windowStart = date("Y-m-d");
$windowEnd = date_add(date_create(date("Y-m-d")), date_interval_create_from_date_string($days . ' days'));
$downtimesA = \Factory::getDowntimeService()->getActiveDowntimes();
$downtimesI = \Factory::getDowntimeService()->getImminentDowntimes($windowStart, $windowEnd);
$params['timePeriod'] = $timePeriod;
$params['downtimesActive'] = $downtimesA;
$params['downtimesImmenent'] = $downtimesI;
show_view("downtime/downtimes_overview.php", $params);
}
示例4: endDt
/**
* Controller for an edit downtime request
* @global array $_POST only set if the browser has POSTed data
* @return null
*/
function endDt()
{
require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
require_once __DIR__ . '/../utils.php';
if (!isset($_POST['id']) || !is_numeric($_POST['id'])) {
throw new Exception("A downtime id must be specified");
}
$serv = \Factory::getDowntimeService();
$dt = $serv->getDowntime($_POST['id']);
if ($dt == null) {
throw new Exception("No downtime with that id");
}
$dn = Get_User_Principle();
$user = \Factory::getUserService()->getUserByPrinciple($dn);
//Check the portal is not in read only mode, returns exception if it is and user is not an admin
checkPortalIsNotReadOnlyOrUserIsAdmin($user);
$serv->endDowntime($dt, $user);
$params = array('downtime' => $dt);
show_view("downtime/ended_downtime.php", $params);
}
示例5: delete
/**
* Controller for a delete downtime request
* @return null
*/
function delete()
{
require_once __DIR__ . '/../../../../lib/Gocdb_Services/Factory.php';
require_once __DIR__ . '/../../../../htdocs/web_portal/components/Get_User_Principle.php';
require_once __DIR__ . '/../utils.php';
$dn = Get_User_Principle();
$user = \Factory::getUserService()->getUserByPrinciple($dn);
if (is_null($user)) {
throw new \Exception("Unregistered users can't delete a downtime.");
}
//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::getDowntimeService();
if (isset($_REQUEST['id'])) {
$dt = $serv->getDowntime($_REQUEST['id']);
if ($dt != null) {
$serv->deleteDowntime($dt, $user);
}
}
show_view('downtime/deleted_downtime.php');
}