Completed
Push — master ( 565c08...93d030 )
by José
125:33 queued 71:22
created
plugin/buycourses/src/paypalfunctions.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -324,6 +324,8 @@
 block discarded – undo
324 324
  * @nvpStr is nvp string.
325 325
  * returns an associtive array containing the response from the server.
326 326
  *
327
+ * @param string $methodName
328
+ * @param string $nvpStr
327 329
  */
328 330
 function hash_call($methodName, $nvpStr)
329 331
 {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
  *		phoneNum:			the phoneNum  entered on the merchant's site
112 112
  */
113 113
 function CallMarkExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL,
114
-                                 $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
115
-                                 $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
114
+                                    $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState,
115
+                                    $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum
116 116
 )
117 117
 {
118 118
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
  */
266 266
 
267 267
 function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber,
268
-                       $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip,
269
-                       $countryCode, $currencyCode)
268
+                        $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip,
269
+                        $countryCode, $currencyCode)
270 270
 {
271 271
     //Construct the parameter string that describes DoDirectPayment
272 272
     $nvpstr = "&AMT=" . $paymentAmount;
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 function CallShortcutExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $extra)
68 68
 {
69 69
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
70
-    $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount;
71
-    $nvpstr .= "&PAYMENTREQUEST_0_ITEMAMT=" . $paymentAmount;
72
-    $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
73
-    $nvpstr .= "&RETURNURL=" . $returnURL;
74
-    $nvpstr .= "&CANCELURL=" . $cancelURL;
75
-    $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
70
+    $nvpstr = "&PAYMENTREQUEST_0_AMT=".$paymentAmount;
71
+    $nvpstr .= "&PAYMENTREQUEST_0_ITEMAMT=".$paymentAmount;
72
+    $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=".$paymentType;
73
+    $nvpstr .= "&RETURNURL=".$returnURL;
74
+    $nvpstr .= "&CANCELURL=".$cancelURL;
75
+    $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=".$currencyCodeType;
76 76
     $nvpstr .= $extra;
77 77
 
78 78
     $_SESSION["currencyCodeType"] = $currencyCodeType;
@@ -116,20 +116,20 @@  discard block
 block discarded – undo
116 116
 )
