// Returns status code 1 if successful in simply checking authorisation and blogging ability. // Returns status code 103 is successful in adding blog entry. // Can also return various blog-specific error codes. /** Lets Sloodle know we are in a linker script. */ define('SLOODLE_LINKER_SCRIPT', true); /** Grab the Sloodle/Moodle configuration. */ require_once '../sl_config.php'; /** Include the Sloodle PHP API. */ require_once SLOODLE_LIBROOT . '/sloodle_session.php'; // Authenticate the request as user-specific, and load a blog module $sloodle = new SloodleSession(); $sloodle->authenticate_user_request(); $sloodle->load_module('blog', false); // No database data required // Attempt to validate the avatar $sloodle->validate_avatar(); $sloodle->user->login(); // Is blogging enabled? if (!$sloodle->module->is_enabled()) { $sloodle->response->quick_output(-10401, 'BLOG', 'Blogging is disabled on this site.', false); exit; } // Check if the user has permission to create blog entries if (!$sloodle->module->user_can_write()) { $sloodle->response->quick_output(-10402, 'BLOG', 'User lacks permission to write blog entries.', false); exit; } // Check for our additional parameters $sloodleblogsubject = $sloodle->request->optional_param('sloodleblogsubject', ''); $sloodleblogbody = $sloodle->request->optional_param('sloodleblogbody', ''); $sloodleblogvisibility = $sloodle->request->optional_param('sloodleblogvisibility', 'site');
/** Lets Sloodle know we are in a linker script. */ define('SLOODLE_LINKER_SCRIPT', true); /** Grab the Sloodle/Moodle configuration. */ require_once '../sl_config.php'; /** Include the Sloodle PHP API. */ require_once SLOODLE_LIBROOT . '/sloodle_session.php'; // Process the request (but we can't authenticate it) $sloodle = new SloodleSession(); // Make sure we have the required parameters $objuuid = $sloodle->request->required_param('sloodleobjuuid'); $objname = $sloodle->request->required_param('sloodleobjname'); $objpwd = $sloodle->request->required_param('sloodleobjpwd'); $avuuid = $sloodle->request->get_avatar_uuid(); $avname = $sloodle->request->get_avatar_name(); // Attempt to validate the user (but suppress autoreg/enrol) $avatar_validated = $sloodle->validate_avatar(false); // If user validation failed, then setup a pending avatar entry $lst = null; if (!$avatar_validated) { $pa = $sloodle->user->add_pending_avatar($avuuid, $avname); if (!$pa) { $sloodle->response->quick_output(-322, 'MISC_REGISTER', 'Failed to add pending avatar details.', false); exit; } // Store the login security token $lst = $pa->lst; } // Attempt to add a new object to the database $sloodleauthid = $sloodle->user->add_user_object($avuuid, $objuuid, $objname, $objpwd); if (!$sloodleauthid) { $sloodle->response->quick_output(-201, 'OBJECT_AUTH', 'Failed to add user object to database.', false);