Skip to content

Commit

Permalink
IT: Remove print_error() from blue plugins [M41] #674555
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason.Platts authored and sammarshallou committed Jun 15, 2023
1 parent 8e42655 commit c6bccb3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions classes/portfolio_caller.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ protected function prepare_post($post, $usehtmls = true) {
$output .= \html_writer::start_tag('body') . "\n";
}
if (!$oublog = oublog_get_blog_from_postid($post->id)) {
print_error('invalidpost', 'oublog');
throw new moodle_exception('invalidpost', 'oublog');
}
if (!$cm = get_coursemodule_from_instance('oublog', $oublog->id)) {
print_error('invalidcoursemodule');
throw new moodle_exception('invalidcoursemodule');
}
$oublogoutput = $PAGE->get_renderer('mod_oublog');
$context = \context_module::instance($cm->id);
Expand Down
8 changes: 4 additions & 4 deletions deletepost.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
}
// Send an email to the author of the post.
if (!email_to_user($user, $from, $post->title, html_to_text($messagehtml), $messagehtml)) {
print_error(get_string('emailerror', 'oublog'));
throw new moodle_exception('emailerror', 'oublog');
}

// Prepare for copies.
Expand All @@ -148,7 +148,7 @@
// Send an email copy to the current user, with prefered format.
$subject = strtoupper(get_string('copy')) . ' - '. $post->title;
if (!email_to_user($USER, $from, $subject, html_to_text($messagehtml), $messagehtml)) {
print_error(get_string('emailerror', 'oublog'));
throw new moodle_exception('emailerror', 'oublog');
}
}

Expand All @@ -167,7 +167,7 @@
'id' => -1
);
if (!email_to_user($fakeuser, $from, $subject, '', $messagehtml)) {
print_error(get_string('emailerror', 'oublog'));
throw new moodle_exception('emailerror', 'oublog');
}
}
}
Expand Down Expand Up @@ -241,7 +241,7 @@ function oublog_do_delete($course, $cm, $oublog, $post) {
$DB->update_record('oublog_posts', $updatepost);
if (!oublog_update_item_tags($post->oubloginstancesid, $post->id,
array(), $post->visibility)) {
print_error('tagupdatefailed', 'oublog');
throw new moodle_exception('tagupdatefailed', 'oublog');
}
if (oublog_search_installed() && !local_ousearch_indexingdisabled()) {
$doc = oublog_get_search_document($updatepost, $cm);
Expand Down
14 changes: 7 additions & 7 deletions editcomment.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@
$correctglobal = isset($childoublog->global) ? $childoublog->global : $oublog->global;
$post->userid=$oubloginstance->userid; // oublog_can_view_post needs this
if (!oublog_can_view_post($post, $USER, $context, $cm, $oublog, $childcm, $childoublog)) {
print_error('accessdenied', 'oublog');
throw new moodle_exception('accessdenied', 'oublog');
}

oublog_get_activity_groupmode($childcm ? $childcm : $cm, $childcourse ? $childcourse : $course);
if (!oublog_can_comment($childcm ? $childcm : $cm, $childoublog ? $childoublog : $oublog, $post)) {
print_error('accessdenied', 'oublog');
throw new moodle_exception('accessdenied', 'oublog');
}

if ($oublog->allowcomments == OUBLOG_COMMENTS_PREVENT || $post->allowcomments == OUBLOG_COMMENTS_PREVENT ||
(!empty($childoublog->allowcomments) && $childoublog->allowcomments == OUBLOG_COMMENTS_PREVENT)) {
print_error('commentsnotallowed', 'oublog');
throw new moodle_exception('commentsnotallowed', 'oublog');
}
$viewurl = !empty($referurl) ? $referurl : new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
if ($correctglobal) {
$blogtype = 'personal';
if (!$oubloguser = $DB->get_record('user', array('id'=>$oubloginstance->userid))) {
print_error('invaliduserid');
throw new moodle_exception('invaliduserid');
}
} else {
$blogtype = 'course';
Expand Down Expand Up @@ -160,7 +160,7 @@
if ($moderated) {
// Check IP address
if (oublog_too_many_comments_from_ip()) {
print_error('error_toomanycomments', 'oublog');
throw new moodle_exception('error_toomanycomments', 'oublog');
}

// Set the confirmed cookie if they haven't got it yet
Expand All @@ -170,7 +170,7 @@
}

if (!oublog_add_comment_moderated($oublog, $oubloginstance, $post, $comment)) {
print_error('couldnotaddcomment', 'oublog');
throw new moodle_exception('couldnotaddcomment', 'oublog');
}
$approvaltime = oublog_get_typical_approval_time($post->userid);

Expand All @@ -188,7 +188,7 @@
$comment->userid = $USER->id;

if (!oublog_add_comment($course, $cm, $oublog, $comment)) {
print_error('couldnotaddcomment', 'oublog');
throw new moodle_exception('couldnotaddcomment', 'oublog');
}

// Log add comment event.
Expand Down
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function oublog_delete_instance($oublogid) {
$moduleid=$DB->get_field('modules', 'id', array('name'=>'oublog'));
$cm=$DB->get_record('course_modules', array('module'=>$moduleid, 'instance'=>$oublog->id));
if (!$cm) {
print_error('invalidcoursemodule');
throw new moodle_exception('invalidcoursemodule');
}
local_ousearch_document::delete_module_instance_data($cm);
}
Expand Down

0 comments on commit c6bccb3

Please sign in to comment.