Skip to content
Browse files

No need anymore some database fields.

  • Loading branch information...
1 parent 18ab5c1 commit 9e1c2ba45c1672cd47e6f81cdcda61712c5cf956 ethem committed Dec 28, 2005
View
2 enrol/authorize/action.php
@@ -304,8 +304,6 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
case AN_ACTION_PRIOR_AUTH_CAPTURE:
{
$order->transid = strval($response[6]); // TransactionID
- $order->avscode = strval($response[5]); // Address Verification System code
- $order->authcode = strval($response[4]); // Authorization or Approval code
if ($action == AN_ACTION_AUTH_ONLY) {
$order->status = AN_STATUS_AUTH;
// dont't update settletime
View
7 enrol/authorize/db/mysql.php
@@ -77,6 +77,13 @@ function authorize_upgrade($oldversion=0) {
}
}
+ if ($oldversion < 2005122800) { // no need anymore some fields.
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
+ }
+
return $result;
}
View
7 enrol/authorize/db/postgres7.php
@@ -76,6 +76,13 @@ function authorize_upgrade($oldversion=0) {
}
}
+ if ($oldversion < 2005122800) { // no need anymore some fields.
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP ccexp", false);
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP cvv", false);
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP avscode", false);
+ execute_sql("ALTER TABLE {$CFG->prefix}enrol_authorize DROP authcode", false);
+ }
+
return $result;
}
View
20 enrol/authorize/enrol.php
@@ -185,12 +185,9 @@ function cc_submit($form, $course)
$timenow = time();
$order = new stdClass();
$order->cclastfour = substr($form->cc, -4);
- $order->ccexp = $exp_date;
- $order->cvv = $form->cvv;
$order->ccname = $form->ccfirstname . " " . $form->cclastname;
$order->courseid = $course->id;
$order->userid = $USER->id;
- $order->avscode = 'P';
$order->status = AN_STATUS_NONE; // it will be changed...
$order->settletime = 0; // cron changes this.
$order->timecreated = $timenow;
@@ -619,8 +616,13 @@ function cron()
// AUTO-CAPTURE: Transaction must be captured within 30 days. Otherwise it will expired.
$timediffcnf = $timenowsettle - (intval($CFG->an_review_day) * 3600 * 24);
- $select = "status = '" .AN_STATUS_AUTH. "' AND timecreated < '$timediffcnf' AND timecreated > '$timediff30'";
- if (!$orders = get_records('enrol_authorize', $select)) {
+ $sql = "SELECT E.*, C.fullname, C.enrolperiod " .
+ "FROM {$CFG->prefix}enrol_authorize E " .
+ "INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
+ "WHERE (status = '" .AN_STATUS_AUTH. "') " .
+ " AND (E.timecreated < '$timediffcnf') AND (E.timecreated > '$timediff30')";
+
+ if (!$orders = get_records_sql($sql)) {
return;
}
@@ -647,11 +649,9 @@ function cron()
"ID=$order->id in enrol_authorize table.", $order);
}
$timestart = $timeend = 0;
- if ($course = get_record_sql("SELECT enrolperiod FROM {$CFG->prefix}course WHERE id='$order->courseid'")) {
- if ($course->enrolperiod) {
- $timestart = $timenow;
- $timeend = $timestart + $course->enrolperiod;
- }
+ if ($order->enrolperiod) {
+ $timestart = $timenow;
+ $timeend = $order->settletime + $order->enrolperiod;
}
if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize')) {
$this->log .= "User($order->userid) has been enrolled to course($order->courseid).\n";
View
35 enrol/authorize/index.php
@@ -28,7 +28,7 @@
$authstrs = get_strings(array('paymentmanagement', 'orderid', 'void', 'capture', 'refund',
'authorizedpendingcapture','capturedpendingsettle', 'capturedsettled',
'settled', 'refunded', 'cancelled', 'expired', 'tested',
- 'transid', 'settlementdate', 'notsettled', 'returns', 'noreturns', 'amount',
+ 'transid', 'settlementdate', 'notsettled', 'amount',
'howmuch', 'captureyes', 'unenrolstudent'), 'enrol_authorize');
print_header("$site->shortname: $authstr->paymentmanagement", "$site->fullname", "<a href=\"index.php\">$authstr->paymentmanagement</a>", "");
@@ -97,7 +97,7 @@ function authorize_orders()
foreach ($records as $record) {
$actionstatus = get_order_status_desc($record);
$actions = '&nbsp;';
- foreach ($actionstatus->actions as $value) {
+ foreach ($actionstatus->actions as $value) {
$actions .= "&nbsp;&nbsp;<a href='index.php?$value=yes&amp;order=$record->id'>{$authstrs->$value}</a> ";
}
$table->add_data(array(
@@ -130,7 +130,7 @@ function authorize_order_details($orderno) {
$table->size = array('30%', '70%');
$table->align = array('right', 'left');
- $sql = "SELECT E.*, C.shortname " .
+ $sql = "SELECT E.*, C.shortname, C.enrolperiod " .
"FROM {$CFG->prefix}enrol_authorize E " .
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
"WHERE E.id = '$orderno'";
@@ -176,15 +176,24 @@ function authorize_order_details($orderno) {
else {
if (empty($CFG->an_test)) {
$timestart = $timeend = 0;
- if ($course = get_record_sql("SELECT enrolperiod FROM {$CFG->prefix}course WHERE id='$order->courseid'")) {
- if ($course->enrolperiod) {
- $timestart = $order->settletime;
- $timeend = $timestart + $course->enrolperiod;
- }
+ if ($order->enrolperiod) {
+ $timestart = time(); // early start
+ $timeend = $order->settletime + $order->enrolperiod; // lately end
+ }
+ if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize')) {
+ $user = get_record('user', 'id', $order->userid);
+ $teacher = get_teacher($order->courseid);
+ $a->coursename = $order->shortname;
+ $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
+ email_to_user($user, $teacher,
+ get_string("enrolmentnew", '', $order->shortname),
+ get_string('welcometocoursetext', '', $a));
+ redirect("index.php?order=$order->id");
+ }
+ else {
+ $table->data[] = array("<b><font color=red>$strs->error:</font></b>",
+ "Error while trying to enrol ".fullname($user)." in '$order->shortname'");
}
- enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize');
- // To do: inform user. You will access to course on date $order->settletime
- redirect("index.php?order=$order->id");
}
else {
$table->data[] = array(get_string('testmode', 'enrol_authorize'), get_string('capturetestwarn', 'enrol_authorize'));
@@ -348,7 +357,7 @@ function authorize_order_details($orderno) {
$table->data[] = array("<b>$strs->action</b>", $actions);
print_table($table);
if ($settled) { // show refunds.
- echo "<h4>$authstrs->returns</h4>\n";
+ echo "<h4>" . get_string('returns', 'enrol_authorize') . "</h4>\n";
$table2->size = array('15%', '15%', '20%', '35%', '15%');
$table2->align = array('right', 'right', 'right', 'left', 'right');
$table2->head = array($authstrs->transid, $authstrs->amount, $strs->status, $authstrs->settlementdate, $strs->action);
@@ -369,7 +378,7 @@ function authorize_order_details($orderno) {
}
}
else {
- $table2->data[] = array($authstrs->noreturns);
+ $table2->data[] = array(get_string('noreturns', 'enrol_authorize'));
}
print_table($table2);
}
View
2 enrol/authorize/version.php
@@ -1,6 +1,6 @@
<?PHP // $Id$
-$module->version = 2005122200;
+$module->version = 2005122800;
$module->requires = 2005072200;
?>

0 comments on commit 9e1c2ba

Please sign in to comment.
Something went wrong with that request. Please try again.