Skip to content

Commit

Permalink
Merge branch 'wip-MDL-34457-master' of git://github.com/abgreeve/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jul 24, 2012
2 parents c14ecac + 41b3836 commit 7bc0f80
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 74 deletions.
14 changes: 7 additions & 7 deletions blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@

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
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();
Expand All @@ -77,7 +77,7 @@
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');
}
Expand Down Expand Up @@ -143,7 +143,7 @@
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:
Expand Down Expand Up @@ -215,13 +215,13 @@

//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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions blog/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function definition() {
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;
Expand All @@ -94,9 +94,9 @@ function definition() {
$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));
Expand Down Expand Up @@ -131,7 +131,7 @@ function validation($data, $files) {
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)) {
Expand Down
2 changes: 1 addition & 1 deletion blog/external_blog_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion blog/external_blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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);
Expand Down
10 changes: 5 additions & 5 deletions blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
$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) {
Expand Down Expand Up @@ -122,15 +122,15 @@
}

$courseid = $course->id;
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$coursecontext = context_course::instance($course->id);

require_login($course);

if (!has_capability('moodle/blog:view', $coursecontext)) {
print_error('cannotviewcourseblog', 'blog');
}
} else {
$coursecontext = get_context_instance(CONTEXT_COURSE, SITEID);
$coursecontext = context_course::instance(SITEID);
}

if (!empty($groupid)) {
Expand All @@ -146,7 +146,7 @@
print_error('invalidcourseid');
}

$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$coursecontext = context_course::instance($course->id);
$courseid = $course->id;
require_login($course);

Expand Down Expand Up @@ -183,7 +183,7 @@
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');
Expand Down
Loading

0 comments on commit 7bc0f80

Please sign in to comment.