load($layoutentryid)) { $result = 'deleted'; } if (!$result) { $layout = new SloodleLayout(); if (!$layout->load($layoutentry->layout)) { error_output('Layout not found'); } $controller_context = get_context_instance( CONTEXT_MODULE, $layout->controllerid); if (!has_capability('mod/sloodle:uselayouts', $controller_context)) { error_output( 'Access denied'); } if (!$layoutentry->delete()) { error_output('Layout entry deletion failed'); } $result = 'deleted'; } /* // FOR NOW: Leaving this for later // If we have a rezzer, derez any outstanding objects if ($rezzeruuid) { $active_objects = $controller->get_active_objects( $rezzeruuid, $layoutentryid ); foreach($active_objects as $ao) { if (!$ao->deRez()) { $failures[] = $ao; } } } */ $content = array( 'result' => $result, 'layoutentryid' => $layoutentryid, 'layoutid' => $_REQUEST['layoutid'] ); $rand = rand(0,10); //sleep($rand); print json_encode($content); exit; function error_output($error) { $content = array( 'result' => 'failed', 'error' => $error, ); print json_encode($content); exit; } ?>