Completed
Push — update-3.0 ( c9d4ac...80e736 )
by Daniel Neis
02:14
created
lib.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
process.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -370,6 +370,9 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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 49
 $userid = $USER->id;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 $error_returnurl   = $CFG->wwwroot.'/enrol/pagseguro/return.php';
55 55
 $success_returnurl = $CFG->wwwroot.'/enrol/pagseguro/return.php';
56 56
 
57
-$instanceid  = optional_param('instanceid', 0, PARAM_INT);
57
+$instanceid = optional_param('instanceid', 0, PARAM_INT);
58 58
 
59 59
 $plugin_instance = $DB->get_record("enrol", array("id" => $instanceid, "status" => 0));
60 60
 $courseid     = $plugin_instance->courseid;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 $encoding     = 'UTF-8';
64 64
 $item_id      = $courseid;
65 65
 $item_desc    = empty($course->fullname) ? null : $course->fullname;
66
-$item_qty     = (int)1;
66
+$item_qty     = (int) 1;
67 67
 $item_cost    = empty($plugin_instance->cost) ? 0.00 : number_format($plugin_instance->cost, 2);
68 68
 $item_cost    = str_replace(',', '', $item_cost);
69 69
 $item_amount  = $item_cost;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 $transactionid = optional_param('transaction_id', '', PARAM_RAW);
80 80
 
81 81
 if ($submited) {
82
-    $url = "https://ws.pagseguro.uol.com.br/v2/checkout/?email=" . urlencode($email) . "&token=" . $token;
82
+    $url = "https://ws.pagseguro.uol.com.br/v2/checkout/?email=".urlencode($email)."&token=".$token;
83 83
 
84 84
     $xml = "<?xml version=\"1.0\" encoding=\"$encoding\" standalone=\"yes\"?>
85 85
         <checkout>
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
     $transaction = curl_exec($curl);
133 133
     curl_close($curl);
134 134
 
135
-    if ($transaction == 'Unauthorized'){
135
+    if ($transaction == 'Unauthorized') {
136 136
         // Error=1 Não autorizado.
137 137
         $error_returnurl .= "?id={$courseid}&error=1";
138 138
         header("Location: $error_returnurl");
139
-        exit;//Mantenha essa linha
139
+        exit; //Mantenha essa linha
140 140
     } else {
141
-        $transaction_data  = serialize(trim($transaction));
141
+        $transaction_data = serialize(trim($transaction));
142 142
         process_moodle($transaction_data, $instanceid, $courseid);
143 143
     }
144 144
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 if (!empty($notificationCode)) {
149 149
     $transaction = null;
150 150
     // Sets the web service URL.
151
-    $url = "https://ws.pagseguro.uol.com.br/v2/transactions/notifications/" . $notificationCode . "?email=".$email."&token=".$token;
151
+    $url = "https://ws.pagseguro.uol.com.br/v2/transactions/notifications/".$notificationCode."?email=".$email."&token=".$token;
152 152
 
153 153
     $curl = curl_init($url);
154 154
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
@@ -156,19 +156,19 @@  discard block
 block discarded – undo
156 156
     $transaction = curl_exec($curl);
157 157
     curl_close($curl);
158 158
 
159
-    if ($transaction == 'Unauthorized'){
159
+    if ($transaction == 'Unauthorized') {
160 160
         // Error=1 Não autorizado.
161 161
         $error_returnurl .= "?id={$courseid}&error=1";
162 162
         header("Location: $error_returnurl");
163
-        exit;//Mantenha essa linha
163
+        exit; //Mantenha essa linha
164 164
     } else {
165
-        $transaction_data  = serialize(trim($transaction));
165
+        $transaction_data = serialize(trim($transaction));
166 166
         process_moodle($transaction_data, $instanceid, $courseid);
167 167
     }
168 168
 }
169 169
 
170 170
 function process_moodle($transaction_data, $instanceid, $cid) {
171
-    global $CFG,$USER,$DB,$course;
171
+    global $CFG, $USER, $DB, $course;
172 172
 
173 173
     /// Read all the data from pagseguro and get it ready for later;
174 174
     /// we expect only valid UTF-8 encoding, it is the responsibility
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
     $transaction_xml = unserialize($transaction_data);
189 189
     $transaction = json_decode(json_encode(simplexml_load_string($transaction_xml)));
190 190
 
191
-    if($transaction) {
191
+    if ($transaction) {
192 192
         foreach ($transaction as $trans_key => $trans_value) {
193 193
             $trans_key = strtolower($trans_key);
194
-            if(!is_object($trans_value)) {
194
+            if (!is_object($trans_value)) {
195 195
                 $data->$trans_key = $trans_value;
196 196
             } else {
197
-                foreach($trans_value as $key => $value) {
197
+                foreach ($trans_value as $key => $value) {
198 198
                     $key = strtolower($key);
199
-                    if(is_object($value)) {
200
-                        foreach($value as $k => $v) {
199
+                    if (is_object($value)) {
200
+                        foreach ($value as $k => $v) {
201 201
                             $k = strtolower($k);
202 202
                             $k = $trans_key.'_'.$key.'_'.$k;
203 203
                             $data->$k = $v;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     $data->instanceid       = $instanceid;
222 222
     $data->timeupdated      = time();
223 223
 
224
-    if(!isset($data->reference) && empty($data->reference)) {
224
+    if (!isset($data->reference) && empty($data->reference)) {
225 225
         $data->reference    = $plugin->get_config('pagsegurobusiness');
226 226
     }
227 227
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
298 298
 
299 299
     // Check that amount paid is the correct amount
300
-    if ( (float) $plugin_instance->cost <= 0 ) {
300
+    if ((float) $plugin_instance->cost <= 0) {
301 301
         $cost = (float) $plugin->get_config('cost');
302 302
     } else {
303 303
         $cost = (float) $plugin_instance->cost;
Please login to merge, or discard this patch.
edit_form.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
locallib.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
settings.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
version.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
 defined('MOODLE_INTERNAL') || die();
29 29
 
30
-$plugin->version   = 2016030900;        // The current plugin version (Date: YYYYMMDDXX)
31
-$plugin->requires  = 2011112901;        // Requires this Moodle version
30
+$plugin->version   = 2016030900; // The current plugin version (Date: YYYYMMDDXX)
31
+$plugin->requires  = 2011112901; // Requires this Moodle version
32 32
 $plugin->release   = '3';
33
-$plugin->component = 'enrol_pagseguro';    // Full name of the plugin (used for diagnostics)
33
+$plugin->component = 'enrol_pagseguro'; // Full name of the plugin (used for diagnostics)
Please login to merge, or discard this patch.