Completed
Push — 1.10.x ( f2aaaf...ef00db )
by Yannick
241:15 queued 197:35
created
main/auth/openid/openid.lib.php 3 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -121,6 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 /**
123 123
  * Encode a message from _openid_create_message for HTTP Post
124
+ * @param null|string $message
124 125
  */
125 126
 function _openid_encode_message($message) {
126 127
     $encoded_message = '';
@@ -173,6 +174,7 @@  discard block
 block discarded – undo
173 174
 
174 175
 /**
175 176
  * Pull the href attribute out of an html link element.
177
+ * @param string $rel
176 178
  */
177 179
 function _openid_link_href($rel, $html) {
178 180
     $rel = preg_quote($rel);
@@ -186,6 +188,7 @@  discard block
 block discarded – undo
186 188
 
187 189
 /**
188 190
  * Pull the http-equiv attribute out of an html meta element
191
+ * @param string $equiv
189 192
  */
190 193
 function _openid_meta_httpequiv($equiv, $html) {
191 194
     preg_match('|<meta\s+http-equiv=["\']' . $equiv . '["\'](.*)/?>|iU', $html, $matches);
@@ -221,6 +224,10 @@  discard block
 block discarded – undo
221 224
     return base64_encode($signature);
222 225
 }
223 226
 
227
+/**
228
+ * @param string $key
229
+ * @param null|string $text
230
+ */
224 231
 function _openid_hmac($key, $text) {
225 232
     if (strlen($key) > OPENID_SHA1_BLOCKSIZE) {
226 233
         $key = _openid_sha1($key, true);
@@ -256,6 +263,9 @@  discard block
 block discarded – undo
256 263
     return base64_encode(_openid_dh_long_to_binary($str));
257 264
 }
258 265
 
266
+/**
267
+ * @param string $str
268
+ */
259 269
 function _openid_dh_binary_to_long($str) {
260 270
     $bytes = array_merge(unpack('C*', $str));
261 271
 
@@ -297,6 +307,9 @@  discard block
 block discarded – undo
297 307
     return $string;
298 308
 }
299 309
 
310
+/**
311
+ * @param string $secret
312
+ */
300 313
 function _openid_dh_xorsecret($shared, $secret) {
301 314
     $dh_shared_str = _openid_dh_long_to_binary($shared);
302 315
     $sha1_dh_shared = _openid_sha1($dh_shared_str);
@@ -308,6 +321,9 @@  discard block
 block discarded – undo
308 321
     return $xsecret;
309 322
 }
310 323
 
324
+/**
325
+ * @param string $stop
326
+ */
311 327
 function _openid_dh_rand($stop) {
312 328
     static $duplicate_cache = array();
313 329
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  * Code
10 10
  */
11 11
 // Diffie-Hellman Key Exchange Default Value.
12
-define('OPENID_DH_DEFAULT_MOD', '155172898181473697471232257763715539915724801' .
13
-        '966915404479707795314057629378541917580651227423698188993727816152646631' .
14
-        '438561595825688188889951272158842675419950341258706556549803580104870537' .
15
-        '681476726513255747040765857479291291572334510643245094715007229621094194' .
12
+define('OPENID_DH_DEFAULT_MOD', '155172898181473697471232257763715539915724801'.
13
+        '966915404479707795314057629378541917580651227423698188993727816152646631'.
14
+        '438561595825688188889951272158842675419950341258706556549803580104870537'.
15
+        '681476726513255747040765857479291291572334510643245094715007229621094194'.
16 16
         '349783925984760375594985848253359305585439638443');
17 17
 
18 18
 // Constants for Diffie-Hellman key exchange computations.
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 function openid_redirect_http($url, $message) {
33 33
     $query = array();
34 34
     foreach ($message as $key => $val) {
35
-        $query[] = $key . '=' . urlencode($val);
35
+        $query[] = $key.'='.urlencode($val);
36 36
     }
37 37
     $sep = (strpos($url, '?') === FALSE) ? '?' : '&';
38
-    header('Location: ' . $url . $sep . implode('&', $query), TRUE, 302);
38
+    header('Location: '.$url.$sep.implode('&', $query), TRUE, 302);
39 39
     //exit;
40 40
 }
41 41
 
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
  * This function should be deprecated for 1.8.6.2 needs documentation
45 45
  */
46 46
 function openid_redirect($url, $message) {
47
-    $output = '<html><head><title>' . get_lang('OpenIDRedirect') . "</title></head>\n<body>";
48
-    $output .= '<form method="post" action="' . $url . '" id="openid-redirect-form">';
47
+    $output = '<html><head><title>'.get_lang('OpenIDRedirect')."</title></head>\n<body>";
48
+    $output .= '<form method="post" action="'.$url.'" id="openid-redirect-form">';
49 49
     foreach ($message as $key => $value) {
50
-        $output .='<input type="hidden" name="' . $key . '" value="' . $value . '">';
50
+        $output .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
51 51
     }
52
-    $output .= '<noscript><input type="submit" name="submit" value="' . get_lang('Send') . '"/></noscript>';
52
+    $output .= '<noscript><input type="submit" name="submit" value="'.get_lang('Send').'"/></noscript>';
53 53
     $output .= '</form>';
54 54
     $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>';
55 55
     $output .= "</body></html>";
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     $normalized_url = $url;
95 95
 
96 96
     if (stristr($url, '://') === FALSE) {
97
-        $normalized_url = 'http://' . $url;
97
+        $normalized_url = 'http://'.$url;
98 98
     }
99 99
 
100 100
     if (substr_count($normalized_url, '/') < 3) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             if ($encoded_message != '') {
134 134
                 $encoded_message .= '&';
135 135
             }
136
-            $encoded_message .= rawurlencode(trim($parts[0])) . '=' . rawurlencode(trim($parts[1]));
136
+            $encoded_message .= rawurlencode(trim($parts[0])).'='.rawurlencode(trim($parts[1]));
137 137
         }
138 138
     }
139 139
 
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  */
165 165
 function _openid_nonce() {
166 166
     // YYYY-MM-DDThh:mm:ssTZD UTC, plus some optional extra unique chars
167
-    return gmstrftime('%Y-%m-%dT%H:%M:%S%Z') .
168
-            chr(mt_rand(0, 25) + 65) .
169
-            chr(mt_rand(0, 25) + 65) .
170
-            chr(mt_rand(0, 25) + 65) .
167
+    return gmstrftime('%Y-%m-%dT%H:%M:%S%Z').
168
+            chr(mt_rand(0, 25) + 65).
169
+            chr(mt_rand(0, 25) + 65).
170
+            chr(mt_rand(0, 25) + 65).
171 171
             chr(mt_rand(0, 25) + 65);
172 172
 }
173 173
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function _openid_link_href($rel, $html) {
178 178
     $rel = preg_quote($rel);
179
-    preg_match('|<link\s+rel=["\'](.*)' . $rel . '(.*)["\'](.*)/?>|iU', $html, $matches);
179
+    preg_match('|<link\s+rel=["\'](.*)'.$rel.'(.*)["\'](.*)/?>|iU', $html, $matches);
180 180
     if (isset($matches[3])) {
181 181
         preg_match('|href=["\']([^"]+)["\']|iU', $matches[0], $href);
182 182
         return trim($href[1]);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
  * Pull the http-equiv attribute out of an html meta element
189 189
  */
190 190
 function _openid_meta_httpequiv($equiv, $html) {
191
-    preg_match('|<meta\s+http-equiv=["\']' . $equiv . '["\'](.*)/?>|iU', $html, $matches);
191
+    preg_match('|<meta\s+http-equiv=["\']'.$equiv.'["\'](.*)/?>|iU', $html, $matches);
192 192
     if (isset($matches[1])) {
193 193
         preg_match('|content=["\']([^"]+)["\']|iU', $matches[1], $content);
194 194
         return $content[1];
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
     $sign_data = array();
210 210
 
211 211
     foreach ($keys_to_sign as $key) {
212
-        if (isset($message_array['openid.' . $key])) {
213
-            $sign_data[$key] = $message_array['openid.' . $key];
212
+        if (isset($message_array['openid.'.$key])) {
213
+            $sign_data[$key] = $message_array['openid.'.$key];
214 214
         }
215 215
     }
216 216
 
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
     $key = str_pad($key, OPENID_SHA1_BLOCKSIZE, chr(0x00));
230 230
     $ipad = str_repeat(chr(0x36), OPENID_SHA1_BLOCKSIZE);
231 231
     $opad = str_repeat(chr(0x5c), OPENID_SHA1_BLOCKSIZE);
232
-    $hash1 = _openid_sha1(($key ^ $ipad) . $text, true);
233
-    $hmac = _openid_sha1(($key ^ $opad) . $hash1, true);
232
+    $hash1 = _openid_sha1(($key ^ $ipad).$text, true);
233
+    $hmac = _openid_sha1(($key ^ $opad).$hash1, true);
234 234
 
235 235
     return $hmac;
236 236
 }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     }
338 338
 
339 339
     do {
340
-        $bytes = "\x00" . _openid_get_bytes($nbytes);
340
+        $bytes = "\x00"._openid_get_bytes($nbytes);
341 341
         $n = _openid_dh_binary_to_long($bytes);
342 342
         // Keep looping if this value is in the low duplicated range.
343 343
     } while (bccomp($n, $duplicate) < 0);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@
 block discarded – undo
61 61
  */
62 62
 function _openid_is_xri($identifier) {
63 63
     $firstchar = substr($identifier, 0, 1);
64
-    if ($firstchar == "@" || $firstchar == "=")
65
-        return TRUE;
64
+    if ($firstchar == "@" || $firstchar == "=") {
65
+            return TRUE;
66
+    }
66 67
 
67 68
     if (stristr($identifier, 'xri://') !== FALSE) {
68 69
         return TRUE;
Please login to merge, or discard this patch.
main/auth/shibboleth/app/model/shibboleth_store.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     /**
19 19
      *
20
-     * @return ShibbolethData 
20
+     * @return ShibbolethStore 
21 21
      */
22 22
     public static function instance()
23 23
     {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -168,12 +168,10 @@
 block discarded – undo
168 168
                 if (empty($result))
169 169
                 {
170 170
                     $result = $default;
171
-                }
172
-                else if (count($result) == 1)
171
+                } else if (count($result) == 1)
173 172
                 {
174 173
                     $result = reset($result);
175
-                }
176
-                else
174
+                } else
177 175
                 {
178 176
                     $result = $result;
179 177
                 }
Please login to merge, or discard this patch.
main/auth/shibboleth/app/model/user.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -56,6 +56,9 @@
 block discarded – undo
56 56
         return $this->get(array('shibb_unique_id' => $id));
57 57
     }
58 58
     
59
+    /**
60
+     * @param string $id
61
+     */
59 62
     public function shibboleth_id_exists($id)
60 63
     {
61 64
         return $this->exist(array('shibb_unique_id' => $id));
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Shibboleth;
4 4
 
5
-require_once dirname(__FILE__) . '/scaffold/user.class.php';
5
+require_once dirname(__FILE__).'/scaffold/user.class.php';
6 6
 
7 7
 /**
8 8
  * A Chamilo user. Model for the User table.
Please login to merge, or discard this patch.
main/auth/shibboleth/app/shibboleth.class.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
     /**
130 130
      *
131
-     * @param ShibbolethUser $user
131
+     * @param ShibbolethUser $shibb_user
132 132
      */
133 133
     public static function save($shibb_user)
134 134
     {
@@ -230,6 +230,7 @@  discard block
 block discarded – undo
230 230
      * Sends an email to the Chamilo and Shibboleth administrators in the name
231 231
      * of the logged-in user.
232 232
      *
233
+     * @param string $subject
233 234
      */
234 235
     public static function email_admin($subject, $message)
235 236
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,14 +78,14 @@
 block discarded – undo
78 78
 
79 79
     public static function sys_path()
80 80
     {
81
-        $path = dirname(__FILE__) . '/../';
81
+        $path = dirname(__FILE__).'/../';
82 82
         return $path;
83 83
     }
84 84
 
85 85
     public static function url($path = '')
86 86
     {
87 87
         $result = api_get_path('WEB_PATH');
88
-        $result .= '/main/auth/shibboleth/' . $path;
88
+        $result .= '/main/auth/shibboleth/'.$path;
89 89
         return $result;
90 90
     }
91 91
 
Please login to merge, or discard this patch.
main/auth/shibboleth/db/shibboleth_upgrade.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * Creates the 'shibb_unique_id' field in the table 'user' of the main Chamilo database if it doesn't exist yet
36 36
      *
37 37
      * @author Nicolas Rod
38
-     * @return void
38
+     * @return false|null
39 39
      */
40 40
     public static function create_shibb_unique_id_field_if_missing()
41 41
     {
Please login to merge, or discard this patch.
main/auth/shibboleth/lib/store.class.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -346,6 +346,9 @@
 block discarded – undo
346 346
         return $result;
347 347
     }
348 348
 
349
+    /**
350
+     * @param string $sql
351
+     */
349 352
     protected function execute($sql)
350 353
     {
351 354
         return Database::query($sql, null, __FILE__);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 
247 247
         $db_name = $this->get_db_name($object);
248 248
         $sql = "INSERT INTO `{$db_name}`.`{$this->table_name}` ";
249
-        $sql .= ' (' . join(', ', $keys) . ') ';
249
+        $sql .= ' ('.join(', ', $keys).') ';
250 250
         $sql .= 'VALUES';
251
-        $sql .= ' (' . join(', ', $values) . ') ';
251
+        $sql .= ' ('.join(', ', $values).') ';
252 252
 
253 253
         $result = $this->execute($sql);
254 254
         if ($result)
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         $items = array();
296 296
         foreach ($args as $key => $val)
297 297
         {
298
-            $items[] = $key . ' = ' . $this->format_value($val);
298
+            $items[] = $key.' = '.$this->format_value($val);
299 299
         }
300 300
         return implode(' AND ', $items);
301 301
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -107,8 +107,7 @@  discard block
 block discarded – undo
107 107
         if ($this->is_new($object))
108 108
         {
109 109
             $result = $this->insert($object);
110
-        }
111
-        else
110
+        } else
112 111
         {
113 112
             $result = $this->update($object);
114 113
         }
@@ -257,8 +256,7 @@  discard block
 block discarded – undo
257 256
             $object->{$this->id_name} = $id;
258 257
             $object->{db_name} = $db_name;
259 258
             return $id;
260
-        }
261
-        else
259
+        } else
262 260
         {
263 261
             return false;
264 262
         }
@@ -278,16 +276,13 @@  discard block
 block discarded – undo
278 276
                     return '';
279 277
                 }
280 278
                 $args = array($this->pk_name, $arg);
281
-            }
282
-            else if (is_string($arg))
279
+            } else if (is_string($arg))
283 280
             {
284 281
                 return $arg;
285
-            }
286
-            else if (is_array($arg))
282
+            } else if (is_array($arg))
287 283
             {
288 284
                 $args = $arg;
289
-            }
290
-            else
285
+            } else
291 286
             {
292 287
                 return $arg;
293 288
             }
@@ -309,17 +304,14 @@  discard block
 block discarded – undo
309 304
         if (is_bool($var))
310 305
         {
311 306
             return $value ? '1' : '0';
312
-        }
313
-        else if (is_numeric($value))
307
+        } else if (is_numeric($value))
314 308
         {
315 309
             return empty($value) ? '0' : $value;
316
-        }
317
-        else if (is_string($value))
310
+        } else if (is_string($value))
318 311
         {
319 312
             $value = mysql_escape_string($value);
320 313
             return "'$value'";
321
-        }
322
-        else
314
+        } else
323 315
         {
324 316
             return $value;
325 317
         }
