Passed
Push — 1.10.x ( 62de0e...37d5af )
by Angel Fernando Quiroz
48:23
created
main/newscorm/learnpath.class.php 1 patch
Braces   +114 added lines, -78 removed lines patch added patch discarded remove patch
@@ -3939,8 +3939,9 @@  discard block
 block discarded – undo
3939 3939
                 WHERE c_id = ".$course_id."
3940 3940
                 ORDER BY display_order";
3941 3941
         $res = Database::query($sql);
3942
-        if ($res === false)
3943
-            return false;
3942
+        if ($res === false) {
3943
+                    return false;
3944
+        }
3944 3945
         $lps = array ();
3945 3946
         $lp_order = array ();
3946 3947
         $num = Database :: num_rows($res);
@@ -4540,8 +4541,9 @@  discard block
 block discarded – undo
4540 4541
         if ($this->debug > 0) {
4541 4542
             error_log('New LP - In learnpath::set_maker()', 0);
4542 4543
         }
4543
-        if (empty ($name))
4544
-            return false;
4544
+        if (empty ($name)) {
4545
+                    return false;
4546
+        }
4545 4547
         $this->maker = $name;
4546 4548
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4547 4549
         $course_id = api_get_course_int_id();
@@ -4606,8 +4608,9 @@  discard block
 block discarded – undo
4606 4608
     public function set_terms_by_prefix($terms_string, $prefix)
4607 4609
     {
4608 4610
         $course_id = api_get_course_int_id();
4609
-        if (api_get_setting('search_enabled') !== 'true')
4610
-            return false;
4611
+        if (api_get_setting('search_enabled') !== 'true') {
4612
+                    return false;
4613
+        }
4611 4614
 
4612 4615
         if (!extension_loaded('xapian')) {
4613 4616
             return false;
@@ -4620,8 +4623,9 @@  discard block
 block discarded – undo
4620 4623
         $stored_terms = $this->get_common_index_terms_by_prefix($prefix);
4621 4624
 
4622 4625
         // Don't do anything if no change, verify only at DB, not the search engine.
4623
-        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0))
4624
-            return false;
4626
+        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) {
4627
+                    return false;
4628
+        }
4625 4629
 
4626 4630
         require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API.
4627 4631
         require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
@@ -4813,8 +4817,9 @@  discard block
 block discarded – undo
4813 4817
         if ($this->debug > 0) {
4814 4818
             error_log('New LP - In learnpath::set_proximity()', 0);
4815 4819
         }
4816
-        if (empty ($name))
4817
-            return false;
4820
+        if (empty ($name)) {
4821
+                    return false;
4822
+        }
4818 4823
 
4819 4824
         $this->proximity = $name;
4820 4825
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
@@ -5156,8 +5161,9 @@  discard block
 block discarded – undo
5156 5161
 
5157 5162
         $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order";
5158 5163
         $res = Database::query($sql);
5159
-        if ($res === false)
5160
-            return false;
5164
+        if ($res === false) {
5165
+                    return false;
5166
+        }
5161 5167
 
5162 5168
         $num = Database :: num_rows($res);
5163 5169
         // First check the order is correct, globally (might be wrong because
@@ -5468,8 +5474,9 @@  discard block
 block discarded – undo
5468 5474
             $position[$key] = $row['display_order'];
5469 5475
         }
5470 5476
 
5471
-        if (count($array) > 0)
5472
-            array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5477
+        if (count($array) > 0) {
5478
+                    array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5479
+        }
5473 5480
 
5474 5481
         return $array;
5475 5482
     }
@@ -6023,8 +6030,9 @@  discard block
 block discarded – undo
6023 6030
         $tmp_filename = $filename;
6024 6031
 
6025 6032
         $i = 0;
6026
-        while (file_exists($filepath . $tmp_filename . '.'.$extension))
6027
-            $tmp_filename = $filename . '_' . ++ $i;
6033
+        while (file_exists($filepath . $tmp_filename . '.'.$extension)) {
6034
+                    $tmp_filename = $filename . '_' . ++ $i;
6035
+        }
6028 6036
 
6029 6037
         $filename = $tmp_filename . '.'.$extension;
6030 6038
         if ($extension == 'html') {
@@ -6103,10 +6111,12 @@  discard block
 block discarded – undo
6103 6111
                     if ($new_comment || $new_title) {
6104 6112
                         $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
6105 6113
                         $ct = '';
6106
-                        if ($new_comment)
6107
-                            $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6108
-                        if ($new_title)
6109
-                            $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' ";
6114
+                        if ($new_comment) {
6115
+                                                    $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6116
+                        }
6117
+                        if ($new_title) {
6118
+                                                    $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' ";
6119
+                        }
6110 6120
 
6111 6121
                         $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)."
6112 6122
                                WHERE c_id = ".$course_id." AND id = " . $document_id;
@@ -6130,17 +6140,21 @@  discard block
 block discarded – undo
6130 6140
         // Please, do not modify this dirname formatting.
6131 6141
         $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir'];
6132 6142
 
6133
-        if (strstr($dir, '..'))
6134
-            $dir = '/';
6143
+        if (strstr($dir, '..')) {
6144
+                    $dir = '/';
6145
+        }
6135 6146
 
6136
-        if ($dir[0] == '.')
6137
-            $dir = substr($dir, 1);
6147
+        if ($dir[0] == '.') {
6148
+                    $dir = substr($dir, 1);
6149
+        }
6138 6150
 
6139
-        if ($dir[0] != '/')
6140
-            $dir = '/' . $dir;
6151
+        if ($dir[0] != '/') {
6152
+                    $dir = '/' . $dir;
6153
+        }
6141 6154
 
6142
-        if ($dir[strlen($dir) - 1] != '/')
6143
-            $dir .= '/';
6155
+        if ($dir[strlen($dir) - 1] != '/') {
6156
+                    $dir .= '/';
6157
+        }
6144 6158
 
6145 6159
         $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
6146 6160
 
@@ -6206,8 +6220,9 @@  discard block
 block discarded – undo
6206 6220
                 }
6207 6221
                 $return .= '<div style="padding:10px;">';
6208 6222
 
6209
-                if ($msg != '')
6210
-                    $return .= $msg;
6223
+                if ($msg != '') {
6224
+                                    $return .= $msg;
6225
+                }
6211 6226
 
6212 6227
                 $return .= '<h3>'.$row['title'].'</h3>';
6213 6228
                 switch ($row['item_type']) {
@@ -6453,10 +6468,11 @@  discard block
 block discarded – undo
6453 6468
         $item_title			= Security::remove_XSS($item_title);
6454 6469
         $item_description 	= Security::remove_XSS($item_description);
6455 6470
 
6456
-        if ($id != 0 && is_array($extra_info))
6457
-            $parent = $extra_info['parent_item_id'];
6458
-        else
6459
-            $parent = 0;
6471
+        if ($id != 0 && is_array($extra_info)) {
6472
+                    $parent = $extra_info['parent_item_id'];
6473
+        } else {
6474
+                    $parent = 0;
6475
+        }
6460 6476
 
6461 6477
         $sql = "SELECT * FROM " . $tbl_lp_item . "
6462 6478
                 WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
@@ -6729,11 +6745,13 @@  discard block
 block discarded – undo
6729 6745
         }
6730 6746
 
6731 6747
         $legend = '<legend>';
6732
-        if ($action == 'add')
6733
-            $legend .= get_lang('CreateTheExercise');
6734
-        elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise');
6735
-        else
6736
-            $legend .= get_lang('EditCurrentExecice');
6748
+        if ($action == 'add') {
6749
+                    $legend .= get_lang('CreateTheExercise');
6750
+        } elseif ($action == 'move') {
6751
+            $legend .= get_lang('MoveTheCurrentExercise');
6752
+        } else {
6753
+                    $legend .= get_lang('EditCurrentExecice');
6754
+        }
6737 6755
         if (isset ($_GET['edit']) && $_GET['edit'] == 'true') {
6738 6756
             $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument'));
6739 6757
         }
@@ -6760,8 +6778,9 @@  discard block
 block discarded – undo
6760 6778
                         $arrHide[] = $arrLP[$i]['id'];
6761 6779
                     }