117 117
 {
118 118
     // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation
119
-    $nvpstr = "&PAYMENTREQUEST_0_AMT=" . $paymentAmount;
120
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType;
121
-    $nvpstr = $nvpstr . "&RETURNURL=" . $returnURL;
122
-    $nvpstr = $nvpstr . "&CANCELURL=" . $cancelURL;
123
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType;
124
-    $nvpstr = $nvpstr . "&ADDROVERRIDE=1";
125
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTONAME=" . $shipToName;
126
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET=" . $shipToStreet;
127
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTREET2=" . $shipToStreet2;
128
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCITY=" . $shipToCity;
129
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOSTATE=" . $shipToState;
130
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=" . $shipToCountryCode;
131
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOZIP=" . $shipToZip;
132
-    $nvpstr = $nvpstr . "&PAYMENTREQUEST_0_SHIPTOPHONENUM=" . $phoneNum;
119
+    $nvpstr = "&PAYMENTREQUEST_0_AMT=".$paymentAmount;
120
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_PAYMENTACTION=".$paymentType;
121
+    $nvpstr = $nvpstr."&RETURNURL=".$returnURL;
122
+    $nvpstr = $nvpstr."&CANCELURL=".$cancelURL;
123
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_CURRENCYCODE=".$currencyCodeType;
124
+    $nvpstr = $nvpstr."&ADDROVERRIDE=1";
125
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTONAME=".$shipToName;
126
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTREET=".$shipToStreet;
127
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTREET2=".$shipToStreet2;
128
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOCITY=".$shipToCity;
129
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOSTATE=".$shipToState;
130
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=".$shipToCountryCode;
131
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOZIP=".$shipToZip;
132
+    $nvpstr = $nvpstr."&PAYMENTREQUEST_0_SHIPTOPHONENUM=".$phoneNum;
133 133
 
134 134
     $_SESSION["currencyCodeType"] = $currencyCodeType;
135 135
     $_SESSION["PaymentType"] = $paymentType;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * Build a second API request to PayPal, using the token as the
173 173
      * ID to get the details on the payment authorization
174 174
      */
175
-    $nvpstr = "&TOKEN=" . $token;
175
+    $nvpstr = "&TOKEN=".$token;
176 176
 
177 177
     /**
178 178
      * Make the API call and store the results in an array.
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
     $payerID = urlencode($_SESSION['payer_id']);
214 214
     $serverName = urlencode($_SERVER['SERVER_NAME']);
215 215
 
216
-    $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt;
217
-    $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName;
218
-    $nvpstr = '&' . http_build_query([
216
+    $nvpstr = '&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTREQUEST_0_PAYMENTACTION='.$paymentType.'&PAYMENTREQUEST_0_AMT='.$FinalPaymentAmt;
217
+    $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE='.$currencyCodeType.'&IPADDRESS='.$serverName;
218
+    $nvpstr = '&'.http_build_query([
219 219
         'TOKEN' => $token,
220 220
         'PAYERID' => $payerID,
221 221
         'PAYMENTACTION' => $paymentType,
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
                        $countryCode, $currencyCode)
270 270
 {
271 271
     //Construct the parameter string that describes DoDirectPayment
272
-    $nvpstr = "&AMT=" . $paymentAmount;
273
-    $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode;
274
-    $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType;
275
-    $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType;
276
-    $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber;
277
-    $nvpstr = $nvpstr . "&EXPDATE=" . $expDate;
278
-    $nvpstr = $nvpstr . "&CVV2=" . $cvv2;
279
-    $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName;
280
-    $nvpstr = $nvpstr . "&LASTNAME=" . $lastName;
281
-    $nvpstr = $nvpstr . "&STREET=" . $street;
282
-    $nvpstr = $nvpstr . "&CITY=" . $city;
283
-    $nvpstr = $nvpstr . "&STATE=" . $state;
284
-    $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode;
285
-    $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];
272
+    $nvpstr = "&AMT=".$paymentAmount;
273
+    $nvpstr = $nvpstr."&CURRENCYCODE=".$currencyCode;
274
+    $nvpstr = $nvpstr."&PAYMENTACTION=".$paymentType;
275
+    $nvpstr = $nvpstr."&CREDITCARDTYPE=".$creditCardType;
276
+    $nvpstr = $nvpstr."&ACCT=".$creditCardNumber;
277
+    $nvpstr = $nvpstr."&EXPDATE=".$expDate;
278
+    $nvpstr = $nvpstr."&CVV2=".$cvv2;
279
+    $nvpstr = $nvpstr."&FIRSTNAME=".$firstName;
280
+    $nvpstr = $nvpstr."&LASTNAME=".$lastName;
281
+    $nvpstr = $nvpstr."&STREET=".$street;
282
+    $nvpstr = $nvpstr."&CITY=".$city;
283
+    $nvpstr = $nvpstr."&STATE=".$state;
284
+    $nvpstr = $nvpstr."&COUNTRYCODE=".$countryCode;
285
+    $nvpstr = $nvpstr."&IPADDRESS=".$_SERVER['REMOTE_ADDR'];
286 286
 
287 287
     $resArray = hash_call("DoDirectPayment", $nvpstr);
288 288
 
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
     //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
346 346
     //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
347 347
     if ($USE_PROXY) {
348
-        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST . ":" . $PROXY_PORT);
348
+        curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST.":".$PROXY_PORT);
349 349
     }
350 350
 
351 351
     //NVPRequest for submitting to server
352
-    $nvpreq = "METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) .
353
-        "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) .
354
-        "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
352
+    $nvpreq = "METHOD=".urlencode($methodName)."&VERSION=".urlencode($version).
353
+        "&PWD=".urlencode($API_Password)."&USER=".urlencode($API_UserName).
354
+        "&SIGNATURE=".urlencode($API_Signature).$nvpStr."&BUTTONSOURCE=".urlencode($sBNCode);
355 355
 
356 356
     //setting the nvpreq as POST FIELD to curl
357 357
     curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 {
386 386
     global $PAYPAL_URL;
387 387
     // Redirect to paypal.com here
388
-    $payPalURL = $PAYPAL_URL . $token;
389
-    header("Location: " . $payPalURL);
388
+    $payPalURL = $PAYPAL_URL.$token;
389
+    header("Location: ".$payPalURL);
390 390
     exit;
391 391
 }
392 392
 
Please login to merge, or discard this patch.
plugin/clockworksms/lib/clockworksms_plugin.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     /**
15 15
      * create (a singleton function that ensures ClockworksmsPlugin instance is
16 16
      * created only once. If it is already created, it returns the instance)
17
-     * @return  object  ClockworksmsPlugin instance
17
+     * @return  ClockworksmsPlugin  ClockworksmsPlugin instance
18 18
      */
19 19
     public static function create()
20 20
     {
Please login to merge, or discard this patch.
plugin/clockworksms/vendor/clockworksms_api.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -471,6 +471,8 @@  discard block
 block discarded – undo
471 471
   *
472 472
   * @param   string   method Clockwork method to call (sms/credit)
473 473
   * @param   string   data   Content of HTTP POST
474
+  * @param string $method
475
+  * @param string $data
474 476
   *
475 477
   * @return  string          Response from Clockwork
476 478
   * @author  Martin Steel
@@ -505,6 +507,7 @@  discard block
 block discarded – undo
505 507
   *
506 508
   * @param   string url      URL to send to
507 509
   * @param   string data     Data to POST
510
+  * @param string $url
508 511
   * @return  string          Response returned by server
509 512
   * @author  Martin Steel
510 513
   */
@@ -631,7 +634,7 @@  discard block
 block discarded – undo
631 634
    * Check if a number is a valid MSISDN
632 635
    *
633 636
    * @param string $val Value to check
634
-   * @return bool True if valid MSISDN
637
+   * @return integer True if valid MSISDN
635 638
    * @author James Inman
636 639
    * @since 1.3.0
637 640
    * @todo Take an optional country code and check that the number starts with it
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 */
11 11
 
12 12
 if ( !class_exists('ClockworkException') ) {
13
-  require_once('exception.php');
13
+    require_once('exception.php');
14 14
 }
15 15
 
16 16
 /**
@@ -21,130 +21,130 @@  discard block
 block discarded – undo
21 21
 */
22 22
 class Clockwork {
23 23
 
24
-  /*
24
+    /*
25 25
   * Version of this class
26 26
   */
27
-  const VERSION           = '1.3.1';
28
-
29
-  /**
30
-  * All Clockwork API calls start with BASE_URL
31
-  * @author  Martin Steel
32
-  */
33
-  const API_BASE_URL      = 'api.clockworksms.com/xml/';
34
-
35
-  /**
36
-  * string to append to API_BASE_URL to check authentication
37
-  * @author  Martin Steel
38
-  */
39
-  const API_AUTH_METHOD   = 'authenticate';
40
-
41
-  /**
42
-  * string to append to API_BASE_URL for sending SMS
43
-  * @author  Martin Steel
44
-  */
45
-  const API_SMS_METHOD    = 'sms';
46
-
47
-  /**
48
-  * string to append to API_BASE_URL for checking message credit
49
-  * @author  Martin Steel
50
-  */
51
-  const API_CREDIT_METHOD = 'credit';
52
-
53
-  /**
54
-  * string to append to API_BASE_URL for checking account balance
55
-  * @author  Martin Steel
56
-  */
57
-  const API_BALANCE_METHOD = 'balance';
58
-
59
-  /** 
60
-  * Clockwork API Key
61
-  * 
62
-  * @var string
63
-  * @author  Martin Steel
64
-  */
65
-  public $key;
66
-
67
-  /**
68
-  * Use SSL when making HTTP requests
69
-  *
70
-  * If this is not set, SSL will be used where PHP supports it
71
-  *
72
-  * @var bool
73
-  * @author  Martin Steel
74
-  */
75
-  public $ssl;
76
-
77
-  /**
78
-  * Proxy server hostname (Optional)
79
-  *
80
-  * @var string
81
-  * @author  Martin Steel
82
-  */
83
-  public $proxy_host;
84
-
85
-  /**
86
-  * Proxy server port (Optional)
87
-  *
88
-  * @var integer
89
-  * @author  Martin Steel
90
-  */
91
-  public $proxy_port;
92
-
93
-  /**
94
-  * From address used on text messages
95
-  *
96
-  * @var string (11 characters or 12 numbers)
97
-  * @author  Martin Steel
98
-  */
99
-  public $from;
100
-
101
-  /**
102
-  * Allow long SMS messages (Cost up to 3 credits)
103
-  *
104
-  * @var bool
105
-  * @author  Martin Steel
106
-  */
107
-  public $long;
108
-
109
-  /**
110
-  * Truncate message text if it is too long
111
-  *
112
-  * @var bool
113
-  * @author  Martin Steel
114
-  */
115
-  public $truncate;
116
-
117
-  /**
118
-  * Enables various logging of messages when true.
119
-  *
120
-  * @var bool
121
-  * @author  Martin Steel
122
-  */
123
-  public $log;
124
-
125
-  /**
126
-  * What Clockwork should do if you send an invalid character
127
-  *
128
-  * Possible values:
129
-  *      'error'     - Return an error (Messasge is not sent)
130
-  *      'remove'    - Remove the invalid character(s)
131
-  *      'replace'   - Replace invalid characters where possible, remove others 
132
-  * @author  Martin Steel
133
-  */
134
-  public $invalid_char_action;
135
-
136
-  /**
137
-  * Create a new instance of the Clockwork wrapper
138
-  *
139
-  * @param   string  key         Your Clockwork API Key
140
-  * @param   array   options     Optional parameters for sending SMS
141
-  * @author  Martin Steel
142
-  */
143
-  public function __construct($key, array $options = array()) {
27
+    const VERSION           = '1.3.1';
28
+
29
+    /**
30
+     * All Clockwork API calls start with BASE_URL
31
+     * @author  Martin Steel
32
+     */
33
+    const API_BASE_URL      = 'api.clockworksms.com/xml/';
34
+
35
+    /**
36
+     * string to append to API_BASE_URL to check authentication
37
+     * @author  Martin Steel
38
+     */
39
+    const API_AUTH_METHOD   = 'authenticate';
40
+
41
+    /**
42
+     * string to append to API_BASE_URL for sending SMS
43
+     * @author  Martin Steel
44
+     */
45
+    const API_SMS_METHOD    = 'sms';
46
+
47
+    /**
48
+     * string to append to API_BASE_URL for checking message credit
49
+     * @author  Martin Steel
50
+     */
51
+    const API_CREDIT_METHOD = 'credit';
52
+
53
+    /**
54
+     * string to append to API_BASE_URL for checking account balance
55
+     * @author  Martin Steel
56
+     */
57
+    const API_BALANCE_METHOD = 'balance';
58
+
59
+    /** 
60
+     * Clockwork API Key
61
+     * 
62
+     * @var string
63
+     * @author  Martin Steel
64
+     */
65
+    public $key;
66
+
67
+    /**
68
+     * Use SSL when making HTTP requests
69
+     *
70
+     * If this is not set, SSL will be used where PHP supports it
71
+     *
72
+     * @var bool
73
+     * @author  Martin Steel
74
+     */
75
+    public $ssl;
76
+
77
+    /**
78
+     * Proxy server hostname (Optional)
79
+     *
80
+     * @var string
81
+     * @author  Martin Steel
82
+     */
83
+    public $proxy_host;
84
+
85
+    /**
86
+     * Proxy server port (Optional)
87
+     *
88
+     * @var integer
89
+     * @author  Martin Steel
90
+     */
91
+    public $proxy_port;
92
+
93
+    /**
94
+     * From address used on text messages
95
+     *
96
+     * @var string (11 characters or 12 numbers)
97
+     * @author  Martin Steel
98
+     */
99
+    public $from;
100
+
101
+    /**
102
+     * Allow long SMS messages (Cost up to 3 credits)
103
+     *
104
+     * @var bool
105
+     * @author  Martin Steel
106
+     */
107
+    public $long;
108
+
109
+    /**
110
+     * Truncate message text if it is too long
111
+     *
112
+     * @var bool
113
+     * @author  Martin Steel
114
+     */
115
+    public $truncate;
116
+
117
+    /**
118
+     * Enables various logging of messages when true.
119
+     *
120
+     * @var bool
121
+     * @author  Martin Steel
122
+     */
123
+    public $log;
124
+
125
+    /**
126
+     * What Clockwork should do if you send an invalid character
127
+     *
128
+     * Possible values:
129
+     *      'error'     - Return an error (Messasge is not sent)
130
+     *      'remove'    - Remove the invalid character(s)
131
+     *      'replace'   - Replace invalid characters where possible, remove others 
132
+     * @author  Martin Steel
133
+     */
134
+    public $invalid_char_action;
135
+
136
+    /**
137
+     * Create a new instance of the Clockwork wrapper
138
+     *
139
+     * @param   string  key         Your Clockwork API Key
140
+     * @param   array   options     Optional parameters for sending SMS
141
+     * @author  Martin Steel
142
+     */
143
+    public function __construct($key, array $options = array()) {
144 144
     if (empty($key)) {
145
-      throw new ClockworkException("Key can't be blank");      
145
+        throw new ClockworkException("Key can't be blank");      
146 146
     } else {
147
-      $this->key = $key;
147
+        $this->key = $key;
148 148
     }
149 149
         
150 150
     $this->ssl                  = (array_key_exists('ssl', $options)) ? $options['ssl'] : null;
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
     $this->truncate             = (array_key_exists('truncate', $options)) ? $options['truncate'] : null;
156 156
     $this->invalid_char_action  = (array_key_exists('invalid_char_action', $options)) ? $options['invalid_char_action'] : null;
157 157
     $this->log                  = (array_key_exists('log', $options)) ? $options['log'] : false;
158
-  }
158
+    }
159 159
 
160
-  /**
161
-  * Send some text messages
162
-  * 
163
-  *
164
-  * @author  Martin Steel
165
-  */
166
-  public function send(array $sms) {
160
+    /**
161
+     * Send some text messages
162
+     * 
163
+     *
164
+     * @author  Martin Steel
165
+     */
166
+    public function send(array $sms) {
167 167
     if (!is_array($sms)) {
168
-      throw new ClockworkException("sms parameter must be an array");
168
+        throw new ClockworkException("sms parameter must be an array");
169 169
     }
170 170
     $single_message = $this->is_assoc($sms);
171 171
 
172 172
     if ($single_message) {
173
-      $sms = array($sms);
173
+        $sms = array($sms);
174 174
     }
175 175
 
176 176
     $req_doc = new DOMDocument('1.0', 'UTF-8');
@@ -182,70 +182,70 @@  discard block
 block discarded – undo
182 182
     $root->appendChild($user_node);
183 183
 
184 184
     for ($i = 0; $i < count($sms); $i++) {
185
-      $single = $sms[$i];
185
+        $single = $sms[$i];
186 186
 
187
-      $sms_node = $req_doc->createElement('SMS');
187
+        $sms_node = $req_doc->createElement('SMS');
188 188
            
189
-      // Phone number
190
-      $sms_node->appendChild($req_doc->createElement('To', $single['to'])); 
189
+        // Phone number
190
+        $sms_node->appendChild($req_doc->createElement('To', $single['to'])); 
191 191
             
192
-      // Message text
193
-      $content_node = $req_doc->createElement('Content');
194
-      $content_node->appendChild($req_doc->createTextNode($single['message']));
195
-      $sms_node->appendChild($content_node);
192
+        // Message text
193
+        $content_node = $req_doc->createElement('Content');
194
+        $content_node->appendChild($req_doc->createTextNode($single['message']));
195
+        $sms_node->appendChild($content_node);
196 196
 
197
-      // From
198
-      if (array_key_exists('from', $single) || isset($this->from)) {
197
+        // From
198
+        if (array_key_exists('from', $single) || isset($this->from)) {
199 199
         $from_node = $req_doc->createElement('From');
200 200
         $from_node->appendChild($req_doc->createTextNode(array_key_exists('from', $single) ? $single['from'] : $this->from));
201 201
         $sms_node->appendChild($from_node);
202
-      }
202
+        }
203 203
 
204
-      // Client ID
205
-      if (array_key_exists('client_id', $single)) {
204
+        // Client ID
205
+        if (array_key_exists('client_id', $single)) {
206 206
         $client_id_node = $req_doc->createElement('ClientID');
207 207
         $client_id_node->appendChild($req_doc->createTextNode($single['client_id']));
208 208
         $sms_node->appendChild($client_id_node);
209
-      }
209
+        }
210 210
 
211
-      // Long
212
-      if (array_key_exists('long', $single) || isset($this->long)) {
211
+        // Long
212
+        if (array_key_exists('long', $single) || isset($this->long)) {
213 213
         $long = array_key_exists('long', $single) ? $single['long'] : $this->long;
214 214
         $long_node = $req_doc->createElement('Long');
215 215
         $long_node->appendChild($req_doc->createTextNode($long ? 1 : 0));
216 216
         $sms_node->appendChild($long_node);
217
-      }
217
+        }
218 218
 
219
-      // Truncate
220
-      if (array_key_exists('truncate', $single) || isset($this->truncate)) {
219
+        // Truncate
220
+        if (array_key_exists('truncate', $single) || isset($this->truncate)) {
221 221
         $truncate = array_key_exists('truncate', $single) ? $single['truncate'] : $this->truncate;
222 222
         $trunc_node = $req_doc->createElement('Truncate');
223 223
         $trunc_node->appendChild($req_doc->createTextNode($truncate ? 1 : 0));
224 224
         $sms_node->appendChild($trunc_node);
225
-      }
225
+        }
226 226
 
227
-      // Invalid Char Action
228
-      if (array_key_exists('invalid_char_action', $single) || isset($this->invalid_char_action)) {
227
+        // Invalid Char Action
228
+        if (array_key_exists('invalid_char_action', $single) || isset($this->invalid_char_action)) {
229 229
         $action = array_key_exists('invalid_char_action', $single) ? $single['invalid_char_action'] : $this->invalid_char_action;
230 230
         switch (strtolower($action)) {
231
-          case 'error':
231
+            case 'error':
232 232
           $sms_node->appendChild($req_doc->createElement('InvalidCharAction', 1));
233
-          break;
234
-          case 'remove':
233
+            break;
234
+            case 'remove':
235 235
           $sms_node->appendChild($req_doc->createElement('InvalidCharAction', 2));
236
-          break;
237
-          case 'replace':
236
+            break;
237
+            case 'replace':
238 238
           $sms_node->appendChild($req_doc->createElement('InvalidCharAction', 3));
239
+            break;
240
+            default:
239 241
           break;
240
-          default:
241
-          break;
242 242
         }
243
-      }
243
+        }
244 244
 
245
-      // Wrapper ID
246
-      $sms_node->appendChild($req_doc->createElement('WrapperID', $i));
245
+        // Wrapper ID
246
+        $sms_node->appendChild($req_doc->createElement('WrapperID', $i));
247 247
 
248
-      $root->appendChild($sms_node);
248
+        $root->appendChild($sms_node);
249 249
     }
250 250
 
251 251
     $req_xml = $req_doc->saveXML();
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
     $err_desc = null;
260 260
 
261 261
     foreach($resp_doc->documentElement->childNodes AS $doc_child) {
262
-      switch(strtolower($doc_child->nodeName)) {
262
+        switch(strtolower($doc_child->nodeName)) {
263 263
         case 'sms_resp':
264 264
         $resp = array();
265 265
         $wrapper_id = null;
266 266
         foreach($doc_child->childNodes AS $resp_node) {
267
-          switch(strtolower($resp_node->nodeName)) {
267
+            switch(strtolower($resp_node->nodeName)) {
268 268
             case 'messageid':
269 269
             $resp['id'] = $resp_node->nodeValue;
270 270
             break;
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
             case 'wrapperid':
278 278
             $wrapper_id = $resp_node->nodeValue;
279 279
             break;
280
-          }
280
+            }
281 281
         }
282 282
         if( array_key_exists('error_code', $resp ) ) 
283 283
         {
284
-          $resp['success'] = 0;
284
+            $resp['success'] = 0;
285 285
         } else {
286
-          $resp['success'] = 1;
286
+            $resp['success'] = 1;
287 287
         }
288 288
         $resp['sms'] = $sms[$wrapper_id];
289 289
         array_push($response, $resp);
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
         case 'errdesc':
295 295
         $err_desc = $doc_child->nodeValue;
296 296
         break;
297
-      }
297
+        }
298 298
     }
299 299
 
300 300
     if (isset($err_no)) {
301
-      throw new ClockworkException($err_desc, $err_no);      
301
+        throw new ClockworkException($err_desc, $err_no);      
302 302
     }
303 303
         
304 304
     if ($single_message) {
305
-      return $response[0];
305
+        return $response[0];
306 306
     } else {
307
-      return $response;
307
+        return $response;
308 308
     }
309
-  }
310
-
311
-  /**
312
-  * Check how many SMS credits you have available
313
-  *
314
-  * @return  integer   SMS credits remaining
315
-  * @deprecated Use checkBalance() instead
316
-  * @author  Martin Steel
317
-  */
318
-  public function checkCredit() {
309
+    }
310
+
311
+    /**
312
+     * Check how many SMS credits you have available
313
+     *
314
+     * @return  integer   SMS credits remaining
315
+     * @deprecated Use checkBalance() instead
316
+     * @author  Martin Steel
317
+     */
318
+    public function checkCredit() {
319 319
     // Create XML doc for request
320 320
     $req_doc = new DOMDocument('1.0', 'UTF-8');
321 321
     $root = $req_doc->createElement('Credit');
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
     $err_desc = null;
337 337
         
338 338
     foreach ($resp_doc->documentElement->childNodes AS $doc_child) {
339
-      switch ($doc_child->nodeName) {
339
+        switch ($doc_child->nodeName) {
340 340
         case "Credit":
341 341
         $credit = $doc_child->nodeValue;
342 342
         break;
@@ -348,22 +348,22 @@  discard block
 block discarded – undo
348 348
         break;
349 349
         default:
350 350
         break;
351
-      }
351
+        }
352 352
     }
353 353
 
354 354
     if (isset($err_no)) {
355
-      throw new ClockworkException($err_desc, $err_no);
355
+        throw new ClockworkException($err_desc, $err_no);
356 356
     }
357 357
     return $credit;
358
-  }
358
+    }
359 359
 
360
-  /**
361
-  * Check your account balance
362
-  *
363
-  * @return  array   Array of account balance: 
364
-  * @author  Martin Steel
365
-  */
366
-  public function checkBalance() {
360
+    /**
361
+     * Check your account balance
362
+     *
363
+     * @return  array   Array of account balance: 
364
+     * @author  Martin Steel
365
+     */
366
+    public function checkBalance() {
367 367
     // Create XML doc for request
368 368
     $req_doc = new DOMDocument('1.0', 'UTF-8');
369 369
     $root = $req_doc->createElement('Balance');
@@ -384,20 +384,20 @@  discard block
 block discarded – undo
384 384
     $err_desc = null;
385 385
         
386 386
     foreach ($resp_doc->documentElement->childNodes as $doc_child) {
387
-      switch ($doc_child->nodeName) {
387
+        switch ($doc_child->nodeName) {
388 388
         case "Balance":
389 389
         $balance = number_format(floatval($doc_child->nodeValue), 2);
390 390
         break;
391 391
         case "Currency":
392 392
         foreach ($doc_child->childNodes as $resp_node) {
393
-          switch ($resp_node->tagName) {
393
+            switch ($resp_node->tagName) {
394 394
             case "Symbol":
395 395
             $symbol = $resp_node->nodeValue; 
396 396
             break;
397 397
             case "Code":
398 398
             $code = $resp_node->nodeValue; 
399 399
             break;
400
-          }
400
+            }
401 401
         }
402 402
         break;
403 403
         case "ErrNo":
@@ -408,23 +408,23 @@  discard block
 block discarded – undo
408 408
         break;
409 409
         default:
410 410
         break;
411
-      }
411
+        }
412 412
     }
413 413
 
414 414
     if (isset($err_no)) {
415
-      throw new ClockworkException($err_desc, $err_no);
415
+        throw new ClockworkException($err_desc, $err_no);
416 416
     }
417 417
         
418 418
     return array( 'symbol' => $symbol, 'balance' => $balance, 'code' => $code );
419
-  }
419
+    }
420 420
 
421
-  /**
422
-  * Check whether the API Key is valid
423
-  *
424
-  * @return  bool    True indicates a valid key
425
-  * @author  Martin Steel
426
-  */
427
-  public function checkKey() {
421
+    /**
422
+     * Check whether the API Key is valid
423
+     *
424
+     * @return  bool    True indicates a valid key
425
+     * @author  Martin Steel
426
+     */
427
+    public function checkKey() {
428 428
     // Create XML doc for request
429 429
     $req_doc = new DOMDocument('1.0', 'UTF-8');
430 430
     $root = $req_doc->createElement('Authenticate');
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     $err_desc = null;
446 446
 
447 447
     foreach ($resp_doc->documentElement->childNodes AS $doc_child) {
448
-      switch ($doc_child->nodeName) {
448
+        switch ($doc_child->nodeName) {
449 449
         case "CustID":
450 450
         $cust_id = $doc_child->nodeValue;
451 451
         break;
@@ -457,33 +457,33 @@  discard block
 block discarded – undo
457 457
         break;
458 458
         default:
459 459
         break;
460
-      }
460
+        }
461 461
     }
462 462
 
463 463
     if (isset($err_no)) {
464
-      throw new ClockworkException($err_desc, $err_no);
464
+        throw new ClockworkException($err_desc, $err_no);
465 465
     }
466 466
     return isset($cust_id);   
467
-  }
468
-
469
-  /**
470
-  * Make an HTTP POST to Clockwork
471
-  *
472
-  * @param   string   method Clockwork method to call (sms/credit)
473
-  * @param   string   data   Content of HTTP POST
474
-  *
475
-  * @return  string          Response from Clockwork
476
-  * @author  Martin Steel
477
-  */
478
-  protected function postToClockwork($method, $data) {
467
+    }
468
+
469
+    /**
470
+     * Make an HTTP POST to Clockwork
471
+     *
472
+     * @param   string   method Clockwork method to call (sms/credit)
473
+     * @param   string   data   Content of HTTP POST
474
+     *
475
+     * @return  string          Response from Clockwork
476
+     * @author  Martin Steel
477
+     */
478
+    protected function postToClockwork($method, $data) {
479 479
     if ($this->log) {
480
-      $this->logXML("API $method Request XML", $data);
480
+        $this->logXML("API $method Request XML", $data);
481 481
     }
482 482
     
483 483
     if( isset( $this->ssl ) ) {
484
-      $ssl = $this->ssl;
484
+        $ssl = $this->ssl;
485 485
     } else {
486
-      $ssl = $this->sslSupport();
486
+        $ssl = $this->sslSupport();
487 487
     }
488 488
 
489 489
     $url = $ssl ? 'https://' : 'http://';
@@ -492,152 +492,152 @@  discard block
 block discarded – undo
492 492
     $response = $this->xmlPost($url, $data);
493 493
 
494 494
     if ($this->log) {
495
-      $this->logXML("API $method Response XML", $response);
495
+        $this->logXML("API $method Response XML", $response);
496 496
     }
497 497
 
498 498
     return $response;
499
-  }
500
-
501
-  /**
502
-  * Make a HTTP POST
503
-  *
504
-  * cURL will be used if available, otherwise tries the PHP stream functions
505
-  *
506
-  * @param   string url      URL to send to
507
-  * @param   string data     Data to POST
508
-  * @return  string          Response returned by server
509
-  * @author  Martin Steel
510
-  */
511
-  protected function xmlPost($url, $data) {
499
+    }
500
+
501
+    /**
502
+     * Make a HTTP POST
503
+     *
504
+     * cURL will be used if available, otherwise tries the PHP stream functions
505
+     *
506
+     * @param   string url      URL to send to
507
+     * @param   string data     Data to POST
508
+     * @return  string          Response returned by server
509
+     * @author  Martin Steel
510
+     */
511
+    protected function xmlPost($url, $data) {
512 512
     if(extension_loaded('curl')) {
513
-      $ch = curl_init($url);
514
-      curl_setopt($ch, CURLOPT_POST, 1);
515
-      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
516
-      curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
517
-      curl_setopt($ch, CURLOPT_USERAGENT, 'Clockwork PHP Wrapper/1.0' . self::VERSION);
518
-      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
519
-      if (isset($this->proxy_host) && isset($this->proxy_port)) {
513
+        $ch = curl_init($url);
514
+        curl_setopt($ch, CURLOPT_POST, 1);
515
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
516
+        curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
517
+        curl_setopt($ch, CURLOPT_USERAGENT, 'Clockwork PHP Wrapper/1.0' . self::VERSION);
518
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
519
+        if (isset($this->proxy_host) && isset($this->proxy_port)) {
520 520
         curl_setopt($ch, CURLOPT_PROXY, $this->proxy_host);
521 521
         curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy_port);
522
-      }
522
+        }
523 523
 
524
-      $response = curl_exec($ch);
525
-      $info = curl_getinfo($ch);
524
+        $response = curl_exec($ch);
525
+        $info = curl_getinfo($ch);
526 526
 
527
-      if ($response === false || $info['http_code'] != 200) {
527
+        if ($response === false || $info['http_code'] != 200) {
528 528
         throw new Exception('HTTP Error calling Clockwork API - HTTP Status: ' . $info['http_code'] . ' - cURL Erorr: ' . curl_error($ch));
529
-      } elseif (curl_errno($ch) > 0) {
529
+        } elseif (curl_errno($ch) > 0) {
530 530
         throw new Exception('HTTP Error calling Clockwork API - cURL Error: ' . curl_error($ch));
531
-      }
531
+        }
532 532
 
533
-      curl_close($ch);
533
+        curl_close($ch);
534 534
 
535
-      return $response;
535
+        return $response;
536 536
     } elseif (function_exists('stream_get_contents')) {
537
-      // Enable error Track Errors
538
-      $track = ini_get('track_errors');
539
-      ini_set('track_errors',true);
537
+        // Enable error Track Errors
538
+        $track = ini_get('track_errors');
539
+        ini_set('track_errors',true);
540 540
 
541
-      $params = array('http' => array(
542
-      'method'  => 'POST',
543
-      'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/" . self::VERSION . "\r\n",
544
-      'content' => $data
545
-      ));
541
+        $params = array('http' => array(
542
+        'method'  => 'POST',
543
+        'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/" . self::VERSION . "\r\n",
544
+        'content' => $data
545
+        ));
546 546
 
547
-      if (isset($this->proxy_host) && isset($this->proxy_port)) {
547
+        if (isset($this->proxy_host) && isset($this->proxy_port)) {
548 548
         $params['http']['proxy'] = 'tcp://'.$this->proxy_host . ':' . $this->proxy_port;
549 549
         $params['http']['request_fulluri'] = True;
550
-      }
550
+        }
551 551
 
552
-      $ctx = stream_context_create($params);
553
-      $fp = @fopen($url, 'rb', false, $ctx);
554
-      if (!$fp) {
552
+        $ctx = stream_context_create($params);
553
+        $fp = @fopen($url, 'rb', false, $ctx);
554
+        if (!$fp) {
555 555
         ini_set('track_errors',$track);
556 556
         throw new Exception("HTTP Error calling Clockwork API - fopen Error: $php_errormsg");
557
-      }
558
-      $response = @stream_get_contents($fp);
559
-      if ($response === false) {
557
+        }
558
+        $response = @stream_get_contents($fp);
559
+        if ($response === false) {
560 560
         ini_set('track_errors',$track);
561 561
         throw new Exception("HTTP Error calling Clockwork API - stream Error: $php_errormsg");
562
-      }
563
-      ini_set('track_errors',$track);
564
-      return $response;
562
+        }
563
+        ini_set('track_errors',$track);
564
+        return $response;
565 565
     } else {
566
-      throw new Exception("Clockwork requires PHP5 with cURL or HTTP stream support");
566
+        throw new Exception("Clockwork requires PHP5 with cURL or HTTP stream support");
567 567
     }
568
-  }
569
-
570
-  /**
571
-  * Does the server/HTTP wrapper support SSL
572
-  *
573
-  * This is a best guess effort, some servers have weird setups where even
574
-  * though cURL is compiled with SSL support is still fails to make
575
-  * any requests.
576
-  *
577
-  * @return bool     True if SSL is supported
578
-  * @author  Martin Steel
579
-  */
580
-  protected function sslSupport() {
568
+    }
569
+
570
+    /**
571
+     * Does the server/HTTP wrapper support SSL
572
+     *
573
+     * This is a best guess effort, some servers have weird setups where even
574
+     * though cURL is compiled with SSL support is still fails to make
575
+     * any requests.
576
+     *
577
+     * @return bool     True if SSL is supported
578
+     * @author  Martin Steel
579
+     */
580
+    protected function sslSupport() {
581 581
     $ssl = false;
582 582
     // See if PHP is compiled with cURL
583 583
     if (extension_loaded('curl')) {
584
-      $version = curl_version();
585
-      $ssl = ($version['features'] & CURL_VERSION_SSL) ? true : false;
584
+        $version = curl_version();
585
+        $ssl = ($version['features'] & CURL_VERSION_SSL) ? true : false;
586 586
     } elseif (extension_loaded('openssl')) {
587
-      $ssl = true;
587
+        $ssl = true;
588 588
     }
589 589
     return $ssl;
590
-  }
591
-
592
-  /**
593
-  * Log some XML, tidily if possible, in the PHP error log
594
-  *
595
-  * @param   string  log_msg The log message to prepend to the XML
596
-  * @param   string  xml     An XML formatted string
597
-  *
598
-  * @return  void
599
-  * @author  Martin Steel
600
-  */
601
-  protected function logXML($log_msg, $xml) {
590
+    }
591
+
592
+    /**
593
+     * Log some XML, tidily if possible, in the PHP error log
594
+     *
595
+     * @param   string  log_msg The log message to prepend to the XML
596
+     * @param   string  xml     An XML formatted string
597
+     *
598
+     * @return  void
599
+     * @author  Martin Steel
600
+     */
601
+    protected function logXML($log_msg, $xml) {
602 602
     // Tidy if possible
603 603
     if (class_exists('tidy')) {
604
-      $tidy = new tidy;
605
-      $config = array(
606
-      'indent'     => true,
607
-      'input-xml'  => true,
608
-      'output-xml' => true,
609
-      'wrap'       => 200
610
-      );
611
-      $tidy->parseString($xml, $config, 'utf8');
612
-      $tidy->cleanRepair();
613
-      $xml = $tidy;
604
+        $tidy = new tidy;
605
+        $config = array(
606
+        'indent'     => true,
607
+        'input-xml'  => true,
608
+        'output-xml' => true,
609
+        'wrap'       => 200
610
+        );
611
+        $tidy->parseString($xml, $config, 'utf8');
612
+        $tidy->cleanRepair();
613
+        $xml = $tidy;
614 614
     }
615 615
     // Output
616 616
     error_log("Clockwork $log_msg: $xml");
617
-  }
618
-
619
-  /**
620
-  * Check if an array is associative
621
-  *
622
-  * @param   array $array Array to check
623
-  * @return  bool
624
-  * @author  Martin Steel
625
-  */
626
-  protected function is_assoc($array) {
617
+    }
618
+
619
+    /**
620
+     * Check if an array is associative
621
+     *
622
+     * @param   array $array Array to check
623
+     * @return  bool
624
+     * @author  Martin Steel
625
+     */
626
+    protected function is_assoc($array) {
627 627
     return (bool)count(array_filter(array_keys($array), 'is_string'));
628
-  }
628
+    }
629 629
   
630
-  /**
631
-   * Check if a number is a valid MSISDN
632
-   *
633
-   * @param string $val Value to check
634
-   * @return bool True if valid MSISDN
635
-   * @author James Inman
636
-   * @since 1.3.0
637
-   * @todo Take an optional country code and check that the number starts with it
638
-   */
639
-  public static function is_valid_msisdn($val) {
630
+    /**
631
+     * Check if a number is a valid MSISDN
632
+     *
633
+     * @param string $val Value to check
634
+     * @return bool True if valid MSISDN
635
+     * @author James Inman
636
+     * @since 1.3.0
637
+     * @todo Take an optional country code and check that the number starts with it
638
+     */
639
+    public static function is_valid_msisdn($val) {
640 640
     return preg_match( '/^[1-9][0-9]{7,12}$/', $val );
641
-  }
641
+    }
642 642
 
643 643
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 * @version     1.3.0
10 10
 */
11 11
 
12
-if ( !class_exists('ClockworkException') ) {
12
+if (!class_exists('ClockworkException')) {
13 13
   require_once('exception.php');
14 14
 }
15 15
 
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
   /*
25 25
   * Version of this class
26 26
   */
27
-  const VERSION           = '1.3.1';
27
+  const VERSION = '1.3.1';
28 28
 
29 29
   /**
30 30
   * All Clockwork API calls start with BASE_URL
31 31
   * @author  Martin Steel
32 32
   */
33
-  const API_BASE_URL      = 'api.clockworksms.com/xml/';
33
+  const API_BASE_URL = 'api.clockworksms.com/xml/';
34 34
 
35 35
   /**
36 36
   * string to append to API_BASE_URL to check authentication
37 37
   * @author  Martin Steel
38 38
   */
39
-  const API_AUTH_METHOD   = 'authenticate';
39
+  const API_AUTH_METHOD = 'authenticate';
40 40
 
41 41
   /**
42 42
   * string to append to API_BASE_URL for sending SMS
43 43
   * @author  Martin Steel
44 44
   */
45
-  const API_SMS_METHOD    = 'sms';
45
+  const API_SMS_METHOD = 'sms';
46 46
 
47 47
   /**
48 48
   * string to append to API_BASE_URL for checking message credit
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
     $err_no = null;
259 259
     $err_desc = null;
260 260
 
261
-    foreach($resp_doc->documentElement->childNodes AS $doc_child) {
262
-      switch(strtolower($doc_child->nodeName)) {
261
+    foreach ($resp_doc->documentElement->childNodes AS $doc_child) {
262
+      switch (strtolower($doc_child->nodeName)) {
263 263
         case 'sms_resp':
264 264
         $resp = array();
265 265
         $wrapper_id = null;
266
-        foreach($doc_child->childNodes AS $resp_node) {
267
-          switch(strtolower($resp_node->nodeName)) {
266
+        foreach ($doc_child->childNodes AS $resp_node) {
267
+          switch (strtolower($resp_node->nodeName)) {
268 268
             case 'messageid':
269 269
             $resp['id'] = $resp_node->nodeValue;
270 270
             break;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             break;
280 280
           }
281 281
         }
282
-        if( array_key_exists('error_code', $resp ) ) 
282
+        if (array_key_exists('error_code', $resp)) 
283 283
         {
284 284
           $resp['success'] = 0;
285 285
         } else {
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
       throw new ClockworkException($err_desc, $err_no);
416 416
     }
417 417
         
418
-    return array( 'symbol' => $symbol, 'balance' => $balance, 'code' => $code );
418
+    return array('symbol' => $symbol, 'balance' => $balance, 'code' => $code);
419 419
   }
420 420
 
421 421
   /**
@@ -480,14 +480,14 @@  discard block
 block discarded – undo
480 480
       $this->logXML("API $method Request XML", $data);
481 481
     }
482 482
     
483
-    if( isset( $this->ssl ) ) {
483
+    if (isset($this->ssl)) {
484 484
       $ssl = $this->ssl;
485 485
     } else {
486 486
       $ssl = $this->sslSupport();
487 487
     }
488 488
 
489 489
     $url = $ssl ? 'https://' : 'http://';
490
-    $url .= self::API_BASE_URL . $method;
490
+    $url .= self::API_BASE_URL.$method;
491 491
 
492 492
     $response = $this->xmlPost($url, $data);
493 493
 
@@ -509,12 +509,12 @@  discard block
 block discarded – undo
509 509
   * @author  Martin Steel
510 510
   */
511 511
   protected function xmlPost($url, $data) {
512
-    if(extension_loaded('curl')) {
512
+    if (extension_loaded('curl')) {
513 513
       $ch = curl_init($url);
514 514
       curl_setopt($ch, CURLOPT_POST, 1);
515 515
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
516 516
       curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
517
-      curl_setopt($ch, CURLOPT_USERAGENT, 'Clockwork PHP Wrapper/1.0' . self::VERSION);
517
+      curl_setopt($ch, CURLOPT_USERAGENT, 'Clockwork PHP Wrapper/1.0'.self::VERSION);
518 518
       curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
519 519
       if (isset($this->proxy_host) && isset($this->proxy_port)) {
520 520
         curl_setopt($ch, CURLOPT_PROXY, $this->proxy_host);
@@ -525,9 +525,9 @@  discard block
 block discarded – undo
525 525
       $info = curl_getinfo($ch);
526 526
 
527 527
       if ($response === false || $info['http_code'] != 200) {
528
-        throw new Exception('HTTP Error calling Clockwork API - HTTP Status: ' . $info['http_code'] . ' - cURL Erorr: ' . curl_error($ch));
528
+        throw new Exception('HTTP Error calling Clockwork API - HTTP Status: '.$info['http_code'].' - cURL Erorr: '.curl_error($ch));
529 529
       } elseif (curl_errno($ch) > 0) {
530
-        throw new Exception('HTTP Error calling Clockwork API - cURL Error: ' . curl_error($ch));
530
+        throw new Exception('HTTP Error calling Clockwork API - cURL Error: '.curl_error($ch));
531 531
       }
532 532
 
533 533
       curl_close($ch);
@@ -536,31 +536,31 @@  discard block
 block discarded – undo
536 536
     } elseif (function_exists('stream_get_contents')) {
537 537
       // Enable error Track Errors
538 538
       $track = ini_get('track_errors');
539
-      ini_set('track_errors',true);
539
+      ini_set('track_errors', true);
540 540
 
541 541
       $params = array('http' => array(
542 542
       'method'  => 'POST',
543
-      'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/" . self::VERSION . "\r\n",
543
+      'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/".self::VERSION."\r\n",
544 544
       'content' => $data
545 545
       ));
546 546
 
547 547
       if (isset($this->proxy_host) && isset($this->proxy_port)) {
548
-        $params['http']['proxy'] = 'tcp://'.$this->proxy_host . ':' . $this->proxy_port;
548
+        $params['http']['proxy'] = 'tcp://'.$this->proxy_host.':'.$this->proxy_port;
549 549
         $params['http']['request_fulluri'] = True;
550 550
       }
551 551
 
552 552
       $ctx = stream_context_create($params);
553 553
       $fp = @fopen($url, 'rb', false, $ctx);
554 554
       if (!$fp) {
555
-        ini_set('track_errors',$track);
555
+        ini_set('track_errors', $track);
556 556
         throw new Exception("HTTP Error calling Clockwork API - fopen Error: $php_errormsg");
557 557
       }
558 558
       $response = @stream_get_contents($fp);
559 559
       if ($response === false) {
560
-        ini_set('track_errors',$track);
560
+        ini_set('track_errors', $track);
561 561
         throw new Exception("HTTP Error calling Clockwork API - stream Error: $php_errormsg");
562 562
       }
563
-      ini_set('track_errors',$track);
563
+      ini_set('track_errors', $track);
564 564
       return $response;
565 565
     } else {
566 566
       throw new Exception("Clockwork requires PHP5 with cURL or HTTP stream support");
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
   * @author  Martin Steel
625 625
   */
626 626
   protected function is_assoc($array) {
627
-    return (bool)count(array_filter(array_keys($array), 'is_string'));
627
+    return (bool) count(array_filter(array_keys($array), 'is_string'));
628 628
   }
629 629
   
630 630
   /**
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
    * @todo Take an optional country code and check that the number starts with it
638 638
    */
639 639
   public static function is_valid_msisdn($val) {
640
-    return preg_match( '/^[1-9][0-9]{7,12}$/', $val );
640
+    return preg_match('/^[1-9][0-9]{7,12}$/', $val);
641 641
   }
642 642
 
643 643
 }
Please login to merge, or discard this patch.
plugin/courselegal/CourseLegalPlugin.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param int $courseId
63 63
      * @param int $sessionId
64 64
      *
65
-     * @return array
65
+     * @return string
66 66
      */
67 67
     public function getUserAcceptedLegal($userId, $courseId, $sessionId)
68 68
     {
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     * @param int $courseCode
113 113
     * @param int $sessionId
114 114
     * @param boolean $sendEmail Optional. Indicate whether the mail must be sent. Default is true
115
-    * @return mixed
115
+    * @return false|string
116 116
     */
117 117
     public function saveUserLegal($userId, $courseCode, $sessionId, $sendEmail = true)
118 118
     {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @param int $courseId
219 219
      * @param int $sessionId
220 220
      *
221
-     * @return bool
221
+     * @return boolean|null
222 222
      */
223 223
     public function saveUserMailLegal($link, $userId, $courseId, $sessionId)
224 224
     {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -108,12 +108,12 @@
 block discarded – undo
108 108
     }
109 109
 
110 110
     /**
111
-    * @param int $userId
112
-    * @param int $courseCode
113
-    * @param int $sessionId
114
-    * @param boolean $sendEmail Optional. Indicate whether the mail must be sent. Default is true
115
-    * @return mixed
116
-    */
111
+     * @param int $userId
112
+     * @param int $courseCode
113
+     * @param int $sessionId
114
+     * @param boolean $sendEmail Optional. Indicate whether the mail must be sent. Default is true
115
+     * @return mixed
116
+     */
117 117
     public function saveUserLegal($userId, $courseCode, $sessionId, $sendEmail = true)
118 118
     {
119 119
         $courseInfo = api_get_course_info($courseCode);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -421,7 +421,7 @@
 block discarded – undo
421 421
                 array('id = ? ' => $id)
422 422
             );
423 423
             if (!empty($legalData['filename'])) {
424
-                $fileToDelete = $coursePath . '/' . $legalData['filename'];
424
+                $fileToDelete = $coursePath.'/'.$legalData['filename'];
425 425
                 if (file_exists($fileToDelete)) {
426 426
                     unlink($fileToDelete);
427 427
                 }
Please login to merge, or discard this patch.
plugin/kannelsms/lib/kannelsms_plugin.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     /**
15 15
      * create (a singleton function that ensures KannelsmsPlugin instance is
16 16
      * created only once. If it is already created, it returns the instance)
17
-     * @return  object  KannelsmsPlugin instance
17
+     * @return  KannelsmsPlugin  KannelsmsPlugin instance
18 18
      */
19 19
     public static function create()
20 20
     {
Please login to merge, or discard this patch.
plugin/kannelsms/vendor/kannelsms_api.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,6 +138,7 @@  discard block
 block discarded – undo
138 138
   *
139 139
   * @param   string  key         Your Kannel API Key
140 140
   * @param   array   options     Optional parameters for sending SMS
141
+  * @param string $key
141 142
   * @author  Martin Steel
142 143
   */
143 144
   public function __construct($key, array $options = array()) {
@@ -471,6 +472,8 @@  discard block
 block discarded – undo
471 472
   *
472 473
   * @param   string   method Kannel method to call (sms/credit)
473 474
   * @param   string   data   Content of HTTP POST
475
+  * @param string $method
476
+  * @param string $data
474 477
   *
475 478
   * @return  string          Response from Kannel
476 479
   * @author  Martin Steel
@@ -505,6 +508,7 @@  discard block
 block discarded – undo
505 508
   *
506 509
   * @param   string url      URL to send to
507 510
   * @param   string data     Data to POST
511
+  * @param string $url
508 512
   * @return  string          Response returned by server
509 513
   * @author  Martin Steel
510 514
   */
@@ -631,7 +635,7 @@  discard block
 block discarded – undo
631 635
    * Check if a number is a valid MSISDN
632 636
    *
633 637
    * @param string $val Value to check
634
-   * @return bool True if valid MSISDN
638
+   * @return integer True if valid MSISDN
635 639
    * @author James Inman
636 640
    * @since 1.3.0
637 641
    * @todo Take an optional country code and check that the number starts with it
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 */
11 11
 
12 12
 if ( !class_exists('KannelException') ) {
13
-  require_once('exception.php');
13
+    require_once('exception.php');
14 14
 }
15 15
 
16 16
 /**
@@ -21,130 +21,130 @@  discard block
 block discarded – undo
21 21
 */
22 22
 class Kannel {
23 23
 
24
-  /*
24
+    /*
25 25
   * Version of this class
26 26
   */
27
-  const VERSION           = '1.3.1';
28
-
29
-  /**
30
-  * All Kannel API calls start with BASE_URL
31
-  * @author  Martin Steel
32
-  */
33
-  const API_BASE_URL      = 'api.kannelsms.com/xml/';
34
-
35
-  /**
36
-  * string to append to API_BASE_URL to check authentication
37
-  * @author  Martin Steel
38
-  */
39
-  const API_AUTH_METHOD   = 'authenticate';
40
-
41
-  /**
42
-  * string to append to API_BASE_URL for sending SMS
43
-  * @author  Martin Steel
44
-  */
45
-  const API_SMS_METHOD    = 'sms';
46
-
47
-  /**
48
-  * string to append to API_BASE_URL for checking message credit
49
-  * @author  Martin Steel
50
-  */
51
-  const API_CREDIT_METHOD = 'credit';
52
-
53
-  /**
54
-  * string to append to API_BASE_URL for checking account balance
55
-  * @author  Martin Steel
56
-  */
57
-  const API_BALANCE_METHOD = 'balance';
58
-
59
-  /** 
60
-  * Kannel API Key
61
-  * 
62
-  * @var string
63
-  * @author  Martin Steel
64
-  */
65
-  public $key;
66
-
67
-  /**
68
-  * Use SSL when making HTTP requests
69
-  *
70
-  * If this is not set, SSL will be used where PHP supports it
71
-  *
72
-  * @var bool
73
-  * @author  Martin Steel
74
-  */
75
-  public $ssl;
76
-
77
-  /**
78
-  * Proxy server hostname (Optional)
79
-  *
80
-  * @var string
81
-  * @author  Martin Steel
82
-  */
83
-  public $proxy_host;
84
-
85
-  /**
86
-  * Proxy server port (Optional)
87
-  *
88
-  * @var integer
89
-  * @author  Martin Steel
90
-  */
91
-  public $proxy_port;
92
-
93
-  /**
94
-  * From address used on text messages
95
-  *
96
-  * @var string (11 characters or 12 numbers)
97
-  * @author  Martin Steel
98
-  */
99
-  public $from;
100
-
101
-  /**
102
-  * Allow long SMS messages (Cost up to 3 credits)
103
-  *
104
-  * @var bool
105
-  * @author  Martin Steel
106
-  */
107
-  public $long;
108
-
109
-  /**
110
-  * Truncate message text if it is too long
111
-  *
112
-  * @var bool
113
-  * @author  Martin Steel
114
-  */
115
-  public $truncate;
116
-
117
-  /**
118
-  * Enables various logging of messages when true.
119
-  *
120
-  * @var bool
121
-  * @author  Martin Steel
122
-  */
123
-  public $log;
124
-
125
-  /**
126
-  * What Kannel should do if you send an invalid character
127
-  *
128
-  * Possible values:
129
-  *      'error'     - Return an error (Messasge is not sent)
130
-  *      'remove'    - Remove the invalid character(s)
131
-  *      'replace'   - Replace invalid characters where possible, remove others 
132
-  * @author  Martin Steel
133
-  */
134
-  public $invalid_char_action;
135
-
136
-  /**
137
-  * Create a new instance of the Kannel wrapper
138
-  *
139
-  * @param   string  key         Your Kannel API Key
140
-  * @param   array   options     Optional parameters for sending SMS
141
-  * @author  Martin Steel
142
-  */
143
-  public function __construct($key, array $options = array()) {
27
+    const VERSION           = '1.3.1';
28
+
29
+    /**
30
+     * All Kannel API calls start with BASE_URL
31
+     * @author  Martin Steel
32
+     */
33
+    const API_BASE_URL      = 'api.kannelsms.com/xml/';
34
+
35
+    /**
36
+     * string to append to API_BASE_URL to check authentication
37
+     * @author  Martin Steel
38
+     */
39
+    const API_AUTH_METHOD   = 'authenticate';
40
+
41
+    /**
42
+     * string to append to API_BASE_URL for sending SMS
43
+     * @author  Martin Steel
44
+     */
45
+    const API_SMS_METHOD    = 'sms';
46
+
47
+    /**
48
+     * string to append to API_BASE_URL for checking message credit
49
+     * @author  Martin Steel
50
+     */
51
+    const API_CREDIT_METHOD = 'credit';
52
+
53
+    /**
54
+     * string to append to API_BASE_URL for checking account balance
55
+     * @author  Martin Steel
56
+     */
57
+    const API_BALANCE_METHOD = 'balance';
58
+
59
+    /** 
60
+     * Kannel API Key
61
+     * 
62
+     * @var string
63
+     * @author  Martin Steel
64
+     */
65
+    public $key;
66
+
67
+    /**
68
+     * Use SSL when making HTTP requests
69
+     *
70
+     * If this is not set, SSL will be used where PHP supports it
71
+     *
72
+     * @var bool
73
+     * @author  Martin Steel
74
+     */
75
+    public $ssl;
76
+
77
+    /**
78
+     * Proxy server hostname (Optional)
79
+     *
80
+     * @var string
81
+     * @author  Martin Steel
82
+     */
83
+    public $proxy_host;
84
+
85
+    /**
86
+     * Proxy server port (Optional)
87
+     *
88
+     * @var integer
89
+     * @author  Martin Steel
90
+     */
91
+    public $proxy_port;
92
+
93
+    /**
94
+     * From address used on text messages
95
+     *
96
+     * @var string (11 characters or 12 numbers)
97
+     * @author  Martin Steel
98
+     */
99
+    public $from;
100
+
101
+    /**
102
+     * Allow long SMS messages (Cost up to 3 credits)
103
+     *
104
+     * @var bool
105
+     * @author  Martin Steel
106
+     */
107
+    public $long;
108
+
109
+    /**
110
+     * Truncate message text if it is too long
111
+     *
112
+     * @var bool
113
+     * @author  Martin Steel
114
+     */
115
+    public $truncate;
116
+
117
+    /**
118
+     * Enables various logging of messages when true.
119
+     *
120
+     * @var bool
121
+     * @author  Martin Steel
122
+     */
123
+    public $log;
124
+
125
+    /**
126
+     * What Kannel should do if you send an invalid character
127
+     *
128
+     * Possible values:
129
+     *      'error'     - Return an error (Messasge is not sent)
130
+     *      'remove'    - Remove the invalid character(s)
131
+     *      'replace'   - Replace invalid characters where possible, remove others 
132
+     * @author  Martin Steel
133
+     */
134
+    public $invalid_char_action;
135
+
136
+    /**
137
+     * Create a new instance of the Kannel wrapper
138
+     *
139
+     * @param   string  key         Your Kannel API Key
140
+     * @param   array   options     Optional parameters for sending SMS
141
+     * @author  Martin Steel
142
+     */
143
+    public function __construct($key, array $options = array()) {
144 144
     if (empty($key)) {
145
-      throw new KannelException("Key can't be blank");
145
+        throw new KannelException("Key can't be blank");
146 146
     } else {
147
-      $this->key = $key;
147
+        $this->key = $key;
148 148
     }
149 149
         
150 150
     $this->ssl                  = (array_key_exists('ssl', $options)) ? $options['ssl'] : null;
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
     $this->truncate             = (array_key_exists('truncate', $options)) ? $options['truncate'] : null;
156 156
     $this->invalid_char_action  = (array_key_exists('invalid_char_action', $options)) ? $options['invalid_char_action'] : null;
157 157
     $this->log                  = (array_key_exists('log', $options)) ? $options['log'] : false;
158
-  }
158
+    }
159 159
 
160
-  /**
161
-  * Send some text messages
162
-  * 
163
-  *
164
-  * @author  Martin Steel
165
-  */
166
-  public function send(array $sms) {
160
+    /**
161
+     * Send some text messages
162
+     * 
163
+     *
164
+     * @author  Martin Steel
165
+     */
166
+    public function send(array $sms) {
167 167
     if (!is_array($sms)) {
168
-      throw new KannelException("sms parameter must be an array");
168
+        throw new KannelException("sms parameter must be an array");
169 169
     }
170 170
     $single_message = $this->is_assoc($sms);
171 171
 
172 172
     if ($single_message) {
173
-      $sms = array($sms);
173
+        $sms = array($sms);
174 174
     }
175 175
 
176 176
     $req_doc = new \DOMDocument('1.0', 'UTF-8');
@@ -182,70 +182,70 @@  discard block
 block discarded – undo
182 182
     $root->appendChild($user_node);
183 183
 
184 184
     for ($i = 0; $i < count($sms); $i++) {
185
-      $single = $sms[$i];
185
+        $single = $sms[$i];
186 186
 
187
-      $sms_node = $req_doc->createElement('SMS');
187
+        $sms_node = $req_doc->createElement('SMS');
188 188
            
189
-      // Phone number
190
-      $sms_node->appendChild($req_doc->createElement('To', $single['to'])); 
189
+        // Phone number
190
+        $sms_node->appendChild($req_doc->createElement('To', $single['to'])); 
191 191
             
192
-      // Message text
193
-      $content_node = $req_doc->createElement('Content');
194
-      $content_node->appendChild($req_doc->createTextNode($single['message']));
195
-      $sms_node->appendChild($content_node);
192
+        // Message text
193
+        $content_node = $req_doc->createElement('Content');
194
+        $content_node->appendChild($req_doc->createTextNode($single['message']));
195
+        $sms_node->appendChild($content_node);
196 196
 
197
-      // From
198
-      if (array_key_exists('from', $single) || isset($this->from)) {
197
+        // From
198
+        if (array_key_exists('from', $single) || isset($this->from)) {
199 199
         $from_node = $req_doc->createElement('From');
200 200
         $from_node->appendChild($req_doc->createTextNode(array_key_exists('from', $single) ? $single['from'] : $this->from));
201 201
         $sms_node->appendChild($from_node);
202
-      }
202
+        }
203 203
 
204
-      // Client ID
205
-      if (array_key_exists('client_id', $single)) {
204
+        // Client ID
205
+        if (array_key_exists('client_id', $single)) {
206 206
         $client_id_node = $req_doc->createElement('ClientID');
207 207
         $client_id_node->appendChild($req_doc->createTextNode($single['client_id']));
208 208
         $sms_node->appendChild($client_id_node);
209
-      }
209
+        }
210 210
 
211
-      // Long
212
-      if (array_key_exists('long', $single) || isset($this->long)) {
211
+        // Long
212
+        if (array_key_exists('long', $single) || isset($this->long)) {
213 213
         $long = array_key_exists('long', $single) ? $single['long'] : $this->long;
214 214
         $long_node = $req_doc->createElement('Long');
215 215
         $long_node->appendChild($req_doc->createTextNode($long ? 1 : 0));
216 216
         $sms_node->appendChild($long_node);
217
-      }
217
+        }
218 218
 
219
-      // Truncate
220
-      if (array_key_exists('truncate', $single) || isset($this->truncate)) {
219
+        // Truncate
220
+        if (array_key_exists('truncate', $single) || isset($this->truncate)) {
221 221
         $truncate = array_key_exists('truncate', $single) ? $single['truncate'] : $this->truncate;
222 222
         $trunc_node = $req_doc->createElement('Truncate');
223 223
         $trunc_node->appendChild($req_doc->createTextNode($truncate ? 1 : 0));
224 224
         $sms_node->appendChild($trunc_node);
225
-      }
225
+        }
226 226
 
227
-      // Invalid Char Action
228
-      if (array_key_exists('invalid_char_action', $single) || isset($this->invalid_char_action)) {
227
+        // Invalid Char Action
228
+        if (array_key_exists('invalid_char_action', $single) || isset($this->invalid_char_action)) {
229 229
         $action = array_key_exists('invalid_char_action', $single) ? $single['invalid_char_action'] : $this->invalid_char_action;
230 230
         switch (strtolower($action)) {
231
-          case 'error':
231
+            case 'error':
232 232
           $sms_node->appendChild($req_doc->createElement('InvalidCharAction', 1));
233
-          break;
234
-          case 'remove':
233
+            break;
234
+            case 'remove':
235 235
           $sms_node->appendChild($req_doc->createElement('InvalidCharAction', 2));
236
-          break;
237
-          case 'replace':
236
+            break;
237
+            case 'replace':
238 238
           $sms_node->appendChild($req_doc->createElement('InvalidCharAction', 3));
239
+            break;
240
+            default:
239 241
           break;
240
-          default:
241
-          break;
242 242
         }
243
-      }
243
+        }
244 244
 
245
-      // Wrapper ID
246
-      $sms_node->appendChild($req_doc->createElement('WrapperID', $i));
245
+        // Wrapper ID
246
+        $sms_node->appendChild($req_doc->createElement('WrapperID', $i));
247 247
 
248
-      $root->appendChild($sms_node);
248
+        $root->appendChild($sms_node);
249 249
     }
250 250
 
251 251
     $req_xml = $req_doc->saveXML();
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
     $err_desc = null;
260 260
 
261 261
     foreach($resp_doc->documentElement->childNodes AS $doc_child) {
262
-      switch(strtolower($doc_child->nodeName)) {
262
+        switch(strtolower($doc_child->nodeName)) {
263 263
         case 'sms_resp':
264 264
         $resp = array();
265 265
         $wrapper_id = null;
266 266
         foreach($doc_child->childNodes AS $resp_node) {
267
-          switch(strtolower($resp_node->nodeName)) {
267
+            switch(strtolower($resp_node->nodeName)) {
268 268
             case 'messageid':
269 269
             $resp['id'] = $resp_node->nodeValue;
270 270
             break;
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
             case 'wrapperid':
278 278
             $wrapper_id = $resp_node->nodeValue;
279 279
             break;
280
-          }
280
+            }
281 281
         }
282 282
         if( array_key_exists('error_code', $resp ) ) 
283 283
         {
284
-          $resp['success'] = 0;
284
+            $resp['success'] = 0;
285 285
         } else {
286
-          $resp['success'] = 1;
286
+            $resp['success'] = 1;
287 287
         }
288 288
         $resp['sms'] = $sms[$wrapper_id];
289 289
         array_push($response, $resp);
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
         case 'errdesc':
295 295
         $err_desc = $doc_child->nodeValue;
296 296
         break;
297
-      }
297
+        }
298 298
     }
299 299
 
300 300
     if (isset($err_no)) {
301
-      throw new KannelException($err_desc, $err_no);
301
+        throw new KannelException($err_desc, $err_no);
302 302
     }
303 303
         
304 304
     if ($single_message) {
305
-      return $response[0];
305
+        return $response[0];
306 306
     } else {
307
-      return $response;
307
+        return $response;
308 308
     }
309
-  }
310
-
311
-  /**
312
-  * Check how many SMS credits you have available
313
-  *
314
-  * @return  integer   SMS credits remaining
315
-  * @deprecated Use checkBalance() instead
316
-  * @author  Martin Steel
317
-  */
318
-  public function checkCredit() {
309
+    }
310
+
311
+    /**
312
+     * Check how many SMS credits you have available
313
+     *
314
+     * @return  integer   SMS credits remaining
315
+     * @deprecated Use checkBalance() instead
316
+     * @author  Martin Steel
317
+     */
318
+    public function checkCredit() {
319 319
     // Create XML doc for request
320 320
     $req_doc = new \DOMDocument('1.0', 'UTF-8');
321 321
     $root = $req_doc->createElement('Credit');
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
     $err_desc = null;
337 337
         
338 338
     foreach ($resp_doc->documentElement->childNodes AS $doc_child) {
339
-      switch ($doc_child->nodeName) {
339
+        switch ($doc_child->nodeName) {
340 340
         case "Credit":
341 341
         $credit = $doc_child->nodeValue;
342 342
         break;
@@ -348,22 +348,22 @@  discard block
 block discarded – undo
348 348
         break;
349 349
         default:
350 350
         break;
351
-      }
351
+        }
352 352
     }
353 353
 
354 354
     if (isset($err_no)) {
355
-      throw new KannelException($err_desc, $err_no);
355
+        throw new KannelException($err_desc, $err_no);
356 356
     }
357 357
     return $credit;
358
-  }
358
+    }
359 359
 
360
-  /**
361
-  * Check your account balance
362
-  *
363
-  * @return  array   Array of account balance: 
364
-  * @author  Martin Steel
365
-  */
366
-  public function checkBalance() {
360
+    /**
361
+     * Check your account balance
362
+     *
363
+     * @return  array   Array of account balance: 
364
+     * @author  Martin Steel
365
+     */
366
+    public function checkBalance() {
367 367
     // Create XML doc for request
368 368
     $req_doc = new \DOMDocument('1.0', 'UTF-8');
369 369
     $root = $req_doc->createElement('Balance');
@@ -384,20 +384,20 @@  discard block
 block discarded – undo
384 384
     $err_desc = null;
385 385
         
386 386
     foreach ($resp_doc->documentElement->childNodes as $doc_child) {
387
-      switch ($doc_child->nodeName) {
387
+        switch ($doc_child->nodeName) {
388 388
         case "Balance":
389 389
         $balance = number_format(floatval($doc_child->nodeValue), 2);
390 390
         break;
391 391
         case "Currency":
392 392
         foreach ($doc_child->childNodes as $resp_node) {
393
-          switch ($resp_node->tagName) {
393
+            switch ($resp_node->tagName) {
394 394
             case "Symbol":
395 395
             $symbol = $resp_node->nodeValue; 
396 396
             break;
397 397
             case "Code":
398 398
             $code = $resp_node->nodeValue; 
399 399
             break;
400
-          }
400
+            }
401 401
         }
402 402
         break;
403 403
         case "ErrNo":
@@ -408,23 +408,23 @@  discard block
 block discarded – undo
408 408
         break;
409 409
         default:
410 410
         break;
411
-      }
411
+        }
412 412
     }
413 413
 
414 414
     if (isset($err_no)) {
415
-      throw new KannelException($err_desc, $err_no);
415
+        throw new KannelException($err_desc, $err_no);
416 416
     }
417 417
         
418 418
     return array( 'symbol' => $symbol, 'balance' => $balance, 'code' => $code );
419
-  }
419
+    }
420 420
 
421
-  /**
422
-  * Check whether the API Key is valid
423
-  *
424
-  * @return  bool    True indicates a valid key
425
-  * @author  Martin Steel
426
-  */
427
-  public function checkKey() {
421
+    /**
422
+     * Check whether the API Key is valid
423
+     *
424
+     * @return  bool    True indicates a valid key
425
+     * @author  Martin Steel
426
+     */
427
+    public function checkKey() {
428 428
     // Create XML doc for request
429 429
     $req_doc = new \DOMDocument('1.0', 'UTF-8');
430 430
     $root = $req_doc->createElement('Authenticate');
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     $err_desc = null;
446 446
 
447 447
     foreach ($resp_doc->documentElement->childNodes AS $doc_child) {
448
-      switch ($doc_child->nodeName) {
448
+        switch ($doc_child->nodeName) {
449 449
         case "CustID":
450 450
         $cust_id = $doc_child->nodeValue;
451 451
         break;
@@ -457,33 +457,33 @@  discard block
 block discarded – undo
457 457
         break;
458 458
         default:
459 459
         break;
460
-      }
460
+        }
461 461
     }
462 462
 
463 463
     if (isset($err_no)) {
464
-      throw new KannelException($err_desc, $err_no);
464
+        throw new KannelException($err_desc, $err_no);
465 465
     }
466 466
     return isset($cust_id);   
467
-  }
468
-
469
-  /**
470
-  * Make an HTTP POST to Kannel
471
-  *
472
-  * @param   string   method Kannel method to call (sms/credit)
473
-  * @param   string   data   Content of HTTP POST
474
-  *
475
-  * @return  string          Response from Kannel
476
-  * @author  Martin Steel
477
-  */
478
-  protected function postToKannel($method, $data) {
467
+    }
468
+
469
+    /**
470
+     * Make an HTTP POST to Kannel
471
+     *
472
+     * @param   string   method Kannel method to call (sms/credit)
473
+     * @param   string   data   Content of HTTP POST
474
+     *
475
+     * @return  string          Response from Kannel
476
+     * @author  Martin Steel
477
+     */
478
+    protected function postToKannel($method, $data) {
479 479
     if ($this->log) {
480
-      $this->logXML("API $method Request XML", $data);
480
+        $this->logXML("API $method Request XML", $data);
481 481
     }
482 482
     
483 483
     if( isset( $this->ssl ) ) {
484
-      $ssl = $this->ssl;
484
+        $ssl = $this->ssl;
485 485
     } else {
486
-      $ssl = $this->sslSupport();
486
+        $ssl = $this->sslSupport();
487 487
     }
488 488
 
489 489
     $url = $ssl ? 'https://' : 'http://';
@@ -492,152 +492,152 @@  discard block
 block discarded – undo
492 492
     $response = $this->xmlPost($url, $data);
493 493
 
494 494
     if ($this->log) {
495
-      $this->logXML("API $method Response XML", $response);
495
+        $this->logXML("API $method Response XML", $response);
496 496
     }
497 497
 
498 498
     return $response;
499
-  }
500
-
501
-  /**
502
-  * Make a HTTP POST
503
-  *
504
-  * cURL will be used if available, otherwise tries the PHP stream functions
505
-  *
506
-  * @param   string url      URL to send to
507
-  * @param   string data     Data to POST
508
-  * @return  string          Response returned by server
509
-  * @author  Martin Steel
510
-  */
511
-  protected function xmlPost($url, $data) {
499
+    }
500
+
501
+    /**
502
+     * Make a HTTP POST
503
+     *
504
+     * cURL will be used if available, otherwise tries the PHP stream functions
505
+     *
506
+     * @param   string url      URL to send to
507
+     * @param   string data     Data to POST
508
+     * @return  string          Response returned by server
509
+     * @author  Martin Steel
510
+     */
511
+    protected function xmlPost($url, $data) {
512 512
     if(extension_loaded('curl')) {
513
-      $ch = curl_init($url);
514
-      curl_setopt($ch, CURLOPT_POST, 1);
515
-      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
516
-      curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
517
-      curl_setopt($ch, CURLOPT_USERAGENT, 'Kannel PHP Wrapper/1.0' . self::VERSION);
518
-      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
519
-      if (isset($this->proxy_host) && isset($this->proxy_port)) {
513
+        $ch = curl_init($url);
514
+        curl_setopt($ch, CURLOPT_POST, 1);
515
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
516
+        curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
517
+        curl_setopt($ch, CURLOPT_USERAGENT, 'Kannel PHP Wrapper/1.0' . self::VERSION);
518
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
519
+        if (isset($this->proxy_host) && isset($this->proxy_port)) {
520 520
         curl_setopt($ch, CURLOPT_PROXY, $this->proxy_host);
521 521
         curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy_port);
522
-      }
522
+        }
523 523
 
524
-      $response = curl_exec($ch);
525
-      $info = curl_getinfo($ch);
524
+        $response = curl_exec($ch);
525
+        $info = curl_getinfo($ch);
526 526
 
527
-      if ($response === false || $info['http_code'] != 200) {
527
+        if ($response === false || $info['http_code'] != 200) {
528 528
         throw new \Exception('HTTP Error calling Kannel API - HTTP Status: ' . $info['http_code'] . ' - cURL Erorr: ' . curl_error($ch));
529
-      } elseif (curl_errno($ch) > 0) {
529
+        } elseif (curl_errno($ch) > 0) {
530 530
         throw new \Exception('HTTP Error calling Kannel API - cURL Error: ' . curl_error($ch));
531
-      }
531
+        }
532 532
 
533
-      curl_close($ch);
533
+        curl_close($ch);
534 534
 
535
-      return $response;
535
+        return $response;
536 536
     } elseif (function_exists('stream_get_contents')) {
537
-      // Enable error Track Errors
538
-      $track = ini_get('track_errors');
539
-      ini_set('track_errors',true);
537
+        // Enable error Track Errors
538
+        $track = ini_get('track_errors');
539
+        ini_set('track_errors',true);
540 540
 
541
-      $params = array('http' => array(
542
-      'method'  => 'POST',
543
-      'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/" . self::VERSION . "\r\n",
544
-      'content' => $data
545
-      ));
541
+        $params = array('http' => array(
542
+        'method'  => 'POST',
543
+        'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/" . self::VERSION . "\r\n",
544
+        'content' => $data
545
+        ));
546 546
 
547
-      if (isset($this->proxy_host) && isset($this->proxy_port)) {
547
+        if (isset($this->proxy_host) && isset($this->proxy_port)) {
548 548
         $params['http']['proxy'] = 'tcp://'.$this->proxy_host . ':' . $this->proxy_port;
549 549
         $params['http']['request_fulluri'] = True;
550
-      }
550
+        }
551 551
 
552
-      $ctx = stream_context_create($params);
553
-      $fp = @fopen($url, 'rb', false, $ctx);
554
-      if (!$fp) {
552
+        $ctx = stream_context_create($params);
553
+        $fp = @fopen($url, 'rb', false, $ctx);
554
+        if (!$fp) {
555 555
         ini_set('track_errors',$track);
556 556
         throw new \Exception("HTTP Error calling Kannel API - fopen Error: $php_errormsg");
557
-      }
558
-      $response = @stream_get_contents($fp);
559
-      if ($response === false) {
557
+        }
558
+        $response = @stream_get_contents($fp);
559
+        if ($response === false) {
560 560
         ini_set('track_errors',$track);
561 561
         throw new \Exception("HTTP Error calling Kannel API - stream Error: $php_errormsg");
562
-      }
563
-      ini_set('track_errors',$track);
564
-      return $response;
562
+        }
563
+        ini_set('track_errors',$track);
564
+        return $response;
565 565
     } else {
566
-      throw new \Exception("Kannel requires PHP5 with cURL or HTTP stream support");
566
+        throw new \Exception("Kannel requires PHP5 with cURL or HTTP stream support");
567 567
     }
568
-  }
569
-
570
-  /**
571
-  * Does the server/HTTP wrapper support SSL
572
-  *
573
-  * This is a best guess effort, some servers have weird setups where even
574
-  * though cURL is compiled with SSL support is still fails to make
575
-  * any requests.
576
-  *
577
-  * @return bool     True if SSL is supported
578
-  * @author  Martin Steel
579
-  */
580
-  protected function sslSupport() {
568
+    }
569
+
570
+    /**
571
+     * Does the server/HTTP wrapper support SSL
572
+     *
573
+     * This is a best guess effort, some servers have weird setups where even
574
+     * though cURL is compiled with SSL support is still fails to make
575
+     * any requests.
576
+     *
577
+     * @return bool     True if SSL is supported
578
+     * @author  Martin Steel
579
+     */
580
+    protected function sslSupport() {
581 581
     $ssl = false;
582 582
     // See if PHP is compiled with cURL
583 583
     if (extension_loaded('curl')) {
584
-      $version = curl_version();
585
-      $ssl = ($version['features'] & CURL_VERSION_SSL) ? true : false;
584
+        $version = curl_version();
585
+        $ssl = ($version['features'] & CURL_VERSION_SSL) ? true : false;
586 586
     } elseif (extension_loaded('openssl')) {
587
-      $ssl = true;
587
+        $ssl = true;
588 588
     }
589 589
     return $ssl;
590
-  }
591
-
592
-  /**
593
-  * Log some XML, tidily if possible, in the PHP error log
594
-  *
595
-  * @param   string  log_msg The log message to prepend to the XML
596
-  * @param   string  xml     An XML formatted string
597
-  *
598
-  * @return  void
599
-  * @author  Martin Steel
600
-  */
601
-  protected function logXML($log_msg, $xml) {
590
+    }
591
+
592
+    /**
593
+     * Log some XML, tidily if possible, in the PHP error log
594
+     *
595
+     * @param   string  log_msg The log message to prepend to the XML
596
+     * @param   string  xml     An XML formatted string
597
+     *
598
+     * @return  void
599
+     * @author  Martin Steel
600
+     */
601
+    protected function logXML($log_msg, $xml) {
602 602
     // Tidy if possible
603 603
     if (class_exists('tidy')) {
604
-      $tidy = new \tidy;
605
-      $config = array(
606
-      'indent'     => true,
607
-      'input-xml'  => true,
608
-      'output-xml' => true,
609
-      'wrap'       => 200
610
-      );
611
-      $tidy->parseString($xml, $config, 'utf8');
612
-      $tidy->cleanRepair();
613
-      $xml = $tidy;
604
+        $tidy = new \tidy;
605
+        $config = array(
606
+        'indent'     => true,
607
+        'input-xml'  => true,
608
+        'output-xml' => true,
609
+        'wrap'       => 200
610
+        );
611
+        $tidy->parseString($xml, $config, 'utf8');
612
+        $tidy->cleanRepair();
613
+        $xml = $tidy;
614 614
     }
615 615
     // Output
616 616
     error_log("Kannel $log_msg: $xml");
617
-  }
618
-
619
-  /**
620
-  * Check if an array is associative
621
-  *
622
-  * @param   array $array Array to check
623
-  * @return  bool
624
-  * @author  Martin Steel
625
-  */
626
-  protected function is_assoc($array) {
617
+    }
618
+
619
+    /**
620
+     * Check if an array is associative
621
+     *
622
+     * @param   array $array Array to check
623
+     * @return  bool
624
+     * @author  Martin Steel
625
+     */
626
+    protected function is_assoc($array) {
627 627
     return (bool)count(array_filter(array_keys($array), 'is_string'));
628
-  }
628
+    }
629 629
   
630
-  /**
631
-   * Check if a number is a valid MSISDN
632
-   *
633
-   * @param string $val Value to check
634
-   * @return bool True if valid MSISDN
635
-   * @author James Inman
636
-   * @since 1.3.0
637
-   * @todo Take an optional country code and check that the number starts with it
638
-   */
639
-  public static function is_valid_msisdn($val) {
630
+    /**
631
+     * Check if a number is a valid MSISDN
632
+     *
633
+     * @param string $val Value to check
634
+     * @return bool True if valid MSISDN
635
+     * @author James Inman
636
+     * @since 1.3.0
637
+     * @todo Take an optional country code and check that the number starts with it
638
+     */
639
+    public static function is_valid_msisdn($val) {
640 640
     return preg_match( '/^[1-9][0-9]{7,12}$/', $val );
641
-  }
641
+    }
642 642
 
643 643
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 * @version     1.3.0
10 10
 */
11 11
 
12
-if ( !class_exists('KannelException') ) {
12
+if (!class_exists('KannelException')) {
13 13
   require_once('exception.php');
14 14
 }
15 15
 
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
   /*
25 25
   * Version of this class
26 26
   */
27
-  const VERSION           = '1.3.1';
27
+  const VERSION = '1.3.1';
28 28
 
29 29
   /**
30 30
   * All Kannel API calls start with BASE_URL
31 31
   * @author  Martin Steel
32 32
   */
33
-  const API_BASE_URL      = 'api.kannelsms.com/xml/';
33
+  const API_BASE_URL = 'api.kannelsms.com/xml/';
34 34
 
35 35
   /**
36 36
   * string to append to API_BASE_URL to check authentication
37 37
   * @author  Martin Steel
38 38
   */
39
-  const API_AUTH_METHOD   = 'authenticate';
39
+  const API_AUTH_METHOD = 'authenticate';
40 40
 
41 41
   /**
42 42
   * string to append to API_BASE_URL for sending SMS
43 43
   * @author  Martin Steel
44 44
   */
45
-  const API_SMS_METHOD    = 'sms';
45
+  const API_SMS_METHOD = 'sms';
46 46
 
47 47
   /**
48 48
   * string to append to API_BASE_URL for checking message credit
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
     $err_no = null;
259 259
     $err_desc = null;
260 260
 
261
-    foreach($resp_doc->documentElement->childNodes AS $doc_child) {
262
-      switch(strtolower($doc_child->nodeName)) {
261
+    foreach ($resp_doc->documentElement->childNodes AS $doc_child) {
262
+      switch (strtolower($doc_child->nodeName)) {
263 263
         case 'sms_resp':
264 264
         $resp = array();
265 265
         $wrapper_id = null;
266
-        foreach($doc_child->childNodes AS $resp_node) {
267
-          switch(strtolower($resp_node->nodeName)) {
266
+        foreach ($doc_child->childNodes AS $resp_node) {
267
+          switch (strtolower($resp_node->nodeName)) {
268 268
             case 'messageid':
269 269
             $resp['id'] = $resp_node->nodeValue;
270 270
             break;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             break;
280 280
           }
281 281
         }
282
-        if( array_key_exists('error_code', $resp ) ) 
282
+        if (array_key_exists('error_code', $resp)) 
283 283
         {
284 284
           $resp['success'] = 0;
285 285
         } else {
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
       throw new KannelException($err_desc, $err_no);
416 416
     }
417 417
         
418
-    return array( 'symbol' => $symbol, 'balance' => $balance, 'code' => $code );
418
+    return array('symbol' => $symbol, 'balance' => $balance, 'code' => $code);
419 419
   }
420 420
 
421 421
   /**
@@ -480,14 +480,14 @@  discard block
 block discarded – undo
480 480
       $this->logXML("API $method Request XML", $data);
481 481
     }
482 482
     
483
-    if( isset( $this->ssl ) ) {
483
+    if (isset($this->ssl)) {
484 484
       $ssl = $this->ssl;
485 485
     } else {
486 486
       $ssl = $this->sslSupport();
487 487
     }
488 488
 
489 489
     $url = $ssl ? 'https://' : 'http://';
490
-    $url .= self::API_BASE_URL . $method;
490
+    $url .= self::API_BASE_URL.$method;
491 491
 
492 492
     $response = $this->xmlPost($url, $data);
493 493
 
@@ -509,12 +509,12 @@  discard block
 block discarded – undo
509 509
   * @author  Martin Steel
510 510
   */
511 511
   protected function xmlPost($url, $data) {
512
-    if(extension_loaded('curl')) {
512
+    if (extension_loaded('curl')) {
513 513
       $ch = curl_init($url);
514 514
       curl_setopt($ch, CURLOPT_POST, 1);
515 515
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
516 516
       curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
517
-      curl_setopt($ch, CURLOPT_USERAGENT, 'Kannel PHP Wrapper/1.0' . self::VERSION);
517
+      curl_setopt($ch, CURLOPT_USERAGENT, 'Kannel PHP Wrapper/1.0'.self::VERSION);
518 518
       curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
519 519
       if (isset($this->proxy_host) && isset($this->proxy_port)) {
520 520
         curl_setopt($ch, CURLOPT_PROXY, $this->proxy_host);
@@ -525,9 +525,9 @@  discard block
 block discarded – undo
525 525
       $info = curl_getinfo($ch);
526 526
 
527 527
       if ($response === false || $info['http_code'] != 200) {
528
-        throw new \Exception('HTTP Error calling Kannel API - HTTP Status: ' . $info['http_code'] . ' - cURL Erorr: ' . curl_error($ch));
528
+        throw new \Exception('HTTP Error calling Kannel API - HTTP Status: '.$info['http_code'].' - cURL Erorr: '.curl_error($ch));
529 529
       } elseif (curl_errno($ch) > 0) {
530
-        throw new \Exception('HTTP Error calling Kannel API - cURL Error: ' . curl_error($ch));
530
+        throw new \Exception('HTTP Error calling Kannel API - cURL Error: '.curl_error($ch));
531 531
       }
532 532
 
533 533
       curl_close($ch);
@@ -536,31 +536,31 @@  discard block
 block discarded – undo
536 536
     } elseif (function_exists('stream_get_contents')) {
537 537
       // Enable error Track Errors
538 538
       $track = ini_get('track_errors');
539
-      ini_set('track_errors',true);
539
+      ini_set('track_errors', true);
540 540
 
541 541
       $params = array('http' => array(
542 542
       'method'  => 'POST',
543
-      'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/" . self::VERSION . "\r\n",
543
+      'header'  => "Content-Type: text/xml\r\nUser-Agent: mediaburst PHP Wrapper/".self::VERSION."\r\n",
544 544
       'content' => $data
545 545
       ));
546 546
 
547 547
       if (isset($this->proxy_host) && isset($this->proxy_port)) {
548
-        $params['http']['proxy'] = 'tcp://'.$this->proxy_host . ':' . $this->proxy_port;
548
+        $params['http']['proxy'] = 'tcp://'.$this->proxy_host.':'.$this->proxy_port;
549 549
         $params['http']['request_fulluri'] = True;
550 550
       }
551 551
 
552 552
       $ctx = stream_context_create($params);
553 553
       $fp = @fopen($url, 'rb', false, $ctx);
554 554
       if (!$fp) {
555
-        ini_set('track_errors',$track);
555
+        ini_set('track_errors', $track);
556 556
         throw new \Exception("HTTP Error calling Kannel API - fopen Error: $php_errormsg");
557 557
       }
558 558
       $response = @stream_get_contents($fp);
559 559
       if ($response === false) {
560
-        ini_set('track_errors',$track);
560
+        ini_set('track_errors', $track);
561 561
         throw new \Exception("HTTP Error calling Kannel API - stream Error: $php_errormsg");
562 562
       }
563
-      ini_set('track_errors',$track);
563
+      ini_set('track_errors', $track);
564 564
       return $response;
565 565
     } else {
566 566
       throw new \Exception("Kannel requires PHP5 with cURL or HTTP stream support");
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
   * @author  Martin Steel
625 625
   */
626 626
   protected function is_assoc($array) {
627
-    return (bool)count(array_filter(array_keys($array), 'is_string'));
627
+    return (bool) count(array_filter(array_keys($array), 'is_string'));
628 628
   }
629 629
   
630 630
   /**
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
    * @todo Take an optional country code and check that the number starts with it
638 638
    */
639 639
   public static function is_valid_msisdn($val) {
640
-    return preg_match( '/^[1-9][0-9]{7,12}$/', $val );
640
+    return preg_match('/^[1-9][0-9]{7,12}$/', $val);
641 641
   }
642 642
 
643 643
 }
Please login to merge, or discard this patch.
plugin/openmeetings/lib/openmeetings.class.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,8 @@
 block discarded – undo
213 213
     /**
214 214
      * Returns a meeting "join" URL
215 215
      * @param string The name of the meeting (usually the course code)
216
-     * @return mixed The URL to join the meeting, or false on error
216
+     * @param false|string $meetingId
217
+     * @return false|null The URL to join the meeting, or false on error
217 218
      * @todo implement moderator pass
218 219
      * @assert ('') === false
219 220
      * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
         $om_user   = $plugin->get('user');
50 50
         $om_pass   = $plugin->get('pass');
51 51
         $accessUrl = api_get_access_url($_configuration['access_url']);
52
-        $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://')+3, -1);
52
+        $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1);
53 53
         if (strcmp($this->externalType, 'localhost') == 0) {
54
-            $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://')+3, -1);
54
+            $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1);
55 55
         }
56 56
         $this->externalType = 'chamilolms.'.$this->externalType;
57 57
         $this->table = \Database::get_main_table('plugin_openmeetings');
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             // This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId
162 162
             $room = new Room();
163 163
             $room->loadRoomId($meetingData['room_id']);
164
-            $roomArray = (array)$room;
164
+            $roomArray = (array) $room;
165 165
             $roomArray['SID'] = $this->sessionId;
166 166
             $roomId = $this->gateway->updateRoomWithModeration($room);
167 167
             if ($roomId != $meetingData['room_id']) {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             $room->SID = $this->sessionId;
177 177
             $room->name = $this->roomName;
178 178
             //$room->roomtypes_id = $room->roomtypes_id;
179
-            $room->comment = urlencode(get_lang('Course').': ' . $params['meeting_name'] . ' - '.$_configuration['software_name']);
179
+            $room->comment = urlencode(get_lang('Course').': '.$params['meeting_name'].' - '.$_configuration['software_name']);
180 180
             //$room->numberOfPartizipants = $room->numberOfPartizipants;
181 181
             $room->ispublic = $room->getString('isPublic', 'false');
182 182
             //$room->appointment = $room->getString('appointment');
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             $params['room_id'] = $roomId;
201 201
             $params['c_id'] = api_get_course_int_id();
202 202
             $params['session_id'] = api_get_session_id();
203
-            $params['record'] = ($room->allowRecording?1:0);
203
+            $params['record'] = ($room->allowRecording ? 1 : 0);
204 204
 
205 205
             $id = \Database::insert($this->table, $params);
206 206
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         }
239 239
         $params = array('room_id' => $meetingData['room_id']);
240 240
         $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag($params);
241
-        $iframe = $this->url . "/?" ."secureHash=" . $returnVal;
241
+        $iframe = $this->url."/?"."secureHash=".$returnVal;
242 242
         printf("<iframe src='%s' width='%s' height = '%s' />", $iframe, "100%", 640);
243 243
     }
244 244
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         $userId = $_SESSION['_user']['user_id'];
347 347
         $systemType = 'Chamilo';
348 348
         $room_id = $params['room_id'];
349
-        $becomeModerator = ( $this->isTeacher() ? 1 : 0 );
349
+        $becomeModerator = ($this->isTeacher() ? 1 : 0);
350 350
         $allowRecording = 1; //Provisional
351 351
 
352 352
         $urlWsdl = $this->url."/services/UserService?wsdl";
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
                 error_log(__FILE__.'+'.__LINE__.' Meetings found: '.print_r($meetingDb, 1));
421 421
                 $remoteMeeting = array();
422 422
                 $meetingDb['created_at'] = api_get_local_time($meetingDb['created_at']);
423
-                $meetingDb['closed_at'] = (!empty($meetingDb['closed_at']) ? api_get_local_time($meetingDb['closed_at']):'');
423
+                $meetingDb['closed_at'] = (!empty($meetingDb['closed_at']) ? api_get_local_time($meetingDb['closed_at']) : '');
424 424
                 // Fixed value for now
425 425
                 $meetingDb['participantCount'] = 40;
426 426
                 $rec = $this->gateway->getFlvRecordingByRoomId($meetingDb['room_id']);
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
                         \Display::url('[.avi]', $link2, array('target' => '_blank'));
437 437
 
438 438
                 }
439
-                $item['show_links']  = implode('<br />', $links);
439
+                $item['show_links'] = implode('<br />', $links);
440 440
 
441 441
                 // The following code is currently commented because the web service
442 442
                 // says this is not allowed by the SOAP user.
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
                 $remoteMeeting = $current_room;
487 487
                 */
488 488
 
489
-                if (empty( $remoteMeeting )) {
489
+                if (empty($remoteMeeting)) {
490 490
                 /*
491 491
                     error_log(__FILE__.'+'.__LINE__.' Empty remote Meeting for now');
492 492
                     if ($meetingDb['status'] == 1 && $this->isTeacher()) {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             return false;
127 127
         }
128 128
     }
129
-    */
129
+     */
130 130
 
131 131
     /*
132 132
      * Creating a Room for the meeting
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
         return true;
257 257
     }
258 258
 
259
-     /**
260
-     * Gets the password for a specific meeting for the current user
261
-     * @return string A moderator password if user is teacher, or the course code otherwise
262
-     */
259
+        /**
260
+         * Gets the password for a specific meeting for the current user
261
+         * @return string A moderator password if user is teacher, or the course code otherwise
262
+         */
263 263
     public function getMeetingUserPassword()
264 264
     {
265 265
         if ($this->isTeacher()) {
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     //
539 539
     //            }
540 540
     //
541
-                 //$item['created_at'] = api_convert_and_format_date($meetingDb['created_at']);
541
+                    //$item['created_at'] = api_convert_and_format_date($meetingDb['created_at']);
542 542
     //            //created_at
543 543
     //
544 544
     //            $item['publish_url'] = api_get_self().'?action=publish&id='.$meetingDb['id'];
Please login to merge, or discard this patch.
plugin/openmeetings/lib/openmeetings_gateway.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -36,6 +36,11 @@
 block discarded – undo
36 36
     private $_pass;
37 37
     private $_url;
38 38
 
39
+    /**
40
+     * @param string $host
41
+     * @param string $user
42
+     * @param string $pass
43
+     */
39 44
     public function __construct($host, $user, $pass)
40 45
     {
41 46
         $this->_user = urlencode($user);
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
         $this->rest = new OpenMeetingsRestService();
48 48
         $err = $this->rest->getError();
49 49
         if ($err) {
50
-            error_log('Constructor error: ' . $err);
51
-            error_log('Debug: ' . $this->rest->getDebug());;
50
+            error_log('Constructor error: '.$err);
51
+            error_log('Debug: '.$this->rest->getDebug()); ;
52 52
             exit();
53 53
         }
54 54
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function getRestUrl($name)
61 61
     {
62
-        return $this->getUrl() . "/services/" . $name . "/";
62
+        return $this->getUrl()."/services/".$name."/";
63 63
     }
64 64
 
65 65
     /**
@@ -89,30 +89,30 @@  discard block
 block discarded – undo
89 89
     public function loginUser()
90 90
     {
91 91
         $returnValue = 0;
92
-        $response = $this->rest->call($this->getRestUrl("UserService") . "getSession", "session_id");
92
+        $response = $this->rest->call($this->getRestUrl("UserService")."getSession", "session_id");
93 93
 
94 94
         if ($this->rest->getError()) {
95 95
             error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($response, 1));
96 96
         } else {
97 97
             $err = $this->rest->getError();
98 98
             if ($err) {
99
-                error_log('Error: ' . $err);
99
+                error_log('Error: '.$err);
100 100
             } else {
101 101
                 //error_log('getSession returned '.$response. ' - Storing as sessionId');
102 102
                 $this->sessionId = $response;
103 103
 
104 104
                 $url = $this->getRestUrl("UserService")
105 105
                         . "loginUser?"
106
-                        . "SID=" . $this->sessionId
107
-                        . "&username=" . $this->_user
108
-                        . "&userpass=" . $this->_pass;
106
+                        . "SID=".$this->sessionId
107
+                        . "&username=".$this->_user
108
+                        . "&userpass=".$this->_pass;
109 109
                 $result = $this->rest->call($url);
110 110
                 if ($this->rest->getError()) {
111 111
                     error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result, 1));
112 112
                 } else {
113 113
                     $err = $this->rest->getError();
114 114
                     if ($err) {
115
-                        error_log('Error '. $err);
115
+                        error_log('Error '.$err);
116 116
                     } else {
117 117
                         $returnValue = $result;
118 118
                     }
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $err = $this->rest->getError();
137 137
         if ($err) {
138
-            error_log('Constructor error: ' . $err);
139
-            error_log('Debug: ' . $this->rest->getDebug());
138
+            error_log('Constructor error: '.$err);
139
+            error_log('Debug: '.$this->rest->getDebug());
140 140
             exit();
141 141
         }
142 142
 
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
         }
147 147
 
148 148
         $url = $this->getRestUrl($this->getRestUrl("RoomService")
149
-                . "updateRoomWithModeration?SID=" . $this->sessionId
150
-                . "&room_id=" . $room->room_id
151
-                . "&name=" . urlencode($room->name)
152
-                . "&roomtypes_id=" . $room->roomtypes_id
153
-                . "&comment=" . $room->comment
154
-                . "&numberOfPartizipants=" . $room->numberOfPartizipants
149
+                . "updateRoomWithModeration?SID=".$this->sessionId
150
+                . "&room_id=".$room->room_id
151
+                . "&name=".urlencode($room->name)
152
+                . "&roomtypes_id=".$room->roomtypes_id
153
+                . "&comment=".$room->comment
154
+                . "&numberOfPartizipants=".$room->numberOfPartizipants
155 155
                 . "&ispublic=false"
156 156
                 . "&appointment=false"
157 157
                 . "&isDemoRoom=false"
158 158
                 . "&demoTime=0"
159
-                . "&isModeratedRoom=" . $this->var_to_str($isModeratedRoom));
159
+                . "&isModeratedRoom=".$this->var_to_str($isModeratedRoom));
160 160
         //error_log($url);
161 161
         $result = $this->rest->call($url);
162 162
 
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
         } else {
166 166
             $err = $this->rest->getError();
167 167
             if ($err) {
168
-                error_log('Error: ' . $err);
168
+                error_log('Error: '.$err);
169 169
             } else {
170 170
                 // echo '<h2>Result</h2><pre>'; print_r($result["return"]); echo '</pre>';
171 171
                 //error_log('Room updated successfully '.print_r($result,1));
172 172
                 return $result;
173 173
             }
174 174
         }
175
-        return - 1;
175
+        return -1;
176 176
     }
177 177
 
178 178
     /**
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
     {
189 189
         $result = $this->rest->call($this->getRestUrl("UserService")
190 190
                 . 'setUserObjectAndGenerateRecordingHashByURL?'
191
-                . 'SID=' . $this->sessionId
192
-                . '&username=' . urlencode($username)
193
-                . '&firstname=' . urlencode($firstname)
194
-                . '&lastname=' . urlencode($lastname)
195
-                . '&externalUserId=' . $userId
196
-                . '&externalUserType=' . urlencode($systemType)
197
-                . '&recording_id=' . $recording_id, 'return');
191
+                . 'SID='.$this->sessionId
192
+                . '&username='.urlencode($username)
193
+                . '&firstname='.urlencode($firstname)
194
+                . '&lastname='.urlencode($lastname)
195
+                . '&externalUserId='.$userId
196
+                . '&externalUserType='.urlencode($systemType)
197
+                . '&recording_id='.$recording_id, 'return');
198 198
 
199 199
         if ($result->fault) {
200 200
             error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result, 1));
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 return $result;
207 207
             }
208 208
         }
209
-        return - 1;
209
+        return -1;
210 210
     }
211 211
 
212 212
     /**
@@ -226,28 +226,28 @@  discard block
 block discarded – undo
226 226
     {
227 227
         $err = $this->rest->getError();
228 228
         if ($err) {
229
-            error_log('Constructor error: ' . $err);
230
-            error_log('Debug: ' . $this->rest->getDebug());;
229
+            error_log('Constructor error: '.$err);
230
+            error_log('Debug: '.$this->rest->getDebug()); ;
231 231
             exit();
232 232
         }
233 233
 
234 234
         $result = $this->rest->call($this->getRestUrl("UserService")
235 235
                 . "setUserObjectAndGenerateRoomHashByURLAndRecFlag?"
236
-                . "SID=" . $this->sessionId
237
-                . "&username=" . urlencode($username)
238
-                . "&firstname=" . urlencode($firstname)
239
-                . "&lastname=" . urlencode($lastname)
240
-                . "&profilePictureUrl=" . urlencode($profilePictureUrl)
241
-                . "&email=" . urlencode($email)
242
-                . "&externalUserId=" . urlencode($userId)
243
-                . "&externalUserType=" . urlencode($systemType)
244
-                . "&room_id=" . urlencode($room_id)
245
-                . "&becomeModeratorAsInt=" . $becomeModerator
236
+                . "SID=".$this->sessionId
237
+                . "&username=".urlencode($username)
238
+                . "&firstname=".urlencode($firstname)
239
+                . "&lastname=".urlencode($lastname)
240
+                . "&profilePictureUrl=".urlencode($profilePictureUrl)
241
+                . "&email=".urlencode($email)
242
+                . "&externalUserId=".urlencode($userId)
243
+                . "&externalUserType=".urlencode($systemType)
244
+                . "&room_id=".urlencode($room_id)
245
+                . "&becomeModeratorAsInt=".$becomeModerator
246 246
                 . "&showAudioVideoTestAsInt=1"
247
-                . "&allowRecording=" . $this->var_to_str($allowRecording));
247
+                . "&allowRecording=".$this->var_to_str($allowRecording));
248 248
 
249 249
         if ($result->fault) {
250
-            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
250
+            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result, 1));
251 251
         } else {
252 252
             $err = $this->rest->getError();
253 253
             if ($err) {
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 return $result;
258 258
             }
259 259
         }
260
-        return - 1;
260
+        return -1;
261 261
     }
262 262
 
263 263
     /**
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
     {
269 269
         $err = $this->rest->getError();
270 270
         if ($err) {
271
-            error_log('Constructor error: ' . $err);
272
-            error_log('Debug: ' . $this->rest->getDebug());
271
+            error_log('Constructor error: '.$err);
272
+            error_log('Debug: '.$this->rest->getDebug());
273 273
             exit();
274 274
         }
275 275
         $url = $this->getRestUrl("RoomService")."deleteRoom?SID=".$this->sessionId."&rooms_id=".$openmeetings->room_id;
276 276
         $result = $this->rest->call($url);
277 277
 
278 278
         if ($result->fault) {
279
-            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
279
+            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result, 1));
280 280
         } else {
281 281
             $err = $this->rest->getError();
282 282
             if ($err) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                 return $result;
288 288
             }
289 289
         }
290
-        return - 1;
290
+        return -1;
291 291
     }
292 292
 
293 293
     /**
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
     {
298 298
         $result = $this->rest->call($this->getRestUrl("UserService")
299 299
                 . "setUserObjectAndGenerateRoomHash?"
300
-                . "SID=" . $this->sessionId
301
-                . "&username=" . urlencode($username)
302
-                . "&firstname=" . urlencode($firstname)
303
-                . "&lastname=" . urlencode($lastname)
304
-                . "&profilePictureUrl=" . urlencode($profilePictureUrl)
305
-                . "&email=" . urlencode($email)
306
-                . "&externalUserId=" . urlencode($externalUserId)
307
-                . "&externalUserType=" . urlencode($externalUserType)
308
-                . "&room_id=" . $room_id
309
-                . "&becomeModeratorAsInt=" . $becomeModeratorAsInt
310
-                . "&showAudioVideoTestAsInt=" . $showAudioVideoTestAsInt);
300
+                . "SID=".$this->sessionId
301
+                . "&username=".urlencode($username)
302
+                . "&firstname=".urlencode($firstname)
303
+                . "&lastname=".urlencode($lastname)
304
+                . "&profilePictureUrl=".urlencode($profilePictureUrl)
305
+                . "&email=".urlencode($email)
306
+                . "&externalUserId=".urlencode($externalUserId)
307
+                . "&externalUserType=".urlencode($externalUserType)
308
+                . "&room_id=".$room_id
309
+                . "&becomeModeratorAsInt=".$becomeModeratorAsInt
310
+                . "&showAudioVideoTestAsInt=".$showAudioVideoTestAsInt);
311 311
 
312 312
         if ($result->getError()) {
313
-            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
313
+            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result, 1));
314 314
         } else {
315 315
             $err = $this->rest->getError();
316 316
             if ($err) {
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                 return $result;
321 321
             }
322 322
         }
323
-        return - 1;
323
+        return -1;
324 324
     }
325 325
 
326 326
     /**
@@ -338,29 +338,29 @@  discard block
 block discarded – undo
338 338
         }
339 339
         $url = $this->getRestUrl("RoomService")
340 340
                 . $service.'?'
341
-                . 'SID=' . $room->SID
342
-                . '&name=' . $room->name
343
-                . '&roomtypes_id=' . $room->roomtypes_id
344
-                . '&comment='. $room->comment
345
-                . '&numberOfPartizipants=' . $room->numberOfPartizipants
346
-                . '&ispublic=' . $this->var_to_str($room->ispublic)
347
-                . '&appointment=' . $this->var_to_str($room->appointment)
348
-                . '&isDemoRoom=' . $this->var_to_str($room->isDemoRoom)
349
-                . '&demoTime=' . $room->demoTime
350
-                . '&isModeratedRoom=' . $this->var_to_str($room->isModeratedRoom)
351
-                . '&externalRoomType=' . $room->externalRoomType;
341
+                . 'SID='.$room->SID
342
+                . '&name='.$room->name
343
+                . '&roomtypes_id='.$room->roomtypes_id
344
+                . '&comment='.$room->comment
345
+                . '&numberOfPartizipants='.$room->numberOfPartizipants
346
+                . '&ispublic='.$this->var_to_str($room->ispublic)
347
+                . '&appointment='.$this->var_to_str($room->appointment)
348
+                . '&isDemoRoom='.$this->var_to_str($room->isDemoRoom)
349
+                . '&demoTime='.$room->demoTime
350
+                . '&isModeratedRoom='.$this->var_to_str($room->isModeratedRoom)
351
+                . '&externalRoomType='.$room->externalRoomType;
352 352
         if ($room->allowRecording) {
353
-            $url .= '&allowUserQuestions=' . $this->var_to_str($room->allowUserQuestions)
354
-                 . '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly)
355
-                 . '&waitForRecording=' . $this->var_to_str($room->waitForRecording)
356
-                 . '&allowRecording=' . $this->var_to_str($room->allowRecording);
353
+            $url .= '&allowUserQuestions='.$this->var_to_str($room->allowUserQuestions)
354
+                 . '&isAudioOnly='.$this->var_to_str($room->isAudioOnly)
355
+                 . '&waitForRecording='.$this->var_to_str($room->waitForRecording)
356
+                 . '&allowRecording='.$this->var_to_str($room->allowRecording);
357 357
         } elseif ($room->isAudioOnly) {
358
-            $url .= '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly);
358
+            $url .= '&isAudioOnly='.$this->var_to_str($room->isAudioOnly);
359 359
         }
360 360
         $result = $this->rest->call($url);
361 361
 
362 362
         if ($this->rest->fault) {
363
-            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result,1));
363
+            error_log('Fault (Expect - The request contains an invalid SOAP body) '.print_r($result, 1));
364 364
         } else {
365 365
             $err = $this->rest->getError();
366 366
             if ($err) {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
             return false;
386 386
         }
387 387
 
388
-        $url = $this->getRestUrl("RoomService") . "getRoomsWithCurrentUsersByListAndType?SID=" . $this->sessionId
388
+        $url = $this->getRestUrl("RoomService")."getRoomsWithCurrentUsersByListAndType?SID=".$this->sessionId
389 389
             . "&start=1&max=1000&orderby=name&asc=true&externalRoomType=chamilolms";
390 390
         //$url = $this->getRestUrl("RoomService")
391 391
         //    . "getRoomTypes?"
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
         $rooms = array();
397 397
         foreach ($result as $room) {
398 398
             //error_log(__FILE__.'+'.__LINE__.': one room found on remote: '.print_r($room,1));
399
-            if ($room['externalRoomType'] == $type && count($room['currentusers']) > 0 ) {
399
+            if ($room['externalRoomType'] == $type && count($room['currentusers']) > 0) {
400 400
                 $rooms[] = $room;
401 401
             }
402 402
         }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 
419 419
         $url = $this->getRestUrl("RoomService")
420 420
             . "getRoomById?"
421
-            . "SID=" . $this->sessionId
421
+            . "SID=".$this->sessionId
422 422
             . "&rooms_id=".$roomId;
423 423
         //error_log(__FILE__.'+'.__LINE__.' Calling WS: '.$url);
424 424
         $result = $this->rest->call($url, "return");
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
     {
433 433
         $url = $this->getRestUrl("RoomService")
434 434
             . "getFlvRecordingByExternalRoomType?"
435
-            . "SID=" . $this->sessionId
436
-            . "&externalRoomType=" . urlencode($this->config["moduleKey"]);
435
+            . "SID=".$this->sessionId
436
+            . "&externalRoomType=".urlencode($this->config["moduleKey"]);
437 437
 
438 438
         $result = $this->rest->call($url, "return");
439 439
 
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
     {
450 450
         $url = $this->getRestUrl("RoomService")
451 451
             . "getFlvRecordingByRoomId?"
452
-            . "SID=" . $this->sessionId
453
-            . "&roomId=" . urlencode($id);
452
+            . "SID=".$this->sessionId
453
+            . "&roomId=".urlencode($id);
454 454
 
455 455
         $result = $this->rest->call($url, "return");
456 456
 
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
     {
465 465
         $url = $this->getRestUrl("RoomService")
466 466
             . "getFlvRecordingByExternalUserId?"
467
-            . "SID=" . $this->sessionId
468
-            . "&externalUserId=" . $id;
467
+            . "SID=".$this->sessionId
468
+            . "&externalUserId=".$id;
469 469
 
470 470
         $result = $this->rest->call($url, "return");
471 471
 
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -351,9 +351,9 @@
 block discarded – undo
351 351
                 . '&externalRoomType=' . $room->externalRoomType;
352 352
         if ($room->allowRecording) {
353 353
             $url .= '&allowUserQuestions=' . $this->var_to_str($room->allowUserQuestions)
354
-                 . '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly)
355
-                 . '&waitForRecording=' . $this->var_to_str($room->waitForRecording)
356
-                 . '&allowRecording=' . $this->var_to_str($room->allowRecording);
354
+                    . '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly)
355
+                    . '&waitForRecording=' . $this->var_to_str($room->waitForRecording)
356
+                    . '&allowRecording=' . $this->var_to_str($room->allowRecording);
357 357
         } elseif ($room->isAudioOnly) {
358 358
             $url .= '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly);
359 359
         }
Please login to merge, or discard this patch.
plugin/openmeetings/lib/openmeetings_rest_service.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -27,6 +27,9 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class OpenMeetingsRestService
29 29
 {
30
+    /**
31
+     * @param string $request
32
+     */
30 33
     function call($request, $returnAttribute = "return")
31 34
     {
32 35
         // This will allow you to view errors in the browser
@@ -121,6 +124,9 @@  discard block
 block discarded – undo
121 124
             
122 125
     }
123 126
 
127
+    /**
128
+     * @param DOMDocument $node
129
+     */
124 130
     function getArray($node)
125 131
     {
126 132
         if (is_null($node) || !is_object($node)) {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
         // $request
41 41
         
42 42
         // Initialize the session by passing the request as a parameter
43
-        $session = curl_init ( $request );
43
+        $session = curl_init($request);
44 44
         
45 45
         // Set curl options by passing session and flags
46 46
         // CURLOPT_HEADER allows us to receive the HTTP header
47
-        curl_setopt ( $session, CURLOPT_HEADER, true );
47
+        curl_setopt($session, CURLOPT_HEADER, true);
48 48
         
49 49
         // CURLOPT_RETURNTRANSFER will return the response
50
-        curl_setopt ( $session, CURLOPT_RETURNTRANSFER, true );
50
+        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
51 51
         
52 52
         // Make the request
53
-        $response = curl_exec ( $session );
53
+        $response = curl_exec($session);
54 54
         
55 55
         // Close the curl session
56
-        curl_close ( $session );
56
+        curl_close($session);
57 57
         
58 58
         // Confirm that the request was transmitted to the OpenMeetings! Image Search Service
59
-        if (! $response) {
60
-            die ( "Request OpenMeetings! OpenMeetings Service failed and no response was returned in ".__CLASS__.'::'.__FUNCTION__.'()' );
59
+        if (!$response) {
60
+            die ("Request OpenMeetings! OpenMeetings Service failed and no response was returned in ".__CLASS__.'::'.__FUNCTION__.'()');
61 61
         }
62 62
         
63 63
         // Create an array to store the HTTP response codes
64
-        $status_code = array ();
64
+        $status_code = array();
65 65
         
66 66
         // Use regular expressions to extract the code from the header
67
-        preg_match ( '/\d\d\d/', $response, $status_code );
67
+        preg_match('/\d\d\d/', $response, $status_code);
68 68
         $bt = debug_backtrace();
69 69
         $caller = array_shift($bt);
70 70
         $extra = ' (from '.$caller['file'].' at line '.$caller['line'].') ';
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
                 // Success
75 75
                 break;
76 76
             case 503 :
77
-                error_log( 'Your call to OpenMeetings Web Services '.$extra.' failed and returned an HTTP status of 503.
77
+                error_log('Your call to OpenMeetings Web Services '.$extra.' failed and returned an HTTP status of 503.
78 78
                                  That means: Service unavailable. An internal problem prevented us from returning data to you.' );
79 79
                 return false;
80 80
                 break;
81 81
             case 403 :
82
-                error_log( 'Your call to OpenMeetings Web Services '.$extra.' failed and returned an HTTP status of 403.
82
+                error_log('Your call to OpenMeetings Web Services '.$extra.' failed and returned an HTTP status of 403.
83 83
                                  That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.' );
84 84
                 return false;
85 85
                 break;
86 86
             case 400 :
87 87
                 // You may want to fall through here and read the specific XML error
88
-                error_log( 'Your call to OpenMeetings Web Services '.$extra.' failed and returned an HTTP status of 400.
88
+                error_log('Your call to OpenMeetings Web Services '.$extra.' failed and returned an HTTP status of 400.
89 89
                                  That means:  Bad request. The parameters passed to the service did not match as expected.   
90 90
                                  The exact error is returned in the XML response.' );
91 91
                 return false;
92 92
                 break;
93 93
             default :
94
-                error_log( 'Your call to OpenMeetings Web Services '.$extra.' returned an unexpected HTTP status of: ' . $status_code [0] . " Request " . $request );
94
+                error_log('Your call to OpenMeetings Web Services '.$extra.' returned an unexpected HTTP status of: '.$status_code [0]." Request ".$request);
95 95
                 return false;
96 96
         }
97 97
         
Please login to merge, or discard this patch.