hasPermissionTo("edit") ) { delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_waramu_queue WHERE ID=$id"); $success = true; } } else { $obj = waramu_getResource("", $rid); if ( $obj->hasPermissionTo("edit") ) { $w = waramu_get(); $au = buildAppUser(get_loggedin_user()); $w->deleteResource($au, $rid); // TODO: catch exceptions $success = true; } } if ( $success ) { // delete info from tables by id; delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_waramu_resources WHERE waramu_id='$id'"); delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_resource_stats WHERE waramu_id='$id'"); delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_resources_quality_marks WHERE waramu_id='$id'"); delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_favorite_resources WHERE waramu_id='$id'"); $resource_collections = get_entities_from_metadata("resources", $id, "object", "collection"); foreach ($resource_collections as $collection) { if ($collection) { $resources = $collection->resources; if (is_string($resources)) { $resources = array($resources); } foreach ($resources as $key => $res) { if ($res == $id) { unset($resources[$key]); $collection->resources = $resources; $collection->needs_update = 1; $collection->save(); } } } } /*translation:Learning resource deleted!*/ system_messages(elgg_echo("koolielu:learning_resource_deleted"), "errors"); forward($CONFIG->wwwroot.'pg/waramu'); } else { /*translation:You cannot delete this resource!*/ system_messages(elgg_echo("koolielu:you_cannot_delete"), "errors"); forward($CONFIG->wwwroot.'pg/waramu/view/'.$rid); } ?>