6762 6780
                 } else {
6763
-                    if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
6764
-                        $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6781
+                    if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
6782
+                                            $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6783
+                    }
6765 6784
                 }
6766 6785
             }
6767 6786
 
@@ -6779,11 +6798,13 @@  discard block
 block discarded – undo
6779 6798
 
6780 6799
         for ($i = 0; $i < count($arrLP); $i++) {
6781 6800
             if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
6782
-                if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6801
+                if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6802
+                                    $selected = 'selected="selected" ';
6803
+                } elseif ($action == 'add') {
6783 6804
                     $selected = 'selected="selected" ';
6784
-                elseif ($action == 'add') $selected = 'selected="selected" ';
6785
-                else
6786
-                    $selected = '';
6805
+                } else {
6806
+                                    $selected = '';
6807
+                }
6787 6808
 
6788 6809
                 $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>';
6789 6810
             }
@@ -6810,9 +6831,11 @@  discard block
 block discarded – undo
6810 6831
                 $arrHide = array ();
6811 6832
                 for ($i = 0; $i < count($arrLP); $i++) {
6812 6833
                     if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
6813
-                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6814
-                            $s_selected_position = $arrLP[$i]['id'];
6815
-                        elseif ($action == 'add') $s_selected_position = 0;
6834
+                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6835
+                                                    $s_selected_position = $arrLP[$i]['id'];
6836
+                        } elseif ($action == 'add') {
6837
+                            $s_selected_position = 0;
6838
+                        }
6816 6839
                         $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
6817 6840
 
6818 6841
                     }
@@ -7009,9 +7032,11 @@  discard block
 block discarded – undo
7009 7032
             $arrHide = array();
7010 7033
             for ($i = 0; $i < count($arrLP); $i++) {
7011 7034
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7012
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7013
-                        $s_selected_position = $arrLP[$i]['id'];
7014
-                    elseif ($action == 'add') $s_selected_position = 0;
7035
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7036
+                                            $s_selected_position = $arrLP[$i]['id'];
7037
+                    } elseif ($action == 'add') {
7038
+                        $s_selected_position = 0;
7039
+                    }
7015 7040
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7016 7041
                 }
7017 7042
             }
@@ -7214,9 +7239,11 @@  discard block
 block discarded – undo
7214 7239
 
7215 7240
             for ($i = 0; $i < count($arrLP); $i++) {
7216 7241
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7217
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
7218
-                        $s_selected_position = $arrLP[$i]['id'];
7219
-                    elseif ($action == 'add') $s_selected_position = 0;
7242
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7243
+                                            $s_selected_position = $arrLP[$i]['id'];
7244
+                    } elseif ($action == 'add') {
7245
+                        $s_selected_position = 0;
7246
+                    }
7220 7247
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7221 7248
 
7222 7249
                 }
@@ -7250,8 +7277,7 @@  discard block
 block discarded – undo
7250 7277
 
7251 7278
         if (is_numeric($extra_info)) {
7252 7279
             $form->addHidden('path', $extra_info);
7253
-        }
7254
-        elseif (is_array($extra_info)) {
7280
+        } elseif (is_array($extra_info)) {
7255 7281
             $form->addHidden('path', $extra_info['path']);
7256 7282
         }
7257 7283
 
@@ -7304,8 +7330,9 @@  discard block
 block discarded – undo
7304 7330
                     lp_id = " . $this->lp_id . " AND
7305 7331
                     id != $id";
7306 7332
 
7307
-        if ($item_type == 'module')
7308
-            $sql .= " AND parent_item_id = 0";
7333
+        if ($item_type == 'module') {
7334
+                    $sql .= " AND parent_item_id = 0";
7335
+        }
7309 7336
 
7310 7337
         $result = Database::query($sql);
7311 7338
         $arrLP = array ();
@@ -7655,9 +7682,11 @@  discard block
 block discarded – undo
7655 7682
         //POSITION
7656 7683
         for ($i = 0; $i < count($arrLP); $i++) {
7657 7684
             if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
7658
-                if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7685
+                if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7686
+                                    $s_selected_position = $arrLP[$i]['id'];
7687
+                } elseif ($action == 'add') {
7659 7688
                     $s_selected_position = $arrLP[$i]['id'];
7660
-                elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
7689
+                }
7661 7690
                 $arrHide[$arrLP[$i]['id']]['value'] = get_lang('After') . ' "' . $arrLP[$i]['title'] . '"';
