Merge branch 'MDL-40633' of git://github.com/timhunt/moodle
authorMarina Glancy <marina@moodle.com>
Mon, 15 Jul 2013 04:41:55 +0000 (14:41 +1000)
committerMarina Glancy <marina@moodle.com>
Mon, 15 Jul 2013 04:41:55 +0000 (14:41 +1000)
32 files changed:
admin/cli/alternative_component_cache.php [new file with mode: 0644]
admin/cli/install.php
admin/tool/behat/cli/init.php
admin/tool/behat/cli/util.php
admin/tool/phpunit/cli/init.php
admin/tool/phpunit/cli/util.php
cache/classes/loaders.php
enrol/authorize/authorize.js [deleted file]
enrol/authorize/authorizenet.class.php [deleted file]
enrol/authorize/const.php [deleted file]
enrol/authorize/db/access.php [deleted file]
enrol/authorize/db/install.xml [deleted file]
enrol/authorize/db/messages.php [deleted file]
enrol/authorize/db/upgrade.php [deleted file]
enrol/authorize/enrol_form.php [deleted file]
enrol/authorize/import_form.php [deleted file]
enrol/authorize/index.php [deleted file]
enrol/authorize/lang/en/enrol_authorize.php [deleted file]
enrol/authorize/localfuncs.php [deleted file]
enrol/authorize/locallib.php [deleted file]
enrol/authorize/uploadcsv.php [deleted file]
enrol/authorize/version.php [deleted file]
install.php
lib/classes/component.php
lib/csslib.php
lib/db/caches.php
lib/moodlelib.php
lib/phpunit/bootstrap.php
lib/pluginlib.php
lib/setup.php
mod/workshop/allocation/manual/lib.php
version.php

