Skip to content

Commit

Permalink
"MDL-14460,fix get_context_instance, merged from MOODLE_19_STABLE"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Apr 30, 2008
1 parent 33aa572 commit d9d16e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
print_error('noguestpost', 'blog');
}

$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
if (!has_capability('moodle/blog:create', $sitecontext) and !has_capability('moodle/blog:manageentries', $sitecontext)) {
print_error('cannoteditpostorblog');
}
Expand Down
2 changes: 1 addition & 1 deletion blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
print_error('blogdisable', 'blog');
}

$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);


// change block edit staus if not guest and logged in
Expand Down
10 changes: 5 additions & 5 deletions blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function blog_print_html_formatted_entries($postid, $filtertype, $filterselect,
$bloglimit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
$start = $blogpage * $bloglimit;

$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);

$morelink = '<br />&nbsp;&nbsp;';

Expand Down Expand Up @@ -369,7 +369,7 @@ function blog_user_can_edit_post($blogEntry) {

global $CFG, $USER;

$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);

if (has_capability('moodle/blog:manageentries', $sitecontext)) {
return true; // can edit any blog post
Expand Down Expand Up @@ -400,7 +400,7 @@ function blog_user_can_view_user_post($targetuserid, $blogEntry=null) {
return true; // can view own posts in any case
}

$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/blog:manageentries', $sitecontext)) {
return true; // can manage all posts
}
Expand Down Expand Up @@ -524,15 +524,15 @@ function blog_fetch_entries($postid='', $fetchlimit=10, $fetchstart='', $filtert
$tagquerysql = '';
}

if (isloggedin() && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM, SITEID), $USER->id, false)) {
if (isloggedin() && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) {
$permissionsql = 'AND (p.publishstate = \'site\' OR p.publishstate = \'public\' OR p.userid = '.$USER->id.')';
} else {
$permissionsql = 'AND p.publishstate = \'public\'';
}

// 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, SITEID))) {
if (has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) {
$permissionsql = '';
} else if ($filtertype=='user' && has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_USER, $filterselect))) {
$permissionsql = '';
Expand Down
2 changes: 1 addition & 1 deletion blog/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

if ($courseid == SITEID) {
require_login();
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
$context = get_context_instance(CONTEXT_SYSTEM);
} else {
require_login($courseid);
$context = get_context_instance(CONTEXT_COURSE, $courseid);
Expand Down
2 changes: 1 addition & 1 deletion calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ function calendar_get_default_courses($ignoreref = false) {
}

$courses = array();
if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
if (!empty($CFG->calendar_adminseesall)) {
$courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course');
return $courses;
Expand Down

0 comments on commit d9d16e5

Please sign in to comment.