7662 7691
             }
7663 7692
         }
@@ -7690,9 +7719,11 @@  discard block
 block discarded – undo
7690 7719
 
7691 7720
             for ($i = 0; $i < count($arrLP); $i++) {
7692 7721
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7693
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7722
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7723
+                                            $s_selected_position = $arrLP[$i]['id'];
7724
+                    } elseif ($action == 'add') {
7694 7725
                         $s_selected_position = $arrLP[$i]['id'];
7695
-                    elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
7726
+                    }
7696 7727
 
7697 7728
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7698 7729
 
@@ -7703,17 +7734,18 @@  discard block
 block discarded – undo
7703 7734
                 $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
7704 7735
                 $edit = isset($_GET['edit']) ? $_GET['edit'] : null;
7705 7736
                 if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $edit == 'true')) {
7706
-                    if (isset ($_POST['content']))
7707
-                        $content = stripslashes($_POST['content']);
7708
-                    elseif (is_array($extra_info)) {
7737
+                    if (isset ($_POST['content'])) {
7738
+                                            $content = stripslashes($_POST['content']);
7739
+                    } elseif (is_array($extra_info)) {
7709 7740
                         //If it's an html document or a text file
7710 7741
                         if (!$no_display_edit_textarea) {
7711 7742
                             $content = $this->display_document($extra_info['path'], false, false);
7712 7743
                         }
7713
-                    } elseif (is_numeric($extra_info))
7714
-                        $content = $this->display_document($extra_info, false, false);
7715
-                    else
7716
-                        $content = '';
7744
+                    } elseif (is_numeric($extra_info)) {
7745
+                                            $content = $this->display_document($extra_info, false, false);
7746
+                    } else {
7747
+                                            $content = '';
7748
+                    }
7717 7749
 
7718 7750
                     if (!$no_display_edit_textarea) {
7719 7751
                         // We need to calculate here some specific settings for the online editor.
@@ -7981,9 +8013,11 @@  discard block
 block discarded – undo
7981 8013
             $arrHide = array();
7982 8014
             for ($i = 0; $i < count($arrLP); $i++) {
7983 8015
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7984
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
7985
-                        $s_selected_position = $arrLP[$i]['id'];
7986
-                    elseif ($action == 'add') $s_selected_position = 0;
8016
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8017
+                                            $s_selected_position = $arrLP[$i]['id'];
8018
+                    } elseif ($action == 'add') {
8019
+                        $s_selected_position = 0;
8020
+                    }
7987 8021
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7988 8022
 
7989 8023
                 }
@@ -8186,9 +8220,11 @@  discard block
 block discarded – undo
8186 8220
             $arrHide = array ();
8187 8221
             for ($i = 0; $i < count($arrLP); $i++) {
8188 8222
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
8189
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8190
-                        $s_selected_position = $arrLP[$i]['id'];
8191
-                    elseif ($action == 'add') $s_selected_position = 0;
8223
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8224
+                                            $s_selected_position = $arrLP[$i]['id'];
8225
+                    } elseif ($action == 'add') {
8226
+                        $s_selected_position = 0;
8227
+                    }
8192 8228
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8193 8229
 
8194 8230
                 }
@@ -9763,9 +9799,9 @@  discard block
 block discarded – undo
9763 9799
         $main_code_path = api_get_path(SYS_CODE_PATH).'newscorm/packaging/';
9764 9800
         $extra_files = scandir($main_code_path);
9765 9801
         foreach ($extra_files as $extra_file) {
9766
-            if (strpos($extra_file, '.') === 0)
9767
-                continue;
9768
-            else {
9802
+            if (strpos($extra_file, '.') === 0) {
9803
+                            continue;
9804
+            } else {
9769 9805
                 $dest_file = $archive_path . $temp_dir_short . '/' . $extra_file;
9770 9806
                 $this->create_path($dest_file);
9771 9807
                 copy($main_code_path.$extra_file, $dest_file);
Please login to merge, or discard this patch.