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


PHP Infocom::canApplyOn方法代码示例

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


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

示例1: add

 /**
  * Add an item in the database with all it's items.
  *
  * @param $input     array    the _POST vars returned by the item form when press add
  * @param options    array    with the insert options
  *   - unicity_message : do not display message if item it a duplicate (default is yes)
  * @param $history   boolean  do history log ? (true by default)
  *
  * @return integer the new ID of the added item (or false if fail)
  **/
 function add(array $input, $options = array(), $history = true)
 {
     global $DB, $CFG_GLPI;
     if ($DB->isSlave()) {
         return false;
     }
     // Store input in the object to be available in all sub-method / hook
     $this->input = $input;
     if (isset($this->input['add'])) {
         // Input from the interface
         // Save this data to be available if add fail
         $this->saveInput();
     }
     // Call the plugin hook - $this->input can be altered
     // This hook get the data from the form, not yet altered
     Plugin::doHook("pre_item_add", $this);
     if ($this->input && is_array($this->input)) {
         if (isset($this->input['add'])) {
             $this->input['_add'] = $this->input['add'];
             unset($this->input['add']);
         }
         $this->input = $this->prepareInputForAdd($this->input);
     }
     if ($this->input && is_array($this->input)) {
         // Call the plugin hook - $this->input can be altered
         // This hook get the data altered by the object method
         Plugin::doHook("post_prepareadd", $this);
     }
     if ($this->input && is_array($this->input)) {
         //Check values to inject
         $this->filterValues(!isCommandLine());
     }
     if ($this->input && is_array($this->input)) {
         $this->fields = array();
         $table_fields = $DB->list_fields($this->getTable());
         // fill array for add
         foreach ($this->input as $key => $val) {
             if ($key[0] != '_' && isset($table_fields[$key])) {
                 $this->fields[$key] = $this->input[$key];
             }
         }
         // Auto set date_mod if exsist
         if (isset($table_fields['date_mod'])) {
             $this->fields['date_mod'] = $_SESSION["glpi_currenttime"];
         }
         if ($this->checkUnicity(true, $options)) {
             if ($this->addToDB()) {
                 $this->post_addItem();
                 $this->addMessageOnAddAction();
                 if ($this->dohistory && $history) {
                     $changes[0] = 0;
                     $changes[1] = $changes[2] = "";
                     Log::history($this->fields["id"], $this->getType(), $changes, 0, Log::HISTORY_CREATE_ITEM);
                 }
                 // Auto create infocoms
                 if (isset($CFG_GLPI["auto_create_infocoms"]) && $CFG_GLPI["auto_create_infocoms"] && Infocom::canApplyOn($this)) {
                     $ic = new Infocom();
                     if (!$ic->getFromDBforDevice($this->getType(), $this->fields['id'])) {
                         $ic->add(array('itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
                     }
                 }
                 // If itemtype is in infocomtype and if states_id field is filled
                 // and item is not a template
                 if (InfoCom::canApplyOn($this) && isset($this->input['states_id']) && (!isset($this->input['is_template']) || !$this->input['is_template'])) {
                     //Check if we have to automatical fill dates
                     Infocom::manageDateOnStatusChange($this);
                 }
                 Plugin::doHook("item_add", $this);
                 // As add have suceed, clean the old input value
                 if (isset($this->input['_add'])) {
                     $this->clearSavedInput();
                 }
                 if ($this->mailqueueonaction) {
                     QueuedMail::forceSendFor($this->getType(), $this->fields['id']);
                 }
                 return $this->fields['id'];
             }
         }
     }
     $this->last_status = self::NOTHING_TO_DO;
     return false;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:92,代码来源:commondbtm.class.php


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