Source for file sl_blog_linker.php
Documentation is available at sl_blog_linker.php
// This file is part of the Sloodle project (www.sloodle.org) and is released under the GNU GPL v3.
* Allows the Sloodle Toolbar HUD object in Second Life to write to a user's Moodle blog.
* @copyright Copyright (c) 2007-8 Sloodle (various contributors)
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
* @contributor (various - original design and implementation)
* @contributor Peter R. Bloomfield - updated to use new API and communications format
// This script is expected to be accessed from in-world.
// The following parameters are required:
// sloodlepwd = the prim password used to authenticate the blog toolbar for this site
// sloodleuuid = the SL UUID of the agent making the blog entry (optional if 'sloodleavname' is specified)
// sloodleavname = the name of the avatar making the blog entry (optional if 'sloodleuuid' is specified)
// sloodleblogsubject = the subject line of the blog entry
// sloodleblogbody = the main body of the blog entry
require_once('../config.php');
require_once(SLOODLE_DIRROOT.
'/sl_debug.php');
require_once(SLOODLE_DIRROOT.
'/lib/sl_lsllib.php');
require_once($CFG->dirroot .
'/blog/lib.php'); // Moodle blog functionality
// Create an LSL handler and process the basic request data
$lsl->request->process_request_data();
// Ensure the request is authenticated
$lsl->request->authenticate_request();
// Attempt to login the user
$lsl->login_by_request();
// Obtain the additional parameters for the blog entry
$sloodleblogsubject =
$lsl->request->required_param('sloodleblogsubject', PARAM_RAW);
$sloodleblogbody =
$lsl->request->required_param('sloodleblogbody', PARAM_RAW);
// We need to know if all header data was retrieved
$use_slurl =
(isset
($_SERVER['HTTP_X_SECONDLIFE_REGION']) && isset
($_SERVER['HTTP_X_SECONDLIFE_LOCAL_POSITION']));
// Use the HTTP headers added by SL to get the region and position data, and construct a SLurl from them
$region =
$_SERVER['HTTP_X_SECONDLIFE_REGION'];
$position =
$_SERVER['HTTP_X_SECONDLIFE_LOCAL_POSITION'];
sscanf($position, "(%f, %f, %f)", $x, $y, $z);
$slurl =
"http://slurl.com/secondlife/" .
$region .
"/" .
$x .
"/" .
$y .
"/" .
$z;
$slurl =
'<a href="' .
$slurl .
'">' .
$region .
'</a>';
$slurl =
'[location unknown]';
// Make all string data safe
// Construct the final blog body
$sloodleblogbody =
"Posted from Second Life: " .
$slurl .
"\n\n" .
$sloodleblogbody;
// Write a blog entry into database
$blogEntry =
new stdClass();
$blogEntry->subject =
$sloodleblogsubject;
$blogEntry->summary =
$sloodleblogbody;
$blogEntry->module =
'blog';
$blogEntry->userid =
$lsl->user->get_moodle_user_id();
$blogEntry->publishstate =
'site'; // 'draft' or 'site' or 'public'
$blogEntry->lastmodified =
time();
$blogEntry->created =
time();
// Insert the new blog entry, making sure it is successful
if ($entryID =
insert_record('post',$blogEntry)) {
$lsl->response->set_status_code(1);
$lsl->response->set_status_descriptor('OK');
$lsl->response->set_status_code(-
1);
$lsl->response->set_status_descriptor('ERROR');
$lsl->response->add_data_line('Failed to insert blog entry into database.');
$lsl->response->render_to_output();
Documentation generated on Tue, 04 Mar 2008 15:08:36 +0000 by phpDocumentor 1.4.0