/**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginBadgesBadge') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginBadgesBadgeType::transfer($item->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_badges_badgetypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
     }
 }
Esempio n. 2
0
function plugin_badges_getDropdown()
{
    $plugin = new Plugin();
    if ($plugin->isActivated("badges")) {
        return array("PluginBadgesBadgeType" => PluginBadgesBadgeType::getTypeName(2));
    } else {
        return array();
    }
}
Esempio n. 3
0
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "Transfert":
             if ($input['itemtype'] == 'PluginBadgesBadge') {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $badge = new PluginBadgesBadge();
                         $badge->getFromDB($key);
                         $type = PluginBadgesBadgeType::transfer($badge->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                         if ($type > 0) {
                             $values["id"] = $key;
                             $values["plugin_badges_badgetypes_id"] = $type;
                             if ($badge->update($values)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         }
                         unset($values);
                         $values["id"] = $key;
                         $values["entities_id"] = $input['entities_id'];
                         if ($badge->update($values)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }