mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-14129, fix print_error() call, see tracker
This commit is contained in:
parent
e31a44ee20
commit
8b141784a8
3 changed files with 20 additions and 20 deletions
|
@ -57,7 +57,7 @@ class page_blog extends page_base {
|
||||||
$courserecord = NULL;
|
$courserecord = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (! ($courserecord = get_record('course', 'id', $this->courseid)) ) {
|
if (! ($courserecord = get_record('course', 'id', $this->courseid)) ) {
|
||||||
print_error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' );
|
print_error('invalidcourseid', 'error', '', $this->courseid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->full_init_done = true;
|
$this->full_init_done = true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tab
|
||||||
|
|
||||||
|
|
||||||
if (empty($CFG->bloglevel)) {
|
if (empty($CFG->bloglevel)) {
|
||||||
print_error('Blogging is disabled!');
|
print_error('blogdisable', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||||
|
@ -63,53 +63,53 @@ switch ($filtertype) {
|
||||||
|
|
||||||
case 'site':
|
case 'site':
|
||||||
if ($CFG->bloglevel < BLOG_SITE_LEVEL) {
|
if ($CFG->bloglevel < BLOG_SITE_LEVEL) {
|
||||||
print_error('Site blogs is not enabled');
|
print_error('siteblogdisable', 'blog');
|
||||||
}
|
}
|
||||||
if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
|
if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
|
||||||
require_login();
|
require_login();
|
||||||
}
|
}
|
||||||
if (!has_capability('moodle/blog:view', $sitecontext)) {
|
if (!has_capability('moodle/blog:view', $sitecontext)) {
|
||||||
print_error('You do not have the required permissions to view all site blogs');
|
print_error('cannotviewsiteblog', 'blog');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'course':
|
case 'course':
|
||||||
if ($CFG->bloglevel < BLOG_COURSE_LEVEL) {
|
if ($CFG->bloglevel < BLOG_COURSE_LEVEL) {
|
||||||
print_error('Course blogs is not enabled');
|
print_error('courseblogdisable', 'blog');
|
||||||
}
|
}
|
||||||
if (!$course = get_record('course', 'id', $filterselect)) {
|
if (!$course = get_record('course', 'id', $filterselect)) {
|
||||||
print_error('Incorrect course id specified');
|
print_error('invalidcourseid');
|
||||||
}
|
}
|
||||||
$courseid = $course->id;
|
$courseid = $course->id;
|
||||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||||
require_login($course);
|
require_login($course);
|
||||||
if (!has_capability('moodle/blog:view', $coursecontext)) {
|
if (!has_capability('moodle/blog:view', $coursecontext)) {
|
||||||
print_error('You do not have the required permissions to view blogs in this course');
|
print_error('cannotviewcourseblog', 'blog');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'group':
|
case 'group':
|
||||||
if ($CFG->bloglevel < BLOG_GROUP_LEVEL) {
|
if ($CFG->bloglevel < BLOG_GROUP_LEVEL) {
|
||||||
print_error('Group blogs is not enabled');
|
print_error('groupblogdisable', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix for MDL-9268
|
// fix for MDL-9268
|
||||||
if (! $group = groups_get_group($filterselect)) { //TODO:check.
|
if (! $group = groups_get_group($filterselect)) { //TODO:check.
|
||||||
print_error('Incorrect group id specified');
|
print_error('invalidgroupid');
|
||||||
}
|
}
|
||||||
if (!$course = get_record('course', 'id', $group->courseid)) {
|
if (!$course = get_record('course', 'id', $group->courseid)) {
|
||||||
print_error('Incorrect course id specified');
|
print_error('invalidcourseid');
|
||||||
}
|
}
|
||||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||||
$courseid = $course->id;
|
$courseid = $course->id;
|
||||||
require_login($course);
|
require_login($course);
|
||||||
if (!has_capability('moodle/blog:view', $coursecontext)) {
|
if (!has_capability('moodle/blog:view', $coursecontext)) {
|
||||||
print_error('You do not have the required permissions to view blogs in this course/group');
|
print_error('cannotviewcourseorgroupblog', 'blog');
|
||||||
}
|
}
|
||||||
if (groups_get_course_groupmode($course) == SEPARATEGROUPS
|
if (groups_get_course_groupmode($course) == SEPARATEGROUPS
|
||||||
and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
|
and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
|
||||||
if (!groups_is_member($filterselect)) {
|
if (!groups_is_member($filterselect)) {
|
||||||
error ('You are not a member of this course group');
|
print_error('notmemberofgroup');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,24 +117,24 @@ switch ($filtertype) {
|
||||||
|
|
||||||
case 'user':
|
case 'user':
|
||||||
if ($CFG->bloglevel < BLOG_USER_LEVEL) {
|
if ($CFG->bloglevel < BLOG_USER_LEVEL) {
|
||||||
print_error('Blogs is not enabled');
|
print_error('blogdisable', 'blog');
|
||||||
}
|
}
|
||||||
if (!$user = get_record('user', 'id', $filterselect)) {
|
if (!$user = get_record('user', 'id', $filterselect)) {
|
||||||
print_error('Incorrect user id');
|
print_error('invaliduserid');
|
||||||
}
|
}
|
||||||
if ($USER->id == $filterselect) {
|
if ($USER->id == $filterselect) {
|
||||||
if (!has_capability('moodle/blog:create', $sitecontext)
|
if (!has_capability('moodle/blog:create', $sitecontext)
|
||||||
and !has_capability('moodle/blog:view', $sitecontext)) {
|
and !has_capability('moodle/blog:view', $sitecontext)) {
|
||||||
print_error('You do not have your own blog, sorry.');
|
print_error('donothaveblog', 'blog');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$personalcontext = get_context_instance(CONTEXT_USER, $filterselect);
|
$personalcontext = get_context_instance(CONTEXT_USER, $filterselect);
|
||||||
if (!has_capability('moodle/blog:view', $sitecontext)
|
if (!has_capability('moodle/blog:view', $sitecontext)
|
||||||
and !has_capability('moodle/user:readuserblogs', $personalcontext)) {
|
and !has_capability('moodle/user:readuserblogs', $personalcontext)) {
|
||||||
print_error('You do not have the required permissions to read user blogs');
|
print_error('cannotviewuserblog', 'blog');
|
||||||
}
|
}
|
||||||
if (!blog_user_can_view_user_post($filterselect)) {
|
if (!blog_user_can_view_user_post($filterselect)) {
|
||||||
print_error('You can not view blog of this user, sorry.');
|
print_error('cannotviewcourseblog', 'blog');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$userid = $filterselect;
|
$userid = $filterselect;
|
||||||
|
@ -146,7 +146,7 @@ switch ($filtertype) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
print_error('Incorrect blog filter type specified');
|
print_error('incorrectblogfilter', 'blog');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($CFG->bloglevel)) {
|
if (empty($CFG->bloglevel)) {
|
||||||
print_error('Blogging is disabled!');
|
print_error('blogdisable', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_capability('moodle/blog:view', $context);
|
require_capability('moodle/blog:view', $context);
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
$pagesize = required_param('pagesize', PARAM_INT);
|
$pagesize = required_param('pagesize', PARAM_INT);
|
||||||
|
|
||||||
if ($pagesize < 1) {
|
if ($pagesize < 1) {
|
||||||
print_error('invalid page size');
|
print_error('invalidpagesize');
|
||||||
}
|
}
|
||||||
set_user_preference('blogpagesize', $pagesize);
|
set_user_preference('blogpagesize', $pagesize);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue