Completed
Pull Request — 1.11.x (#1215)
by José
45:23
created
plugin/vchamilo/views/editinstance.controller.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,9 @@
 block discarded – undo
2 2
 
3 3
 require_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
4 4
 
5
-if (!defined('CHAMILO_INTERNAL')) die('You cannot use this script this way');
5
+if (!defined('CHAMILO_INTERNAL')) {
6
+    die('You cannot use this script this way');
7
+}
6 8
 
7 9
 if ($data->what == 'addinstance' || $data->what == 'registerinstance') {
8 10
 
Please login to merge, or discard this patch.
plugin/vchamilo/cli/bulkcreatenodes.php 1 patch
Braces   +17 added lines, -5 removed lines patch added patch discarded remove patch
@@ -74,8 +74,14 @@  discard block
 block discarded – undo
74 74
 
75 75
     $content = file($options['config']);
76 76
     foreach($content as $l) {
77
-        if (preg_match('/^\s+$/', $l)) continue; // Empty lines.
78
-        if (preg_match('/^[#\/!;]/', $l)) continue; // Comments (any form).
77
+        if (preg_match('/^\s+$/', $l)) {
78
+            continue;
79
+        }
80
+        // Empty lines.
81
+        if (preg_match('/^[#\/!;]/', $l)) {
82
+            continue;
83
+        }
84
+        // Comments (any form).
79 85
         if (preg_match('/^(.*?)=(.*)$/', $l, $matches)) {
80 86
             if (in_array($matches[1], $expectedoptions)){
81 87
                 $options[trim($matches[1])] = trim($matches[2]);
@@ -90,16 +96,22 @@  discard block
 block discarded – undo
90 96
 require_once($_configuration['root_sys'] . '/plugin/vchamilo/lib/vchamilo_plugin.class.php');
91 97
 
92 98
 global $DB;
93
-if ($options['verbose']) echo "building database manager\n";
99
+if ($options['verbose']) {
100
+    echo "building database manager\n";
101
+}
94 102
 $DB = new DatabaseManager();
95
-if ($options['verbose']) echo "building plugin vchamilo\n";
103
+if ($options['verbose']) {
104
+    echo "building plugin vchamilo\n";
105
+}
96 106
 $plugininstance = VChamiloPlugin::create();
97 107
 
98 108
 if (empty($options['nodes'])) {
99 109
     cli_error('Missing node definition. Halt.');
100 110
 }
101 111
 
102
-if ($options['verbose']) echo "parsing nodelist\n";
112
+if ($options['verbose']) {
113
+    echo "parsing nodelist\n";
114
+}
103 115
 $nodes = vchamilo_parse_csv_nodelist($options['nodes'], $plugininstance);
104 116
 
105 117
 if ($options['lint']) {
Please login to merge, or discard this patch.
plugin/vchamilo/cli/clilib.php 1 patch
Braces   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,7 +133,9 @@  discard block
 block discarded – undo
133 133
             $key = $headers[$f];
134 134
             if (preg_match('/\|/', $key)) {
135 135
                 list($plugin, $variable) = explode('|', str_replace('plugin_', '', $key));
136
-                if (empty($variable)) die("Key error in CSV : $key ");
136
+                if (empty($variable)) {
137
+                    die("Key error in CSV : $key ");
138
+                }
137 139
                 if (!isset($vnode->$plugin)) {
138 140
                     $vnode->$plugin = new StdClass();
139 141
                 }
@@ -170,8 +172,13 @@  discard block
 block discarded – undo
170 172
     static $first = true;
171 173
 
172 174
     // We may have a risk the BOM is present on first line
173
-    if ($resetfirst) $first = true;
174
-    if (!isset($textlib)) $textlib = new textlib(); // Singleton
175
+    if ($resetfirst) {
176
+        $first = true;
177
+    }
178
+    if (!isset($textlib)) {
179
+        $textlib = new textlib();
180
+    }
181
+    // Singleton
175 182
     $text = $textlib->trim_utf8_bom($text);
176 183
     $first = false;
177 184
 
Please login to merge, or discard this patch.
plugin/vchamilo/cli/bulkdestroynodes.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -91,25 +91,39 @@
 block discarded – undo
91 91
 }
92 92
 
93 93
 require_once($_configuration['root_sys'].'local/classes/database.class.php');       // cli only functions
94
-if ($options['verbose']) echo "loaded dbclass\n";
94
+if ($options['verbose']) {
95
+    echo "loaded dbclass\n";
96
+}
95 97
 require_once($_configuration['root_sys'].'local/classes/textlib.class.php');       // cli only functions
96
-if ($options['verbose']) echo "loaded textlib\n";
98
+if ($options['verbose']) {
99
+    echo "loaded textlib\n";
100
+}
97 101
 require_once($_configuration['root_sys'].'local/classes/mootochamlib.php');       // moodle like API
98
-if ($options['verbose']) echo "loaded moodle wrapping\n";
102
+if ($options['verbose']) {
103
+    echo "loaded moodle wrapping\n";
104
+}
99 105
 require_once($_configuration['root_sys'] . '/plugin/vchamilo/lib/vchamilo_plugin.class.php');
100
-if ($options['verbose']) echo "loaded vchamilo plugin\n";
106
+if ($options['verbose']) {
107
+    echo "loaded vchamilo plugin\n";
108
+}
101 109
 
102 110
 global $DB;
103
-if ($options['verbose']) echo "building database manager\n";
111
+if ($options['verbose']) {
112
+    echo "building database manager\n";
113
+}
104 114
 $DB = new DatabaseManager();
105
-if ($options['verbose']) echo "building plugin vchamilo\n";
115
+if ($options['verbose']) {
116
+    echo "building plugin vchamilo\n";
117
+}
106 118
 $plugininstance = VChamiloPlugin::create();
107 119
 
108 120
 if (empty($options['nodes'])) {
109 121
     cli_error(get_string('climissingnodes', 'block_vmoodle'));
110 122
 }
111 123
 
112
-if ($options['verbose']) echo "parsing nodelist\n";
124
+if ($options['verbose']) {
125
+    echo "parsing nodelist\n";
126
+}
113 127
 $nodes = vchamilo_parse_csv_nodelist($options['nodes'], $plugininstance);
114 128
 
115 129
 if ($options['lint']) {
Please login to merge, or discard this patch.
main/newscorm/learnpath.class.php 1 patch
Braces   +107 added lines, -74 removed lines patch added patch discarded remove patch
@@ -3944,8 +3944,9 @@  discard block
 block discarded – undo
3944 3944
                 WHERE c_id = ".$course_id."
3945 3945
                 ORDER BY display_order";
3946 3946
         $res = Database::query($sql);
3947
-        if ($res === false)
3948
-            return false;
3947
+        if ($res === false) {
3948
+                    return false;
3949
+        }
3949 3950
         $lps = array ();
3950 3951
         $lp_order = array ();
3951 3952
         $num = Database :: num_rows($res);
@@ -4545,8 +4546,9 @@  discard block
 block discarded – undo
4545 4546
         if ($this->debug > 0) {
4546 4547
             error_log('New LP - In learnpath::set_maker()', 0);
4547 4548
         }
4548
-        if (empty ($name))
4549
-            return false;
4549
+        if (empty ($name)) {
4550
+                    return false;
4551
+        }
4550 4552
         $this->maker = $name;
4551 4553
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
4552 4554
         $course_id = api_get_course_int_id();
@@ -4611,8 +4613,9 @@  discard block
 block discarded – undo
4611 4613
     public function set_terms_by_prefix($terms_string, $prefix)
4612 4614
     {
4613 4615
         $course_id = api_get_course_int_id();
4614
-        if (api_get_setting('search_enabled') !== 'true')
4615
-            return false;
4616
+        if (api_get_setting('search_enabled') !== 'true') {
4617
+                    return false;
4618
+        }
4616 4619
 
4617 4620
         if (!extension_loaded('xapian')) {
4618 4621
             return false;
@@ -4625,8 +4628,9 @@  discard block
 block discarded – undo
4625 4628
         $stored_terms = $this->get_common_index_terms_by_prefix($prefix);
4626 4629
 
4627 4630
         // Don't do anything if no change, verify only at DB, not the search engine.
4628
-        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0))
4629
-            return false;
4631
+        if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) {
4632
+                    return false;
4633
+        }
4630 4634
 
4631 4635
         require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API.
4632 4636
         require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
@@ -4818,8 +4822,9 @@  discard block
 block discarded – undo
4818 4822
         if ($this->debug > 0) {
4819 4823
             error_log('New LP - In learnpath::set_proximity()', 0);
4820 4824
         }
4821
-        if (empty ($name))
4822
-            return false;
4825
+        if (empty ($name)) {
4826
+                    return false;
4827
+        }
4823 4828
 
4824 4829
         $this->proximity = $name;
4825 4830
         $lp_table = Database :: get_course_table(TABLE_LP_MAIN);
@@ -5163,8 +5168,9 @@  discard block
 block discarded – undo
5163 5168
 
5164 5169
         $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order";
5165 5170
         $res = Database::query($sql);
5166
-        if ($res === false)
5167
-            return false;
5171
+        if ($res === false) {
5172
+                    return false;
5173
+        }
5168 5174
 
5169 5175
         $num = Database :: num_rows($res);
5170 5176
         // First check the order is correct, globally (might be wrong because
@@ -5475,8 +5481,9 @@  discard block
 block discarded – undo
5475 5481
             $position[$key] = $row['display_order'];
5476 5482
         }
5477 5483
 
5478
-        if (count($array) > 0)
5479
-            array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5484
+        if (count($array) > 0) {
5485
+                    array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array);
5486
+        }
5480 5487
 
5481 5488
         return $array;
5482 5489
     }
@@ -6190,10 +6197,12 @@  discard block
 block discarded – undo
6190 6197
                     if ($new_comment || $new_title) {
6191 6198
                         $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
6192 6199
                         $ct = '';
6193
-                        if ($new_comment)
6194
-                            $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6195
-                        if ($new_title)
6196
-                            $ct .= ", title='" . Database::escape_string($new_title)."' ";
6200
+                        if ($new_comment) {
6201
+                                                    $ct .= ", comment='" . Database::escape_string($new_comment). "'";
6202
+                        }
6203
+                        if ($new_title) {
6204
+                                                    $ct .= ", title='" . Database::escape_string($new_title)."' ";
6205
+                        }
6197 6206
 
6198 6207
                         $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)."
6199 6208
                                WHERE c_id = ".$course_id." AND id = " . $document_id;
@@ -6217,17 +6226,21 @@  discard block
 block discarded – undo
6217 6226
         // Please, do not modify this dirname formatting.
6218 6227
         $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir'];
6219 6228
 
6220
-        if (strstr($dir, '..'))
6221
-            $dir = '/';
6229
+        if (strstr($dir, '..')) {
6230
+                    $dir = '/';
6231
+        }
6222 6232
 
6223
-        if ($dir[0] == '.')
6224
-            $dir = substr($dir, 1);
6233
+        if ($dir[0] == '.') {
6234
+                    $dir = substr($dir, 1);
6235
+        }
6225 6236
 
6226
-        if ($dir[0] != '/')
6227
-            $dir = '/' . $dir;
6237
+        if ($dir[0] != '/') {
6238
+                    $dir = '/' . $dir;
6239
+        }
6228 6240
 
6229
-        if ($dir[strlen($dir) - 1] != '/')
6230
-            $dir .= '/';
6241
+        if ($dir[strlen($dir) - 1] != '/') {
6242
+                    $dir .= '/';
6243
+        }
6231 6244
 
6232 6245
         $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
6233 6246
 
@@ -6292,8 +6305,9 @@  discard block
 block discarded – undo
6292 6305
                 }
6293 6306
                 $return .= '<div style="padding:10px;">';
6294 6307
 
6295
-                if ($msg != '')
6296
-                    $return .= $msg;
6308
+                if ($msg != '') {
6309
+                                    $return .= $msg;
6310
+                }
6297 6311
 
6298 6312
                 $return .= '<h3>'.$row['title'].'</h3>';
6299 6313
                 switch ($row['item_type']) {
@@ -6563,10 +6577,11 @@  discard block
 block discarded – undo
6563 6577
         $item_title			= Security::remove_XSS($item_title);
6564 6578
         $item_description 	= Security::remove_XSS($item_description);
6565 6579
 
6566
-        if ($id != 0 && is_array($extra_info))
6567
-            $parent = $extra_info['parent_item_id'];
6568
-        else
6569
-            $parent = 0;
6580
+        if ($id != 0 && is_array($extra_info)) {
6581
+                    $parent = $extra_info['parent_item_id'];
6582
+        } else {
6583
+                    $parent = 0;
6584
+        }
6570 6585
 
6571 6586
         $sql = "SELECT * FROM " . $tbl_lp_item . "
6572 6587
                 WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
@@ -6839,11 +6854,13 @@  discard block
 block discarded – undo
6839 6854
         }
6840 6855
 
6841 6856
         $legend = '<legend>';
6842
-        if ($action == 'add')
6843
-            $legend .= get_lang('CreateTheExercise');
6844
-        elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise');
6845
-        else
6846
-            $legend .= get_lang('EditCurrentExecice');
6857
+        if ($action == 'add') {
6858
+                    $legend .= get_lang('CreateTheExercise');
6859
+        } elseif ($action == 'move') {
6860
+            $legend .= get_lang('MoveTheCurrentExercise');
6861
+        } else {
6862
+                    $legend .= get_lang('EditCurrentExecice');
6863
+        }
6847 6864
         if (isset ($_GET['edit']) && $_GET['edit'] == 'true') {
6848 6865
             $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument'));
6849 6866
         }
@@ -6870,8 +6887,9 @@  discard block
 block discarded – undo
6870 6887
                         $arrHide[] = $arrLP[$i]['id'];
6871 6888
                     }
6872 6889
                 } else {
6873
-                    if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
6874
-                        $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6890
+                    if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
6891
+                                            $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>';
6892
+                    }
6875 6893
                 }
