mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
Merge branch 'wip-MDL-34457-master' of git://github.com/abgreeve/moodle
This commit is contained in:
commit
7bc0f808d3
@ -45,7 +45,7 @@ $returnurl = new moodle_url('/blog/index.php');
|
||||
|
||||
if (!empty($courseid) && empty($modid)) {
|
||||
$returnurl->param('courseid', $courseid);
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
$PAGE->set_context(context_course::instance($courseid));
|
||||
}
|
||||
|
||||
// If a modid is given, guess courseid
|
||||
@ -53,12 +53,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(get_context_instance(CONTEXT_MODULE, $modid));
|
||||
$PAGE->set_context(context_module::instance($modid));
|
||||
}
|
||||
|
||||
// If courseid is empty use the system context
|
||||
if (empty($courseid)) {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$PAGE->set_context(context_system::instance());
|
||||
}
|
||||
|
||||
$blogheaders = blog_get_headers();
|
||||
@ -77,7 +77,7 @@ if (isguestuser()) {
|
||||
print_error('noguestentry', 'blog');
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:create', $sitecontext) && !has_capability('moodle/blog:manageentries', $sitecontext)) {
|
||||
print_error('cannoteditentryorblog');
|
||||
}
|
||||
@ -143,7 +143,7 @@ if (!empty($entry->id)) {
|
||||
if ($CFG->useblogassociations && ($blogassociations = $DB->get_records('blog_association', array('blogid' => $entry->id)))) {
|
||||
|
||||
foreach ($blogassociations as $assocrec) {
|
||||
$context = get_context_instance_by_id($assocrec->contextid);
|
||||
$context = context::instance_by_id($assocrec->contextid);
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_COURSE:
|
||||
@ -215,13 +215,13 @@ switch ($action) {
|
||||
|
||||
//pre-select the course for associations
|
||||
if ($courseid) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$entry->courseassoc = $context->id;
|
||||
}
|
||||
|
||||
//pre-select the mod for associations
|
||||
if ($modid) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $modid);
|
||||
$context = context_module::instance($modid);
|
||||
$entry->modassoc = $context->id;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class blog_edit_form extends moodleform {
|
||||
if (!empty($courseid)) {
|
||||
$course = $DB->get_record('course', array('id' => $courseid));
|
||||
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$a = new stdClass();
|
||||
$a->coursename = format_string($course->fullname, true, array('context' => $context));
|
||||
$contextid = $context->id;
|
||||
@ -94,9 +94,9 @@ class blog_edit_form extends moodleform {
|
||||
$a = new stdClass();
|
||||
$a->modtype = get_string('modulename', $mod->modname);
|
||||
$a->modname = $mod->name;
|
||||
$context = get_context_instance(CONTEXT_MODULE, $modid);
|
||||
$context = context_module::instance($modid);
|
||||
} else {
|
||||
$context = get_context_instance_by_id($entry->modassoc);
|
||||
$context = context::instance_by_id($entry->modassoc);
|
||||
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
|
||||
$a = new stdClass();
|
||||
$a->modtype = $DB->get_field('modules', 'name', array('id' => $cm->module));
|
||||
@ -131,7 +131,7 @@ class blog_edit_form extends moodleform {
|
||||
global $CFG, $DB, $USER;
|
||||
|
||||
$errors = array();
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
// validate course association
|
||||
if (!empty($data['courseassoc']) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
|
||||
|
@ -32,7 +32,7 @@ require_once($CFG->libdir . '/simplepie/moodle_simplepie.php');
|
||||
require_once($CFG->dirroot.'/tag/lib.php');
|
||||
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/blog:manageexternal', $context);
|
||||
|
||||
// TODO redirect if $CFG->useexternalblogs is off, $CFG->maxexternalblogsperuser == 0, or if user doesn't have caps to manage external blogs
|
||||
|
@ -29,7 +29,7 @@ require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_system::instance();
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_url(new moodle_url('/blog/external_blogs.php'));
|
||||
require_capability('moodle/blog:manageexternal', $context);
|
||||
|
@ -56,7 +56,7 @@ if (!empty($groupid) && empty($courseid)) {
|
||||
$courseid = $DB->get_field('groups', 'courseid', array('id'=>$groupid));
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
// check basic permissions
|
||||
if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
|
||||
@ -122,7 +122,7 @@ if (!empty($courseid)) {
|
||||
}
|
||||
|
||||
$courseid = $course->id;
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
require_login($course);
|
||||
|
||||
@ -130,7 +130,7 @@ if (!empty($courseid)) {
|
||||
print_error('cannotviewcourseblog', 'blog');
|
||||
}
|
||||
} else {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, SITEID);
|
||||
$coursecontext = context_course::instance(SITEID);
|
||||
}
|
||||
|
||||
if (!empty($groupid)) {
|
||||
@ -146,7 +146,7 @@ if (!empty($groupid)) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$courseid = $course->id;
|
||||
require_login($course);
|
||||
|
||||
@ -183,7 +183,7 @@ if (!empty($userid)) {
|
||||
print_error('donothaveblog', 'blog');
|
||||
}
|
||||
} else {
|
||||
$personalcontext = get_context_instance(CONTEXT_USER, $userid);
|
||||
$personalcontext = context_user::instance($userid);
|
||||
|
||||
if (!has_capability('moodle/blog:view', $sitecontext) && !has_capability('moodle/user:readuserblogs', $personalcontext)) {
|
||||
print_error('cannotviewuserblog', 'blog');
|
||||
|
64
blog/lib.php
64
blog/lib.php
@ -42,7 +42,7 @@ require_once($CFG->dirroot.'/tag/lib.php');
|
||||
function blog_user_can_edit_entry($blogentry) {
|
||||
global $USER;
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
if (has_capability('moodle/blog:manageentries', $sitecontext)) {
|
||||
return true; // can edit any blog entry
|
||||
@ -72,7 +72,7 @@ function blog_user_can_view_user_entry($targetuserid, $blogentry=null) {
|
||||
return true; // can view own entries in any case
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
if (has_capability('moodle/blog:manageentries', $sitecontext)) {
|
||||
return true; // can manage all entries
|
||||
}
|
||||
@ -101,7 +101,7 @@ function blog_user_can_view_user_entry($targetuserid, $blogentry=null) {
|
||||
|
||||
case BLOG_USER_LEVEL:
|
||||
default:
|
||||
$personalcontext = get_context_instance(CONTEXT_USER, $targetuserid);
|
||||
$personalcontext = context_user::instance($targetuserid);
|
||||
return has_capability('moodle/user:readuserblogs', $personalcontext);
|
||||
break;
|
||||
|
||||
@ -131,7 +131,7 @@ function blog_remove_associations_for_user($userid) {
|
||||
*/
|
||||
function blog_remove_associations_for_course($courseid) {
|
||||
global $DB;
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$DB->delete_records('blog_association', array('contextid' => $context->id));
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ function blog_sync_external_entries($externalblog) {
|
||||
*/
|
||||
function blog_delete_external_entries($externalblog) {
|
||||
global $DB;
|
||||
require_capability('moodle/blog:manageexternal', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/blog:manageexternal', context_system::instance());
|
||||
$DB->delete_records_select('post',
|
||||
"module='blog_external' AND " . $DB->sql_compare_text('content') . " = ?",
|
||||
array($externalblog->id));
|
||||
@ -406,7 +406,7 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
|
||||
}
|
||||
|
||||
// If blog level is global then display a link to view all site entries
|
||||
if (!empty($CFG->bloglevel) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (!empty($CFG->bloglevel) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', context_system::instance())) {
|
||||
$options[CONTEXT_SYSTEM] = array('viewsite' => array(
|
||||
'string' => get_string('viewsiteentries', 'blog'),
|
||||
'link' => new moodle_url('/blog/index.php')
|
||||
@ -450,7 +450,7 @@ function blog_get_options_for_user(stdClass $user=null) {
|
||||
return $useroptions[$user->id];
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
$canview = has_capability('moodle/blog:view', $sitecontext);
|
||||
|
||||
if (!$iscurrentuser && $canview && ($CFG->bloglevel >= BLOG_SITE_LEVEL)) {
|
||||
@ -510,7 +510,7 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
|
||||
}
|
||||
|
||||
// Check that the user can associate with the course
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:associatecourse', $sitecontext)) {
|
||||
return $options;
|
||||
}
|
||||
@ -526,7 +526,7 @@ function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
|
||||
return $courseoptions[$key];
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id, IGNORE_MISSING);
|
||||
$canparticipate = (is_enrolled($coursecontext) or is_viewing($coursecontext));
|
||||
|
||||
if (has_capability('moodle/blog:view', $coursecontext)) {
|
||||
@ -587,7 +587,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
}
|
||||
|
||||
// Check the user can associate with the module
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:associatemodule', $sitecontext)) {
|
||||
return $options;
|
||||
}
|
||||
@ -604,7 +604,7 @@ function blog_get_options_for_module($module, $user=null) {
|
||||
return $moduleoptions[$module->id];
|
||||
}
|
||||
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $module->id);
|
||||
$modcontext = context_module::instance($module->id, IGNORE_MISSING);
|
||||
$canparticipate = (is_enrolled($modcontext) or is_viewing($modcontext));
|
||||
|
||||
if (has_capability('moodle/blog:view', $modcontext)) {
|
||||
@ -719,7 +719,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
$headers['strview'] = null;
|
||||
|
||||
$site = $DB->get_record('course', array('id' => SITEID));
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
// Common Lang strings
|
||||
$strparticipants = get_string("participants");
|
||||
$strblogentries = get_string("blogentries", 'blog');
|
||||
@ -761,7 +761,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
// Case 1: No entry, mod, course or user params: all site entries to be shown (filtered by search and tag/tagid)
|
||||
// Note: if action is set to 'add' or 'edit', we do this at the end
|
||||
if (empty($entryid) && empty($modid) && empty($courseid) && empty($userid) && !in_array($action, array('edit', 'add'))) {
|
||||
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$PAGE->navbar->add($strblogentries, $blogurl);
|
||||
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
|
||||
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
|
||||
@ -784,7 +784,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
} else {
|
||||
$mycourseid = $site->id;
|
||||
}
|
||||
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
|
||||
$PAGE->navbar->add($strblogentries, $blogurl);
|
||||
|
||||
@ -803,7 +803,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 3: A user's blog entries
|
||||
if (!empty($userid) && empty($entryid) && ((empty($courseid) && empty($modid)) || !$CFG->useblogassociations)) {
|
||||
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$blogurl->param('userid', $userid);
|
||||
$PAGE->set_title("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
|
||||
$PAGE->set_heading("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
|
||||
@ -814,7 +814,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 4: No blog associations, no userid
|
||||
if (!$CFG->useblogassociations && empty($userid) && !in_array($action, array('edit', 'add'))) {
|
||||
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
|
||||
$PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
|
||||
$headers['heading'] = get_string('siteblog', 'blog', $shortname);
|
||||
@ -822,7 +822,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 5: Blog entries associated with an activity by a specific user (courseid ignored)
|
||||
if (!empty($userid) && !empty($modid) && empty($entryid)) {
|
||||
$shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$shortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$blogurl->param('userid', $userid);
|
||||
$blogurl->param('modid', $modid);
|
||||
|
||||
@ -845,8 +845,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 6: Blog entries associated with a course by a specific user
|
||||
if (!empty($userid) && !empty($courseid) && empty($modid) && empty($entryid)) {
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$blogurl->param('userid', $userid);
|
||||
$blogurl->param('courseid', $courseid);
|
||||
|
||||
@ -857,7 +857,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
$a = new stdClass();
|
||||
$a->user = fullname($user);
|
||||
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$a->course = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
|
||||
$a->type = get_string('course');
|
||||
$headers['heading'] = get_string('blogentriesbyuseraboutcourse', 'blog', $a);
|
||||
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
|
||||
@ -869,8 +869,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 7: Blog entries by members of a group, associated with that group's course
|
||||
if (!empty($groupid) && empty($modid) && empty($entryid)) {
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$blogurl->param('courseid', $course->id);
|
||||
|
||||
$PAGE->navbar->add($strblogentries, $blogurl);
|
||||
@ -883,7 +883,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
$a = new stdClass();
|
||||
$a->group = $group->name;
|
||||
$a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$a->course = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
|
||||
$a->type = get_string('course');
|
||||
$headers['heading'] = get_string('blogentriesbygroupaboutcourse', 'blog', $a);
|
||||
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
|
||||
@ -892,8 +892,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 8: Blog entries by members of a group, associated with an activity in that course
|
||||
if (!empty($groupid) && !empty($modid) && empty($entryid)) {
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$headers['cm'] = $cm;
|
||||
$blogurl->param('modid', $modid);
|
||||
$PAGE->navbar->add($strblogentries, $blogurl);
|
||||
@ -916,8 +916,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 9: All blog entries associated with an activity
|
||||
if (!empty($modid) && empty($userid) && empty($groupid) && empty($entryid)) {
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$PAGE->set_cm($cm, $course);
|
||||
$blogurl->param('modid', $modid);
|
||||
$PAGE->navbar->add($strblogentries, $blogurl);
|
||||
@ -932,15 +932,15 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
|
||||
// Case 10: All blog entries associated with a course
|
||||
if (!empty($courseid) && empty($userid) && empty($groupid) && empty($modid) && empty($entryid)) {
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$siteshortname = format_string($site->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$blogurl->param('courseid', $courseid);
|
||||
$PAGE->navbar->add($strblogentries, $blogurl);
|
||||
$PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
|
||||
$PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
|
||||
$a = new stdClass();
|
||||
$a->type = get_string('course');
|
||||
$headers['heading'] = get_string('blogentriesabout', 'blog', format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))));
|
||||
$headers['heading'] = get_string('blogentriesabout', 'blog', format_string($course->fullname, true, array('context' => context_course::instance($course->id))));
|
||||
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
|
||||
$headers['strview'] = get_string('viewblogentries', 'blog', $a);
|
||||
$blogurl->remove_params(array('userid'));
|
||||
@ -987,9 +987,9 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
|
||||
*/
|
||||
function blog_get_associated_count($courseid, $cmid=null) {
|
||||
global $DB;
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
if ($cmid) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cmid);
|
||||
$context = context_module::instance($cmid);
|
||||
}
|
||||
return $DB->count_records('blog_association', array('contextid' => $context->id));
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class blog_entry {
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
// Comments
|
||||
$cmt = new stdClass();
|
||||
$cmt->context = get_context_instance(CONTEXT_USER, $user->id);
|
||||
$cmt->context = context_user::instance($user->id);
|
||||
$cmt->courseid = $PAGE->course->id;
|
||||
$cmt->area = 'format_blog';
|
||||
$cmt->itemid = $this->id;
|
||||
@ -159,7 +159,7 @@ class blog_entry {
|
||||
$topiccell->text = $OUTPUT->container($titlelink, 'subject');
|
||||
$topiccell->text .= $OUTPUT->container_start('author');
|
||||
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $PAGE->course->id)));
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', context_course::instance($PAGE->course->id)));
|
||||
$by = new stdClass();
|
||||
$by->name = html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $PAGE->course->id)), $fullname);
|
||||
$by->date = $template['created'];
|
||||
@ -247,7 +247,7 @@ class blog_entry {
|
||||
|
||||
// First find and show the associated course
|
||||
foreach ($blogassociations as $assocrec) {
|
||||
$context = get_context_instance_by_id($assocrec->contextid);
|
||||
$context = context::instance_by_id($assocrec->contextid);
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$assocurl = new moodle_url('/course/view.php', array('id' => $context->instanceid));
|
||||
$text = $DB->get_field('course', 'shortname', array('id' => $context->instanceid)); //TODO: performance!!!!
|
||||
@ -259,7 +259,7 @@ class blog_entry {
|
||||
|
||||
// Now show mod association
|
||||
foreach ($blogassociations as $assocrec) {
|
||||
$context = get_context_instance_by_id($assocrec->contextid);
|
||||
$context = context::instance_by_id($assocrec->contextid);
|
||||
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
if ($hascourseassocs) {
|
||||
@ -375,7 +375,7 @@ class blog_entry {
|
||||
public function edit($params=array(), $form=null, $summaryoptions=array(), $attachmentoptions=array()) {
|
||||
global $CFG, $USER, $DB, $PAGE;
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
$entry = $this;
|
||||
|
||||
$this->form = $form;
|
||||
@ -447,7 +447,7 @@ class blog_entry {
|
||||
$assocobject->blogid = $this->id;
|
||||
$DB->insert_record('blog_association', $assocobject);
|
||||
|
||||
$context = get_context_instance_by_id($contextid);
|
||||
$context = context::instance_by_id($contextid);
|
||||
$courseid = null;
|
||||
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
@ -495,7 +495,7 @@ class blog_entry {
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$syscontext = context_system::instance();
|
||||
|
||||
$files = $fs->get_area_files($syscontext->id, 'blog', 'attachment', $this->id);
|
||||
|
||||
@ -576,7 +576,7 @@ class blog_entry {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
if (has_capability('moodle/blog:manageentries', $sitecontext)) {
|
||||
return true; // can edit any blog entry
|
||||
@ -600,7 +600,7 @@ class blog_entry {
|
||||
*/
|
||||
public function can_user_view($targetuserid) {
|
||||
global $CFG, $USER, $DB;
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
if (empty($CFG->bloglevel) || !has_capability('moodle/blog:view', $sitecontext)) {
|
||||
return false; // blog system disabled or user has no blog view capability
|
||||
@ -638,7 +638,7 @@ class blog_entry {
|
||||
|
||||
case BLOG_USER_LEVEL:
|
||||
default:
|
||||
$personalcontext = get_context_instance(CONTEXT_USER, $targetuserid);
|
||||
$personalcontext = context_user::instance($targetuserid);
|
||||
return has_capability('moodle/user:readuserblogs', $personalcontext);
|
||||
break;
|
||||
}
|
||||
@ -753,11 +753,11 @@ class blog_listing {
|
||||
|
||||
// fix for MDL-9165, use with readuserblogs capability in a user context can read that user's private blogs
|
||||
// admins can see all blogs regardless of publish states, as described on the help page
|
||||
if (has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/user:readuserblogs', context_system::instance())) {
|
||||
// don't add permission constraints
|
||||
|
||||
} else if(!empty($this->filters['user']) && has_capability('moodle/user:readuserblogs',
|
||||
get_context_instance(CONTEXT_USER, (empty($this->filters['user']->id) ? 0 : $this->filters['user']->id)))) {
|
||||
context_user::instance((empty($this->filters['user']->id) ? 0 : $this->filters['user']->id)))) {
|
||||
// don't add permission constraints
|
||||
|
||||
} else {
|
||||
@ -808,7 +808,7 @@ class blog_listing {
|
||||
*/
|
||||
public function print_entries() {
|
||||
global $CFG, $USER, $DB, $OUTPUT;
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
$page = optional_param('blogpage', 0, PARAM_INT);
|
||||
$limit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
|
||||
@ -1020,7 +1020,7 @@ class blog_filter_context extends blog_filter {
|
||||
// Ignore course filter if blog associations are not enabled
|
||||
if ($this->id != $SITE->id && !empty($CFG->useblogassociations)) {
|
||||
$this->overrides = array('site');
|
||||
$context = get_context_instance(CONTEXT_COURSE, $this->id);
|
||||
$context = context_course::instance($this->id);
|
||||
$this->tables['ba'] = 'blog_association';
|
||||
$this->conditions[] = 'p.id = ba.blogid';
|
||||
$this->conditions[] = 'ba.contextid = '.$context->id;
|
||||
@ -1036,7 +1036,7 @@ class blog_filter_context extends blog_filter {
|
||||
if (!empty($CFG->useblogassociations)) {
|
||||
$this->overrides = array('course', 'site');
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $this->id);
|
||||
$context = context_module::instance($this->id);
|
||||
$this->tables['ba'] = 'blog_association';
|
||||
$this->tables['p'] = 'post';
|
||||
$this->conditions = array('p.id = ba.blogid', 'ba.contextid = ?');
|
||||
@ -1086,7 +1086,7 @@ class blog_filter_user extends blog_filter {
|
||||
$this->params[] = $this->id;
|
||||
|
||||
if (!empty($CFG->useblogassociations)) { // only show blog entries associated with this course
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $DB->get_field('groups', 'courseid', array('id' => $this->id)));
|
||||
$coursecontext = context_course::instance($DB->get_field('groups', 'courseid', array('id' => $this->id)));
|
||||
$this->tables['ba'] = 'blog_association';
|
||||
$this->conditions[] = 'gm.groupid = ?';
|
||||
$this->conditions[] = 'ba.contextid = ?';
|
||||
|
@ -57,11 +57,11 @@ $PAGE->set_pagelayout('standard');
|
||||
|
||||
if ($courseid == SITEID) {
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_system::instance();
|
||||
$PAGE->set_context($context);
|
||||
} else {
|
||||
require_login($courseid);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
}
|
||||
|
||||
if (empty($CFG->bloglevel)) {
|
||||
|
@ -119,7 +119,7 @@ function blog_rss_add_http_header($context, $title, $filtertype, $filterselect=0
|
||||
function blog_rss_get_params($filters) {
|
||||
$thingid = $rsscontext = $filtertype = null;
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
|
||||
if (!$filters) {
|
||||
$thingid = SITEID;
|
||||
@ -128,14 +128,14 @@ function blog_rss_get_params($filters) {
|
||||
} else if (array_key_exists('course', $filters)) {
|
||||
$thingid = $filters['course'];
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $thingid);
|
||||
$coursecontext = context_course::instance($thingid);
|
||||
$rsscontext = $coursecontext;
|
||||
|
||||
$filtertype = 'course';
|
||||
} else if (array_key_exists('user', $filters)) {
|
||||
$thingid = $filters['user'];
|
||||
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $thingid);
|
||||
$usercontext = context_user::instance($thingid);
|
||||
$rsscontext = $usercontext;
|
||||
|
||||
$filtertype = 'user';
|
||||
@ -163,7 +163,7 @@ function blog_rss_get_feed($context, $args) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$sitecontext = context_system::instance();
|
||||
if (!has_capability('moodle/blog:view', $sitecontext)) {
|
||||
return null;
|
||||
}
|
||||
@ -242,10 +242,10 @@ function blog_rss_get_feed($context, $args) {
|
||||
break;
|
||||
case 'course':
|
||||
$info = $DB->get_field('course', 'fullname', array('id'=>$id));
|
||||
$info = format_string($info, true, array('context' => get_context_instance(CONTEXT_COURSE, $id)));
|
||||
$info = format_string($info, true, array('context' => context_course::instance($id)));
|
||||
break;
|
||||
case 'site':
|
||||
$info = format_string($SITE->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
|
||||
$info = format_string($SITE->fullname, true, array('context' => context_course::instance(SITEID)));
|
||||
break;
|
||||
case 'group':
|
||||
$group = groups_get_group($id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user