本文整理汇总了PHP中MassiveAction::getItemtype方法的典型用法代码示例。如果您正苦于以下问题:PHP MassiveAction::getItemtype方法的具体用法?PHP MassiveAction::getItemtype怎么用?PHP MassiveAction::getItemtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MassiveAction
的用法示例。
在下文中一共展示了MassiveAction::getItemtype方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case "uninstall":
$itemtype = $ma->getItemtype(false);
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
//Session::addMessageAfterRedirect(sprintf(__('Form duplicated: %s', 'formcreator'), $item->getName()));
$_SESSION['glpi_uninstalllist'][$itemtype][$id] = $id;
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
}
}
Html::redirect($CFG_GLPI["root_doc"] . '/plugins/uninstall/front/action.php?device_type=' . $itemtype . "&model_id=" . $_POST["model_id"]);
return;
break;
}
return;
}
示例2: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'add_task':
$itemtype = $ma->getItemtype(true);
$tasktype = $itemtype . 'Task';
if ($ttype = getItemForItemtype($tasktype)) {
$ttype->showFormMassiveAction();
return true;
}
return false;
case 'add_actor':
$types = array(0 => Dropdown::EMPTY_VALUE, CommonITILActor::REQUESTER => __('Requester'), CommonITILActor::OBSERVER => __('Watcher'), CommonITILActor::ASSIGN => __('Assigned to'));
$rand = Dropdown::showFromArray('actortype', $types);
$paramsmassaction = array('actortype' => '__VALUE__');
Ajax::updateItemOnSelectEvent("dropdown_actortype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAddActor.php", $paramsmassaction);
echo "<span id='show_massiveaction_field'> </span>\n";
return true;
case 'update_notif':
Dropdown::showYesNo('use_notification');
echo "<br><br>";
echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
return true;
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
示例3: showMassiveActionsSubForm
/**
* Main entry of the modal window for massive actions
*
* @return nothing: display
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
$PluginShellcommandsShellcommand = new PluginShellcommandsShellcommand();
switch ($ma->getAction()) {
case 'generate':
$itemtype = $ma->getItemtype(false);
if (in_array($itemtype, PluginShellcommandsShellcommand::getTypes(true))) {
echo PluginShellcommandsCommandGroup::getTypeName(1) . " ";
Dropdown::show('PluginShellcommandsCommandGroup', array('name' => 'commandgroup', 'entity' => $_SESSION['glpiactive_entity'], 'comments' => false));
echo "<br><br>";
}
break;
}
return false;
}
示例4: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
$itemtype = $ma->getItemtype(false);
$item = new PluginConsumablesRequest();
$validation = new PluginConsumablesValidation();
$consumable = new Consumable();
$input = $ma->getInput();
if (count($ids)) {
switch ($ma->getAction()) {
case "validate":
foreach ($ids as $key => $val) {
if ($item->can($key, UPDATE)) {
$item->getFromDB($key);
// Get available consumables
$outConsumable = array();
$availables = $consumable->find("`consumableitems_id` = '" . $item->fields['consumables_id'] . "' AND `items_id` = 0");
foreach ($availables as $available) {
$outConsumable[] = $available;
}
// Check if enough stock
if (!empty($outConsumable) && count($outConsumable) >= $item->fields['number']) {
// Give consumable
$result = array(1);
for ($i = 0; $i < $item->fields['number']; $i++) {
if (isset($outConsumable[$i]) && $consumable->out($outConsumable[$i]['id'], $item->fields['give_itemtype'], $item->fields['give_items_id'])) {
$result[] = 1;
} else {
$result[] = 0;
}
}
if (!in_array(0, $result)) {
// Validation status update
$validation->validationConsumable($item->fields, CommonITILValidation::ACCEPTED);
// Send notification
NotificationEvent::raiseEvent(PluginConsumablesNotificationTargetRequest::CONSUMABLE_RESPONSE, $item, array('entities_id' => $_SESSION['glpiactive_entity'], 'consumablerequest' => $item->fields, 'comment' => $input['comment']));
$ma->addMessage("<span style='color:green'>" . sprintf(__('Consumable %s validated', 'consumables'), Dropdown::getDropdownName("glpi_consumableitems", $item->fields['consumables_id'])) . "</span>");
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_KO);
}
} else {
$ma->addMessage(sprintf(__('Not enough stock for consumable %s', 'consumables'), Dropdown::getDropdownName("glpi_consumableitems", $item->fields['consumables_id'])));
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_KO);
}
} else {
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($validation->getErrorMessage(ERROR_RIGHT));
}
}
break;
case "refuse":
foreach ($ids as $key => $val) {
if ($item->can($key, UPDATE)) {
// Validation status update
if ($validation->validationConsumable($item->fields, CommonITILValidation::REFUSED)) {
// Send notification
NotificationEvent::raiseEvent(PluginConsumablesNotificationTargetRequest::CONSUMABLE_RESPONSE, $item, array('entities_id' => $_SESSION['glpiactive_entity'], 'consumablerequest' => $item->fields, 'comment' => $input['comment']));
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_OK);
$ma->addMessage(__('Consumable refused', 'consumables'));
} else {
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_KO);
}
} else {
$ma->itemDone($validation->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($validation->getErrorMessage(ERROR_RIGHT));
}
}
break;
default:
return parent::doSpecificMassiveActions($ma->POST);
}
}
}
示例5: showMassiveActionsSubForm
static function showMassiveActionsSubForm(MassiveAction $ma)
{
switch ($ma->getAction()) {
case "install":
Dropdown::showItemTypes("item_item", self::getTypes(true));
echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
return true;
break;
case "uninstall":
Dropdown::showItemTypes("item_item", self::getTypes(true));
echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
return true;
break;
case 'generate':
$PluginShellcommandsShellcommand = new PluginShellcommandsShellcommand();
$itemtype = $ma->getItemtype(false);
if (in_array($itemtype, PluginShellcommandsShellcommand::getTypes(true))) {
$PluginShellcommandsShellcommand->dropdownCommands($itemtype);
echo "<br><br>";
}
break;
}
return parent::showMassiveActionsSubForm($ma);
}