Example #1
0
/**
 * Print the link for the RSS feed with the correct RSS icon
 *
 * @param stdClass    $contextid     The id of the context under which the URL should be created
 * @param int         $userid        The source of the RSS feed (site/course/group/user)
 * @param string      $componentname The name of the component for which the feed exists
 * @param string      $id            The name by which to call the RSS File
 * @param string      $tooltiptext   The tooltip to be displayed with the link
 * @return string HTML output for the RSS link
 */
function rss_get_link($contextid, $userid, $componentname, $id, $tooltiptext = '')
{
    global $OUTPUT;
    static $rsspath = '';
    $rsspath = rss_get_url($contextid, $userid, $componentname, $id);
    $rsspix = $OUTPUT->pix_url('i/rss');
    return '<a href="' . $rsspath . '"><img src="' . $rsspix . '" title="' . strip_tags($tooltiptext) . '" alt="' . get_string('rss') . '" /></a>';
}
Example #2
0
/**
 * This function returns the icon (from theme) with the link to rss/file.php
 *
 * @global object
 * @global object
 */
function rss_get_link($courseid, $userid, $modulename, $id, $tooltiptext = '')
{
    global $OUTPUT;
    static $rsspath = '';
    //In site course, if no logged (userid), use admin->id. Bug 2048.
    if ($courseid == SITEID and empty($userid)) {
        $admin = get_admin();
        $userid = $admin->id;
    }
    $rsspath = rss_get_url($courseid, $userid, $modulename, $id);
    $rsspix = $OUTPUT->old_icon_url('i/rss');
    return '<a href="' . $rsspath . '"><img src="' . $rsspix . '" title="' . strip_tags($tooltiptext) . '" alt="' . get_string('rss') . '" /></a>';
}
Example #3
0
/**
 * Build the URL for the RSS feed
 *
 * @param int    $contextid    The context under which the URL should be created
 * @param int    $userid       The id of the user requesting the RSS Feed
 * @param string $filtertype   The source of the RSS feed (site/course/group/user)
 * @param int    $filterselect The id of the item defined by $filtertype
 * @param int    $tagid        The id of the row in the tag table that identifies the RSS Feed
 * @return string
 */
function blog_rss_get_url($contextid, $userid, $filtertype, $filterselect = 0, $tagid = 0)
{
    $componentname = 'blog';
    $additionalargs = null;
    switch ($filtertype) {
        case 'site':
            $additionalargs = 'site/' . SITEID;
            break;
        case 'course':
            $additionalargs = 'course/' . $filterselect;
            break;
        case 'group':
            $additionalargs = 'group/' . $filterselect;
            break;
        case 'user':
            $additionalargs = 'user/' . $filterselect;
            break;
    }
    if ($tagid) {
        $additionalargs .= '/' . $tagid;
    }
    return rss_get_url($contextid, $userid, $componentname, $additionalargs);
}
Example #4
0
        redirect($CFG->wwwroot . '/mod/data/field.php?d=' . $data->id);
        // Redirect to field entry
    }
}
if ($rid) {
    // So do you have access?
    if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey()) {
        print_error('noaccess', 'data');
    }
}
if ($cancel) {
    redirect('view.php?d=' . $data->id);
}
/// RSS and CSS and JS meta
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
    $rsspath = rss_get_url($context->id, $USER->id, 'mod_data', $data->id);
    $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
    $PAGE->add_alternate_version($courseshortname . ': %fullname%', $rsspath, 'application/rss+xml');
}
if ($data->csstemplate) {
    $PAGE->requires->css('/mod/data/css.php?d=' . $data->id);
}
if ($data->jstemplate) {
    $PAGE->requires->js('/mod/data/js.php?d=' . $data->id, true);
}
$possiblefields = $DB->get_records('data_fields', array('dataid' => $data->id), 'id');
foreach ($possiblefields as $field) {
    if ($field->type == 'file' || $field->type == 'picture') {
        require_once $CFG->dirroot . '/repository/lib.php';
        break;
    }
Example #5
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $forumnode The node to add module settings to
 */
function forum_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $forumnode) {
    global $USER, $PAGE, $CFG, $DB, $OUTPUT;

    $forumobject = $DB->get_record("forum", array("id" => $PAGE->cm->instance));
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = context_module::instance($PAGE->cm->instance);
    }

    // for some actions you need to be enrolled, beiing admin is not enough sometimes here
    $enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
    $activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);

    $canmanage  = has_capability('mod/forum:managesubscriptions', $PAGE->cm->context);
    $subscriptionmode = forum_get_forcesubscribed($forumobject);
    $cansubscribe = ($activeenrolled && $subscriptionmode != FORUM_FORCESUBSCRIBE && ($subscriptionmode != FORUM_DISALLOWSUBSCRIBE || $canmanage));

    if ($canmanage) {
        $mode = $forumnode->add(get_string('subscriptionmode', 'forum'), null, navigation_node::TYPE_CONTAINER);

        $allowchoice = $mode->add(get_string('subscriptionoptional', 'forum'), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_CHOOSESUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);
        $forceforever = $mode->add(get_string("subscriptionforced", "forum"), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_FORCESUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);
        $forceinitially = $mode->add(get_string("subscriptionauto", "forum"), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_INITIALSUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);
        $disallowchoice = $mode->add(get_string('subscriptiondisabled', 'forum'), new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'mode'=>FORUM_DISALLOWSUBSCRIBE, 'sesskey'=>sesskey())), navigation_node::TYPE_SETTING);

        switch ($subscriptionmode) {
            case FORUM_CHOOSESUBSCRIBE : // 0
                $allowchoice->action = null;
                $allowchoice->add_class('activesetting');
                break;
            case FORUM_FORCESUBSCRIBE : // 1
                $forceforever->action = null;
                $forceforever->add_class('activesetting');
                break;
            case FORUM_INITIALSUBSCRIBE : // 2
                $forceinitially->action = null;
                $forceinitially->add_class('activesetting');
                break;
            case FORUM_DISALLOWSUBSCRIBE : // 3
                $disallowchoice->action = null;
                $disallowchoice->add_class('activesetting');
                break;
        }

    } else if ($activeenrolled) {

        switch ($subscriptionmode) {
            case FORUM_CHOOSESUBSCRIBE : // 0
                $notenode = $forumnode->add(get_string('subscriptionoptional', 'forum'));
                break;
            case FORUM_FORCESUBSCRIBE : // 1
                $notenode = $forumnode->add(get_string('subscriptionforced', 'forum'));
                break;
            case FORUM_INITIALSUBSCRIBE : // 2
                $notenode = $forumnode->add(get_string('subscriptionauto', 'forum'));
                break;
            case FORUM_DISALLOWSUBSCRIBE : // 3
                $notenode = $forumnode->add(get_string('subscriptiondisabled', 'forum'));
                break;
        }
    }

    if ($cansubscribe) {
        if (forum_is_subscribed($USER->id, $forumobject)) {
            $linktext = get_string('unsubscribe', 'forum');
        } else {
            $linktext = get_string('subscribe', 'forum');
        }
        $url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'sesskey'=>sesskey()));
        $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
    }

    if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
        $url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$forumobject->id));
        $forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
    }

    if ($enrolled && forum_tp_can_track_forums($forumobject)) { // keep tracking info for users with suspended enrolments
        if ($forumobject->trackingtype != FORUM_TRACKING_OPTIONAL) {
            //tracking forced on or off in forum settings so dont provide a link here to change it
            //could add unclickable text like for forced subscription but not sure this justifies adding another menu item
        } else {
            if (forum_tp_is_tracked($forumobject)) {
                $linktext = get_string('notrackforum', 'forum');
            } else {
                $linktext = get_string('trackforum', 'forum');
            }
            $url = new moodle_url('/mod/forum/settracking.php', array('id'=>$forumobject->id));
            $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
        }
    }

    if (!isloggedin() && $PAGE->course->id == SITEID) {
        $userid = guest_user()->id;
    } else {
        $userid = $USER->id;
    }

    $hascourseaccess = ($PAGE->course->id == SITEID) || can_access_course($PAGE->course, $userid);
    $enablerssfeeds = !empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds);

    if ($enablerssfeeds && $forumobject->rsstype && $forumobject->rssarticles && $hascourseaccess) {

        if (!function_exists('rss_get_url')) {
            require_once("$CFG->libdir/rsslib.php");
        }

        if ($forumobject->rsstype == 1) {
            $string = get_string('rsssubscriberssdiscussions','forum');
        } else {
            $string = get_string('rsssubscriberssposts','forum');
        }

        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $userid, "mod_forum", $forumobject->id));
        $forumnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
    }
}
Example #6
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $datanode The node to add module settings to
 */
