本文整理汇总了PHP中NotificationEvent类的典型用法代码示例。如果您正苦于以下问题:PHP NotificationEvent类的具体用法?PHP NotificationEvent怎么用?PHP NotificationEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NotificationEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterAdd
static function afterAdd(Group_Ticket $item)
{
global $DB;
//Toolbox::logDebug(__METHOD__, $item);
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('add_notif')) {
if ($item->getField('type') == CommonITILActor::ASSIGN) {
$ticket = new Ticket();
if ($ticket->getFromDB($item->getField('tickets_id'))) {
NotificationEvent::raiseEvent('plugin_behaviors_ticketnewgrp', $ticket);
}
}
}
// Check is the connected user is a tech
if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('own_ticket', 1)) {
return false;
// No check
}
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('single_tech_mode') != 0 && $item->input['type'] == CommonITILActor::ASSIGN) {
$crit = array('tickets_id' => $item->input['tickets_id'], 'type' => CommonITILActor::ASSIGN);
foreach ($DB->request('glpi_groups_tickets', $crit) as $data) {
if ($data['id'] != $item->getID()) {
$gu = new Group_Ticket();
$gu->delete($data);
}
}
if ($config->getField('single_tech_mode') == 2) {
foreach ($DB->request('glpi_tickets_users', $crit) as $data) {
$gu = new Ticket_User();
$gu->delete($data);
}
}
}
}
示例2: afterUpdate
static function afterUpdate(TicketSatisfaction $ticketsatisfaction)
{
$config = PluginBehaviorsConfig::getInstance();
$ticket = new Ticket();
if ($config->getField('add_notif') && $ticket->getFromDB($ticketsatisfaction->getField('tickets_id')) && $ticketsatisfaction->input["date_answered"]) {
NotificationEvent::raiseEvent('plugin_behaviors_replysurvey', $ticket);
}
}
示例3: afterPurge
static function afterPurge(Document_Item $document_item)
{
$config = PluginBehaviorsConfig::getInstance();
if ($config->getField('add_notif') && $document_item->fields['itemtype'] == 'Ticket' && isset($_POST['item'])) {
// prevent not use in case of purge ticket
$ticket = new Ticket();
$ticket->getFromDB($document_item->fields['items_id']);
NotificationEvent::raiseEvent('plugin_behaviors_document_itemdel', $ticket);
}
}
示例4: post_deleteFromDB
function post_deleteFromDB()
{
global $CFG_GLPI;
$donotif = $CFG_GLPI["use_mailing"];
if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) {
$donotif = false;
}
$t = new Ticket();
if ($t->getFromDB($this->fields['tickets_id'])) {
if ($t->fields["suppliers_id_assign"] == 0 && $t->countUsers(Ticket::ASSIGN) == 0 && $t->countGroups(Ticket::ASSIGN) == 0) {
$t->update(array('id' => $this->fields['tickets_id'], 'status' => 'new'));
} else {
$t->updateDateMod($this->fields['tickets_id']);
if ($donotif) {
NotificationEvent::raiseEvent("update", $t);
}
}
}
parent::post_deleteFromDB();
}
示例5: executeActions
/**
* @param $output
* @param $params
**/
function executeActions($output, $params)
{
if (count($this->actions)) {
foreach ($this->actions as $action) {
switch ($action->fields["action_type"]) {
case "send":
$ticket = new Ticket();
if ($ticket->getFromDB($output['id'])) {
NotificationEvent::raiseEvent('recall', $ticket);
}
break;
case "add_validation":
if (isset($output['_add_validation']) && !is_array($output['_add_validation'])) {
$output['_add_validation'] = array($output['_add_validation']);
}
switch ($action->fields['field']) {
case 'users_id_validate_requester_supervisor':
$output['_add_validation'][] = 'requester_supervisor';
break;
case 'users_id_validate_assign_supervisor':
$output['_add_validation'][] = 'assign_supervisor';
break;
case 'groups_id_validate':
$output['_add_validation']['group'][] = $action->fields["value"];
break;
case 'users_id_validate':
$output['_add_validation'][] = $action->fields["value"];
break;
case 'validation_percent':
$output[$action->fields["field"]] = $action->fields["value"];
break;
default:
$output['_add_validation'][] = $action->fields["value"];
break;
}
break;
case "assign":
$output[$action->fields["field"]] = $action->fields["value"];
// Special case of users_id_requester
if ($action->fields["field"] === '_users_id_requester') {
// Add groups of requester
if (!isset($output['_groups_id_of_requester'])) {
$output['_groups_id_of_requester'] = array();
}
foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
$output['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
break;
case "append":
$actions = $this->getActions();
$value = $action->fields["value"];
if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) {
$value = $actions[$action->fields["field"]]["appendtoarray"];
$value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"];
}
$output[$actions[$action->fields["field"]]["appendto"]][] = $value;
// Special case of users_id_requester
if ($action->fields["field"] === '_users_id_requester') {
// Add groups of requester
if (!isset($output['_groups_id_of_requester'])) {
$output['_groups_id_of_requester'] = array();
}
foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
$output['_groups_id_of_requester'][$g['id']] = $g['id'];
}
}
break;
case 'fromuser':
if ($action->fields['field'] == 'locations_id' && isset($output['users_locations'])) {
$output['locations_id'] = $output['users_locations'];
}
break;
case 'fromitem':
if ($action->fields['field'] == 'locations_id' && isset($output['items_locations'])) {
$output['locations_id'] = $output['items_locations'];
}
if ($action->fields['field'] == 'groups_id' && isset($output['items_groups'])) {
$output['groups_id'] = $output['items_groups'];
}
break;
case 'compute':
// Value could be not set (from test)
$urgency = isset($output['urgency']) ? $output['urgency'] : 3;
$impact = isset($output['impact']) ? $output['impact'] : 3;
// Apply priority_matrix from config
$output['priority'] = Ticket::computePriority($urgency, $impact);
break;
case "affectbyip":
case "affectbyfqdn":
case "affectbymac":
if (!isset($output["entities_id"])) {
$output["entities_id"] = $params["entities_id"];
}
if (isset($this->regex_results[0])) {
$regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
//.........这里部分代码省略.........
示例6: post_addItem
function post_addItem()
{
global $CFG_GLPI;
parent::post_addItem();
if (isset($this->input['_tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($this->input['_tickets_id'])) {
$pt = new Change_Ticket();
$pt->add(array('tickets_id' => $this->input['_tickets_id'], 'changes_id' => $this->fields['id']));
if (!empty($ticket->fields['itemtype']) && $ticket->fields['items_id'] > 0) {
$it = new Change_Item();
$it->add(array('changes_id' => $this->fields['id'], 'itemtype' => $ticket->fields['itemtype'], 'items_id' => $ticket->fields['items_id']));
}
}
}
if (isset($this->input['_problems_id'])) {
$problem = new Problem();
if ($problem->getFromDB($this->input['_problems_id'])) {
$cp = new Change_Problem();
$cp->add(array('problems_id' => $this->input['_problems_id'], 'changes_id' => $this->fields['id']));
}
}
// Processing Email
if ($CFG_GLPI["use_mailing"]) {
// Clean reload of the change
$this->getFromDB($this->fields['id']);
$type = "new";
if (isset($this->fields["status"]) && in_array($this->input["status"], $this->getSolvedStatusArray())) {
$type = "solved";
}
NotificationEvent::raiseEvent($type, $this);
}
}
示例7: showDebug
/**
* Display debug information for current object
**/
function showDebug()
{
$license = array('softname' => '', 'name' => '', 'serial' => '', 'expire' => '');
$options['entities_id'] = $this->getEntityID();
$options['licenses'] = array($license);
NotificationEvent::debugEvent($this, $options);
}
示例8: post_updateItem
function post_updateItem($history = 1)
{
global $CFG_GLPI;
$job = new Ticket();
$donotif = $CFG_GLPI["use_mailing"];
if (isset($this->input['_disablenotif'])) {
$donotif = false;
}
if ($job->getFromDB($this->fields["tickets_id"])) {
if (count($this->updates) && $donotif) {
$options = array('validation_id' => $this->fields["id"], 'validation_status' => $this->fields["status"]);
NotificationEvent::raiseEvent('validation_answer', $job, $options);
}
// Set global validation to accepted to define one
if ($job->fields['global_validation'] == 'waiting' || self::getNumberValidationForTicket($this->fields["tickets_id"]) == 1 || self::isAllValidationsHaveSameStatusForTicket($this->fields["tickets_id"])) {
$input['id'] = $this->fields["tickets_id"];
$input['global_validation'] = $this->fields["status"];
$job->update($input);
}
}
parent::post_updateItem($history);
}
示例9: cronCheckDBreplicate
/**
* Cron process to check DB replicate state
*
* @param $task to log and get param
**/
static function cronCheckDBreplicate($task)
{
global $DB;
//Lauch cron only is :
// 1 the master database is avalaible
// 2 the slave database is configurated
if (!$DB->isSlave() && self::isDBSlaveActive()) {
$DBslave = self::getDBSlaveConf();
if (is_array($DBslave->dbhost)) {
$hosts = $DBslave->dbhost;
} else {
$hosts = array($DBslave->dbhost);
}
foreach ($hosts as $num => $name) {
$diff = self::getReplicateDelay($num);
// Quite strange, but allow simple stat
$task->addVolume($diff);
if ($diff > 1000000000) {
// very large means slave is disconnect
$task->log(sprintf(__s("Mysql server: %s can't connect to the database"), $name));
} else {
//TRANS: %1$s is the server name, %2$s is the time
$task->log(sprintf(__('Mysql server: %1$s, difference between master and slave: %2$s'), $name, Html::timestampToString($diff, true)));
}
if ($diff > $task->fields['param'] * 60) {
//Raise event if replicate is not synchronized
$options = array('diff' => $diff, 'name' => $name, 'entities_id' => 0);
// entity to avoid warning in getReplyTo
NotificationEvent::raiseEvent('desynchronization', new self(), $options);
}
}
return 1;
}
return 0;
}
示例10: showDebug
/**
* Display debug information for current object
**/
function showDebug()
{
$options['entities_id'] = $this->getEntityID();
$options['contracts'] = array();
NotificationEvent::debugEvent($this, $options);
}
示例11: cronAdditionalalertsNewOcs
static function cronAdditionalalertsNewOcs($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$CronTask = new CronTask();
if ($CronTask->getFromDBbyName("PluginAdditionalalertsOcsAlert", "AdditionalalertsNewOcs")) {
if ($CronTask->fields["state"] == CronTask::STATE_DISABLE) {
return 0;
}
} else {
return 0;
}
$message = array();
$cron_status = 0;
foreach (self::getEntitiesToNotify('use_newocs_alert') as $entity => $repeat) {
foreach ($DB->request("glpi_plugin_ocsinventoryng_ocsservers", "`is_active` = 1") as $config) {
$query_newocsmachine = self::queryNew($config, $entity);
$newocsmachine_infos = array();
$newocsmachine_messages = array();
$type = Alert::END;
$newocsmachine_infos[$type] = array();
foreach ($DB->request($query_newocsmachine) as $data) {
$entity = $data['entities_id'];
$message = $data["name"];
$newocsmachine_infos[$type][$entity][] = $data;
if (!isset($newocsmachines_infos[$type][$entity])) {
$newocsmachine_messages[$type][$entity] = __('New imported computers from OCS-NG', 'additionalalerts') . "<br />";
}
$newocsmachine_messages[$type][$entity] .= $message;
}
$delay_ocs = 0;
foreach ($newocsmachine_infos[$type] as $entity => $newocsmachines) {
Plugin::loadLang('additionalalerts');
if (NotificationEvent::raiseEvent("newocs", new PluginAdditionalalertsOcsAlert(), array('entities_id' => $entity, 'ocsmachines' => $newocsmachines, 'delay_ocs' => $delay_ocs))) {
$message = $newocsmachine_messages[$type][$entity];
$cron_status = 1;
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}\n");
$task->addVolume(1);
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": {$message}");
}
} else {
if ($task) {
$task->log(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send newocsmachines alert failed\n");
} else {
Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . ": Send newocsmachines alert failed", false, ERROR);
}
}
}
}
}
return $cron_status;
}
示例12: post_addItem
function post_addItem()
{
global $CFG_GLPI;
parent::post_addItem();
if (isset($this->input['_tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($this->input['_tickets_id'])) {
$pt = new Problem_Ticket();
$pt->add(array('tickets_id' => $this->input['_tickets_id'], 'problems_id' => $this->fields['id'], '_no_notif' => true));
if (!empty($ticket->fields['itemtype']) && $ticket->fields['items_id'] > 0) {
$it = new Item_Problem();
$it->add(array('problems_id' => $this->fields['id'], 'itemtype' => $ticket->fields['itemtype'], 'items_id' => $ticket->fields['items_id'], '_no_notif' => true));
}
}
}
// Processing Email
if ($CFG_GLPI["use_mailing"]) {
// Clean reload of the problem
$this->getFromDB($this->fields['id']);
$type = "new";
if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
$type = "solved";
}
NotificationEvent::raiseEvent($type, $this);
}
}
示例13: post_addItem
function post_addItem()
{
global $CFG_GLPI;
if ($CFG_GLPI["use_mailing"]) {
NotificationEvent::raiseEvent("new", $this);
}
parent::post_addItem();
}
示例14: showDebug
/**
* Display debug information for current object
**/
function showDebug()
{
$params = array('message' => '', 'action_type' => true, 'action_user' => getUserName(Session::getLoginUserID()), 'entities_id' => $_SESSION['glpiactive_entity'], 'itemtype' => get_class($this), 'date' => $_SESSION['glpi_currenttime'], 'refuse' => true);
NotificationEvent::debugEvent($this, $params);
}
示例15: post_addItem
function post_addItem()
{
global $CFG_GLPI;
if (isset($this->input['_planningrecall'])) {
$this->input['_planningrecall']['items_id'] = $this->fields['id'];
PlanningRecall::manageDatas($this->input['_planningrecall']);
}
$donotif = $CFG_GLPI["use_mailing"];
if (isset($this->fields["begin"]) && !empty($this->fields["begin"])) {
Planning::checkAlreadyPlanned($this->fields["users_id_tech"], $this->fields["begin"], $this->fields["end"], array($this->getType() => array($this->fields["id"])));
$calendars_id = Entity::getUsedConfig('calendars_id', $this->input["_job"]->fields['entities_id']);
$calendar = new Calendar();
// Using calendar
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
if (!$calendar->isAWorkingHour(strtotime($this->fields["begin"]))) {
Session::addMessageAfterRedirect(__('Start of the selected timeframe is not a working hour.'), false, ERROR);
}
if (!$calendar->isAWorkingHour(strtotime($this->fields["end"]))) {
Session::addMessageAfterRedirect(__('End of the selected timeframe is not a working hour.'), false, ERROR);
}
}
}
$this->input["_job"]->updateDateMod($this->input[$this->input["_job"]->getForeignKeyField()]);
if (isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
$this->input["_job"]->updateActionTime($this->input[$this->input["_job"]->getForeignKeyField()]);
}
//change status only if input change
if (isset($this->input['_status']) && $this->input['_status'] != $this->input['_job']->fields['status']) {
$update['status'] = $this->input['_status'];
$update['id'] = $this->input['_job']->fields['id'];
$update['_disablenotif'] = true;
$this->input['_job']->update($update);
}
if (!empty($this->fields['begin']) && $this->input["_job"]->isStatusExists(CommonITILObject::PLANNED) && ($this->input["_job"]->fields["status"] == CommonITILObject::INCOMING || $this->input["_job"]->fields["status"] == CommonITILObject::ASSIGNED)) {
$input2['id'] = $this->input["_job"]->getID();
$input2['status'] = CommonITILObject::PLANNED;
$input2['_disablenotif'] = true;
$this->input["_job"]->update($input2);
}
if ($donotif) {
$options = array('task_id' => $this->fields["id"], 'is_private' => $this->isPrivate());
NotificationEvent::raiseEvent('add_task', $this->input["_job"], $options);
}
// Add log entry in the ITIL object
$changes[0] = 0;
$changes[1] = '';
$changes[2] = $this->fields['id'];
Log::history($this->getField($this->input["_job"]->getForeignKeyField()), $this->input["_job"]->getTYpe(), $changes, $this->getType(), Log::HISTORY_ADD_SUBITEM);
}