6876 6894
             }
6877 6895
 
@@ -6889,11 +6907,13 @@  discard block
 block discarded – undo
6889 6907
 
6890 6908
         for ($i = 0; $i < count($arrLP); $i++) {
6891 6909
             if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
6892
-                if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6910
+                if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6911
+                                    $selected = 'selected="selected" ';
6912
+                } elseif ($action == 'add') {
6893 6913
                     $selected = 'selected="selected" ';
6894
-                elseif ($action == 'add') $selected = 'selected="selected" ';
6895
-                else
6896
-                    $selected = '';
6914
+                } else {
6915
+                                    $selected = '';
6916
+                }
6897 6917
 
6898 6918
                 $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>';
6899 6919
             }
@@ -6920,9 +6940,11 @@  discard block
 block discarded – undo
6920 6940
                 $arrHide = array ();
6921 6941
                 for ($i = 0; $i < count($arrLP); $i++) {
6922 6942
                     if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
6923
-                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
6924
-                            $s_selected_position = $arrLP[$i]['id'];
6925
-                        elseif ($action == 'add') $s_selected_position = 0;
6943
+                        if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
6944
+                                                    $s_selected_position = $arrLP[$i]['id'];
6945
+                        } elseif ($action == 'add') {
6946
+                            $s_selected_position = 0;
6947
+                        }
6926 6948
                         $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
