本文整理汇总了PHP中Search::isInfocomOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::isInfocomOption方法的具体用法?PHP Search::isInfocomOption怎么用?PHP Search::isInfocomOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::isInfocomOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processMassiveActionsForOneItemtype
/**
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $CFG_GLPI;
$action = $ma->getAction();
switch ($action) {
case 'delete':
foreach ($ids as $id) {
if ($item->can($id, DELETE)) {
if ($item->delete(array("id" => $id))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'restore':
foreach ($ids as $id) {
if ($item->can($id, PURGE)) {
if ($item->restore(array("id" => $id))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'purge_item_but_devices':
case 'purge_but_item_linked':
case 'purge':
foreach ($ids as $id) {
if ($item->can($id, PURGE)) {
$force = 1;
// Only mark deletion for
if ($item->maybeDeleted() && $item->useDeletedToLockIfDynamic() && $item->isDynamic()) {
$force = 0;
}
$delete_array = array('id' => $id);
if ($action == 'purge_item_but_devices') {
$delete_array['keep_devices'] = true;
}
if ($item instanceof CommonDropdown) {
if ($item->haveChildren()) {
if ($action != 'purge_but_item_linked') {
$force = 0;
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage(__("You can't delete that item by massive actions, because it has sub-items"));
$ma->addMessage(__("but you can do it by the form of the item"));
continue;
}
}
if ($item->isUsed()) {
if ($action != 'purge_but_item_linked') {
$force = 0;
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage(__("You can't delete that item, because it is used for one or more items"));
$ma->addMessage(__("but you can do it by the form of the item"));
continue;
}
}
}
if ($item->delete($delete_array, $force)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'update':
if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
return false;
}
$index = $ma->POST['search_options'][$item->getType()];
$searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
$input = $ma->POST;
if (isset($searchopt[$index])) {
/// Infocoms case
if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$index]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
//.........这里部分代码省略.........
示例2:
$items_in_group = 0;
$newgroup = "";
if (!$first_group) {
$newgroup .= "</optgroup>";
}
$newgroup .= "<optgroup label=\"{$val}\">";
} else {
// No id and no entities_id massive action and no first item
if ($val["field"] != 'id' && $key != 1 && ($val["linkfield"] != 'entities_id' || isset($val['massiveaction']) && $val['massiveaction'])) {
if (!isset($val['massiveaction']) || $val['massiveaction']) {
if ($show_all) {
$newgroup .= "<option value='{$key}'>" . $val["name"] . "</option>";
$items_in_group++;
} else {
// Do not show infocom items
if ($show_infocoms && Search::isInfocomOption($_POST["itemtype"], $key) || !$show_infocoms && !Search::isInfocomOption($_POST["itemtype"], $key)) {
$newgroup .= "<option value='{$key}'>" . $val["name"] . "</option>";
$items_in_group++;
}
}
}
}
}
}
if (!empty($newgroup) && $items_in_group > 0) {
echo $newgroup;
}
if (!$first_group) {
echo "</optgroup>";
}
echo "</select>";
示例3: foreach
$item->delete(array("id" => $key), 1);
}
}
break;
case "restore":
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$item->restore(array("id" => $key));
}
}
break;
case "update":
$searchopt = Search::getCleanedOptions($_POST["itemtype"], 'w');
if (isset($searchopt[$_POST["id_field"]])) {
/// Infocoms case
if (!isPluginItemType($_POST["itemtype"]) && Search::isInfocomOption($_POST["itemtype"], $_POST["id_field"])) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$_POST["id_field"]]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($_POST[$_POST["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
}
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
if ($item->getFromDB($key)) {
if ($link_entity_type < 0 || $link_entity_type == $item->getEntityID() || $ent->fields["is_recursive"] && in_array($link_entity_type, getAncestorsOf("glpi_entities", $item->getEntityID()))) {
// Add infocom if not exists
if (!$ic->getFromDBforDevice($_POST["itemtype"], $key)) {
示例4: doMassiveActions
/**
* Do the standard massive actions
*
* @since version 0.84
*
* This must not be overloaded in Class
* @param $input array of input datas
*
* @return an array of results (ok, ko, noright counts, may include REDIRECT field to set REDIRECT page)
**/
function doMassiveActions($input = array())
{
global $CFG_GLPI;
if (!isset($input["item"]) || count($input["item"]) == 0) {
return false;
}
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case 'add_document':
case 'remove_document':
$doc = new Document();
return $doc->doSpecificMassiveActions($input);
case "add_transfer_list":
if (!isset($_SESSION['glpitransfer_list'])) {
$_SESSION['glpitransfer_list'] = array();
}
if (!isset($_SESSION['glpitransfer_list'][$input["itemtype"]])) {
$_SESSION['glpitransfer_list'][$input["itemtype"]] = array();
}
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
$_SESSION['glpitransfer_list'][$input["itemtype"]][$key] = $key;
$res['ok']++;
}
}
$res['REDIRECT'] = $CFG_GLPI['root_doc'] . '/front/transfer.action.php';
break;
case "delete":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
if ($this->delete(array("id" => $key))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "purge":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
$force = 1;
// Only mark deletion for
if ($this->maybeDeleted() && $this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
$force = 0;
}
if ($this->delete(array("id" => $key), $force)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "restore":
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'd')) {
if ($this->restore(array("id" => $key))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
break;
case "update":
$searchopt = Search::getCleanedOptions($input["itemtype"], 'w');
if (isset($searchopt[$input["id_field"]])) {
/// Infocoms case
if (!isPluginItemType($input["itemtype"]) && Search::isInfocomOption($input["itemtype"], $input["id_field"])) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$input["id_field"]]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
//.........这里部分代码省略.........