/** * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($input['action']) { case "assign_vlan": if (!empty($input["vlans_id"])) { $networkportvlan = new NetworkPort_Vlan(); foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($this->can($key, 'w')) { if ($networkportvlan->assignVlan($key, $input["vlans_id"], isset($input['tagged']) ? '1' : '0')) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } } else { $res['ko']++; } break; case "unassign_vlan": if (!empty($input["vlans_id"])) { $networkportvlan = new NetworkPort_Vlan(); foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($this->can($key, 'w')) { if ($networkportvlan->unassignVlan($key, $input["vlans_id"])) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } } else { $nbko++; } break; // Interest of this massive action ? Replace switch by another : don't re-create manually all ports // Interest of this massive action ? Replace switch by another : don't re-create manually all ports case "move_port": if (isset($input["items_id"]) && !empty($input["items_id"])) { foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($this->getFromDB($key)) { $input2 = array(); $input2['id'] = $key; $input2['items_id'] = $input["items_id"]; $input2['itemtype'] = 'NetworkEquipment'; if ($this->can($input2['id'], 'w')) { if ($this->update($input2)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } else { $res['ko']++; } } } } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); } return $res; }
/** * @since version 0.84 * * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); // print_r($input);exit(); switch ($input['action']) { case "give": if ($input["give_items_id"] > 0 && !empty($input['give_itemtype'])) { foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($this->can($key, 'w')) { if ($this->out($key, $input['give_itemtype'], $input["give_items_id"])) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } if ($item = getItemForItemtype($input['give_itemtype'])) { Event::log($input["consumableitems_id"], "consumables", 5, "inventory", sprintf(__('%s gives a consumable'), $_SESSION["glpiname"])); } } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); } return $res; }
/** * @since version 0.84 * * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($input['action']) { case "uninstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($this->can($key, 'w')) { if ($this->uninstall($key)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } break; case "updatepages": if (isset($input['pages'])) { foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($this->can($key, 'w')) { if ($this->update(array('id' => $key, 'pages' => $input['pages']))) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); } return $res; }
/** * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($input['action']) { case "transform_to": if (isset($input["transform_to"]) && !empty($input["transform_to"])) { $networkport = new NetworkPort(); foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($networkport->can($key, 'w') && $this->can($key, 'd')) { // Don't try to migrate already affected ports if (empty($networkport->fields['instantiation_type'])) { if ($networkport->switchInstantiationType($input['transform_to']) !== false) { $instantiation = $networkport->getInstantiation(); $input2 = $this->fields; $input2['networkports_id'] = $input2['id']; unset($input2['id']); if ($instantiation->add($input2)) { $this->delete(array('id' => $key)); $res['ok']++; } else { $res['ko']++; } } else { $res['ko']++; } } else { $res['ko']++; } } else { $res['noright']++; } } } } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); } return $res; }