本文整理汇总了PHP中CommonDBTM::restore方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::restore方法的具体用法?PHP CommonDBTM::restore怎么用?PHP CommonDBTM::restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::restore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"]])) {
//.........这里部分代码省略.........