本文整理匯總了PHP中CommonDropdown::processMassiveActionsForOneItemtype方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonDropdown::processMassiveActionsForOneItemtype方法的具體用法?PHP CommonDropdown::processMassiveActionsForOneItemtype怎麽用?PHP CommonDropdown::processMassiveActionsForOneItemtype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonDropdown
的用法示例。
在下文中一共展示了CommonDropdown::processMassiveActionsForOneItemtype方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'duplicate':
// For calendar duplicate in another entity
if (method_exists($item, 'duplicate')) {
$input = $ma->getInput();
$options = array();
if ($item->isEntityAssign()) {
$options = array('entities_id' => $input['entities_id']);
}
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
if (!$item->isEntityAssign() || $input['entities_id'] != $item->getEntityID()) {
if ($item->can(-1, CREATE, $options)) {
if ($item->duplicate($options)) {
$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));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例2: processMassiveActionsForOneItemtype
/**
* @since version 0.90
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'merge':
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item->getEntityID() == $_SESSION['glpiactive_entity']) {
if ($item->update(array('id' => $key, 'is_recursive' => 1))) {
$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 {
$input2 = $item->fields;
// Change entity
$input2['entities_id'] = $_SESSION['glpiactive_entity'];
$input2['is_recursive'] = 1;
$input2 = Toolbox::addslashes_deep($input2);
if (!$item->import($input2)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
}
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例3: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'duplicate':
// For calendar duplicate in another entity
if (method_exists($item, 'duplicate')) {
$input = $ma->getInput();
$options = array();
if ($item->isEntityAssign()) {
$options = array('entities_id' => $input['entities_id']);
}
foreach ($ids as $id) {
if ($item->getFromDB($id)) {
if (!$item->isEntityAssign() || $input['entities_id'] != $item->getEntityID()) {
if ($item->can(-1, CREATE, $options)) {
if ($item->duplicate($options)) {
$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));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
case 'addholiday':
// add an holiday with massive action
$input = $ma->getInput();
if ($input['holidays_id'] > 0) {
$holiday = new Holiday();
$calendar_holiday = new Calendar_Holiday();
$holiday->getFromDB($input['holidays_id']);
$entities = array($holiday->getEntityID() => $holiday->getEntityID());
if ($holiday->isRecursive()) {
$entities = getSonsOf("glpi_entities", $holiday->getEntityID());
}
foreach ($ids as $id) {
$entities_id = CommonDBTM::getItemEntity('Calendar', $id);
if (isset($entities[$entities_id])) {
$input = array('calendars_id' => $id, 'holidays_id' => $input['holidays_id']);
if ($calendar_holiday->add($input)) {
$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_ON_ACTION));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例4: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
* @param MassiveAction $ma
* @param CommonDBTM $item
* @param array $ids
* @return nothing|void
*/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
$notimport = new PluginOcsinventoryngNotimportedcomputer();
switch ($ma->getAction()) {
case "plugin_ocsinventoryng_import":
$input = $ma->getInput();
foreach ($ids as $id) {
if (PluginOcsinventoryngNotimportedcomputer::computerImport(array('id' => $id, 'force' => true, 'entity' => $input['entity']))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
}
return;
case "plugin_ocsinventoryng_replayrules":
foreach ($ids as $id) {
if (PluginOcsinventoryngNotimportedcomputer::computerImport(array('id' => $id))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
}
return;
case "plugin_ocsinventoryng_delete":
foreach ($ids as $id) {
if ($notimport->deleteNotImportedComputer($id)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例5: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
$input = $ma->getInput();
switch ($ma->getAction()) {
case 'move_under':
if (isset($input['parent'])) {
$fk = $item->getForeignKeyField();
$parent = clone $item;
if (!$parent->getFromDB($input['parent'])) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($parent->getErrorMessage(ERROR_NOT_FOUND));
return;
}
foreach ($ids as $id) {
if ($item->can($id, UPDATE)) {
// Check if parent is not a child of the original one
if (!in_array($parent->getID(), getSonsOf($item->getTable(), $item->getID()))) {
if ($item->update(array('id' => $id, $fk => $parent->getID()))) {
$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_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
$ma->addMessage($parent->getErrorMessage(ERROR_COMPAT));
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}