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


PHP Infocom::getItemtypesThatCanHave方法代码示例

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


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

示例1: transferSingleSupplier

 /**
  * Transfer an enterprise
  *
  * @param $ID ID of the enterprise
  **/
 function transferSingleSupplier($ID)
 {
     global $DB, $CFG_GLPI;
     // TODO clean system : needed ?
     $ent = new Supplier();
     if ($this->options['keep_supplier'] && $ent->getFromDB($ID)) {
         if (isset($this->noneedtobe_transfer['Supplier'][$ID])) {
             // recursive enterprise
             return $ID;
         }
         if (isset($this->already_transfer['Supplier'][$ID])) {
             // Already transfer
             return $this->already_transfer['Supplier'][$ID];
         }
         $newID = -1;
         // Not already transfer
         $links_remaining = 0;
         // All linked items need to be transfer so transfer enterprise ?
         // Search for contract
         $query = "SELECT COUNT(*) AS cpt\n                   FROM `glpi_contracts_suppliers`\n                   WHERE `suppliers_id` = '{$ID}'\n                         AND `contracts_id` NOT IN " . $this->item_search['Contract'];
         $result_search = $DB->query($query);
         $links_remaining = $DB->result($result_search, 0, 'cpt');
         if ($links_remaining == 0) {
             // Search for infocoms
             if ($this->options['keep_infocom']) {
                 foreach (Infocom::getItemtypesThatCanHave() as $itemtype) {
                     if (isset($this->item_search[$itemtype])) {
                         $query = "SELECT COUNT(*) AS cpt\n                               FROM `glpi_infocoms`\n                               WHERE `suppliers_id` = '{$ID}'\n                                     AND `itemtype` = '{$itemtype}'\n                                     AND `items_id` NOT IN " . $this->item_search[$itemtype];
                         if ($result_search = $DB->query($query)) {
                             $links_remaining += $DB->result($result_search, 0, ' cpt');
                         }
                     }
                 }
             }
         }
         // All linked items need to be transfer -> use unique transfer system
         if ($links_remaining == 0) {
             $this->transferItem('Supplier', $ID, $ID);
             $newID = $ID;
         } else {
             // else Transfer by Copy
             // Is existing item in the destination entity ?
             $query = "SELECT *\n                      FROM `glpi_suppliers`\n                      WHERE `entities_id` = '" . $this->to . "'\n                            AND `name` = '" . addslashes($ent->fields['name']) . "'";
             if ($result_search = $DB->query($query)) {
                 if ($DB->numrows($result_search) > 0) {
                     $newID = $DB->result($result_search, 0, 'id');
                     $this->addToAlreadyTransfer('Supplier', $ID, $newID);
                 }
             }
             // Not found -> transfer copy
             if ($newID < 0) {
                 // 1 - create new item
                 unset($ent->fields['id']);
                 $input = $ent->fields;
                 $input['entities_id'] = $this->to;
                 unset($ent->fields);
                 $newID = $ent->add(toolbox::addslashes_deep($input));
                 // 2 - transfer as copy
                 $this->transferItem('Supplier', $ID, $newID);
             }
             // Founded -> use to link : nothing to do
         }
         return $newID;
     }
     return 0;
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:71,代码来源:transfer.class.php

示例2: plugin_example_postinit

function plugin_example_postinit()
{
    global $CFG_GLPI;
    // All plugins are initialized, so all types are registered
    foreach (Infocom::getItemtypesThatCanHave() as $type) {
        // do something
    }
}
开发者ID:pluginsGLPI,项目名称:example,代码行数:8,代码来源:hook.php


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