Skip to content
Browse files

MDL-10181 User Management Improvements: Cron unenrolment of manual sh…

…ould takes place in the main cron.

It is time to use own enrolment method when calling funcs enrol_into_course, role_assign, role_unassign.

Zend Studio Warning: Assignment in condition (line XX), Solved, one more ()
Assignments in a conditional statement are sometimes the result of a typo.
In many cases, instead of the assignment operator =, the equality operator ==
should be used. When comparing a variable and a non-variable expression,
it is common practice to put the variable on the right-hand side of the equality
operator, so that if the equality operator is erroneously replaced with the
assignment operator, PHP will report a parse error immediately.
This helps you avoid a big subset of this class of bugs.
  • Loading branch information...
1 parent c9c2c21 commit d8347a0ab7b1fc0a77a430df2d073438925c2a24 ethem committed
Showing with 13 additions and 13 deletions.
  1. +6 −6 enrol/authorize/enrol.php
  2. +1 −1 enrol/authorize/localfuncs.php
  3. +5 −5 enrol/authorize/locallib.php
  4. +1 −1 enrol/authorize/uploadcsv.php
View
12 enrol/authorize/enrol.php
@@ -221,7 +221,7 @@ function cc_submit($form, $course)
redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
}
else {
- enrol_into_course($course, $USER, 'manual');
+ enrol_into_course($course, $USER, 'authorize');
redirect("$CFG->wwwroot/course/view.php?id=$course->id");
}
return;
@@ -244,7 +244,7 @@ function cc_submit($form, $course)
$a->orderid = $order->id;
$emailsubject = get_string('adminnewordersubject', 'enrol_authorize', $a);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
- if ($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments')) {
+ if (($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments'))) {
foreach ($paymentmanagers as $paymentmanager) {
email_to_user($paymentmanager, $USER, $emailsubject, $emailmessage);
}
@@ -254,7 +254,7 @@ function cc_submit($form, $course)
}
// Credit card captured, ENROL student now...
- if (enrol_into_course($course, $USER, 'manual')) {
+ if (enrol_into_course($course, $USER, 'authorize')) {
if (!empty($CFG->enrol_mailstudents)) {
send_welcome_messages($order->id);
}
@@ -445,7 +445,7 @@ function config_form($frm)
}
}
- if ($count = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) {
+ if (($count = count_records('enrol_authorize', 'status', AN_STATUS_AUTH))) {
$a = new stdClass;
$a->count = $count;
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=".AN_STATUS_AUTH;
@@ -646,7 +646,7 @@ function cron()
$timeend = $order->settletime + $course->enrolperiod;
}
$user = get_record('user', 'id', $order->userid);
- if (role_assign($role->id, $user->id, 0, $context->id, $timestart, $timeend, 0, 'manual')) {
+ if (role_assign($role->id, $user->id, 0, $context->id, $timestart, $timeend, 0, 'authorize')) {
$this->log .= "User($user->id) has been enrolled to course($course->id).\n";
if (!empty($CFG->enrol_mailstudents)) {
$sendem[] = $order->id;
@@ -784,7 +784,7 @@ function cron_daily()
foreach($courseinfos as $courseinfo) {
$lastcourse = $courseinfo->courseid;
$context = get_context_instance(CONTEXT_COURSE, $lastcourse);
- if ($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments')) {
+ if (($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments'))) {
$a = new stdClass;
$a->course = $courseinfo->shortname;
$a->pending = $courseinfo->cnt;
View
2 enrol/authorize/localfuncs.php
@@ -40,7 +40,7 @@ function prevent_double_paid($course)
$sql .= 'AND status='.AN_STATUS_NONE;
}
- if ($recid = get_field_sql($sql)) {
+ if (($recid = get_field_sql($sql))) {
$a = new stdClass;
$a->orderid = $recid;
$a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$a->orderid";
View
10 enrol/authorize/locallib.php
@@ -53,7 +53,7 @@ function authorize_print_orders($courseid, $userid)
$sql .= "WHERE (e.userid='$userid') ";
}
$sql .= "ORDER BY c.sortorder, c.fullname";
- if ($popupcrs = get_records_sql_menu($sql)) {
+ if (($popupcrs = get_records_sql_menu($sql))) {
$popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
echo "<table border='0' width='100%' cellspacing='0' cellpadding='3' class='generaltable generalbox'>";
echo "<tr>";
@@ -155,7 +155,7 @@ function authorize_print_orders($courseid, $userid)
$where .= "AND (e.userid = '" . $userid . "') ";
}
- if ($sort = $table->get_sql_sort()) {
+ if (($sort = $table->get_sql_sort())) {
$sort = ' ORDER BY ' . $sort;
}
@@ -163,7 +163,7 @@ function authorize_print_orders($courseid, $userid)
$table->initialbars($totalcount > $perpage);
$table->pagesize($perpage, $totalcount);
- if ($records = get_records_sql($select . $from . $where . $sort, $table->get_page_start(), $table->get_page_size())) {
+ if (($records = get_records_sql($select . $from . $where . $sort, $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);
@@ -279,7 +279,7 @@ function authorize_print_order_details($orderno)
else {
if (empty($CFG->an_test)) {
$user = get_record('user', 'id', $order->userid);
- if (enrol_into_course($course, $user, 'manual')) {
+ if (enrol_into_course($course, $user, 'authorize')) {
if (!empty($CFG->enrol_mailstudents)) {
send_welcome_messages($order->id);
}
@@ -312,7 +312,7 @@ function authorize_print_order_details($orderno)
$sql = "SELECT SUM(amount) AS refunded FROM {$CFG->prefix}enrol_authorize_refunds " .
"WHERE (orderid = '" . $orderno . "') AND (status = '" . AN_STATUS_CREDIT . "')";
- if ($refund = get_record_sql($sql)) {
+ if (($refund = get_record_sql($sql))) {
$extra->sum = floatval($refund->refunded);
}
$upto = round($order->amount - $extra->sum, 2);
View
2 enrol/authorize/uploadcsv.php
@@ -206,7 +206,7 @@ function authorize_process_csv($filename)
$timestart = time();
$timeend = $timestart + $course->enrolperiod;
}
- if (role_assign($role->id, $user->id, 0, $coursecontext->id, $timestart, $timeend, 0, 'manual')) {
+ if (role_assign($role->id, $user->id, 0, $coursecontext->id, $timestart, $timeend, 0, 'authorize')) {
$imported++;
if (!empty($CFG->enrol_mailstudents)) {
$sendem[] = $order->id;

0 comments on commit d8347a0

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