6927 6949
 
6928 6950
                     }
@@ -7119,9 +7141,11 @@  discard block
 block discarded – undo
7119 7141
             $arrHide = array();
7120 7142
             for ($i = 0; $i < count($arrLP); $i++) {
7121 7143
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7122
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7123
-                        $s_selected_position = $arrLP[$i]['id'];
7124
-                    elseif ($action == 'add') $s_selected_position = 0;
7144
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7145
+                                            $s_selected_position = $arrLP[$i]['id'];
7146
+                    } elseif ($action == 'add') {
7147
+                        $s_selected_position = 0;
7148
+                    }
7125 7149
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7126 7150
                 }
7127 7151
             }
@@ -7324,9 +7348,11 @@  discard block
 block discarded – undo
7324 7348
 
7325 7349
             for ($i = 0; $i < count($arrLP); $i++) {
7326 7350
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
7327
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
7328
-                        $s_selected_position = $arrLP[$i]['id'];
7329
-                    elseif ($action == 'add') $s_selected_position = 0;
7351
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7352
+                                            $s_selected_position = $arrLP[$i]['id'];
7353
+                    } elseif ($action == 'add') {
7354
+                        $s_selected_position = 0;
7355
+                    }
7330 7356
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7331 7357
 
7332 7358
                 }
@@ -7360,8 +7386,7 @@  discard block
 block discarded – undo
7360 7386
 
7361 7387
         if (is_numeric($extra_info)) {
7362 7388
             $form->addHidden('path', $extra_info);
7363
-        }
7364
-        elseif (is_array($extra_info)) {
7389
+        } elseif (is_array($extra_info)) {
7365 7390
             $form->addHidden('path', $extra_info['path']);
7366 7391
         }
7367 7392
 
@@ -7414,8 +7439,9 @@  discard block
 block discarded – undo
7414 7439
                     lp_id = " . $this->lp_id . " AND
7415 7440
                     id != $id";
7416 7441
 
7417
-        if ($item_type == 'module')
7418
-            $sql .= " AND parent_item_id = 0";
7442
+        if ($item_type == 'module') {
7443
+                    $sql .= " AND parent_item_id = 0";
7444
+        }
7419 7445
 
7420 7446
         $result = Database::query($sql);
7421 7447
         $arrLP = array ();
@@ -7820,9 +7846,11 @@  discard block
 block discarded – undo
7820 7846
             $arrHide = array();
7821 7847
             for ($i = 0; $i < count($arrLP); $i++) {
7822 7848
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) {
7823
-                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id'])
7849
+                    if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
7850
+                                            $s_selected_position = $arrLP[$i]['id'];
7851
+                    } elseif ($action == 'add') {
7824 7852
                         $s_selected_position = $arrLP[$i]['id'];
7825
-                    elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id'];
7853
+                    }
7826 7854
 
7827 7855
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
7828 7856
 
@@ -7833,17 +7861,18 @@  discard block
 block discarded – undo
7833 7861
                 $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null;
7834 7862
                 $edit = isset($_GET['edit']) ? $_GET['edit'] : null;
7835 7863
                 if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) {
7836
-                    if (isset ($_POST['content']))
7837
-                        $content = stripslashes($_POST['content']);
7838
-                    elseif (is_array($extra_info)) {
7864
+                    if (isset ($_POST['content'])) {
7865
+                                            $content = stripslashes($_POST['content']);
7866
+                    } elseif (is_array($extra_info)) {
7839 7867
                         //If it's an html document or a text file
7840 7868
                         if (!$no_display_edit_textarea) {
7841 7869
                             $content = $this->display_document($extra_info['path'], false, false);
7842 7870
                         }
7843
-                    } elseif (is_numeric($extra_info))
7844
-                        $content = $this->display_document($extra_info, false, false);
7845
-                    else
7846
-                        $content = '';
7871
+                    } elseif (is_numeric($extra_info)) {
7872
+                                            $content = $this->display_document($extra_info, false, false);
7873
+                    } else {
7874
+                                            $content = '';
7875
+                    }
7847 7876
 
7848 7877
                     if (!$no_display_edit_textarea) {
7849 7878
                         // We need to calculate here some specific settings for the online editor.
@@ -8111,9 +8140,11 @@  discard block
 block discarded – undo
8111 8140
             $arrHide = array();
8112 8141
             for ($i = 0; $i < count($arrLP); $i++) {
8113 8142
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
8114
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8115
-                        $s_selected_position = $arrLP[$i]['id'];
8116
-                    elseif ($action == 'add') $s_selected_position = 0;
8143
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8144
+                                            $s_selected_position = $arrLP[$i]['id'];
8145
+                    } elseif ($action == 'add') {
8146
+                        $s_selected_position = 0;
8147
+                    }
8117 8148
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8118 8149
 
8119 8150
                 }
@@ -8316,9 +8347,11 @@  discard block
 block discarded – undo
8316 8347
             $arrHide = array ();
8317 8348
             for ($i = 0; $i < count($arrLP); $i++) {
8318 8349
                 if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') {
8319
-                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id'])
8320
-                        $s_selected_position = $arrLP[$i]['id'];
8321
-                    elseif ($action == 'add') $s_selected_position = 0;
8350
+                    if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) {
8351
+                                            $s_selected_position = $arrLP[$i]['id'];
8352
+                    } elseif ($action == 'add') {
8353
+                        $s_selected_position = 0;
8354
+                    }
8322 8355
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
8323 8356
 
8324 8357
                 }