function data_extend_settings_navigation(settings_navigation $settings, navigation_node $datanode) {
    global $PAGE, $DB, $CFG, $USER;

    $data = $DB->get_record('data', array("id" => $PAGE->cm->instance));

    $currentgroup = groups_get_activity_group($PAGE->cm);
    $groupmode = groups_get_activity_groupmode($PAGE->cm);

    if (data_user_can_add_entry($data, $currentgroup, $groupmode, $PAGE->cm->context)) { // took out participation list here!
        if (empty($editentry)) { //TODO: undefined
            $addstring = get_string('add', 'data');
        } else {
            $addstring = get_string('editentry', 'data');
        }
        $datanode->add($addstring, new moodle_url('/mod/data/edit.php', array('d'=>$PAGE->cm->instance)));
    }

    if (has_capability(DATA_CAP_EXPORT, $PAGE->cm->context)) {
        // The capability required to Export database records is centrally defined in 'lib.php'
        // and should be weaker than those required to edit Templates, Fields and Presets.
        $datanode->add(get_string('exportentries', 'data'), new moodle_url('/mod/data/export.php', array('d'=>$data->id)));
    }
    if (has_capability('mod/data:manageentries', $PAGE->cm->context)) {
        $datanode->add(get_string('importentries', 'data'), new moodle_url('/mod/data/import.php', array('d'=>$data->id)));
    }

    if (has_capability('mod/data:managetemplates', $PAGE->cm->context)) {
        $currenttab = '';
        if ($currenttab == 'list') {
            $defaultemplate = 'listtemplate';
        } else if ($currenttab == 'add') {
            $defaultemplate = 'addtemplate';
        } else if ($currenttab == 'asearch') {
            $defaultemplate = 'asearchtemplate';
        } else {
            $defaultemplate = 'singletemplate';
        }

        $templates = $datanode->add(get_string('templates', 'data'));

        $templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
        foreach ($templatelist as $template) {
            $templates->add(get_string($template, 'data'), new moodle_url('/mod/data/templates.php', array('d'=>$data->id,'mode'=>$template)));
        }

        $datanode->add(get_string('fields', 'data'), new moodle_url('/mod/data/field.php', array('d'=>$data->id)));
        $datanode->add(get_string('presets', 'data'), new moodle_url('/mod/data/preset.php', array('d'=>$data->id)));
    }

    if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
        require_once("$CFG->libdir/rsslib.php");

        $string = get_string('rsstype','forum');

        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_data', $data->id));
        $datanode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
    }
}
Example #7
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $forumnode The node to add module settings to
 */