Please login to merge, or discard this patch.
main/auth/sso/sso.Drupal.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 
91 91
     /**
92 92
      * Validates the received active connection data with the database
93
-     * @return	bool	Return the loginFailed variable value to local.inc.php
93
+     * @return	null|false	Return the loginFailed variable value to local.inc.php
94 94
      */
95 95
     public function check_user()
96 96
     {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class ssoDrupal
24 24
 {
25
-    public $protocol;   // 'http://',
26
-    public $domain;     // 'localhost/project/drupal',
27
-    public $auth_uri;   // '/?q=user',
25
+    public $protocol; // 'http://',
26
+    public $domain; // 'localhost/project/drupal',
27
+    public $auth_uri; // '/?q=user',
28 28
     public $deauth_uri; // '/?q=logout',
29
-    public $referer;    // http://my.chamilo.com/main/auth/profile.php
29
+    public $referer; // http://my.chamilo.com/main/auth/profile.php
30 30
 
31 31
     /**
32 32
      * Instanciates the object, initializing all relevant URL strings
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
                     && ($sso['username'] == $uData['username'])) {
124 124
 
125 125
                     //Check if the account is active (not locked)
126
-                    if ($uData['active']=='1') {
126
+                    if ($uData['active'] == '1') {
127 127
                         // check if the expiration date has not been reached
128
-                        if (empty($uData['expiration_date']) OR $uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
128
+                        if (empty($uData['expiration_date']) OR $uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date'] == '0000-00-00 00:00:00') {
129 129
 
130 130
                             //If Multiple URL is enabled
131 131
                             if (api_get_multiple_access_url()) {
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
                                             // the user credentials are OK, which
159 159
                                             // should be protection enough
160 160
                                             // against evil URL spoofing...
161
-                                            $sso_target = api_get_path(WEB_PATH) . base64_decode($sso['ruri']);
161
+                                            $sso_target = api_get_path(WEB_PATH).base64_decode($sso['ruri']);
162 162
                                         } else {
163
-                                            $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) . 'index.php';
163
+                                            $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH).'index.php';
164 164
                                         }
165
-                                        header('Location: '. $sso_target);
165
+                                        header('Location: '.$sso_target);
166 166
                                         exit;
167 167
                                     } else {
168 168
                                         // user does not have permission for this site
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
         // If this is an administrator, allow him to make some changes in
280 280
         // the Chamilo profile
281 281
         if ($asAdmin && api_is_platform_admin(true)) {
282
-            return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$userId";
282
+            return api_get_path(WEB_CODE_PATH)."admin/user_edit.php?user_id=$userId";
283 283
         }
284 284
         // If the user doesn't match a Drupal user, give the normal profile
285 285
         // link
286 286
         if ($drupalUserIdData === false) {
287
-            return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
287
+            return api_get_path(WEB_CODE_PATH).'auth/profile.php';
288 288
         }
289 289
         // In all other cases, generate a link to the Drupal profile edition
290 290
         $drupalUserId = $drupalUserIdData['value'];
Please login to merge, or discard this patch.
main/coursecopy/classes/Course.class.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -327,6 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
     /**
329 329
     * Serialize the course with the best serializer available
330
+    * @return string
330 331
     */
331 332
     public static function serialize($course)
332 333
     {
@@ -339,6 +340,7 @@  discard block
 block discarded – undo
339 340
 
340 341
     /**
341 342
     * Unserialize the course with the best serializer available
343
+    * @param string $course
342 344
     */
343 345
     public static function unserialize($course)
344 346
     {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
     }
327 327
 
328 328
     /**
329
-    * Serialize the course with the best serializer available
330
-    */
329
+     * Serialize the course with the best serializer available
330
+     */
331 331
     public static function serialize($course)
332 332
     {
333 333
         if (extension_loaded('igbinary')) {
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
     }
339 339
 
340 340
     /**
341
-    * Unserialize the course with the best serializer available
342
-    */
341
+     * Unserialize the course with the best serializer available
342
+     */
343 343
     public static function unserialize($course)
344 344
     {
345 345
         if (extension_loaded('igbinary')) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
             if (is_array($resources)) {
41 41
                 foreach ($resources as $resource) {
42 42
                     Coursecopy\Resource::setClassType($resource);
43
-                    if ($resource->links_to($resource_to_check) ) {
43
+                    if ($resource->links_to($resource_to_check)) {
44 44
                         return true;
45 45
                     }
46
-                    if ($type == RESOURCE_LEARNPATH && get_class($resource)=='CourseCopyLearnpath') {
46
+                    if ($type == RESOURCE_LEARNPATH && get_class($resource) == 'CourseCopyLearnpath') {
47 47
                         if ($resource->has_item($resource_to_check)) {
48 48
                             return true;
49 49
                         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function has_resources($resource_type = null)
72 72
     {
73
-        if( $resource_type != null) {
73
+        if ($resource_type != null) {
74 74
             return isset($this->resources[$resource_type]) && is_array($this->resources[$resource_type]) && (count(
75 75
                     $this->resources[$resource_type]
76 76
                 ) > 0);
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
                             $description = $resource->content;
178 178
                             break;
179 179
                         case RESOURCE_THEMATIC:
180
-                            $title 			= $resource->title;
181
-                            $description 	= $resource->content;
180
+                            $title = $resource->title;
181
+                            $description = $resource->content;
182 182
                             break;
183 183
                         case RESOURCE_ATTENDANCE:
184
-                            $title 			= $resource->params['name'];
185
-                            $description 	= $resource->params['description'];
184
+                            $title = $resource->params['name'];
185
+                            $description = $resource->params['description'];
186 186
                             break;
187 187
                         case RESOURCE_WORK:
188 188
                             $title = $resource->title;
Please login to merge, or discard this patch.
main/coursecopy/classes/CourseArchiver.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
173 173
 
174 174
     /**
175 175
      * @param array $file
176
-     * @return bool|string
176
+     * @return string|false
177 177
      */
178 178
     public static function import_uploaded_file($file)
179 179
     {
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
             while (($file = readdir($handle)) !== false) {
24 24
                 if ($file != "." && $file != ".." &&
25 25
                     strpos($file, 'CourseArchiver_') === 0 &&
26
-                    is_dir($dir . '/' . $file)
26
+                    is_dir($dir.'/'.$file)
27 27
                 ) {
28
-                    rmdirr($dir . '/' . $file);
28
+                    rmdirr($dir.'/'.$file);
29 29
                 }
30 30
             }
31 31
             closedir($handle);
@@ -43,48 +43,48 @@  discard block
 block discarded – undo
43 43
         CourseArchiver::clean_backup_dir();
44 44
 
45 45
         // Create a temp directory
46
-        $tmp_dir_name = 'CourseArchiver_' . api_get_unique_id();
47
-        $backup_dir = api_get_path(SYS_ARCHIVE_PATH) . $tmp_dir_name . '/';
46
+        $tmp_dir_name = 'CourseArchiver_'.api_get_unique_id();
47
+        $backup_dir = api_get_path(SYS_ARCHIVE_PATH).$tmp_dir_name.'/';
48 48
 
49 49
         // All course-information will be stored in course_info.dat
50
-        $course_info_file = $backup_dir . 'course_info.dat';
50
+        $course_info_file = $backup_dir.'course_info.dat';
51 51
         $zip_dir = api_get_path(SYS_ARCHIVE_PATH);
52 52
         $user = api_get_user_info();
53 53
         $date = new DateTime(api_get_local_time());
54
-        $zip_file = $user['user_id'] . '_' . $course->code . '_' . $date->format('Ymd-His') . '.zip';
54
+        $zip_file = $user['user_id'].'_'.$course->code.'_'.$date->format('Ymd-His').'.zip';
55 55
         $php_errormsg = '';
56 56
         $res = @mkdir($backup_dir, $perm_dirs);
57 57
         if ($res === false) {
58 58
             //TODO set and handle an error message telling the user to review the permissions on the archive directory
59
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini') . ' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0);
59
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created', 0);
60 60
         }
61 61
         // Write the course-object to the file
62 62
         $fp = @fopen($course_info_file, 'w');
63 63
         if ($fp === false) {
64
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
64
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
65 65
         }
66 66
 
67 67
         $res = @fwrite($fp, base64_encode(serialize($course)));
68 68
         if ($res === false) {
69
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
69
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
70 70
         }
71 71
 
72 72
         $res = @fclose($fp);
73 73
         if ($res === false) {
74
-            error_log(__FILE__ . ' line ' . __LINE__ . ': ' . (ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
74
+            error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors') != false ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
75 75
         }
76 76
 
77 77
         // Copy all documents to the temp-dir
78 78
         if (isset($course->resources[RESOURCE_DOCUMENT]) && is_array($course->resources[RESOURCE_DOCUMENT])) {
79 79
             foreach ($course->resources[RESOURCE_DOCUMENT] as $document) {
80 80
                 if ($document->file_type == DOCUMENT) {
81
-                    $doc_dir = $backup_dir . $document->path;
81
+                    $doc_dir = $backup_dir.$document->path;
82 82
                     @mkdir(dirname($doc_dir), $perm_dirs, true);
83
-                    if (file_exists($course->path . $document->path)) {
84
-                        copy($course->path . $document->path, $doc_dir);
83
+                    if (file_exists($course->path.$document->path)) {
84
+                        copy($course->path.$document->path, $doc_dir);
85 85
                     }
86 86
                 } else {
87
-                    @mkdir($backup_dir . $document->path, $perm_dirs, true);
87
+                    @mkdir($backup_dir.$document->path, $perm_dirs, true);
88 88
                 }
89 89
             }
90 90
         }
@@ -92,49 +92,49 @@  discard block
 block discarded – undo
92 92
         // Copy all scorm documents to the temp-dir
93 93
         if (isset($course->resources[RESOURCE_SCORM]) && is_array($course->resources[RESOURCE_SCORM])) {
94 94
             foreach ($course->resources[RESOURCE_SCORM] as $document) {
95
-                $doc_dir = dirname($backup_dir . $document->path);
95
+                $doc_dir = dirname($backup_dir.$document->path);
96 96
                 @mkdir($doc_dir, $perm_dirs, true);
97
-                copyDirTo($course->path . $document->path, $doc_dir, false);
97
+                copyDirTo($course->path.$document->path, $doc_dir, false);
98 98
             }
99 99
         }
100 100
 
101 101
         // Copy calendar attachments.
102 102
 
103 103
         if (isset($course->resources[RESOURCE_EVENT]) && is_array($course->resources[RESOURCE_EVENT])) {
104
-            $doc_dir = dirname($backup_dir . '/upload/calendar/');
104
+            $doc_dir = dirname($backup_dir.'/upload/calendar/');
105 105
             @mkdir($doc_dir, $perm_dirs, true);
106
-            copyDirTo($course->path . 'upload/calendar/', $doc_dir, false);
106
+            copyDirTo($course->path.'upload/calendar/', $doc_dir, false);
107 107
         }
108 108
 
109 109
         // Copy Learning path author image.
110 110
         if (isset($course->resources[RESOURCE_LEARNPATH]) && is_array($course->resources[RESOURCE_LEARNPATH])) {
111
-            $doc_dir = dirname($backup_dir . '/upload/learning_path/');
111
+            $doc_dir = dirname($backup_dir.'/upload/learning_path/');
112 112
             @mkdir($doc_dir, $perm_dirs, true);
113
-            copyDirTo($course->path . 'upload/learning_path/', $doc_dir, false);
113
+            copyDirTo($course->path.'upload/learning_path/', $doc_dir, false);
114 114
         }
115 115
 
116 116
         // Copy announcements attachments.
117 117
         if (isset($course->resources[RESOURCE_ANNOUNCEMENT]) && is_array($course->resources[RESOURCE_ANNOUNCEMENT])) {
118
-            $doc_dir = dirname($backup_dir . '/upload/announcements/');
118
+            $doc_dir = dirname($backup_dir.'/upload/announcements/');
119 119
             @mkdir($doc_dir, $perm_dirs, true);
120
-            copyDirTo($course->path . 'upload/announcements/', $doc_dir, false);
120
+            copyDirTo($course->path.'upload/announcements/', $doc_dir, false);
121 121
         }
122 122
 
123 123
         // Copy work folders (only folders)
124 124
         if (isset($course->resources[RESOURCE_WORK]) && is_array($course->resources[RESOURCE_WORK])) {
125
-            $doc_dir = dirname($backup_dir . '/upload/work/');
125
+            $doc_dir = dirname($backup_dir.'/upload/work/');
126 126
             @mkdir($doc_dir, $perm_dirs, true);
127 127
             // @todo: adjust to only create subdirs, but not copy files
128
-            copyDirTo($course->path . 'upload/work/', $doc_dir, false);
128
+            copyDirTo($course->path.'upload/work/', $doc_dir, false);
129 129
         }
130 130
 
131 131
         // Zip the course-contents
132
-        $zip = new PclZip($zip_dir . $zip_file);
133
-        $zip->create($zip_dir . $tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir . $tmp_dir_name . '/');
132
+        $zip = new PclZip($zip_dir.$zip_file);
133
+        $zip->create($zip_dir.$tmp_dir_name, PCLZIP_OPT_REMOVE_PATH, $zip_dir.$tmp_dir_name.'/');
134 134
         //$zip->deleteByIndex(0);
135 135
         // Remove the temp-dir.
136 136
         rmdirr($backup_dir);
137
-        return '' . $zip_file;
137
+        return ''.$zip_file;
138 138
     }
139 139
 
140 140
     /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         global $dateTimeFormatLong;
147 147
         $backup_files = array();
148
-        $dirname = api_get_path(SYS_ARCHIVE_PATH) . '';
148
+        $dirname = api_get_path(SYS_ARCHIVE_PATH).'';
149 149
         if ($dir = opendir($dirname)) {
150 150
             while (($file = readdir($dir)) !== false) {
151 151
                 $file_parts = explode('_', $file);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                     $date = $file_parts[0];
157 157
                     $ext = isset($file_parts[1]) ? $file_parts[1] : null;
158 158
                     if ($ext == 'zip' && ($user_id != null && $owner_id == $user_id || $user_id == null)) {
159
-                        $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 9, 2) . ':' . substr($date, 11, 2) . ':' . substr($date, 13, 2);
159
+                        $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6, 2).' '.substr($date, 9, 2).':'.substr($date, 11, 2).':'.substr($date, 13, 2);
160 160
                         $backup_files[] = array(
161 161
                             'file' => $file,
162 162
                             'date' => $date,
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public static function import_uploaded_file($file)
179 179
     {
180
-        $new_filename = uniqid('') . '.zip';
180
+        $new_filename = uniqid('').'.zip';
181 181
         $new_dir = api_get_path(SYS_ARCHIVE_PATH);
182 182
         if (is_dir($new_dir) && is_writable($new_dir)) {
183 183
             move_uploaded_file($file, api_get_path(SYS_ARCHIVE_PATH).$new_filename);
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
     {
201 201
         CourseArchiver::clean_backup_dir();
202 202
         // Create a temp directory
203
-        $tmp_dir_name = 'CourseArchiver_' . uniqid('');
204
-        $unzip_dir = api_get_path(SYS_ARCHIVE_PATH) . '' . $tmp_dir_name;
203
+        $tmp_dir_name = 'CourseArchiver_'.uniqid('');
204
+        $unzip_dir = api_get_path(SYS_ARCHIVE_PATH).''.$tmp_dir_name;
205 205
         @mkdir($unzip_dir, api_get_permissions_for_new_directories(), true);
206
-        @copy(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename, $unzip_dir . '/backup.zip');
206
+        @copy(api_get_path(SYS_ARCHIVE_PATH).''.$filename, $unzip_dir.'/backup.zip');
207 207
         // unzip the archive
208
-        $zip = new PclZip($unzip_dir . '/backup.zip');
208
+        $zip = new PclZip($unzip_dir.'/backup.zip');
209 209
         @chdir($unzip_dir);
210 210
         $zip->extract(PCLZIP_OPT_TEMP_FILE_ON);
211 211
         // remove the archive-file
212 212
         if ($delete) {
213
-            @unlink(api_get_path(SYS_ARCHIVE_PATH) . '' . $filename);
213
+            @unlink(api_get_path(SYS_ARCHIVE_PATH).''.$filename);
214 214
         }
215 215
         // read the course
216 216
         if (!is_file('course_info.dat')) {
Please login to merge, or discard this patch.