From 6a933f1308e946325d5b8f639c1788e800a9a9f1 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 14 May 2008 05:56:10 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- enrol/authorize/enrol_form.php | 2 +- enrol/authorize/index.php | 4 ++-- enrol/authorize/locallib.php | 15 +++++++++------ enrol/authorize/uploadcsv.php | 8 +++----- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index eea8655f58..77ec0234da 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -11,7 +11,7 @@ class enrol_authorize_form extends moodleform $paymentmethodsenabled = get_list_of_payment_methods(); $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA); if (!in_array($paymentmethod, $paymentmethodsenabled)) { - print_error("Invalid payment method: $paymentmethod"); + print_error('invalidpaymentmethod', '', '', $paymentmethod); } $mform =& $this->_form; diff --git a/enrol/authorize/index.php b/enrol/authorize/index.php index 12d416756d..60146ac9f2 100644 --- a/enrol/authorize/index.php +++ b/enrol/authorize/index.php @@ -14,13 +14,13 @@ /// Get course if (! $course = get_record('course', 'id', $courseid)) { - print_error('Could not find that course'); + print_error('invaliduserid'); } /// Only SITE users can access to this page require_login(); // Don't use $courseid! User may want to see old orders. if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) { - print_error("Guests cannot use this page."); + print_error('noguest'); } /// Load strings. All strings should be defined here. locallib.php uses these strings. diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index 09f3e42ae5..6b7c79337a 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -211,15 +211,16 @@ function authorize_print_order($orderid) $confirm = optional_param('confirm', 0, PARAM_BOOL); if (!$order = get_record('enrol_authorize', 'id', $orderid)) { - print_error("Order $orderid not found.", '', "$CFG->wwwroot/enrol/authorize/index.php"); + print_error('orderidnotfound', '', + "$CFG->wwwroot/enrol/authorize/index.php", $orderid); } if (!$course = get_record('course', 'id', $order->courseid)) { - print_error("Could not find that course id $order->courseid", '', "$CFG->wwwroot/enrol/authorize/index.php"); + print_error('invalidcourseid', '', "$CFG->wwwroot/enrol/authorize/index.php"); } if (!$user = get_record('user', 'id', $order->userid)) { - print_error("Could not find that user id $order->userid", '', "$CFG->wwwroot/enrol/authorize/index.php"); + print_error('nousers', '', "$CFG->wwwroot/enrol/authorize/index.php"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); @@ -317,11 +318,13 @@ function authorize_print_order($orderid) } $upto = round($order->amount - $refunded, 2); if ($upto <= 0) { - print_error("Refunded to original amount: $order->amount", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); + print_error('refoundtoorigi', '', + "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $order->amount); } $amount = round(optional_param('amount', $upto), 2); if ($amount > $upto) { - print_error("Can be refunded to $upto", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); + print_error('refoundto', '', + "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $upto); } if ($confirm && confirm_sesskey()) { $extra = new stdClass; @@ -403,7 +406,7 @@ function authorize_print_order($orderid) $suborder = get_record_sql($sql); if (!$suborder) { // not found - print_error("Transaction can not be voided because of already been voided.", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); + print_error('transactionvoid', '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); } $refundedstatus = authorize_get_status_action($suborder); unset($suborder->courseid); diff --git a/enrol/authorize/uploadcsv.php b/enrol/authorize/uploadcsv.php index 940033abcd..288c53d54e 100644 --- a/enrol/authorize/uploadcsv.php +++ b/enrol/authorize/uploadcsv.php @@ -76,13 +76,13 @@ function authorize_process_csv($filename) /// Open the file and get first line $handle = fopen($filename, "r"); if (!$handle) { - print_error('CANNOT OPEN CSV FILE'); + print_error('cannotopencsv'); } $firstline = fgetcsv($handle, 8192, ","); $numfields = count($firstline); if ($numfields != 49 && $numfields != 70) { @fclose($handle); - print_error('INVALID CSV FILE; Each line must include 49 or 70 fields'); + print_error('csvinvalidcolsnum'); } /// Re-sort fields @@ -97,9 +97,7 @@ function authorize_process_csv($filename) } if (empty($csvfields)) { @fclose($handle); - print_error("INVALID CSV FILE: First line must include 'Header Fields' and - the file must be type of
'Expanded Fields/Comma Separated'
or
- 'Expanded Fields with CAVV Result Code/Comma Separated'"); + print_error('csvinvalidcols'); } /// Read lines -- 2.39.5