mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-27814-master' of git://github.com/ankitagarwal/moodle
Conflicts: lib/deprecatedlib.php
This commit is contained in:
commit
b90bd21c5f
@ -45,7 +45,6 @@ $returnurl = new moodle_url('/blog/index.php');
|
||||
|
||||
if (!empty($courseid) && empty($modid)) {
|
||||
$returnurl->param('courseid', $courseid);
|
||||
$PAGE->set_context(context_course::instance($courseid));
|
||||
}
|
||||
|
||||
// If a modid is given, guess courseid
|
||||
@ -53,13 +52,12 @@ if (!empty($modid)) {
|
||||
$returnurl->param('modid', $modid);
|
||||
$courseid = $DB->get_field('course_modules', 'course', array('id' => $modid));
|
||||
$returnurl->param('courseid', $courseid);
|
||||
$PAGE->set_context(context_module::instance($modid));
|
||||
}
|
||||
|
||||
// If courseid is empty use the system context
|
||||
if (empty($courseid)) {
|
||||
$PAGE->set_context(context_system::instance());
|
||||
}
|
||||
// Blogs are always in system context.
|
||||
$sitecontext = context_system::instance();
|
||||
$PAGE->set_context($sitecontext);
|
||||
|
||||
|
||||
$blogheaders = blog_get_headers();
|
||||
|
||||
@ -77,7 +75,6 @@ if (isguestuser()) {
|
||||
print_error('noguestentry', 'blog');
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:create', $sitecontext) && !has_capability('moodle/blog:manageentries', $sitecontext)) {
|
||||
print_error('cannoteditentryorblog');
|
||||
}
|
||||
|
@ -86,11 +86,9 @@ class blog_edit_form extends moodleform {
|
||||
$contextid = $entry->courseassoc;
|
||||
}
|
||||
|
||||
if (has_capability('moodle/blog:associatecourse', $context)) {
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
|
||||
$mform->setDefault('courseassoc', $contextid);
|
||||
}
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
|
||||
$mform->setDefault('courseassoc', $contextid);
|
||||
|
||||
} else if ((!empty($entry->modassoc) || !empty($modid))) {
|
||||
if (!empty($modid)) {
|
||||
@ -108,11 +106,9 @@ class blog_edit_form extends moodleform {
|
||||
$modid = $context->instanceid;
|
||||
}
|
||||
|
||||
if (has_capability('moodle/blog:associatemodule', $context)) {
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
|
||||
$mform->setDefault('modassoc', $context->id);
|
||||
}
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
|
||||
$mform->setDefault('modassoc', $context->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,14 +137,9 @@ class blog_edit_form extends moodleform {
|
||||
|
||||
// validate course association
|
||||
if (!empty($data['courseassoc'])) {
|
||||
$coursecontext = context::instance_by_id($data['courseassoc'], IGNORE_MISSING);
|
||||
$coursecontext = context::instance_by_id($data['courseassoc']);
|
||||
|
||||
$canassociatecourse = has_capability('moodle/blog:associatecourse', $coursecontext);
|
||||
if ($coursecontext->contextlevel == CONTEXT_COURSE && $canassociatecourse) {
|
||||
if (!is_enrolled($coursecontext) and !is_viewing($coursecontext)) {
|
||||
$errors['courseassoc'] = get_string('studentnotallowed', '', fullname($USER, true));
|
||||
}
|
||||
} else {
|
||||
if ($coursecontext->contextlevel != CONTEXT_COURSE) {
|
||||
$errors['courseassoc'] = get_string('error');
|
||||
}
|
||||
}
|
||||
@ -156,10 +147,9 @@ class blog_edit_form extends moodleform {
|
||||
// validate mod association
|
||||
if (!empty($data['modassoc'])) {
|
||||
$modcontextid = $data['modassoc'];
|
||||
$modcontext = context::instance_by_id($modcontextid, IGNORE_MISSING);
|
||||
$modcontext = context::instance_by_id($modcontextid);
|
||||
|
||||
$canassociatemodule = has_capability('moodle/blog:associatemodule', $modcontext);
|
||||
if ($canassociatemodule) {
|
||||
if ($modcontext->contextlevel == CONTEXT_MODULE) {
|
||||
// get context of the mod's course
|
||||
$coursecontext = $modcontext->get_course_context(true);
|
||||
|
||||
@ -171,11 +161,6 @@ class blog_edit_form extends moodleform {
|
||||
} else {
|
||||
$data['courseassoc'] = $coursecontext->id;
|
||||
}
|
||||
|
||||
// ensure the user has access to each mod's course
|
||||
if (!is_enrolled($modcontext) and !is_viewing($modcontext)) {
|
||||
$errors['modassoc'] = get_string('studentnotallowed', '', fullname($USER, true));
|
||||
}
|
||||
} else {
|
||||
$errors['modassoc'] = get_string('error');
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ if (!empty($groupid) && empty($courseid)) {
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
// Blogs are always in system context.
|
||||
$PAGE->set_context($sitecontext);
|
||||
|
||||
// check basic permissions
|
||||
if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
|
||||
@ -122,11 +124,9 @@ if (!empty($courseid)) {
|
||||
}
|
||||
|
||||
$courseid = $course->id;
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
require_login($course);
|
||||
|
||||
if (!has_capability('moodle/blog:view', $coursecontext)) {
|
||||
if (!has_capability('moodle/blog:view', $sitecontext)) {
|
||||
print_error('cannotviewcourseblog', 'blog');
|
||||
}
|
||||
} else {
|
||||
@ -150,7 +150,7 @@ if (!empty($groupid)) {
|
||||
$courseid = $course->id;
|
||||
require_login($course);
|
||||
|
||||
if (!has_capability('moodle/blog:view', $coursecontext)) {
|
||||
if (!has_capability('moodle/blog:view', $sitecontext)) {
|
||||
print_error(get_string('cannotviewcourseorgroupblog', 'blog'));
|
||||
}
|
||||
|
||||
@ -199,15 +199,6 @@ if (!empty($userid)) {
|
||||
|
||||
$courseid = (empty($courseid)) ? SITEID : $courseid;
|
||||
|
||||
if (empty($entryid) && empty($modid) && empty($groupid)) {
|
||||
$PAGE->set_context(context_user::instance($USER->id));
|
||||
} else if (!empty($modid)) {
|
||||
$PAGE->set_context(context_module::instance($modid));
|
||||
} else if (!empty($courseid)) {
|
||||
$PAGE->set_context(context_course::instance($courseid));
|
||||
} else {
|
||||
$PAGE->set_context(context_system::instance());
|
||||
}
|
||||
|
||||
$blogheaders = blog_get_headers();
|
||||
|
||||
@ -217,7 +208,7 @@ if ($CFG->enablerssfeeds) {
|
||||
$thingid = null;
|
||||
list($thingid, $rsscontext, $filtertype) = blog_rss_get_params($blogheaders['filters']);
|
||||
if (empty($rsscontext)) {
|
||||
$rsscontext = get_system_context();
|
||||
$rsscontext = context_system::instance();
|
||||
}
|
||||
$rsstitle = $blogheaders['heading'];
|
||||
|
||||
|
95
blog/lib.php
95
blog/lib.php
@ -294,57 +294,6 @@ function blog_delete_external_entries($externalblog) {
|
||||
array($externalblog->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL based on the context of the current page.
|
||||
* This URL points to blog/index.php and includes filter parameters appropriate for the current page.
|
||||
*
|
||||
* @param stdclass $context
|
||||
* @return string
|
||||
*/
|
||||
function blog_get_context_url($context=null) {
|
||||
global $CFG;
|
||||
|
||||
$viewblogentriesurl = new moodle_url('/blog/index.php');
|
||||
|
||||
if (empty($context)) {
|
||||
global $PAGE;
|
||||
$context = $PAGE->context;
|
||||
}
|
||||
|
||||
// Change contextlevel to SYSTEM if viewing the site course
|
||||
if ($context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID) {
|
||||
$context = context_system::instance();
|
||||
}
|
||||
|
||||
$filterparam = '';
|
||||
$strlevel = '';
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
case CONTEXT_BLOCK:
|
||||
case CONTEXT_COURSECAT:
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
$filterparam = 'courseid';
|
||||
$strlevel = get_string('course');
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$filterparam = 'modid';
|
||||
$strlevel = print_context_name($context);
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
$filterparam = 'userid';
|
||||
$strlevel = get_string('user');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($filterparam)) {
|
||||
$viewblogentriesurl->param($filterparam, $context->instanceid);
|
||||
}
|
||||
|
||||
return $viewblogentriesurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks that blogs are enabled, and that the user can see blogs at all
|
||||
* @return bool
|
||||
@ -512,10 +461,6 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
|
||||
|
||||
// Check that the user can associate with the course
|
||||
$sitecontext = context_system::instance();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
if (!has_capability('moodle/blog:associatecourse', $coursecontext)) {
|
||||
return $options;
|
||||
}
|
||||
// Generate the cache key
|
||||
$key = $course->id.':';
|
||||
if (!empty($user)) {
|
||||
@ -528,36 +473,35 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
|
||||
return $courseoptions[$key];
|
||||
}
|
||||
|
||||
$canparticipate = (is_enrolled($coursecontext) or is_viewing($coursecontext));
|
||||
|
||||
if (has_capability('moodle/blog:view', $coursecontext)) {
|
||||
if (has_capability('moodle/blog:view', $sitecontext)) {
|
||||
// We can view!
|
||||
if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
|
||||
// View entries about this course
|
||||
$options['courseview'] = array(
|
||||
'string' => get_string('viewcourseblogs', 'blog'),
|
||||
'link' => new moodle_url('/blog/index.php', array('courseid'=>$course->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('courseid' => $course->id))
|
||||
);
|
||||
}
|
||||
// View MY entries about this course
|
||||
$options['courseviewmine'] = array(
|
||||
'string' => get_string('viewmyentriesaboutcourse', 'blog'),
|
||||
'link' => new moodle_url('/blog/index.php', array('courseid'=>$course->id, 'userid'=>$USER->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('courseid' => $course->id, 'userid' => $USER->id))
|
||||
);
|
||||
if (!empty($user) && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
|
||||
// View the provided users entries about this course
|
||||
$options['courseviewuser'] = array(
|
||||
'string' => get_string('viewentriesbyuseraboutcourse', 'blog', fullname($user)),
|
||||
'link' => new moodle_url('/blog/index.php', array('courseid'=>$course->id, 'userid'=>$user->id))
|
||||
'link' => new moodle_url('/blog/index.php', array('courseid' => $course->id, 'userid' => $user->id))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/blog:create', $sitecontext) and $canparticipate) {
|
||||
if (has_capability('moodle/blog:create', $sitecontext)) {
|
||||
// We can blog about this course
|
||||
$options['courseadd'] = array(
|
||||
'string' => get_string('blogaboutthiscourse', 'blog'),
|
||||
'link' => new moodle_url('/blog/edit.php', array('action'=>'add', 'courseid'=>$course->id))
|
||||
'link' => new moodle_url('/blog/edit.php', array('action' => 'add', 'courseid' => $course->id))
|
||||
);
|
||||
}
|
||||
|
||||
@ -587,12 +531,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
// Check the user can associate with the module
|
||||
$modcontext = context_module::instance($module->id);
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:associatemodule', $modcontext)) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
// Generate the cache key
|
||||
$key = $module->id.':';
|
||||
@ -606,9 +545,8 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
return $moduleoptions[$key];
|
||||
}
|
||||
|
||||
$canparticipate = (is_enrolled($modcontext) or is_viewing($modcontext));
|
||||
|
||||
if (has_capability('moodle/blog:view', $modcontext)) {
|
||||
if (has_capability('moodle/blog:view', $sitecontext)) {
|
||||
// Save correct module name for later usage.
|
||||
$modulename = get_string('modulename', $module->modname);
|
||||
|
||||
@ -639,7 +577,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/blog:create', $sitecontext) and $canparticipate) {
|
||||
if (has_capability('moodle/blog:create', $sitecontext)) {
|
||||
// The user can blog about this module
|
||||
$options['moduleadd'] = array(
|
||||
'string' => get_string('blogaboutthismodule', 'blog', $modulename),
|
||||
@ -699,23 +637,6 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
$blogurl = new moodle_url('/blog/index.php');
|
||||
|
||||
// If the title is not yet set, it's likely that the context isn't set either, so skip this part
|
||||
$pagetitle = $PAGE->title;
|
||||
if (!empty($pagetitle)) {
|
||||
$contexturl = blog_get_context_url();
|
||||
|
||||
// Look at the context URL, it may have additional params that are not in the current URL
|
||||
if (!$blogurl->compare($contexturl)) {
|
||||
$blogurl = $contexturl;
|
||||
if (empty($courseid)) {
|
||||
$courseid = $blogurl->param('courseid');
|
||||
}
|
||||
if (empty($modid)) {
|
||||
$modid = $blogurl->param('modid');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$headers['stradd'] = get_string('addnewentry', 'blog');
|
||||
$headers['strview'] = null;
|
||||
|
||||
|
@ -679,41 +679,26 @@ class blog_listing {
|
||||
|
||||
if (empty($userid) || (!empty($userid) && $userid == $USER->id)) {
|
||||
|
||||
$canaddentries = true;
|
||||
$courseid = optional_param('courseid', null, PARAM_INT);
|
||||
if ($modid = optional_param('modid', null, PARAM_INT)) {
|
||||
if (!has_capability('moodle/blog:associatemodule', context_module::instance($modid))) {
|
||||
$canaddentries = false;
|
||||
}
|
||||
} else if ($courseid) {
|
||||
if (!has_capability('moodle/blog:associatecourse', context_course::instance($courseid))) {
|
||||
$canaddentries = false;
|
||||
}
|
||||
}
|
||||
$modid = optional_param('modid', null, PARAM_INT);
|
||||
|
||||
if ($canaddentries) {
|
||||
$addurl = new moodle_url("$CFG->wwwroot/blog/edit.php");
|
||||
$urlparams = array('action' => 'add',
|
||||
'userid' => $userid,
|
||||
'courseid' => $courseid,
|
||||
'groupid' => optional_param('groupid', null, PARAM_INT),
|
||||
'modid' => $modid,
|
||||
'tagid' => optional_param('tagid', null, PARAM_INT),
|
||||
'tag' => optional_param('tag', null, PARAM_INT),
|
||||
'search' => optional_param('search', null, PARAM_INT));
|
||||
$addurl = new moodle_url("$CFG->wwwroot/blog/edit.php");
|
||||
$urlparams = array('action' => 'add',
|
||||
'userid' => $userid,
|
||||
'courseid' => $courseid,
|
||||
'groupid' => optional_param('groupid', null, PARAM_INT),
|
||||
'modid' => $modid,
|
||||
'tagid' => optional_param('tagid', null, PARAM_INT),
|
||||
'tag' => optional_param('tag', null, PARAM_INT),
|
||||
'search' => optional_param('search', null, PARAM_INT));
|
||||
|
||||
foreach ($urlparams as $var => $val) {
|
||||
if (empty($val)) {
|
||||
unset($urlparams[$var]);
|
||||
}
|
||||
}
|
||||
$addurl->params($urlparams);
|
||||
$urlparams = array_filter($urlparams);
|
||||
$addurl->params($urlparams);
|
||||
|
||||
$addlink = '<div class="addbloglink">';
|
||||
$addlink .= '<a href="'.$addurl->out().'">'. $blogheaders['stradd'].'</a>';
|
||||
$addlink .= '</div>';
|
||||
echo $addlink;
|
||||
}
|
||||
$addlink = '<div class="addbloglink">';
|
||||
$addlink .= '<a href="'.$addurl->out().'">'. $blogheaders['stradd'].'</a>';
|
||||
$addlink .= '</div>';
|
||||
echo $addlink;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,20 +55,16 @@ if ($groupid !== null) {
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
if ($courseid == SITEID) {
|
||||
require_login();
|
||||
$context = context_system::instance();
|
||||
$PAGE->set_context($context);
|
||||
} else {
|
||||
require_login($courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
}
|
||||
$sitecontext = context_system::instance();
|
||||
$PAGE->set_context($sitecontext);
|
||||
require_login($courseid);
|
||||
|
||||
if (empty($CFG->enableblogs)) {
|
||||
print_error('blogdisable', 'blog');
|
||||
}
|
||||
|
||||
require_capability('moodle/blog:view', $context);
|
||||
// The preference is site wide not blog specific. Hence user should have permissions in site level.
|
||||
require_capability('moodle/blog:view', $sitecontext);
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
|
@ -123,26 +123,15 @@ function blog_rss_get_params($filters) {
|
||||
|
||||
if (!$filters) {
|
||||
$thingid = SITEID;
|
||||
$rsscontext = $sitecontext;
|
||||
$filtertype = 'site';
|
||||
} else if (array_key_exists('course', $filters)) {
|
||||
$thingid = $filters['course'];
|
||||
|
||||
$coursecontext = context_course::instance($thingid);
|
||||
$rsscontext = $coursecontext;
|
||||
|
||||
$filtertype = 'course';
|
||||
} else if (array_key_exists('user', $filters)) {
|
||||
$thingid = $filters['user'];
|
||||
|
||||
$usercontext = context_user::instance($thingid);
|
||||
$rsscontext = $usercontext;
|
||||
|
||||
$filtertype = 'user';
|
||||
} else if (array_key_exists('group', $filters)) {
|
||||
$thingid = $filters['group'];
|
||||
|
||||
$rsscontext = $sitecontext; //is this the context we should be using for group blogs?
|
||||
$filtertype = 'group';
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,6 @@ $string['invalidgroupid'] = 'Invalid group ID';
|
||||
$string['invalidurl'] = 'This URL is unreachable';
|
||||
$string['linktooriginalentry'] = 'Link to original blog entry';
|
||||
$string['maxexternalblogsperuser'] = 'Maximum number of external blogs per user';
|
||||
$string['mustassociatecourse'] = 'If you are publishing to course or group members, you must associate a course with this entry';
|
||||
$string['name'] = 'Name';
|
||||
$string['name_help'] = 'Enter a descriptive name for your external blog. (If no name is supplied, the title of your external blog will be used).';
|
||||
$string['noentriesyet'] = 'No visible entries here';
|
||||
|
@ -83,8 +83,8 @@ $string['badges:viewbadges'] = 'View available badges without earning them';
|
||||
$string['badges:viewotherbadges'] = 'View public badges in other users\' profiles';
|
||||
$string['block:edit'] = 'Edit a block\'s settings';
|
||||
$string['block:view'] = 'View block';
|
||||
$string['blog:associatecourse'] = 'Associate blog entries with courses';
|
||||
$string['blog:associatemodule'] = 'Associate blog entries with activity modules';
|
||||
$string['blog:associatecourse'] = 'This capability is deprecated and does nothing.';
|
||||
$string['blog:associatemodule'] = 'This capability is deprecated and does nothing.';
|
||||
$string['blog:create'] = 'Create new blog entries';
|
||||
$string['blog:manageentries'] = 'Edit and manage entries';
|
||||
$string['blog:manageexternal'] = 'Edit and manage external blogs';
|
||||
|
@ -1127,30 +1127,19 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
// TODO: Remove 'moodle/blog:associatecourse' and 'moodle/blog:associatemodule' after a few releases.
|
||||
'moodle/blog:associatecourse' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'student' => CAP_ALLOW,
|
||||
'user' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
'archetypes' => array()
|
||||
),
|
||||
|
||||
'moodle/blog:associatemodule' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'student' => CAP_ALLOW,
|
||||
'user' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
'archetypes' => array()
|
||||
),
|
||||
|
||||
'moodle/calendar:manageownentries' => array( // works in CONTEXT_SYSTEM only
|
||||
|
@ -4279,6 +4279,60 @@ function get_category_courses_array_recursively(array &$flattened, $category) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL based on the context of the current page.
|
||||
* This URL points to blog/index.php and includes filter parameters appropriate for the current page.
|
||||
*
|
||||
* @param stdclass $context
|
||||
* @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
|
||||
* @todo Remove this in 2.7
|
||||
* @return string
|
||||
*/
|
||||
function blog_get_context_url($context=null) {
|
||||
global $CFG;
|
||||
|
||||
debugging('Function blog_get_context_url() is deprecated, getting params from context is not reliable for blogs.', DEBUG_DEVELOPER);
|
||||
$viewblogentriesurl = new moodle_url('/blog/index.php');
|
||||
|
||||
if (empty($context)) {
|
||||
global $PAGE;
|
||||
$context = $PAGE->context;
|
||||
}
|
||||
|
||||
// Change contextlevel to SYSTEM if viewing the site course
|
||||
if ($context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID) {
|
||||
$context = context_system::instance();
|
||||
}
|
||||
|
||||
$filterparam = '';
|
||||
$strlevel = '';
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
case CONTEXT_BLOCK:
|
||||
case CONTEXT_COURSECAT:
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
$filterparam = 'courseid';
|
||||
$strlevel = get_string('course');
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$filterparam = 'modid';
|
||||
$strlevel = print_context_name($context);
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
$filterparam = 'userid';
|
||||
$strlevel = get_string('user');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($filterparam)) {
|
||||
$viewblogentriesurl->param($filterparam, $context->instanceid);
|
||||
}
|
||||
|
||||
return $viewblogentriesurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve course records with the course managers and other related records
|
||||
* that we need for print_course(). This allows print_courses() to do its job
|
||||
|
Loading…
x
Reference in New Issue
Block a user