Ok, at the moment, I'm deploying the view page as a resource and I'm collecting $_GET parameters for stuff like which SWF file to use and which DB records to access (I have a DB table of interactions which identifies which DB table and which interaction to populate the SWF file with).
I have a MDL.php service class for Moodle variables which works perfectly except for the course names:
class MDL
{
public $logged_in;
public $course_id;
public $course_fullname;
public $course_shortname;
public $user_id;
public $data_path;
public function __construct()
{
global $CFG;
require_once('../../../config.php');
if (isguestuser() || isloggedin()){
$this->logged_in = true;
global $USER;
global $SESSION;
global $COURSE;
// set variables
$this->course_id = $SESSION->cal_course_referer;
$this->course_fullname = $COURSE->fullname;
$this->course_shortname = $COURSE->shortname;
$this->user_id = $USER->id;
$this->data_path = $CFG->
wwwroot . '/file.php/' . $this->course_id . '/';
} else {
$this->logged_in = false;
}
}
/**
*temporary function for testing - gets current course full name
*@returns string
*/
public function get_course_fullname()
{
if($this->logged_in) {
return $this->course_fullname; // at the moment this just returns the site name
} else {
return false;
}
}
/**
*cleans up variables for garbage collector
*@returns nothing
*/
public function __destruct()
{
unset($this->logged_in);
unset($this->mdl_course_id);
unset($this->mdl_user_id);
unset($this->mdl_data_path);
}
}
So how can I make this class work properly? I can actually print out the variables I want to access (see above) but I don't know how to access them directly in this script.