From fae11dca5662029cfbcb5be95dcb917ef3dc3bc9 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 24 Apr 2008 02:24:49 +0000 Subject: [PATCH] MDL-14129, fix print_error call --- blog/edit.php | 24 ++++++++++++------------ blog/header.php | 8 ++++---- lang/en_utf8/blog.php | 2 ++ lang/en_utf8/error.php | 5 ++++- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/blog/edit.php b/blog/edit.php index 0e858febfa..888dc18db0 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -12,7 +12,7 @@ $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tab - d require_login($courseid); if (empty($CFG->bloglevel)) { - print_error('Blogging is disabled!'); + print_error('blogdisable', 'blog'); } if (isguest()) { @@ -21,13 +21,13 @@ if (isguest()) { $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); if (!has_capability('moodle/blog:create', $sitecontext) and !has_capability('moodle/blog:manageentries', $sitecontext)) { - print_error('You can not post or edit blogs.'); + print_error('cannoteditpostorblog'); } // Make sure that the person trying to edit have access right if ($id) { if (!$existing = get_record('post', 'id', $id)) { - print_error('Wrong blog post id'); + print_error('wrongpostid', 'blog'); } if (!blog_user_can_edit_post($existing)) { @@ -52,7 +52,7 @@ $strblogs = get_string('blogs','blog'); if ($action=='delete'){ if (!$existing) { - print_error('Incorrect blog post id'); + print_error('wrongpostid', 'blog'); } if (data_submitted() and $confirm and confirm_sesskey()) { do_delete($existing); @@ -83,12 +83,12 @@ if ($blogeditform->is_cancelled()){ case 'edit': if (!$existing) { - print_error('Incorrect blog post id'); + print_error('wrongpostid', 'blog'); } do_edit($fromform, $blogeditform); break; default : - print_error('Unknown action!'); + print_error('invalidaction'); } redirect($returnurl); } @@ -105,7 +105,7 @@ switch ($action) { case 'edit': if (!$existing) { - print_error('Incorrect blog post id'); + print_error('wrongpostid', 'blog'); } $post->id = $existing->id; $post->subject = $existing->subject; @@ -124,12 +124,12 @@ switch ($action) { } break; default : - print_error('Unknown action!'); + print_error('unknowaction'); } // done here in order to allow deleting of posts with wrong user id above if (!$user = get_record('user', 'id', $userid)) { - print_error('Incorrect user id'); + print_error('invaliduserid'); } $navlinks = array(); $navlinks[] = array('name' => fullname($user), 'link' => "$CFG->wwwroot/user/view.php?id=$userid", 'type' => 'misc'); @@ -164,7 +164,7 @@ function do_delete($post) { add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id); if (!$status) { - print_error('Error occured while deleting post', '', $returnurl); + print_error('deleteposterror', 'blog', $returnurl); } } @@ -191,7 +191,7 @@ function do_add($post, $blogeditform) { add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject); } else { - print_error('There was an error adding this post in the database', '', $returnurl); + print_error('deleteposterror', 'blog', $returnurl); } } @@ -226,7 +226,7 @@ function do_edit($post, $blogeditform) { add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject); } else { - print_error('There was an error updating this post in the database', '', $returnurl); + print_error('deleteposterror', 'blog', $returnurl); } } diff --git a/blog/header.php b/blog/header.php index aee8625334..63234d0c8a 100755 --- a/blog/header.php +++ b/blog/header.php @@ -17,7 +17,7 @@ blog_check_and_install_blocks(); if (!$course = get_record('course', 'id', $courseid)) { - print_error('The course number was incorrect ('. $courseid .')'); + print_error('invalidcourseid', '', '', $courseid); } // Bounds for block widths @@ -99,7 +99,7 @@ $tagstring = get_string('tag'); // needed also for user tabs later if (!$course = get_record('course', 'id', $courseid)) { - print_error('Wrong course id'); + print_error('invalidcourseid', '', '', $courseid); } $navlinks = array(); @@ -157,7 +157,7 @@ $navlinks = array(); print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); } } else { - print_error('Unable to find group'); + print_error('cannotfindgroup'); } break; @@ -165,7 +165,7 @@ $navlinks = array(); case 'user': $participants = get_string('participants'); if (!$user = get_record('user', 'id', $filterselect)) { - print_error('Wrong user id'); + print_error('invaliduserid'); } if ($course->id != SITEID) { diff --git a/lang/en_utf8/blog.php b/lang/en_utf8/blog.php index d42dcffe77..2e2d30154d 100755 --- a/lang/en_utf8/blog.php +++ b/lang/en_utf8/blog.php @@ -22,6 +22,7 @@ $string['courseblogdisable'] = 'Course blogs is not enabled'; $string['courseblogs'] = 'Users can only see blogs for people who share a course'; $strign['donothaveblog'] = 'You do not have your own blog, sorry.'; $string['deleteotagswarn'] = 'Are you sure you want to remove this / these tags
from all blog posts and remove it from the system?'; +$string['deleteposterror'] = 'Error occured while deleting post'; $string['disableblogs'] = 'Disable blog system completely'; $string['emptybody'] = 'Blog entry body can not be empty'; $string['emptytitle'] = 'Blog entry title can not be empty'; @@ -63,6 +64,7 @@ $string['userblog'] = 'User blog: $a'; $string['viewcourseentries'] = 'View course entries'; $string['viewmyentries'] = 'View my entries'; $string['viewsiteentries'] = 'View site entries'; +$string['wrongpostid'] = 'Wrong blog post id'; $string['worldblogs'] = 'The world can read entries set to be world-accessible'; ?> diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index dcee94252f..80fbbf3cde 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -22,10 +22,12 @@ $string['cannotdeleterolewithid'] = 'Could not delete role with ID $a'; $string['cannotdownloadcomponents'] = 'Cannot download components.'; $string['cannotdownloadlanguageupdatelist'] = 'Cannot download list of language updates from download.moodle.org'; $string['cannotdownloadzipfile'] = 'Cannot download ZIP file.'; +$string['cannoteditpostorblog'] = 'You can not post or edit blogs.'; $string['cannoteditmasterlang'] = 'You do not have permission to edit master language package. This permission is controlled by the capability "moodle/site:langeditmaster". Set this capability to allow you to edit master language packages in case you are the maintainer of a package.'; $string['cannotfindcomponent'] = 'Cannot find component.'; $string['cannotfindcategory'] = 'Cannot find category record from database by ID - $a'; $string['cannotfinddocs'] = 'Cannot find \"$a\" language docs files'; +$string['cannotfindgroup'] = 'Unable to find group'; $string['cannotfindinfo'] = 'Cannot find info for: \"$a\"'; $string['cannotfindhelp'] = 'Cannot find \"$a\" language help files'; $string['cannotfindlang'] = 'Cannot find \"$a\" language pack!'; @@ -83,7 +85,7 @@ $string['invalidaction'] = 'Invalid action parameter.'; $string['invalidarguments'] = 'No valid arguments supplied'; $string['invalidaccessparameter'] = 'Invalid access parameter.'; $string['invalidcourse'] = 'Invalid course'; -$string['invalidcourseid'] = 'You are tring to view an invalid course. Id: $a'; +$string['invalidcourseid'] = 'You are tring to use an invalid course ID: ($a)'; $string['invalidcoursemodule'] = 'Bad course module ID'; $string['invalidfieldname'] = '\"$a\" is not a valid field name'; $string['invalidfiletype'] = '\"$a\" is not a valid file type'; @@ -152,6 +154,7 @@ $string['statscatchupmode'] = 'Statistics is currently in catchup mode. So far $ $string['tagnotfound'] = 'The specified tag was not found in the database'; $string['unicodeupgradeerror'] = 'Sorry, but your database is not already in Unicode, and this version of Moodle is not able to migrate your database to Unicode. Please upgrade to Moodle 1.7.x first and perform the Unicode migration from the Admin page. After that is done you should be able to migrate to Moodle $a'; $string['statsnodata'] = 'There is no available data for that combination of course and time period.'; +$string['unknowaction']= 'Unknown action!'; $string['unknowncourse'] = 'Unknown course named \"$a\"'; $string['unknowncourseidnumber'] = 'Unknown Course ID \"$a\"'; $string['unknowngroup'] = 'Unknown group \"$a\"'; -- 2.39.5