@@ -219,7 +219,7 @@  | 
                                                    ||
| 219 | 219 | |
| 220 | 220 | // Pass $view=true to filter hidden caps if the user cannot see them.  | 
                                                        
| 221 | 221 | if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',  | 
                                                        
| 222 | -                                             '', '', '', '', false, true)) { | 
                                                        |
| 222 | +                                                '', '', '', '', false, true)) { | 
                                                        |
| 223 | 223 | $users = sort_by_roleassignment_authority($users, $context);  | 
                                                        
| 224 | 224 | $teacher = array_shift($users);  | 
                                                        
| 225 | 225 |          } else { | 
                                                        
@@ -34,7 +34,7 @@ discard block  | 
                                                    ||
| 34 | 34 |  require("../../../config.php"); | 
                                                        
| 35 | 35 | |
| 36 | 36 | require_once($CFG->libdir.'/eventslib.php');  | 
                                                        
| 37 | -require_once($CFG->libdir . '/filelib.php');  | 
                                                        |
| 37 | +require_once($CFG->libdir.'/filelib.php');  | 
                                                        |
| 38 | 38 | |
| 39 | 39 | // PayPal does not like when we return error messages here,  | 
                                                        
| 40 | 40 | // the custom handler just logs exceptions and stops.  | 
                                                        
@@ -77,15 +77,15 @@ discard block  | 
                                                    ||
| 77 | 77 |  $custom = optional_param('custom', '', PARAM_TEXT); | 
                                                        
| 78 | 78 |  $custom = explode('-', $custom); | 
                                                        
| 79 | 79 | $data->userid = (int)$custom[0];  | 
                                                        
| 80 | -$data->contextid = (int)$custom[1];  | 
                                                        |
| 80 | +$data->contextid = (int)$custom[1];  | 
                                                        |
| 81 | 81 | $data->timeupdated = time();  | 
                                                        
| 82 | 82 | |
| 83 | -if (! $user = $DB->get_record("user", array("id" => $data->userid))) { | 
                                                        |
| 83 | +if (!$user = $DB->get_record("user", array("id" => $data->userid))) { | 
                                                        |
| 84 | 84 |      availability_paypal_message_error_to_admin("Not a valid user id", $data); | 
                                                        
| 85 | 85 | die;  | 
                                                        
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
| 88 | -if (! $context = context::instance_by_id($data->contextid, IGNORE_MISSING)) { | 
                                                        |
| 88 | +if (!$context = context::instance_by_id($data->contextid, IGNORE_MISSING)) { | 
                                                        |
| 89 | 89 |      availability_paypal_message_error_to_admin("Not a valid context id", $data); | 
                                                        
| 90 | 90 | die;  | 
                                                        
| 91 | 91 | }  | 
                                                        
@@ -144,7 +144,7 @@ discard block  | 
                                                    ||
| 144 | 144 | |
| 145 | 145 | // If currency is incorrectly set then someone maybe trying to cheat the system.  | 
                                                        
| 146 | 146 |          if ($data->payment_currency != $paypal->currency) { | 
                                                        
| 147 | - $str = "Currency does not match course settings, received: " . $data->payment_currency;  | 
                                                        |
| 147 | + $str = "Currency does not match course settings, received: ".$data->payment_currency;  | 
                                                        |
| 148 | 148 | availability_paypal_message_error_to_admin($str, $data);  | 
                                                        
| 149 | 149 | die;  | 
                                                        
| 150 | 150 | }  | 
                                                        
@@ -169,8 +169,8 @@ discard block  | 
                                                    ||
| 169 | 169 | |
| 170 | 170 | // If our status is not completed or not pending on an echeck clearance then ignore and die.  | 
                                                        
| 171 | 171 | // This check is redundant at present but may be useful if paypal extend the return codes in the future.  | 
                                                        
| 172 | - if (! ( $data->payment_status == "Completed" or  | 
                                                        |
| 173 | -               ($data->payment_status == "Pending" and $data->pending_reason == "echeck") ) ) { | 
                                                        |
| 172 | + if (!($data->payment_status == "Completed" or  | 
                                                        |
| 173 | +               ($data->payment_status == "Pending" and $data->pending_reason == "echeck"))) { | 
                                                        |
| 174 | 174 | die;  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | 176 | |
@@ -204,10 +204,10 @@ discard block  | 
                                                    ||
| 204 | 204 | $coursecontext = context_course::instance($course->id, IGNORE_MISSING);  | 
                                                        
| 205 | 205 | |
| 206 | 206 | // Check that amount paid is the correct amount.  | 
                                                        
| 207 | -        if ( (float) $paypal->cost < 0 ) { | 
                                                        |
| 208 | - $cost = (float) 0;  | 
                                                        |
| 207 | +        if ((float)$paypal->cost < 0) { | 
                                                        |
| 208 | + $cost = (float)0;  | 
                                                        |
| 209 | 209 |          } else { | 
                                                        
| 210 | - $cost = (float) $paypal->cost;  | 
                                                        |
| 210 | + $cost = (float)$paypal->cost;  | 
                                                        |
| 211 | 211 | }  | 
                                                        
| 212 | 212 | |
| 213 | 213 | // Use the same rounding of floats as on the plugin form.  | 
                                                        
@@ -229,7 +229,7 @@ discard block  | 
                                                    ||
| 229 | 229 | $teacher = false;  | 
                                                        
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | -    } else if (strcmp ($result, "INVALID") == 0) { // ERROR. | 
                                                        |
| 232 | +    } else if (strcmp($result, "INVALID") == 0) { // ERROR. | 
                                                        |
| 233 | 233 |          $DB->insert_record("availability_paypal_tnx", $data, false); | 
                                                        
| 234 | 234 |          availability_paypal_message_error_to_admin("Received an invalid payment notification!! (Fake payment?)", $data); | 
                                                        
| 235 | 235 | }  | 
                                                        
@@ -99,7 +99,7 @@  | 
                                                    ||
| 99 | 99 | // Should double-check with paypal everytime ?  | 
                                                        
| 100 | 100 | $context = $info->get_context();  | 
                                                        
| 101 | 101 |          $allow = $DB->record_exists('availability_paypal_tnx', | 
                                                        
| 102 | -                                  array('userid' => $userid, | 
                                                        |
| 102 | +                                    array('userid' => $userid, | 
                                                        |
| 103 | 103 | 'contextid' => $context->id,  | 
                                                        
| 104 | 104 | 'payment_status' => 'Completed'));  | 
                                                        
| 105 | 105 |          if ($not) { | 
                                                        
@@ -27,5 +27,5 @@  | 
                                                    ||
| 27 | 27 | $plugin->version = 2018121902;  | 
                                                        
| 28 | 28 | $plugin->requires = 2015050500;  | 
                                                        
| 29 | 29 | $plugin->release = 7;  | 
                                                        
| 30 | -$plugin->maturity = MATURITY_STABLE;  | 
                                                        |
| 30 | +$plugin->maturity = MATURITY_STABLE;  | 
                                                        |
| 31 | 31 | $plugin->component = 'availability_paypal';  | 
                                                        
@@ -130,7 +130,7 @@  | 
                                                    ||
| 130 | 130 | <input type="hidden" name="no_note" value="1" />  | 
                                                        
| 131 | 131 | <input type="hidden" name="no_shipping" value="1" />  | 
                                                        
| 132 | 132 |              <input type="hidden" name="notify_url" value="<?php echo "{$CFG->wwwroot}/availability/condition/paypal/ipn.php" ?>" /> | 
                                                        
| 133 | - <?php $returnurl = $CFG->wwwroot . '/availability/condition/paypal/view.php?contextid=' . $contextid; ?>  | 
                                                        |
| 133 | + <?php $returnurl = $CFG->wwwroot.'/availability/condition/paypal/view.php?contextid='.$contextid; ?>  | 
                                                        |
| 134 | 134 | <input type="hidden" name="return" value="<?php echo $returnurl ?>" />  | 
                                                        
| 135 | 135 | <input type="hidden" name="cancel_return" value="<?php echo $returnurl"" ?>" />  | 
                                                        
| 136 | 136 | <input type="hidden" name="rm" value="2" />  |