From 839958faf62ac5db903f8d79714127f1aa00b0cb Mon Sep 17 00:00:00 2001 From: ethem Date: Mon, 14 Aug 2006 15:06:11 +0000 Subject: [PATCH] * $CFG->teachermanagepayments will have to go since we are moving away from the rigid hardcoded teacher role concept. * If a teacher has_capability('enrol/authorize:managepayments'), send email about pending orders expiring. * All isteacher converted to has_capability. --- enrol/authorize/config.html | 7 ------- enrol/authorize/db/mysql.php | 6 ++++++ enrol/authorize/db/postgres7.php | 6 ++++++ enrol/authorize/enrol.php | 10 ++++++---- enrol/authorize/locallib.php | 8 +++++--- enrol/authorize/version.php | 2 +- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/enrol/authorize/config.html b/enrol/authorize/config.html index 54ad840b23..ee5ad3c9b2 100755 --- a/enrol/authorize/config.html +++ b/enrol/authorize/config.html @@ -18,7 +18,6 @@ if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5'; if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2'; if (!isset($frm->an_emailexpiredteacher)) $frm->an_emailexpiredteacher = ''; if (!isset($frm->an_sorttype)) $frm->an_sorttype = 'ttl'; -if (!isset($frm->an_teachermanagepay)) $frm->an_teachermanagepay = ''; if (isset($CFG->an_cutoff)) { $cutoff = intval($CFG->an_cutoff); @@ -59,12 +58,6 @@ if (!isset($frm->acceptccs)) { - - an_teachermanagepay: - an_teachermanagepay)) ?> - - - wwwroot, 0, 5) !== 'https') { /* https && loginhttps */ ?> loginhttps: diff --git a/enrol/authorize/db/mysql.php b/enrol/authorize/db/mysql.php index 72976ed740..de260e330e 100755 --- a/enrol/authorize/db/mysql.php +++ b/enrol/authorize/db/mysql.php @@ -117,6 +117,12 @@ function enrol_authorize_upgrade($oldversion=0) { delete_records('config_plugins', 'name', 'an_nextmail'); // run twice. } + if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7 + if (isset($CFG->an_teachermanagepay)) { + delete_records('config', 'name', 'an_teachermanagepay'); + } + } + return $result; } diff --git a/enrol/authorize/db/postgres7.php b/enrol/authorize/db/postgres7.php index a5b2c4a73c..78aec0c598 100644 --- a/enrol/authorize/db/postgres7.php +++ b/enrol/authorize/db/postgres7.php @@ -128,6 +128,12 @@ function enrol_authorize_upgrade($oldversion=0) { delete_records('config_plugins', 'name', 'an_nextmail'); // run twice. } + if ($oldversion < 2006081401) { // no need an_teachermanagepay in 1.7 + if (isset($CFG->an_teachermanagepay)) { + delete_records('config', 'name', 'an_teachermanagepay'); + } + } + return $result; } diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index df1c9870c1..6f0a5af8e4 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -477,7 +477,6 @@ class enrolment_plugin_authorize // optional authorize.net settings set_config('an_avs', optional_param('an_avs', 0, PARAM_BOOL)); set_config('an_test', optional_param('an_test', 0, PARAM_BOOL)); - set_config('an_teachermanagepay', optional_param('an_teachermanagepay', 0, PARAM_BOOL)); set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL)); $acceptccs = optional_param('acceptccs', @@ -884,8 +883,8 @@ class enrolment_plugin_authorize email_to_user($adminuser, $adminuser, $subject, $message); // Email to teachers - if (empty($CFG->an_teachermanagepay) or empty($CFG->an_emailexpiredteacher)) { - return; // teachers can't manage payments or email feature disabled for teachers. + if (empty($CFG->an_emailexpiredteacher)) { + return; // email feature disabled for teachers. } $sorttype = empty($CFG->an_sorttype) ? 'ttl' : $CFG->an_sorttype; @@ -914,8 +913,11 @@ class enrolment_plugin_authorize $a->url = $CFG->wwwroot.'/enrol/authorize/index.php?course='. $lastcourse.'&status='.AN_STATUS_AUTH; $message = get_string('pendingordersemailteacher', 'enrol_authorize', $a); + $context = get_context_instance(CONTEXT_COURSE, $lastcourse); foreach ($teachers as $teacher) { - email_to_user($teacher, $adminuser, $subject, $message); + if (has_capability('enrol/authorize:managepayments', $context, $teacher->id)) { + email_to_user($teacher, $adminuser, $subject, $message); + } } } } diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index 98c5550892..0c8f72bfe7 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -26,7 +26,8 @@ function authorize_print_orders() $perpage = 10; $status = optional_param('status', AN_STATUS_NONE, PARAM_INT); - if (! isteacher($courseid)) { + $context = get_context_instance(CONTEXT_COURSE, $courseid); + if (! has_capability('enrol/authorize:managepayments', $context)) { $userid = $USER->id; } @@ -182,8 +183,9 @@ function authorize_print_order_details($orderno) } if ($USER->id != $order->userid) { // Current user viewing someone else's order - if (! isteacher($order->courseid)) { - error("Students can view their order."); + $context = get_context_instance(CONTEXT_COURSE, $order->courseid); + if (! has_capability('enrol/authorize:managepayments', $context)) { + error("You don't have access rights on this order."); } } diff --git a/enrol/authorize/version.php b/enrol/authorize/version.php index 7b8e8c13c3..b00449357a 100755 --- a/enrol/authorize/version.php +++ b/enrol/authorize/version.php @@ -1,6 +1,6 @@ version = 2006081400; +$plugin->version = 2006081401; $plugin->requires = 2005072200; ?> -- 2.39.5