diff --git a/admin/cli/alternative_component_cache.php b/admin/cli/alternative_component_cache.php
new file mode 100644 (file)
index 0000000..6b3d454
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This hack is intended for clustered sites that do not want
+ * to use shared cachedir for component cache.
+ *
+ * This file needs to be called after any change in PHP files in dataroot,
+ * that is before upgrade and install.
+ *
+ * @package   core
+ * @copyright 2013 Petr Skoda (skodak)  {@link http://skodak.org}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+define('CLI_SCRIPT', true);
+define('ABORT_AFTER_CONFIG', true); // We need just the values from config.php.
+define('CACHE_DISABLE_ALL', true); // This prevents reading of existing caches.
+define('IGNORE_COMPONENT_CACHE', true);
+
+require(__DIR__.'/../../config.php');
+require_once($CFG->libdir.'/clilib.php');
+
+// Now get cli options.
+list($options, $unrecognized) = cli_get_params(
+    array(
+        'file'    => false,
+        'rebuild' => false,
+        'print'   => false,
+        'help'    => false
+    ),
+    array(
+        'h' => 'help'
+    )
+);
+
+if ($unrecognized) {
+    $unrecognized = implode("\n  ", $unrecognized);
+    cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
+}
+
+if (!$options['rebuild'] and !$options['file'] and !$options['print']) {
+    $help =
+"Create alternative component cache file
+
+Options:
+-h, --help            Print out this help
+--rebuild             Rebuild \$CFG->alternative_component_cache file
+--file=filepath       Save component cache to file
+--print               Print component cache file content
+
+Example:
+\$ php admin/cli/rebuild_alternative_component_cache.php --rebuild
+";
+
+    echo $help;
+    exit(0);
+}
+
+error_reporting(E_ALL | E_STRICT);
+ini_set('display_errors', 1);
+
+$content = core_component::get_cache_content();
+
+if ($options['print']) {
+    echo $content;
+    exit(0);
+}
+
+if ($options['rebuild']) {
+    if (empty($CFG->alternative_component_cache)) {
+        fwrite(STDERR, 'config.php does not contain $CFG->alternative_component_cache setting');
+        fwrite(STDERR, "\n");
+        exit(2);
+    }
+    $target = $CFG->alternative_component_cache;
+} else {
+    $target = $options['file'];
+}
+
+if (!$target) {
+    fwrite(STDERR, "Invalid target file $target");
+    fwrite(STDERR, "\n");
+    exit(1);
+}
+
+$bytes = file_put_contents($target, $content);
+
+if (!$bytes) {
+    fwrite(STDERR, "Error writing to $target");
+    fwrite(STDERR, "\n");
+    exit(1);
+}
+
+// Success.
+echo "File $target was updated\n";
+exit(0);
index f0bee31..c2d08d1 100644 (file)
@@ -139,6 +139,8 @@ define('CACHE_DISABLE_ALL', true);
 
 define('PHPUNIT_TEST', false);
 
+define('IGNORE_COMPONENT_CACHE', true);
+
 // Check that PHP is of a sufficient version
 if (version_compare(phpversion(), "5.3.3") < 0) {
     $phpversion = phpversion();
index 9ac6931..5547b56 100644 (file)
@@ -34,6 +34,7 @@ if (function_exists('opcache_reset')) {
 
 // Is not really necessary but adding it as is a CLI_SCRIPT.
 define('CLI_SCRIPT', true);
+define('CACHE_DISABLE_ALL', true);
 
 // Basic functions.
 require_once(__DIR__ . '/../../../../lib/clilib.php');
index b28f4fc..cef4ea7 100644 (file)
@@ -84,6 +84,7 @@ define('BEHAT_UTIL', true);
 define('CLI_SCRIPT', true);
 define('ABORT_AFTER_CONFIG', true);
 define('NO_OUTPUT_BUFFERING', true);
+define('IGNORE_COMPONENT_CACHE', true);
 
 error_reporting(E_ALL | E_STRICT);
 ini_set('display_errors', '1');
index a3d875d..eb807ee 100644 (file)
@@ -32,6 +32,8 @@ if (function_exists('opcache_reset')) {
     opcache_reset();
 }
 
+define('IGNORE_COMPONENT_CACHE', true);
+
 require_once(__DIR__.'/../../../../lib/clilib.php');
 require_once(__DIR__.'/../../../../lib/phpunit/bootstraplib.php');
 require_once(__DIR__.'/../../../../lib/testing/lib.php');
index 035ce7b..be593a2 100644 (file)
@@ -28,6 +28,8 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
     die; // no access from web!
 }
 
+define('IGNORE_COMPONENT_CACHE', true);
+
 require_once(__DIR__.'/../../../../lib/clilib.php');
 require_once(__DIR__.'/../../../../lib/phpunit/bootstraplib.php');
 require_once(__DIR__.'/../../../../lib/testing/lib.php');
index 6f4e680..da8fe67 100644 (file)
@@ -117,6 +117,8 @@ class cache implements cache_loader {
     /**
      * An array containing just the keys being used in the persist cache.
      * This seems redundant perhaps but is used when managing the size of the persist cache.
+     * Items are added to the end of the array and the when we need to reduce the size of the cache we use the
+     * key that is first on this array.
      * @var array
      */
     private $persistkeys = array();
@@ -965,6 +967,15 @@ class cache implements cache_loader {
             if ($this->perfdebug) {
                 cache_helper::record_cache_hit('** static persist **', $this->definition->get_id());
             }
+            if ($this->persistmaxsize > 1 && $this->persistcount > 1) {
+                // Check to see if this is the last item on the persist keys array.
+                if (end($this->persistkeys) !== $key) {
+                    // It isn't the last item.
+                    // Move the item to the end of the array so that it is last to be removed.
+                    unset($this->persistkeys[$key]);
+                    $this->persistkeys[$key] = $key;
+                }
+            }
             return $result;
         } else {
             if ($this->perfdebug) {
@@ -989,6 +1000,7 @@ class cache implements cache_loader {
         $this->persistcache[$key] = $data;
         if ($this->persistmaxsize !== false) {
             $this->persistcount++;
+            $this->persistkeys[$key] = $key;
             if ($this->persistcount > $this->persistmaxsize) {
                 $dropkey = array_shift($this->persistkeys);
                 unset($this->persistcache[$dropkey]);
diff --git a/enrol/authorize/authorize.js b/enrol/authorize/authorize.js
deleted file mode 100644 (file)
index fe8139a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-function authorize_jump_to_mypayments(e, args) {
-    var locationtogo = M.cfg.wwwroot + '/enrol/authorize/index.php?status=' + args.status;
-    locationtogo += '&user=' + (this.checked ? args.userid : '0');
-    top.location.href = locationtogo;
-}
diff --git a/enrol/authorize/authorizenet.class.php b/enrol/authorize/authorizenet.class.php
deleted file mode 100644 (file)
index 299eda0..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize enrolment plugin.
- *
- * This plugin allows you to set up paid courses, using authorize.net.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');
-}
-
-require_once($CFG->dirroot.'/enrol/authorize/const.php');
-require_once($CFG->dirroot.'/enrol/authorize/localfuncs.php');
-
-class AuthorizeNet
-{
-    const AN_DELIM = '|';
-    const AN_ENCAP = '"';
-
-    const AN_REASON_NOCCTYPE    =   17;
-    const AN_REASON_NOCCTYPE2   =   28;
-    const AN_REASON_NOACH       =   18;
-    const AN_REASON_ACHONLY     =   56;
-    const AN_REASON_NOACHTYPE   =  245;
-    const AN_REASON_NOACHTYPE2  =  246;
-
-    /**
-     * Gets settlement time
-     *
-     * @param int $time Time processed, usually now.
-     * @return int Settlement time
-     */
-    public static function getsettletime($time)
-    {
-        $mconfig = get_config('enrol_authorize');
-
-        $cutoff_hour = intval($mconfig->an_cutoff_min);
-        $cutoff_min = intval($mconfig->an_cutoff_hour);
-        $cutofftime = strtotime("{$cutoff_hour}:{$cutoff_min}", $time);
-        if ($cutofftime < $time) {
-            $cutofftime = strtotime("{$cutoff_hour}:{$cutoff_min}", $time + (24 * 3600));
-        }
-        return $cutofftime;
-    }
-
-    /**
-     * Is order settled? Status must be auth_captured or credited.
-     *
-     * @param object $order Order details
-     * @return bool true, if settled, false otherwise.
-     */
-    public static function settled($order)
-    {
-        return ((AN_STATUS_AUTHCAPTURE == $order->status || AN_STATUS_CREDIT == $order->status) and ($order->settletime > 0) and ($order->settletime < time()));
-    }
-
-    /**
-     * Is order expired? 'Authorized/Pending Capture' transactions are expired after 30 days.
-     *
-     * @param object &$order Order details.
-     * @return bool true, transaction is expired, false otherwise.
-     */
-    public static function expired(&$order)
-    {
-        global $DB;
-        static $timediff30 = 0;
-
-        if ($order->status == AN_STATUS_EXPIRE) {
-            return true;
-        }
-        elseif ($order->status != AN_STATUS_AUTH) {
-            return false;
-        }
-
-        if (0 == $timediff30) {
-            $timediff30 = self::getsettletime(time()) - (30 * 24 * 3600);
-        }
-
-        $expired = self::getsettletime($order->timecreated) < $timediff30;
-        if ($expired)
-        {
-            $order->status = AN_STATUS_EXPIRE;
-            $DB->update_record('enrol_authorize', $order);
-        }
-        return $expired;
-    }
-
-    /**
-     * Performs an action on authorize.net and updates/inserts records. If record update fails,
-     * sends email to admin.
-     *
-     * @param object &$order Which transaction data will be sent. See enrol_authorize table.
-     * @param string &$message Information about error message.
-     * @param object &$extra Extra data that used for refunding and credit card information.
-     * @param int $action Which action will be performed. See AN_ACTION_*
-     * @param string $cctype Used internally to configure credit types automatically.
-     * @return int AN_APPROVED Transaction was successful, AN_RETURNZERO otherwise. Use $message for reason.
-     */
-    public static function process(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $cctype=NULL)
-    {
-        global $CFG, $DB;
-        static $constpd = array();
-        require_once($CFG->libdir.'/filelib.php');
-
-        $mconfig = get_config('enrol_authorize');
-
-        if (empty($constpd)) {
-            $mconfig = get_config('enrol_authorize');
-            $constpd = array(
-                'x_version'         => '3.1',
-                'x_delim_data'      => 'True',
-                'x_delim_char'      => self::AN_DELIM,
-                'x_encap_char'      => self::AN_ENCAP,
-                'x_relay_response'  => 'FALSE',
-                'x_login'           => $mconfig->an_login
-            );
-
-            if (!empty($mconfig->an_tran_key)) {
-                $constpd['x_tran_key'] = $mconfig->an_tran_key;
-            }
-            else {
-                $constpd['x_password'] = $mconfig->an_password;
-            }
-        }
-
-        if (empty($order) or empty($order->id)) {
-            $message = "Check order->id!";
-            return AN_RETURNZERO;
-        }
-
-        $method = $order->paymentmethod;
-        if (empty($method)) {
-            $method = AN_METHOD_CC;
-        }
-        elseif ($method != AN_METHOD_CC && $method != AN_METHOD_ECHECK) {
-            $message = "Invalid method: $method";
-            return AN_RETURNZERO;
-        }
-
-        $action = intval($action);
-        if ($method == AN_METHOD_ECHECK) {
-            if ($action != AN_ACTION_AUTH_CAPTURE && $action != AN_ACTION_CREDIT) {
-                $message = "Please perform AUTH_CAPTURE or CREDIT for echecks";
-                return AN_RETURNZERO;
-            }
-        }
-
-        $pd = $constpd;
-        $pd['x_method'] = $method;
-        $test = !empty($mconfig->an_test);
-        $pd['x_test_request'] = ($test ? 'TRUE' : 'FALSE');
-
-        switch ($action) {
-            case AN_ACTION_AUTH_ONLY:
-            case AN_ACTION_CAPTURE_ONLY:
-            case AN_ACTION_AUTH_CAPTURE:
-                {
-                    if ($order->status != AN_STATUS_NONE) {
-                        $message = "Order status must be AN_STATUS_NONE(0)!";
-                        return AN_RETURNZERO;
-                    }
-                    elseif (empty($extra)) {
-                        $message = "Need extra fields!";
-                        return AN_RETURNZERO;
-                    }
-                    elseif (($action == AN_ACTION_CAPTURE_ONLY) and empty($extra->x_auth_code)) {
-                        $message = "x_auth_code is required for capture only transactions!";
-                        return AN_RETURNZERO;
-                    }
-
-                    $ext = (array)$extra;
-                    $pd['x_type'] = (($action==AN_ACTION_AUTH_ONLY)
-                                      ? 'AUTH_ONLY' :( ($action==AN_ACTION_CAPTURE_ONLY)
-                                                        ? 'CAPTURE_ONLY' : 'AUTH_CAPTURE'));
-                    foreach($ext as $k => $v) {
-                        $pd[$k] = $v;
-                    }
-                }
-                break;
-
-            case AN_ACTION_PRIOR_AUTH_CAPTURE:
-                {
-                    if ($order->status != AN_STATUS_AUTH) {
-                        $message = "Order status must be authorized!";
-                        return AN_RETURNZERO;
-                    }
-                    if (self::expired($order)) {
-                        $message = "Transaction must be captured within 30 days. EXPIRED!";
-                        return AN_RETURNZERO;
-                    }
-                    $pd['x_type'] = 'PRIOR_AUTH_CAPTURE';
-                    $pd['x_trans_id'] = $order->transid;
-                }
-                break;
-
-            case AN_ACTION_CREDIT:
-                {
-                    if ($order->status != AN_STATUS_AUTHCAPTURE) {
-                        $message = "Order status must be authorized/captured!";
-                        return AN_RETURNZERO;
-                    }
-                    if (!self::settled($order)) {
-                        $message = "Order must be settled. Try VOID, check Cut-Off time if it fails!";
-                        return AN_RETURNZERO;
-                    }
-                    if (empty($extra->amount)) {
-                        $message = "No valid amount!";
-                        return AN_RETURNZERO;
-                    }
-                    $timenowsettle = self::getsettletime(time());
-                    $timediff = $timenowsettle - (120 * 3600 * 24);
-                    if ($order->settletime < $timediff) {
-                        $message = "Order must be credited within 120 days!";
-                        return AN_RETURNZERO;
-                    }
-
-                    $pd['x_type'] = 'CREDIT';
-                    $pd['x_trans_id'] = $order->transid;
-                    $pd['x_currency_code'] = $order->currency;
-                    $pd['x_invoice_num'] = $extra->orderid;
-                    $pd['x_amount'] = $extra->amount;
-                    if ($method == AN_METHOD_CC) {
-                        $pd['x_card_num'] = sprintf("%04d", intval($order->refundinfo));
-                    }
-                    elseif ($method == AN_METHOD_ECHECK && empty($order->refundinfo)) {
-                        $message = "Business checkings can be refunded only.";
-                        return AN_RETURNZERO;
-                    }
-                }
-                break;
-
-            case AN_ACTION_VOID:
-                {
-                    if (self::expired($order) || self::settled($order)) {
-                        $message = "The transaction cannot be voided due to the fact that it is expired or settled.";
-                        return AN_RETURNZERO;
-                    }
-                    $pd['x_type'] = 'VOID';
-                    $pd['x_trans_id'] = $order->transid;
-                }
-                break;
-
-            default:
-            {
-                $message = "Invalid action: $action";
-                return AN_RETURNZERO;
-            }
-        }
-
-        $headers = array('Connection' => 'close');
-        if (! (empty($mconfig->an_referer) || $mconfig->an_referer == "http://")) {
-            $headers['Referer'] = $mconfig->an_referer;
-        }
-
-        @ignore_user_abort(true);
-        if (intval(ini_get('max_execution_time')) > 0) {
-            @set_time_limit(300);
-        }
-
-        $host = $test ? 'test.authorize.net' : 'secure.authorize.net';
-        $data = download_file_content("https://$host:443/gateway/transact.dll", $headers, $pd, false, 300, 60, true);
-        if (!$data) {
-            $message = "No connection to https://$host:443";
-            return AN_RETURNZERO;
-        }
-        $response = explode(self::AN_ENCAP.self::AN_DELIM.self::AN_ENCAP, $data);
-        if ($response === false) {
-            $message = "response error";
-            return AN_RETURNZERO;
-        }
-        $rcount = count($response) - 1;
-        if ($response[0]{0} == self::AN_ENCAP) {
-            $response[0] = substr($response[0], 1);
-        }
-        if (substr($response[$rcount], -1) == self::AN_ENCAP) {
-            $response[$rcount] = substr($response[$rcount], 0, -1);
-        }
-
-        $responsecode = intval($response[0]);
-        if ($responsecode == AN_APPROVED || $responsecode == AN_REVIEW)
-        {
-            $transid = floatval($response[6]);
-            if ($test || $transid == 0) {
-                return $responsecode; // don't update original transaction in test mode.
-            }
-            switch ($action) {
-                case AN_ACTION_AUTH_ONLY:
-                case AN_ACTION_CAPTURE_ONLY:
-                case AN_ACTION_AUTH_CAPTURE:
-                case AN_ACTION_PRIOR_AUTH_CAPTURE:
-                    {
-                        $order->transid = $transid;
-
-                        if ($method == AN_METHOD_CC) {
-                            if ($action == AN_ACTION_AUTH_ONLY || $responsecode == AN_REVIEW) {
-                                $order->status = AN_STATUS_AUTH;
-                            } else {
-                                $order->status = AN_STATUS_AUTHCAPTURE;
-                                $order->settletime = self::getsettletime(time());
-                            }
-                        }
-                        elseif ($method == AN_METHOD_ECHECK) {
-                            $order->status = AN_STATUS_UNDERREVIEW;
-                        }
-
-                        $DB->update_record('enrol_authorize', $order);
-                    }
-                    break;
-
-                case AN_ACTION_CREDIT:
-                    {
-                        // Credit generates new transaction id.
-                        // So, $extra must be updated, not $order.
-                        $extra->status = AN_STATUS_CREDIT;
-                        $extra->transid = $transid;
-                        $extra->settletime = self::getsettletime(time());
-                        $extra->id = $DB->insert_record('enrol_authorize_refunds', $extra);
-                    }
-                    break;
-
-                case AN_ACTION_VOID:
-                    {
-                        $tableupdate = 'enrol_authorize';
-                        if ($order->status == AN_STATUS_CREDIT) {
-                            $tableupdate = 'enrol_authorize_refunds';
-                            unset($order->paymentmethod);
-                        }
-                        $order->status = AN_STATUS_VOID;
-                        $DB->update_record($tableupdate, $order);
-                    }
-                    break;
-            }
-        }
-        else
-        {
-            $reasonno = $response[2];
-            $reasonstr = "reason" . $reasonno;
-            $message = get_string($reasonstr, "enrol_authorize");
-            if ($message == '[[' . $reasonstr . ']]') {
-                $message = isset($response[3]) ? $response[3] : 'unknown error';
-            }
-            if ($method == AN_METHOD_CC && !empty($mconfig->an_avs) && $response[5] != "P") {
-                $avs = "avs" . strtolower($response[5]);
-                $stravs = get_string($avs, "enrol_authorize");
-                $message .= "<br />" . get_string("avsresult", "enrol_authorize", $stravs);
-            }
-            if (!$test) { // Autoconfigure :)
-                switch($reasonno) {
-                    // Credit card type isn't accepted
-                    case self::AN_REASON_NOCCTYPE:
-                    case self::AN_REASON_NOCCTYPE2:
-                        {
-                            if (!empty($cctype)) {
-                                $ccaccepts = get_list_of_creditcards();
-
-                                unset($ccaccepts[$cctype]);
-                                set_config("an_acceptcc_{$cctype}", 0, 'enrol_authorize');
-
-                                foreach ($ccaccepts as $key=>$val) {
-                                    set_config("an_acceptcc_{$key}", 1, 'enrol_authorize');
-                                }
-                                message_to_admin("$message ($cctype) This is new config(an_acceptccs):", $ccaccepts);
-                            }
-                            break;
-                        }
-                    // Echecks only
-                    case self::AN_REASON_ACHONLY:
-                        {
-                            set_config("an_acceptmethod_".AN_METHOD_ECHECK, 1, 'enrol_authorize');
-                            message_to_admin("$message This is new config(an_acceptmethods):", array(AN_METHOD_ECHECK));
-                            break;
-                        }
-                    // Echecks aren't accepted
-                    case self::AN_REASON_NOACH:
-                        {
-                            set_config("an_acceptmethod_".AN_METHOD_CC, 1, 'enrol_authorize');
-                            message_to_admin("$message This is new config(an_acceptmethods):", array(AN_METHOD_CC));
-                            break;
-                        }
-                    // This echeck type isn't accepted
-                    case self::AN_REASON_NOACHTYPE:
-                    case self::AN_REASON_NOACHTYPE2:
-                        {
-                            if (!empty($extra->x_echeck_type)) {
-                                switch ($extra->x_echeck_type) {
-                                    // CCD=BUSINESSCHECKING
-                                    case 'CCD':
-                                        {
-                                            set_config('an_acceptecheck_CHECKING', 1, 'enrol_authorize');
-                                            set_config('an_acceptecheck_SAVINGS', 1, 'enrol_authorize');
-                                            message_to_admin("$message This is new config(an_acceptechecktypes):", array('CHECKING','SAVINGS'));
-                                        }
-                                        break;
-                                    // WEB=CHECKING or SAVINGS
-                                    case 'WEB':
-                                        {
-                                            set_config('an_acceptecheck_BUSINESSCHECKING', 1, 'enrol_authorize');
-                                            message_to_admin("$message This is new config(an_acceptechecktypes):", array('BUSINESSCHECKING'));
-                                        }
-                                        break;
-                                }
-                            }
-                            break;
-                        }
-                }
-            }
-        }
-        return $responsecode;
-    }
-}
-
-
diff --git a/enrol/authorize/const.php b/enrol/authorize/const.php
deleted file mode 100644 (file)
index 16030df..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-
-/**#@+
- * Authorize.net payment methods.
- *
- * Credit Card (cc)
- * eCheck (echeck)
- */
-define('AN_METHOD_CC',     'cc');
-define('AN_METHOD_ECHECK', 'echeck');
-/**#@-*/
-
-/**#@+
- * Order status used in enrol_authorize table.
- *
- * NONE: New order or order is in progress. TransactionID hasn't received yet.
- * AUTH: Authorized/Pending Capture.
- * CAPTURE: Captured.
- * AUTHCAPTURE: Authorized/Captured
- * CREDIT: Refunded.
- * VOID: Cancelled.
- * EXPIRE: Expired. Orders be expired unless be accepted within 30 days.
- *
- * These are valid only for ECHECK:
- * UNDERREVIEW: Hold for review.
- * APPROVEDREVIEW: Approved review.
- * REVIEWFAILED: Review failed.
- * TEST: Tested (dummy status). Created in TEST mode and TransactionID is 0.
- */
-define('AN_STATUS_NONE',            0x00);
-define('AN_STATUS_AUTH',            0x01);
-define('AN_STATUS_CAPTURE',         0x02);
-define('AN_STATUS_AUTHCAPTURE',     0x03);
-define('AN_STATUS_CREDIT',          0x04);
-define('AN_STATUS_VOID',            0x08);
-define('AN_STATUS_EXPIRE',          0x10);
-define('AN_STATUS_UNDERREVIEW',     0x20);
-define('AN_STATUS_APPROVEDREVIEW',  0x40);
-define('AN_STATUS_REVIEWFAILED',    0x80);
-define('AN_STATUS_TEST',            0xff); // dummy status
-/**#@-*/
-
-/**#@+
- * Actions used in AuthorizeNet::process() method.
- *
- * NONE: No action. Function always returns false.
- * AUTH_ONLY: Used to authorize only, don't capture.
- * CAPTURE_ONLY: Authorization code was received from a bank over the phone.
- * AUTH_CAPTURE: Used to authorize and capture (default action).
- * PRIOR_AUTH_CAPTURE:  Used to capture, it was authorized before.
- * CREDIT: Used to return funds to a customer's credit card.
- * VOID: Used to cancel an exiting pending transaction.
- *
- * Credit rules:
- *  1. It can be credited within 120 days after the original authorization was obtained.
- *  2. Amount can be any amount up to the original amount charged.
- *  3. Captured/pending settlement transactions cannot be credited,
- *     instead a void must be issued to cancel the settlement.
- *  NOTE: It assigns a new transactionID to the original transaction.
- *        We should save it, so admin can cancel new transaction if it is a mistake return.
- *
- * Void rules:
- *  1. These requests effectively cancel the Capture request that would start the funds transfer process.
- *  2. It mustn't be settled. Please set up settlement date correctly.
- *  3. These transactions can be voided:
- *     authorized/pending capture, captured/pending settlement, credited/pending settlement
- */
-define('AN_ACTION_NONE',                0);
-define('AN_ACTION_AUTH_ONLY',           1);
-define('AN_ACTION_CAPTURE_ONLY',        2);
-define('AN_ACTION_AUTH_CAPTURE',        3);
-define('AN_ACTION_PRIOR_AUTH_CAPTURE',  4);
-define('AN_ACTION_CREDIT',              5);
-define('AN_ACTION_VOID',                6);
-/**#@-*/
-
-/**#@+
- * Return codes for AuthorizeNet::process() method.
- *
- * AN_RETURNZERO: No connection was made on authorize.net.
- * AN_APPROVED: The transaction was accepted.
- * AN_DECLINED: The transaction was declined.
- * AN_REVIEW: The transaction was held for review.
- */
-define('AN_RETURNZERO', 0);
-define('AN_APPROVED',   1);
-define('AN_DECLINED',   2);
-define('AN_ERROR',      3);
-define('AN_REVIEW',     4);
-/**#@-*/
-
-
diff --git a/enrol/authorize/db/access.php b/enrol/authorize/db/access.php
deleted file mode 100644 (file)
index 9f0f047..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize.Net enrolment plugin capabilities.
- *
- * @package    enrol_authorize
- * @copyright  2006 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-$capabilities = array(
-
-    'enrol/authorize:config' => array(
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW,
-        )
-    ),
-
-    'enrol/authorize:manage' => array(
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW,
-            'editingteacher' => CAP_ALLOW,
-        )
-    ),
-
-    'enrol/authorize:unenrol' => array(
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW,
-        )
-    ),
-
-    'enrol/authorize:unenrolself' => array(
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_COURSE,
-        'archetypes' => array(
-        )
-    ),
-
-
-    'enrol/authorize:managepayments' => array(
-        'riskbitmask' => RISK_PERSONAL,
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_SYSTEM,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW
-        )
-    ),
-
-    'enrol/authorize:uploadcsv' => array(
-        'riskbitmask' => RISK_XSS,
-        'captype' => 'write',
-        'contextlevel' => CONTEXT_SYSTEM,
-        'archetypes' => array(
-            'manager' => CAP_ALLOW
-        )
-    )
-
-);
-
-
diff --git a/enrol/authorize/db/install.xml b/enrol/authorize/db/install.xml
deleted file mode 100644 (file)
index 39df20a..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="enrol/authorize/db" VERSION="20120122" COMMENT="XMLDB file for Moodle enrol/authorize"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
->
-  <TABLES>
-    <TABLE NAME="enrol_authorize" COMMENT="Holds all known information about authorize.net transactions">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
-        <FIELD NAME="paymentmethod" TYPE="char" LENGTH="6" NOTNULL="true" DEFAULT="cc" SEQUENCE="false"/>
-        <FIELD NAME="refundinfo" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="ccname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
-        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="status" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="amount" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
-        <FIELD NAME="currency" TYPE="char" LENGTH="3" NOTNULL="true" DEFAULT="USD" SEQUENCE="false"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid"/>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
-        <INDEX NAME="status" UNIQUE="false" FIELDS="status"/>
-        <INDEX NAME="transid" UNIQUE="false" FIELDS="transid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="enrol_authorize_refunds" COMMENT="Authorize.net refunds">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
-        <FIELD NAME="orderid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="status" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="amount" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
-        <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
-        <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
-        <KEY NAME="orderid" TYPE="foreign" FIELDS="orderid" REFTABLE="enrol_authorize" REFFIELDS="id" COMMENT="Reference to enrol_authorize.id"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="transid" UNIQUE="false" FIELDS="transid"/>
-      </INDEXES>
-    </TABLE>
-  </TABLES>
-</XMLDB>
\ No newline at end of file
diff --git a/enrol/authorize/db/messages.php b/enrol/authorize/db/messages.php
deleted file mode 100644 (file)
index 8d3df01..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Defines message providers (types of message sent) for the PayPal enrolment plugin.
- *
- * @package    enrol_authorize
- * @copyright  2012 Andrew Davis
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-$messageproviders = array(
-    'authorize_enrolment' => array(),
-);
diff --git a/enrol/authorize/db/upgrade.php b/enrol/authorize/db/upgrade.php
deleted file mode 100644 (file)
index adbb27d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize.Net enrolment plugin upgrades.
- *
- * @package    enrol_authorize
- * @copyright  2006 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-function xmldb_enrol_authorize_upgrade($oldversion) {
-    global $CFG, $DB;
-
-    $dbman = $DB->get_manager();
-
-
-    // Moodle v2.3.0 release upgrade line
-    // Put any upgrade step following this
-
-
-    // Moodle v2.4.0 release upgrade line
-    // Put any upgrade step following this
-
-
-    // Moodle v2.5.0 release upgrade line.
-    // Put any upgrade step following this.
-
-
-    return true;
-}
diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php
deleted file mode 100644 (file)
index 49136da..0000000
+++ /dev/null
@@ -1,358 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize.Net enrol plugin implementation.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->libdir.'/formslib.php');
-
-class enrol_authorize_form extends moodleform
-{
-    protected $instance;
-
-    function definition() {
-        global $USER;
-
-        $mform = $this->_form;
-        $this->instance = $this->_customdata;
-        $plugin = enrol_get_plugin('authorize');
-
-        $paymentmethodsenabled = get_list_of_payment_methods();
-        $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA);
-        if (!in_array($paymentmethod, $paymentmethodsenabled)) {
-            print_error('invalidpaymentmethod', '', '', $paymentmethod);
-        }
-
-        $othermethodstr = $this->other_method_available($paymentmethod);
-        if ($othermethodstr) {
-            $mform->addElement('static', '', '<div class="mdl-right">' . $othermethodstr . '</div>', '');
-        }
-
-        $mform->addElement('hidden', 'id');
-        $mform->setType('id', PARAM_INT);
-        $mform->setDefault('id', $this->instance->courseid);
-
-        $mform->addElement('hidden', 'instanceid');
-        $mform->setType('instanceid', PARAM_INT);
-        $mform->setDefault('instanceid', $this->instance->id);
-
-        $mform->addElement('hidden', 'paymentmethod', $paymentmethod);
-        $mform->setType('paymentmethod', PARAM_ALPHA);
-
-        $firstlastnamestr = (AN_METHOD_CC == $paymentmethod) ? get_string('nameoncard', 'enrol_authorize') : get_string('echeckfirslasttname', 'enrol_authorize');
-        $mform->addElement('text', 'firstname', get_string('firstnameoncard', 'enrol_authorize'), 'size="16"');
-        $mform->addElement('text', 'lastname', get_string('lastnameoncard', 'enrol_authorize'), 'size="16"');
-        $mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'client');
-        $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'client');
-        $mform->setType('firstname', PARAM_ALPHANUM);
-        $mform->setType('lastname', PARAM_ALPHANUM);
-        $mform->setDefault('firstname', $USER->firstname);
-        $mform->setDefault('lastname', $USER->lastname);
-
-        if (AN_METHOD_CC == $paymentmethod)
-        {
-            $mform->addElement('passwordunmask', 'cc', get_string('ccno', 'enrol_authorize'), 'size="20"');
-            $mform->setType('cc', PARAM_ALPHANUM);
-            $mform->setDefault('cc', '');
-            $mform->addRule('cc', get_string('missingcc', 'enrol_authorize'), 'required', null, 'client');
-            $mform->addRule('cc', get_string('ccinvalid', 'enrol_authorize'), 'numeric', null, 'client');
-
-            $monthsmenu = array('' => get_string('choose'));
-            for ($i = 1; $i <= 12; $i++) {
-                $monthsmenu[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
-            }
-            $nowdate = getdate();
-            $startyear = $nowdate["year"] - 1;
-            $endyear = $startyear + 20;
-            $yearsmenu = array('' => get_string('choose'));
-            for ($i = $startyear; $i < $endyear; $i++) {
-                $yearsmenu[$i] = $i;
-            }
-            $mform->addElement('select', 'ccexpiremm', get_string('expiremonth', 'enrol_authorize'), $monthsmenu);
-            $mform->addElement('select', 'ccexpireyyyy', get_string('expireyear', 'enrol_authorize'), $yearsmenu);
-            $mform->addRule('ccexpiremm', get_string('missingccexpiremonth', 'enrol_authorize'), 'required', null, 'client');
-            $mform->addRule('ccexpireyyyy', get_string('missingccexpireyear', 'enrol_authorize'), 'required', null, 'client');
-            $mform->setType('ccexpiremm', PARAM_INT);
-            $mform->setType('ccexpireyyyy', PARAM_INT);
-            $mform->setDefault('ccexpiremm', '');
-            $mform->setDefault('ccexpireyyyy', '');
-
-            $creditcardsmenu = array('' => get_string('choose')) + get_list_of_creditcards();
-            $mform->addElement('select', 'cctype', get_string('cctype', 'enrol_authorize'), $creditcardsmenu);
-            $mform->setType('cctype', PARAM_ALPHA);
-            $mform->addRule('cctype', get_string('missingcctype', 'enrol_authorize'), 'required', null, 'client');
-            $mform->setDefault('cctype', '');
-
-            $mform->addElement('text', 'cvv', get_string('ccvv', 'enrol_authorize'), 'size="4"');
-            $mform->setType('cvv', PARAM_ALPHANUM);
-            $mform->setDefault('cvv', '');
-            $mform->addRule('cvv', get_string('missingcvv', 'enrol_authorize'), 'required', null, 'client');
-            $mform->addRule('cvv', get_string('missingcvv', 'enrol_authorize'), 'numeric', null, 'client');
-
-            if ($plugin->get_config('an_authcode')) {
-                $ccauthgrp = array();
-                $ccauthgrp[] = &$mform->createElement('checkbox', 'haveauth', null, get_string('haveauthcode', 'enrol_authorize'));
-                $ccauthgrp[] = &$mform->createElement('static', 'nextline', null, '<br />');
-                $ccauthgrp[] = &$mform->createElement('text', 'ccauthcode', '', 'size="8"');
-                $mform->addGroup($ccauthgrp, 'ccauthgrp', get_string('authcode', 'enrol_authorize'), '&nbsp;', false);
-
-                $ccauthgrprules = array();
-                $ccauthgrprules['ccauthcode'][] = array(get_string('missingccauthcode', 'enrol_authorize'), 'numeric', null, 'client');
-                $mform->addGroupRule('ccauthgrp', $ccauthgrprules);
-                $mform->setDefault('haveauth', '');
-                $mform->setDefault('ccauthcode', '');
-            }
-
-            if ($plugin->get_config('an_avs')) {
-                $mform->addElement('header', 'addressheader', '&nbsp;&nbsp;' . get_string('address'), '');
-
-                $mform->addElement('text', 'ccaddress', get_string('address'), 'size="30"');
-                $mform->setType('ccaddress', PARAM_ALPHANUM);
-                $mform->setDefault('ccaddress', $USER->address);
-                $mform->addRule('ccaddress', get_string('missingaddress', 'enrol_authorize'), 'required', null, 'client');
-
-                $mform->addElement('text', 'cccity', get_string('cccity', 'enrol_authorize'), 'size="14"');
-                $mform->addElement('text', 'ccstate', get_string('ccstate', 'enrol_authorize'), 'size="8"');
-                $mform->addRule('cccity', get_string('missingcity'), 'required', null, 'client');
-                $mform->setType('cccity', PARAM_ALPHANUM);
-                $mform->setType('ccstate', PARAM_ALPHANUM);
-                $mform->setDefault('cccity', $USER->city);
-                $mform->setDefault('ccstate', '');
-
-                $mform->addElement('select', 'cccountry', get_string('country'), get_string_manager()->get_list_of_countries());
-                $mform->addRule('cccountry', get_string('missingcountry'), 'required', null, 'client');
-                $mform->setType('cccountry', PARAM_ALPHA);
-                $mform->setDefault('cccountry', $USER->country);
-            }
-            else {
-                $mform->addElement('hidden', 'ccstate', '');
-                $mform->setType('ccstate', PARAM_ALPHANUM);
-                $mform->addElement('hidden', 'ccaddress', $USER->address);
-                $mform->setType('ccaddress', PARAM_ALPHANUM);
-                $mform->addElement('hidden', 'cccity', $USER->city);
-                $mform->setType('cccity', PARAM_ALPHANUM);
-                $mform->addElement('hidden', 'cccountry', $USER->country);
-                $mform->setType('ccountry', PARAM_ALPHA);
-                $mform->setDefault('cccountry', $USER->country);
-            }
-        } elseif (AN_METHOD_ECHECK == $paymentmethod) {
-            $mform->addElement('text', 'abacode', get_string('echeckabacode', 'enrol_authorize'), 'size="9" maxlength="9"');
-            $mform->setType('abacode', PARAM_ALPHANUM);
-            $mform->setDefault('abacode', '');
-            $mform->addRule('abacode', get_string('missingaba', 'enrol_authorize'), 'required', null, 'client');
-            $mform->addRule('abacode', get_string('missingaba', 'enrol_authorize'), 'numeric', null, 'client');
-
-            $mform->addElement('text', 'accnum', get_string('echeckaccnum', 'enrol_authorize'), 'size="20" maxlength="20"');
-            $mform->setType('accnum', PARAM_ALPHANUM);
-            $mform->setDefault('accnum', '');
-            $mform->addRule('accnum', get_string('invalidaccnum', 'enrol_authorize'), 'required', null, 'client');
-            $mform->addRule('accnum', get_string('invalidaccnum', 'enrol_authorize'), 'numeric', null, 'client');
-
-            $acctypes = array();
-            $acctypesenabled = get_list_of_bank_account_types();
-            foreach ($acctypesenabled as $key) {
-                $acctypes[$key] = get_string("echeck".strtolower($key), "enrol_authorize");
-            }
-            $acctypes = array('' => get_string('choose')) + $acctypes;
-            $mform->addElement('select', 'acctype', get_string('echeckacctype', 'enrol_authorize'), $acctypes);
-            $mform->setType('acctype', PARAM_ALPHA);
-            $mform->addRule('acctype', get_string('invalidacctype', 'enrol_authorize'), 'required', null, 'client');
-            $mform->setDefault('acctype', '');
-
-            $mform->addElement('text', 'bankname', get_string('echeckbankname', 'enrol_authorize'), 'size="20" maxlength="50"');
-            $mform->setType('bankname', PARAM_ALPHANUM);
-            $mform->setDefault('bankname', '');
-            $mform->addRule('bankname', get_string('missingbankname', 'enrol_authorize'), 'required', null, 'client');
-        }
-
-        $mform->addElement('text', 'cczip', get_string('zipcode', 'enrol_authorize'), 'size="5"');
-        $mform->setType('cczip', PARAM_ALPHANUM);
-        $mform->setDefault('cczip', '');
-        $mform->addRule('cczip', get_string('missingzip', 'enrol_authorize'), 'required', null, 'client');
-
-        $this->add_action_buttons(false, get_string('sendpaymentbutton', 'enrol_authorize'));
-    }
-
-    function validation($data, $files) {
-        $errors = parent::validation($data, $files);
-        $plugin = enrol_get_plugin('authorize');
-
-        if (AN_METHOD_CC == $data['paymentmethod'])
-        {
-            if (!in_array($data['cctype'], array_keys(get_list_of_creditcards()))) {
-                $errors['cctype'] = get_string('missingcctype', 'enrol_authorize');
-            }
-
-            $expdate = sprintf("%02d", intval($data['ccexpiremm'])) . $data['ccexpireyyyy'];
-            $validcc = $this->validate_cc($data['cc'], $data['cctype'], $expdate);
-            if (!$validcc) {
-                if ($validcc === 0) {
-                    $errors['ccexpiremm'] = get_string('ccexpired', 'enrol_authorize');
-                }
-                else {
-                    $errors['cc'] = get_string('ccinvalid', 'enrol_authorize');
-                }
-            }
-
-            if ($plugin->get_config('an_authcode') && !empty($data['haveauth']) && empty($data['ccauthcode'])) {
-                $errors['ccauthgrp'] = get_string('missingccauthcode', 'enrol_authorize');
-            }
-        }
-        elseif (AN_METHOD_ECHECK == $data['paymentmethod'])
-        {
-            if (!$this->validate_aba($data['abacode'])) {
-                $errors['abacode'] = get_string('invalidaba', 'enrol_authorize');
-            }
-
-            if (!in_array($data['acctype'], get_list_of_bank_account_types())) {
-                $errors['acctype'] = get_string('invalidacctype', 'enrol_authorize');
-            }
-        }
-
-        return $errors;
-    }
-
-    private function other_method_available($currentmethod)
-    {
-
-        if ($currentmethod == AN_METHOD_CC) {
-            $otheravailable = in_array(AN_METHOD_ECHECK, get_list_of_payment_methods());
-            $url = 'index.php?id='.$this->instance->courseid.'&amp;paymentmethod='.AN_METHOD_ECHECK;
-            $stringtofetch = 'usingecheckmethod';
-        } else {
-            $otheravailable = in_array(AN_METHOD_CC, get_list_of_payment_methods());
-            $url = 'index.php?id='.$this->instance->courseid.'&amp;paymentmethod='.AN_METHOD_CC;
-            $stringtofetch = 'usingccmethod';
-        }
-        if ($otheravailable) {
-            $a = new stdClass;
-            $a->url = $url;
-            return get_string($stringtofetch, "enrol_authorize", $a);
-        }
-        else {
-            return '';
-        }
-    }
-
-    private function validate_aba($aba)
-    {
-        if (preg_match("/^[0-9]{9}$/", $aba)) {
-            $n = 0;
-            for($i = 0; $i < 9; $i += 3) {
-                $n += (substr($aba, $i, 1) * 3) + (substr($aba, $i + 1, 1) * 7) + (substr($aba, $i + 2, 1));
-            }
-            if ($n != 0 and $n % 10 == 0) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private function validate_cc($Num, $Name = "n/a", $Exp = "")
-    {
-        // Check the expiration date first
-        if (strlen($Exp))
-        {
-            $Month = substr($Exp, 0, 2);
-            $Year  = substr($Exp, -2);
-            $WorkDate = "$Month/01/$Year";
-            $WorkDate = strtotime($WorkDate);
-            $LastDay  = date("t", $WorkDate);
-            $Expires  = strtotime("$Month/$LastDay/$Year 11:59:59");
-            if ($Expires < time()) return 0;
-        }
-
-        //  Innocent until proven guilty
-        $GoodCard = true;
-
-        //  Get rid of any non-digits
-        $Num = preg_replace("/[^0-9]~/", "", $Num);
-
-        // Perform card-specific checks, if applicable
-        switch ($Name)
-        {
-            case "mcd" :
-                $GoodCard = preg_match("/^5[1-5].{14}$/", $Num);
-                break;
-
-            case "vis" :
-                $GoodCard = preg_match("/^4.{15}$|^4.{12}$/", $Num);
-                break;
-
-            case "amx" :
-                $GoodCard = preg_match("/^3[47].{13}$/", $Num);
-                break;
-
-            case "dsc" :
-                $GoodCard = preg_match("/^6011.{12}$/", $Num);
-                break;
-
-            case "dnc" :
-                $GoodCard = preg_match("/^30[0-5].{11}$|^3[68].{12}$/", $Num);
-                break;
-
-            case "jcb" :
-                $GoodCard = preg_match("/^3.{15}$|^2131|1800.{11}$/", $Num);
-                break;
-
-            case "dlt" :
-                $GoodCard = preg_match("/^4.{15}$/", $Num);
-                break;
-
-            case "swi" :
-                $GoodCard = preg_match("/^[456].{15}$|^[456].{17,18}$/", $Num);
-                break;
-
-            case "enr" :
-                $GoodCard = preg_match("/^2014.{11}$|^2149.{11}$/", $Num);
-                break;
-        }
-
-        // The Luhn formula works right to left, so reverse the number.
-        $Num = strrev($Num);
-        $Total = 0;
-
-        for ($x=0; $x < strlen($Num); $x++)
-        {
-            $digit = substr($Num, $x, 1);
-
-            // If it's an odd digit, double it
-            if ($x/2 != floor($x/2)) {
-                $digit *= 2;
-
-                // If the result is two digits, add them
-                if (strlen($digit) == 2)
-                $digit = substr($digit, 0, 1) + substr($digit, 1, 1);
-            }
-            // Add the current digit, doubled and added if applicable, to the Total
-            $Total += $digit;
-        }
-
-        // If it passed (or bypassed) the card-specific check and the Total is
-        // evenly divisible by 10, it's cool!
-        return ($GoodCard && $Total % 10 == 0);
-    }
-
-}
-
diff --git a/enrol/authorize/import_form.php b/enrol/authorize/import_form.php
deleted file mode 100644 (file)
index 91484aa..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Adds new instance of enrol_authorize to specified course
- * or edits current instance.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-require_once($CFG->libdir.'/formslib.php');
-
-class enrol_authorize_import_form extends moodleform {
-
-    function definition() {
-        global $CFG;
-        $mform =& $this->_form;
-
-        $mform->addElement('filepicker', 'csvfile', get_string('filetoimport', 'glossary'));
-        $submit_string = get_string('submit');
-        $this->add_action_buttons(false, $submit_string);
-    }
-}
diff --git a/enrol/authorize/index.php b/enrol/authorize/index.php
deleted file mode 100644 (file)
index f888a9e..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Adds new instance of enrol_authorize to specified course
- * or edits current instance.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-/// Load libraries
-    require_once('../../config.php');
-    require_once('const.php');
-    require_once('locallib.php');
-    require_once('localfuncs.php');
-    require_once('authorizenet.class.php');
-
-/// Parameters
-    $orderid  = optional_param('order', 0, PARAM_INT);
-    $courseid = optional_param('course', SITEID, PARAM_INT);
-    $userid   = optional_param('user', 0, PARAM_INT);
-
-    $url = new moodle_url('/enrol/authorize/index.php');
-    if ($orderid !== 0) {
-        $url->param('order', $orderid);
-    }
-    if ($courseid !== SITEID) {
-        $url->param('course', $courseid);
-    }
-    if ($userid !== 0) {
-        $url->param('user', $userid);
-    }
-    $PAGE->set_url($url);
-
-/// Get course
-    if (!($course = $DB->get_record('course', array('id'=>$courseid)))) {
-        print_error('invalidcourseid');
-    }
-
-/// Only SITE users can access to this page
-    require_login(); // Don't use $courseid! User may want to see old orders.
-    if (isguestuser()) {
-        print_error('noguest');
-    }
-
-/// Load strings. All strings should be defined here. locallib.php uses these strings.
-    $strs = get_strings(array('search','status','action','time','course','confirm','yes','no','cancel','all','none','error'));
-    $authstrs = get_strings(array('orderid','nameoncard','echeckfirslasttname','void','capture','refund','delete',
-        'allpendingorders','authcaptured','authorizedpendingcapture','capturedpendingsettle','settled',
-        'refunded','cancelled','expired','underreview','approvedreview','reviewfailed','tested','new',
-        'paymentmethod','methodcc','methodecheck', 'paymentmanagement', 'orderdetails', 'cclastfour', 'isbusinesschecking','shopper',
-        'transid','settlementdate','notsettled','amount','unenrolstudent'), 'enrol_authorize');
-
-/// User wants to see all orders
-    if (empty($orderid)) {
-        authorize_print_orders($courseid, $userid);
-    }
-    else {
-        authorize_print_order($orderid);
-    }
-
diff --git a/enrol/authorize/lang/en/enrol_authorize.php b/enrol/authorize/lang/en/enrol_authorize.php
deleted file mode 100644 (file)
index 5a67999..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Strings for component 'enrol_authorize', language 'en'.
- *
- * @package   enrol_authorize
- * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-$string['authorize:config'] = 'Configure Authorize.Net enrol instances';
-$string['authorize:manage'] = 'Manage enrolled users';
-$string['authorize:unenrol'] = 'Unenrol users from course';
-$string['authorize:unenrolself'] = 'Unenrol self from the course';
-$string['authorize:managepayments'] = 'Manage payments';
-$string['authorize:uploadcsv'] = 'Upload CSV file';
-$string['adminacceptccs'] = 'Which credit card types will be accepted?';
-$string['adminaccepts'] = 'Select payment methods allowed and their types';
-$string['anauthcode'] = 'Obtain authcode';
-$string['anauthcodedesc'] = 'If a user\'s credit card cannot be captured on the internet directly, obtain authorization code over the phone from customer\'s bank.';
-$string['adminauthorizeccapture'] = 'Order review and scheduled-capture settings';
-$string['adminauthorizeemail'] = 'Email sending settings';
-$string['adminauthorizesettings'] = 'Authorize.Net merchant account settings';
-$string['adminauthorizewide'] = 'General settings';
-$string['anavs'] = 'Address Verification System';
-$string['anavsdesc'] = 'Check this if you have activated Address Verification System (AVS) in your Authorize.Net merchant account. This demands address fields like street, state, country and zip when user fills out payment form.';
-$string['adminconfighttps'] = 'Please ensure that you have "<a href="{$a->url}">turned loginhttps ON</a>" to use this plugin<br />in Admin >> Variables >> Security >> HTTP security.';
-$string['adminconfighttpsgo'] = 'Go to the <a href="{$a->url}">secure page</a> to configure this plugin.';
-$string['admincronsetup'] = 'The cron.php maintenance script has not been run for at least 24 hours.<br />Cron must be enabled if you want to use scheduled-capture feature.<br /><b>Enable</b> \'Authorize.Net plugin\' and <b>setup cron</b> properly; or <b>uncheck an_review</b> again.<br />If you disable scheduled-capture, transactions will be cancelled unless you review them within 30 days.<br />Check <b>an_review</b> and enter <b>\'0\' to an_capture_day</b> field<br />if you want to <b>manually</b> accept/deny payments within 30 days.';
-$string['anemailexpired'] = 'Expiry notification';
-$string['anemailexpireddesc'] = 'This is useful for \'manual-capture\'. Admins are notified the specified amount of days prior to pending orders expiring.';
-$string['adminemailexpiredsort'] = 'When the number of pending orders expiring are sent to the teachers via email, which one is important?';
-$string['adminemailexpiredsortcount'] = 'Order count';
-$string['adminemailexpiredsortsum'] = 'Total amount';
-$string['anemailexpiredteacher'] = 'Expiry notification - Teacher';
-$string['anemailexpiredteacherdesc'] = 'If you have enabled manual-capture (see above) and teachers can manage the payments, they may also notified about pending orders expiring. This will send an email to each course teachers about the count of the pending orders to expire.';
-$string['adminemailexpsetting'] = '(0=disable sending email, default=2, max=5)<br />(Manual capture settings for sending email: cron=enabled, an_review=checked, an_capture_day=0, an_emailexpired=1-5)';
-$string['adminhelpcapturetitle'] = 'Scheduled-capture day';
-$string['adminhelpreviewtitle'] = 'Order review';
-$string['adminneworder'] = 'Dear Admin,
-
-  You have received a new pending order:
-
-   Order ID: {$a->orderid}
-   Transaction ID: {$a->transid}
-   User: {$a->user}
-   Course: {$a->course}
-   Amount: {$a->amount}
-
-   SCHEDULED-CAPTURE ENABLED?: {$a->acstatus}
-
-  If the scheduled-capture is active, the credit card is to be captured on {$a->captureon}
-  and then the user is to be enrolled to course; otherwise it will be expired
-  on {$a->expireon} and cannot be captured after this day.
-
-  You can also accept/deny the payment to enrol the student immediately following this link:
-  {$a->url}';
-$string['adminnewordersubject'] = '{$a->course}: New pending order: {$a->orderid}';
-$string['adminpendingorders'] = 'You have disabled scheduled-capture feature.<br />Total {$a->count} transactions with the status of \'Authorized/Pending capture\' are to be cancelled unless you check them.<br />To accept/deny payments, go to <a href=\'{$a->url}\'>Payment Management</a> page.';
-$string['anreview'] = 'Review';
-$string['anreviewdesc'] = 'Review order before processing the credit card.';
-$string['adminteachermanagepay'] = 'Teachers can manage the payments of the course.';
-$string['allpendingorders'] = 'All pending orders';
-$string['amount'] = 'Amount';
-$string['anlogin'] = 'Authorize.Net: Login name';
-$string['anpassword'] = 'Authorize.Net: Password';
-$string['anreferer'] = 'Referer';
-$string['anrefererdesc'] = 'Define the URL referer if you have set up this in your Authorize.Net merchant account. This will send a line "Referer: URL" embedded in the web request.';
-$string['antestmode'] = 'Test mode';
-$string['antestmodedesc'] = 'Run transactions in test mode only (no money will be drawn)';
-$string['antrankey'] = 'Authorize.Net: Transaction key';
-$string['approvedreview'] = 'Approved review';
-$string['authcaptured'] = 'Authorized / Captured';
-$string['authcode'] = 'Authorization code';
-$string['authorizedpendingcapture'] = 'Authorized / Pending capture';
-$string['authorizeerror'] = 'Authorize.Net error: {$a}';
-$string['avsa'] = 'Address (street) matches, postal code does not';
-$string['avsb'] = 'Address information not provided';
-$string['avse'] = 'Address Verification System error';
-$string['avsg'] = 'Non-U.S. card issuing bank';
-$string['avsn'] = 'No match on address (street) nor postal code';
-$string['avsp'] = 'Address Verification System not applicable';
-$string['avsr'] = 'Retry - system unavailable or timed out';
-$string['avsresult'] = 'AVS result: {$a}';
-$string['avss'] = 'Service not supported by issuer';
-$string['avsu'] = 'Address information is unavailable';
-$string['avsw'] = '9 digit postal code matches, address (street) does not';
-$string['avsx'] = 'Address (street) and 9 digit postal code match';
-$string['avsy'] = 'Address (street) and 5 digit postal code match';
-$string['avsz'] = '5 digit postal code matches, address (street) does not';
-$string['canbecredit'] = 'Can be refunded to {$a->upto}';
-$string['cancelled'] = 'Cancelled';
-$string['capture'] = 'Capture';
-$string['capturedpendingsettle'] = 'Captured / Pending settlement';
-$string['capturedsettled'] = 'Captured / Settled';
-$string['captureyes'] = 'The credit card will be captured and the student will be enrolled to the course. Are you sure?';
-$string['ccexpire'] = 'Expiry date';
-$string['ccexpired'] = 'The credit card has expired';
-$string['ccinvalid'] = 'Invalid card number';
-$string['cclastfour'] = 'CC last four';
-$string['ccno'] = 'Credit card number';
-$string['cctype'] = 'Credit card type';
-$string['ccvv'] = 'Card verification';
-$string['ccvvhelp'] = 'Look at the back of card (last 3 digits)';
-$string['costdefaultdesc'] = '<strong>In course settings, enter -1</strong> to use this default cost to course cost field.';
-$string['cutofftime'] = 'Cut-off time';
-$string['cutofftimedesc'] = 'Transaction cut-off time. When the last transaction is picked up for settlement?';
-$string['dataentered'] = 'Data entered';
-$string['delete'] = 'Destroy';
-$string['description'] = 'The Authorize.Net module allows you to set up paid courses via payment providers. Two ways to set the course cost (1) a site-wide cost as a default for the whole site or (2) a course setting that you can set for each course individually. The course cost overrides the site cost.';
-$string['echeckabacode'] = 'Bank ABA number';
-$string['echeckaccnum'] = 'Bank account number';
-$string['echeckacctype'] = 'Bank account type';
-$string['echeckbankname'] = 'Bank name';
-$string['echeckbusinesschecking'] = 'Business checking';
-$string['echeckfirslasttname'] = 'Bank account owner';
-$string['echeckchecking'] = 'Checking';
-$string['echecksavings'] = 'Savings';
-$string['enrolname'] = 'Authorize.Net payment gateway';
-$string['expired'] = 'Expired';
-$string['haveauthcode'] = 'I have already an authorization code';
-$string['howmuch'] = 'How much?';
-$string['httpsrequired'] = 'We are sorry to inform you that your request cannot be processed now. This site\'s configuration couldn\'t be set up correctly.<br /><br />Please don\'t enter your credit card number unless you see a yellow lock at the bottom of the browser. If the symbol appears, it means the page encrypts all data sent between client and server. So the information during the transaction between the two computers is protected, hence your credit card number cannot be captured over the internet.';
-$string['choosemethod'] = 'If you know the enrolment key of the cource, please enter it below;<br />Otherwise you need to pay for this course.';
-$string['chooseone'] = 'Fill one or both of the following two fields. The password isn\'t shown.';
-$string['invalidaba'] = 'Invalid ABA number';
-$string['invalidaccnum'] = 'Invalid account number';
-$string['invalidacctype'] = 'Invalid account type';
-$string['isbusinesschecking'] = 'Is business checking?';
-$string['logindesc'] = 'This option must be ON. <br /><br />Please ensure that you have turned <a href="{$a->url}">loginhttps ON</a> in Admin >> Variables >> Security.<br /><br />Turning this on will make Moodle use a secure https connection just for the login and payment pages.';
-$string['logininfo'] = 'When configuring your Authorize.Net account, the login name is required and you must enter <strong>either</strong> the transaction key <strong>or</strong> the password in the appropriate box. We recommend you enter the transaction key due to security precautions.';
-$string['messageprovider:authorize_enrolment'] = 'Authorize.Net enrolment messages';
-$string['methodcc'] = 'Credit card';
-$string['methodccdesc'] = 'Select credit card and accepted types below';
-$string['methodecheck'] = 'eCheck (ACH)';
-$string['methodecheckdesc'] = 'Select eCheck and accepted types below';
-$string['missingaba'] = 'Missing ABA number';
-$string['missingaddress'] = 'Missing address';
-$string['missingbankname'] = 'Missing bank name';
-$string['missingcc'] = 'Missing card number';
-$string['missingccauthcode'] = 'Missing authorization code';
-$string['missingccexpiremonth'] = 'Missing expiration month';
-$string['missingccexpireyear'] = 'Missing expiration year';
-$string['missingcctype'] = 'Missing card type';
-$string['missingcvv'] = 'Missing verification number';
-$string['missingzip'] = 'Missing postal code';
-$string['mypaymentsonly'] = 'Show my payments only';
-$string['nameoncard'] = 'Name on card';
-$string['new'] = 'New';
-$string['noreturns'] = 'No returns!';
-$string['notsettled'] = 'Not settled';
-$string['orderdetails'] = 'Order details';
-$string['orderid'] = 'OrderID';
-$string['paymentmanagement'] = 'Payment management';
-$string['paymentmethod'] = 'Payment method';
-$string['paymentpending'] = 'Your payment is pending for this course with this order number {$a->orderid}.  See <a href=\'{$a->url}\'>Order Details</a>.';
-$string['pendingecheckemail'] = 'Dear manager,
-
-There are {$a->count} pending echecks now and you have to upload a csv file to get the users enrolled.
-
-Click the link and read the help file on the page seen:
-{$a->url}';
-$string['pendingechecksubject'] = '{$a->course}: Pending eChecks({$a->count})';
-$string['pendingordersemail'] = 'Dear admin,
-
-{$a->pending} transactions for course "{$a->course}" will expire unless you accept payment within {$a->days} days.
-
-This is a warning message, because you didn\'t enable scheduled-capture.
-It means you have to accept or deny payments manually.
-
-To accept/deny pending payments go to:
-{$a->url}
-
-To enable scheduled-capture, it means you will not receive any warning emails anymore, go to:
-
-{$a->enrolurl}';
-$string['pendingordersemailteacher'] = 'Dear teacher,
-
-{$a->pending} transactions costed {$a->currency} {$a->sumcost} for course "{$a->course}"
-will expire unless you accept payment with in {$a->days} days.
-
-You have to accept or deny payments manually because of the admin hasn\'t enabled the scheduled-capture.
-
-{$a->url}';
-$string['pendingorderssubject'] = 'WARNING: {$a->course}, {$a->pending} order(s) will expire within {$a->days} day(s).';
-$string['pluginname'] = 'Authorize.Net';
-$string['reason11'] = 'A duplicate transaction has been submitted.';
-$string['reason13'] = 'The merchant Login ID is invalid or the account is inactive.';
-$string['reason16'] = 'The transaction was not found.';
-$string['reason17'] = 'The merchant does not accept this type of credit card.';
-$string['reason245'] = 'This eCheck type is not allowed when using the payment gateway hosted payment form.';
-$string['reason246'] = 'This eCheck type is not allowed.';
-$string['reason27'] = 'The transaction resulted in an AVS mismatch. The address provided does not match billing address of cardholder.';
-$string['reason28'] = 'The merchant does not accept this type of credit card.';
-$string['reason30'] = 'The configuration with the processor is invalid. Call merchant service provider.';
-$string['reason39'] = 'The supplied currency code is either invalid, not supported, not allowed for this merchant or doesn\'t have an exchange rate.';
-$string['reason43'] = 'The merchant was incorrectly set up at the processor. Call your merchant service provider.';
-$string['reason44'] = 'This transaction has been declined. Card code filter error!';
-$string['reason45'] = 'This transaction has been declined. Card code / AVS filter error!';
-$string['reason47'] = 'The amount requested for settlement may not be greater than the original amount authorized.';
-$string['reason5'] = 'A valid amount is required.';
-$string['reason50'] = 'This transaction is awaiting settlement and cannot be refunded.';
-$string['reason51'] = 'The sum of all credits against this transaction is greater than the original transaction amount.';
-$string['reason54'] = 'The referenced transaction does not meet the criteria for issuing a credit.';
-$string['reason55'] = 'The sum of credits against the referenced transaction would exceed the original debit amount.';
-$string['reason56'] = 'This merchant accepts eCheck (ACH) transactions only; no credit card transactions are accepted.';
-$string['refund'] = 'Refund';
-$string['refunded'] = 'Refunded';
-$string['returns'] = 'Returns';
-$string['ancaptureday'] = 'Capture day';
-$string['ancapturedaydesc'] = 'Capture the credit card automatically unless a teacher or administrator review the order within the specified days. CRON MUST BE ENABLED.<br />(0 days means it will disable scheduled-capture, also means teacher or admin review order manually. Transaction will be cancelled if you disable scheduled-capture or unless you review it within 30 days.)';
-$string['reviewfailed'] = 'Review failed';
-$string['reviewnotify'] = 'Your payment will be reviewed. Expect an email within a few days from your teacher.';
-$string['sendpaymentbutton'] = 'Send payment';
-$string['settled'] = 'Settled';
-$string['settlementdate'] = 'Settlement date';
-$string['shopper'] = 'Shopper';
-$string['subvoidyes'] = 'The transaction refunded ({$a->transid}) is going to be cancelled and this will cause crediting {$a->amount} to your account. Are you sure?';
-$string['tested'] = 'Tested';
-$string['testmode'] = '[TEST MODE]';
-$string['testwarning'] = 'Capturing/Voiding/Refunding seems working in test mode, but no record was updated or inserted in database.';
-$string['transid'] = 'TransactionID';
-$string['underreview'] = 'Under review';
-$string['unenrolstudent'] = 'Unenrol student?';
-$string['uploadcsv'] = 'Upload a CSV file';
-$string['usingccmethod'] = 'Enrol using <a href="{$a->url}"><strong>Credit Card</strong></a>';
-$string['usingecheckmethod'] = 'Enrol using <a href="{$a->url}"><strong>eCheck</strong></a>';
-$string['verifyaccount'] = 'Verify your Authorize.Net merchant account';
-$string['verifyaccountresult'] = '<b>Verification result:</b> {$a}';
-$string['void'] = 'Void';
-$string['voidyes'] = 'The transaction will be cancelled. Are you sure?';
-$string['welcometocoursesemail'] = 'Dear {$a->name},
-
-Thanks for your payments. You have enrolled these courses:
-
-{$a->courses}
-
-You may view your payment details or edit your profile:
- {$a->paymenturl}
- {$a->profileurl}';
-$string['youcantdo'] = 'You can\'t do this action: {$a->action}';
-$string['zipcode'] = 'Zip code';
-$string['cost'] = 'Cost';
-$string['currency'] = 'Currency';
-$string['enrolperiod'] = 'Enrolment duration';
-$string['enrolstartdate'] = 'Start date';
-$string['enrolenddate'] = 'End date';
-$string['enrolenddaterror'] = 'Enrolment end date cannot be earlier than start date';
-$string['status'] = 'Allow Autorize.Net enrolments';
-$string['nocost'] = 'There is no cost associated with enrolling in this course via Authorize.Net!';
-$string['firstnameoncard'] = 'Firstname on card';
-$string['lastnameoncard'] = 'Lastname on card';
-$string['expiremonth'] = 'Expiry month';
-$string['expireyear'] = 'Expiry year';
-$string['cccity'] = 'City';
-$string['ccstate'] = 'State';
-$string['unenrolselfconfirm'] = 'Do you really want to unenrol yourself from course "{$a}"?';
diff --git a/enrol/authorize/localfuncs.php b/enrol/authorize/localfuncs.php
deleted file mode 100644 (file)
index 473af61..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize enrolment plugin.
- *
- * This plugin allows you to set up paid courses, using authorize.net.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-require_once($CFG->libdir.'/eventslib.php');
-
-function get_course_cost($plugininstance) {
-    $defaultplugin = enrol_get_plugin('authorize');
-
-    $cost = (float)0;
-    $currency = (!empty($plugininstance->currency))
-                 ? $plugininstance->currency :( empty($defaultplugin->currency)
-                                        ? 'USD' : $defaultplugin->enrol_currency );
-
-    if (!empty($plugininstance->cost)) {
-        $cost = (float)(((float)$plugininstance->cost) < 0) ? $defaultplugin->cost : $plugininstance->cost;
-    }
-
-    $cost = format_float($cost, 2);
-    $ret = array(
-        'cost' => $cost,
-        'currency' => $currency
-    );
-
-    return $ret;
-}
-
-function zero_cost($plugininstance) {
-    $curcost = get_course_cost($plugininstance);
-    return (abs($curcost['cost']) < 0.01);
-}
-
-function prevent_double_paid($plugininstance) {
-    global $CFG, $SESSION, $USER, $DB;
-    $plugin = enrol_get_plugin('authorize');
-
-    $sql = "SELECT id FROM {enrol_authorize} WHERE userid = ? AND courseid = ? AND instanceid = ?";
-    $params = array($USER->id, $plugininstance->courseid, $plugininstance->id);
-
-    if (!$plugin->get_config('an_test')) { // Real mode
-        $sql .= ' AND status IN(?,?,?)';
-        $params[] = AN_STATUS_AUTH;
-        $params[] = AN_STATUS_UNDERREVIEW;
-        $params[] = AN_STATUS_APPROVEDREVIEW;
-    }
-    else { // Test mode
-        $sql .= ' AND status=?';
-        $params[] = AN_STATUS_NONE;
-    }
-
-    if (($recid = $DB->get_field_sql($sql, $params))) {
-        $a = new stdClass;
-        $a->orderid = $recid;
-        $a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$a->orderid";
-        redirect($a->url, get_string("paymentpending", "enrol_authorize", $a), '10');
-        return;
-    }
-    if (isset($SESSION->ccpaid)) {
-        unset($SESSION->ccpaid);
-        redirect($CFG->wwwroot . '/login/logout.php?sesskey='.sesskey());
-        return;
-    }
-}
-
-function get_list_of_creditcards($getall = false) {
-    $plugin = enrol_get_plugin('authorize');
-
-    $alltypes = array(
-        'mcd' => 'Master Card',
-        'vis' => 'Visa',
-        'amx' => 'American Express',
-        'dsc' => 'Discover',
-        'dnc' => 'Diners Club',
-        'jcb' => 'JCB',
-        'swi' => 'Switch',
-        'dlt' => 'Delta',
-        'enr' => 'EnRoute'
-    );
-
-    if ($getall) {
-        return $alltypes;
-    }
-
-    $ret = array();
-    foreach ($alltypes as $code=>$name) {
-        if ($plugin->get_config("an_acceptcc_{$code}")) {
-            $ret[$code] = $name;
-        }
-    }
-
-    return $ret;
-}
-
-function get_list_of_payment_methods($getall = false) {
-    $plugin = enrol_get_plugin('authorize');
-    $method_cc = $plugin->get_config('an_acceptmethod_cc');
-    $method_echeck = $plugin->get_config('an_acceptmethod_echeck');
-
-
-    if ($getall || (empty($method_cc) && empty($method_echeck))) {
-        return array(AN_METHOD_CC, AN_METHOD_ECHECK);
-    } else {
-        $methods = array();
-        if ($method_cc) {
-            $methods[] = AN_METHOD_CC;
-        }
-
-        if ($method_echeck) {
-            $methods[] = AN_METHOD_ECHECK;
-        }
-
-        return $methods;
-    }
-}
-
-function get_list_of_bank_account_types($getall = false) {
-    $plugin = enrol_get_plugin('authorize');
-    $alltypes = array('CHECKING', 'BUSINESSCHECKING', 'SAVINGS');
-
-    if ($getall) {
-        return $alltypes;
-    } else {
-        $types = array();
-        foreach ($alltypes as $type) {
-            if ($plugin->get_config("an_acceptecheck_{$type}")) {
-                $types[] = $type;
-            }
-        }
-
-        return $types;
-    }
-}
-
-function message_to_admin($subject, $data) {
-    global $SITE;
-
-    $admin = get_admin();
-    $data = (array)$data;
-
-    $emailmessage = "$SITE->fullname: Transaction failed.\n\n$subject\n\n";
-    $emailmessage .= print_r($data, true);
-    $eventdata = new stdClass();
-    $eventdata->modulename        = 'moodle';
-    $eventdata->component         = 'enrol_authorize';
-    $eventdata->name              = 'authorize_enrolment';
-    $eventdata->userfrom          = $admin;
-    $eventdata->userto            = $admin;
-    $eventdata->subject           = "$SITE->fullname: Authorize.net ERROR";
-    $eventdata->fullmessage       = $emailmessage;
-    $eventdata->fullmessageformat = FORMAT_PLAIN;
-    $eventdata->fullmessagehtml   = '';
-    $eventdata->smallmessage      = '';
-    message_send($eventdata);
-}
-
-function send_welcome_messages($orderdata) {
-    global $CFG, $SITE, $DB;
-
-    if (empty($orderdata)) {
-        return;
-    }
-
-    if (is_numeric($orderdata)) {
-        $orderdata = array($orderdata);
-    }
-
-    $sql = "SELECT e.id, e.courseid, e.userid, c.fullname
-              FROM {enrol_authorize} e
-              JOIN {course} c ON c.id = e.courseid
-             WHERE e.id IN(" . implode(',', $orderdata) . ")
-          ORDER BY e.userid";
-
-    $rs = $DB->get_recordset_sql($sql);
-    if (!$rs->valid()) {
-        $rs->close(); // Not going to iterate (but exit), close rs
-        return;
-    }
-
-    if ($rs->valid() and $ei = current($rs))
-    {
-        if (1 < count($orderdata)) {
-            $sender = get_admin();
-        }
-        else {
-            $context = context_course::instance($ei->courseid);
-            $paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments', '', '', '0', '1');
-            $sender = array_shift($paymentmanagers);
-        }
-
-        do
-        {
-            $usercourses = array();
-            $lastuserid = $ei->userid;
-
-            while ($ei && $ei->userid == $lastuserid) {
-                $context = context_course::instance($ei->courseid);
-                $usercourses[] = format_string($ei->fullname, true, array('context' => $context));
-                if (!$rs->valid()) {
-                    break;
-                }
-                $rs->next();
-                $ei = $rs->current();
-            }
-
-            if (($user = $DB->get_record('user', array('id'=>$lastuserid)))) {
-                $a = new stdClass;
-                $a->name = $user->firstname;
-                $a->courses = implode("\n", $usercourses);
-                $a->profileurl = "$CFG->wwwroot/user/view.php?id=$lastuserid";
-                $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$lastuserid";
-                $emailmessage = get_string('welcometocoursesemail', 'enrol_authorize', $a);
-                $subject = get_string("enrolmentnew", 'enrol', format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))));
-
-                $eventdata = new stdClass();
-                $eventdata->modulename        = 'moodle';
-                $eventdata->component         = 'enrol_authorize';
-                $eventdata->name              = 'authorize_enrolment';
-                $eventdata->userfrom          = $sender;
-                $eventdata->userto            = $user;
-                $eventdata->subject           = $subject;
-                $eventdata->fullmessage       = $emailmessage;
-                $eventdata->fullmessageformat = FORMAT_PLAIN;
-                $eventdata->fullmessagehtml   = '';
-                $eventdata->smallmessage      = '';
-                message_send($eventdata);
-            }
-        }
-        while ($ei);
-
-        $rs->close(); // end of iteration, close rs
-    }
-}
-
-function check_curl_available() {
-    return function_exists('curl_init') &&
-           function_exists('stream_get_wrappers') &&
-           in_array('https', stream_get_wrappers());
-}
-
-function authorize_verify_account() {
-    global $USER, $SITE;
-    $plugin = enrol_get_plugin('authorize');
-
-    require_once('authorizenet.class.php');
-
-    $original_antest = $plugin->get_config('an_test');
-    $plugin->set_config('an_test', 1); // Test mode
-    $shortname = format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID)));
-
-    $order = new stdClass();
-    $order->id = -1;
-    $order->paymentmethod = AN_METHOD_CC;
-    $order->refundinfo = '1111';
-    $order->ccname = 'Test User';
-    $order->courseid = $SITE->id;
-    $order->userid = $USER->id;
-    $order->status = AN_STATUS_NONE;
-    $order->settletime = 0;
-    $order->transid = 0;
-    $order->timecreated = time();
-    $order->amount = '0.01';
-    $order->currency = 'USD';
-
-    $extra = new stdClass();
-    $extra->x_card_num = '4111111111111111';
-    $extra->x_card_code = '123';
-    $extra->x_exp_date = "12" . intval(date("Y")) + 5;
-    $extra->x_currency_code = $order->currency;
-    $extra->x_amount = $order->amount;
-    $extra->x_first_name = 'Test';
-    $extra->x_last_name = 'User';
-    $extra->x_country = $USER->country;
-
-    $extra->x_invoice_num = $order->id;
-    $extra->x_description = $shortname . ' - Authorize.net Merchant Account Verification Test';
-
-    $ret = '';
-    $message = '';
-    if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_AUTH_CAPTURE)) {
-        $ret = get_string('verifyaccountresult', 'enrol_authorize', get_string('success'));
-    }
-    else {
-        $ret = get_string('verifyaccountresult', 'enrol_authorize', $message);
-    }
-
-    $plugin->set_config('an_test', $original_antest);
-
-    return $ret;
-}
-
-
diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php
deleted file mode 100644 (file)
index b44c727..0000000
+++ /dev/null
@@ -1,728 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize enrolment plugin.
- *
- * This plugin allows you to set up paid courses, using authorize.net.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');
-}
-
-define('ORDER_CAPTURE', 'capture');
-define('ORDER_DELETE',  'delete');
-define('ORDER_REFUND',  'refund');
-define('ORDER_VOID',    'void');
-
-/**
- * authorize_print_orders
- *
- */
-function authorize_print_orders($courseid, $userid) {
-    global $course;
-    global $CFG, $USER, $SITE, $DB, $OUTPUT, $PAGE;
-    global $strs, $authstrs;
-
-    $plugin = enrol_get_plugin('authorize');
-
-    require_once($CFG->libdir.'/tablelib.php');
-
-    $perpage = optional_param('perpage', 10, PARAM_INT);
-    $showonlymy = optional_param('showonlymy', 0, PARAM_BOOL);
-    $searchquery = optional_param('searchquery', '0', PARAM_INT);
-    $searchtype = optional_param('searchtype', 'orderid', PARAM_ALPHA);
-    $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
-
-    $coursecontext = context_course::instance($courseid);
-
-    $searchmenu = array('orderid' => $authstrs->orderid, 'transid' => $authstrs->transid, 'cclastfour' => $authstrs->cclastfour);
-    $buttons = "<form method='post' action='index.php' autocomplete='off'><div>";
-    $buttons .= html_writer::label(get_string('orderdetails', 'enrol_authorize'), 'menusearchtype', false, array('class' => 'accesshide'));
-    $buttons .= html_writer::select($searchmenu, 'searchtype', $searchtype, false);
-    $buttons .= html_writer::label(get_string('search'), 'searchquery', false, array('class' => 'accesshide'));
-    $buttons .= "<input id='searchquery' type='text' size='16' name='searchquery' value='' />";
-    $buttons .= "<input type='submit' value='$strs->search' />";
-    $buttons .= "</div></form>";
-
-    if (has_capability('enrol/authorize:uploadcsv', context_user::instance($USER->id))) {
-        $buttons .= "<form method='get' action='uploadcsv.php'><div><input type='submit' value='".get_string('uploadcsv', 'enrol_authorize')."' /></div></form>";
-    }
-
-    $canmanagepayments = has_capability('enrol/authorize:managepayments', $coursecontext);
-    if ($showonlymy || !$canmanagepayments) {
-        $userid = $USER->id;
-    }
-
-    $baseurl = $CFG->wwwroot.'/enrol/authorize/index.php?user='.$userid;
-
-    $params = array('userid'=>$userid);
-    $sql = "SELECT c.id, c.fullname FROM {course} c JOIN {enrol_authorize} e ON c.id = e.courseid ";
-    $sql .= ($userid > 0) ? "WHERE (e.userid=:userid) " : '';
-    $sql .= "ORDER BY c.sortorder, c.fullname";
-    if (($popupcrs = $DB->get_records_sql_menu($sql, $params))) {
-        $popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
-    }
-    $popupmenu = empty($popupcrs) ? '' : $OUTPUT->single_select(new moodle_url($baseurl.'&status='.$status), 'course', $popupcrs, $courseid, null, 'coursesmenu');
-    $popupmenu .= '<br />';
-    $statusmenu = array(
-        AN_STATUS_NONE => $strs->all,
-        AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW => $authstrs->allpendingorders,
-        AN_STATUS_AUTH => $authstrs->authorizedpendingcapture,
-        AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured,
-        AN_STATUS_CREDIT => $authstrs->refunded,
-        AN_STATUS_VOID => $authstrs->cancelled,
-        AN_STATUS_EXPIRE => $authstrs->expired,
-        AN_STATUS_UNDERREVIEW => $authstrs->underreview,
-        AN_STATUS_APPROVEDREVIEW => $authstrs->approvedreview,
-        AN_STATUS_REVIEWFAILED => $authstrs->reviewfailed,
-        AN_STATUS_TEST => $authstrs->tested
-    );
-
-    $popupmenu .= $OUTPUT->single_select(new moodle_url($baseurl.'&course='.$courseid), 'status', $statusmenu, $status, null, 'statusmenu');
-    if ($canmanagepayments) {
-        $popupmenu .= '<br />';
-        $PAGE->requires->js('/enrol/authorize/authorize.js');
-        $aid = $OUTPUT->add_action_handler(new component_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status)));
-        $popupmenu .= html_writer::checkbox('enrol_authorize', 1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'), array('id'=>$aid));
-    }
-
-    if (SITEID != $courseid) {
-        $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
-        $PAGE->navbar->add($shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
-    }
-    $PAGE->navbar->add($authstrs->paymentmanagement, 'index.php');
-    $PAGE->set_title("$course->shortname: $authstrs->paymentmanagement");
-    $PAGE->set_heading($authstrs->paymentmanagement);
-    $PAGE->set_headingmenu($popupmenu);
-    $PAGE->set_button($buttons);
-    echo $OUTPUT->header();
-
-    $table = new flexible_table('enrol-authorize');
-    $table->set_attribute('width', '100%');
-    $table->set_attribute('cellspacing', '0');
-    $table->set_attribute('cellpadding', '3');
-    $table->set_attribute('id', 'orders');
-    $table->set_attribute('class', 'generaltable generalbox');
-
-    if ($perpage > 100) { $perpage = 100; }
-    $perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
-    $perpagemenu = $OUTPUT->single_select(new moodle_url($baseurl.'&status='.$status.'&course='.$courseid), 'perpage', $perpagemenus, $perpage, array(''=>'choosedots'), 'perpagemenu');
-    $table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action'));
-    $table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu));
-    $table->define_baseurl($baseurl."&amp;status=$status&amp;course=$courseid&amp;perpage=$perpage");
-
-    $table->no_sorting('action');
-    $table->sortable(true, 'id', SORT_DESC);
-    $table->pageable(true);
-    $table->setup();
-
-    $select = "SELECT e.id, e.paymentmethod, e.refundinfo, e.transid, e.courseid, e.userid, e.status, e.ccname, e.timecreated, e.settletime ";
-    $from   = "FROM {enrol_authorize} e ";
-    $where  = "WHERE (1=1) ";
-    $params = array();
-
-    if (!empty($searchquery)) {
-        switch($searchtype) {
-            case 'orderid':
-                $where = "WHERE (e.id = :searchquery) ";
-                $params['searchquery'] = $searchquery;
-                break;
-
-            case 'transid':
-                $where = "WHERE (e.transid = :searchquery) ";
-                $params['searchquery'] = $searchquery;
-                break;
-
-            case 'cclastfour':
-                $searchquery = sprintf("%04d", $searchquery);
-                $where = "WHERE (e.refundinfo = :searchquery) AND (e.paymentmethod=:method) ";
-                $params['searchquery'] = $searchquery;
-                $params['method'] = AN_METHOD_CC;
-                break;
-        }
-    }
-    else {
-        switch ($status)
-        {
-            case AN_STATUS_NONE:
-                if (!$plugin->get_config('an_test')) {
-                    $where .= "AND (e.status != :status) ";
-                    $params['status'] = AN_STATUS_NONE;
-                }
-                break;
-
-            case AN_STATUS_TEST:
-                $newordertime = time() - 120; // -2 minutes. Order may be still in process.
-                $where .= "AND (e.status = :status) AND (e.transid = '0') AND (e.timecreated < :newordertime) ";
-                $params['status'] = AN_STATUS_NONE;
-                $params['newordertime'] = $newordertime;
-                break;
-
-            case AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW:
-                $where .= 'AND (e.status IN(:status1,:status2,:status3)) ';
-                $params['status1'] = AN_STATUS_AUTH;
-                $params['status2'] = AN_STATUS_UNDERREVIEW;
-                $params['status3'] = AN_STATUS_APPROVEDREVIEW;
-                break;
-
-            case AN_STATUS_CREDIT:
-                $from .= "INNER JOIN {enrol_authorize_refunds} r ON e.id = r.orderid ";
-                $where .= "AND (e.status = :status) ";
-                $params['status'] = AN_STATUS_AUTHCAPTURE;
-                break;
-
-            default:
-                $where .= "AND (e.status = :status) ";
-                $params['status'] = $status;
-                break;
-        }
-
-        if (SITEID != $courseid) {
-            $where .= "AND (e.courseid = :courseid) ";
-            $params['courseid'] = $courseid;
-        }
-    }
-
-    // This must be always LAST where!!!
-    if ($userid > 0) {
-        $where .= "AND (e.userid = :userid) ";
-        $params['userid'] = $userid;
-    }
-
-    if (($sort = $table->get_sql_sort())) {
-        $sort = ' ORDER BY ' . $sort;
-    }
-
-    $totalcount = $DB->count_records_sql('SELECT COUNT(*) ' . $from . $where, $params);
-    $table->initialbars($totalcount > $perpage);
-    $table->pagesize($perpage, $totalcount);
-
-    if (($records = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size()))) {
-        foreach ($records as $record) {
-            $actionstatus = authorize_get_status_action($record);
-            $color = authorize_get_status_color($actionstatus->status);
-            $actions = '';
-
-            if (empty($actionstatus->actions)) {
-                $actions .= $strs->none;
-            }
-            else {
-                foreach ($actionstatus->actions as $val) {
-                    $actions .= authorize_print_action_button($record->id, $val);
-                }
-            }
-
-            $table->add_data(array(
-                "<a href='index.php?order=$record->id'>$record->id</a>",
-                $record->ccname,
-                userdate($record->timecreated),
-                "<font style='color:$color'>" . $authstrs->{$actionstatus->status} . "</font>",
-                $actions
-            ));
-        }
-    }
-
-    $table->print_html();
-    echo $OUTPUT->footer();
-}
-
-/**
- * authorize_print_order
- *
- * @param object $order
- */
-function authorize_print_order($orderid)
-{
-    global $CFG, $USER, $DB, $OUTPUT, $PAGE;
-    global $strs, $authstrs;
-
-    $plugin = enrol_get_plugin('authorize');
-    $an_test = $plugin->get_config('an_test');
-
-    $do = optional_param('do', '', PARAM_ALPHA);
-    $unenrol = optional_param('unenrol', 0, PARAM_BOOL);
-    $confirm = optional_param('confirm', 0, PARAM_BOOL);
-
-    if (!$order = $DB->get_record('enrol_authorize', array('id'=>$orderid))) {
-        print_error('orderidnotfound', '',
-                "$CFG->wwwroot/enrol/authorize/index.php", $orderid);
-    }
-
-    if (!$course = $DB->get_record('course', array('id'=>$order->courseid))) {
-        print_error('invalidcourseid', '', "$CFG->wwwroot/enrol/authorize/index.php");
-    }
-
-    if (!$user = $DB->get_record('user', array('id'=>$order->userid))) {
-        print_error('nousers', '', "$CFG->wwwroot/enrol/authorize/index.php");
-    }
-
-    $coursecontext = context_course::instance($course->id);
-    if ($USER->id != $order->userid) { // Current user viewing someone else's order
-        require_capability('enrol/authorize:managepayments', $coursecontext);
-    }
-
-    $settled = AuthorizeNet::settled($order);
-    $statusandactions = authorize_get_status_action($order);
-    $color = authorize_get_status_color($statusandactions->status);
-
-    $buttons = '';
-    if (empty($do))
-    {
-        if (empty($statusandactions->actions)) {
-            if ((AN_METHOD_ECHECK == $order->paymentmethod) && has_capability('enrol/authorize:uploadcsv', context_user::instance($USER->id))) {
-                $buttons .= "<form method='get' action='uploadcsv.php'><div><input type='submit' value='".get_string('uploadcsv', 'enrol_authorize')."' /></div></form>";
-            }
-        }
-        else {
-            foreach ($statusandactions->actions as $val) {
-                $buttons .= authorize_print_action_button($orderid, $val);
-            }
-        }
-    }
-
-    if (SITEID != $course->id) {
-        $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
-        $PAGE->navbar->add($shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
-    }
-    $PAGE->navbar->add($authstrs->paymentmanagement, 'index.php?course='.$course->id);
-    $PAGE->navbar->add($authstrs->orderid . ': ' . $orderid, 'index.php');
-    $PAGE->set_course($course);
-    $PAGE->set_title("$course->shortname: $authstrs->paymentmanagement");
-    $PAGE->set_heading($authstrs->orderdetails);
-    $PAGE->set_cacheable(false);
-    $PAGE->set_button($buttons);
-    echo $OUTPUT->header();
-
-    $table = new html_table();
-    $table->width = '100%';
-    $table->size = array('30%', '70%');
-    $table->align = array('right', 'left');
-
-    if (AN_METHOD_CC == $order->paymentmethod) {
-        $table->data[] = array("<b>$authstrs->paymentmethod:</b>", $authstrs->methodcc);
-        $table->data[] = array("<b>$authstrs->nameoncard:</b>", $order->ccname . ' (<b><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'">'.fullname($user).'</a></b>)');
-        $table->data[] = array("<b>$authstrs->cclastfour:</b>", $order->refundinfo);
-    }
-    else {
-        $table->data[] = array("<b>$authstrs->paymentmethod:</b>", $authstrs->methodecheck);
-        $table->data[] = array("<b>$authstrs->echeckfirslasttname:</b>", $order->ccname . ' (<b><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'">'.fullname($user).'</a></b>)');
-        $table->data[] = array("<b>$authstrs->isbusinesschecking:</b>", ($order->refundinfo == 1) ? $strs->yes : $strs->no);
-    }
-
-    $table->data[] = array("<b>$authstrs->amount:</b>", "$order->currency $order->amount");
-    $table->data[] = array("<b>$authstrs->transid:</b>", $order->transid);
-    $table->data[] = array("<b>$strs->time:</b>", userdate($order->timecreated));
-    $table->data[] = array("<b>$authstrs->settlementdate:</b>", $settled ? userdate($order->settletime) : $authstrs->notsettled);
-    $table->data[] = array("<b>$strs->status:</b>", "<b><font style='color:$color'>" . $authstrs->{$statusandactions->status} . "</font></b>");
-
-    if (ORDER_CAPTURE == $do && in_array(ORDER_CAPTURE, $statusandactions->actions)) {
-        if ($confirm && confirm_sesskey()) {
-            $message = '';
-            $extra = NULL;
-            if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
-                if (empty($an_test)) {
-                    if (enrol_into_course($course, $user, 'authorize')) {
-                        if ($plugin->get_config('enrol_mailstudents')) {
-                            send_welcome_messages($orderid);
-                        }
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
-                    }
-                    else {
-                        $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", "Error while trying to enrol ".fullname($user)." in '" . $shortname . "'", 20);
-                    }
-                }
-                else {
-                    redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", get_string('testwarning', 'enrol_authorize'), 10);
-                }
-            }
-            else {
-                redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $message, 20);
-            }
-        }
-        $table->data[] = array("<b>$strs->confirm:</b>", get_string('captureyes', 'enrol_authorize') . '<br />' .
-                               authorize_print_action_button($orderid, ORDER_CAPTURE, 0, true, false, $strs->no));
-        echo html_writer::table($table);
-    }
-    elseif (ORDER_REFUND == $do && in_array(ORDER_REFUND, $statusandactions->actions)) {
-        $refunded = 0.0;
-        $sql = "SELECT SUM(amount) AS refunded
-                  FROM {enrol_authorize_refunds}
-                 WHERE (orderid = ?)
-                   AND (status = ?)";
-
-        if (($refundval = $DB->get_field_sql($sql, array($orderid, AN_STATUS_CREDIT)))) {
-            $refunded = floatval($refundval);
-        }
-        $upto = round($order->amount - $refunded, 2);
-        if ($upto <= 0) {
-            print_error('refoundtoorigi', '',
-                    "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $order->amount);
-        }
-        $amount = round(optional_param('amount', $upto, PARAM_RAW), 2);
-        if ($amount > $upto) {
-            print_error('refoundto', '',
-                    "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $upto);
-        }
-        if ($confirm && confirm_sesskey()) {
-            $extra = new stdClass;
-            $extra->orderid = $orderid;
-            $extra->amount = $amount;
-            $message = '';
-            $success = AuthorizeNet::process($order, $message, $extra, AN_ACTION_CREDIT);
-            if (AN_APPROVED == $success || AN_REVIEW == $success) {
-                if (empty($an_test)) {
-                    if (empty($extra->id)) {
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", "insert record error", 20);
-                    }
-                    else {
-                        if (!empty($unenrol)) {
-                            $pinstance = $DB->get_record('enrol', array('id'=>$order->instanceid));
-                            $plugin->unenrol_user($pinstance, $order->userid);
-                            //role_unassign_all(array('userid'=>$order->userid, 'contextid'=>$coursecontext->id, 'component'=>'enrol_authorize'), true, true);
-                        }
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
-                    }
-                }
-                else {
-                    redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", get_string('testwarning', 'enrol_authorize'), 10);
-                }
-            }
-            else {
-                redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $message, 20);
-            }
-        }
-        $a = new stdClass;
-        $a->upto = $upto;
-        $inputattrs = array('id' => 'amount', 'type' => 'text', 'size' => '5', 'name' => 'amount', 'value' => $amount);
-        $extrahtml = html_writer::label(get_string('howmuch', 'enrol_authorize'), 'amount'). ' '.
-                     html_writer::empty_tag('input', $inputattrs). ' '.
-                     get_string('canbecredit', 'enrol_authorize', $a) . '<br />';
-        $table->data[] = array("<b>$strs->confirm:</b>",
-                               authorize_print_action_button($orderid, ORDER_REFUND, 0, true, $authstrs->unenrolstudent, $strs->no, $extrahtml));
-        echo html_writer::table($table);
-    }
-    elseif (ORDER_DELETE == $do && in_array(ORDER_DELETE, $statusandactions->actions)) {
-        if ($confirm && confirm_sesskey()) {
-            if (!empty($unenrol)) {
-                $pinstance = $DB->get_record('enrol', array('id'=>$order->instanceid));
-                $plugin->unenrol_user($pinstance, $order->userid);
-                //role_unassign_all(array('userid'=>$order->userid, 'contextid'=>$coursecontext->id, 'component'=>'enrol_authorize'), true, true);
-            }
-            $DB->delete_records('enrol_authorize', array('id'=>$orderid));
-            redirect("$CFG->wwwroot/enrol/authorize/index.php");
-        }
-        $table->data[] = array("<b>$strs->confirm:</b>",
-                               authorize_print_action_button($orderid, ORDER_DELETE, 0, true, $authstrs->unenrolstudent,$strs->no));
-        echo html_writer::table($table);
-    }
-    elseif (ORDER_VOID == $do) { // special case: cancel original or refunded transaction?
-        $suborderid = optional_param('suborder', 0, PARAM_INT);
-        if (empty($suborderid) && in_array(ORDER_VOID, $statusandactions->actions)) { // cancel original
-            if ($confirm && confirm_sesskey()) {
-                $extra = NULL;
-                $message = '';
-                if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_VOID)) {
-                    if (empty($an_test)) {
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
-                    }
-                    else {
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", get_string('testwarning', 'enrol_authorize'), 10);
-                    }
-                }
-                else {
-                    redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $message, 20);
-                }
-            }
-            $table->data[] = array("<b>$strs->confirm:</b>", get_string('voidyes', 'enrol_authorize') . '<br />' .
-                                   authorize_print_action_button($orderid, ORDER_VOID, 0, true, false, $strs->no));
-            echo html_writer::table($table);
-        }
-        elseif (!empty($suborderid)) { // cancel refunded
-            $sql = "SELECT r.*, e.courseid, e.paymentmethod
-                      FROM {enrol_authorize_refunds} r
-                INNER JOIN {enrol_authorize} e
-                        ON r.orderid = e.id
-                     WHERE r.id = ?
-                       AND r.orderid = ?
-                       AND r.status = ?";
-
-            $suborder = $DB->get_record_sql($sql, array($suborderid, $orderid, AN_STATUS_CREDIT));
-            if (!$suborder) { // not found
-                print_error('transactionvoid', '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
-            }
-            $refundedstatus = authorize_get_status_action($suborder);
-            unset($suborder->courseid);
-            if (in_array(ORDER_VOID, $refundedstatus->actions)) {
-                if ($confirm && confirm_sesskey()) {
-                    $message = '';
-                    $extra = NULL;
-                    if (AN_APPROVED == AuthorizeNet::process($suborder, $message, $extra, AN_ACTION_VOID)) {
-                        if (empty($an_test)) {
-                            if (!empty($unenrol)) {
-                                $pinstance = $DB->get_record('enrol', array('id'=>$order->instanceid));
-                                $plugin->unenrol_user($pinstance, $order->userid);
-                                //role_unassign_all(array('userid'=>$order->userid, 'contextid'=>$coursecontext->id, 'component'=>'enrol_authorize'), true, true);
-                            }
-                            redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
-                        }
-                        else {
-                            redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", get_string('testwarning', 'enrol_authorize'), 10);
-                        }
-                    }
-                    else {
-                        redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", $message, 20);
-                    }
-                }
-                $a = new stdClass;
-                $a->transid = $suborder->transid;
-                $a->amount = $suborder->amount;
-                $table->data[] = array("<b>$strs->confirm:</b>", get_string('subvoidyes', 'enrol_authorize', $a) . '<br />' .
-                                       authorize_print_action_button($orderid, ORDER_VOID, $suborderid, true, $authstrs->unenrolstudent, $strs->no));
-                echo html_writer::table($table);
-            }
-        }
-    }
-    else {
-        echo html_writer::table($table);
-
-        if ($settled) { // show refunds.
-            $t2 = new html_table();
-            $t2->size = array('45%', '15%', '20%', '10%', '10%');
-            $t2->align = array('right', 'right', 'right', 'right', 'right');
-            $t2->head = array($authstrs->settlementdate, $authstrs->transid, $strs->status, $strs->action, $authstrs->amount);
-
-            $sql = "SELECT r.*, e.courseid, e.paymentmethod
-                      FROM {enrol_authorize_refunds} r
-                INNER JOIN {enrol_authorize} e
-                        ON r.orderid = e.id
-                     WHERE r.orderid = ?";
-
-            if (($refunds = $DB->get_records_sql($sql, array($orderid)))) {
-                $sumrefund = floatval(0.0);
-                foreach ($refunds as $rf) {
-                    $subactions = '';
-                    $substatus = authorize_get_status_action($rf);
-                    if (empty($substatus->actions)) {
-                        $subactions .= $strs->none;
-                    }
-                    else {
-                        foreach ($substatus->actions as $vl) {
-                            $subactions .= authorize_print_action_button($orderid, $vl, $rf->id);
-                        }
-                    }
-                    $sign = '';
-                    $color = authorize_get_status_color($substatus->status);
-                    if ($substatus->status == 'refunded' or $substatus->status == 'settled') {
-                        $sign = '-';
-                        $sumrefund += floatval($rf->amount);
-                    }
-                    $t2->data[] = array(
-                        userdate($rf->settletime),
-                        $rf->transid,
-                        "<b><font style='color:$color'>" .$authstrs->{$substatus->status} . "</font></b>",
-                        $subactions,
-                        format_float($sign . $rf->amount, 2)
-                    );
-                }
-                $t2->data[] = array('','',get_string('total'),$order->currency,format_float('-'.$sumrefund, 2));
-            }
-            else {
-                $t2->data[] = array('','',get_string('noreturns', 'enrol_authorize'),'','');
-            }
-            echo "<h4>" . get_string('returns', 'enrol_authorize') . "</h4>\n";
-            echo html_writer::table($t2);
-        }
-    }
-
-    echo $OUTPUT->footer();
-}
-
-/**
- * authorize_get_status_action
- *
- * @param object $order Order details.
- * @return object
- */
-function authorize_get_status_action($order)
-{
-    global $CFG;
-    static $newordertime = 0;
-
-    if (0 == $newordertime) {
-        $newordertime = time() - 120; // -2 minutes. Order may be still in process.
-    }
-
-    $ret = new stdClass();
-    $ret->actions = array();
-
-    $canmanage = has_capability('enrol/authorize:managepayments', context_course::instance($order->courseid));
-
-    if (floatval($order->transid) == 0) { // test transaction or new order
-        if ($order->timecreated < $newordertime) {
-            if ($canmanage) {
-                $ret->actions = array(ORDER_DELETE);
-            }
-            $ret->status = 'tested';
-        }
-        else {
-            $ret->status = 'new';
-        }
-        return $ret;
-    }
-
-    switch ($order->status) {
-        case AN_STATUS_AUTH:
-            if (AuthorizeNet::expired($order)) {
-                if ($canmanage) {
-                    $ret->actions = array(ORDER_DELETE);
-                }
-                $ret->status = 'expired';
-            }
-            else {
-                if ($canmanage) {
-                    $ret->actions = array(ORDER_CAPTURE, ORDER_VOID);
-                }
-                $ret->status = 'authorizedpendingcapture';
-            }
-            return $ret;
-
-        case AN_STATUS_AUTHCAPTURE:
-            if (AuthorizeNet::settled($order)) {
-                if ($canmanage) {
-                    if (($order->paymentmethod == AN_METHOD_CC) || ($order->paymentmethod == AN_METHOD_ECHECK && !empty($order->refundinfo))) {
-                        $ret->actions = array(ORDER_REFUND);
-                    }
-                }
-                $ret->status = 'settled';
-            }
-            else {
-                if ($order->paymentmethod == AN_METHOD_CC && $canmanage) {
-                    $ret->actions = array(ORDER_VOID);
-                }
-                $ret->status = 'capturedpendingsettle';
-            }
-            return $ret;
-
-        case AN_STATUS_CREDIT:
-            if (AuthorizeNet::settled($order)) {
-                $ret->status = 'settled';
-            }
-            else {
-                if ($order->paymentmethod == AN_METHOD_CC && $canmanage) {
-                    $ret->actions = array(ORDER_VOID);
-                }
-                $ret->status = 'refunded';
-            }
-            return $ret;
-
-        case AN_STATUS_VOID:
-            $ret->status = 'cancelled';
-            return $ret;
-
-        case AN_STATUS_EXPIRE:
-            if ($canmanage) {
-                $ret->actions = array(ORDER_DELETE);
-            }
-            $ret->status = 'expired';
-            return $ret;
-
-        case AN_STATUS_UNDERREVIEW:
-            $ret->status = 'underreview';
-            return $ret;
-
-        case AN_STATUS_APPROVEDREVIEW:
-            $ret->status = 'approvedreview';
-            return $ret;
-
-        case AN_STATUS_REVIEWFAILED:
-            if ($canmanage) {
-                $ret->actions = array(ORDER_DELETE);
-            }
-            $ret->status = 'reviewfailed';
-            return $ret;
-
-        default:
-            return $ret;
-    }
-}
-
-
-function authorize_get_status_color($status)
-{
-    $color = 'black';
-    switch ($status)
-    {
-        case 'settled':
-        case 'capturedpendingsettle':
-            $color = '#339900'; // green
-            break;
-
-        case 'underreview':
-        case 'approvedreview':
-        case 'authorizedpendingcapture':
-            $color = '#FF6600'; // orange
-            break;
-
-        case 'new':
-        case 'tested':
-            $color = '#003366'; // blue
-            break;
-
-        case 'expired':
-        case 'cancelled':
-        case 'refunded';
-        case 'reviewfailed':
-            $color = '#FF0033'; // red
-            break;
-    }
-    return $color;
-}
-
-function authorize_print_action_button($orderid, $do, $suborderid=0, $confirm=false, $unenrol=false, $nobutton=false, $extrahtml='')
-{
-    global $CFG, $OUTPUT;
-    global $authstrs;
-
-    $ret =  '<form action="'.$CFG->wwwroot.'/enrol/authorize/index.php'.'" method="post"><div>' .
-            '<input type="hidden" name="order" value="'.$orderid.'" />' .
-            '<input type="hidden" name="do" value="'.$do.'" />' .
-            '<input type="hidden" name="sesskey" value="'. sesskey() . '" />';
-    if (!empty($suborderid)) {
-        $ret .= '<input type="hidden" name="suborder" value="'.$suborderid.'" />';
-    }
-    if (!empty($confirm)) {
-        $ret .= '<input type="hidden" name="confirm" value="1" />';
-    }
-    if (!empty($unenrol)) {
-        $ret .= html_writer::checkbox('unenrol', 1, false, $unenrol) . '<br />';
-    }
-    $ret .= $extrahtml;
-    $ret .= '<input type="submit" value="'.$authstrs->$do.'" />' .
-            '</div></form>';
-    if (!empty($nobutton)) {
-        $ret .= '<form method="get" action="index.php"><div><input type="hidden" name="order" value="'.$orderid.'" /><input type="submit" value="'.$nobutton.'" /></div></form>';
-    }
-    return $ret;
-}
-
diff --git a/enrol/authorize/uploadcsv.php b/enrol/authorize/uploadcsv.php
deleted file mode 100644 (file)
index 9c62501..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize.Net enrolment plugin - support for user self unenrolment.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/// Load libraries
-require_once('../../config.php');
-require_once($CFG->dirroot.'/enrol/authorize/const.php');
-require_once($CFG->dirroot.'/enrol/authorize/localfuncs.php');
-require_once($CFG->libdir.'/eventslib.php');
-require_once('import_form.php');
-
-/// Require capabilities
-require_login();
-require_capability('enrol/authorize:uploadcsv', context_system::instance());
-
-/// Print header
-$struploadcsv = get_string('uploadcsv', 'enrol_authorize');
-$managebutton = "<form method='get' action='index.php'><input type='submit' value='".get_string('paymentmanagement', 'enrol_authorize')."' /></form>";
-
-$form = new enrol_authorize_import_form();
-
-$PAGE->set_url('/enrol/authorize/uploadcsv.php');
-$PAGE->navbar->add(get_string('paymentmanagement', 'enrol_authorize'), 'index.php');
-$PAGE->navbar->add($struploadcsv, 'uploadcsv.php');
-$PAGE->set_title($struploadcsv);
-$PAGE->set_cacheable(false);
-$PAGE->set_button($managebutton);
-echo $OUTPUT->header();
-echo $OUTPUT->heading($struploadcsv);
-
-/// Handle CSV file
-if (!$form->get_data()) {
-    $form->display();
-} else {
-    $filename = $CFG->tempdir . '/enrolauthorize/importedfile_'.time().'.csv';
-    make_temp_directory('enrolauthorize');
-    // Fix mac/dos newlines
-    $text = $form->get_file_content('csvfile');
-    $text = preg_replace('!\r\n?!', "\n", $text);
-    $fp = fopen($filename, "w");
-    fwrite($fp, $text);
-    fclose($fp);
-    authorize_process_csv($filename);
-}
-
-/// Print footer
-echo $OUTPUT->footer();
-
-function authorize_process_csv($filename) {
-    global $CFG, $SITE, $DB;
-
-    $plugin = enrol_get_plugin('authorize');
-
-    /// We need these fields
-    $myfields = array(
-        'Transaction ID',           // enrol_authorize.transid or enrol_authorize_refunds.transid; See: Reference Transaction ID
-        'Transaction Status',       // Under Review,Approved Review,Review Failed,Settled Successfully
-        'Transaction Type',         // Authorization w/ Auto Capture, Authorization Only, Capture Only, Credit, Void, Prior Authorization Capture
-        'Settlement Amount',        //
-        'Settlement Currency',      //
-        'Settlement Date/Time',     //
-        'Authorization Amount',     //
-        'Authorization Currency',   //
-        'Submit Date/Time',         // timecreated
-        'Reference Transaction ID', // enrol_authorize.transid if Transaction Type = Credit
-        'Total Amount',             // enrol_authorize.cost
-        'Currency',                 // enrol_authorize.currency
-        'Invoice Number',           // enrol_authorize.id: Don't trust this! Backup/Restore changes this
-        'Customer ID'               // enrol_authorize.userid
-    );
-
-    /// Open the file and get first line
-    $handle = fopen($filename, "r");
-    if (!$handle) {
-        print_error('cannotopencsv');
-    }
-    $firstline = fgetcsv($handle, 8192, ",");
-    $numfields = count($firstline);
-    if ($numfields != 49 && $numfields != 70) {
-        @fclose($handle);
-        print_error('csvinvalidcolsnum');
-    }
-
-    /// Re-sort fields
-    $csvfields = array();
-    foreach ($myfields as $myfield) {
-        $csvindex = array_search($myfield, $firstline);
-        if ($csvindex === false) {
-            $csvfields = array();
-            break;
-        }
-        $csvfields[$myfield] = $csvindex;
-    }
-    if (empty($csvfields)) {
-        @fclose($handle);
-        print_error('csvinvalidcols');
-    }
-
-    /// Read lines
-    $sendem = array();
-    $ignoredlines = '';
-
-    $imported = 0;
-    $updated = 0;
-    $ignored = 0;
-    while (($data = fgetcsv($handle, 8192, ",")) !== FALSE) {
-        if (count($data) != $numfields) {
-            $ignored++; // ignore empty lines
-            continue;
-        }
-
-        $transid = $data[$csvfields['Transaction ID']];
-        $transtype = $data[$csvfields['Transaction Type']];
-        $transstatus = $data[$csvfields['Transaction Status']];
-        $reftransid = $data[$csvfields['Reference Transaction ID']];
-        $settlementdate = strtotime($data[$csvfields['Settlement Date/Time']]);
-
-        if ($transstatus == 'Approved Review' || $transstatus == 'Review Failed') {
-            if (($order = $DB->get_record('enrol_authorize', array('transid'=>$transid)))) {
-                $order->status = ($transstatus == 'Approved Review') ? AN_STATUS_APPROVEDREVIEW : AN_STATUS_REVIEWFAILED;
-                $DB->update_record('enrol_authorize', $order);
-                $updated++; // Updated order status
-            }
-            continue;
-        }
-
-        if (!empty($reftransid) && is_numeric($reftransid) && 'Settled Successfully' == $transstatus && 'Credit' == $transtype) {
-            if (($order = $DB->get_record('enrol_authorize', array('transid'=>$reftransid)))) {
-                if (AN_METHOD_ECHECK == $order->paymentmethod) {
-                    $refund = $DB->get_record('enrol_authorize_refunds', array('transid'=>$transid));
-                    if ($refund) {
-                        $refund->status = AN_STATUS_CREDIT;
-                        $refund->settletime = $settlementdate;
-                        $DB->update_record('enrol_authorize_refunds', $refund);
-                        $updated++;
-                    }
-                    else {
-                        $ignored++;
-                        $ignoredlines .= $reftransid . ": Not our business(Reference Transaction ID)\n";
-                    }
-                }
-            }
-            else {
-                $ignored++;
-                $ignoredlines .= $reftransid . ": Not our business(Transaction ID)\n";
-            }
-            continue;
-        }
-
-        if (! ($transstatus == 'Settled Successfully' && $transtype == 'Authorization w/ Auto Capture')) {
-            $ignored++;
-            $ignoredlines .= $transid . ": Not settled\n";
-            continue;
-        }
-
-        // TransactionId must match
-        $order = $DB->get_record('enrol_authorize', array('transid'=>$transid));
-        if (!$order) {
-            $ignored++;
-            $ignoredlines .= $transid . ": Not our business\n";
-            continue;
-        }
-
-        // Authorized/Captured and Settled
-        $order->status = AN_STATUS_AUTHCAPTURE;
-        $order->settletime = $settlementdate;
-        $DB->update_record('enrol_authorize', $order);
-        $updated++; // Updated order status and settlement date
-
-        if ($order->paymentmethod != AN_METHOD_ECHECK) {
-            $ignored++;
-            $ignoredlines .= $transid . ": The method must be echeck\n";
-            continue;
-        }
-
-        // Get course and context
-        $course = $DB->get_record('course', array('id'=>$order->courseid));
-        if (!$course) {
-            $ignored++;
-            $ignoredlines .= $transid . ": Could not find this course: " . $order->courseid . "\n";
-            continue;
-        }
-        $coursecontext = context_course::instance($course->id, IGNORE_MISSING);
-        if (!$coursecontext) {
-            $ignored++;
-            $ignoredlines .= $transid . ": Could not find course context: " . $order->courseid . "\n";
-            continue;
-        }
-
-        // Get user
-        $user = $DB->get_record('user', array('id'=>$order->userid));
-        if (!$user) {
-            $ignored++;
-            $ignoredlines .= $transid . ": Could not find this user: " . $order->userid . "\n";
-            continue;
-        }
-
-        // If user wasn't enrolled, enrol now. Ignore otherwise. Because admin user might submit this file again.
-        if (($role = get_default_course_role($course))) {
-            if (! user_has_role_assignment($user->id, $role->id, $coursecontext->id)) {
-                $timestart = $timeend = 0;
-                if ($course->enrolperiod) {
-                    $timestart = time();
-                    $timeend = $timestart + $course->enrolperiod;
-                }
-                // Enrol user
-                $pinstance = $DB->get_record('enrol', array('id'=>$order->instanceid));
-                $plugin->enrol_user($pinstance, $user->id, $pinstance->roleid, $timestart, $timeend);
-
-                $imported++;
-                if ($plugin->get_config('enrol_mailstudents')) {
-                    $sendem[] = $order->id;
-                }
-            }
-        }
-    }
-    fclose($handle);
-
-    /// Send email to admin
-    if (!empty($ignoredlines)) {
-        $admin = get_admin();
-
-        $eventdata = new stdClass();
-        $eventdata->modulename        = 'moodle';
-        $eventdata->component         = 'enrol_authorize';
-        $eventdata->name              = 'authorize_enrolment';
-        $eventdata->userfrom          = $admin;
-        $eventdata->userto            = $admin;
-        $eventdata->subject           = format_string($SITE->fullname, true, array('context' => context_course::instance(SITEID))).': Authorize.net CSV ERROR LOG';
-        $eventdata->fullmessage       = $ignoredlines;
-        $eventdata->fullmessageformat = FORMAT_PLAIN;
-        $eventdata->fullmessagehtml   = '';
-        $eventdata->smallmessage      = '';
-        message_send($eventdata);
-    }
-
-    /// Send welcome messages to users
-    if (!empty($sendem)) {
-        send_welcome_messages($sendem);
-    }
-
-    /// Show result
-    notice("<b>Done...</b><br />Imported: $imported<br />Updated: $updated<br />Ignored: $ignored");
-}
diff --git a/enrol/authorize/version.php b/enrol/authorize/version.php
deleted file mode 100644 (file)
index 1a91383..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Authorize.Net enrolment plugin version specification.
- *
- * @package    enrol_authorize
- * @copyright  2010 Eugene Venter
- * @author     Eugene Venter
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->version   = 2013050100;        // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires  = 2013050100;        // Requires this Moodle version
-$plugin->component = 'enrol_authorize'; // Full name of the plugin (used for diagnostics)
-$plugin->cron      = 180;
index 950b39a..f591b00 100644 (file)
@@ -47,6 +47,7 @@ define('CLI_SCRIPT', false); // prevents some warnings later
 define('AJAX_SCRIPT', false); // prevents some warnings later
 define('CACHE_DISABLE_ALL', true); // Disables caching.. just in case.
 define('PHPUNIT_TEST', false);