@@ -9998,9 +10031,9 @@  discard block
 block discarded – undo
9998 10031
         $main_code_path = api_get_path(SYS_CODE_PATH).'newscorm/packaging/';
9999 10032
         $extra_files = scandir($main_code_path);
10000 10033
         foreach ($extra_files as $extra_file) {
10001
-            if (strpos($extra_file, '.') === 0)
10002
-                continue;
10003
-            else {
10034
+            if (strpos($extra_file, '.') === 0) {
10035
+                            continue;
10036
+            } else {
10004 10037
                 $dest_file = $archive_path . $temp_dir_short . '/' . $extra_file;
10005 10038
                 $this->create_path($dest_file);
10006 10039
                 copy($main_code_path.$extra_file, $dest_file);
Please login to merge, or discard this patch.
main/auth/external_login/functions.inc.php 1 patch
Braces   +37 added lines, -24 removed lines patch added patch discarded remove patch
@@ -95,30 +95,43 @@
 block discarded – undo
95 95
  * */
96 96
 function external_add_user($u) {
97 97
     //Setting default
98
-    if (empty($u['password']))
99
-        $u['password'] = null;
100
-    if (empty($u['status']))
101
-        $u['status'] = 5;
102
-    if (!isset($u['official_code']))
103
-        $u['official_code'] = '';
104
-    if (!isset($u['language']))
105
-        $u['language'] = '';
106
-    if (!isset($u['phone']))
107
-        $u['phone'] = '';
108
-    if (!isset($u['picture_uri']))
109
-        $u['picture_uri'] = '';
110
-    if (!isset($u['auth_source']))
111
-        $u['auth_source'] = PLATFORM_AUTH_SOURCE;
112
-    if (!isset($u['expiration_date']))
113
-        $u['expiration_date'] = '';
114
-    if (!isset($u['active']))
115
-        $u['active'] = 1;
116
-    if (!isset($u['hr_dept_id']))
117
-        $u['hr_dept_id'] = 0; //id of responsible HR
118
-    if (!isset($u['extra']))
119
-        $u['extra'] = null;
120
-    if (!isset($u['encrypt_method']))
121
-        $u['encrypt_method'] = '';
98
+    if (empty($u['password'])) {
99
+            $u['password'] = null;
100
+    }
101
+    if (empty($u['status'])) {
102
+            $u['status'] = 5;
103
+    }
104
+    if (!isset($u['official_code'])) {
105
+            $u['official_code'] = '';
106
+    }
107
+    if (!isset($u['language'])) {
108
+            $u['language'] = '';
109
+    }
110
+    if (!isset($u['phone'])) {
111
+            $u['phone'] = '';
112
+    }
113
+    if (!isset($u['picture_uri'])) {
114
+            $u['picture_uri'] = '';
115
+    }
116
+    if (!isset($u['auth_source'])) {
117
+            $u['auth_source'] = PLATFORM_AUTH_SOURCE;
118
+    }
119
+    if (!isset($u['expiration_date'])) {
120
+            $u['expiration_date'] = '';
121
+    }
122
+    if (!isset($u['active'])) {
123
+            $u['active'] = 1;
124
+    }
125
+    if (!isset($u['hr_dept_id'])) {
126
+            $u['hr_dept_id'] = 0;
127
+    }
128
+    //id of responsible HR
129
+    if (!isset($u['extra'])) {
130
+            $u['extra'] = null;
131
+    }
132
+    if (!isset($u['encrypt_method'])) {
133
+            $u['encrypt_method'] = '';
134
+    }
122 135
 
123 136
     $chamilo_uid = UserManager::create_user($u['firstname'], $u['lastname'], $u['status'], $u['email'], $u['username'], $u['password'], $u['official_code'], $u['language'], $u['phone'], $u['picture_uri'], $u['auth_source'], $u['expiration_date'], $u['active'], $u['hr_dept_id'], $u['extra'], $u['encrypt_method']);
124 137
     return $chamilo_uid;
Please login to merge, or discard this patch.
main/newscorm/lp_controller.php 1 patch
Braces   +230 added lines, -116 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'])) {
@@ -231,10 +233,14 @@  discard block
 block discarded – undo
231 233
     // If refresh is set, we regenerate the oLP object from the database (kind of flush).
232 234
     Session::erase('refresh');
233 235
     $myrefresh = 1;
234
-    if ($debug > 0) error_log('New LP - Refresh asked', 0);
235
-}
236
+    if ($debug > 0) {
237
+        error_log('New LP - Refresh asked', 0);
238
+    }
239
+    }
236 240
 
237
-if ($debug > 0) error_log('New LP - Passed refresh check', 0);
241
+if ($debug > 0) {
242
+    error_log('New LP - Passed refresh check', 0);
243
+}
238 244
 
239 245
 if (!empty($_REQUEST['dialog_box'])) {
240 246
     $dialog_box = stripslashes(urldecode($_REQUEST['dialog_box']));
@@ -244,17 +250,23 @@  discard block
 block discarded – undo
244 250
 $lp_found = false;
245 251
 
246 252
 if (isset($_SESSION['lpobject'])) {
247
-    if ($debug > 0) error_log('New LP - SESSION[lpobject] is defined', 0);
253
+    if ($debug > 0) {
254
+        error_log('New LP - SESSION[lpobject] is defined', 0);
255
+    }
248 256
     $oLP = unserialize($_SESSION['lpobject']);
249 257
     if (isset($oLP) && is_object($oLP)) {
250
-        if ($debug > 0) error_log('New LP - oLP is object', 0);
258
+        if ($debug > 0) {
259
+            error_log('New LP - oLP is object', 0);
260
+        }
251 261
         if ($myrefresh == 1 OR
252 262
             empty($oLP->cc) OR
253 263
             $oLP->cc != api_get_course_id() OR
254 264
             $oLP->lp_view_session_id != $session_id OR
255 265
             $oLP->scorm_debug == '1'
256 266
         ) {
257
-            if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0);
267
+            if ($debug > 0) {
268
+                error_log('New LP - Course has changed, discard lp object', 0);
269
+            }
258 270
             if ($myrefresh == 1) { $myrefresh_id = $oLP->get_id(); }
259 271
             $oLP = null;
260 272
             Session::erase('oLP');
@@ -268,13 +280,19 @@  discard block
 block discarded – undo
268 280
 
269 281
 $course_id = api_get_course_int_id();
270 282
 
271
-if ($debug>0) error_log('New LP - Passed data remains check', 0);
283
+if ($debug>0) {
284
+    error_log('New LP - Passed data remains check', 0);
285
+}
272 286
 
273 287
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
274
-    if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
288
+    if ($debug > 0) {
289
+        error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
290
+    }
275 291
     // Regenerate a new lp object? Not always as some pages don't need the object (like upload?)
276 292
     if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) {
277
-        if ($debug > 0) error_log('New LP - lp_id is defined', 0);
293
+        if ($debug > 0) {
294
+            error_log('New LP - lp_id is defined', 0);
295
+        }
278 296
         // Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
279 297
         // right object.
280 298
         if (!empty($_REQUEST['lp_id'])) {
@@ -286,49 +304,67 @@  discard block
 block discarded – undo
286 304
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
287 305
         if (is_numeric($lp_id)) {
288 306
             $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
289
-            if ($debug > 0) error_log('New LP - querying '.$sel, 0);
307
+            if ($debug > 0) {
308
+                error_log('New LP - querying '.$sel, 0);
309
+            }
290 310
             $res = Database::query($sel);
291 311
 
292 312
             if (Database::num_rows($res)) {
293 313
                 $row = Database::fetch_array($res);
294 314
                 $type = $row['lp_type'];
295
-                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);
315
+                if ($debug > 0) {
316
+                    error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
317
+                }
296 318
                 switch ($type) {
297 319
                     case 1:
298
-                        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);
320
+                        if ($debug > 0) {
321
+                            error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
322
+                        }
299 323
 
300 324
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
301 325
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
302 326
                         break;
303 327
                     case 2:
304
-                        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);
328
+                        if ($debug > 0) {
329
+                            error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
330
+                        }
305 331
                         $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id());
306 332
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
307 333
                         break;
308 334
                     case 3:
309
-                        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);
335
+                        if ($debug > 0) {
336
+                            error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
337
+                        }
310 338
                         $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id());
311 339
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
312 340
                         break;
313 341
                     default:
314
-                        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);
342
+                        if ($debug > 0) {
343
+                            error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
344
+                        }
315 345
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
316 346
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
317 347
                         break;
318 348
                 }
319 349
             }
