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


PHP Alert::clear方法代码示例

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


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

示例1: Alert

 function pre_updateInDB()
 {
     // Clean end alert if expire is after old one
     if (isset($this->oldvalues['expire']) && $this->oldvalues['expire'] < $this->fields['expire']) {
         $alert = new Alert();
         $alert->clear($this->getType(), $this->fields['id'], Alert::END);
     }
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:8,代码来源:softwarelicense.class.php

示例2: testAddDelete

 public function testAddDelete()
 {
     $alert = new Alert();
     $nb = countElementsInTable($alert->getTable());
     $comp = getItemByTypeName('Computer', '_test_pc01');
     $date = '2016-09-01 12:34:56';
     // Add
     $id = $alert->add(['itemtype' => $comp->getType(), 'items_id' => $comp->getID(), 'type' => Alert::END, 'date' => $date]);
     $this->assertGreaterThan(0, $id);
     $this->assertGreaterThan($nb, countElementsInTable($alert->getTable()));
     // Getters
     $this->assertFalse(Alert::alertExists($comp->getType(), $comp->getID(), Alert::NOTICE));
     $this->assertEquals($id, Alert::alertExists($comp->getType(), $comp->getID(), Alert::END));
     $this->assertEquals($date, Alert::getAlertDate($comp->getType(), $comp->getID(), Alert::END));
     // Delete
     $this->assertTrue($alert->clear($comp->getType(), $comp->getID(), Alert::END));
     $this->assertEquals($nb, countElementsInTable($alert->getTable()));
     // Still true, nothing to delete but no error
     $this->assertTrue($alert->clear($comp->getType(), $comp->getID(), Alert::END));
 }
开发者ID:btry,项目名称:glpi,代码行数:20,代码来源:AlertTest.php

示例3: Alert

 function pre_updateInDB()
 {
     // Clean end alert if buy_date is after old one
     // Or if duration is greater than old one
     if (isset($this->oldvalues['warranty_date']) && $this->oldvalues['warranty_date'] < $this->fields['warranty_date'] || isset($this->oldvalues['warranty_duration']) && $this->oldvalues['warranty_duration'] < $this->fields['warranty_duration']) {
         $alert = new Alert();
         $alert->clear($this->getType(), $this->fields['id'], Alert::END);
     }
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:9,代码来源:infocom.class.php

示例4: cronContract

 /**
  * Cron action on contracts : alert depending of the config : on notice and expire
  *
  * @param $task for log, if NULL display (default NULL)
  **/
 static function cronContract($task = NULL)
 {
     global $DB, $CFG_GLPI;
     if (!$CFG_GLPI["use_mailing"]) {
         return 0;
     }
     $message = array();
     $items_notice = array();
     $items_end = array();
     $cron_status = 0;
     $contract_infos[Alert::END] = array();
     $contract_infos[Alert::NOTICE] = array();
     $contract_messages = array();
     foreach (Entity::getEntitiesToNotify('use_contracts_alert') as $entity => $value) {
         $before = Entity::getUsedConfig('send_contracts_alert_before_delay', $entity);
         $query_notice = "SELECT `glpi_contracts`.*\n                          FROM `glpi_contracts`\n                          LEFT JOIN `glpi_alerts`\n                              ON (`glpi_contracts`.`id` = `glpi_alerts`.`items_id`\n                                  AND `glpi_alerts`.`itemtype` = 'Contract'\n                                  AND `glpi_alerts`.`type`='" . Alert::NOTICE . "')\n                          WHERE (`glpi_contracts`.`alert` & " . pow(2, Alert::NOTICE) . ") >'0'\n                                AND `glpi_contracts`.`is_deleted` = '0'\n                                AND `glpi_contracts`.`begin_date` IS NOT NULL\n                                AND `glpi_contracts`.`duration` <> '0'\n                                AND `glpi_contracts`.`notice` <> '0'\n                                AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n                                                     INTERVAL `glpi_contracts`.`duration` MONTH),\n                                             CURDATE()) > '0'\n                                AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n                                                     INTERVAL (`glpi_contracts`.`duration`\n                                                                -`glpi_contracts`.`notice`) MONTH),\n                                             CURDATE()) < '{$before}'\n                                AND `glpi_alerts`.`date` IS NULL\n                                AND `glpi_contracts`.`entities_id` = '" . $entity . "'";
         $query_end = "SELECT `glpi_contracts`.*\n                       FROM `glpi_contracts`\n                       LEFT JOIN `glpi_alerts`\n                           ON (`glpi_contracts`.`id` = `glpi_alerts`.`items_id`\n                               AND `glpi_alerts`.`itemtype` = 'Contract'\n                               AND `glpi_alerts`.`type`='" . Alert::END . "')\n                       WHERE (`glpi_contracts`.`alert` & " . pow(2, Alert::END) . ") > '0'\n                             AND `glpi_contracts`.`is_deleted` = '0'\n                             AND `glpi_contracts`.`begin_date` IS NOT NULL\n                             AND `glpi_contracts`.`duration` <> '0'\n                             AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n                                                  INTERVAL (`glpi_contracts`.`duration`) MONTH),\n                                          CURDATE()) < '{$before}'\n                             AND `glpi_alerts`.`date` IS NULL\n                             AND `glpi_contracts`.`entities_id` = '" . $entity . "'";
         $querys = array('notice' => $query_notice, 'end' => $query_end);
         foreach ($querys as $type => $query) {
             foreach ($DB->request($query) as $data) {
                 $entity = $data['entities_id'];
                 $message = sprintf(__('%1$s: %2$s') . "<br>\n", $data["name"], Infocom::getWarrantyExpir($data["begin_date"], $data["duration"], $data["notice"]));
                 $contract_infos[$type][$entity][$data['id']] = $data;
                 if (!isset($contract_messages[$type][$entity])) {
                     switch ($type) {
                         case 'notice':
                             $contract_messages[$type][$entity] = __('Contract entered in notice time') . "<br>";
                             break;
                         case 'end':
                             $contract_messages[$type][$entity] = __('Contract ended') . "<br>";
                             break;
                     }
                 }
                 $contract_messages[$type][$entity] .= $message;
             }
         }
         // Get contrats with periodicity alerts
         $query_periodicity = "SELECT `glpi_contracts`.*\n                               FROM `glpi_contracts`\n                               WHERE `glpi_contracts`.`alert` & " . pow(2, Alert::PERIODICITY) . " > '0'\n                                     AND `glpi_contracts`.`entities_id` = '" . $entity . "' ";
         // Foreach ones :
         foreach ($DB->request($query_periodicity) as $data) {
             $entity = $data['entities_id'];
             // Compute end date + 12 month : do not send alerts after
             $end_alert = date('Y-m-d', strtotime($data['begin_date'] . " +" . ($data['duration'] + 12) . " month"));
             if (!empty($data['begin_date']) && $data['periodicity'] && $end_alert > date('Y-m-d')) {
                 $todo = array('periodicity' => Alert::PERIODICITY);
                 if ($data['alert'] & pow(2, Alert::NOTICE)) {
                     $todo['periodicitynotice'] = Alert::NOTICE;
                 }
                 // Get previous alerts
                 foreach ($todo as $type => $event) {
                     $previous_alerts[$type] = Alert::getAlertDate(__CLASS__, $data['id'], $event);
                 }
                 // compute next alert date based on already send alerts (or not)
                 foreach ($todo as $type => $event) {
                     $next_alerts[$type] = date('Y-m-d', strtotime($data['begin_date'] . " -" . $before . " day"));
                     if ($type == Alert::NOTICE) {
                         $next_alerts[$type] = date('Y-m-d', strtotime($next_alerts[$type] . " -" . $data['notice'] . " month"));
                     }
                     $today_limit = date('Y-m-d', strtotime(date('Y-m-d') . " -" . $data['periodicity'] . " month"));
                     // Init previous by begin date if not set
                     if (empty($previous_alerts[$type])) {
                         $previous_alerts[$type] = $today_limit;
                     }
                     while ($next_alerts[$type] < $previous_alerts[$type] && $next_alerts[$type] < $end_alert) {
                         $next_alerts[$type] = date('Y-m-d', strtotime($next_alerts[$type] . " +" . $data['periodicity'] . " month"));
                     }
                     // If this date is passed : clean alerts and send again
                     if ($next_alerts[$type] <= date('Y-m-d')) {
                         $alert = new Alert();
                         $alert->clear(__CLASS__, $data['id'], $event);
                         $real_alert_date = date('Y-m-d', strtotime($next_alerts[$type] . " +" . $before . " day"));
                         $message = sprintf(__('%1$s: %2$s') . "<br>\n", $data["name"], Html::convDate($real_alert_date));
                         $data['alert_date'] = $real_alert_date;
                         $data['items'] = Contract_Item::getItemsForContract($data['id'], $entity);
                         $contract_infos[$type][$entity][$data['id']] = $data;
                         switch ($type) {
                             case 'periodicitynotice':
                                 $contract_messages[$type][$entity] = __('Contract entered in notice time for period') . "<br>";
                                 break;
                             case 'periodicity':
                                 $contract_messages[$type][$entity] = __('Contract period ended') . "<br>";
                                 break;
                         }
                         $contract_messages[$type][$entity] .= $message;
                     }
                 }
             }
         }
     }
     foreach (array('notice' => Alert::NOTICE, 'end' => Alert::END, 'periodicity' => Alert::PERIODICITY, 'periodicitynotice' => Alert::NOTICE) as $event => $type) {
         if (isset($contract_infos[$event]) && count($contract_infos[$event])) {
             foreach ($contract_infos[$event] as $entity => $contracts) {
                 if (NotificationEvent::raiseEvent($event, new self(), array('entities_id' => $entity, 'items' => $contracts))) {
                     $message = $contract_messages[$event][$entity];
                     $cron_status = 1;
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:contract.class.php

示例5: Alert

 /**
  * @see CommonDBTM::post_updateItem()
  **/
 function post_updateItem($history = 1)
 {
     $alert = new Alert();
     $alert->clear($this->getType(), $this->fields['id'], Alert::ACTION);
     parent::post_updateItem($history);
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:9,代码来源:planningrecall.class.php

示例6: Alert

 function pre_updateInDB()
 {
     // Clean end alert if warranty_date is after old one
     // Or if duration is greater than old one
     if (isset($this->oldvalues['warranty_date']) && $this->oldvalues['warranty_date'] < $this->fields['warranty_date'] || isset($this->oldvalues['warranty_duration']) && $this->oldvalues['warranty_duration'] < $this->fields['warranty_duration']) {
         $alert = new Alert();
         $alert->clear($this->getType(), $this->fields['id'], Alert::END);
     }
     // Check budgets link validity
     if ((in_array('budgets_id', $this->updates) || in_array('buy_date', $this->updates)) && $this->fields['budgets_id'] && ($budget = getItemForItemtype('Budget')) && $budget->getFromDB($this->fields['budgets_id'])) {
         if (!is_null($budget->fields['begin_date']) && $this->fields['buy_date'] < $budget->fields['begin_date'] || !is_null($budget->fields['end_date']) && $this->fields['buy_date'] > $budget->fields['end_date']) {
             $msg = sprintf(__('Purchase date incompatible with the associated budget. %1$s not in budget period: %2$s / %3$s'), Html::convDate($this->fields['buy_date']), Html::convDate($budget->fields['begin_date']), Html::convDate($budget->fields['end_date']));
             Session::addMessageAfterRedirect($msg, false, ERROR);
         }
     }
 }
开发者ID:GeorgeAlexandre,项目名称:glpi,代码行数:16,代码来源:infocom.class.php

示例7: Alert

 function pre_updateInDB()
 {
     // Clean end alert if begin_date is after old one
     // Or if duration is greater than old one
     if (isset($this->oldvalues['begin_date']) && $this->oldvalues['begin_date'] < $this->fields['begin_date'] || isset($this->oldvalues['duration']) && $this->oldvalues['duration'] < $this->fields['duration']) {
         $alert = new Alert();
         $alert->clear($this->getType(), $this->fields['id'], Alert::END);
     }
     // Clean notice alert if begin_date is after old one
     // Or if duration is greater than old one
     // Or if notice is lesser than old one
     if (isset($this->oldvalues['begin_date']) && $this->oldvalues['begin_date'] < $this->fields['begin_date'] || isset($this->oldvalues['duration']) && $this->oldvalues['duration'] < $this->fields['duration'] || isset($this->oldvalues['notice']) && $this->oldvalues['notice'] > $this->fields['notice']) {
         $alert = new Alert();
         $alert->clear($this->getType(), $this->fields['id'], Alert::NOTICE);
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:16,代码来源:contract.class.php


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