Esempio n. 1
0
        if ($groupid == 0 and !has_capability('moodle/site:accessallgroups', $context, $userid)) {
            $uservalidated = false;
        }
    }
}
if (!$uservalidated) {
    pcast_rss_error('rsserrorauth');
}
// OK, the use should be able to see the feed, generate the .pcast file
$pcast = $DB->get_record('pcast', array('id' => $pcastid), '*', MUST_EXIST);
// Check to se if RSS is enabled
// NOTE: cannot use the rss_enabled_for_mod() function due to the functions internals and naming conflicts
if ($pcast->rssepisodes == 0 || empty($pcast->rssepisodes)) {
    pcast_rss_error();
}
$sql = pcast_rss_get_sql($pcast);
$filename = rss_get_file_name($pcast, $sql);
//Append the GroupID to the end of the filename
$filename .= '_' . $groupid;
$cachedfilepath = pcast_rss_get_file_full_name('mod_pcast', $filename);
// Figure out the URL for the podcast based on the user info
$args = $pcast->id . '/' . $userid . '/' . $groupid;
$url = new moodle_url(rss_get_url($context->id, $userid, 'pcast', $args));
// Build the .pcast file
$rss = pcast_build_pcast_file($pcast, $url);
//Save the XML contents to file.
$status = pcast_rss_save_file('mod_pcast', $filename, $rss);
if (!$status) {
    $cachedfilepath = null;
}
// Check that file exists
Esempio n. 2
0
/**
 * If there is new stuff in since $time this returns true
 * Otherwise it returns false.
 *
 * @param object $pcast the pcast activity object
 * @param int $time timestamp
 * @return bool
 */
function pcast_rss_newstuff($pcast, $time)
{
    global $DB;
    $sql = pcast_rss_get_sql($pcast, $time);
    $recs = $DB->get_records_sql($sql, null, 0, 1);
    //limit of 1. If we get even 1 back we have new stuff
    return $recs && !empty($recs);
}