function forum_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $forumnode)
{
    global $USER, $PAGE, $CFG, $DB, $OUTPUT;
    $forumobject = $DB->get_record("forum", array("id" => $PAGE->cm->instance));
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = context_module::instance($PAGE->cm->instance);
    }
    $params = $PAGE->url->params();
    if (!empty($params['d'])) {
        $discussionid = $params['d'];
    }
    // for some actions you need to be enrolled, beiing admin is not enough sometimes here
    $enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
    $activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);
    $canmanage = has_capability('mod/forum:managesubscriptions', $PAGE->cm->context);
    $subscriptionmode = \mod_forum\subscriptions::get_subscription_mode($forumobject);
    $cansubscribe = $activeenrolled && !\mod_forum\subscriptions::is_forcesubscribed($forumobject) && (!\mod_forum\subscriptions::subscription_disabled($forumobject) || $canmanage);
    if ($canmanage) {
        $mode = $forumnode->add(get_string('subscriptionmode', 'forum'), null, navigation_node::TYPE_CONTAINER);
        $mode->add_class('subscriptionmode');
        $allowchoice = $mode->add(get_string('subscriptionoptional', 'forum'), new moodle_url('/mod/forum/subscribe.php', array('id' => $forumobject->id, 'mode' => FORUM_CHOOSESUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        $forceforever = $mode->add(get_string("subscriptionforced", "forum"), new moodle_url('/mod/forum/subscribe.php', array('id' => $forumobject->id, 'mode' => FORUM_FORCESUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        $forceinitially = $mode->add(get_string("subscriptionauto", "forum"), new moodle_url('/mod/forum/subscribe.php', array('id' => $forumobject->id, 'mode' => FORUM_INITIALSUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        $disallowchoice = $mode->add(get_string('subscriptiondisabled', 'forum'), new moodle_url('/mod/forum/subscribe.php', array('id' => $forumobject->id, 'mode' => FORUM_DISALLOWSUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        switch ($subscriptionmode) {
            case FORUM_CHOOSESUBSCRIBE:
                // 0
                $allowchoice->action = null;
                $allowchoice->add_class('activesetting');
                $allowchoice->icon = new pix_icon('t/selected', '', 'mod_forum');
                break;
            case FORUM_FORCESUBSCRIBE:
                // 1
                $forceforever->action = null;
                $forceforever->add_class('activesetting');
                $forceforever->icon = new pix_icon('t/selected', '', 'mod_forum');
                break;
            case FORUM_INITIALSUBSCRIBE:
                // 2
                $forceinitially->action = null;
                $forceinitially->add_class('activesetting');
                $forceinitially->icon = new pix_icon('t/selected', '', 'mod_forum');
                break;
            case FORUM_DISALLOWSUBSCRIBE:
                // 3
                $disallowchoice->action = null;
                $disallowchoice->add_class('activesetting');
                $disallowchoice->icon = new pix_icon('t/selected', '', 'mod_forum');
                break;
        }
    } else {
        if ($activeenrolled) {
            switch ($subscriptionmode) {
                case FORUM_CHOOSESUBSCRIBE:
                    // 0
                    $notenode = $forumnode->add(get_string('subscriptionoptional', 'forum'));
                    break;
                case FORUM_FORCESUBSCRIBE:
                    // 1
                    $notenode = $forumnode->add(get_string('subscriptionforced', 'forum'));
                    break;
                case FORUM_INITIALSUBSCRIBE:
                    // 2
                    $notenode = $forumnode->add(get_string('subscriptionauto', 'forum'));
                    break;
                case FORUM_DISALLOWSUBSCRIBE:
                    // 3
                    $notenode = $forumnode->add(get_string('subscriptiondisabled', 'forum'));
                    break;
            }
        }
    }
    if ($cansubscribe) {
        if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, null, $PAGE->cm)) {
            $linktext = get_string('unsubscribe', 'forum');
        } else {
            $linktext = get_string('subscribe', 'forum');
        }
        $url = new moodle_url('/mod/forum/subscribe.php', array('id' => $forumobject->id, 'sesskey' => sesskey()));
        $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
        if (isset($discussionid)) {
            if (\mod_forum\subscriptions::is_subscribed($USER->id, $forumobject, $discussionid, $PAGE->cm)) {
                $linktext = get_string('unsubscribediscussion', 'forum');
            } else {
                $linktext = get_string('subscribediscussion', 'forum');
            }
            $url = new moodle_url('/mod/forum/subscribe.php', array('id' => $forumobject->id, 'sesskey' => sesskey(), 'd' => $discussionid, 'returnurl' => $PAGE->url->out()));
            $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
        }
    }
    if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)) {
        $url = new moodle_url('/mod/forum/subscribers.php', array('id' => $forumobject->id));
        $forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
    }
    if ($enrolled && forum_tp_can_track_forums($forumobject)) {
        // keep tracking info for users with suspended enrolments
        if ($forumobject->trackingtype == FORUM_TRACKING_OPTIONAL || !$CFG->forum_allowforcedreadtracking && $forumobject->trackingtype == FORUM_TRACKING_FORCED) {
            if (forum_tp_is_tracked($forumobject)) {
                $linktext = get_string('notrackforum', 'forum');
            } else {
                $linktext = get_string('trackforum', 'forum');
            }
            $url = new moodle_url('/mod/forum/settracking.php', array('id' => $forumobject->id, 'sesskey' => sesskey()));
            $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
        }
    }
    if (!isloggedin() && $PAGE->course->id == SITEID) {
        $userid = guest_user()->id;
    } else {
        $userid = $USER->id;
    }
    $hascourseaccess = $PAGE->course->id == SITEID || can_access_course($PAGE->course, $userid);
    $enablerssfeeds = !empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds);
    if ($enablerssfeeds && $forumobject->rsstype && $forumobject->rssarticles && $hascourseaccess) {
        if (!function_exists('rss_get_url')) {
            require_once "{$CFG->libdir}/rsslib.php";
        }
        if ($forumobject->rsstype == 1) {
            $string = get_string('rsssubscriberssdiscussions', 'forum');
        } else {
            $string = get_string('rsssubscriberssposts', 'forum');
        }
        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $userid, "mod_forum", $forumobject->id));
        $forumnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
    }
}
Example #8
0
/**
 * Get all of the blog options that relate to the passed user.
 *
 * If no user is passed the current user is assumed.
 *
 * @staticvar array $useroptions Cache so we don't have to regenerate multiple times
 * @param stdClass $user
 * @return array The array of options for the requested user
 */
function blog_get_options_for_user(stdClass $user = null)
{
    global $CFG, $USER;
    // Cache
    static $useroptions = array();
    $options = array();
    // Blogs must be enabled and the user must be logged in
    if (!blog_is_enabled_for_user()) {
        return $options;
    }
    // Sort out the user var
    if ($user === null || $user->id == $USER->id) {
        $user = $USER;
        $iscurrentuser = true;
    } else {
        $iscurrentuser = false;
    }
    // If we've already generated serve from the cache
    if (array_key_exists($user->id, $useroptions)) {
        return $useroptions[$user->id];
    }
    $sitecontext = get_context_instance(CONTEXT_SYSTEM);
    $canview = has_capability('moodle/blog:view', $sitecontext);
    if (!$iscurrentuser && $canview && $CFG->bloglevel >= BLOG_SITE_LEVEL) {
        // Not the current user, but we can view and its blogs are enabled for SITE or GLOBAL
        $options['userentries'] = array('string' => get_string('viewuserentries', 'blog', fullname($user)), 'link' => new moodle_url('/blog/index.php', array('userid' => $user->id)));
    } else {
        // It's the current user
        if ($canview) {
            // We can view our own blogs .... BIG surprise
            $options['view'] = array('string' => get_string('viewallmyentries', 'blog'), 'link' => new moodle_url('/blog/index.php', array('userid' => $USER->id)));
        }
        if (has_capability('moodle/blog:create', $sitecontext)) {
            // We can add to our own blog
            $options['add'] = array('string' => get_string('addnewentry', 'blog'), 'link' => new moodle_url('/blog/edit.php', array('action' => 'add')));
        }
    }
    if ($canview && $CFG->enablerssfeeds) {
        $options['rss'] = array('string' => get_string('rssfeed', 'blog'), 'link' => new moodle_url(rss_get_url($sitecontext->id, $USER->id, 'blog', 'user/' . $user->id)));
    }
    // Cache the options
    $useroptions[$user->id] = $options;
    // Return the options
    return $options;
}
Example #9
0
        // Redirect to field entry
    }
}
if ($rid) {
    // So do you have access?
    if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey()) {
        error(get_string('noaccess', 'data'));
    }
}
if ($cancel) {
    redirect('view.php?d=' . $data->id);
}
/// RSS and CSS and JS meta
$meta = '';
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
    $rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id);
    $meta .= '<link rel="alternate" type="application/rss+xml" ';
    $meta .= 'title ="' . format_string($course->shortname) . ': %fullname%" href="' . $rsspath . '" />';
}
if ($data->csstemplate) {
    $meta .= '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/data/css.php?d=' . $data->id . '" /> ';
}
if ($data->jstemplate) {
    $meta .= '<script type="text/javascript" src="' . $CFG->wwwroot . '/mod/data/js.php?d=' . $data->id . '"></script>';
}
/// Print the page header
$strdata = get_string('modulenameplural', 'data');
$navlinks = array();
$navlinks[] = array('name' => $strdata, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
$navlinks[] = array('name' => format_string($data->name), 'link' => '', 'type' => 'activityinstance');
$navigation = build_navigation($navlinks);
Example #10
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $glossarynode The node to add module settings to
 */
function glossary_extend_settings_navigation(settings_navigation $settings, navigation_node $glossarynode) {
    global $PAGE, $DB, $CFG, $USER;

    $mode = optional_param('mode', '', PARAM_ALPHA);
    $hook = optional_param('hook', 'ALL', PARAM_CLEAN);

    if (has_capability('mod/glossary:import', $PAGE->cm->context)) {
        $glossarynode->add(get_string('importentries', 'glossary'), new moodle_url('/mod/glossary/import.php', array('id'=>$PAGE->cm->id)));
    }

    if (has_capability('mod/glossary:export', $PAGE->cm->context)) {
        $glossarynode->add(get_string('exportentries', 'glossary'), new moodle_url('/mod/glossary/export.php', array('id'=>$PAGE->cm->id, 'mode'=>$mode, 'hook'=>$hook)));
    }

    if (has_capability('mod/glossary:approve', $PAGE->cm->context) && ($hiddenentries = $DB->count_records('glossary_entries', array('glossaryid'=>$PAGE->cm->instance, 'approved'=>0)))) {
        $glossarynode->add(get_string('waitingapproval', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id'=>$PAGE->cm->id, 'mode'=>'approval')));
    }

    if (has_capability('mod/glossary:write', $PAGE->cm->context)) {
        $glossarynode->add(get_string('addentry', 'glossary'), new moodle_url('/mod/glossary/edit.php', array('cmid'=>$PAGE->cm->id)));
    }

    $glossary = $DB->get_record('glossary', array("id" => $PAGE->cm->instance));

    if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles  && can_access_course($PAGE->course, $USER)) {
        require_once("$CFG->libdir/rsslib.php");

        $string = get_string('rsstype','forum');

        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_glossary', $glossary->id));
        $glossarynode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
    }
}
Example #11
0
/**
 *
 */
function dataform_extend_navigation($navigation, $course, $module, $cm)
{
    global $PAGE, $USER, $CFG;
    $df = mod_dataform_dataform::instance($cm->instance);
    if ($views = $df->view_manager->views_navigation_menu) {
        foreach ($views as $viewid => $name) {
            $navigation->add($name, new moodle_url('/mod/dataform/view.php', array('d' => $df->id, 'view' => $viewid)));
        }
    }
    // RSS links.
    if (!empty($CFG->enablerssfeeds) and !empty($CFG->dataform_enablerssfeeds)) {
        if ($rssviews = $df->get_rss_views()) {
            require_once "{$CFG->libdir}/rsslib.php";
            $rssstr = get_string('rss');
            foreach ($rssviews as $viewid => $view) {
                $feedname = $view->name;
                $componentinstance = "{$df->id}/{$viewid}";
                $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_dataform', $componentinstance));
                $navigation->add($feedname, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', $rssstr));
            }
        }
    }
}
Example #12
0
 /**
  * This function display the hub homepage
  * It is called early when loading any Moodle page.
  * @return integer return true if Moodle index.php home page must continue normal display
  */
 public function display_homepage()
 {
     global $PAGE, $SITE, $OUTPUT, $CFG, $USER;
     //check if the front page search should not be displayed
     //=> hand over the home page to Moodle index.php
     //Two cases possible:
     //1- the hub is private and the users are not logged in
     //2- the hub is set with no search form on the login page
     $hubprivacy = get_config('local_hub', 'privacy');
     $searchfornologin = get_config('local_hub', 'searchfornologin');
     if (($hubprivacy == HUBPRIVATE or $searchfornologin === '0') and !isloggedin()) {
         return true;
     }
     require_once $CFG->dirroot . "/local/hub/forms.php";
     $PAGE->set_url('/');
     $PAGE->set_pagetype('site-index');
     $PAGE->set_docs_path('');
     $PAGE->set_pagelayout('frontpage');
     $PAGE->set_title($SITE->fullname);
     $PAGE->set_heading($SITE->fullname);
     //little trick to require login in order to rate or comment
     $mustbelogged = optional_param('mustbelogged', false, PARAM_BOOL);
     if ($mustbelogged) {
         require_login();
     }
     //log redirection to a course page
     $redirectcourseid = optional_param('redirectcourseid', false, PARAM_INT);
     if (!empty($redirectcourseid)) {
         //do not check sesskey because can be call by RSS feed
         $course = $this->get_course($redirectcourseid);
         if (!empty($course->courseurl)) {
             $courseurl = new moodle_url($course->courseurl);
         } else {
             if (!empty($course->demourl)) {
                 $courseurl = new moodle_url($course->demourl);
             } else {
                 //we try to display a demo site but none has been set
                 echo $OUTPUT->header();
                 echo get_string('nodemo', 'local_hub');
                 echo $OUTPUT->footer();
                 die;
             }
         }
         $rss = optional_param('rss', false, PARAM_BOOL);
         $rss = empty($rss) ? '' : 'rss';
         add_to_log(SITEID, 'local_hub', 'course redirection ' . $rss, '', $redirectcourseid);
         redirect(new moodle_url($courseurl));
     }
     $search = optional_param('search', null, PARAM_TEXT);
     $renderer = $PAGE->get_renderer('local_hub');
     //forms
     //Warning: because we want to support GET and we want people to be able to give the url,
     // we need to bypass the sesskey form checking
     $_GET['sesskey'] = sesskey();
     $fromformdata['coverage'] = optional_param('coverage', 'all', PARAM_TEXT);
     $fromformdata['licence'] = optional_param('licence', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['subject'] = optional_param('subject', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['siteid'] = optional_param('siteid', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['lastmodified'] = optional_param('lastmodified', HUB_LASTMODIFIED_WEEK, PARAM_ALPHANUMEXT);
     $fromformdata['audience'] = optional_param('audience', 'all', PARAM_ALPHANUMEXT);
     $currentlanguage = explode('_', current_language());
     $fromformdata['language'] = optional_param('language', $currentlanguage[0], PARAM_ALPHANUMEXT);
     $fromformdata['educationallevel'] = optional_param('educationallevel', 'all', PARAM_ALPHANUMEXT);
     $fromformdata['downloadable'] = optional_param('downloadable', 1, PARAM_ALPHANUM);
     $fromformdata['orderby'] = optional_param('orderby', 'newest', PARAM_ALPHA);
     $fromformdata['search'] = $search;
     $coursesearchform = new course_search_form('', $fromformdata, 'get');
     $fromform = $coursesearchform->get_data();
     $coursesearchform->set_data($fromformdata);
     $fromform = (object) $fromformdata;
     //Retrieve courses by web service
     $options = array();
     //special shortcut if a course id is given in param, we search straight forward this id
     if ($courseid = optional_param('courseid', 0, PARAM_INTEGER)) {
         $options['onlyvisible'] = true;
         $options['ids'] = array($courseid);
         $options['downloadable'] = true;
         $options['enrollable'] = true;
         $courses = $this->get_courses($options);
         $coursetotal = 1;
         //Add the name of the course to the page title
         //(useful because some sites as Facebook is going to read it to build a shared link name)
         foreach ($courses as $course) {
             $PAGE->set_title($course->fullname . ' - ' . $SITE->fullname);
         }
     } else {
         if (!empty($fromform) and optional_param('submitbutton', 0, PARAM_ALPHANUMEXT)) {
             $downloadable = optional_param('downloadable', false, PARAM_INTEGER);
             if (!empty($fromform->coverage)) {
                 $options['coverage'] = $fromform->coverage;
             }
             if ($fromform->licence != 'all') {
                 $options['licenceshortname'] = $fromform->licence;
             }
             if ($fromform->subject != 'all') {
                 $options['subject'] = $fromform->subject;
             }
             if ($fromform->audience != 'all') {
                 $options['audience'] = $fromform->audience;
             }
             if ($fromform->educationallevel != 'all') {
                 $options['educationallevel'] = $fromform->educationallevel;
             }
             if ($fromform->language != 'all') {
                 $options['language'] = $fromform->language;
             }
             //sort method
             switch ($fromform->orderby) {
                 case 'newest':
                     $options['orderby'] = 'timemodified DESC';
                     break;
                 case 'eldest':
                     $options['orderby'] = 'timemodified ASC';
                     break;
                 case 'publisher':
                     $options['orderby'] = 'publishername ASC';
                     break;
                 case 'fullname':
                     $options['orderby'] = 'fullname ASC';
                     break;
                 case 'ratingaverage':
                     $options['orderby'] = 'ratingaverage DESC';
                     break;
                 default:
                     break;
             }
             //get courses
             $options['search'] = $search;
             $options['onlyvisible'] = true;
             $options['downloadable'] = $downloadable;
             $options['enrollable'] = !$downloadable;
             $page = optional_param('page', 0, PARAM_INT);
             $courses = $this->get_courses($options, $page * HUB_COURSE_PER_PAGE, HUB_COURSE_PER_PAGE);
             $coursetotal = $this->get_courses($options, 0, 0, true);
             //reset the options
             $options['orderby'] = $fromform->orderby;
             unset($options['onlyvisible']);
         }
     }
     if (!empty($courses)) {
         //load javascript
         $courseids = array();
         //all result courses
         $courseimagenumbers = array();
         //number of screenshots of all courses (must be exact same order than $courseids)
         foreach ($courses as $course) {
             $courseids[] = $course->id;
             $courseimagenumbers[] = $course->screenshots;
         }
         $PAGE->requires->yui_module('moodle-block_community-imagegallery', 'M.blocks_community.init_imagegallery', array(array('imageids' => $courseids, 'imagenumbers' => $courseimagenumbers, 'huburl' => $CFG->wwwroot)));
         //get courses content
         foreach ($courses as $course) {
             $contents = $this->get_course_contents($course->id);
             if (!empty($contents)) {
                 foreach ($contents as $content) {
                     $course->contents[] = $content;
                 }
             }
         }
         //load ratings and comments
         require_once $CFG->dirroot . '/rating/lib.php';
         $ratingoptions = new stdclass();
         $ratingoptions->context = context_course::instance(SITEID);
         //front page course
         $ratingoptions->items = $courses;
         $ratingoptions->aggregate = RATING_AGGREGATE_COUNT;
         //the aggregation method
         $ratingoptions->scaleid = 0 - get_config('local_hub', 'courseratingscaleid');
         //rating API is expecting "minus scaleid"
         $ratingoptions->userid = $USER->id;
         $ratingoptions->returnurl = $CFG->wwwroot . "/local/hub/index.php";
         $ratingoptions->component = 'local_hub';
         $ratingoptions->ratingarea = 'featured';
         $rm = new rating_manager();
         $courses = $rm->get_ratings($ratingoptions);
         //this function return $ratingoptions->items with information about the ratings
         foreach ($courses as $course) {
             $course->rating->settings->permissions->viewany = 1;
         }
         require_once $CFG->dirroot . '/comment/lib.php';
         foreach ($courses as $course) {
             $commentoptions = new stdClass();
             $commentoptions->context = context_course::instance(SITEID);
             $commentoptions->area = 'local_hub';
             $commentoptions->itemid = $course->id;
             $commentoptions->showcount = true;
             $commentoptions->component = 'local_hub';
             $course->comment = new comment($commentoptions);
             $course->comment->set_view_permission(true);
         }
     }
     //create rss feed link
     $enablerssfeeds = get_config('local_hub', 'enablerssfeeds');
     if (!empty($enablerssfeeds)) {
         require $CFG->libdir . '/rsslib.php';
         $audience = key_exists('audience', $options) ? $options['audience'] : 'all';
         $educationallevel = key_exists('educationallevel', $options) ? $options['educationallevel'] : 'all';
         if (key_exists('downloadable', $options)) {
             $downloadable = empty($options['downloadable']) ? 0 : 1;
         } else {
             $downloadable = 'all';
         }
         $subject = key_exists('subject', $options) ? $options['subject'] : 'all';
         $licence = key_exists('licence', $options) ? $options['licence'] : 'all';
         $language = key_exists('language', $options) ? $options['language'] : 'all';
         $audience = key_exists('audience', $options) ? $options['audience'] : 'all';
         $orderby = key_exists('orderby', $options) ? $options['orderby'] : 'newest';
         $search = empty($search) ? 0 : urlencode($search);
         //retrieve guest user if user not logged in
         $userid = empty($USER->id) ? $CFG->siteguest : $USER->id;
         $ctx = context_course::instance(SITEID);
         //add the link tage to the header
         $rsslink = rss_get_url($ctx->id, $userid, 'local_hub', $downloadable . '/' . $audience . '/' . $educationallevel . '/' . $subject . '/' . $licence . '/' . $language . '/' . $search . '/');
         $PAGE->add_alternate_version('RSS', $rsslink, 'application/rss+xml');
         //create the rss icon
         $rssicon = rss_get_link($ctx->id, $userid, 'local_hub', $downloadable . '/' . $audience . '/' . $educationallevel . '/' . $subject . '/' . $licence . '/' . $language . '/' . $search . '/' . $orderby . '/', get_string('rsstooltip', 'local_hub'));
     }
     /// OUTPUT
     echo $OUTPUT->header();
     //notification message sent to publisher
     if (optional_param('messagesent', 0, PARAM_INTEGER)) {
         echo $OUTPUT->notification(get_string('messagesentsuccess', 'local_hub'), 'notifysuccess');
     }
     //search form
     $coursesearchform->display();
     //Course listing
     $options['submitbutton'] = 1;
     //need to set up the submitbutton to 1 for the paging bar (simulate search)
     //and paramlink
     //set language value back to 'all'
     if (!key_exists('language', $options)) {
         $options['language'] = 'all';
     }
     if (isset($courses) and empty($courseid)) {
         if (empty($coursetotal)) {
             $coursetotalhtml = get_string('nocourse', 'local_hub');
         } else {
             $coursetotalhtml = get_string('coursetotal', 'local_hub', $coursetotal);
         }
         echo html_writer::tag('div', $coursetotalhtml, array('class' => 'hubcoursetotal'));
     }
     if (!empty($courses)) {
         //paging bar
         if ($coursetotal > HUB_COURSE_PER_PAGE) {
             $baseurl = new moodle_url('', $options);
             $pagingbarhtml = $OUTPUT->paging_bar($coursetotal, $page, HUB_COURSE_PER_PAGE, $baseurl);
             $pagingbarhtml = html_writer::tag('div', $pagingbarhtml, array('class' => 'pagingbar'));
             echo $pagingbarhtml;
         }
         echo highlight($search, $renderer->course_list($courses));
         if (!empty($pagingbarhtml)) {
             echo $pagingbarhtml;
         }
     }
     //rss icon
     if (!empty($enablerssfeeds)) {
         echo html_writer::tag('div', $rssicon, array('class' => 'hubrsslink'));
     }
     //permalink
     if (!empty($courses)) {
         $permalinkparams = array();
         //special case: course list is a unique course for a given ID
         if (!empty($courseid)) {
             $permalinkparams['courseid'] = $courseid;
         } else {
             $permalinkparams = $options;
         }
         $permalink = html_writer::tag('div', html_writer::tag('a', get_string('permalink', 'local_hub'), array('href' => new moodle_url('', $permalinkparams))), array('class' => 'hubcoursepermalink'));
         echo $permalink;
     }
     echo $OUTPUT->footer();
 }
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($editing) {
    require_capability('mod/lightboxgallery:edit', $context);
}
add_to_log($course->id, 'lightboxgallery', 'view', 'view.php?id=' . $cm->id . '&page=' . $page, $gallery->id, $cm->id, $userid);
require_js(array('js/prototype.js', 'js/scriptaculous.js', 'js/effects.js', 'js/lightbox.js'));
$navigation = build_navigation('', $cm);
$update = update_module_button($cm->id, $course->id, get_string('modulenameshort', 'lightboxgallery'));
if (has_capability('mod/lightboxgallery:edit', $context)) {
    $options = array('id' => $cm->id, 'page' => $page, 'editing' => $editing ? '0' : '1');
    $update = print_single_button($CFG->wwwroot . '/mod/lightboxgallery/view.php', $options, get_string('turnediting' . ($editing ? 'off' : 'on')), 'get', '', true) . $update;
}
$meta = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/lightboxgallery/css/lightbox.css" />';
$allowrssfeed = lightboxgallery_rss_enabled() && $gallery->rss;
if ($allowrssfeed) {
    $rsspath = rss_get_url($course->id, $userid, 'lightboxgallery', $gallery->id);
    $meta .= "\n" . '<link rel="alternate" href="' . $rsspath . '" type="application/rss+xml" title="' . format_string($gallery->name) . '" id="gallery" />';
}
$meta .= "\n" . '<style type="text/css">';
$meta .= "\n" . '#navbar_bg {display:none;}';
$meta .= "\n" . '#header_bg {display:none;}';
$meta .= "\n" . '#banner_bg {display:none;}';
$meta .= "\n" . '</style>';
print_header();
//$course->shortname . ': ' . $gallery->name, $course->fullname, $navigation, '', $meta, true, $update, navmenu($course, $cm));
$heading = get_string('displayinggallery', 'lightboxgallery', $gallery->name);
if ($allowrssfeed) {
    $heading .= ' ' . rss_get_link($course->id, $userid, 'lightboxgallery', $gallery->id, get_string('rsssubscribe', 'lightboxgallery'));
}
print_heading($heading);
lightboxgallery_print_js_config($gallery->autoresize);
Example #14
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $forumnode The node to add module settings to
 */
function hsuforum_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $forumnode)
{
    global $USER, $PAGE, $CFG, $DB;
    $config = get_config('hsuforum');
    $forumobject = $DB->get_record("hsuforum", array("id" => $PAGE->cm->instance));
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = context_module::instance($PAGE->cm->instance);
    }
    // for some actions you need to be enrolled, beiing admin is not enough sometimes here
    $enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
    $activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);
    $canmanage = has_capability('mod/hsuforum:managesubscriptions', $PAGE->cm->context);
    $subscriptionmode = hsuforum_get_forcesubscribed($forumobject);
    $cansubscribe = $activeenrolled && $subscriptionmode != HSUFORUM_FORCESUBSCRIBE && ($subscriptionmode != HSUFORUM_DISALLOWSUBSCRIBE || $canmanage);
    $discussionid = optional_param('d', 0, PARAM_INT);
    $viewingdiscussion = ($PAGE->url->compare(new moodle_url('/mod/hsuforum/discuss.php'), URL_MATCH_BASE) and $discussionid);
    if (!is_guest($PAGE->cm->context)) {
        $forumnode->add(get_string('export', 'hsuforum'), new moodle_url('/mod/hsuforum/route.php', array('contextid' => $PAGE->cm->context->id, 'action' => 'export')), navigation_node::TYPE_SETTING, null, null, new pix_icon('i/export', get_string('export', 'hsuforum')));
    }
    $forumnode->add(get_string('viewposters', 'hsuforum'), new moodle_url('/mod/hsuforum/route.php', array('contextid' => $PAGE->cm->context->id, 'action' => 'viewposters')), navigation_node::TYPE_SETTING, null, null, new pix_icon('t/preview', get_string('viewposters', 'hsuforum')));
    if ($canmanage) {
        $mode = $forumnode->add(get_string('subscriptionmode', 'hsuforum'), null, navigation_node::TYPE_CONTAINER);
        $allowchoice = $mode->add(get_string('subscriptionoptional', 'hsuforum'), new moodle_url('/mod/hsuforum/subscribe.php', array('id' => $forumobject->id, 'mode' => HSUFORUM_CHOOSESUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        $forceforever = $mode->add(get_string("subscriptionforced", "hsuforum"), new moodle_url('/mod/hsuforum/subscribe.php', array('id' => $forumobject->id, 'mode' => HSUFORUM_FORCESUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        $forceinitially = $mode->add(get_string("subscriptionauto", "hsuforum"), new moodle_url('/mod/hsuforum/subscribe.php', array('id' => $forumobject->id, 'mode' => HSUFORUM_INITIALSUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        $disallowchoice = $mode->add(get_string('subscriptiondisabled', 'hsuforum'), new moodle_url('/mod/hsuforum/subscribe.php', array('id' => $forumobject->id, 'mode' => HSUFORUM_DISALLOWSUBSCRIBE, 'sesskey' => sesskey())), navigation_node::TYPE_SETTING);
        switch ($subscriptionmode) {
            case HSUFORUM_CHOOSESUBSCRIBE:
                // 0
                $allowchoice->action = null;
                $allowchoice->add_class('activesetting');
                break;
            case HSUFORUM_FORCESUBSCRIBE:
                // 1
                $forceforever->action = null;
                $forceforever->add_class('activesetting');
                break;
            case HSUFORUM_INITIALSUBSCRIBE:
                // 2
                $forceinitially->action = null;
                $forceinitially->add_class('activesetting');
                break;
            case HSUFORUM_DISALLOWSUBSCRIBE:
                // 3
                $disallowchoice->action = null;
                $disallowchoice->add_class('activesetting');
                break;
        }
    } else {
        if ($activeenrolled) {
            switch ($subscriptionmode) {
                case HSUFORUM_CHOOSESUBSCRIBE:
                    // 0
                    $notenode = $forumnode->add(get_string('subscriptionoptional', 'hsuforum'));
                    break;
                case HSUFORUM_FORCESUBSCRIBE:
                    // 1
                    $notenode = $forumnode->add(get_string('subscriptionforced', 'hsuforum'));
                    break;
                case HSUFORUM_INITIALSUBSCRIBE:
                    // 2
                    $notenode = $forumnode->add(get_string('subscriptionauto', 'hsuforum'));
                    break;
                case HSUFORUM_DISALLOWSUBSCRIBE:
                    // 3
                    $notenode = $forumnode->add(get_string('subscriptiondisabled', 'hsuforum'));
                    break;
            }
        }
    }
    if ($cansubscribe) {
        if (hsuforum_is_subscribed($USER->id, $forumobject)) {
            $linktext = get_string('unsubscribe', 'hsuforum');
        } else {
            $linktext = get_string('subscribe', 'hsuforum');
        }
        $url = new moodle_url('/mod/hsuforum/subscribe.php', array('id' => $forumobject->id, 'sesskey' => sesskey()));
        $forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
    }
    if ($viewingdiscussion) {
        require_once __DIR__ . '/lib/discussion/subscribe.php';
        $subscribe = new hsuforum_lib_discussion_subscribe($forumobject, $PAGE->cm->context);
        if ($subscribe->can_subscribe()) {
            $subscribeurl = new moodle_url('/mod/hsuforum/route.php', array('contextid' => $PAGE->cm->context->id, 'action' => 'subscribedisc', 'discussionid' => $discussionid, 'sesskey' => sesskey(), 'returnurl' => $PAGE->url));
            if ($subscribe->is_subscribed($discussionid)) {
                $linktext = get_string('unsubscribedisc', 'hsuforum');
            } else {
                $linktext = get_string('subscribedisc', 'hsuforum');
            }
            $forumnode->add($linktext, $subscribeurl, navigation_node::TYPE_SETTING);
        }
    }
    if (has_capability('mod/hsuforum:viewsubscribers', $PAGE->cm->context)) {
        $url = new moodle_url('/mod/hsuforum/subscribers.php', array('id' => $forumobject->id));
        $forumnode->add(get_string('showsubscribers', 'hsuforum'), $url, navigation_node::TYPE_SETTING);
        $discsubscribers = ($viewingdiscussion or optional_param('action', '', PARAM_ALPHA) == 'discsubscribers');
        if ($discsubscribers && !hsuforum_is_forcesubscribed($forumobject) && $discussionid) {
            $url = new moodle_url('/mod/hsuforum/route.php', array('contextid' => $PAGE->cm->context->id, 'action' => 'discsubscribers', 'discussionid' => $discussionid));
            $forumnode->add(get_string('showdiscussionsubscribers', 'hsuforum'), $url, navigation_node::TYPE_SETTING, null, 'discsubscribers');
        }
    }
    if (!isloggedin() && $PAGE->course->id == SITEID) {
        $userid = guest_user()->id;
    } else {
        $userid = $USER->id;
    }
    $hascourseaccess = $PAGE->course->id == SITEID || can_access_course($PAGE->course, $userid);
    $enablerssfeeds = !empty($config->enablerssfeeds) && !empty($config->enablerssfeeds);
    if ($enablerssfeeds && $forumobject->rsstype && $forumobject->rssarticles && $hascourseaccess) {
        if (!function_exists('rss_get_url')) {
            require_once "{$CFG->libdir}/rsslib.php";
        }
        if ($forumobject->rsstype == 1) {
            $string = get_string('rsssubscriberssdiscussions', 'hsuforum');
        } else {
            $string = get_string('rsssubscriberssposts', 'hsuforum');
        }
        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $userid, "mod_hsuforum", $forumobject->id));
        $forumnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
    }
}
Example #15
0
}
// 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
if (empty($cachedfilepath) || !file_exists($cachedfilepath)) {
    die($cachedfilepath);
    pcast_rss_error();
}
// Send the .pcast file to the user!
send_file($cachedfilepath, 'rss.pcast', 0, 0, 0, 1);
// DO NOT CACHE
Example #16
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $pcastnode The node to add module settings to
 */
function pcast_extend_settings_navigation(settings_navigation $settings, navigation_node $pcastnode)
{
    global $PAGE, $DB, $CFG, $USER;
    $mode = optional_param('mode', '', PARAM_ALPHA);
    $hook = optional_param('hook', 'ALL', PARAM_CLEAN);
    $group = optional_param('group', '', PARAM_ALPHANUM);
    if (has_capability('mod/pcast:approve', $PAGE->cm->context) && ($hiddenentries = $DB->count_records('pcast_episodes', array('pcastid' => $PAGE->cm->instance, 'approved' => 0)))) {
        $pcastnode->add(get_string('waitingapproval', 'pcast'), new moodle_url('/mod/pcast/view.php', array('id' => $PAGE->cm->id, 'mode' => PCAST_APPROVAL_VIEW)));
    }
    if (has_capability('mod/pcast:write', $PAGE->cm->context)) {
        $pcastnode->add(get_string('addnewepisode', 'pcast'), new moodle_url('/mod/pcast/edit.php', array('cmid' => $PAGE->cm->id)));
    }
    $pcast = $DB->get_record('pcast', array("id" => $PAGE->cm->instance));
    if (!empty($CFG->enablerssfeeds) && !empty($CFG->pcast_enablerssfeeds) && $pcast->rssepisodes) {
        require_once "{$CFG->libdir}/rsslib.php";
        $string = get_string('rsslink', 'pcast');
        //Sort out groups
        if (is_numeric($group)) {
            $currentgroup = $group;
        } else {
            $groupmode = groups_get_activity_groupmode($PAGE->cm);
            if ($groupmode > 0) {
                $currentgroup = groups_get_activity_group($PAGE->cm);
            } else {
                $currentgroup = 0;
            }
        }
        $args = $pcast->id . '/' . $currentgroup;
        $url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'pcast', $args));
        $pcastnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
        if (!empty($CFG->pcast_enablerssitunes)) {
            $string = get_string('pcastlink', 'pcast');
            require_once "{$CFG->dirroot}/mod/pcast/rsslib.php";
            $url = pcast_rss_get_url($PAGE->cm->context->id, $USER->id, 'pcast', $args);
            $pcastnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
        }
    }
}