/** * This function returns the URL for the RSS XML file. * * @param int $contextid the course id * @param int $userid the current user id * @param string $componentname the name of the current component. For example "forum" * @param string $additionalargs For modules, module instance id * @return string the url of the RSS feed */ function rss_get_url($contextid, $userid, $componentname, $additionalargs) { global $CFG; require_once $CFG->libdir . '/filelib.php'; $usertoken = rss_get_token($userid); return get_file_url($contextid . '/' . $usertoken . '/' . $componentname . '/' . $additionalargs . '/rss.xml', null, 'rssfile'); }
/** * This function returns the URL for the RSS XML file. * * @param int $contextid the course id * @param int $userid the current user id * @param string $componentname the name of the current component. For example "forum" * @param string $additionalargs For modules, module instance id * @return string the url of the RSS feed */ function rss_get_url($contextid, $userid, $componentname, $additionalargs) { global $CFG; if (empty($userid)) { $userid = guest_user()->id; } $usertoken = rss_get_token($userid); $url = '/rss/file.php'; return moodle_url::make_file_url($url, '/' . $contextid . '/' . $usertoken . '/' . $componentname . '/' . $additionalargs . '/rss.xml'); }
} } } if (empty($context)) { //this shouldnt happen. something bad is going on. rss_error('rsserror'); } //make sure that $CFG->siteguest is set if (empty($CFG->siteguest)) { if (!($guestid = $DB->get_field('user', 'id', array('username' => 'guest', 'mnethostid' => $CFG->mnet_localhost_id)))) { // guest does not exist yet, weird rss_error('rsserror'); } set_config('siteguest', $guestid); } $guesttoken = rss_get_token($CFG->siteguest); //change forum to mod_forum (for example) $componentname = 'mod_' . $componentname; $url = $PAGE->url; $url->set_slashargument("/{$context->id}/{$guesttoken}/{$componentname}/{$instanceid}/rss.xml"); //redirect to the 2.0 rss URL redirect($url); } else { // Authenticate the user from the token $userid = rss_get_userid_from_token($token); if (!$userid) { rss_error('rsserrorauth'); } } // Check the context actually exists list($context, $course, $cm) = get_context_info_array($contextid);
} } // RSS keys. if (!empty($CFG->enablerssfeeds)) { require_once $CFG->dirroot . '/lib/rsslib.php'; $action = optional_param('action', '', PARAM_ALPHANUMEXT); $confirm = optional_param('confirm', 0, PARAM_BOOL); $rssrenderer = $PAGE->get_renderer('core', 'rss'); if ($action == 'resetrsstoken') { // Display confirmation page to Reset the token. if (!$confirm) { $resetconfirmation = $rssrenderer->user_reset_rss_token_confirmation(); } else { rss_delete_token($USER->id); } } if (empty($resetconfirmation)) { $token = rss_get_token($USER->id); $rsstokenboxhtml = $rssrenderer->user_rss_token_box($token); // Display the box for the user's RSS token. } } // PAGE OUTPUT. echo $OUTPUT->header(); if (!empty($resetconfirmation)) { echo $resetconfirmation; } else { echo $webservicetokenboxhtml; echo $rsstokenboxhtml; } echo $OUTPUT->footer();
/** * This function returns the URL for the RSS XML file. * * @global object * @param int contextid the course id * @param int userid the current user id * @param string modulename the name of the current module. For example "forum" * @param string $additionalargs For modules, module instance id * @todo THIS WILL NOT WORK WITH SLASHARGS DISABLED */ function pcast_rss_get_url($contextid, $userid, $componentname, $additionalargs) { global $CFG, $USER, $PAGE; require_once $CFG->libdir . '/rsslib.php'; $usertoken = rss_get_token($userid); $args = '/' . $contextid . '/' . $usertoken . '/' . $componentname . '/' . $additionalargs . '/rss.pcast'; $url = new moodle_url('/mod/pcast/subscribe.php' . $args); return $url; }