/** * Do the specific massive actions * * @since version 0.84 * * @param $input array of input datas * * @return an array of results (nbok, nbko, nbnoright counts) **/ public function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $route_item = new PluginRoutetablesRoutetable_Item(); switch ($input['action']) { case 'Duplicate': if ($input['itemtype'] == 'PluginRoutetablesRoutetable') { foreach ($input['item'] as $key => $val) { if ($val == 1) { if ($this->getFromDB($key)) { unset($this->fields["id"]); $this->fields["entities_id"] = $input["entities_id"]; if ($newID = $this->add($this->fields)) { $res['ok']++; } else { $res['ko']++; } } else { $res['ko']++; } } } } break; case "Install": foreach ($input["item"] as $key => $val) { if ($val == 1) { $values = array('plugin_routetables_routetables_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($route_item->can(-1, 'w', $input)) { if ($route_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($route_item->deleteItemByRoutetablesAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; case "Transfert": if ($input['itemtype'] == 'PluginRoutetablesRoutetable') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($this->update($values)) { $res['ok']++; } else { $res['ko']++; } } } } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }
function plugin_routetables_MassiveActionsProcess($data) { $route_item = new PluginRoutetablesRoutetable_Item(); $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($data['action']) { case "plugin_routetables_add_item": foreach ($data["item"] as $key => $val) { if ($val == 1) { $input = array('plugin_routetables_routetables_id' => $data['plugin_routetables_routetables_id'], 'items_id' => $key, 'itemtype' => $data['itemtype']); if ($route_item->can(-1, 'w', $input)) { if ($route_item->add($input)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } break; } return $res; }