id) { error_output( 'User not logged in' ); } $rezzer = new SloodleActiveObject(); $sloodleuser = new SloodleUser(); $sloodleuser->user_data = $USER; if (!$controllerid = optional_param('controllerid', 0, PARAM_INT)) { error_output( 'Controller ID missing' ); } if ( !$rezzeruuid = optional_param('rezzeruuid', '', PARAM_SAFEDIR) ) { error_output( 'Rezzer UUID missing or incorrect' ); } if ( !$rezzer->loadByUUID($rezzeruuid) ) { error_output( 'Controller ID missing' ); } $controller_context = get_context_instance( CONTEXT_MODULE, $controllerid); if (!has_capability('mod/sloodle:uselayouts', $controller_context)) { error_output( 'Access denied'); } // TODO: Make this check for a change in the site name, then remove the "true" to avoid pointless reconfiguration if (true || ($rezzer->controllerid != $controllerid) || ($rezzer->userid != $USER->id) ) { //if ( ($rezzer->controllerid != $controllerid) || ($rezzer->userid != $USER->id) ) { $rezzer->controllerid = $controllerid; if (!$rezzer->save()) { error_output('Updating rezzer failed'); } if (!$result = $rezzer->sendConfig()) { error_output('Sending config failed'); } if ($result['info']['http_code'] == 404) { error_output('HTTP-in URL not found'); } if ($result['info']['http_code'] != 200) { error_output('HTTP-in request failed'); } } $info = $result['info']; $result = 'configured'; $content = array( 'result' => $result, 'error' => '', 'info' => $info, ); print json_encode($content); function error_output($error) { $content = array( 'result' => 'failed', 'error' => $error, ); print json_encode($content); exit; } ?>