authenticate_request($authrequired); // Get the extra parameters $sloodleobjuuid = $sloodle->request->required_param('sloodleobjuuid'); $sloodleobjname = $sloodle->request->required_param('sloodleobjname'); $sloodleobjpwd = $sloodle->request->required_param('sloodleobjpwd'); $sloodleobjtype = $sloodle->request->optional_param('sloodleobjtype', ''); $sloodlecloneconfig = $sloodle->request->optional_param('sloodlecloneconfig', ''); // uuid of an object whose config we want to clone. combined with a layout id of 0. used for rezzing a mothership from a set $sloodlehttpinurl = $sloodle->request->optional_param('sloodlehttpinurl',''); // When the set rezzes an item from a layout, it can pass this parameter saying what layout entry the object represented. // We'll use that to auto-configure the object based on the layout entry configurations. $sloodlelayoutentryid = $sloodle->request->optional_param('sloodlelayoutentryid',-1,PARAM_INT); // If the request was authenticated, then the object is being fully authorised. // Otherwise, it is simply a 'pending' authorisation. if ($request_auth) { // If the request is coming from an authorised object, then use that user as the authoriser for this one $sloodlepwd = $sloodle->request->required_param('sloodlepwd'); $pwdparts = explode('|', $sloodlepwd, 2); if (count($pwdparts) >= 2 && strlen($pwdparts[0]) == 36) { // Do we have a UUID? $userid = $sloodle->course->controller->get_authorizing_user($pwdparts[0]); if ($userid) $sloodle->user->load_user($userid); } $httpinpassword = sloodle_random_prim_password(); // Authorise the object on the controller $authid = $sloodle->course->controller->register_object($sloodleobjuuid, $sloodleobjname, $sloodle->user, $sloodleobjpwd, $httpinpassword, $sloodleobjtype); $alreadyconfigured = "0"; if ($sloodlelayoutentryid > 0) { if ($sloodle->course->controller->configure_object_from_layout_entry($authid, $sloodlelayoutentryid)) { // This flag will tell the rezzer to tell the object that it's already configured // That way the object will know not to tell the user to configure it. $alreadyconfigured = "1"; } } else if ( ($sloodlelayoutentryid == 0) && ($sloodlecloneconfig != '') ) { // use 0 to mean we want to configure based on the parent who authorized us, rather than on a layout. Doing this to make the mothership worked when rezzed by a Sloodle Set, but we may want to do the same kind of thing with Registration Booths etc. if ($result = $sloodle->course->controller->configure_object_from_parent($authid, $sloodlecloneconfig)) { // This flag will tell the rezzer to tell the object that it's already configured // That way the object will know not to tell the user to configure it. $alreadyconfigured = $result; $alreadyconfigured = "1"; } else { $alreadyconfigured = "0"; } } if ($authid) { $sloodle->response->set_status_code(1); $sloodle->response->set_status_descriptor('OK'); $sloodle->response->add_data_line($authid); $sloodle->response->add_data_line($alreadyconfigured); } else { $sloodle->response->set_status_code(-201); $sloodle->response->set_status_descriptor('OBJECT_AUTH'); $sloodle->response->add_data_line('Failed to register new active object.'); } } else { // Create a new unauthorised entry $httpinpassword = sloodle_random_prim_password(); $authid = $sloodle->course->controller->register_unauth_object($sloodleobjuuid, $sloodleobjname, $sloodleobjpwd, $sloodleobjtype, null, $sloodlehttpinurl, $httpinpassword); if ($authid != 0) { $sloodle->response->set_status_code(1); $sloodle->response->set_status_descriptor('OK'); $sloodle->response->add_data_line($authid); $sloodle->response->add_data_line($alreadyconfigured="0"); } else { $sloodle->response->set_status_code(-201); $sloodle->response->set_status_descriptor('OBJECT_AUTH'); $sloodle->response->add_data_line('Failed to register new active object.'); } } // Render the output sloodle_debug('
'); $sloodle->response->render_to_output(); sloodle_debug(''); ?>