Example #1
0
    die('Invalid authentication');
}
$isBooker = checkIfBooker($resopInCourseId, $user);
if (!$isBooker && ($type == 'booker' || $type == 'class' && $requestedName == 'all')) {
    die('Access rights are not sufficient');
}
//now we have should done authentication stuff
if ($requestedName == 'all') {
    $requestedName = '%';
}
//get the data
if ($type == 'class') {
    $entries = ResopDB::getClassEntries($requestedName, $resopId);
} else {
    if ($type == 'booker') {
        $entries = ResopDB::getBookerEntries($requestedName);
    } else {
        die('Ivalid request');
    }
}
/*
echo "<textarea cols=50 rows=20>";
print_r($entries);
echo "</textarea>";
*/
//build the ical stuff
$ical = new iCalendar();
$ical->add_property('method', 'PUBLISH');
$hostaddress = str_replace('http://', '', $CFG->wwwroot);
$hostaddress = str_replace('https://', '', $hostaddress);
/* example for one entry, key in array is always id
Example #2
0
function showBookers($id, $name)
{
    global $DB, $USER, $CFG, $OUTPUT, $resop;
    //thought id and resop id are the same but they are not.
    //I don't understand why, so what resop->id is used in my internal db-tables and id is the id of an instance
    //inside of a course
    $authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id' => $USER->id)) . $CFG->resop_exportsalt);
    $urlExport = array('id' => $id, 'resopId' => $resop->id, 'userid' => $USER->id, 'authtoken' => $authtoken, 'type' => 'booker', 'name' => $name);
    $linkExport = $OUTPUT->action_link(new moodle_url('exportIcal.php', $urlExport), 'iCal', null, array('title' => get_string('iCal', 'resop'), 'class' => 'ical-link'));
    //$OUTPUT->action_link you find under lib/outputrenderers.php - but I don't understand action (set to null is default)
    //delete get's the old action and class to go back to this page
    echo $linkExport;
    echo $OUTPUT->help_icon('iCal', 'resop');
    $bookerEntries = ResopDB::getBookerEntries($name);
    showEntriesTable($id, $bookerEntries, array('name' => $name));
}