You should have received a copy of the GNU General Public License along with Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } if (!isset($_GET["plugin_resources_resources_id"])) { $_GET["plugin_resources_resources_id"] = 0; } $task = new PluginResourcesTask(); $task_item = new PluginResourcesTask_Item(); //add tasks if (isset($_POST['add'])) { $task->check(-1, 'w', $_POST); $newID = $task->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $task->check($_POST['id'], 'w'); $task->update($_POST); //no sending mail here : see post_updateItem of PluginResourcesTask Html::back(); } else { if (isset($_POST["delete"])) { $task->check($_POST['id'], 'w'); $task->delete($_POST);
function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $task_item = new PluginResourcesTask_Item(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginResourcesTask') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']); if ($tasktype > 0) { $values["id"] = $key; $values["plugin_resources_tasktypes_id"] = $tasktype; $PluginResourcesTask->update($values); } unset($values); $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($this->update($values)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Duplicate": if ($input['itemtype'] == 'PluginResourcesTask') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); unset($this->fields["id"]); $this->fields["name"] = addslashes($this->fields["name"]); $this->fields["comment"] = addslashes($this->fields["comment"]); if ($this->add($this->fields)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Install": foreach ($input["item"] as $key => $val) { if ($val == 1) { $values = array('plugin_resources_tasks_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($task_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($task_item->deleteItemByTaskAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }
/** * Hook called After an item is purge */ static function cleanForItem(CommonDBTM $item) { $type = get_class($item); $temp = new PluginResourcesResource_Item(); $temp->deleteByCriteria(array('itemtype' => $type, 'items_id' => $item->getField('id'))); $task = new PluginResourcesTask_Item(); $task->deleteByCriteria(array('itemtype' => $type, 'items_id' => $item->getField('id'))); }