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


PHP NotificationEvent::raiseEvent方法代码示例

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


在下文中一共展示了NotificationEvent::raiseEvent方法的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);
             }
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:35,代码来源:group_ticket.class.php

示例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);
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:8,代码来源:ticketsatisfaction.class.php

示例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);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:10,代码来源:document_item.class.php

示例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();
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:20,代码来源:group_ticket.class.php

示例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]);
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:glpi,代码行数:101,代码来源:ruleticket.class.php

示例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);
     }
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:33,代码来源:change.class.php

示例7: cronSoftware

 /**
  * Cron action on softwares : alert on expired licences
  *
  * @param $task to log, if NULL display (default NULL)
  *
  * @return 0 : nothing to do 1 : done with success
  **/
 static function cronSoftware($task = NULL)
 {
     global $DB, $CFG_GLPI;
     $cron_status = 1;
     if (!$CFG_GLPI['use_mailing']) {
         return 0;
     }
     $message = array();
     $items_notice = array();
     $items_end = array();
     foreach (Entity::getEntitiesToNotify('use_licenses_alert') as $entity => $value) {
         $before = Entity::getUsedConfig('send_licenses_alert_before_delay', $entity);
         // Check licenses
         $query = "SELECT `glpi_softwarelicenses`.*,\n                          `glpi_softwares`.`name` AS softname\n                   FROM `glpi_softwarelicenses`\n                   INNER JOIN `glpi_softwares`\n                        ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                   LEFT JOIN `glpi_alerts`\n                        ON (`glpi_softwarelicenses`.`id` = `glpi_alerts`.`items_id`\n                            AND `glpi_alerts`.`itemtype` = 'SoftwareLicense'\n                            AND `glpi_alerts`.`type` = '" . Alert::END . "')\n                   WHERE `glpi_alerts`.`date` IS NULL\n                         AND `glpi_softwarelicenses`.`expire` IS NOT NULL\n                         AND DATEDIFF(`glpi_softwarelicenses`.`expire`,\n                                      CURDATE()) < '{$before}'\n                         AND `glpi_softwares`.`is_template` = '0'\n                         AND `glpi_softwares`.`is_deleted` = '0'\n                         AND `glpi_softwares`.`entities_id` = '" . $entity . "'";
         $message = "";
         $items = array();
         foreach ($DB->request($query) as $license) {
             $name = $license['softname'] . ' - ' . $license['name'] . ' - ' . $license['serial'];
             //TRANS: %1$s the license name, %2$s is the expiration date
             $message .= sprintf(__('License %1$s expired on %2$s'), Html::convDate($license["expire"]), $name) . "<br>\n";
             $items[$license['id']] = $license;
         }
         if (!empty($items)) {
             $alert = new Alert();
             $options['entities_id'] = $entity;
             $options['licenses'] = $items;
             if (NotificationEvent::raiseEvent('alert', new self(), $options)) {
                 $entityname = Dropdown::getDropdownName("glpi_entities", $entity);
                 if ($task) {
                     //TRANS: %1$s is the entity, %2$s is the message
                     $task->log(sprintf(__('%1$s: %2$s') . "\n", $entityname, $message));
                     $task->addVolume(1);
                 } else {
                     Session::addMessageAfterRedirect(sprintf(__('%1$s: %2$s'), $entityname, $message));
                 }
                 $input["type"] = Alert::END;
                 $input["itemtype"] = 'SoftwareLicense';
                 // add alerts
                 foreach ($items as $ID => $consumable) {
                     $input["items_id"] = $ID;
                     $alert->add($input);
                     unset($alert->fields['id']);
                 }
             } else {
                 $entityname = Dropdown::getDropdownName('glpi_entities', $entity);
                 //TRANS: %s is entity name
                 $msg = sprintf(__('%1$s: %2$s'), $entityname, __('Send licenses alert failed'));
                 if ($task) {
                     $task->log($msg);
                 } else {
                     Session::addMessageAfterRedirect($msg, false, ERROR);
                 }
             }
         }
     }
     return $cron_status;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:64,代码来源:softwarelicense.class.php

示例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);
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:22,代码来源:ticketvalidation.class.php

示例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;
 }
开发者ID:pvasener,项目名称:glpi,代码行数:40,代码来源:dbconnection.class.php

示例10: 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;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:56,代码来源:ocsalert.class.php

示例11: 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);
     }
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:26,代码来源:problem.class.php

