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


PHP Infocom::manageDateOnStatusChange方法代码示例

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


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

示例1: update

 /**
  * Update some elements of an item in the database.
  *
  * @param $input array : the _POST vars returned by the item form when press update
  * @param $history boolean : do history log ?
  * @param options an array with the insert options
  *
  * @return boolean : true on success
  **/
 function update($input, $history = 1, $options = array())
 {
     global $DB, $CFG_GLPI;
     if ($DB->isSlave()) {
         return false;
     }
     if (!$this->getFromDB($input[$this->getIndexName()])) {
         return false;
     }
     // Store input in the object to be available in all sub-method / hook
     $this->input = $input;
     // Plugin hook - $this->input can be altered
     doHook("pre_item_update", $this);
     if ($this->input && is_array($this->input)) {
         $this->input = $this->prepareInputForUpdate($this->input);
         if (isset($this->input['update'])) {
             $this->input['_update'] = $this->input['update'];
             unset($this->input['update']);
         }
         $this->filterValues();
     }
     // Valid input for update
     if ($this->checkUnicity(false, $options)) {
         if ($this->input && is_array($this->input)) {
             // Fill the update-array with changes
             $x = 0;
             $this->updates = array();
             $this->oldvalues = array();
             foreach ($this->input as $key => $val) {
                 if (array_key_exists($key, $this->fields)) {
                     // Prevent history for date statement (for date for example)
                     if (is_null($this->fields[$key]) && $this->input[$key] == 'NULL') {
                         $this->fields[$key] = 'NULL';
                     }
                     if (mysql_real_escape_string($this->fields[$key]) != $this->input[$key]) {
                         if ($key != "id") {
                             // Store old values
                             if (!in_array($key, $this->history_blacklist)) {
                                 $this->oldvalues[$key] = $this->fields[$key];
                             }
                             $this->fields[$key] = $this->input[$key];
                             $this->updates[$x] = $key;
                             $x++;
                         }
                     }
                 }
             }
             if (count($this->updates)) {
                 if (array_key_exists('date_mod', $this->fields)) {
                     // is a non blacklist field exists
                     if (count(array_diff($this->updates, $this->history_blacklist)) > 0) {
                         $this->fields['date_mod'] = $_SESSION["glpi_currenttime"];
                         $this->updates[$x++] = 'date_mod';
                     }
                 }
                 $this->pre_updateInDB();
                 if (count($this->updates)) {
                     if ($this->updateInDB($this->updates, $this->dohistory && $history ? $this->oldvalues : array())) {
                         $this->addMessageOnUpdateAction();
                         doHook("item_update", $this);
                         // forward entity information if needed
                         if (count($this->forward_entity_to) && (in_array("entities_id", $this->updates) || in_array("is_recursive", $this->updates))) {
                             $this->forwardEntityInformations();
                         }
                         // If itemtype is in infocomtype and if states_id field is filled
                         // and item not a template
                         if (in_array($this->getType(), $CFG_GLPI["infocom_types"]) && in_array('states_id', $this->updates) && $this->getField('is_template') != NOT_AVAILABLE) {
                             //Check if we have to automatical fill dates
                             Infocom::manageDateOnStatusChange($this, false);
                         }
                     }
                 }
             }
             $this->post_updateItem($history);
             return true;
         }
     }
     return false;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:88,代码来源:commondbtm.class.php

示例2: update


//.........这里部分代码省略.........
     Plugin::doHook("pre_item_update", $this);
     if ($this->input && is_array($this->input)) {
         $this->input = $this->prepareInputForUpdate($this->input);
         if (isset($this->input['update'])) {
             $this->input['_update'] = $this->input['update'];
             unset($this->input['update']);
         }
         $this->filterValues(!isCommandLine());
     }
     // Valid input for update
     if ($this->checkUnicity(false, $options)) {
         if ($this->input && is_array($this->input)) {
             // Fill the update-array with changes
             $x = 0;
             $this->updates = array();
             $this->oldvalues = array();
             foreach ($this->input as $key => $val) {
                 if (array_key_exists($key, $this->fields)) {
                     // Prevent history for date statement (for date for example)
                     if (is_null($this->fields[$key]) && $this->input[$key] == 'NULL') {
                         $this->fields[$key] = 'NULL';
                     }
                     // Compare item
                     $ischanged = true;
                     $searchopt = $this->getSearchOptionByField('field', $key, $this->getTable());
                     if (isset($searchopt['datatype'])) {
                         switch ($searchopt['datatype']) {
                             case 'string':
                             case 'text':
                                 $ischanged = strcmp($DB->escape($this->fields[$key]), $this->input[$key]) != 0;
                                 break;
                             case 'itemlink':
                                 if ($key == 'name') {
                                     $ischanged = strcmp($DB->escape($this->fields[$key]), $this->input[$key]) != 0;
                                     break;
                                 }
                                 // else default
                             // else default
                             default:
                                 $ischanged = $DB->escape($this->fields[$key]) != $this->input[$key];
                                 break;
                         }
                     } else {
                         // No searchoption case
                         $ischanged = $DB->escape($this->fields[$key]) != $this->input[$key];
                     }
                     if ($ischanged) {
                         if ($key != "id") {
                             // Store old values
                             if (!in_array($key, $this->history_blacklist)) {
                                 $this->oldvalues[$key] = $this->fields[$key];
                             }
                             $this->fields[$key] = $this->input[$key];
                             $this->updates[$x] = $key;
                             $x++;
                         }
                     }
                 }
             }
             if (count($this->updates)) {
                 if (array_key_exists('date_mod', $this->fields)) {
                     // is a non blacklist field exists
                     if (count(array_diff($this->updates, $this->history_blacklist)) > 0) {
                         $this->fields['date_mod'] = $_SESSION["glpi_currenttime"];
                         $this->updates[$x++] = 'date_mod';
                     }
                 }
                 $this->pre_updateInDB();
                 if (count($this->updates)) {
                     if ($this->updateInDB($this->updates, $this->dohistory && $history ? $this->oldvalues : array())) {
                         $this->addMessageOnUpdateAction();
                         Plugin::doHook("item_update", $this);
                         //Fill forward_entity_to array with itemtypes coming from plugins
                         if (isset(self::$plugins_forward_entity[$this->getType()])) {
                             foreach (self::$plugins_forward_entity[$this->getType()] as $itemtype) {
                                 static::$forward_entity_to[] = $itemtype;
                             }
                         }
                         // forward entity information if needed
                         if (count(static::$forward_entity_to) && (in_array("entities_id", $this->updates) || in_array("is_recursive", $this->updates))) {
                             $this->forwardEntityInformations();
                         }
                         // If itemtype is in infocomtype and if states_id field is filled
                         // and item not a template
                         if (InfoCom::canApplyOn($this) && in_array('states_id', $this->updates) && $this->getField('is_template') != NOT_AVAILABLE) {
                             //Check if we have to automatical fill dates
                             Infocom::manageDateOnStatusChange($this, false);
                         }
                     }
                 }
             }
             $this->post_updateItem($history);
             if ($this->mailqueueonaction) {
                 QueuedMail::forceSendFor($this->getType(), $this->fields['id']);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:101,代码来源:commondbtm.class.php


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