controller = sloodle_get_record('sloodle_controller', 'sloodleid', $this->sloodle->id)) error('Failed to locate Controller data');
}
/**
* Process any form data which has been submitted.
*/
function process_form()
{
}
/**
* Render the view of the Controller.
*/
function render()
{
global $CFG;
// Fetch the controller data
$this->controller = sloodle_get_record('sloodle_controller', 'sloodleid', $this->sloodle->id);
if (!$this->controller) return false;
// The name, type and description of the module should already be displayed by the main "view.php" script.
echo "
\n";
// Check if some kind of action has been requested
$action = optional_param('action', '', PARAM_TEXT);
// Indicate whether or not this module is enabled
echo '
\n";
// Can the user access protected data?
if ($this->canedit) {
// Active (authorised) objects
sloodle_print_box_start('generalbox boxaligncenter boxwidthwide');
echo '
'.get_string('authorizedobjects','sloodle').'
';
// Has a delete objects action been requested
if ($action == 'delete_objects') {
// Count how many objects we delete
$numdeleted = 0;
// Go through each request parameter
foreach ($_REQUEST as $name => $val) {
// Is this a delete objects request?
if ($val != 'true') continue;
$parts = explode('_', $name);
if (count($parts) == 2 && $parts[0] == 'sloodledeleteobj') {
// Only delete the object if it belongs to this controller
if (sloodle_delete_records('sloodle_active_object', 'controllerid', $this->cm->id, 'id', (int)$parts[1])) {
$numdeleted++;
// Delete any associated configuration settings too
sloodle_delete_records('sloodle_object_config', 'object', (int)$parts[1]);
}
}
}
// Indicate our results
echo ''.get_string('numdeleted','sloodle').': '.$numdeleted.'
';
}
// Get all objects authorised for this controller
$recs = sloodle_get_records('sloodle_active_object', 'controllerid', $this->cm->id, 'timeupdated DESC');
if (is_array($recs) && count($recs) > 0) {
// Construct a table
//TODO: add authorising user link
$objects_table = new stdClass();
$objects_table->head = array(get_string('objectname','sloodle'),get_string('objectuuid','sloodle'),get_string('objecttype','sloodle'),get_string('lastupdated','sloodle'),'');
$objects_table->align = array('left', 'left', 'left', 'left', 'center');
foreach ($recs as $obj) {
// Skip this object if it has no type information
if (empty($obj->type)) continue;
// Construct a link to this object's configuration page
$config_link = "wwwroot}/mod/sloodle/classroom/configure_object.php?sloodleauthid={$obj->id}\">";
$objects_table->data[] = array($config_link.$obj->name.'', $obj->uuid, $obj->type, date('Y-m-d H:i:s T', (int)$obj->timeupdated), "id}\" value=\"true\" /");
}
// Display a form and the table
echo '';
} else {
echo ''.get_string('noentries','sloodle').' ';
}
sloodle_print_box_end();
}
echo "