示例12: post_addItem

 function post_addItem()
 {
     global $CFG_GLPI;
     if ($CFG_GLPI["use_mailing"]) {
         NotificationEvent::raiseEvent("new", $this);
     }
     parent::post_addItem();
 }
开发者ID:btry,项目名称:glpi,代码行数:8,代码来源:reservation.class.php

示例13: 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);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:49,代码来源:commonitiltask.class.php

示例14: 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']));
             /// TODO add linked tickets and linked hardware (to problem and tickets)
             /// create standard function
         }
     }
     // Processing Email
     if ($CFG_GLPI["use_mailing"]) {
         // Clean reload of the change
         $this->getFromDB($this->fields['id']);
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         NotificationEvent::raiseEvent($type, $this);
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:35,代码来源:change.class.php

示例15: cronConsumable

 /**
  * Cron action on consumables : alert if a stock is behind the threshold
  *
  * @param $task   to log, if NULL display (default NULL)
  *
  * @return 0 : nothing to do 1 : done with success
  **/
 static function cronConsumable($task = NULL)
 {
     global $DB, $CFG_GLPI;
     $cron_status = 1;
     if ($CFG_GLPI["use_mailing"]) {
         $message = array();
         $items = array();
         $alert = new Alert();
         foreach (Entity::getEntitiesToNotify('consumables_alert_repeat') as $entity => $repeat) {
             $query_alert = "SELECT `glpi_consumableitems`.`id` AS consID,\n                                   `glpi_consumableitems`.`entities_id` AS entity,\n                                   `glpi_consumableitems`.`ref` AS ref,\n                                   `glpi_consumableitems`.`name` AS name,\n                                   `glpi_consumableitems`.`alarm_threshold` AS threshold,\n                                   `glpi_alerts`.`id` AS alertID,\n                                   `glpi_alerts`.`date`\n                            FROM `glpi_consumableitems`\n                            LEFT JOIN `glpi_alerts`\n                                 ON (`glpi_consumableitems`.`id` = `glpi_alerts`.`items_id`\n                                     AND `glpi_alerts`.`itemtype`='ConsumableItem')\n                            WHERE `glpi_consumableitems`.`is_deleted` = '0'\n                                  AND `glpi_consumableitems`.`alarm_threshold` >= '0'\n                                  AND `glpi_consumableitems`.`entities_id` = '" . $entity . "'\n                                  AND (`glpi_alerts`.`date` IS NULL\n                                       OR (`glpi_alerts`.date+{$repeat}) < CURRENT_TIMESTAMP());";
             $message = "";
             $items = array();
             foreach ($DB->request($query_alert) as $consumable) {
                 if (($unused = Consumable::getUnusedNumber($consumable["consID"])) <= $consumable["threshold"]) {
                     // define message alert
                     //TRANS: %1$s is the consumable name, %2$s its reference, %3$d the remaining number
                     $message .= sprintf(__('Threshold of alarm reached for the type of consumable: %1$s - Reference %2$s - Remaining %3$d'), $consumable['name'], $consumable['ref'], $unused);
                     $message .= '<br>';
                     $items[$consumable["consID"]] = $consumable;
                     // if alert exists -> delete
                     if (!empty($consumable["alertID"])) {
                         $alert->delete(array("id" => $consumable["alertID"]));
                     }
                 }
             }
             if (!empty($items)) {
                 $options['entities_id'] = $entity;
                 $options['items'] = $items;
                 if (NotificationEvent::raiseEvent('alert', new ConsumableItem(), $options)) {
                     if ($task) {
                         $task->log(Dropdown::getDropdownName("glpi_entities", $entity) . " :  {$message}\n");
                         $task->addVolume(1);
                     } else {
                         Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . " :  {$message}");
                     }
                     $input["type"] = Alert::THRESHOLD;
                     $input["itemtype"] = 'ConsumableItem';
                     // add alerts
                     foreach ($items as $ID => $consumable) {
                         $input["items_id"] = $ID;
                         $alert->add($input);
                         unset($alert->fields['id']);
                     }
                 } else {
                     $entityname = Dropdown::getDropdownName('glpi_entities', $entity);
                     //TRANS: %s is entity name
                     $msg = sprintf(__('%s: send consumable alert failed'), $entityname);
                     if ($task) {
                         $task->log($msg);
                     } else {
                         Session::addMessageAfterRedirect($msg, false, ERROR);
                     }
                 }
             }
         }
     }
     return $cron_status;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:65,代码来源:consumableitem.class.php


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