public static function deleteItem($pack) { $item = dbconnection::queryObject("SELECT * FROM items WHERE item_id = '{$pack->item_id}'"); $pack->auth->game_id = $item->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM items WHERE item_id = '{$pack->item_id}' LIMIT 1"); //cleanup $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_ITEM' AND link_id = '{$pack->item_id}'"); for ($i = 0; $i < count($options); $i++) { $pack->dialog_option_id = $options[$i]->dialog_option_id; dialogs::deleteDialogOption($pack); } $tabs = dbconnection::queryArray("SELECT * FROM tabs WHERE type = 'ITEM' AND content_id = '{$pack->item_id}'"); for ($i = 0; $i < count($tabs); $i++) { $pack->tab_id = $tabs[$i]->tab_id; tabs::deleteTab($pack); } $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'ITEM' AND object_id = '{$pack->item_id}'"); for ($i = 0; $i < count($tags); $i++) { $pack->object_tag_id = $tags[$i]->object_tag_id; tags::deleteObjectTag($pack); } $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'ITEM' AND object_id = '{$pack->item_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } $factories = dbconnection::queryArray("SELECT * FROM factories WHERE object_type = 'ITEM' AND object_id = '{$pack->item_id}'"); for ($i = 0; $i < count($factories); $i++) { $pack->factory_id = $factories[$i]->factory_id; factories::deleteFactory($pack); } $events = dbconnection::queryArray("SELECT * FROM events WHERE (event = 'GIVE_ITEM_PLAYER' OR event = 'TAKE_ITEM_PLAYER' OR event = 'GIVE_ITEM_GAME' OR event = 'TAKE_ITEM_GAME') AND content_id = '{$pack->item_id}'"); for ($i = 0; $i < count($events); $i++) { $pack->event_id = $events[$i]->event_id; events::deleteEvent($pack); } $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_VIEWED_ITEM' AND content_id = '{$pack->item_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_HAS_ITEM' AND content_id = '{$pack->item_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'GAME_HAS_ITEM' AND content_id = '{$pack->item_id}'"); for ($i = 0; $i < count($reqAtoms); $i++) { $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id; requirements::deleteRequirementAtom($pack); } games::bumpGameVersion($pack); return new return_package(0); }
public static function deleteEventPackage($pack) { $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$pack->event_package_id}'")->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::query("DELETE FROM event_packages WHERE event_package_id = '{$pack->event_package_id}' LIMIT 1"); //cleanup $events = dbconnection::queryArray("SELECT * FROM events WHERE event_package_id = '{$pack->event_package_id}'"); for ($i = 0; $i < count($events); $i++) { $pack->event_id = $events[$i]->event_id; events::deleteEvent($pack); } dbconnection::query("UPDATE dialog_scripts SET event_package_id = 0 WHERE event_package_id = '{$pack->event_package_id}'"); dbconnection::query("UPDATE plaques SET event_package_id = 0 WHERE event_package_id = '{$pack->event_package_id}'"); dbconnection::query("UPDATE quests SET active_event_package_id = 0 WHERE active_event_package_id = '{$pack->event_package_id}'"); dbconnection::query("UPDATE quests SET complete_event_package_id = 0 WHERE complete_event_package_id = '{$pack->event_package_id}'"); $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'EVENT_PACKAGE' AND object_id = '{$pack->event_package_id}'"); for ($i = 0; $i < count($instances); $i++) { $pack->instance_id = $instances[$i]->instance_id; instances::deleteInstance($pack); } games::bumpGameVersion($pack); return new return_package(0); }