+define('IGNORE_COMPONENT_CACHE', true);
 
 // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
 // This is a quick hack.  Ideally we should ask the admin for a value.  See MDL-22625 for more on this.
index 0c7a8fa..e82f62a 100644 (file)
@@ -22,6 +22,8 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+defined('MOODLE_INTERNAL') || die();
+
 /**
  * Collection of components related methods.
  */
@@ -79,20 +81,44 @@ class core_component {
             return;
         }
 
-        if (PHPUNIT_TEST or !empty($CFG->early_install_lang) or
-                (defined('BEHAT_UTIL') and BEHAT_UTIL) or
-                (defined('BEHAT_TEST') and BEHAT_TEST)) {
-            // 1/ Do not bother storing the file for unit tests,
-            //    we need fresh copy for each execution and
-            //    later we keep it in memory.
-            // 2/ We can not write to dataroot in installer yet.
+        if (defined('IGNORE_COMPONENT_CACHE') and IGNORE_COMPONENT_CACHE) {
             self::fill_all_caches();
             return;
         }
 
-        // Note: cachedir MUST be shared by all servers in a cluster, sorry guys...
-        //       MUC should use classloading, we can not depend on it here.
-        $cachefile = "$CFG->cachedir/core_component.php";
+        if (!empty($CFG->alternative_component_cache)) {
+            // Hack for heavily clustered sites that want to manage component cache invalidation manually.
+            $cachefile = $CFG->alternative_component_cache;
+
+            if (file_exists($cachefile)) {
+                if (CACHE_DISABLE_ALL) {
+                    // Verify the cache state only on upgrade pages.
+                    $content = self::get_cache_content();
+                    if (sha1_file($cachefile) !== sha1($content)) {
+                        die('Outdated component cache file defined in $CFG->alternative_component_cache, can not continue');
+                    }
+                    return;
+                }
+                $cache = array();
+                include($cachefile);
+                self::$plugintypes = $cache['plugintypes'];
+                self::$plugins     = $cache['plugins'];
+                self::$subsystems  = $cache['subsystems'];
+                self::$classmap    = $cache['classmap'];
+                return;
+            }
+
+            if (!is_writable(dirname($cachefile))) {
+                die('Can not create alternative component cache file defined in $CFG->alternative_component_cache, can not continue');
+            }
+
+            // Lets try to create the file, it might be in some writable directory or a local cache dir.
+
+        } else {
+            // Note: $CFG->cachedir MUST be shared by all servers in a cluster,
+            //       use $CFG->alternative_component_cache if you do not like it.
+            $cachefile = "$CFG->cachedir/core_component.php";
+        }
 
         if (!CACHE_DISABLE_ALL and !self::is_developer()) {
             // 1/ Use the cache only outside of install and upgrade.
@@ -105,7 +131,7 @@ class core_component {
                 } else if (!isset($cache['plugintypes']) or !isset($cache['plugins']) or !isset($cache['subsystems']) or !isset($cache['classmap'])) {
                     // Something is very wrong.
                 } else if ($cache['plugintypes']['mod'] !== "$CFG->dirroot/mod") {
-                    // Dirroot was changed.
+                    // $CFG->dirroot was changed.
                 } else {
                     // The cache looks ok, let's use it.
                     self::$plugintypes = $cache['plugintypes'];
@@ -114,17 +140,12 @@ class core_component {
                     self::$classmap    = $cache['classmap'];
                     return;
                 }
+                // Note: we do not verify $CFG->admin here intentionally,
+                //       they must visit admin/index.php after any change.
             }
         }
 
-        $cachedir = dirname($cachefile);
-        if (!is_dir($cachedir)) {
-            mkdir($cachedir, $CFG->directorypermissions, true);
-        }
-
         if (!isset(self::$plugintypes)) {
-            self::fill_all_caches();
-
             // This needs to be atomic and self-fixing as much as possible.
 
             $content = self::get_cache_content();
@@ -132,14 +153,25 @@ class core_component {
                 if (sha1_file($cachefile) === sha1($content)) {
                     return;
                 }
+                // Stale cache detected!
                 unlink($cachefile);
             }
 
+            // Permissions might not be setup properly in installers.
+            $dirpermissions = !isset($CFG->directorypermissions) ? 02777 : $CFG->directorypermissions;
+            $filepermissions = !isset($CFG->filepermissions) ? ($dirpermissions & 0666) : $CFG->filepermissions;
+
+            clearstatcache();
+            $cachedir = dirname($cachefile);
+            if (!is_dir($cachedir)) {
+                mkdir($cachedir, $dirpermissions, true);
+            }
+
             if ($fp = @fopen($cachefile.'.tmp', 'xb')) {
                 fwrite($fp, $content);
                 fclose($fp);
                 @rename($cachefile.'.tmp', $cachefile);
-                @chmod($cachefile, $CFG->filepermissions);
+                @chmod($cachefile, $filepermissions);
             }
             @unlink($cachefile.'.tmp'); // Just in case anything fails (race condition).
             self::invalidate_opcode_php_cache($cachefile);
@@ -157,11 +189,16 @@ class core_component {
     protected static function is_developer() {
         global $CFG;
 
-        if (!isset($CFG->config_php_settings['debug'])) {
+        if (isset($CFG->config_php_settings['debug'])) {
+            // Standard moodle script.
+            $debug = (int)$CFG->config_php_settings['debug'];
+        } else if (isset($CFG->debug)) {
+            // Usually script with ABORT_AFTER_CONFIG.
+            $debug = (int)$CFG->debug;
+        } else {
             return false;
         }
 
-        $debug = (int)$CFG->config_php_settings['debug'];
         if ($debug & E_ALL and $debug & E_STRICT) {
             return true;
         }
@@ -172,9 +209,15 @@ class core_component {
     /**
      * Create cache file content.
      *
+     * @private this is intended for $CFG->alternative_component_cache only.
+     *
      * @return string
      */
-    protected static function get_cache_content() {
+    public static function get_cache_content() {
+        if (!isset(self::$plugintypes)) {
+            self::fill_all_caches();
+        }
+
         $cache = array(
             'subsystems'  => self::$subsystems,
             'plugintypes' => self::$plugintypes,
index 50ca446..37c5f3f 100644 (file)
@@ -312,6 +312,11 @@ function css_minify_css($files) {
         return '';
     }
 
+    // We do not really want any 304 here!
+    // There does not seem to be any better way to prevent them here.
+    unset($_SERVER['HTTP_IF_NONE_MATCH']);
+    unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
+
     set_include_path($CFG->libdir . '/minify/lib' . PATH_SEPARATOR . get_include_path());
     require_once('Minify.php');
 
@@ -340,7 +345,7 @@ function css_minify_css($files) {
     $error = 'unknown';
     try {
         $result = Minify::serve('Files', $options);
-        if ($result['success']) {
+        if ($result['success'] and $result['statusCode'] == 200) {
             return $result['content'];
         }
     } catch (Exception $e) {
index 90fd929..980837e 100644 (file)
@@ -30,12 +30,13 @@ $definitions = array(
 
     // Used to store processed lang files.
     // The keys used are the component of the string file.
+    // The persistent max size has been based upon student access of the site.
     'string' => array(
         'mode' => cache_store::MODE_APPLICATION,
         'simplekeys' => true,
         'simpledata' => true,
         'persistent' => true,
-        'persistentmaxsize' => 3
+        'persistentmaxsize' => 30
     ),
 
     // Used to store database meta information.
@@ -48,7 +49,7 @@ $definitions = array(
             'dbfamily'
         ),
         'persistent' => true,
-        'persistentmaxsize' => 2
+        'persistentmaxsize' => 15
     ),
 
     // Event invalidation cache.
@@ -78,7 +79,7 @@ $definitions = array(
 
     // HTML Purifier cache
     // This caches the html purifier cleaned text. This is done because the text is usually cleaned once for every user
-    // and context combo. Text caching handles caching for the combonation, this cache is responsible for caching the
+    // and context combo. Text caching handles caching for the combination, this cache is responsible for caching the
     // cleaned text which is shareable.
     'htmlpurifier' => array(
         'mode' => cache_store::MODE_APPLICATION,
index 593c964..fcb1e18 100644 (file)
@@ -1550,6 +1550,9 @@ function purge_all_caches() {
 
     cache_helper::purge_all();
 
+    // Clear course cache for all courses.
+    rebuild_course_cache(0, true);
+
     // purge all other caches: rss, simplepie, etc.
     remove_dir($CFG->cachedir.'', true);
 
index 0593812..6dee621 100644 (file)
@@ -40,6 +40,10 @@ if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off
     }
 }
 
+if (!defined('IGNORE_COMPONENT_CACHE')) {
+    define('IGNORE_COMPONENT_CACHE', true);
+}
+
 require_once(__DIR__.'/bootstraplib.php');
 require_once(__DIR__.'/../testing/lib.php');
 require_once(__DIR__.'/classes/autoloader.php');
index 1706683..fd4c32b 100644 (file)
@@ -636,6 +636,7 @@ class plugin_manager {
         // Moodle 2.3 supports upgrades from 2.2.x only.
         $plugins = array(
             'qformat' => array('blackboard'),
+            'enrol' => array('authorize'),
         );
 
         if (!isset($plugins[$type])) {
@@ -715,7 +716,7 @@ class plugin_manager {
             ),
 
             'enrol' => array(
-                'authorize', 'category', 'cohort', 'database', 'flatfile',
+                'category', 'cohort', 'database', 'flatfile',
                 'guest', 'imsenterprise', 'ldap', 'manual', 'meta', 'mnet',
                 'paypal', 'self'
             ),
@@ -823,6 +824,7 @@ class plugin_manager {
 
             'tinymce' => array(
                 'ctrlhelp', 'dragmath', 'moodleemoticon', 'moodleimage', 'moodlemedia', 'moodlenolink', 'spellchecker',
+                'pdw', 'wrap'
             ),
 
             'theme' => array(
index 0f79447..d0c2ab4 100644 (file)
@@ -276,10 +276,10 @@ if (!defined('AJAX_SCRIPT')) {
 }
 
 // File permissions on created directories in the $CFG->dataroot
-if (empty($CFG->directorypermissions)) {
+if (!isset($CFG->directorypermissions)) {
     $CFG->directorypermissions = 02777;      // Must be octal (that's why it's here)
 }
-if (empty($CFG->filepermissions)) {
+if (!isset($CFG->filepermissions)) {
     $CFG->filepermissions = ($CFG->directorypermissions & 0666); // strip execute flags
 }
 // better also set default umask because recursive mkdir() does not apply permissions recursively otherwise
index 5e00ac4..3b62b76 100644 (file)
@@ -243,7 +243,7 @@ class workshop_manual_allocator implements workshop_allocator {
         $reviewers = array();
         if ($submissions) {
             list($submissionids, $params) = $DB->get_in_or_equal(array_keys($submissions), SQL_PARAMS_NAMED);
-            $picturefields = user_picture::fields('r', array(), 'reviewerid')
+            $picturefields = user_picture::fields('r', array(), 'reviewerid');
             $sql = "SELECT a.id AS assessmentid, a.submissionid, $picturefields,
                            s.id AS submissionid, s.authorid
                       FROM {workshop_assessments} a
index 09445b7..8920a08 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$version  = 2013071200.00;              // YYYYMMDD      = weekly release date of this DEV branch
+$version  = 2013071500.00;              // YYYYMMDD      = weekly release date of this DEV branch
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes