Completed
Push — 1.11.x ( ae642b...8fe553 )
by José
74:31 queued 35:16
created
main/lp/aicc.class.php 1 patch
Braces   +21 added lines, -13 removed lines patch added patch discarded remove patch
@@ -509,7 +509,9 @@  discard block
 block discarded – undo
509 509
                     if ($file != '.' && $file != '..') {
510 510
                         $filetype = 'file';
511 511
 
512
-                        if (is_dir($course_sys_dir.$new_dir.$file)) $filetype = 'folder';
512
+                        if (is_dir($course_sys_dir.$new_dir.$file)) {
513
+                            $filetype = 'folder';
514
+                        }
513 515
 
514 516
                         // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
515 517
                         //$safe_file = api_replace_dangerous_char($file, 'strict');
@@ -908,37 +910,43 @@  discard block
 block discarded – undo
908 910
                     if ($enclosed && $data{$i+1} == $enclosure) {
909 911
                         $fldval .= $chr;
910 912
                         ++$i; // Skip the next character.
911
-                    } else
912
-                        $enclosed = !$enclosed;
913
+                    } else {
914
+                                            $enclosed = !$enclosed;
915
+                    }
913 916
                     break;
914 917
                 case $delim:
915 918
                     if (!$enclosed) {
916 919
                         $ret_array[$linecount][$fldcount++] = $fldval;
917 920
                         $fldval = '';
918
-                    } else
919
-                        $fldval .= $chr;
921
+                    } else {
922
+                                            $fldval .= $chr;
923
+                    }
920 924
                     break;
921 925
                 case "\r":
922
-                    if (!$enclosed&&$data{$i+1} == "\n")
923
-                        continue;
926
+                    if (!$enclosed&&$data{$i+1} == "\n") {
927
+                                            continue;
928
+                    }
924 929
                 case "\n":
925 930
                     if (!$enclosed) {
926 931
                         $ret_array[$linecount++][$fldcount] = $fldval;
927 932
                         $fldcount = 0;
928 933
                         $fldval = '';
929
-                    } else
930
-                        $fldval .= $chr;
934
+                    } else {
935
+                                            $fldval .= $chr;
936
+                    }
931 937
                     break;
932 938
                 case "\\r":
933
-                    if (!$enclosed&&$data{$i+1} == "\\n")
934
-                        continue;
939
+                    if (!$enclosed&&$data{$i+1} == "\\n") {
940
+                                            continue;
941
+                    }
935 942
                 case "\\n":
936 943
                     if (!$enclosed) {
937 944
                         $ret_array[$linecount++][$fldcount] = $fldval;
938 945
                         $fldcount = 0;
939 946
                         $fldval = '';
940
-                    } else
941
-                        $fldval .= $chr;
947
+                    } else {
948
+                                            $fldval .= $chr;
949
+                    }
942 950
                     break;
943 951
                 default:
944 952
                     $fldval .= $chr;
Please login to merge, or discard this patch.
main/lp/lp_controller.php 1 patch
Braces   +86 added lines, -36 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 $use_anonymous = true;
14 14
 
15 15
 $debug = 0;
16
-if ($debug > 0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
16
+if ($debug > 0) {
17
+    error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
18
+}
17 19
 
18 20
 // Language files that needs to be included.
19 21
 if (isset($_GET['action'])) {
@@ -209,10 +211,14 @@  discard block
 block discarded – undo
209 211
     // If refresh is set, we regenerate the oLP object from the database (kind of flush).
210 212
     Session::erase('refresh');
211 213
     $myrefresh = 1;
212
-    if ($debug > 0) error_log('New LP - Refresh asked', 0);
213
-}
214
+    if ($debug > 0) {
215
+        error_log('New LP - Refresh asked', 0);
216
+    }
217
+    }
214 218
 
215
-if ($debug > 0) error_log('New LP - Passed refresh check', 0);
219
+if ($debug > 0) {
220
+    error_log('New LP - Passed refresh check', 0);
221
+}
216 222
 
