CommonDBTM::processMassiveActionsForOneItemtype PHP Method

processMassiveActionsForOneItemtype() static public method

Class specific execution of the massive action (new system) by itemtypes
static public processMassiveActionsForOneItemtype ( MassiveAction $ma, CommonDBTM $item, array $ids ) : nothing
$ma MassiveAction the current massive action object
$item CommonDBTM the item on which apply the massive action
$ids array an array of the ids of the item on which apply the action
return nothing (direct submit to $ma object)
    static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
    {
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @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);
 }
All Usage Examples Of CommonDBTM::processMassiveActionsForOneItemtype
CommonDBTM