//Check authentication token $authUserId = !empty($userId) && $authtoken == sha1($userId . $user->password . $CFG->resop_exportsalt); if (!$authUserId) { 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');
function showClasses($id, $select = '%') { global $DB, $OUTPUT, $USER, $CFG, $resop; //resop->id : see note in showBookers $authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id' => $USER->id)) . $CFG->resop_exportsalt); $className = $select == '%' ? 'all' : $select; //% in url does not work - strange, it should its encoded as %25 which is right $urlExport = array('id' => $id, 'resopId' => $resop->id, 'userid' => $USER->id, 'authtoken' => $authtoken, 'type' => 'class', 'name' => $className); $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'); $classEntries = ResopDB::getClassEntries($select, $resop->id); showEntriesTable($id, $classEntries, array('class' => $select)); }