本文整理汇总了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;
}
示例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
}
}