320 350
         } else {
321
-            if ($debug > 0) error_log('New LP - Request[lp_id] is not numeric', 0);
351
+            if ($debug > 0) {
352
+                error_log('New LP - Request[lp_id] is not numeric', 0);
353
+            }
322 354
         }
323 355
     } else {
324
-        if ($debug > 0) error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
356
+        if ($debug > 0) {
357
+            error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
358
+        }
325 359
     }
326 360
     if ($lp_found) {
327 361
         $_SESSION['oLP'] = $oLP;
328 362
     }
329 363
 }
330 364
 
331
-if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
365
+if ($debug > 0) {
366
+    error_log('New LP - Passed oLP creation check', 0);
367
+}
332 368
 
333 369
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
334 370
 
@@ -372,11 +408,15 @@  discard block
 block discarded – undo
372 408
         if (!$is_allowed_to_edit) {
373 409
             api_not_allowed(true);
374 410
         }
375
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
411
+        if ($debug > 0) {
412
+            error_log('New LP - add item action triggered', 0);
413
+        }
376 414
 
377 415
         if (!$lp_found) {
378 416
             //check if the learnpath ID was defined, otherwise send back to list
379
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
417
+            if ($debug > 0) {
418
+                error_log('New LP - No learnpath given for add item', 0);
419
+            }
380 420
             require 'lp_list.php';
381 421
         } else {
382 422
             $_SESSION['refresh'] = 1;
@@ -465,11 +505,15 @@  discard block
 block discarded – undo
465 505
             api_not_allowed(true);
466 506
         }
467 507
 
468
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
508
+        if ($debug > 0) {
509
+            error_log('New LP - add audio action triggered', 0);
510
+        }
469 511
 
