本文整理匯總了PHP中MassiveAction::setRedirect方法的典型用法代碼示例。如果您正苦於以下問題:PHP MassiveAction::setRedirect方法的具體用法?PHP MassiveAction::setRedirect怎麽用?PHP MassiveAction::setRedirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MassiveAction
的用法示例。
在下文中一共展示了MassiveAction::setRedirect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'duplicate':
$rulecollection = new RuleCollection();
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
if ($rulecollection->duplicateRule($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_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
break;
case 'export':
if (count($ids)) {
$_SESSION['exportitems'] = $ids;
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
$ma->setRedirect('rule.backup.php?action=download&itemtype=' . $item->getType());
}
break;
case 'move_rule':
$input = $ma->getInput();
$collectionname = $input['rule_class_name'] . 'Collection';
$rulecollection = new $collectionname();
if ($rulecollection->canUpdate()) {
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
if ($rulecollection->moveRule($id, $input['ranking'], $input['move_type'])) {
$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_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
break;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例2: processMassiveActionsForOneItemtype
//.........這裏部分代碼省略.........
$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"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
}
foreach ($ids as $key) {
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()))) {
$input2["items_id"] = $key;
$input2["itemtype"] = $item->getType();
if ($ic->can(-1, CREATE, $input2)) {
// Add infocom if not exists
if (!$ic->getFromDBforDevice($item->getType(), $key)) {
$input2["items_id"] = $key;
$input2["itemtype"] = $item->getType();
unset($ic->fields);
$ic->add($input2);
$ic->getFromDBforDevice($item->getType(), $key);
}
$id = $ic->fields["id"];
unset($ic->fields);
if ($ic->update(array('id' => $id, $input["field"] => $input[$input["field"]]))) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
} else {
/// Not infocoms
$link_entity_type = array();
/// Specific entity item
$itemtable = getTableForItemType($item->getType());
$itemtype2 = getItemTypeForTable($searchopt[$index]["table"]);
if ($item2 = getItemForItemtype($itemtype2)) {
if ($index != 80 && $searchopt[$index]["table"] != $itemtable && $item2->isEntityAssign() && $item->isEntityAssign()) {
if ($item2->getFromDB($input[$input["field"]])) {
if (isset($item2->fields["entities_id"]) && $item2->fields["entities_id"] >= 0) {
if (isset($item2->fields["is_recursive"]) && $item2->fields["is_recursive"]) {
$link_entity_type = getSonsOf("glpi_entities", $item2->fields["entities_id"]);
} else {
$link_entity_type[] = $item2->fields["entities_id"];
}
}
}
}
}
foreach ($ids as $key) {
if ($item->canEdit($key) && $item->canMassiveAction($action, $input['field'], $input[$input["field"]])) {
if (count($link_entity_type) == 0 || in_array($item->fields["entities_id"], $link_entity_type)) {
if ($item->update(array('id' => $key, $input["field"] => $input[$input["field"]]))) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
}
}
break;
case 'add_transfer_list':
$itemtype = $item->getType();
if (!isset($_SESSION['glpitransfer_list'])) {
$_SESSION['glpitransfer_list'] = array();
}
if (!isset($_SESSION['glpitransfer_list'][$itemtype])) {
$_SESSION['glpitransfer_list'][$itemtype] = array();
}
foreach ($ids as $id) {
$_SESSION['glpitransfer_list'][$itemtype][$id] = $id;
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
}
$ma->setRedirect($CFG_GLPI['root_doc'] . '/front/transfer.action.php');
break;
}
}