@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * of one type exist. One instance may also produce several icons. |
45 | 45 | * |
46 | 46 | * @param array $instances all enrol instances of this type in one course |
47 | - * @return array of pix_icon |
|
47 | + * @return pix_icon[] of pix_icon |
|
48 | 48 | */ |
49 | 49 | public function get_info_icons(array $instances) { |
50 | 50 | return array(new pix_icon('icon', get_string('pluginname', 'enrol_pagseguro'), 'enrol_pagseguro')); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * Sets up navigation entries. |
74 | 74 | * |
75 | - * @param object $instance |
|
75 | + * @param stdClass $instance |
|
76 | 76 | * @return void |
77 | 77 | */ |
78 | 78 | public function add_course_navigation($instancesnode, stdClass $instance) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function add_course_navigation($instancesnode, stdClass $instance) { |
79 | 79 | if ($instance->enrol !== 'pagseguro') { |
80 | - throw new coding_exception('Invalid enrol instance type!'); |
|
80 | + throw new coding_exception('Invalid enrol instance type!'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $context = context_course::instance($instance->courseid); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | // Pass $view=true to filter hidden caps if the user cannot see them |
161 | 161 | if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC', |
162 | - '', '', '', '', false, true)) { |
|
162 | + '', '', '', '', false, true)) { |
|
163 | 163 | $users = sort_by_roleassignment_authority($users, $context); |
164 | 164 | $teacher = array_shift($users); |
165 | 165 | } else { |
@@ -166,7 +166,7 @@ |
||
166 | 166 | $teacher = false; |
167 | 167 | } |
168 | 168 | |
169 | - if ( (float) $instance->cost <= 0 ) { |
|
169 | + if ((float) $instance->cost <= 0) { |
|
170 | 170 | $cost = (float) $this->get_config('cost'); |
171 | 171 | } else { |
172 | 172 | $cost = (float) $instance->cost; |
@@ -370,6 +370,9 @@ |
||
370 | 370 | header("Location: $success_returnurl"); |
371 | 371 | } |
372 | 372 | |
373 | +/** |
|
374 | + * @param stdClass $data |
|
375 | + */ |
|
373 | 376 | function message_pagseguro_error_to_admin($subject, $data) { |
374 | 377 | $admin = get_admin(); |
375 | 378 | $site = get_site(); |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | define('COMMERCE_PAGSEGURO_STATUS_REFUNDED', 6); |
44 | 44 | define('COMMERCE_PAGSEGURO_STATUS_CANCELED', 7); |
45 | 45 | define('COMMERCE_PAYMENT_STATUS_SUCCESS', 'success'); |
46 | -define('COMMERCE_PAYMENT_STATUS_FAILURE', 'failure') ; |
|
46 | +define('COMMERCE_PAYMENT_STATUS_FAILURE', 'failure'); |
|
47 | 47 | define('COMMERCE_PAYMENT_STATUS_PENDING', 'pending'); |
48 | 48 | |
49 | -$userid = $USER->id; |
|
50 | -$plugin = enrol_get_plugin('pagseguro'); |
|
51 | -$email = $plugin->get_config('pagsegurobusiness'); |
|
52 | -$token = $plugin->get_config('pagsegurotoken'); |
|
49 | +$userid = $USER->id; |
|
50 | +$plugin = enrol_get_plugin('pagseguro'); |
|
51 | +$email = $plugin->get_config('pagsegurobusiness'); |
|
52 | +$token = $plugin->get_config('pagsegurotoken'); |
|
53 | 53 | |
54 | 54 | $error_returnurl = $CFG->wwwroot.'/enrol/pagseguro/return.php'; |
55 | 55 | $success_returnurl = $CFG->wwwroot.'/enrol/pagseguro/return.php'; |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | $currency = $plugin->get_config('currency'); |
63 | 63 | $encoding = 'UTF-8'; |
64 | 64 | $item_id = $courseid; |
65 | -$item_desc = empty($course->fullname) ? null: $course->fullname; |
|
66 | -$item_qty = (int)1; |
|
65 | +$item_desc = empty($course->fullname) ? null : $course->fullname; |
|
66 | +$item_qty = (int) 1; |
|
67 | 67 | $item_cost = empty($plugin_instance->cost) ? 0.00 : number_format($plugin_instance->cost, 2); |
68 | 68 | $item_amount = $item_cost; |
69 | 69 | |
70 | -$redirect_url = $CFG->wwwroot.'/enrol/pagseguro/process.php'; |
|
71 | -$submitValue = get_string("sendpaymentbutton", "enrol_pagseguro"); |
|
70 | +$redirect_url = $CFG->wwwroot.'/enrol/pagseguro/process.php'; |
|
71 | +$submitValue = get_string("sendpaymentbutton", "enrol_pagseguro"); |
|
72 | 72 | |
73 | 73 | $submited = optional_param('usersubmited', 1, PARAM_INT); |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $notificationCode = optional_param('notificationCode', '', PARAM_RAW); |
77 | 77 | |
78 | 78 | if ($submited) { |
79 | - $url = "https://ws.pagseguro.uol.com.br/v2/checkout/?email=" . urlencode($email) . "&token=" . $token; |
|
79 | + $url = "https://ws.pagseguro.uol.com.br/v2/checkout/?email=".urlencode($email)."&token=".$token; |
|
80 | 80 | |
81 | 81 | $xml = "<?xml version=\"1.0\" encoding=\"$encoding\" standalone=\"yes\"?> |
82 | 82 | <checkout> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if (!empty($notificationCode)) { |
124 | 124 | $transaction = null; |
125 | 125 | // Sets the web service URL. |
126 | - $url = "https://pagseguro.uol.com.br/v2/transactions/notifications/" . $notificationCode . "?email=".$email."&token=".$token; |
|
126 | + $url = "https://pagseguro.uol.com.br/v2/transactions/notifications/".$notificationCode."?email=".$email."&token=".$token; |
|
127 | 127 | |
128 | 128 | $curl = curl_init($url); |
129 | 129 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | $transaction = curl_exec($curl); |
132 | 132 | curl_close($curl); |
133 | 133 | |
134 | - if ($transaction == 'Unauthorized'){ |
|
134 | + if ($transaction == 'Unauthorized') { |
|
135 | 135 | //Insira seu código avisando que o sistema está com problemas, sugiro enviar um e-mail avisando para alguém fazer a manutenção |
136 | - exit;//Mantenha essa linha |
|
136 | + exit; //Mantenha essa linha |
|
137 | 137 | } else { |
138 | - $transaction_data = serialize(trim($transaction)); |
|
138 | + $transaction_data = serialize(trim($transaction)); |
|
139 | 139 | process_moodle($transaction_data, $instanceid, $courseid); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | function process_moodle($transaction_data, $instanceid, $cid) { |
144 | - global $CFG,$USER,$DB,$course; |
|
144 | + global $CFG, $USER, $DB, $course; |
|
145 | 145 | |
146 | 146 | /// Read all the data from pagseguro and get it ready for later; |
147 | 147 | /// we expect only valid UTF-8 encoding, it is the responsibility |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | $transaction_xml = unserialize($transaction_data); |
162 | 162 | $transaction = json_decode(json_encode(simplexml_load_string($transaction_xml))); |
163 | 163 | |
164 | - if($transaction) { |
|
164 | + if ($transaction) { |
|
165 | 165 | foreach ($transaction as $trans_key => $trans_value) { |
166 | 166 | $trans_key = strtolower($trans_key); |
167 | - if(!is_object($trans_value)) { |
|
167 | + if (!is_object($trans_value)) { |
|
168 | 168 | $data->$trans_key = $trans_value; |
169 | 169 | } else { |
170 | - foreach($trans_value as $key => $value) { |
|
170 | + foreach ($trans_value as $key => $value) { |
|
171 | 171 | $key = strtolower($key); |
172 | - if(is_object($value)) { |
|
173 | - foreach($value as $k => $v) { |
|
172 | + if (is_object($value)) { |
|
173 | + foreach ($value as $k => $v) { |
|
174 | 174 | $k = strtolower($k); |
175 | 175 | $k = $trans_key.'_'.$key.'_'.$k; |
176 | 176 | $data->$k = $v; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $data->instanceid = $instanceid; |
195 | 195 | $data->timeupdated = time(); |
196 | 196 | |
197 | - if(!isset($data->reference) && empty($data->reference)) { |
|
197 | + if (!isset($data->reference) && empty($data->reference)) { |
|
198 | 198 | $data->reference = $plugin->get_config('pagsegurobusiness'); |
199 | 199 | } |
200 | 200 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); |
270 | 270 | |
271 | 271 | // Check that amount paid is the correct amount |
272 | - if ( (float) $plugin_instance->cost <= 0 ) { |
|
272 | + if ((float) $plugin_instance->cost <= 0) { |
|
273 | 273 | $cost = (float) $plugin->get_config('cost'); |
274 | 274 | } else { |
275 | 275 | $cost = (float) $plugin_instance->cost; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $mform->setType('name', PARAM_TEXT); |
43 | 43 | |
44 | 44 | $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), |
45 | - ENROL_INSTANCE_DISABLED => get_string('no')); |
|
45 | + ENROL_INSTANCE_DISABLED => get_string('no')); |
|
46 | 46 | $mform->addElement('select', 'status', get_string('status', 'enrol_pagseguro'), $options); |
47 | 47 | $mform->setDefault('status', $plugin->get_config('status')); |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $mform->setDefault('cost', $plugin->get_config('cost')); |
52 | 52 | |
53 | 53 | $mform->addElement('select', 'currency', get_string('currency', 'enrol_pagseguro'), |
54 | - \get_string_manager()->get_list_of_currencies()); |
|
54 | + \get_string_manager()->get_list_of_currencies()); |
|
55 | 55 | $mform->setDefault('currency', $plugin->get_config('currency')); |
56 | 56 | |
57 | 57 | if ($instance->id) { |
@@ -42,8 +42,8 @@ |
||
42 | 42 | |
43 | 43 | $pagseguroimgurl = "https://p.simg.uol.com.br/out/pagseguro/i/botoes/pagamentos/99x61-pagar-assina.gif"; |
44 | 44 | $mform->addElement('static', 'paymentrequired', '', |
45 | - html_writer::empty_tag('img', array('alt' => get_string('pagseguroaccepted', 'enrol_pagseguro'), |
|
46 | - 'src' => $pagseguroimgurl))); |
|
45 | + html_writer::empty_tag('img', array('alt' => get_string('pagseguroaccepted', 'enrol_pagseguro'), |
|
46 | + 'src' => $pagseguroimgurl))); |
|
47 | 47 | |
48 | 48 | $mform->addElement('hidden', 'courseid', $instance->courseid); |
49 | 49 | $mform->setType('courseid', PARAM_INT); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin'))); |
48 | 48 | |
49 | 49 | $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), |
50 | - ENROL_INSTANCE_DISABLED => get_string('no')); |
|
50 | + ENROL_INSTANCE_DISABLED => get_string('no')); |
|
51 | 51 | $settings->add(new admin_setting_configselect('enrol_pagseguro/status', |
52 | 52 | get_string('status', 'enrol_pagseguro'), get_string('status_desc', 'enrol_pagseguro'), ENROL_INSTANCE_DISABLED, $options)); |
53 | 53 |
@@ -26,6 +26,6 @@ |
||
26 | 26 | |
27 | 27 | defined('MOODLE_INTERNAL') || die(); |
28 | 28 | |
29 | -$plugin->version = 2011112901; // The current plugin version (Date: YYYYMMDDXX) |
|
30 | -$plugin->requires = 2011112901; // Requires this Moodle version |
|
31 | -$plugin->component = 'enrol_pagseguro'; // Full name of the plugin (used for diagnostics) |
|
29 | +$plugin->version = 2011112901; // The current plugin version (Date: YYYYMMDDXX) |
|
30 | +$plugin->requires = 2011112901; // Requires this Moodle version |
|
31 | +$plugin->component = 'enrol_pagseguro'; // Full name of the plugin (used for diagnostics) |