217 223
 if (!empty($_REQUEST['dialog_box'])) {
218 224
     $dialog_box = stripslashes(urldecode($_REQUEST['dialog_box']));
@@ -222,17 +228,23 @@  discard block
 block discarded – undo
222 228
 $lp_found = false;
223 229
 
224 230
 if (isset($_SESSION['lpobject'])) {
225
-    if ($debug > 0) error_log('New LP - SESSION[lpobject] is defined', 0);
231
+    if ($debug > 0) {
232
+        error_log('New LP - SESSION[lpobject] is defined', 0);
233
+    }
226 234
     $oLP = unserialize($_SESSION['lpobject']);
227 235
     if (isset($oLP) && is_object($oLP)) {
228
-        if ($debug > 0) error_log('New LP - oLP is object', 0);
236
+        if ($debug > 0) {
237
+            error_log('New LP - oLP is object', 0);
238
+        }
229 239
         if ($myrefresh == 1 ||
230 240
             empty($oLP->cc) ||
231 241
             $oLP->cc != api_get_course_id() ||
232 242
             $oLP->lp_view_session_id != $session_id ||
233 243
             $oLP->scorm_debug == '1'
234 244
         ) {
235
-            if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0);
245
+            if ($debug > 0) {
246
+                error_log('New LP - Course has changed, discard lp object', 0);
247
+            }
236 248
             if ($myrefresh == 1) { $myrefresh_id = $oLP->get_id(); }
237 249
             $oLP = null;
238 250
             Session::erase('oLP');
@@ -246,13 +258,19 @@  discard block
 block discarded – undo
246 258
 
247 259
 $course_id = api_get_course_int_id();
248 260
 
249
-if ($debug>0) error_log('New LP - Passed data remains check', 0);
261
+if ($debug>0) {
262
+    error_log('New LP - Passed data remains check', 0);
263
+}
250 264
 
251 265
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
252
-    if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
266
+    if ($debug > 0) {
267
+        error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
268
+    }
253 269
     // Regenerate a new lp object? Not always as some pages don't need the object (like upload?)
254 270
     if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) {
255
-        if ($debug > 0) error_log('New LP - lp_id is defined', 0);
271
+        if ($debug > 0) {
272
+            error_log('New LP - lp_id is defined', 0);
273
+        }
256 274
         // Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
257 275
         // right object.
258 276
         if (!empty($_REQUEST['lp_id'])) {
@@ -264,16 +282,22 @@  discard block
 block discarded – undo
264 282
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
265 283
         if (is_numeric($lp_id)) {
266 284
             $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
267
-            if ($debug > 0) error_log('New LP - querying '.$sel, 0);
285
+            if ($debug > 0) {
286
+                error_log('New LP - querying '.$sel, 0);
287
+            }
268 288
             $res = Database::query($sel);
269 289
 
270 290
             if (Database::num_rows($res)) {
271 291
                 $row = Database::fetch_array($res);
272 292
                 $type = $row['lp_type'];
273
-                if ($debug > 0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
293
+                if ($debug > 0) {
294
+                    error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
295
+                }
274 296
                 switch ($type) {
275 297
                     case 1:
276
-                        if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
298
+                        if ($debug > 0) {
299
+                            error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
300
+                        }
277 301
 
278 302
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
279 303
                         if ($oLP !== false) {
@@ -283,7 +307,9 @@  discard block
 block discarded – undo
283 307
                         }
284 308
                         break;
285 309
                     case 2:
286
-                        if ($debug > 0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
310
+                        if ($debug > 0) {
311
+                            error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
312
+                        }
287 313
                         $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id());
288 314
                         if ($oLP !== false) {
289 315
                             $lp_found = true;
@@ -292,7 +318,9 @@  discard block
 block discarded – undo
292 318
                         }
293 319
                         break;
294 320
                     case 3:
295
-                        if ($debug > 0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
321
+                        if ($debug > 0) {
322
+                            error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
323
+                        }
296 324
                         $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id());
297 325
                         if ($oLP !== false) {
298 326
                             $lp_found = true;
@@ -301,7 +329,9 @@  discard block
 block discarded – undo
301 329
                         }
302 330
                         break;
303 331
                     default:
304
-                        if ($debug > 0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
332
+                        if ($debug > 0) {
333
+                            error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
334
+                        }
305 335
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
306 336
                         if ($oLP !== false) {
307 337
                             $lp_found = true;
@@ -312,17 +342,23 @@  discard block
 block discarded – undo
312 342
                 }
313 343
             }
314 344
         } else {
315
-            if ($debug > 0) error_log('New LP - Request[lp_id] is not numeric', 0);
345
+            if ($debug > 0) {
346
+                error_log('New LP - Request[lp_id] is not numeric', 0);
347
+            }
316 348
         }
317 349
     } else {
318
-        if ($debug > 0) error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
350
+        if ($debug > 0) {
351
+            error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
352
+        }
319 353
     }
320 354
     if ($lp_found) {
321 355
         $_SESSION['oLP'] = $oLP;
322 356
     }
323 357
 }
324 358
 
325
-if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
359
+if ($debug > 0) {
360
+    error_log('New LP - Passed oLP creation check', 0);
361
+}
326 362
 
327 363
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
328 364
 
@@ -359,7 +395,9 @@  discard block
 block discarded – undo
359 395
 }
360 396
 
361 397
 $redirectTo = '';
362
-if ($debug > 0) error_log('New LP - action "'.$action.'" triggered');
398
+if ($debug > 0) {
399
+    error_log('New LP - action "'.$action.'" triggered');
400
+}
363 401
 
364 402
 switch ($action) {
365 403
     case 'add_item':
@@ -368,7 +406,9 @@  discard block
 block discarded – undo
368 406
         }
369 407
         if (!$lp_found) {
370 408
             //check if the learnpath ID was defined, otherwise send back to list
371
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
409
+            if ($debug > 0) {
410
+                error_log('New LP - No learnpath given for add item', 0);
411
+            }
372 412
             require 'lp_list.php';
373 413
         } else {
374 414
             $_SESSION['refresh'] = 1;
@@ -458,7 +498,9 @@  discard block
 block discarded – undo
458 498
         }
459 499
         if (!$lp_found) {
460 500
             //check if the learnpath ID was defined, otherwise send back to list
461
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
501
+            if ($debug > 0) {
502
+                error_log('New LP - No learnpath given for add audio', 0);
503
+            }
462 504
             require 'lp_list.php';
463 505
         } else {
464 506
             $_SESSION['refresh'] = 1;
@@ -606,8 +648,7 @@  discard block
 block discarded – undo
606 648
             if (!$is_allowed_to_edit) {
607 649
                 api_not_allowed(true);
608 650
             }
609
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
610
-            else {
651
+            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } else {
611 652
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
612 653
                 require 'lp_list.php';
613 654
                 exit;
@@ -688,8 +729,7 @@  discard block
 block discarded – undo
688 729
         if (!$is_allowed_to_edit) {
689 730
             api_not_allowed(true);
690 731
         }
691
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
692
-        else {
732
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
693 733
             if (isset($_POST['submit_button'])) {
694 734
                 //Updating the lp.modified_on
695 735
                 $_SESSION['oLP']->set_modified_on();
@@ -983,8 +1023,9 @@  discard block
 block discarded – undo
983 1023
             );
984 1024
             $extraFieldValue->saveFieldValues($_REQUEST);
985 1025
 
986
-            if ($_FILES['lp_preview_image']['size'] > 0)
987
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1026
+            if ($_FILES['lp_preview_image']['size'] > 0) {
1027
+                            $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1028
+            }
988 1029
 
989 1030
             if (api_get_setting('search_enabled') === 'true') {
990 1031
                 require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -1117,16 +1158,24 @@  discard block
 block discarded – undo
1117 1158
         }
1118 1159
         break;
1119 1160
     case 'content':
1120
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1161
+        if ($debug > 0) {
1162
+            error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1163
+        }
1121 1164
         if (!$lp_found) {
1122 1165
             error_log('New LP - No learnpath given for content', 0);
1123 1166
             require 'lp_list.php';
1124 1167
         } else {
1125
-            if ($debug > 0) error_log('New LP - save_last()', 0);
1168
+            if ($debug > 0) {
1169
+                error_log('New LP - save_last()', 0);
1170
+            }
1126 1171
             $_SESSION['oLP']->save_last();
1127
-            if ($debug > 0) error_log('New LP - set_current_item()', 0);
1172
+            if ($debug > 0) {
1173
+                error_log('New LP - set_current_item()', 0);
1174
+            }
1128 1175
             $_SESSION['oLP']->set_current_item($_GET['item_id']);
1129
-            if ($debug > 0) error_log('New LP - start_current_item()', 0);
1176
+            if ($debug > 0) {
1177
+                error_log('New LP - start_current_item()', 0);
1178
+            }
1130 1179
             $_SESSION['oLP']->start_current_item();
1131 1180
             require 'lp_content.php';
1132 1181
         }
@@ -1242,8 +1291,7 @@  discard block
 block discarded – undo
1242 1291
         require 'lp_message.php';
1243 1292
         break;
1244 1293
     case 'return_to_course_homepage':
1245
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1246
-        else {
1294
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1247 1295
             $_SESSION['oLP']->save_current();
1248 1296
             $_SESSION['oLP']->save_last();
1249 1297
             $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
@@ -1436,8 +1484,10 @@  discard block
 block discarded – undo
1436 1484
 
1437 1485
 if (!empty($_SESSION['oLP'])) {
1438 1486
     $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
1439
-    if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
1440
-}
1487
+    if ($debug > 0) {
1488
+        error_log('New LP - lpobject is serialized in session', 0);
1489
+    }
1490
+    }
1441 1491
 
1442 1492
 if (!empty($redirectTo)) {
1443 1493
     header("Location: $redirectTo");
Please login to merge, or discard this patch.
main/admin/configure_extensions.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 ?>
136 136
 <div id="message" style="display: none">
137 137
 	<?php
138
-	if(!empty($message))
139
-		Display::display_normal_message($message)
138
+	if(!empty($message)) {
139
+			Display::display_normal_message($message)
140 140
 	?>
141 141
 </div>
142 142
 
@@ -150,7 +150,9 @@  discard block
 block discarded – undo
150 150
     </div>
151 151
         <div class="row">
152 152
             <div class="col-md-5">
153
-                <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp'), array('class'=>'img-responsive')); ?>
153
+                <?php Display::display_icon('screenshot_ppt2lp.jpg', get_lang('Ppt2lp'), array('class'=>'img-responsive'));
154
+	}
155
+	?>
154 156
             </div>
155 157
             <div class="col-md-7">
156 158
                 <form method="POST" class="form-horizontal" action="<?php echo api_get_self(); ?>">
Please login to merge, or discard this patch.
main/inc/lib/usermanager.lib.php 1 patch
Braces   +94 added lines, -60 removed lines patch added patch discarded remove patch
@@ -817,10 +817,12 @@  discard block
 block discarded – undo
817 817
     public static function update_openid($user_id, $openid)
818 818
     {
819 819
         $table_user = Database :: get_main_table(TABLE_MAIN_USER);
820
-        if ($user_id != strval(intval($user_id)))
821
-            return false;
822
-        if ($user_id === false)
823
-            return false;
820
+        if ($user_id != strval(intval($user_id))) {
821
+                    return false;
822
+        }
823
+        if ($user_id === false) {
824
+                    return false;
825
+        }
824 826
         $sql = "UPDATE $table_user SET
825 827
                 openid='".Database::escape_string($openid)."'";
826 828
         $sql .= " WHERE id= $user_id";
@@ -2137,8 +2139,9 @@  discard block
 block discarded – undo
2137 2139
         if (empty($user_id)) {
2138 2140
             $user_id = 0;
2139 2141
         } else {
2140
-            if ($user_id != strval(intval($user_id)))
2141
-                return array();
2142
+            if ($user_id != strval(intval($user_id))) {
2143
+                            return array();
2144
+            }
2142 2145
         }
2143 2146
         $extra_data = array();
2144 2147
         $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
@@ -2230,8 +2233,9 @@  discard block
 block discarded – undo
2230 2233
         if (empty($user_id)) {
2231 2234
             $user_id = 0;
2232 2235
         } else {
2233
-            if ($user_id != strval(intval($user_id)))
2234
-                return array();
2236
+            if ($user_id != strval(intval($user_id))) {
2237
+                            return array();
2238
+            }
2235 2239
         }
2236 2240
         $extra_data = array();
2237 2241
         $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
@@ -3014,13 +3018,15 @@  discard block
 block discarded – undo
3014 3018
      */
3015 3019
     public static function get_api_keys($user_id = null, $api_service = 'dokeos')
3016 3020
     {
3017
-        if ($user_id != strval(intval($user_id)))
3018
-            return false;
3021
+        if ($user_id != strval(intval($user_id))) {
3022
+                    return false;
3023
+        }
3019 3024
         if (empty($user_id)) {
3020 3025
             $user_id = api_get_user_id();
3021 3026
         }
3022
-        if ($user_id === false)
3023
-            return false;
3027
+        if ($user_id === false) {
3028
+                    return false;
3029
+        }
3024 3030
         $service_name = Database::escape_string($api_service);
3025 3031
         if (is_string($service_name) === false) {
3026 3032
             return false;
@@ -3028,11 +3034,14 @@  discard block
 block discarded – undo
3028 3034
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
3029 3035
         $sql = "SELECT * FROM $t_api WHERE user_id = $user_id AND api_service='$api_service';";
3030 3036
         $res = Database::query($sql);
3031
-        if ($res === false)
3032
-            return false; //error during query
3037
+        if ($res === false) {
3038
+                    return false;
3039
+        }
3040
+        //error during query
3033 3041
         $num = Database::num_rows($res);
3034
-        if ($num == 0)
3035
-            return false;
3042
+        if ($num == 0) {
3043
+                    return false;
3044
+        }
3036 3045
         $list = array();
3037 3046
         while ($row = Database::fetch_array($res)) {
3038 3047
             $list[$row['id']] = $row['api_key'];
@@ -3047,13 +3056,15 @@  discard block
 block discarded – undo
3047 3056
      */
3048 3057
     public static function add_api_key($user_id = null, $api_service = 'dokeos')
3049 3058
     {
3050
-        if ($user_id != strval(intval($user_id)))
3051
-            return false;
3059
+        if ($user_id != strval(intval($user_id))) {
3060
+                    return false;
3061
+        }
3052 3062
         if (empty($user_id)) {
3053 3063
             $user_id = api_get_user_id();
3054 3064
         }
3055
-        if ($user_id === false)
3056
-            return false;
3065
+        if ($user_id === false) {
3066
+                    return false;
3067
+        }
3057 3068
         $service_name = Database::escape_string($api_service);
3058 3069
         if (is_string($service_name) === false) {
3059 3070
             return false;
@@ -3062,8 +3073,10 @@  discard block
 block discarded – undo
3062 3073
         $md5 = md5((time() + ($user_id * 5)) - rand(10000, 10000)); //generate some kind of random key
3063 3074
         $sql = "INSERT INTO $t_api (user_id, api_key,api_service) VALUES ($user_id,'$md5','$service_name')";
3064 3075
         $res = Database::query($sql);
3065
-        if ($res === false)
3066
-            return false; //error during query
3076
+        if ($res === false) {
3077
+                    return false;
3078
+        }
3079
+        //error during query
3067 3080
         $num = Database::insert_id();
3068 3081
         return ($num == 0) ? false : $num;
3069 3082
     }
@@ -3075,22 +3088,29 @@  discard block
 block discarded – undo
3075 3088
      */
3076 3089
     public static function delete_api_key($key_id)
3077 3090
     {
3078
-        if ($key_id != strval(intval($key_id)))
3079
-            return false;
3080
-        if ($key_id === false)
3081
-            return false;
3091
+        if ($key_id != strval(intval($key_id))) {
3092
+                    return false;
3093
+        }
3094
+        if ($key_id === false) {
3095
+                    return false;
3096
+        }
3082 3097
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
3083 3098
         $sql = "SELECT * FROM $t_api WHERE id = ".$key_id;
3084 3099
         $res = Database::query($sql);
3085
-        if ($res === false)
3086
-            return false; //error during query
3100
+        if ($res === false) {
3101
+                    return false;
3102
+        }
3103
+        //error during query
3087 3104
         $num = Database::num_rows($res);
3088
-        if ($num !== 1)
3089
-            return false;
3105
+        if ($num !== 1) {
3106
+                    return false;
3107
+        }
3090 3108
         $sql = "DELETE FROM $t_api WHERE id = ".$key_id;
3091 3109
         $res = Database::query($sql);
3092
-        if ($res === false)
3093
-            return false; //error during query
3110
+        if ($res === false) {
3111
+                    return false;
3112
+        }
3113
+        //error during query
3094 3114
         return true;
3095 3115
     }
3096 3116
 
@@ -3102,10 +3122,12 @@  discard block
 block discarded – undo
3102 3122
      */
3103 3123
     public static function update_api_key($user_id, $api_service)
3104 3124
     {
3105
-        if ($user_id != strval(intval($user_id)))
3106
-            return false;
3107
-        if ($user_id === false)
3108
-            return false;
3125
+        if ($user_id != strval(intval($user_id))) {
3126
+                    return false;
3127
+        }
3128
+        if ($user_id === false) {
3129
+                    return false;
3130
+        }
3109 3131
         $service_name = Database::escape_string($api_service);
3110 3132
         if (is_string($service_name) === false) {
3111 3133
             return false;
@@ -3131,12 +3153,15 @@  discard block
 block discarded – undo
3131 3153
      */
3132 3154
     public static function get_api_key_id($user_id, $api_service)
3133 3155
     {
3134
-        if ($user_id != strval(intval($user_id)))
3135
-            return false;
3136
-        if ($user_id === false)
3137
-            return false;
3138
-        if (empty($api_service))
3139
-            return false;
3156
+        if ($user_id != strval(intval($user_id))) {
3157
+                    return false;
3158
+        }
3159
+        if ($user_id === false) {
3160
+                    return false;
3161
+        }
3162
+        if (empty($api_service)) {
3163
+                    return false;
3164
+        }
3140 3165
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
3141 3166
         $api_service = Database::escape_string($api_service);
3142 3167
         $sql = "SELECT id FROM $t_api WHERE user_id=".$user_id." AND api_service='".$api_service."'";
@@ -4638,8 +4663,9 @@  discard block
 block discarded – undo
4638 4663
                     $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
4639 4664
                     $form->applyFilter('extra_'.$field_details[1], 'trim');
4640 4665
                     if (!$admin_permissions) {
4641
-                        if ($field_details[7] == 0)
4642
-                            $form->freeze('extra_'.$field_details[1]);
4666
+                        if ($field_details[7] == 0) {
4667
+                                                    $form->freeze('extra_'.$field_details[1]);
4668
+                        }
4643 4669
                     }
4644 4670
                     break;
4645 4671
                 case ExtraField::FIELD_TYPE_RADIO:
@@ -4696,8 +4722,9 @@  discard block
 block discarded – undo
4696 4722
                     );
4697 4723
 
4698 4724
                     if (!$admin_permissions) {
4699
-                        if ($field_details[7] == 0)
4700
-                            $form->freeze('extra_'.$field_details[1]);
4725
+                        if ($field_details[7] == 0) {
4726
+                                                    $form->freeze('extra_'.$field_details[1]);
4727
+                        }
4701 4728
                     }
4702 4729
                     break;
4703 4730
                 case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
@@ -4713,8 +4740,9 @@  discard block
 block discarded – undo
4713 4740
                         array('multiple' => 'multiple')
4714 4741
                     );
4715 4742
                     if (!$admin_permissions) {
4716
-                        if ($field_details[7] == 0)
4717
-                            $form->freeze('extra_'.$field_details[1]);
4743
+                        if ($field_details[7] == 0) {
4744
+                                                    $form->freeze('extra_'.$field_details[1]);
4745
+                        }
4718 4746
                     }
4719 4747
                     break;
4720 4748
                 case ExtraField::FIELD_TYPE_DATE:
@@ -4722,8 +4750,9 @@  discard block
 block discarded – undo
4722 4750
                     $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
4723 4751
                     $form->setDefaults($defaults);
4724 4752
                     if (!$admin_permissions) {
4725
-                        if ($field_details[7] == 0)
4726
-                            $form->freeze('extra_'.$field_details[1]);
4753
+                        if ($field_details[7] == 0) {
4754
+                                                    $form->freeze('extra_'.$field_details[1]);
4755
+                        }
4727 4756
                     }
4728 4757
                     $form->applyFilter('theme', 'trim');
4729 4758
                     break;
@@ -4732,8 +4761,9 @@  discard block
 block discarded – undo
4732 4761
                     $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
4733 4762
                     $form->setDefaults($defaults);
4734 4763
                     if (!$admin_permissions) {
4735
-                        if ($field_details[7] == 0)
4736
-                            $form->freeze('extra_'.$field_details[1]);
4764
+                        if ($field_details[7] == 0) {
4765
+                                                    $form->freeze('extra_'.$field_details[1]);
4766
+                        }
4737 4767
                     }
4738 4768
                     $form->applyFilter('theme', 'trim');
4739 4769
                     break;
@@ -4752,8 +4782,9 @@  discard block
 block discarded – undo
4752 4782
                     $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3]);
4753 4783
 
4754 4784
                     if (!$admin_permissions) {
4755
-                        if ($field_details[7] == 0)
4756
-                            $form->freeze('extra_'.$field_details[1]);
4785
+                        if ($field_details[7] == 0) {
4786
+                                                    $form->freeze('extra_'.$field_details[1]);
4787
+                        }
4757 4788
                     }
4758 4789
 
4759 4790
                     /* Recoding the selected values for double : if the user has
@@ -4813,8 +4844,9 @@  discard block
 block discarded – undo
4813 4844
                     break;
4814 4845
                 case ExtraField::FIELD_TYPE_TIMEZONE:
4815 4846
                     $form->addElement('select', 'extra_'.$field_details[1], $field_details[3], api_get_timezones(), '');
4816
-                    if ($field_details[7] == 0)
4817
-                        $form->freeze('extra_'.$field_details[1]);
4847
+                    if ($field_details[7] == 0) {
4848
+                                            $form->freeze('extra_'.$field_details[1]);
4849
+                    }
4818 4850
                     break;
4819 4851
                 case ExtraField::FIELD_TYPE_SOCIAL_PROFILE:
4820 4852
                     // get the social network's favicon
@@ -4839,8 +4871,9 @@  discard block
 block discarded – undo
4839 4871
                     );
4840 4872
                     $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
4841 4873
                     $form->applyFilter('extra_'.$field_details[1], 'trim');
4842
-                    if ($field_details[7] == 0)
4843
-                        $form->freeze('extra_'.$field_details[1]);
4874
+                    if ($field_details[7] == 0) {
4875
+                                            $form->freeze('extra_'.$field_details[1]);
4876
+                    }
4844 4877
                     break;
4845 4878
                 case ExtraField::FIELD_TYPE_FILE:
4846 4879
                     $extra_field = 'extra_'.$field_details[1];
@@ -5249,8 +5282,9 @@  discard block
 block discarded – undo
5249 5282
         $url .= "?s=$s&d=$d&r=$r";
5250 5283
         if ( $img ) {
5251 5284
             $url = '<img src="' . $url . '"';
5252
-            foreach ( $atts as $key => $val )
5253
-                $url .= ' ' . $key . '="' . $val . '"';
5285
+            foreach ( $atts as $key => $val ) {
5286
+                            $url .= ' ' . $key . '="' . $val . '"';
5287
+            }
5254 5288
             $url .= ' />';
5255 5289
         }
5256 5290
         return $url;
Please login to merge, or discard this patch.