470 512
         if (!$lp_found) {
471 513
             //check if the learnpath ID was defined, otherwise send back to list
472
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
514
+            if ($debug > 0) {
515
+                error_log('New LP - No learnpath given for add audio', 0);
516
+            }
473 517
             require 'lp_list.php';
474 518
         } else {
475 519
             $_SESSION['refresh'] = 1;
@@ -543,7 +587,9 @@  discard block
 block discarded – undo
543 587
         if (!$is_allowed_to_edit) {
544 588
             api_not_allowed(true);
545 589
         }
546
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
590
+        if ($debug > 0) {
591
+            error_log('New LP - add_lp action triggered', 0);
592
+        }
547 593
         if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
548 594
             $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
549 595
             $_SESSION['refresh'] = 1;
@@ -602,7 +648,9 @@  discard block
 block discarded – undo
602 648
         if (!$is_allowed_to_edit) {
603 649
             api_not_allowed(true);
604 650
         }
605
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
651
+        if ($debug > 0) {
652
+            error_log('New LP - admin_view action triggered', 0);
653
+        }
606 654
         if (!$lp_found) {
607 655
             error_log('New LP - No learnpath given for admin_view', 0);
608 656
             require 'lp_list.php';
@@ -616,9 +664,10 @@  discard block
 block discarded – undo
616 664
             if (!$is_allowed_to_edit) {
617 665
                 api_not_allowed(true);
618 666
             }
619
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
620
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
621
-            else {
667
+            if ($debug > 0) {
668
+                error_log('New LP - auto_launch action triggered', 0);
669
+            }
670
+            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } else {
622 671
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
623 672
                 require 'lp_list.php';
624 673
                 exit;
@@ -629,10 +678,11 @@  discard block
 block discarded – undo
629 678
         if (!$is_allowed_to_edit) {
630 679
             api_not_allowed(true);
631 680
         }
632
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
681
+        if ($debug > 0) {
682
+            error_log('New LP - build action triggered', 0);
683
+        }
633 684
 
634
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
635
-        else {
685
+        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } else {
636 686
             $_SESSION['refresh'] = 1;
637 687
             //require 'lp_build.php';
638 688
             $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
@@ -644,7 +694,9 @@  discard block
 block discarded – undo
644 694
         if (!$is_allowed_to_edit) {
645 695
             api_not_allowed(true);
646 696
         }
647
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
697
+        if ($debug > 0) {
698
+            error_log('New LP - edit item action triggered', 0);
699
+        }
648 700
 
649 701
         if (!$lp_found) {
650 702
             error_log('New LP - No learnpath given for edit item', 0);
@@ -699,9 +751,10 @@  discard block
 block discarded – undo
699 751
         if (!$is_allowed_to_edit) {
700 752
             api_not_allowed(true);
701 753
         }
702
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
703
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
704
-        else {
754
+        if ($debug > 0) {
755
+            error_log('New LP - edit item prereq action triggered', 0);
756
+        }
757
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
705 758
             if (isset($_POST['submit_button'])) {
706 759
                 //Updating the lp.modified_on
707 760
                 $_SESSION['oLP']->set_modified_on();
@@ -729,9 +782,10 @@  discard block
 block discarded – undo
729 782
         if (!$is_allowed_to_edit) {
730 783
             api_not_allowed(true);
731 784
         }
732
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
733
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
734
-        else {
785
+        if ($debug > 0) {
786
+            error_log('New LP - move item action triggered', 0);
787
+        }
788
+        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } else {
735 789
             $_SESSION['refresh'] = 1;
736 790
             if (isset($_POST['submit_button'])) {
737 791
                 //Updating the lp.modified_on
@@ -764,7 +818,9 @@  discard block
 block discarded – undo
764 818
         if (!$is_allowed_to_edit) {
765 819
             api_not_allowed(true);
766 820
         }
767
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
821
+        if ($debug > 0) {
822
+            error_log('New LP - view_item action triggered', 0);
823
+        }
768 824
         if (!$lp_found) {
769 825
             error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
770 826
         } else {
@@ -776,7 +832,9 @@  discard block
 block discarded – undo
776 832
         if (!$is_allowed_to_edit) {
777 833
             api_not_allowed(true);
778 834
         }
779
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
835
+        if ($debug > 0) {
836
+            error_log('New LP - upload action triggered', 0);
837
+        }
780 838
         $cwdir = getcwd();
781 839
         require 'lp_upload.php';
782 840
         // Reinit current working directory as many functions in upload change it.
@@ -793,9 +851,10 @@  discard block
 block discarded – undo
793 851
             api_not_allowed(true);
794 852
         }
795 853
 
796
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
797
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
798
-        else {
854
+        if ($debug > 0) {
855
+            error_log('New LP - export action triggered', 0);
856
+        }
857
+        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } else {
799 858
             $_SESSION['oLP']->copy();
800 859
         }
801 860
         require 'lp_list.php';
@@ -808,9 +867,10 @@  discard block
 block discarded – undo
808 867
         if ($hideScormExportLink === 'true') {
809 868
             api_not_allowed(true);
810 869
         }
811
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
812
-        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; }
813
-        else {
870
+        if ($debug > 0) {
871
+            error_log('New LP - export action triggered', 0);
872
+        }
873
+        if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; } else {
814 874
             $_SESSION['oLP']->scorm_export();
815 875
             exit();
816 876
             //require 'lp_list.php';
@@ -825,7 +885,9 @@  discard block
 block discarded – undo
825 885
             api_not_allowed(true);
826 886
         }
827 887
 
828
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
888
+        if ($debug > 0) {
889
+            error_log('New LP - export action triggered', 0);
890
+        }
829 891
         if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
830 892
         } else {
831 893
             $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
@@ -839,9 +901,10 @@  discard block
 block discarded – undo
839 901
         if (!$is_allowed_to_edit) {
840 902
             api_not_allowed(true);
841 903
         }
842
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
843
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
844
-        else {
904
+        if ($debug > 0) {
905
+            error_log('New LP - delete action triggered', 0);
906
+        }
907
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } else {
845 908
             $_SESSION['refresh'] = 1;
846 909
             $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
847 910
             Session::erase('oLP');
@@ -853,9 +916,10 @@  discard block
 block discarded – undo
853 916
         if (!$is_allowed_to_edit) {
854 917
             api_not_allowed(true);
855 918
         }
856
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
857
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
858
-        else {
919
+        if ($debug > 0) {
920
+            error_log('New LP - visibility action triggered', 0);
921
+        }
922
+        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } else {
859 923
             learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
860 924
             require 'lp_list.php';
861 925
         }
@@ -865,9 +929,10 @@  discard block
 block discarded – undo
865 929
         if (!$is_allowed_to_edit) {
866 930
             api_not_allowed(true);
867 931
         }
868
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
869
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
870
-        else {
932
+        if ($debug > 0) {
933
+            error_log('New LP - publish action triggered', 0);
934
+        }
935
+        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } else {
871 936
             learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
872 937
             require 'lp_list.php';
873 938
         }
@@ -877,7 +942,9 @@  discard block
 block discarded – undo
877 942
         if (!$is_allowed_to_edit) {
878 943
             api_not_allowed(true);
879 944
         }
880
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
945
+        if ($debug > 0) {
946
+            error_log('New LP - publish action triggered', 0);
947
+        }
881 948
         if (!$lp_found) {
882 949
             error_log('New LP - No learnpath given for publish', 0);
883 950
             require 'lp_list.php';
@@ -891,7 +958,9 @@  discard block
 block discarded – undo
891 958
         if (!$is_allowed_to_edit) {
892 959
             api_not_allowed(true);
893 960
         }
894
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
961
+        if ($debug > 0) {
962
+            error_log('New LP - publish action triggered', 0);
963
+        }
895 964
         if (!$lp_found) {
896 965
             error_log('New LP - No learnpath given for publish', 0);
897 966
             require 'lp_list.php';
@@ -904,9 +973,10 @@  discard block
 block discarded – undo
904 973
         if (!$is_allowed_to_edit) {
905 974
             api_not_allowed(true);
906 975
         }
907
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
908
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
909
-        else {
976
+        if ($debug > 0) {
977
+            error_log('New LP - edit action triggered', 0);
978
+        }
979
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
910 980
             $_SESSION['refresh'] = 1;
911 981
             require 'lp_edit.php';
912 982
         }
@@ -915,9 +985,10 @@  discard block
 block discarded – undo
915 985
         if (!$is_allowed_to_edit) {
916 986
             api_not_allowed(true);
917 987
         }
918
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
919
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
920
-        else {
988
+        if ($debug > 0) {
989
+            error_log('New LP - update_lp action triggered', 0);
990
+        }
991
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
921 992
             $_SESSION['refresh'] = 1;
922 993
             $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
923 994
             $_SESSION['oLP']->set_name($lp_name);
@@ -987,8 +1058,9 @@  discard block
 block discarded – undo
987 1058
             );
988 1059
             $extraFieldValue->saveFieldValues($_REQUEST);
989 1060
 
990
-            if ($_FILES['lp_preview_image']['size'] > 0)
991
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1061
+            if ($_FILES['lp_preview_image']['size'] > 0) {
1062
+                            $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1063
+            }
992 1064
 
993 1065
             if (api_get_setting('search_enabled') === 'true') {
994 1066
                 require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -1028,9 +1100,10 @@  discard block
 block discarded – undo
1028 1100
         if (!$is_allowed_to_edit) {
1029 1101
             api_not_allowed(true);
1030 1102
         }
1031
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1032
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1033
-        else {
1103
+        if ($debug > 0) {
1104
+            error_log('New LP - add sub item action triggered', 0);
1105
+        }
1106
+        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } else {
1034 1107
             $_SESSION['refresh'] = 1;
1035 1108
             if (!empty($_REQUEST['parent_item_id'])) {
1036 1109
                 $_SESSION['from_learnpath']='yes';
@@ -1046,7 +1119,9 @@  discard block
 block discarded – undo
1046 1119
         if (!$is_allowed_to_edit) {
1047 1120
             api_not_allowed(true);
1048 1121
         }
1049
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1122
+        if ($debug > 0) {
1123
+            error_log('New LP - delete item action triggered', 0);
1124
+        }
1050 1125
         if (!$lp_found) {
1051 1126
             error_log('New LP - No learnpath given for delete item', 0);
1052 1127
             require 'lp_list.php';
@@ -1065,9 +1140,10 @@  discard block
 block discarded – undo
1065 1140
         if (!$is_allowed_to_edit) {
1066 1141
             api_not_allowed(true);
1067 1142
         }
1068
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1069
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1070
-        else {
1143
+        if ($debug > 0) {
1144
+            error_log('New LP - edit item prereq action triggered', 0);
1145
+        }
1146
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
1071 1147
             if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1072 1148
                 $_SESSION['refresh'] = 1;
1073 1149
                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
@@ -1076,64 +1152,80 @@  discard block
 block discarded – undo
1076 1152
         }
1077 1153
         break;
1078 1154
     case 'restart':
1079
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
1080
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1081
-        else {
1155
+        if ($debug > 0) {
1156
+            error_log('New LP - restart action triggered', 0);
1157
+        }
1158
+        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } else {
1082 1159
             $_SESSION['oLP']->restart();
1083 1160
             require 'lp_view.php';
1084 1161
         }
1085 1162
         break;
1086 1163
     case 'last':
1087
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
1088
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1089
-        else {
1164
+        if ($debug > 0) {
1165
+            error_log('New LP - last action triggered', 0);
1166
+        }
1167
+        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } else {
1090 1168
             $_SESSION['oLP']->last();
1091 1169
             require 'lp_view.php';
1092 1170
         }
1093 1171
         break;
1094 1172
     case 'first':
1095
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
1096
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1097
-        else {
1173
+        if ($debug > 0) {
1174
+            error_log('New LP - first action triggered', 0);
1175
+        }
1176
+        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } else {
1098 1177
             $_SESSION['oLP']->first();
1099 1178
             require 'lp_view.php';
1100 1179
         }
1101 1180
         break;
1102 1181
     case 'next':
1103
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
1104
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1105
-        else {
1182
+        if ($debug > 0) {
1183
+            error_log('New LP - next action triggered', 0);
1184
+        }
1185
+        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } else {
1106 1186
             $_SESSION['oLP']->next();
1107 1187
             require 'lp_view.php';
1108 1188
         }
1109 1189
         break;
1110 1190
     case 'previous':
1111
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
1112
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1113
-        else {
1191
+        if ($debug > 0) {
1192
+            error_log('New LP - previous action triggered', 0);
1193
+        }
1194
+        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } else {
1114 1195
             $_SESSION['oLP']->previous();
1115 1196
             require 'lp_view.php';
1116 1197
         }
1117 1198
         break;
1118 1199
     case 'content':
1119
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
1120
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1200
+        if ($debug > 0) {
1201
+            error_log('New LP - content action triggered', 0);
1202
+        }
1203
+        if ($debug > 0) {
1204
+            error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1205
+        }
1121 1206
         if (!$lp_found) {
1122 1207
             error_log('New LP - No learnpath given for content', 0);
1123 1208
             require 'lp_list.php';
1124 1209
         } else {
1125
-            if ($debug > 0) error_log('New LP - save_last()', 0);
1210
+            if ($debug > 0) {
1211
+                error_log('New LP - save_last()', 0);
1212
+            }
1126 1213
             $_SESSION['oLP']->save_last();
1127
-            if ($debug > 0) error_log('New LP - set_current_item()', 0);
1214
+            if ($debug > 0) {
1215
+                error_log('New LP - set_current_item()', 0);
1216
+            }
1128 1217
             $_SESSION['oLP']->set_current_item($_GET['item_id']);
1129
-            if ($debug > 0) error_log('New LP - start_current_item()', 0);
1218
+            if ($debug > 0) {
1219
+                error_log('New LP - start_current_item()', 0);
1220
+            }
1130 1221
             $_SESSION['oLP']->start_current_item();
1131 1222
             require 'lp_content.php';
1132 1223
         }
1133 1224
         break;
1134 1225
     case 'view':
1135
-        if ($debug > 0)
1136
-            error_log('New LP - view action triggered', 0);
1226
+        if ($debug > 0) {
1227
+                    error_log('New LP - view action triggered', 0);
1228
+        }
1137 1229
         if (!$lp_found) {
1138 1230
             error_log('New LP - No learnpath given for view', 0);
1139 1231
             require 'lp_list.php';
@@ -1146,17 +1238,19 @@  discard block
 block discarded – undo
1146 1238
         }
1147 1239
         break;
1148 1240
     case 'save':
1149
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
1150
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1151
-        else {
1241
+        if ($debug > 0) {
1242
+            error_log('New LP - save action triggered', 0);
1243
+        }
1244
+        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } else {
1152 1245
             $_SESSION['oLP']->save_item();
1153 1246
             require 'lp_save.php';
1154 1247
         }
1155 1248
         break;
1156 1249
     case 'stats':
1157
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
1158
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1159
-        else {
1250
+        if ($debug > 0) {
1251
+            error_log('New LP - stats action triggered', 0);
1252
+        }
1253
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1160 1254
             $_SESSION['oLP']->save_current();
1161 1255
             $_SESSION['oLP']->save_last();
1162 1256
             $output = require 'lp_stats.php';
@@ -1164,7 +1258,9 @@  discard block
 block discarded – undo
1164 1258
         }
1165 1259
         break;
1166 1260
     case 'list':
1167
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
1261
+        if ($debug > 0) {
1262
+            error_log('New LP - list action triggered', 0);
1263
+        }
1168 1264
         if ($lp_found) {
1169 1265
             $_SESSION['refresh'] = 1;
1170 1266
             $_SESSION['oLP']->save_last();
@@ -1173,7 +1269,9 @@  discard block
 block discarded – undo
1173 1269
         break;
1174 1270
     case 'mode':
1175 1271
         // Switch between fullscreen and embedded mode.
1176
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
1272
+        if ($debug > 0) {
1273
+            error_log('New LP - mode change triggered', 0);
1274
+        }
1177 1275
         $mode = $_REQUEST['mode'];
1178 1276
         if ($mode == 'fullscreen') {
1179 1277
             $_SESSION['oLP']->mode = 'fullscreen';
@@ -1187,7 +1285,9 @@  discard block
 block discarded – undo
1187 1285
         require 'lp_view.php';
1188 1286
         break;
1189 1287
     case 'switch_view_mode':
1190
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1288
+        if ($debug > 0) {
1289
+            error_log('New LP - switch_view_mode action triggered', 0);
1290
+        }
1191 1291
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1192 1292
         if (Security::check_token('get')) {
1193 1293
             $_SESSION['refresh'] = 1;
@@ -1196,7 +1296,9 @@  discard block
 block discarded – undo
1196 1296
         require 'lp_list.php';
1197 1297
         break;
1198 1298
     case 'switch_force_commit':
1199
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1299
+        if ($debug > 0) {
1300
+            error_log('New LP - switch_force_commit action triggered', 0);
1301
+        }
1200 1302
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1201 1303
         $_SESSION['refresh'] = 1;
1202 1304
         $_SESSION['oLP']->update_default_scorm_commit();
@@ -1219,25 +1321,33 @@  discard block
 block discarded – undo
1219 1321
 		break;
1220 1322
      */
1221 1323
 	case 'switch_attempt_mode':
1222
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1324
+		if($debug>0) {
1325
+		    error_log('New LP - switch_reinit action triggered',0);
1326
+		}
1223 1327
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1224 1328
 		$_SESSION['refresh'] = 1;
1225 1329
 		$_SESSION['oLP']->switch_attempt_mode();
1226 1330
         require 'lp_list.php';
1227 1331
         break;
1228 1332
     case 'switch_scorm_debug':
1229
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1333
+        if ($debug > 0) {
1334
+            error_log('New LP - switch_scorm_debug action triggered', 0);
1335
+        }
1230 1336
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1231 1337
         $_SESSION['refresh'] = 1;
1232 1338
         $_SESSION['oLP']->update_scorm_debug();
1233 1339
         require 'lp_list.php';
1234 1340
         break;
1235 1341
     case 'intro_cmdAdd':
1236
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1342
+        if ($debug > 0) {
1343
+            error_log('New LP - intro_cmdAdd action triggered', 0);
1344
+        }
1237 1345
         // Add introduction section page.
1238 1346
         break;
1239 1347
     case 'js_api_refresh':
1240
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1348
+        if ($debug > 0) {
1349
+            error_log('New LP - js_api_refresh action triggered', 0);
1350
+        }
1241 1351
         if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1242 1352
         if (isset($_REQUEST['item_id'])) {
1243 1353
             $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
@@ -1245,8 +1355,7 @@  discard block
 block discarded – undo
1245 1355
         require 'lp_message.php';
1246 1356
         break;
1247 1357
     case 'return_to_course_homepage':
1248
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1249
-        else {
1358
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1250 1359
             $_SESSION['oLP']->save_current();
1251 1360
             $_SESSION['oLP']->save_last();
1252 1361
             $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
@@ -1264,8 +1373,9 @@  discard block
 block discarded – undo
1264 1373
         require 'lp_list_search.php';
1265 1374
         break;
1266 1375
     case 'impress':
1267
-        if ($debug > 0)
1268
-            error_log('New LP - view action triggered', 0);
1376
+        if ($debug > 0) {
1377
+                    error_log('New LP - view action triggered', 0);
1378
+        }
1269 1379
         if (!$lp_found) {
1270 1380
             error_log('New LP - No learnpath given for view', 0);
1271 1381
             require 'lp_list.php';
@@ -1439,15 +1549,19 @@  discard block
 block discarded – undo
1439 1549
         ]);
1440 1550
         break;
1441 1551
     default:
1442
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
1552
+        if ($debug > 0) {
1553
+            error_log('New LP - default action triggered', 0);
1554
+        }
1443 1555
         require 'lp_list.php';
1444 1556
         break;
1445 1557
 }
1446 1558
 
1447 1559
 if (!empty($_SESSION['oLP'])) {
1448 1560
     $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
1449
-    if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
1450
-}
1561
+    if ($debug > 0) {
1562
+        error_log('New LP - lpobject is serialized in session', 0);
1563
+    }
1564
+    }
1451 1565
 
1452 1566
 if (!empty($redirectTo)) {
1453 1567
     header("Location: $redirectTo");
Please login to merge, or discard this patch.
main/exercice/admin.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -362,9 +362,10 @@
 block discarded – undo
362 362
 
363 363
 if ($inATest) {
364 364
     echo '<div class="actions">';
365
-    if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
366
-        echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'.
365
+    if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) {
366
+            echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'.
367 367
             Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
368
+    }
368 369
 
369 370
     if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) &&  !isset($_GET['editQuestion'])) {
370 371
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidreq().'">'.
Please login to merge, or discard this patch.
plugin/vchamilo/lib.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -701,7 +701,9 @@  discard block
 block discarded – undo
701 701
 
702 702
         if (!isset($strings)) {
703 703
             $lang = api_get_language_from_type('platform_lang');
704
-            if (empty($lang)) $lang = 'english';
704
+            if (empty($lang)) {
705
+                $lang = 'english';
706
+            }
705 707
             $path = $_configuration['root_sys'].'local/ent_installer/lang/'.$lang.'/local_ent_installer.php';
706 708
 
707 709
             if (!file_exists($path)) {
@@ -791,10 +793,14 @@  discard block
 block discarded – undo
791 793
 }
792 794
 
793 795
 function ctrace($str) {
794
-    if (!defined('CLI_SCRIPT')) echo "<pre>";
796
+    if (!defined('CLI_SCRIPT')) {
797
+        echo "<pre>";
798
+    }
795 799
     Display::addFlash(Display::return_message($str));
796
-    if (!defined('CLI_SCRIPT')) echo "</pre>";
797
-}
800
+    if (!defined('CLI_SCRIPT')) {
801
+        echo "</pre>";
802
+    }
803
+    }
798 804
 
799 805
 /**
800 806
  * Sets a platform configuration setting to a given value, creating it if necessary
Please login to merge, or discard this patch.