Completed
Pull Request — 1.11.x (#1339)
by José
73:57 queued 34:43
created
main/inc/lib/api.lib.php 1 patch
Indentation   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -625,7 +625,6 @@  discard block
 block discarded – undo
625 625
  * The other configuration parameters have not been changed.
626 626
  *
627 627
  * This is how we can get most used paths, for common purpose:
628
-
629 628
  * api_get_path(REL_PATH)                       /chamilo/
630 629
  * api_get_path(REL_COURSE_PATH)                /chamilo/courses/
631 630
  * api_get_path(REL_CODE_PATH)                  /chamilo/main/
@@ -1803,7 +1802,6 @@  discard block
 block discarded – undo
1803 1802
 
1804 1803
 /**
1805 1804
  * Returns the current course info array.
1806
-
1807 1805
  * Now if the course_code is given, the returned array gives info about that
1808 1806
  * particular course, not specially the current one.
1809 1807
  * @param int $id Numeric ID of the course
@@ -2734,7 +2732,7 @@  discard block
 block discarded – undo
2734 2732
         switch ($session_user_status) {
2735 2733
             case 0:
2736 2734
                 $session_status['status'] = 'student';
2737
-               break;
2735
+                break;
2738 2736
             case 2:
2739 2737
                 $session_status['status'] = 'coach';
2740 2738
             break;
@@ -6492,7 +6490,7 @@  discard block
 block discarded – undo
6492 6490
 function api_get_jquery_ui_js($include_jqgrid = false) {
6493 6491
     $libraries = array();
6494 6492
     if ($include_jqgrid) {
6495
-       $libraries[]='jqgrid';
6493
+        $libraries[]='jqgrid';
6496 6494
     }
6497 6495
     return api_get_jquery_libraries_js($libraries);
6498 6496
 }
Please login to merge, or discard this patch.
main/install/install.lib.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
         $html .= '<label class="checkbox-inline">
1683 1683
                         <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1684 1684
                     </label>';
1685
-         $html .= '<label class="checkbox-inline">
1685
+            $html .= '<label class="checkbox-inline">
1686 1686
                     <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1687 1687
                 </label>';
1688 1688
         $html .= '</div>';
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
     </div>';
1717 1717
 
1718 1718
     echo panel($html, get_lang('Platform'), 'platform');
1719
- ?>
1719
+    ?>
1720 1720
     <div class='form-group'>
1721 1721
         <div class="col-sm-6">
1722 1722
             <button type="submit" class="btn btn-default pull-right" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button>
Please login to merge, or discard this patch.
main/course_home/course_home.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             if (Database::num_rows($result) ==  0) {
214 214
                 $condition = '';
215 215
             } else {
216
-            	//great, there is an specific auto launch for this session we leave the $condition
216
+                //great, there is an specific auto launch for this session we leave the $condition
217 217
             }
218 218
         }
219 219
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             $lp_data = Database::fetch_array($result,'ASSOC');
226 226
             if (!empty($lp_data['id'])) {
227 227
                 if (api_is_platform_admin() || api_is_allowed_to_edit()) {
228
-                	$show_autolaunch_lp_warning = true;
228
+                    $show_autolaunch_lp_warning = true;
229 229
                 } else {
230 230
                     $session_key = 'lp_autolaunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id();
231 231
                     if (!isset($_SESSION[$session_key])) {
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         //if (!isset($_SESSION[$forumKey])) {
255 255
             //redirecting to the LP
256 256
             $url = api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq().'&id_session='.$session_id;
257
-          //  $_SESSION[$forumKey] = true;
257
+            //  $_SESSION[$forumKey] = true;
258 258
             header("Location: $url");
259 259
             exit;
260 260
         //}
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 if (api_get_setting('course.homepage_view') == 'activity' ||
281 281
     api_get_setting('course.homepage_view') == 'activity_big'
282 282
 ) {
283
-	require 'activity.php';
283
+    require 'activity.php';
284 284
 } elseif (api_get_setting('course.homepage_view') == '2column') {
285
-	require '2column.php';
285
+    require '2column.php';
286 286
 } elseif (api_get_setting('course.homepage_view') == '3column') {
287
-	require '3column.php';
287
+    require '3column.php';
288 288
 } elseif (api_get_setting('course.homepage_view') == 'vertical_activity') {
289
-	require 'vertical_activity.php';
289
+    require 'vertical_activity.php';
290 290
 }
291 291
 
292 292
 $content = '<div id="course_tools">'.$content.'</div>';
Please login to merge, or discard this patch.
main/dropbox/index.php 1 patch
Indentation   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 $last_access = '';
8 8
 // get the last time the user accessed the tool
9 9
 if (isset($_SESSION[$_course['id']]) && $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
10
-	$last_access = get_last_tool_access(TOOL_DROPBOX);
11
-	$_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access;
10
+    $last_access = get_last_tool_access(TOOL_DROPBOX);
11
+    $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access;
12 12
 } else {
13
-	if (isset($_SESSION[$_course['id']])) {
14
-		$last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
15
-	}
13
+    if (isset($_SESSION[$_course['id']])) {
14
+        $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
15
+    }
16 16
 }
17 17
 
18 18
 $postAction = isset($_POST['action']) ? $_POST['action'] : null;
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
 // Display the form for adding a new dropbox item.
51 51
 if ($action == 'add') {
52
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
53
-		api_not_allowed();
54
-	}
52
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
53
+        api_not_allowed();
54
+    }
55 55
     display_add_form(
56 56
         $dropbox_unid,
57 57
         $viewReceivedCategory,
@@ -61,56 +61,56 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 if (isset($_POST['submitWork'])) {
64
-	$check = Security::check_token();
65
-	if ($check) {
64
+    $check = Security::check_token();
65
+    if ($check) {
66 66
         store_add_dropbox();
67
-	}
67
+    }
68 68
 }
69 69
 
70 70
 // Display the form for adding a category
71 71
 if ($action == 'addreceivedcategory' || $action == 'addsentcategory') {
72
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
73
-		api_not_allowed();
74
-	}
75
-	$categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : '';
76
-	display_addcategory_form($categoryName, '', $_GET['action']);
72
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
73
+        api_not_allowed();
74
+    }
75
+    $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : '';
76
+    display_addcategory_form($categoryName, '', $_GET['action']);
77 77
 }
78 78
 
79 79
 // Editing a category: displaying the form
80 80
 if ($action == 'editcategory' && isset($_GET['id'])) {
81
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
82
-		api_not_allowed();
83
-	}
84
-	if (!$_POST) {
85
-		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
86
-			api_not_allowed();
87
-		}
88
-		display_addcategory_form('', $_GET['id'], 'editcategory');
89
-	}
81
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
82
+        api_not_allowed();
83
+    }
84
+    if (!$_POST) {
85
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
86
+            api_not_allowed();
87
+        }
88
+        display_addcategory_form('', $_GET['id'], 'editcategory');
89
+    }
90 90
 }
91 91
 
92 92
 // Storing a new or edited category
93 93
 if (isset($_POST['StoreCategory'])) {
94
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
95
-		api_not_allowed();
96
-	}
97
-	$return_information = store_addcategory();
98
-	if ($return_information['type'] == 'confirmation') {
99
-		Display :: display_confirmation_message($return_information['message']);
100
-	}
101
-	if ($return_information['type'] == 'error') {
102
-		Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
103
-		display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
104
-	}
94
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
95
+        api_not_allowed();
96
+    }
97
+    $return_information = store_addcategory();
98
+    if ($return_information['type'] == 'confirmation') {
99
+        Display :: display_confirmation_message($return_information['message']);
100
+    }
101
+    if ($return_information['type'] == 'error') {
102
+        Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
103
+        display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
104
+    }
105 105
 }
106 106
 
107 107
 
108 108
 // Move a File
109 109
 if (($action == 'movesent' || $action == 'movereceived') AND isset($_GET['move_id'])) {
110
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
111
-		api_not_allowed();
112
-	}
113
-	display_move_form(
110
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
111
+        api_not_allowed();
112
+    }
113
+    display_move_form(
114 114
         str_replace('move', '', $action),
115 115
         $_GET['move_id'],
116 116
         get_dropbox_categories(str_replace('move', '', $action)),
@@ -121,33 +121,33 @@  discard block
 block discarded – undo
121 121
     );
122 122
 }
123 123
 if (isset($_POST['do_move'])) {
124
-	Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
124
+    Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
125 125
 }
126 126
 
127 127
 // Delete a file
128 128
 if (($action == 'deletereceivedfile' || $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
129
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
130
-		api_not_allowed();
131
-	}
132
-	$dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
133
-	if ($action == 'deletereceivedfile') {
134
-		$dropboxfile->deleteReceivedWork($_GET['id']);
135
-		$message = get_lang('ReceivedFileDeleted');
136
-	}
137
-	if ($action == 'deletesentfile') {
138
-		$dropboxfile->deleteSentWork($_GET['id']);
139
-		$message = get_lang('SentFileDeleted');
140
-	}
141
-	Display :: display_confirmation_message($message);
129
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
130
+        api_not_allowed();
131
+    }
132
+    $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
133
+    if ($action == 'deletereceivedfile') {
134
+        $dropboxfile->deleteReceivedWork($_GET['id']);
135
+        $message = get_lang('ReceivedFileDeleted');
136
+    }
137
+    if ($action == 'deletesentfile') {
138
+        $dropboxfile->deleteSentWork($_GET['id']);
139
+        $message = get_lang('SentFileDeleted');
140
+    }
141
+    Display :: display_confirmation_message($message);
142 142
 }
143 143
 
144 144
 // Delete a category
145 145
 if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
146
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
147
-		api_not_allowed();
148
-	}
149
-	$message = delete_category($action, $_GET['id']);
150
-	Display :: display_confirmation_message($message);
146
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
147
+        api_not_allowed();
148
+    }
149
+    $message = delete_category($action, $_GET['id']);
150
+    Display :: display_confirmation_message($message);
151 151
 }
152 152
 
153 153
 // Do an action on multiple files
@@ -162,27 +162,27 @@  discard block
 block discarded – undo
162 162
     $postAction == 'delete_sent' ||
163 163
     $postAction == 'download_sent')
164 164
 ) {
165
-	$display_message = handle_multiple_actions();
166
-	Display :: display_normal_message($display_message);
165
+    $display_message = handle_multiple_actions();
166
+    Display :: display_normal_message($display_message);
167 167
 }
168 168
 
169 169
 // Store Feedback
170 170
 
171 171
 if (isset($_POST['feedback'])) {
172
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
173
-		api_not_allowed();
174
-	}
175
-	$check = Security::check_token();
176
-	if ($check) {
177
-		$display_message = store_feedback();
178
-		Display :: display_normal_message($display_message);
179
-		Security::check_token();
180
-	}
172
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
173
+        api_not_allowed();
174
+    }
175
+    $check = Security::check_token();
176
+    if ($check) {
177
+        $display_message = store_feedback();
178
+        Display :: display_normal_message($display_message);
179
+        Security::check_token();
180
+    }
181 181
 }
182 182
 
183 183
 // Error Message
184 184
 if (isset($_GET['error']) AND !empty($_GET['error'])) {
185
-	Display :: display_normal_message(get_lang($_GET['error']));
185
+    Display :: display_normal_message(get_lang($_GET['error']));
186 186
 }
187 187
 
188 188
 $dropbox_data_sent = array();
@@ -190,96 +190,96 @@  discard block
 block discarded – undo
190 190
 $dropbox_data_recieved = array();
191 191
 
192 192
 if ($action != 'add') {
193
-	// Getting all the categories in the dropbox for the given user
194
-	$dropbox_categories = get_dropbox_categories();
195
-	// Greating the arrays with the categories for the received files and for the sent files
196
-	foreach ($dropbox_categories as $category) {
197
-		if ($category['received'] == '1') {
198
-			$dropbox_received_category[] = $category;
199
-		}
200
-		if ($category['sent'] == '1') {
201
-			$dropbox_sent_category[] = $category;
202
-		}
203
-	}
204
-
205
-	// ACTIONS
206
-	if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
207
-		//echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
208
-
209
-		// This is for the categories
210
-		if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
211
-			$view_dropbox_category_received = $viewReceivedCategory;
212
-		} else {
213
-			$view_dropbox_category_received = 0;
214
-		}
215
-
216
-		/* Menu Received */
217
-
218
-		if (api_get_session_id() == 0) {
219
-			echo '<div class="actions">';
220
-			if ($view_dropbox_category_received != 0  && api_is_allowed_to_session_edit(false, true)) {
221
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
222
-				echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
223
-				$movelist[0] = 'Root'; // move_received selectbox content
224
-			} else {
225
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
226
-			}
227
-			echo '</div>';
228
-		} else {
229
-			if (api_is_allowed_to_session_edit(false, true)) {
230
-				echo '<div class="actions">';
231
-				if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
232
-					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
233
-					echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
234
-					$movelist[0] = 'Root'; // move_received selectbox content
235
-				} else {
236
-					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
237
-				}
238
-				echo '</div>';
239
-			}
240
-		}
241
-	}
242
-
243
-	if (!$view || $view == 'sent' || !$dropbox_cnf['sent_received_tabs']) {
244
-		// This is for the categories
245
-		if (isset($viewSentCategory) AND $viewSentCategory != '') {
246
-			$view_dropbox_category_sent = $viewSentCategory;
247
-		} else {
248
-			$view_dropbox_category_sent = 0;
249
-		}
250
-
251
-		/* Menu Sent */
252
-
253
-		if (api_get_session_id() == 0) {
254
-			echo '<div class="actions">';
255
-			if ($view_dropbox_category_sent != 0) {
256
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
257
-				echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
258
-			} else {
259
-				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
260
-			}
261
-			if (empty($viewSentCategory)) {
262
-				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
263
-			}
264
-			echo '</div>';
265
-		} else {
266
-			if (api_is_allowed_to_session_edit(false, true)) {
267
-				echo '<div class="actions">';
268
-				if ($view_dropbox_category_sent != 0) {
269
-					echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
270
-					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
271
-				} else {
272
-					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
273
-				}
274
-				if (empty($viewSentCategory)) {
275
-					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
276
-				}
277
-				echo '</div>';
278
-			}
279
-		}
280
-	}
281
-	/*	THE MENU TABS */
282
-	if ($dropbox_cnf['sent_received_tabs']) {
193
+    // Getting all the categories in the dropbox for the given user
194
+    $dropbox_categories = get_dropbox_categories();
195
+    // Greating the arrays with the categories for the received files and for the sent files
196
+    foreach ($dropbox_categories as $category) {
197
+        if ($category['received'] == '1') {
198
+            $dropbox_received_category[] = $category;
199
+        }
200
+        if ($category['sent'] == '1') {
201
+            $dropbox_sent_category[] = $category;
202
+        }
203
+    }
204
+
205
+    // ACTIONS
206
+    if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
207
+        //echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
208
+
209
+        // This is for the categories
210
+        if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
211
+            $view_dropbox_category_received = $viewReceivedCategory;
212
+        } else {
213
+            $view_dropbox_category_received = 0;
214
+        }
215
+
216
+        /* Menu Received */
217
+
218
+        if (api_get_session_id() == 0) {
219
+            echo '<div class="actions">';
220
+            if ($view_dropbox_category_received != 0  && api_is_allowed_to_session_edit(false, true)) {
221
+                echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
222
+                echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
223
+                $movelist[0] = 'Root'; // move_received selectbox content
224
+            } else {
225
+                echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
226
+            }
227
+            echo '</div>';
228
+        } else {
229
+            if (api_is_allowed_to_session_edit(false, true)) {
230
+                echo '<div class="actions">';
231
+                if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
232
+                    echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
233
+                    echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
234
+                    $movelist[0] = 'Root'; // move_received selectbox content
235
+                } else {
236
+                    echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
237
+                }
238
+                echo '</div>';
239
+            }
240
+        }
241
+    }
242
+
243
+    if (!$view || $view == 'sent' || !$dropbox_cnf['sent_received_tabs']) {
244
+        // This is for the categories
245
+        if (isset($viewSentCategory) AND $viewSentCategory != '') {
246
+            $view_dropbox_category_sent = $viewSentCategory;
247
+        } else {
248
+            $view_dropbox_category_sent = 0;
249
+        }
250
+
251
+        /* Menu Sent */
252
+
253
+        if (api_get_session_id() == 0) {
254
+            echo '<div class="actions">';
255
+            if ($view_dropbox_category_sent != 0) {
256
+                echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
257
+                echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
258
+            } else {
259
+                echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
260
+            }
261
+            if (empty($viewSentCategory)) {
262
+                echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
263
+            }
264
+            echo '</div>';
265
+        } else {
266
+            if (api_is_allowed_to_session_edit(false, true)) {
267
+                echo '<div class="actions">';
268
+                if ($view_dropbox_category_sent != 0) {
269
+                    echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
270
+                    echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
271
+                } else {
272
+                    echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
273
+                }
274
+                if (empty($viewSentCategory)) {
275
+                    echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
276
+                }
277
+                echo '</div>';
278
+            }
279
+        }
280
+    }
281
+    /*	THE MENU TABS */
282
+    if ($dropbox_cnf['sent_received_tabs']) {
283 283
 ?>
284 284
 <ul class="nav nav-tabs">
285 285
     <li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> >
@@ -293,150 +293,150 @@  discard block
 block discarded – undo
293 293
     </li>
294 294
 </ul>
295 295
 <?php
296
-	}
296
+    }
297 297
     /*	RECEIVED FILES */
298
-	if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
299
-		// This is for the categories
300
-		if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
301
-			$view_dropbox_category_received = $viewReceivedCategory;
302
-		} else {
303
-			$view_dropbox_category_received = 0;
304
-		}
305
-
306
-		// Object initialisation
307
-		$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
308
-		 // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
309
-
310
-		// Constructing the array that contains the total number of feedback messages per document.
311
-		$number_feedback = get_total_number_feedback();
312
-
313
-		// Sorting and paging options
314
-		$sorting_options = array();
315
-		$paging_options = array();
316
-
317
-		// The headers of the sortable tables
318
-		$column_header = array();
319
-		$column_header[] = array('', false, '');
320
-		$column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
321
-		$column_header[] = array(get_lang('ReceivedTitle'), true, '');
322
-		$column_header[] = array(get_lang('Size'), true, '');
323
-		$column_header[] = array(get_lang('Authors'), true, '');
324
-		$column_header[] = array(get_lang('LastResent'), true);
325
-
326
-		if (api_get_session_id() == 0) {
327
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
328
-		} elseif (api_is_allowed_to_session_edit(false,true)) {
329
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
330
-		}
331
-
332
-		$column_header[] = array('RealDate', true);
333
-		$column_header[] = array('RealSize', true);
334
-
335
-		// An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
336
-		$column_show[] = 1;
337
-		$column_show[] = 1;
338
-		$column_show[] = 1;
339
-		$column_show[] = 1;
340
-		$column_show[] = 1;
341
-		$column_show[] = 1;
342
-
343
-		if (api_get_session_id() == 0) {
344
-			$column_show[] = 1;
345
-		} elseif (api_is_allowed_to_session_edit(false, true)) {
346
-			$column_show[] = 1;
347
-		}
348
-		$column_show[] = 0;
349
-
350
-		// Here we change the way how the columns are going to be sort
351
-		// in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
352
-		// because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
353
-
354
-		$column_order[3] = 8;
355
-		$column_order[5] = 7;
356
-
357
-		// The content of the sortable table = the received files
358
-		foreach ($dropbox_person -> receivedWork as $dropbox_file) {
359
-			$dropbox_file_data = array();
360
-			if ($view_dropbox_category_received == $dropbox_file->category) {
298
+    if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
299
+        // This is for the categories
300
+        if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
301
+            $view_dropbox_category_received = $viewReceivedCategory;
302
+        } else {
303
+            $view_dropbox_category_received = 0;
304
+        }
305
+
306
+        // Object initialisation
307
+        $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
308
+            // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
309
+
310
+        // Constructing the array that contains the total number of feedback messages per document.
311
+        $number_feedback = get_total_number_feedback();
312
+
313
+        // Sorting and paging options
314
+        $sorting_options = array();
315
+        $paging_options = array();
316
+
317
+        // The headers of the sortable tables
318
+        $column_header = array();
319
+        $column_header[] = array('', false, '');
320
+        $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
321
+        $column_header[] = array(get_lang('ReceivedTitle'), true, '');
322
+        $column_header[] = array(get_lang('Size'), true, '');
323
+        $column_header[] = array(get_lang('Authors'), true, '');
324
+        $column_header[] = array(get_lang('LastResent'), true);
325
+
326
+        if (api_get_session_id() == 0) {
327
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
328
+        } elseif (api_is_allowed_to_session_edit(false,true)) {
329
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
330
+        }
331
+
332
+        $column_header[] = array('RealDate', true);
333
+        $column_header[] = array('RealSize', true);
334
+
335
+        // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
336
+        $column_show[] = 1;
337
+        $column_show[] = 1;
338
+        $column_show[] = 1;
339
+        $column_show[] = 1;
340
+        $column_show[] = 1;
341
+        $column_show[] = 1;
342
+
343
+        if (api_get_session_id() == 0) {
344
+            $column_show[] = 1;
345
+        } elseif (api_is_allowed_to_session_edit(false, true)) {
346
+            $column_show[] = 1;
347
+        }
348
+        $column_show[] = 0;
349
+
350
+        // Here we change the way how the columns are going to be sort
351
+        // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
352
+        // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
353
+
354
+        $column_order[3] = 8;
355
+        $column_order[5] = 7;
356
+
357
+        // The content of the sortable table = the received files
358
+        foreach ($dropbox_person -> receivedWork as $dropbox_file) {
359
+            $dropbox_file_data = array();
360
+            if ($view_dropbox_category_received == $dropbox_file->category) {
361 361
                 // we only display the files that are in the category that we are in.
362
-				$dropbox_file_data[] = $dropbox_file->id;
362
+                $dropbox_file_data[] = $dropbox_file->id;
363 363
 
364
-				if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
365
-					$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
366
-				}
364
+                if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
365
+                    $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
366
+                }
367 367
 
368
-				// New icon
369
-				$new_icon = '';
370
-				if ($dropbox_file->last_upload_date > $last_access &&
368
+                // New icon
369
+                $new_icon = '';
370
+                if ($dropbox_file->last_upload_date > $last_access &&
371 371
                     !in_array($dropbox_file->id, $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])
372 372
                 ) {
373
-					$new_icon = '&nbsp;'.Display::return_icon('new_dropbox_message.png', get_lang('New'),'',ICON_SIZE_SMALL);
374
-				}
373
+                    $new_icon = '&nbsp;'.Display::return_icon('new_dropbox_message.png', get_lang('New'),'',ICON_SIZE_SMALL);
374
+                }
375 375
 
376
-				$link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
377
-				$dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
378
-				$dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
376
+                $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
377
+                $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
378
+                $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
379 379
                     Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description;
380
-				$file_size = $dropbox_file->filesize;
381
-				$dropbox_file_data[] = format_file_size($file_size);
382
-				$dropbox_file_data[] = $dropbox_file->author;
380
+                $file_size = $dropbox_file->filesize;
381
+                $dropbox_file_data[] = format_file_size($file_size);
382
+                $dropbox_file_data[] = $dropbox_file->author;
383 383
 
384
-				$last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
385
-				$dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
384
+                $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
385
+                $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
386 386
                     api_format_date($last_upload_date).'</span>';
387 387
 
388
-				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
388
+                $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
389 389
                 <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
390 390
                 <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movereceived&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
391 391
                 <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletereceivedfile&id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
392 392
                 Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
393 393
 
394
-				// This is a hack to have an additional row in a sortable table
395
-
396
-				if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
397
-					$action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
398
-					$action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
399
-				}
400
-				if (api_get_session_id() == 0) {
401
-					$dropbox_file_data[] = $action_icons;
402
-				} elseif (api_is_allowed_to_session_edit(false, true)) {
403
-					$dropbox_file_data[] = $action_icons;
404
-				}
405
-				$action_icons = '';
406
-				$dropbox_file_data[] = $last_upload_date;
407
-				$dropbox_file_data[] = $file_size;
408
-				$dropbox_data_recieved[] = $dropbox_file_data;
409
-			}
410
-		}
411
-
412
-		// The content of the sortable table = the categories (if we are not in the root)
413
-		if ($view_dropbox_category_received == 0) {
414
-			foreach ($dropbox_categories as $category) {
415
-			    /*  Note: This can probably be shortened since the categories
394
+                // This is a hack to have an additional row in a sortable table
395
+
396
+                if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
397
+                    $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
398
+                    $action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
399
+                }
400
+                if (api_get_session_id() == 0) {
401
+                    $dropbox_file_data[] = $action_icons;
402
+                } elseif (api_is_allowed_to_session_edit(false, true)) {
403
+                    $dropbox_file_data[] = $action_icons;
404
+                }
405
+                $action_icons = '';
406
+                $dropbox_file_data[] = $last_upload_date;
407
+                $dropbox_file_data[] = $file_size;
408
+                $dropbox_data_recieved[] = $dropbox_file_data;
409
+            }
410
+        }
411
+
412
+        // The content of the sortable table = the categories (if we are not in the root)
413
+        if ($view_dropbox_category_received == 0) {
414
+            foreach ($dropbox_categories as $category) {
415
+                /*  Note: This can probably be shortened since the categories
416 416
 			    for the received files are already in the
417 417
 			    $dropbox_received_category array;*/
418
-				$dropbox_category_data = array();
419
-				if ($category['received'] == '1') {
420
-					$movelist[$category['cat_id']] = $category['cat_name'];
418
+                $dropbox_category_data = array();
419
+                if ($category['received'] == '1') {
420
+                    $movelist[$category['cat_id']] = $category['cat_name'];
421 421
                     // This is where the checkbox icon for the files appear
422
-					$dropbox_category_data[] = $category['cat_id'];
423
-					// The icon of the category
424
-					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">';
425
-					$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>';
426
-					$dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
427
-					$dropbox_category_data[] = '';
428
-					$dropbox_category_data[] = '';
429
-					$dropbox_category_data[] = '';
430
-					$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
422
+                    $dropbox_category_data[] = $category['cat_id'];
423
+                    // The icon of the category
424
+                    $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">';
425
+                    $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>';
426
+                    $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
427
+                    $dropbox_category_data[] = '';
428
+                    $dropbox_category_data[] = '';
429
+                    $dropbox_category_data[] = '';
430
+                    $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
431 431
 										  <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletereceivedcategory&id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
432
-				}
433
-				if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
434
-					$dropbox_data_recieved[] = $dropbox_category_data;
435
-				}
436
-			}
437
-		}
438
-
439
-		// Displaying the table
432
+                }
433
+                if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
434
+                    $dropbox_data_recieved[] = $dropbox_category_data;
435
+                }
436
+            }
437
+        }
438
+
439
+        // Displaying the table
440 440
         $additional_get_parameters = array(
441 441
             'view' => $view,
442 442
             'view_received_category' => $viewReceivedCategory,
@@ -447,15 +447,15 @@  discard block
 block discarded – undo
447 447
             'download_received' => get_lang('Download')
448 448
         );
449 449
 
450
-		if (is_array($movelist)) {
451
-			foreach ($movelist as $catid => $catname){
452
-				$selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname);
453
-			}
454
-		}
450
+        if (is_array($movelist)) {
451
+            foreach ($movelist as $catid => $catname){
452
+                $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname);
453
+            }
454
+        }
455 455
 
456
-		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
457
-			$selectlist = array();
458
-		}
456
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
457
+            $selectlist = array();
458
+        }
459 459
         echo '<div class="files-table">';
460 460
         Display::display_sortable_config_table(
461 461
             'dropbox',
@@ -469,154 +469,154 @@  discard block
 block discarded – undo
469 469
             $selectlist
470 470
         );
471 471
         echo '</div>';
472
-	}
473
-
474
-	/*	SENT FILES */
475
-
476
-	if (!$view || $view == 'sent' || !$dropbox_cnf['sent_received_tabs']) {
477
-		// This is for the categories
478
-		if (isset($viewSentCategory) AND $viewSentCategory != '') {
479
-			$view_dropbox_category_sent = $viewSentCategory;
480
-		} else {
481
-			$view_dropbox_category_sent = 0;
482
-		}
483
-
484
-		// Object initialisation
485
-		$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
486
-
487
-		// Constructing the array that contains the total number of feedback messages per document.
488
-		$number_feedback = get_total_number_feedback();
489
-
490
-		// Sorting and paging options
491
-		$sorting_options = array();
492
-		$paging_options = array();
493
-
494
-		// The headers of the sortable tables
495
-		$column_header = array();
496
-
497
-		$column_header[] = array('', false, '');
498
-		$column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
499
-		$column_header[] = array(get_lang('SentTitle'), true, '');
500
-		$column_header[] = array(get_lang('Size'), true, '');
501
-		$column_header[] = array(get_lang('SentTo'), true, '');
502
-		$column_header[] = array(get_lang('LastResent'), true, '');
503
-
504
-		if (api_get_session_id() == 0) {
505
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
506
-		} elseif (api_is_allowed_to_session_edit(false, true)) {
507
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
508
-		}
509
-
510
-		$column_header[] = array('RealDate', true);
511
-		$column_header[] = array('RealSize', true);
512
-
513
-		$column_show = array();
514
-		$column_order = array();
515
-
516
-		// An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
517
-		$column_show[] = 1;
518
-		$column_show[] = 1;
519
-		$column_show[] = 1;
520
-		$column_show[] = 1;
521
-		$column_show[] = 1;
522
-		$column_show[] = 1;
523
-		if (api_get_session_id() == 0) {
524
-			$column_show[] = 1;
525
-		} elseif (api_is_allowed_to_session_edit(false, true)) {
526
-			$column_show[] = 1;
527
-		}
528
-		$column_show[] = 0;
529
-
530
-		// Here we change the way how the colums are going to be sort
531
-		// in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
532
-		// because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
533
-
534
-		$column_order[3] = 8;
535
-		$column_order[5] = 7;
536
-
537
-		// The content of the sortable table = the received files
538
-		foreach ($dropbox_person->sentWork as $dropbox_file) {
539
-			$dropbox_file_data = array();
540
-
541
-			if ($view_dropbox_category_sent == $dropbox_file->category) {
542
-				$dropbox_file_data[] = $dropbox_file->id;
543
-				$link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
544
-				$dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
545
-				$dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
472
+    }
473
+
474
+    /*	SENT FILES */
475
+
476
+    if (!$view || $view == 'sent' || !$dropbox_cnf['sent_received_tabs']) {
477
+        // This is for the categories
478
+        if (isset($viewSentCategory) AND $viewSentCategory != '') {
479
+            $view_dropbox_category_sent = $viewSentCategory;
480
+        } else {
481
+            $view_dropbox_category_sent = 0;
482
+        }
483
+
484
+        // Object initialisation
485
+        $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
486
+
487
+        // Constructing the array that contains the total number of feedback messages per document.
488
+        $number_feedback = get_total_number_feedback();
489
+
490
+        // Sorting and paging options
491
+        $sorting_options = array();
492
+        $paging_options = array();
493
+
494
+        // The headers of the sortable tables
495
+        $column_header = array();
496
+
497
+        $column_header[] = array('', false, '');
498
+        $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
499
+        $column_header[] = array(get_lang('SentTitle'), true, '');
500
+        $column_header[] = array(get_lang('Size'), true, '');
501
+        $column_header[] = array(get_lang('SentTo'), true, '');
502
+        $column_header[] = array(get_lang('LastResent'), true, '');
503
+
504
+        if (api_get_session_id() == 0) {
505
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
506
+        } elseif (api_is_allowed_to_session_edit(false, true)) {
507
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
508
+        }
509
+
510
+        $column_header[] = array('RealDate', true);
511
+        $column_header[] = array('RealSize', true);
512
+
513
+        $column_show = array();
514
+        $column_order = array();
515
+
516
+        // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
517
+        $column_show[] = 1;
518
+        $column_show[] = 1;
519
+        $column_show[] = 1;
520
+        $column_show[] = 1;
521
+        $column_show[] = 1;
522
+        $column_show[] = 1;
523
+        if (api_get_session_id() == 0) {
524
+            $column_show[] = 1;
525
+        } elseif (api_is_allowed_to_session_edit(false, true)) {
526
+            $column_show[] = 1;
527
+        }
528
+        $column_show[] = 0;
529
+
530
+        // Here we change the way how the colums are going to be sort
531
+        // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
532
+        // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
533
+
534
+        $column_order[3] = 8;
535
+        $column_order[5] = 7;
536
+
537
+        // The content of the sortable table = the received files
538
+        foreach ($dropbox_person->sentWork as $dropbox_file) {
539
+            $dropbox_file_data = array();
540
+
541
+            if ($view_dropbox_category_sent == $dropbox_file->category) {
542
+                $dropbox_file_data[] = $dropbox_file->id;
543
+                $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
544
+                $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
545
+                $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
546 546
                     Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description;
547
-				$file_size = $dropbox_file->filesize;
548
-				$dropbox_file_data[] = format_file_size($file_size);
547
+                $file_size = $dropbox_file->filesize;
548
+                $dropbox_file_data[] = format_file_size($file_size);
549 549
                 $receivers_celldata = null;
550
-				foreach ($dropbox_file->recipients as $recipient) {
551
-					$userInfo = api_get_user_info($recipient['user_id']);
552
-					$receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata;
553
-				}
554
-				$receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
555
-				$dropbox_file_data[] = $receivers_celldata;
556
-				$last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
557
-				$dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
558
-					api_format_date($last_upload_date).'</span>';
559
-
560
-				//$dropbox_file_data[] = $dropbox_file->author;
561
-				$receivers_celldata = '';
562
-
563
-				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
550
+                foreach ($dropbox_file->recipients as $recipient) {
551
+                    $userInfo = api_get_user_info($recipient['user_id']);
552
+                    $receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata;
553
+                }
554
+                $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
555
+                $dropbox_file_data[] = $receivers_celldata;
556
+                $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
557
+                $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
558
+                    api_format_date($last_upload_date).'</span>';
559
+
560
+                //$dropbox_file_data[] = $dropbox_file->author;
561
+                $receivers_celldata = '';
562
+
563
+                $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
564 564
                     <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
565 565
                     <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movesent&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
566 566
                     <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletesentfile&id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
567
-				// This is a hack to have an additional row in a sortable table
568
-				if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
569
-					$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
570
-					$action_icons .= "<tr><td colspan=\"2\">";
571
-					$action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
572
-					$action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
573
-				}
574
-				$dropbox_file_data[] = $action_icons;
575
-				$dropbox_file_data[] = $last_upload_date;
576
-				$dropbox_file_data[] = $file_size;
577
-				$action_icons = '';
578
-				$dropbox_data_sent[] = $dropbox_file_data;
579
-			}
580
-		}
567
+                // This is a hack to have an additional row in a sortable table
568
+                if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
569
+                    $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
570
+                    $action_icons .= "<tr><td colspan=\"2\">";
571
+                    $action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
572
+                    $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
573
+                }
574
+                $dropbox_file_data[] = $action_icons;
575
+                $dropbox_file_data[] = $last_upload_date;
576
+                $dropbox_file_data[] = $file_size;
577
+                $action_icons = '';
578
+                $dropbox_data_sent[] = $dropbox_file_data;
579
+            }
580
+        }
581 581
 
582 582
         $moveList = array();
583
-		// The content of the sortable table = the categories (if we are not in the root)
584
-		if ($view_dropbox_category_sent == 0) {
585
-			foreach ($dropbox_categories as $category) {
586
-				$dropbox_category_data = array();
583
+        // The content of the sortable table = the categories (if we are not in the root)
584
+        if ($view_dropbox_category_sent == 0) {
585
+            foreach ($dropbox_categories as $category) {
586
+                $dropbox_category_data = array();
587 587
 
588
-				if ($category['sent'] == '1') {
588
+                if ($category['sent'] == '1') {
589 589
 
590 590
                     $moveList[$category['cat_id']] = $category['cat_name'];
591
-					$dropbox_category_data[] = $category['cat_id'];
592
-					// This is where the checkbox icon for the files appear.
593
-					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">';
594
-					$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
595
-					$dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
596
-					//$dropbox_category_data[] = '';
597
-					$dropbox_category_data[] = '';
598
-					//$dropbox_category_data[] = '';
599
-					$dropbox_category_data[] = '';
600
-					$dropbox_category_data[] = '';
601
-					$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.
591
+                    $dropbox_category_data[] = $category['cat_id'];
592
+                    // This is where the checkbox icon for the files appear.
593
+                    $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">';
594
+                    $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
595
+                    $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
596
+                    //$dropbox_category_data[] = '';
597
+                    $dropbox_category_data[] = '';
598
+                    //$dropbox_category_data[] = '';
599
+                    $dropbox_category_data[] = '';
600
+                    $dropbox_category_data[] = '';
601
+                    $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.
602 602
                                     Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
603 603
 									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletesentcategory&id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.
604 604
                                     Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
605
-				}
606
-				if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
607
-					$dropbox_data_sent[] = $dropbox_category_data;
608
-				}
609
-			}
610
-		}
611
-
612
-		// Displaying the table
613
-		$additional_get_parameters = array(
605
+                }
606
+                if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
607
+                    $dropbox_data_sent[] = $dropbox_category_data;
608
+                }
609
+            }
610
+        }
611
+
612
+        // Displaying the table
613
+        $additional_get_parameters = array(
614 614
             'view' => $view,
615 615
             'view_received_category' => $viewReceivedCategory,
616 616
             'view_sent_category' => $viewSentCategory
617 617
         );
618 618
 
619
-		$selectlist = array(
619
+        $selectlist = array(
620 620
             'delete_received' => get_lang('Delete'),
621 621
             'download_received' => get_lang('Download')
622 622
         );
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
             }
628 628
         }
629 629
 
630
-		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
631
-			$selectlist = array('download_received' => get_lang('Download'));
632
-		}
630
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
631
+            $selectlist = array('download_received' => get_lang('Download'));
632
+        }
633 633
 
634 634
         echo '<div class="files-table">';
635
-		Display::display_sortable_config_table(
635
+        Display::display_sortable_config_table(
636 636
             'dropbox',
637 637
             $column_header,
638 638
             $dropbox_data_sent,
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
             $selectlist
645 645
         );
646 646
         echo '</div>';
647
-	}
647
+    }
648 648
 }
649 649
 
650 650
 Display::display_footer();
Please login to merge, or discard this patch.
main/inc/lib/login.lib.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -852,14 +852,14 @@  discard block
 block discarded – undo
852 852
             $email = false;
853 853
         }
854 854
 
855
-		if ($email) {
856
-			$condition = "LOWER(email) = '".Database::escape_string($username)."' ";
857
-		} else {
855
+        if ($email) {
856
+            $condition = "LOWER(email) = '".Database::escape_string($username)."' ";
857
+        } else {
858 858
             $condition = "LOWER(username) = '".Database::escape_string($username)."'";
859 859
         }
860 860
 
861
-		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
862
-		$query = "SELECT 
861
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
862
+        $query = "SELECT 
863 863
 		            user_id AS uid, 
864 864
 		            lastname AS lastName, 
865 865
 		            firstname AS firstName, 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                     auth_source
875 875
 				 FROM $tbl_user
876 876
 				 WHERE ( $condition AND active = 1) ";
877
-		$result = Database::query($query);
877
+        $result = Database::query($query);
878 878
         $num_rows = Database::num_rows($result);
879 879
         if ($result && $num_rows > 0) {
880 880
             return Database::fetch_assoc($result);
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Element/SelectLanguage.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
  */
8 8
 class SelectLanguage extends HTML_QuickForm_select
9 9
 {
10
-	/**
11
-	 * Class constructor
12
-	 */
13
-	public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
14
-	{
15
-		parent::__construct($elementName, $elementLabel, $options, $attributes);
16
-		// Get all languages
17
-		$languages = api_get_languages();
18
-		$this->_options = array();
19
-		$this->_values = array();
20
-		foreach ($languages['name'] as $index => $name) {
21
-			if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
22
-				$this->addOption($name, $languages['folder'][$index], array('selected'=>'selected'));
23
-			} else {
24
-				$this->addOption($name, $languages['folder'][$index]);
25
-			}
26
-		}
27
-	}
10
+    /**
11
+     * Class constructor
12
+     */
13
+    public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
14
+    {
15
+        parent::__construct($elementName, $elementLabel, $options, $attributes);
16
+        // Get all languages
17
+        $languages = api_get_languages();
18
+        $this->_options = array();
19
+        $this->_values = array();
20
+        foreach ($languages['name'] as $index => $name) {
21
+            if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
22
+                $this->addOption($name, $languages['folder'][$index], array('selected'=>'selected'));
23
+            } else {
24
+                $this->addOption($name, $languages['folder'][$index]);
25
+            }
26
+        }
27
+    }
28 28
 }
Please login to merge, or discard this patch.
main/document/show_content.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,11 +91,11 @@
 block discarded – undo
91 91
 $pathinfo = pathinfo($header_file);
92 92
 
93 93
 if ($pathinfo['extension']=='swf') {
94
-	$width='83%';
95
-	$height='83%';
94
+    $width='83%';
95
+    $height='83%';
96 96
 } else {
97
-	$width='100%';
98
-	$height='100%';
97
+    $width='100%';
98
+    $height='100%';
99 99
 }
100 100
 
101 101
 echo '<iframe border="0" frameborder="0" scrolling="no" style="width:'.$width.'; height:'.$height.';background-color:#ffffff;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&amp;rand='.mt_rand(1, 1000).'"></iframe>';
Please login to merge, or discard this patch.
main/admin/configure_homepage.php 1 patch
Indentation   +849 added lines, -849 removed lines patch added patch discarded remove patch
@@ -17,35 +17,35 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function home_tabs($file_logged_in)
19 19
 {
20
-	$post = strpos($file_logged_in, "_logged_in");
21
-	if ($post !== false) {
22
-		$file_logged_out = str_replace('_logged_in','', $file_logged_in);
23
-		//variables initialization
24
-		$data_logged_out = array();
25
-		$data_logged_in  = array();
26
-
27
-		//we read the file with all links
28
-		$file = file($file_logged_in);
29
-		foreach ($file as $line) {
30
-			$line = str_replace("\n", '',$line);
31
-			//not logged user only sees public links
32
-			if (!preg_match('/::private/',$line)) {
33
-				$data_logged_out[] = $line;
34
-			}
35
-			//logged user only sees all links
36
-			$data_logged_in[] = $line;
37
-		}
38
-		//tabs file for logged out users
39
-		if (file_exists($file_logged_out)) {
40
-			$fp = fopen($file_logged_out, 'w');
41
-			fputs($fp, implode("\n", $data_logged_out));
42
-			fclose($fp);
43
-		}
44
-		//tabs file for logged in users
45
-		$fp = fopen($file_logged_in, 'w');
46
-		fputs($fp, implode("\n", $data_logged_in));
47
-		fclose($fp);
48
-	}
20
+    $post = strpos($file_logged_in, "_logged_in");
21
+    if ($post !== false) {
22
+        $file_logged_out = str_replace('_logged_in','', $file_logged_in);
23
+        //variables initialization
24
+        $data_logged_out = array();
25
+        $data_logged_in  = array();
26
+
27
+        //we read the file with all links
28
+        $file = file($file_logged_in);
29
+        foreach ($file as $line) {
30
+            $line = str_replace("\n", '',$line);
31
+            //not logged user only sees public links
32
+            if (!preg_match('/::private/',$line)) {
33
+                $data_logged_out[] = $line;
34
+            }
35
+            //logged user only sees all links
36
+            $data_logged_in[] = $line;
37
+        }
38
+        //tabs file for logged out users
39
+        if (file_exists($file_logged_out)) {
40
+            $fp = fopen($file_logged_out, 'w');
41
+            fputs($fp, implode("\n", $data_logged_out));
42
+            fclose($fp);
43
+        }
44
+        //tabs file for logged in users
45
+        $fp = fopen($file_logged_in, 'w');
46
+        fputs($fp, implode("\n", $data_logged_in));
47
+        fclose($fp);
48
+    }
49 49
 }
50 50
 
51 51
 $cidReset = true;
@@ -76,39 +76,39 @@  discard block
 block discarded – undo
76 76
 $_languages = api_get_languages();
77 77
 $selfUrl =  api_get_self();
78 78
 $interbreadcrumb[] = array(
79
-	'url' => 'index.php',
80
-	'name' => get_lang('PlatformAdmin')
79
+    'url' => 'index.php',
80
+    'name' => get_lang('PlatformAdmin')
81 81
 );
82 82
 
83 83
 if (!empty($action)) {
84
-	$interbreadcrumb[] = array(
85
-		'url' => 'configure_homepage.php',
86
-		'name' => get_lang('ConfigureHomePage')
87
-	);
88
-
89
-	switch ($action) {
90
-		case 'edit_top':
91
-			$tool_name = get_lang('EditHomePage');
92
-			break;
93
-		case 'edit_news':
94
-			$tool_name = get_lang('EditNews');
95
-			break;
96
-		case 'edit_notice':
97
-			$tool_name = get_lang('EditNotice');
98
-			break;
99
-		case 'insert_link':
100
-			$tool_name = get_lang('InsertLink');
101
-			break;
102
-		case 'edit_link':
103
-			$tool_name = get_lang('EditLink');
104
-			break;
105
-		case 'insert_tabs':
106
-			$tool_name = get_lang('InsertTabs');
107
-			break;
108
-		case 'edit_tabs':
109
-			$tool_name = get_lang('EditTabs');
110
-			break;
111
-	}
84
+    $interbreadcrumb[] = array(
85
+        'url' => 'configure_homepage.php',
86
+        'name' => get_lang('ConfigureHomePage')
87
+    );
88
+
89
+    switch ($action) {
90
+        case 'edit_top':
91
+            $tool_name = get_lang('EditHomePage');
92
+            break;
93
+        case 'edit_news':
94
+            $tool_name = get_lang('EditNews');
95
+            break;
96
+        case 'edit_notice':
97
+            $tool_name = get_lang('EditNotice');
98
+            break;
99
+        case 'insert_link':
100
+            $tool_name = get_lang('InsertLink');
101
+            break;
102
+        case 'edit_link':
103
+            $tool_name = get_lang('EditLink');
104
+            break;
105
+        case 'insert_tabs':
106
+            $tool_name = get_lang('InsertTabs');
107
+            break;
108
+        case 'edit_tabs':
109
+            $tool_name = get_lang('EditTabs');
110
+            break;
111
+    }
112 112
 }
113 113
 
114 114
 // The global logic for language priorities should be:
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 
132 132
 $lang = ''; //el for "Edit Language"
133 133
 if (!empty($_SESSION['user_language_choice'])) {
134
-	$lang = $_SESSION['user_language_choice'];
134
+    $lang = $_SESSION['user_language_choice'];
135 135
 } elseif (!empty($_SESSION['_user']['language'])) {
136
-	$lang = $_SESSION['_user']['language'];
136
+    $lang = $_SESSION['_user']['language'];
137 137
 } else {
138
-	$lang = api_get_setting('platformLanguage');
138
+    $lang = api_get_setting('platformLanguage');
139 139
 }
140 140
 
141 141
 $languageGet = isset($_GET['language']) ? Security::remove_XSS($_GET['language']) : $lang;
@@ -144,25 +144,25 @@  discard block
 block discarded – undo
144 144
 $homePath = api_get_path(SYS_HOME_PATH);
145 145
 
146 146
 if (api_is_multiple_url_enabled()) {
147
-	$access_url_id = api_get_current_access_url_id();
148
-	if ($access_url_id != -1) {
149
-		$url_info = api_get_access_url($access_url_id);
150
-		$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
151
-		$clean_url = api_replace_dangerous_char($url);
152
-		$clean_url = str_replace('/', '-', $clean_url);
153
-		$clean_url .= '/';
154
-
155
-		$homep = $homePath; //homep for Home Path
156
-		$homep_new = $homePath.$clean_url; //homep for Home Path added the url
157
-		$new_url_dir = $homePath.$clean_url;
158
-		//we create the new dir for the new sites
159
-		if (!is_dir($new_url_dir)) {
160
-			mkdir($new_url_dir, api_get_permissions_for_new_directories());
161
-		}
162
-	}
147
+    $access_url_id = api_get_current_access_url_id();
148
+    if ($access_url_id != -1) {
149
+        $url_info = api_get_access_url($access_url_id);
150
+        $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
151
+        $clean_url = api_replace_dangerous_char($url);
152
+        $clean_url = str_replace('/', '-', $clean_url);
153
+        $clean_url .= '/';
154
+
155
+        $homep = $homePath; //homep for Home Path
156
+        $homep_new = $homePath.$clean_url; //homep for Home Path added the url
157
+        $new_url_dir = $homePath.$clean_url;
158
+        //we create the new dir for the new sites
159
+        if (!is_dir($new_url_dir)) {
160
+            mkdir($new_url_dir, api_get_permissions_for_new_directories());
161
+        }
162
+    }
163 163
 } else {
164
-	$homep_new = '';
165
-	$homep = $homePath; //homep for Home Path
164
+    $homep_new = '';
165
+    $homep = $homePath; //homep for Home Path
166 166
 }
167 167
 
168 168
 $menuf = 'home_menu'; //menuf for Menu File
@@ -177,25 +177,25 @@  discard block
 block discarded – undo
177 177
 
178 178
 // If language-specific file does not exist, create it by copying default file
179 179
 foreach ($homef as $my_file) {
180
-	if (api_is_multiple_url_enabled()) {
181
-		if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
182
-			if (!file_exists($homep.$my_file.$ext)) {
183
-				touch($homep.$my_file.$ext);
184
-			}
185
-			@copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
186
-		}
187
-	} else {
188
-		if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
189
-			if (!file_exists($homep.$my_file.$ext)) {
190
-				touch($homep.$my_file.$ext);
191
-			}
192
-			@copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
193
-		}
194
-	}
180
+    if (api_is_multiple_url_enabled()) {
181
+        if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
182
+            if (!file_exists($homep.$my_file.$ext)) {
183
+                touch($homep.$my_file.$ext);
184
+            }
185
+            @copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
186
+        }
187
+    } else {
188
+        if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
189
+            if (!file_exists($homep.$my_file.$ext)) {
190
+                touch($homep.$my_file.$ext);
191
+            }
192
+            @copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
193
+        }
194
+    }
195 195
 }
196 196
 
197 197
 if (api_is_multiple_url_enabled()) {
198
-	$homep = $homep_new;
198
+    $homep = $homep_new;
199 199
 }
200 200
 
201 201
 // Check WCAG settings and prepare edition using WCAG
@@ -204,578 +204,578 @@  discard block
 block discarded – undo
204 204
 // Filter link param
205 205
 $link = '';
206 206
 if (!empty($_GET['link'])) {
207
-	$link = $_GET['link'];
208
-	// If the link parameter is suspicious, empty it
209
-	if (strstr($link, '/') || !strstr($link, '.html') || strstr($link, '\\')) {
210
-		$link = '';
211
-		$action = '';
212
-	}
207
+    $link = $_GET['link'];
208
+    // If the link parameter is suspicious, empty it
209
+    if (strstr($link, '/') || !strstr($link, '.html') || strstr($link, '\\')) {
210
+        $link = '';
211
+        $action = '';
212
+    }
213 213
 }
214 214
 
215 215
 // Start analysing requested actions
216 216
 if (!empty($action)) {
217
-	if (!empty($_POST['formSent'])) {
218
-		// Variables used are $homep for home path, $menuf for menu file, $newsf
219
-		// for news file, $topf for top file, $noticef for noticefile,
220
-		// $ext for '.html'
221
-		switch ($action) {
222
-			case 'edit_top':
223
-				// Filter
224
-				$home_top = trim(stripslashes($_POST['home_top']));
225
-
226
-
227
-				// Write
228
-				if (is_writable($homep)) {
229
-					// Default
230
-					if (is_writable($homep.$topf.'_'.$lang.$ext)) {
231
-						$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
232
-						fputs($fp, $home_top);
233
-						fclose($fp);
234
-
235
-						// Language
236
-						foreach ($_languages['name'] as $key => $value) {
237
-							$lang_name = $_languages['folder'][$key];
238
-							if (isset($_POST[$lang_name])) {
239
-								$fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
240
-								fputs($fp, $home_top);
241
-								fclose($fp);
242
-							}
243
-						}
244
-					} else {
245
-						$errorMsg = get_lang('HomePageFilesNotWritable');
246
-					}
247
-				} else {
248
-					//File does not exist
249
-					$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
250
-					fputs($fp, $home_top);
251
-					fclose($fp);
252
-
253
-					foreach ($_languages['name'] as $key => $value) {
254
-						$lang_name = $_languages['folder'][$key];
255
-						if (isset($_POST[$lang_name])) {
256
-							if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
257
-								$fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
258
-								fputs($fp, $home_top);
259
-								fclose($fp);
260
-							}
261
-						}
262
-					}
263
-				}
264
-
265
-				if (EventsMail::check_if_using_class('portal_homepage_edited')) {
266
-					EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
267
-				}
268
-				Event::addEvent(
269
-					LOG_HOMEPAGE_CHANGED,
270
-					'edit_top',
271
-					cut(strip_tags($home_top), 254),
272
-					api_get_utc_datetime(),
273
-					api_get_user_id()
274
-				);
275
-				break;
276
-			case 'edit_notice':
277
-				// Filter
278
-				$notice_title = trim(strip_tags(stripslashes($_POST['notice_title'])));
279
-				$notice_text = trim(str_replace(array("\r", "\n"), array('', '<br />'), strip_tags(stripslashes($_POST['notice_text']), '<a>')));
280
-				if (empty($notice_title) || empty($notice_text)) {
281
-					$errorMsg = get_lang('NoticeWillBeNotDisplayed');
282
-				}
283
-				// Write
284
-				if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
285
-					if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
286
-						$fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
287
-						if ($errorMsg == '') {
288
-							fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
289
-
290
-							foreach ($_languages['name'] as $key => $value) {
291
-								$lang_name = $_languages['folder'][$key];
292
-								if (isset($_POST[$lang_name])) {
293
-									if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
294
-										if (is_writable($homep.$noticef.'_'.$lang_name.$ext)) {
295
-											$fp = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
296
-											fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
297
-											fclose($fp);
298
-										}
299
-									}
300
-								}
301
-							}
302
-						} else {
303
-							fputs($fp, '');
304
-
305
-							foreach ($_languages['name'] as $key => $value) {
306
-								$lang_name = $_languages['folder'][$key];
307
-								if (isset($_POST[$lang_name])) {
308
-									if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
309
-										$fp1 = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
310
-										fputs($fp1, '');
311
-										fclose($fp1);
312
-									}
313
-								}
314
-							}
315
-						}
316
-						fclose($fp);
317
-					} else {
318
-						$errorMsg .= "<br/>\n".get_lang('HomePageFilesNotWritable');
319
-					}
320
-				} else {
321
-					//File does not exist
322
-					$fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
323
-					fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
324
-					fclose($fp);
325
-				}
326
-				Event::addEvent(
217
+    if (!empty($_POST['formSent'])) {
218
+        // Variables used are $homep for home path, $menuf for menu file, $newsf
219
+        // for news file, $topf for top file, $noticef for noticefile,
220
+        // $ext for '.html'
221
+        switch ($action) {
222
+            case 'edit_top':
223
+                // Filter
224
+                $home_top = trim(stripslashes($_POST['home_top']));
225
+
226
+
227
+                // Write
228
+                if (is_writable($homep)) {
229
+                    // Default
230
+                    if (is_writable($homep.$topf.'_'.$lang.$ext)) {
231
+                        $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
232
+                        fputs($fp, $home_top);
233
+                        fclose($fp);
234
+
235
+                        // Language
236
+                        foreach ($_languages['name'] as $key => $value) {
237
+                            $lang_name = $_languages['folder'][$key];
238
+                            if (isset($_POST[$lang_name])) {
239
+                                $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
240
+                                fputs($fp, $home_top);
241
+                                fclose($fp);
242
+                            }
243
+                        }
244
+                    } else {
245
+                        $errorMsg = get_lang('HomePageFilesNotWritable');
246
+                    }
247
+                } else {
248
+                    //File does not exist
249
+                    $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
250
+                    fputs($fp, $home_top);
251
+                    fclose($fp);
252
+
253
+                    foreach ($_languages['name'] as $key => $value) {
254
+                        $lang_name = $_languages['folder'][$key];
255
+                        if (isset($_POST[$lang_name])) {
256
+                            if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
257
+                                $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
258
+                                fputs($fp, $home_top);
259
+                                fclose($fp);
260
+                            }
261
+                        }
262
+                    }
263
+                }
264
+
265
+                if (EventsMail::check_if_using_class('portal_homepage_edited')) {
266
+                    EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
267
+                }
268
+                Event::addEvent(
269
+                    LOG_HOMEPAGE_CHANGED,
270
+                    'edit_top',
271
+                    cut(strip_tags($home_top), 254),
272
+                    api_get_utc_datetime(),
273
+                    api_get_user_id()
274
+                );
275
+                break;
276
+            case 'edit_notice':
277
+                // Filter
278
+                $notice_title = trim(strip_tags(stripslashes($_POST['notice_title'])));
279
+                $notice_text = trim(str_replace(array("\r", "\n"), array('', '<br />'), strip_tags(stripslashes($_POST['notice_text']), '<a>')));
280
+                if (empty($notice_title) || empty($notice_text)) {
281
+                    $errorMsg = get_lang('NoticeWillBeNotDisplayed');
282
+                }
283
+                // Write
284
+                if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
285
+                    if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
286
+                        $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
287
+                        if ($errorMsg == '') {
288
+                            fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
289
+
290
+                            foreach ($_languages['name'] as $key => $value) {
291
+                                $lang_name = $_languages['folder'][$key];
292
+                                if (isset($_POST[$lang_name])) {
293
+                                    if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
294
+                                        if (is_writable($homep.$noticef.'_'.$lang_name.$ext)) {
295
+                                            $fp = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
296
+                                            fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
297
+                                            fclose($fp);
298
+                                        }
299
+                                    }
300
+                                }
301
+                            }
302
+                        } else {
303
+                            fputs($fp, '');
304
+
305
+                            foreach ($_languages['name'] as $key => $value) {
306
+                                $lang_name = $_languages['folder'][$key];
307
+                                if (isset($_POST[$lang_name])) {
308
+                                    if (file_exists($homep.$noticef.'_'.$lang_name.$ext)) {
309
+                                        $fp1 = fopen($homep.$noticef.'_'.$lang_name.$ext, 'w');
310
+                                        fputs($fp1, '');
311
+                                        fclose($fp1);
312
+                                    }
313
+                                }
314
+                            }
315
+                        }
316
+                        fclose($fp);
317
+                    } else {
318
+                        $errorMsg .= "<br/>\n".get_lang('HomePageFilesNotWritable');
319
+                    }
320
+                } else {
321
+                    //File does not exist
322
+                    $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
323
+                    fputs($fp, "<h5>$notice_title</h5><p>\n$notice_text");
324
+                    fclose($fp);
325
+                }
326
+                Event::addEvent(
327 327
                     LOG_HOMEPAGE_CHANGED,
328 328
                     'edit_notice',
329 329
                     cut(strip_tags($notice_title), 254),
330 330
                     api_get_utc_datetime(),
331 331
                     api_get_user_id()
332 332
                 );
333
-				break;
334
-			case 'edit_news':
335
-				//Filter
336
-				$home_news = trim(stripslashes($_POST['home_news']));
337
-
338
-				//Write
339
-				if ($s_languages_news != 'all') {
340
-					if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
341
-						if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
342
-							$fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
343
-							fputs($fp, $home_news);
344
-							fclose($fp);
345
-						} else {
346
-							$errorMsg = get_lang('HomePageFilesNotWritable');
347
-						}
348
-					} else {
349
-						// File does not exist
350
-						$fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
351
-						fputs($fp, $home_news);
352
-						fclose($fp);
353
-					}
354
-				} else {
355
-					// We update all the news file
356
-					foreach ($_languages['name'] as $key => $value) {
357
-						$english_name = $_languages['folder'][$key];
358
-						if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
359
-							if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
360
-								$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
361
-								fputs($fp, $home_news);
362
-								fclose($fp);
363
-							} else {
364
-								$errorMsg = get_lang('HomePageFilesNotWritable');
365
-							}
366
-						} else {
367
-							// File does not exist
368
-							$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
369
-							fputs($fp, $home_news);
370
-							fclose($fp);
371
-						}
372
-					}
373
-				}
374
-				Event::addEvent(
333
+                break;
334
+            case 'edit_news':
335
+                //Filter
336
+                $home_news = trim(stripslashes($_POST['home_news']));
337
+
338
+                //Write
339
+                if ($s_languages_news != 'all') {
340
+                    if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
341
+                        if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
342
+                            $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
343
+                            fputs($fp, $home_news);
344
+                            fclose($fp);
345
+                        } else {
346
+                            $errorMsg = get_lang('HomePageFilesNotWritable');
347
+                        }
348
+                    } else {
349
+                        // File does not exist
350
+                        $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
351
+                        fputs($fp, $home_news);
352
+                        fclose($fp);
353
+                    }
354
+                } else {
355
+                    // We update all the news file
356
+                    foreach ($_languages['name'] as $key => $value) {
357
+                        $english_name = $_languages['folder'][$key];
358
+                        if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
359
+                            if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
360
+                                $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
361
+                                fputs($fp, $home_news);
362
+                                fclose($fp);
363
+                            } else {
364
+                                $errorMsg = get_lang('HomePageFilesNotWritable');
365
+                            }
366
+                        } else {
367
+                            // File does not exist
368
+                            $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
369
+                            fputs($fp, $home_news);
370
+                            fclose($fp);
371
+                        }
372
+                    }
373
+                }
374
+                Event::addEvent(
375 375
                     LOG_HOMEPAGE_CHANGED,
376 376
                     'edit_news',
377 377
                     strip_tags(cut($home_news, 254)),
378 378
                     api_get_utc_datetime(),
379 379
                     api_get_user_id()
380 380
                 );
381
-				break;
382
-			case 'insert_tabs':
383
-			case 'edit_tabs':
384
-			case 'insert_link':
385
-			case 'edit_link':
386
-				$link_index     = intval($_POST['link_index']);
387
-				$insert_where   = intval($_POST['insert_where']);
388
-				$link_name      = trim(stripslashes($_POST['link_name']));
389
-				$link_url       = trim(stripslashes($_POST['link_url']));
390
-				$add_in_tab     = intval($_POST['add_in_tab']);
391
-				$link_html = trim(stripslashes($_POST['link_html']));
392
-				$filename = trim(stripslashes($_POST['filename']));
393
-				$target_blank = $_POST['target_blank'] ? true : false;
394
-
395
-				if ($link_url == 'http://' || $link_url == 'https://') {
396
-					$link_url = '';
397
-				} elseif (!empty($link_url) && !strstr($link_url, '://')) {
398
-					$link_url='http://'.$link_url;
399
-				}
400
-				$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
401
-
402
-				if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
403
-					$errorMsg = get_lang('HomePageFilesNotWritable');
404
-				} elseif (empty($link_name)) {
405
-					$errorMsg = get_lang('PleaseEnterLinkName');
406
-				} else {
407
-					// New links are added as new files in the home/ directory
408
-					if ($action == 'insert_link' || $action == 'insert_tabs' || empty($filename) || strstr($filename, '/') || !strstr($filename, '.html')) {
409
-						$filename = api_replace_dangerous_char($link_name).'.html';
410
-					}
411
-
412
-					// "home_" prefix for links are renamed to "user_" prefix (to avoid name clash with existing home page files)
413
-					if (!empty($filename)) {
414
-						$filename = str_replace('home_', 'user_', $filename);
415
-					}
416
-					// If the typical language suffix is not found in the file name,
417
-					// replace the ".html" suffix by "_en.html" or the active menu language
418
-					if (!strstr($filename,'_'.$lang.$ext)) {
419
-						$filename = str_replace($ext, '_'.$lang.$ext, $filename);
420
-					}
421
-					// Get the contents of home_menu_en.html (or active menu language
422
-					// version) into $home_menu as an array of one entry per line
423
-					$home_menu = file($homep.$menuf.'_'.$lang.$ext);
424
-					$home_menu = implode("\n", $home_menu);
425
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
426
-					$home_menu = explode("\n", $home_menu);
427
-					$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
428
-					// Prepare place to insert the new link into (default is end of file)
429
-					if ($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) {
430
-						$insert_where = sizeof($home_menu) - 1;
431
-					}
432
-					//
433
-					// For each line of the file, remove trailing spaces and special chars
434
-					//foreach ($home_menu as $key => $enreg) {
435
-					//	$home_menu[$key] = trim($enreg);
436
-					//}
437
-					//
438
-					// If the given link url is empty, then replace the link url by a link to the link file created
439
-
440
-					if (empty($link_url) || $link_url == 'http://' ||  $link_url == 'https://') {
441
-						$link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
442
-						// If the file doesn't exist, then create it and
443
-						// fill it with default text
444
-
445
-						$fp = @fopen($homep.$filename, 'w');
446
-						if ($fp) {
447
-							if (empty($link_html)) {
448
-								fputs($fp, get_lang('MyTextHere'));
449
-								home_tabs($homep.$filename);
450
-							} else {
451
-								fputs($fp, $link_html);
452
-								home_tabs($homep.$filename);
453
-							}
454
-							fclose($fp);
455
-						}
456
-					}
457
-					// If the requested action is to edit a link, open the file and
458
-					// write to it (if the file doesn't exist, create it)
459
-					if (in_array($action, array('edit_link'))  && !empty($link_html)) {
460
-						$fp = @fopen($homep.$filename, 'w');
461
-						if ($fp) {
462
-							fputs($fp, $link_html);
463
-							home_tabs($homep.$filename);
464
-							fclose($fp);
465
-						}
466
-					}
381
+                break;
382
+            case 'insert_tabs':
383
+            case 'edit_tabs':
384
+            case 'insert_link':
385
+            case 'edit_link':
386
+                $link_index     = intval($_POST['link_index']);
387
+                $insert_where   = intval($_POST['insert_where']);
388
+                $link_name      = trim(stripslashes($_POST['link_name']));
389
+                $link_url       = trim(stripslashes($_POST['link_url']));
390
+                $add_in_tab     = intval($_POST['add_in_tab']);
391
+                $link_html = trim(stripslashes($_POST['link_html']));
392
+                $filename = trim(stripslashes($_POST['filename']));
393
+                $target_blank = $_POST['target_blank'] ? true : false;
394
+
395
+                if ($link_url == 'http://' || $link_url == 'https://') {
396
+                    $link_url = '';
397
+                } elseif (!empty($link_url) && !strstr($link_url, '://')) {
398
+                    $link_url='http://'.$link_url;
399
+                }
400
+                $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf;
401
+
402
+                if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
403
+                    $errorMsg = get_lang('HomePageFilesNotWritable');
404
+                } elseif (empty($link_name)) {
405
+                    $errorMsg = get_lang('PleaseEnterLinkName');
406
+                } else {
407
+                    // New links are added as new files in the home/ directory
408
+                    if ($action == 'insert_link' || $action == 'insert_tabs' || empty($filename) || strstr($filename, '/') || !strstr($filename, '.html')) {
409
+                        $filename = api_replace_dangerous_char($link_name).'.html';
410
+                    }
411
+
412
+                    // "home_" prefix for links are renamed to "user_" prefix (to avoid name clash with existing home page files)
413
+                    if (!empty($filename)) {
414
+                        $filename = str_replace('home_', 'user_', $filename);
415
+                    }
416
+                    // If the typical language suffix is not found in the file name,
417
+                    // replace the ".html" suffix by "_en.html" or the active menu language
418
+                    if (!strstr($filename,'_'.$lang.$ext)) {
419
+                        $filename = str_replace($ext, '_'.$lang.$ext, $filename);
420
+                    }
421
+                    // Get the contents of home_menu_en.html (or active menu language
422
+                    // version) into $home_menu as an array of one entry per line
423
+                    $home_menu = file($homep.$menuf.'_'.$lang.$ext);
424
+                    $home_menu = implode("\n", $home_menu);
425
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
426
+                    $home_menu = explode("\n", $home_menu);
427
+                    $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
428
+                    // Prepare place to insert the new link into (default is end of file)
429
+                    if ($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) {
430
+                        $insert_where = sizeof($home_menu) - 1;
431
+                    }
432
+                    //
433
+                    // For each line of the file, remove trailing spaces and special chars
434
+                    //foreach ($home_menu as $key => $enreg) {
435
+                    //	$home_menu[$key] = trim($enreg);
436
+                    //}
437
+                    //
438
+                    // If the given link url is empty, then replace the link url by a link to the link file created
439
+
440
+                    if (empty($link_url) || $link_url == 'http://' ||  $link_url == 'https://') {
441
+                        $link_url = api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
442
+                        // If the file doesn't exist, then create it and
443
+                        // fill it with default text
444
+
445
+                        $fp = @fopen($homep.$filename, 'w');
446
+                        if ($fp) {
447
+                            if (empty($link_html)) {
448
+                                fputs($fp, get_lang('MyTextHere'));
449
+                                home_tabs($homep.$filename);
450
+                            } else {
451
+                                fputs($fp, $link_html);
452
+                                home_tabs($homep.$filename);
453
+                            }
454
+                            fclose($fp);
455
+                        }
456
+                    }
457
+                    // If the requested action is to edit a link, open the file and
458
+                    // write to it (if the file doesn't exist, create it)
459
+                    if (in_array($action, array('edit_link'))  && !empty($link_html)) {
460
+                        $fp = @fopen($homep.$filename, 'w');
461
+                        if ($fp) {
462
+                            fputs($fp, $link_html);
463
+                            home_tabs($homep.$filename);
464
+                            fclose($fp);
465
+                        }
466
+                    }
467 467
 
468 468
                     $class_add_in_tab = 'class="show_menu"';
469 469
 
470
-					if (!$add_in_tab) {
471
-						$class_add_in_tab = 'class="hide_menu"';
472
-					}
473
-
474
-					// If the requested action is to create a link, make some room
475
-					// for the new link in the home_menu array at the requested place
476
-					// and insert the new link there
477
-
478
-					if ($action == 'insert_link' || $action == 'insert_tabs') {
479
-						for ($i = sizeof($home_menu); $i; $i--) {
480
-							if ($i > $insert_where) {
481
-								$home_menu[$i] = $home_menu[$i - 1];
482
-							} else {
483
-								break;
484
-							}
485
-						}
486
-						$home_menu[$insert_where + 1] = '<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'. $link_name .'</a></li>';
487
-					} else {
488
-						// If the request is about a link edition, change the link
489
-						$home_menu[$link_index]='<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'. $link_name .'</a></li>';
490
-					}
491
-					// Re-build the file from the home_menu array
492
-					$home_menu = implode("\n", $home_menu);
493
-					// Write
494
-					if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
495
-						if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
496
-							$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
497
-							fputs($fp, $home_menu);
498
-							home_tabs($homep.$menuf.'_'.$lang.$ext);
499
-							fclose($fp);
500
-
501
-							foreach ($_languages['name'] as $key => $value) {
502
-								$lang_name = $_languages['folder'][$key];
503
-								if (isset($_POST[$lang_name])) {
504
-									$fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
505
-									fputs($fp, $home_menu);
506
-									home_tabs($homep.$menuf.'_'.$lang_name.$ext);
507
-									fclose($fp);
508
-								}
509
-							}
510
-
511
-							if (file_exists($homep.$menuf.$ext)) {
512
-								if (is_writable($homep.$menuf.$ext)) {
513
-									$fpo = fopen($homep.$menuf.$ext, 'w');
514
-									fputs($fpo, $home_menu);
515
-									home_tabs($homep.$menuf.$ext);
516
-									fclose($fpo);
517
-								}
518
-							}
519
-						} else {
520
-							$errorMsg = get_lang('HomePageFilesNotWritable');
521
-						}
522
-					} else {
523
-						//File does not exist
524
-						$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
525
-						fputs($fp, $home_menu);
526
-						home_tabs($homep.$menuf.'_'.$lang.$ext);
527
-						fclose($fp);
528
-
529
-						foreach ($_languages['name'] as $key => $value) {
530
-							$lang_name = $_languages['folder'][$key];
531
-							if (isset($_POST[$lang_name])) {
532
-								$fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
533
-								fputs($fp, $home_menu);
534
-								home_tabs($homep.$menuf.'_'.$lang_name.$ext);
535
-								fclose($fp);
536
-							}
537
-						}
538
-					}
539
-				}
540
-				Event::addEvent(
541
-					LOG_HOMEPAGE_CHANGED,
542
-					$action,
543
-					cut($link_name . ':' . $link_url, 254),
544
-					api_get_utc_datetime(),
545
-					api_get_user_id()
546
-				);
547
-				break;
548
-		} //end of switch($action)
549
-
550
-		if (empty($errorMsg)) {
551
-			header('Location: '.$selfUrl.'?language='.$languageGet);
552
-			exit();
553
-		}
554
-	} else {
555
-		//if POST[formSent] is not set
556
-		switch ($action) {
557
-			case 'open_link':
558
-				// Previously, filtering of GET['link'] was done here but it left
559
-				// a security threat. Filtering has now been moved outside conditions
560
-				break;
561
-			case 'delete_tabs':
562
-			case 'delete_link':
563
-				// A link is deleted by getting the file into an array, removing the
564
-				// link and re-writing the array to the file
565
-				$link_index = intval($_GET['link_index']);
566
-				$menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
567
-				$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
568
-				if (empty($home_menu)) {
569
-					$home_menu = array();
570
-				}
571
-				foreach ($home_menu as $key => $enreg) {
572
-					if ($key == $link_index) {
573
-						unset($home_menu[$key]);
574
-					} else {
575
-						$home_menu[$key] = trim($enreg);
576
-					}
577
-				}
578
-				$home_menu = implode("\n", $home_menu);
579
-				$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
580
-
581
-				$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
582
-				fputs($fp, $home_menu);
583
-				home_tabs($homep.$menuf.'_'.$lang.$ext);
584
-				fclose($fp);
585
-				if (file_exists($homep.$menuf.$ext)) {
586
-					if (is_writable($homep.$menuf.$ext)) {
587
-						$fpo = fopen($homep.$menuf.$ext,'w');
588
-						fputs($fpo, $home_menu);
589
-						home_tabs($homep.$menuf.$ext);
590
-						fclose($fpo);
591
-					}
592
-				}
593
-				header('Location: '.$selfUrl);
594
-				exit();
595
-				break;
596
-			case 'edit_top':
597
-				// This request is only the preparation for the update of the home_top
598
-				$home_top = '';
599
-				if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
600
-					$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
601
-				} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
602
-					$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
603
-				} else {
604
-					$errorMsg = get_lang('HomePageFilesNotReadable');
605
-				}
606
-				$home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
607
-				break;
608
-			case 'edit_notice':
609
-				// This request is only the preparation for the update of the home_notice
610
-				$home_notice = '';
611
-				if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
612
-					$home_notice = @file($homep.$noticef.'_'.$lang.$ext);
613
-				} elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
614
-					$home_notice = @file($homep.$noticef.$lang.$ext);
615
-				} else {
616
-					$errorMsg = get_lang('HomePageFilesNotReadable');
617
-				}
618
-				if (empty($home_notice)) {
619
-					$home_notice = array();
620
-				}
621
-				$notice_title = strip_tags($home_notice[0]);
622
-				$notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title));
623
-				$notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>');
624
-				$notice_text = api_to_system_encoding($notice_text, api_detect_encoding(strip_tags($notice_text)));
625
-				break;
626
-			case 'edit_news':
627
-				// This request is the preparation for the update of the home_news page
628
-				$home_news = '';
629
-				if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
630
-					$home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
631
-				} elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
632
-					$home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
633
-				} else {
634
-					$errorMsg = get_lang('HomePageFilesNotReadable');
635
-				}
636
-				$home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news)));
637
-				break;
638
-			case 'insert_link':
639
-				// This request is the preparation for the addition of an item in home_menu
640
-				$home_menu = '';
641
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
642
-				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
643
-					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
644
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
645
-					$home_menu = @file($homep.$menuf.$lang.$ext);
646
-				} else {
647
-					$errorMsg = get_lang('HomePageFilesNotReadable');
648
-				}
649
-				if (empty($home_menu)) {
650
-					$home_menu = array();
651
-				}
652
-				if (!empty($home_menu)) {
653
-					$home_menu = implode("\n", $home_menu);
654
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
655
-					$home_menu = explode("\n", $home_menu);
656
-				}
657
-				$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
658
-				break;
659
-			case 'insert_tabs':
660
-				// This request is the preparation for the addition of an item in home_menu
661
-				$home_menu = '';
662
-				if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
663
-					$home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
664
-				} elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
665
-					$home_menu = @file($homep.$mtloggedin.$lang.$ext);
666
-				} elseif (touch($homep.$mtloggedin.'_'.$lang.$ext)) {
667
-					$home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
668
-				} else {
669
-					$errorMsg = get_lang('HomePageFilesNotReadable');
670
-				}
671
-				if (empty($home_menu)) {
672
-					$home_menu = array();
673
-				}
674
-				if (!empty($home_menu)) {
675
-					$home_menu = implode("\n", $home_menu);
676
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
677
-					$home_menu = explode("\n", $home_menu);
678
-				}
679
-				$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
680
-				break;
681
-			case 'edit_tabs':
682
-			case 'edit_link':
683
-				// This request is the preparation for the edition of the links array
684
-				$home_menu = '';
685
-				$menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
686
-				if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
687
-					$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
688
-				} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
689
-					$home_menu = @file($homep.$menuf.$lang.$ext);
690
-				} else {
691
-					$errorMsg = get_lang('HomePageFilesNotReadable');
692
-				}
693
-
694
-				if (empty($home_menu)) {
695
-					if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
696
-						$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
697
-					}
698
-				}
699
-
700
-				if (empty($home_menu)) {
701
-					$home_menu = array();
702
-				}
703
-				if (!empty($home_menu)) {
704
-					$home_menu = implode("\n", $home_menu);
705
-					$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
706
-					$home_menu = explode("\n", $home_menu);
707
-				}
708
-
709
-				$link_index = intval($_GET['link_index']);
710
-
711
-				$target_blank = false;
712
-				$link_name = '';
713
-				$link_url = '';
714
-
715
-				//$home_menu_new = array();
716
-				//
717
-				//Cleaning array
718
-				//foreach ($home_menu as $item) {
719
-				//	if(!empty($item)) {
720
-				//		$home_menu_new[] = $item;
721
-				//	}
722
-				//}
723
-				//$home_menu = $home_menu_new;
724
-
725
-				// Cleaning the array
726
-				$home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
727
-
728
-				// For each line of the home_menu file
729
-				foreach ($home_menu as $key => $enreg) {
730
-
731
-					// Check if the current item is the one we want to update
732
-					if ($key == $link_index) {
733
-						// This is the link we want to update
734
-						// Check if the target should be "_blank"
735
-						if (strstr($enreg, 'target="_blank"')) {
736
-							$target_blank = true;
737
-						}
738
-
739
-						if (strstr($enreg, 'hide_menu')) {
740
-							$add_in_tab = false;
741
-						} else {
742
-							$add_in_tab = true;
743
-						}
744
-
745
-						// Remove dangerous HTML tags from the link itself (this is an
746
-						// additional measure in case a link previously contained
747
-						// unsecure tags)
748
-						$link_name = strip_tags($enreg);
749
-
750
-						// Get the contents of "href" attribute in $link_url
751
-						$enreg = explode('href="',$enreg);
752
-						list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
753
-
754
-						// If the link contains the web root of this portal, then strip
755
-						// it off and keep only the name of the file that needs edition
756
-						if (strstr($link_url, '?include=')) {
757
-							$link_url = explode('?include=', $link_url);
758
-
759
-							$filename = $link_url[sizeof($link_url) - 1];
760
-
761
-							if (!strstr($filename, '/') && strstr($filename, '.html')) {
762
-								// Get oonly the contents of the link file
763
-								$link_html = @file($homep.$filename);
764
-								$link_html = implode('', $link_html);
765
-								$link_url = '';
766
-							} else {
767
-								$filename = '';
768
-							}
769
-						}
770
-						break;
771
-					}
772
-				}
773
-				break;
774
-		}//end of second switch($action) (when POST['formSent'] was not set, yet)
775
-	}// end of "else" in if($_POST['formSent']) condition
470
+                    if (!$add_in_tab) {
471
+                        $class_add_in_tab = 'class="hide_menu"';
472
+                    }
473
+
474
+                    // If the requested action is to create a link, make some room
475
+                    // for the new link in the home_menu array at the requested place
476
+                    // and insert the new link there
477
+
478
+                    if ($action == 'insert_link' || $action == 'insert_tabs') {
479
+                        for ($i = sizeof($home_menu); $i; $i--) {
480
+                            if ($i > $insert_where) {
481
+                                $home_menu[$i] = $home_menu[$i - 1];
482
+                            } else {
483
+                                break;
484
+                            }
485
+                        }
486
+                        $home_menu[$insert_where + 1] = '<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'">'. $link_name .'</a></li>';
487
+                    } else {
488
+                        // If the request is about a link edition, change the link
489
+                        $home_menu[$link_index]='<li ' . $class_add_in_tab . '><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'. $link_name .'</a></li>';
490
+                    }
491
+                    // Re-build the file from the home_menu array
492
+                    $home_menu = implode("\n", $home_menu);
493
+                    // Write
494
+                    if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
495
+                        if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
496
+                            $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
497
+                            fputs($fp, $home_menu);
498
+                            home_tabs($homep.$menuf.'_'.$lang.$ext);
499
+                            fclose($fp);
500
+
501
+                            foreach ($_languages['name'] as $key => $value) {
502
+                                $lang_name = $_languages['folder'][$key];
503
+                                if (isset($_POST[$lang_name])) {
504
+                                    $fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
505
+                                    fputs($fp, $home_menu);
506
+                                    home_tabs($homep.$menuf.'_'.$lang_name.$ext);
507
+                                    fclose($fp);
508
+                                }
509
+                            }
510
+
511
+                            if (file_exists($homep.$menuf.$ext)) {
512
+                                if (is_writable($homep.$menuf.$ext)) {
513
+                                    $fpo = fopen($homep.$menuf.$ext, 'w');
514
+                                    fputs($fpo, $home_menu);
515
+                                    home_tabs($homep.$menuf.$ext);
516
+                                    fclose($fpo);
517
+                                }
518
+                            }
519
+                        } else {
520
+                            $errorMsg = get_lang('HomePageFilesNotWritable');
521
+                        }
522
+                    } else {
523
+                        //File does not exist
524
+                        $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
525
+                        fputs($fp, $home_menu);
526
+                        home_tabs($homep.$menuf.'_'.$lang.$ext);
527
+                        fclose($fp);
528
+
529
+                        foreach ($_languages['name'] as $key => $value) {
530
+                            $lang_name = $_languages['folder'][$key];
531
+                            if (isset($_POST[$lang_name])) {
532
+                                $fp = fopen($homep.$menuf.'_'.$lang_name.$ext, 'w');
533
+                                fputs($fp, $home_menu);
534
+                                home_tabs($homep.$menuf.'_'.$lang_name.$ext);
535
+                                fclose($fp);
536
+                            }
537
+                        }
538
+                    }
539
+                }
540
+                Event::addEvent(
541
+                    LOG_HOMEPAGE_CHANGED,
542
+                    $action,
543
+                    cut($link_name . ':' . $link_url, 254),
544
+                    api_get_utc_datetime(),
545
+                    api_get_user_id()
546
+                );
547
+                break;
548
+        } //end of switch($action)
549
+
550
+        if (empty($errorMsg)) {
551
+            header('Location: '.$selfUrl.'?language='.$languageGet);
552
+            exit();
553
+        }
554
+    } else {
555
+        //if POST[formSent] is not set
556
+        switch ($action) {
557
+            case 'open_link':
558
+                // Previously, filtering of GET['link'] was done here but it left
559
+                // a security threat. Filtering has now been moved outside conditions
560
+                break;
561
+            case 'delete_tabs':
562
+            case 'delete_link':
563
+                // A link is deleted by getting the file into an array, removing the
564
+                // link and re-writing the array to the file
565
+                $link_index = intval($_GET['link_index']);
566
+                $menuf = ($action == 'delete_tabs')? $mtloggedin : $menuf;
567
+                $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
568
+                if (empty($home_menu)) {
569
+                    $home_menu = array();
570
+                }
571
+                foreach ($home_menu as $key => $enreg) {
572
+                    if ($key == $link_index) {
573
+                        unset($home_menu[$key]);
574
+                    } else {
575
+                        $home_menu[$key] = trim($enreg);
576
+                    }
577
+                }
578
+                $home_menu = implode("\n", $home_menu);
579
+                $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
580
+
581
+                $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
582
+                fputs($fp, $home_menu);
583
+                home_tabs($homep.$menuf.'_'.$lang.$ext);
584
+                fclose($fp);
585
+                if (file_exists($homep.$menuf.$ext)) {
586
+                    if (is_writable($homep.$menuf.$ext)) {
587
+                        $fpo = fopen($homep.$menuf.$ext,'w');
588
+                        fputs($fpo, $home_menu);
589
+                        home_tabs($homep.$menuf.$ext);
590
+                        fclose($fpo);
591
+                    }
592
+                }
593
+                header('Location: '.$selfUrl);
594
+                exit();
595
+                break;
596
+            case 'edit_top':
597
+                // This request is only the preparation for the update of the home_top
598
+                $home_top = '';
599
+                if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
600
+                    $home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
601
+                } elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
602
+                    $home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
603
+                } else {
604
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
605
+                }
606
+                $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
607
+                break;
608
+            case 'edit_notice':
609
+                // This request is only the preparation for the update of the home_notice
610
+                $home_notice = '';
611
+                if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
612
+                    $home_notice = @file($homep.$noticef.'_'.$lang.$ext);
613
+                } elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
614
+                    $home_notice = @file($homep.$noticef.$lang.$ext);
615
+                } else {
616
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
617
+                }
618
+                if (empty($home_notice)) {
619
+                    $home_notice = array();
620
+                }
621
+                $notice_title = strip_tags($home_notice[0]);
622
+                $notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title));
623
+                $notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>');
624
+                $notice_text = api_to_system_encoding($notice_text, api_detect_encoding(strip_tags($notice_text)));
625
+                break;
626
+            case 'edit_news':
627
+                // This request is the preparation for the update of the home_news page
628
+                $home_news = '';
629
+                if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
630
+                    $home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
631
+                } elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
632
+                    $home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
633
+                } else {
634
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
635
+                }
636
+                $home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news)));
637
+                break;
638
+            case 'insert_link':
639
+                // This request is the preparation for the addition of an item in home_menu
640
+                $home_menu = '';
641
+                $menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
642
+                if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
643
+                    $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
644
+                } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
645
+                    $home_menu = @file($homep.$menuf.$lang.$ext);
646
+                } else {
647
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
648
+                }
649
+                if (empty($home_menu)) {
650
+                    $home_menu = array();
651
+                }
652
+                if (!empty($home_menu)) {
653
+                    $home_menu = implode("\n", $home_menu);
654
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
655
+                    $home_menu = explode("\n", $home_menu);
656
+                }
657
+                $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
658
+                break;
659
+            case 'insert_tabs':
660
+                // This request is the preparation for the addition of an item in home_menu
661
+                $home_menu = '';
662
+                if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) {
663
+                    $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
664
+                } elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) {
665
+                    $home_menu = @file($homep.$mtloggedin.$lang.$ext);
666
+                } elseif (touch($homep.$mtloggedin.'_'.$lang.$ext)) {
667
+                    $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
668
+                } else {
669
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
670
+                }
671
+                if (empty($home_menu)) {
672
+                    $home_menu = array();
673
+                }
674
+                if (!empty($home_menu)) {
675
+                    $home_menu = implode("\n", $home_menu);
676
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
677
+                    $home_menu = explode("\n", $home_menu);
678
+                }
679
+                $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
680
+                break;
681
+            case 'edit_tabs':
682
+            case 'edit_link':
683
+                // This request is the preparation for the edition of the links array
684
+                $home_menu = '';
685
+                $menuf = ($action == 'edit_tabs')? $mtloggedin : $menuf;
686
+                if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
687
+                    $home_menu = @file($homep.$menuf.'_'.$lang.$ext);
688
+                } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
689
+                    $home_menu = @file($homep.$menuf.$lang.$ext);
690
+                } else {
691
+                    $errorMsg = get_lang('HomePageFilesNotReadable');
692
+                }
693
+
694
+                if (empty($home_menu)) {
695
+                    if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
696
+                        $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
697
+                    }
698
+                }
699
+
700
+                if (empty($home_menu)) {
701
+                    $home_menu = array();
702
+                }
703
+                if (!empty($home_menu)) {
704
+                    $home_menu = implode("\n", $home_menu);
705
+                    $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
706
+                    $home_menu = explode("\n", $home_menu);
707
+                }
708
+
709
+                $link_index = intval($_GET['link_index']);
710
+
711
+                $target_blank = false;
712
+                $link_name = '';
713
+                $link_url = '';
714
+
715
+                //$home_menu_new = array();
716
+                //
717
+                //Cleaning array
718
+                //foreach ($home_menu as $item) {
719
+                //	if(!empty($item)) {
720
+                //		$home_menu_new[] = $item;
721
+                //	}
722
+                //}
723
+                //$home_menu = $home_menu_new;
724
+
725
+                // Cleaning the array
726
+                $home_menu = array_values(array_filter(array_map('trim', $home_menu), 'strlen'));
727
+
728
+                // For each line of the home_menu file
729
+                foreach ($home_menu as $key => $enreg) {
730
+
731
+                    // Check if the current item is the one we want to update
732
+                    if ($key == $link_index) {
733
+                        // This is the link we want to update
734
+                        // Check if the target should be "_blank"
735
+                        if (strstr($enreg, 'target="_blank"')) {
736
+                            $target_blank = true;
737
+                        }
738
+
739
+                        if (strstr($enreg, 'hide_menu')) {
740
+                            $add_in_tab = false;
741
+                        } else {
742
+                            $add_in_tab = true;
743
+                        }
744
+
745
+                        // Remove dangerous HTML tags from the link itself (this is an
746
+                        // additional measure in case a link previously contained
747
+                        // unsecure tags)
748
+                        $link_name = strip_tags($enreg);
749
+
750
+                        // Get the contents of "href" attribute in $link_url
751
+                        $enreg = explode('href="',$enreg);
752
+                        list($link_url) = explode('"', $enreg[sizeof($enreg) - 1]);
753
+
754
+                        // If the link contains the web root of this portal, then strip
755
+                        // it off and keep only the name of the file that needs edition
756
+                        if (strstr($link_url, '?include=')) {
757
+                            $link_url = explode('?include=', $link_url);
758
+
759
+                            $filename = $link_url[sizeof($link_url) - 1];
760
+
761
+                            if (!strstr($filename, '/') && strstr($filename, '.html')) {
762
+                                // Get oonly the contents of the link file
763
+                                $link_html = @file($homep.$filename);
764
+                                $link_html = implode('', $link_html);
765
+                                $link_url = '';
766
+                            } else {
767
+                                $filename = '';
768
+                            }
769
+                        }
770
+                        break;
771
+                    }
772
+                }
773
+                break;
774
+        }//end of second switch($action) (when POST['formSent'] was not set, yet)
775
+    }// end of "else" in if($_POST['formSent']) condition
776 776
 } else {
777
-	//if $action is empty, then prepare a list of the course categories to display (?)
778
-	$Categories = CourseCategory::getCategoriesToDisplayInHomePage();
777
+    //if $action is empty, then prepare a list of the course categories to display (?)
778
+    $Categories = CourseCategory::getCategoriesToDisplayInHomePage();
779 779
 }
780 780
 
781 781
 // Display section
@@ -783,25 +783,25 @@  discard block
 block discarded – undo
783 783
 Display::display_header($tool_name);
784 784
 
785 785
 switch ($action) {
786
-	case 'open_link':
787
-		if (!empty($link)) {
788
-			// $link is only set in case of action=open_link and is filtered
789
-			$open = @(string)file_get_contents($homep.$link);
790
-			$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
791
-			echo $open;
792
-		}
793
-		break;
794
-	case 'edit_notice':
795
-		// Display for edit_notice case
796
-		?>
786
+    case 'open_link':
787
+        if (!empty($link)) {
788
+            // $link is only set in case of action=open_link and is filtered
789
+            $open = @(string)file_get_contents($homep.$link);
790
+            $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
791
+            echo $open;
792
+        }
793
+        break;
794
+    case 'edit_notice':
795
+        // Display for edit_notice case
796
+        ?>
797 797
 		<form action="<?php echo $selfUrl; ?>?action=<?php echo $action; ?>" method="post" class="form-horizontal">
798 798
 			<legend><?php echo $tool_name; ?></legend>
799 799
 			<input type="hidden" name="formSent" value="1"/>
800 800
 			<?php
801
-			if (!empty($errorMsg)) {
802
-				Display::display_normal_message($errorMsg);
803
-			}
804
-			?>
801
+            if (!empty($errorMsg)) {
802
+                Display::display_normal_message($errorMsg);
803
+            }
804
+            ?>
805 805
                         <div class="row">
806 806
                             <div class="col-md-12">
807 807
                                 <p><?php echo get_lang('LetThoseFieldsEmptyToHideTheNotice'); ?></p>
@@ -839,170 +839,170 @@  discard block
 block discarded – undo
839 839
                         </div>
840 840
 		</form>
841 841
 		<?php
842
-		break;
843
-	case 'insert_tabs':
844
-	case 'edit_tabs':
845
-	case 'insert_link':
846
-	case 'edit_link':
847
-		$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
848
-		if (!empty($errorMsg)) {
849
-			Display::display_normal_message($errorMsg);
850
-		}
851
-		$default = array();
852
-		$form = new FormValidator('configure_homepage_'.$action, 'post', $selfUrl.'?action='.$action, '', array('style' => 'margin: 0px;'));
853
-		$renderer =& $form->defaultRenderer();
854
-
855
-		$form->addElement('header', '', $tool_name);
856
-		$form->addElement('hidden', 'formSent', '1');
857
-		$form->addElement('hidden', 'link_index', ($action == 'edit_link' || $action == 'edit_tabs') ? $link_index : '0');
858
-		$form->addElement('hidden', 'filename', ($action == 'edit_link' || $action == 'edit_tabs') ? (!empty($filename) ? $filename : '') : '');
859
-
860
-		$form->addElement('text', 'link_name', get_lang('LinkName'), array('size' => '30', 'maxlength' => '50'));
861
-		if (!empty($link_name)) {
862
-			$default['link_name'] = $link_name;
863
-		}
864
-		$default['link_url'] = empty($link_url) ? 'http://' : api_htmlentities($link_url, ENT_QUOTES);
865
-		$linkUrlComment = ($action == 'insert_tabs') ? get_lang('Optional').'<br />'.get_lang('GlobalLinkUseDoubleColumnPrivateToShowPrivately') : '';
866
-		$form->addElement('text', 'link_url', array(get_lang('LinkURL'), $linkUrlComment), array('size' => '30', 'maxlength' => '100', 'style' => 'width: 350px;'));
867
-
868
-		$options = array('-1' => get_lang('FirstPlace'));
869
-
870
-		$selected = '';
871
-
872
-		if ($action == 'insert_link' || $action == 'insert_tabs') {
873
-			$add_in_tab = 1;
874
-			if (is_array($home_menu)){
875
-				foreach ($home_menu as $key => $enreg) {
876
-					if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
877
-						$options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
878
-						$formSentCheck = (!empty($_POST['formSent']) ? true : false);
879
-						$selected = $formSentCheck && $insert_where == $key ? $key : '';
880
-					}
881
-				}
882
-			}
883
-			$default['insert_link'] = $selected;
884
-			$form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
885
-		}
886
-
887
-		$target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
888
-
889
-		if ($action == 'insert_tabs' || $action == 'edit_tabs') {
890
-			$form->addElement('checkbox', 'add_in_tab', null, get_lang('AddInMenu'), 1);
891
-			$default['add_in_tab'] = $add_in_tab;
892
-		}
893
-
894
-		if (!empty($target_blank)) { $target_blank_checkbox->setChecked(true); }
895
-
896
-		if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
897
-			$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
898
-			$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
842
+        break;
843
+    case 'insert_tabs':
844
+    case 'edit_tabs':
845
+    case 'insert_link':
846
+    case 'edit_link':
847
+        $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $mtloggedin : $menuf;
848
+        if (!empty($errorMsg)) {
849
+            Display::display_normal_message($errorMsg);
850
+        }
851
+        $default = array();
852
+        $form = new FormValidator('configure_homepage_'.$action, 'post', $selfUrl.'?action='.$action, '', array('style' => 'margin: 0px;'));
853
+        $renderer =& $form->defaultRenderer();
854
+
855
+        $form->addElement('header', '', $tool_name);
856
+        $form->addElement('hidden', 'formSent', '1');
857
+        $form->addElement('hidden', 'link_index', ($action == 'edit_link' || $action == 'edit_tabs') ? $link_index : '0');
858
+        $form->addElement('hidden', 'filename', ($action == 'edit_link' || $action == 'edit_tabs') ? (!empty($filename) ? $filename : '') : '');
859
+
860
+        $form->addElement('text', 'link_name', get_lang('LinkName'), array('size' => '30', 'maxlength' => '50'));
861
+        if (!empty($link_name)) {
862
+            $default['link_name'] = $link_name;
863
+        }
864
+        $default['link_url'] = empty($link_url) ? 'http://' : api_htmlentities($link_url, ENT_QUOTES);
865
+        $linkUrlComment = ($action == 'insert_tabs') ? get_lang('Optional').'<br />'.get_lang('GlobalLinkUseDoubleColumnPrivateToShowPrivately') : '';
866
+        $form->addElement('text', 'link_url', array(get_lang('LinkURL'), $linkUrlComment), array('size' => '30', 'maxlength' => '100', 'style' => 'width: 350px;'));
867
+
868
+        $options = array('-1' => get_lang('FirstPlace'));
869
+
870
+        $selected = '';
871
+
872
+        if ($action == 'insert_link' || $action == 'insert_tabs') {
873
+            $add_in_tab = 1;
874
+            if (is_array($home_menu)){
875
+                foreach ($home_menu as $key => $enreg) {
876
+                    if (strlen($enreg = trim(strip_tags($enreg))) > 0) {
877
+                        $options[$key] = get_lang('After').' &quot;'.$enreg.'&quot;';
878
+                        $formSentCheck = (!empty($_POST['formSent']) ? true : false);
879
+                        $selected = $formSentCheck && $insert_where == $key ? $key : '';
880
+                    }
881
+                }
882
+            }
883
+            $default['insert_link'] = $selected;
884
+            $form->addElement('select', 'insert_where', get_lang('InsertThisLink') , $options);
885
+        }
886
+
887
+        $target_blank_checkbox = $form->addElement('checkbox', 'target_blank', null, get_lang('OpenInNewWindow'), 1);
888
+
889
+        if ($action == 'insert_tabs' || $action == 'edit_tabs') {
890
+            $form->addElement('checkbox', 'add_in_tab', null, get_lang('AddInMenu'), 1);
891
+            $default['add_in_tab'] = $add_in_tab;
892
+        }
893
+
894
+        if (!empty($target_blank)) { $target_blank_checkbox->setChecked(true); }
895
+
896
+        if ($action == 'edit_link' && (empty($link_url) || $link_url == 'http://' || $link_url == 'https://')) {
897
+            $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : $link_html;
898
+            $form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
899 899
             $form->addButtonSave(get_lang('Save'),'submit');
900 900
 
901
-		} else {
902
-			if (in_array($action, array('edit_tabs','insert_tabs'))) {
903
-				$default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
904
-				$form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
905
-			}
906
-			$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
907
-			$form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
908
-			$i = 0;
909
-			foreach ($_languages['name'] as $key => $value) {
910
-				$i++;
911
-				$lang_name = $_languages['folder'][$key];
912
-				$html_langs = '<td width="300">';
913
-				$html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
914
-				$html_langs .= '</td>';
915
-				if ($i % 5 == 0) {
916
-					$html_langs .= '</tr><tr>';
917
-				}
918
-				$form->addElement('html', $html_langs);
919
-			}
920
-			$form->addElement('html','</tr></table><br/>');
901
+        } else {
902
+            if (in_array($action, array('edit_tabs','insert_tabs'))) {
903
+                $default['link_html'] = isset($_POST['link_html']) ? $_POST['link_html'] : (!empty($link_html) ? $link_html : '');
904
+                $form->addHtmlEditor('link_html', get_lang('Content'), false, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
905
+            }
906
+            $form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
907
+            $form->addElement('html','<table id="table_langs" style="margin-left:159px;"><tr>');
908
+            $i = 0;
909
+            foreach ($_languages['name'] as $key => $value) {
910
+                $i++;
911
+                $lang_name = $_languages['folder'][$key];
912
+                $html_langs = '<td width="300">';
913
+                $html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
914
+                $html_langs .= '</td>';
915
+                if ($i % 5 == 0) {
916
+                    $html_langs .= '</tr><tr>';
917
+                }
918
+                $form->addElement('html', $html_langs);
919
+            }
920
+            $form->addElement('html','</tr></table><br/>');
921 921
             $form->addButtonSave(get_lang('Save'),'submit');
922
-		}
923
-
924
-		$form->setDefaults($default);
925
-		$form->display();
926
-
927
-		break;
928
-	case 'edit_top':
929
-	case 'edit_news':
930
-		if ($action == 'edit_top') {
931
-			$name = $topf;
932
-			$open = $home_top;
933
-		} else {
934
-			$name = $newsf;
935
-			$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
936
-		}
937
-		$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
938
-
939
-		if (!empty($errorMsg)) {
940
-			Display::display_normal_message($errorMsg); //main API
941
-		}
942
-
943
-		$default = array();
944
-		$form = new FormValidator(
945
-			'configure_homepage_'.$action,
946
-			'post',
947
-			$selfUrl.'?action='.$action,
948
-			'',
949
-			array('style' => 'margin: 0px;')
950
-		);
951
-		$renderer =& $form->defaultRenderer();
952
-		$renderer->setHeaderTemplate('');
953
-		$renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
954
-		$renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
955
-		$renderer->setRequiredNoteTemplate('');
956
-		$form->addElement('hidden', 'formSent', '1');
957
-
958
-		if ($action == 'edit_news') {
959
-			$_languages = api_get_languages();
960
-			$html = '<tr><td>'.get_lang('ChooseNewsLanguage').' : ';
961
-			$html .= '<select name="news_languages">';
962
-			$html .= '<option value="all">'.get_lang('ApplyAllLanguages').'</option>';
963
-			foreach ($_languages['name'] as $key => $value) {
964
-				$english_name = $_languages['folder'][$key];
965
-				if ($language == $english_name) {
966
-					$html .= '<option value="'.$english_name.'" selected="selected">'.$value.'</option>';
967
-				} else {
968
-					$html .= '<option value="'.$english_name.'">'.$value.'</option>';
969
-				}
970
-			}
971
-			$html .= '</select></td></tr>';
972
-			$form->addElement('html', $html);
973
-		}
974
-
975
-		$default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
976
-		$form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
977
-		$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
978
-		$form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
979
-
980
-		$currentLanguage = api_get_interface_language();
981
-		$i = 0;
982
-		foreach ($_languages['name'] as $key => $value) {
983
-			$lang_name = $_languages['folder'][$key];
984
-			$i++;
985
-
986
-			$checked = null;
987
-			if ($languageGet == $lang_name)  {
988
-				$checked = "checked";
989
-			}
990
-			$html_langs = '<td width="300">';
991
-			$html_langs .= '<label><input type="checkbox" '.$checked.' id="lang" name="'.$lang_name.'" />&nbsp;'.$value.'<label/>';
992
-			$html_langs .= '</td>';
993
-			if ($i % 5 == 0) {
994
-				$html_langs .= '</tr><tr>';
995
-			}
996
-			$form->addElement('html', $html_langs);
997
-		}
998
-		$form->addElement('html','</tr></table><br/>');
999
-		$form->addButtonSave(get_lang('Save'));
1000
-		$form->setDefaults($default);
1001
-		$form->display();
1002
-
1003
-		break;
1004
-	default: // When no action applies, default page to update campus homepage
1005
-		?>
922
+        }
923
+
924
+        $form->setDefaults($default);
925
+        $form->display();
926
+
927
+        break;
928
+    case 'edit_top':
929
+    case 'edit_news':
930
+        if ($action == 'edit_top') {
931
+            $name = $topf;
932
+            $open = $home_top;
933
+        } else {
934
+            $name = $newsf;
935
+            $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
936
+        }
937
+        $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
938
+
939
+        if (!empty($errorMsg)) {
940
+            Display::display_normal_message($errorMsg); //main API
941
+        }
942
+
943
+        $default = array();
944
+        $form = new FormValidator(
945
+            'configure_homepage_'.$action,
946
+            'post',
947
+            $selfUrl.'?action='.$action,
948
+            '',
949
+            array('style' => 'margin: 0px;')
950
+        );
951
+        $renderer =& $form->defaultRenderer();
952
+        $renderer->setHeaderTemplate('');
953
+        $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
954
+        $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>');
955
+        $renderer->setRequiredNoteTemplate('');
956
+        $form->addElement('hidden', 'formSent', '1');
957
+
958
+        if ($action == 'edit_news') {
959
+            $_languages = api_get_languages();
960
+            $html = '<tr><td>'.get_lang('ChooseNewsLanguage').' : ';
961
+            $html .= '<select name="news_languages">';
962
+            $html .= '<option value="all">'.get_lang('ApplyAllLanguages').'</option>';
963
+            foreach ($_languages['name'] as $key => $value) {
964
+                $english_name = $_languages['folder'][$key];
965
+                if ($language == $english_name) {
966
+                    $html .= '<option value="'.$english_name.'" selected="selected">'.$value.'</option>';
967
+                } else {
968
+                    $html .= '<option value="'.$english_name.'">'.$value.'</option>';
969
+                }
970
+            }
971
+            $html .= '</select></td></tr>';
972
+            $form->addElement('html', $html);
973
+        }
974
+
975
+        $default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
976
+        $form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
977
+        $form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'),array('id' => 'all_langs'));
978
+        $form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
979
+
980
+        $currentLanguage = api_get_interface_language();
981
+        $i = 0;
982
+        foreach ($_languages['name'] as $key => $value) {
983
+            $lang_name = $_languages['folder'][$key];
984
+            $i++;
985
+
986
+            $checked = null;
987
+            if ($languageGet == $lang_name)  {
988
+                $checked = "checked";
989
+            }
990
+            $html_langs = '<td width="300">';
991
+            $html_langs .= '<label><input type="checkbox" '.$checked.' id="lang" name="'.$lang_name.'" />&nbsp;'.$value.'<label/>';
992
+            $html_langs .= '</td>';
993
+            if ($i % 5 == 0) {
994
+                $html_langs .= '</tr><tr>';
995
+            }
996
+            $form->addElement('html', $html_langs);
997
+        }
998
+        $form->addElement('html','</tr></table><br/>');
999
+        $form->addButtonSave(get_lang('Save'));
1000
+        $form->setDefaults($default);
1001
+        $form->display();
1002
+
1003
+        break;
1004
+    default: // When no action applies, default page to update campus homepage
1005
+        ?>
1006 1006
 
1007 1007
 <section id="page-home">
1008 1008
     <div class="row">
@@ -1158,53 +1158,53 @@  discard block
 block discarded – undo
1158 1158
             ?>
1159 1159
 
1160 1160
             <?php
1161
-		if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
1161
+        if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
1162 1162
                     $open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
1163 1163
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1164 1164
                     echo $open;
1165
-		} else {
1165
+        } else {
1166 1166
                     $open = @(string)file_get_contents($homep.$newsf.$ext);
1167 1167
                     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
1168 1168
                     echo $open;
1169
-		}
1169
+        }
1170 1170
             ?>
1171 1171
 
1172 1172
             <?php
1173 1173
                 // Add new page
1174
-		$home_menu = '';
1175
-		if (file_exists($homep.$mtloggedin.'_'.$lang.$ext)) {
1174
+        $home_menu = '';
1175
+        if (file_exists($homep.$mtloggedin.'_'.$lang.$ext)) {
1176 1176
                     $home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
1177
-		} else {
1177
+        } else {
1178 1178
                     $home_menu = @file($homep.$mtloggedin.$ext);
1179
-		}
1180
-		if (empty($home_menu)) {
1179
+        }
1180
+        if (empty($home_menu)) {
1181 1181
                     if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
1182
-			$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
1182
+            $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
1183 1183
                     }
1184
-		}
1185
-		if (empty($home_menu)) {
1184
+        }
1185
+        if (empty($home_menu)) {
1186 1186
                     $home_menu = array();
1187
-		}
1188
-		if (!empty($home_menu)) {
1187
+        }
1188
+        if (!empty($home_menu)) {
1189 1189
                     $home_menu = implode("\n", $home_menu);
1190 1190
                     $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
1191 1191
                     $home_menu = explode("\n", $home_menu);
1192
-		}
1193
-		$link_list = '';
1194
-		$tab_counter = 0;
1192
+        }
1193
+        $link_list = '';
1194
+        $tab_counter = 0;
1195 1195
                     foreach ($home_menu as $enreg) {
1196 1196
                     $enreg = trim($enreg);
1197
-			if (!empty($enreg)) {
1197
+            if (!empty($enreg)) {
1198 1198
                             $edit_link   = ' <a href="'.$selfUrl.'?action=edit_tabs&amp;link_index='.$tab_counter.'" ><span>'.Display::return_icon('edit.png', get_lang('Edit')).'</span></a>';
1199 1199
                             $delete_link = ' <a href="'.$selfUrl.'?action=delete_tabs&amp;link_index='.$tab_counter.'"  onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;"><span>'.Display::return_icon('delete.png', get_lang('Delete')).'</span></a>';
1200 1200
                             $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'),
1201 1201
                                 array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename($selfUrl).'?action=open_link&link=', $edit_link.$delete_link.'</li>'),
1202
-				$enreg);
1202
+                $enreg);
1203 1203
                             $tab_string = str_replace(array('<li>', '</li>','class="hide_menu"', 'hide_menu'), '', $tab_string);
1204
-				$link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
1205
-				$tab_counter++;
1206
-			}
1207
-		}
1204
+                $link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
1205
+                $tab_counter++;
1206
+            }
1207
+        }
1208 1208
             ?>
1209 1209
             <div class="actions">
1210 1210
 		<a href="<?php echo $selfUrl; ?>?action=insert_tabs">
@@ -1212,9 +1212,9 @@  discard block
 block discarded – undo
1212 1212
                 </a>
1213 1213
             </div>
1214 1214
             <?php
1215
-		echo '<ul id="list-hiperlink" class="list-group">';
1216
-		echo $link_list;
1217
-		echo '</ul>';
1215
+        echo '<ul id="list-hiperlink" class="list-group">';
1216
+        echo $link_list;
1217
+        echo '</ul>';
1218 1218
             ?>
1219 1219
         </div>
1220 1220
     </div>
Please login to merge, or discard this patch.
main/admin/ldap_synchro.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -44,121 +44,121 @@
 block discarded – undo
44 44
 $users=Database::store_result($result);
45 45
 
46 46
 foreach($Sessions as $session){
47
-	$id_session = $session['id'];
48
-	$name_session = $session['name'];
49
-	$UserList=array();
50
-	$UserUpdate=array();
51
-	$UserAdd=array();
47
+    $id_session = $session['id'];
48
+    $name_session = $session['name'];
49
+    $UserList=array();
50
+    $UserUpdate=array();
51
+    $UserAdd=array();
52 52
 
53
-	// Parse des code etape de la session
54
-	/*
53
+    // Parse des code etape de la session
54
+    /*
55 55
 	$sql = "SELECT  id_session, code_etape, etape_description, code_ufr, annee
56 56
 		FROM $tbl_session_rel_etape
57 57
 		WHERE id_session='$id_session'
58 58
 		ORDER BY code_ufr, code_etape";
59 59
 	$result = Database::query($sql);
60 60
 	*/
61
-	$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
62
-	ldap_set_version($ds);
63
-	// Import des utilisateurs des etapes dans la session
64
-	if ($ds)
65
-	{
66
-		$r = false;
67
-		$res = ldap_handle_bind($ds, $r);
68
-		$UserList=array();
69
-		if($result !== false)
70
-		{
71
-			//while($row = Database::fetch_array($result))
72
-			//{
73
-				/*
61
+    $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
62
+    ldap_set_version($ds);
63
+    // Import des utilisateurs des etapes dans la session
64
+    if ($ds)
65
+    {
66
+        $r = false;
67
+        $res = ldap_handle_bind($ds, $r);
68
+        $UserList=array();
69
+        if($result !== false)
70
+        {
71
+            //while($row = Database::fetch_array($result))
72
+            //{
73
+                /*
74 74
 				$annee = $row['annee'];
75 75
 				$code_ufr = $row['code_ufr'];
76 76
 				$etape = $row['code_etape'];
77 77
 				*/
78
-				// LDAP Query
79
-				// edupersonorgunitdn=ou=12CI1,ou=2006,ou=diploma,o=Paris1,dc=univ-paris1,dc=fr
80
-				//etapescommented
81
-				//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "edupersonorgunitdn=ou=$etape,ou=$annee,ou=diploma,$LDAPbasedn");
82
-				$sr = @ ldap_search($ds, $ldap_basedn, '(uid=*)');
83
-				$info = ldap_get_entries($ds, $sr);
84
-				for ($key = 0; $key < $info["count"]; $key ++)
85
-				{
86
-					echo "<pre>";
87
-					print_r($info[$key]);
88
-					echo "</pre>";
89
-					$lastname = api_utf8_decode($info[$key]["sn"][0]);
90
-					$firstname = api_utf8_decode($info[$key]["givenname"][0]);
91
-					$email = $info[$key]["mail"][0];
92
-					// Get uid from dn
93
-					$dn_array=ldap_explode_dn($info[$key]["dn"],1);
94
-					$username = $dn_array[0]; // uid is first key
95
-					$outab[] = $info[$key]["edupersonprimaryaffiliation"][0]; // Ici "student"
96
-					$val = ldap_get_values_len($ds, $sr, "userPassword");
97
-					$password = $val[0];
98
-					// Pour faciliter la gestion on ajoute le code "etape-annee"
99
-					$official_code=$etape."-".$annee;
100
-					$auth_source="ldap";
101
-					// Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP)
102
-					$expiration_date='';
103
-					$active=1;
104
-					// Ajout de l'utilisateur
105
-					if (UserManager::is_username_available($username)) {
106
-						$user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
107
-						$UserAdd[]=$user_id;
108
-					} else {
109
-						$user = api_get_user_info_from_username($username);
110
-						$user_id=$user['user_id'];
111
-						UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
112
-						$UserUpdate[]=$user_id;
113
-					}
114
-					$UserList[]=$user_id;
115
-				}
116
-			//}
117
-		}
118
-		if (isset($included) && ($included))
119
-		{
120
-			$message .= "> $name_session: ".count($UserAdd)." ".get_lang('Added').' '.get_lang('And').' '.count($UserUpdate).' '.get_lang('Modified').'<br/>';
121
-		}
122
-		else
123
-		{
124
-			print "> $name_session: ".count($UserAdd).get_lang('Added').' '.get_lang('And').' '.count($UserUpdate).' '.get_lang('Modified')."\n";
125
-		}
78
+                // LDAP Query
79
+                // edupersonorgunitdn=ou=12CI1,ou=2006,ou=diploma,o=Paris1,dc=univ-paris1,dc=fr
80
+                //etapescommented
81
+                //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "edupersonorgunitdn=ou=$etape,ou=$annee,ou=diploma,$LDAPbasedn");
82
+                $sr = @ ldap_search($ds, $ldap_basedn, '(uid=*)');
83
+                $info = ldap_get_entries($ds, $sr);
84
+                for ($key = 0; $key < $info["count"]; $key ++)
85
+                {
86
+                    echo "<pre>";
87
+                    print_r($info[$key]);
88
+                    echo "</pre>";
89
+                    $lastname = api_utf8_decode($info[$key]["sn"][0]);
90
+                    $firstname = api_utf8_decode($info[$key]["givenname"][0]);
91
+                    $email = $info[$key]["mail"][0];
92
+                    // Get uid from dn
93
+                    $dn_array=ldap_explode_dn($info[$key]["dn"],1);
94
+                    $username = $dn_array[0]; // uid is first key
95
+                    $outab[] = $info[$key]["edupersonprimaryaffiliation"][0]; // Ici "student"
96
+                    $val = ldap_get_values_len($ds, $sr, "userPassword");
97
+                    $password = $val[0];
98
+                    // Pour faciliter la gestion on ajoute le code "etape-annee"
99
+                    $official_code=$etape."-".$annee;
100
+                    $auth_source="ldap";
101
+                    // Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP)
102
+                    $expiration_date='';
103
+                    $active=1;
104
+                    // Ajout de l'utilisateur
105
+                    if (UserManager::is_username_available($username)) {
106
+                        $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
107
+                        $UserAdd[]=$user_id;
108
+                    } else {
109
+                        $user = api_get_user_info_from_username($username);
110
+                        $user_id=$user['user_id'];
111
+                        UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
112
+                        $UserUpdate[]=$user_id;
113
+                    }
114
+                    $UserList[]=$user_id;
115
+                }
116
+            //}
117
+        }
118
+        if (isset($included) && ($included))
119
+        {
120
+            $message .= "> $name_session: ".count($UserAdd)." ".get_lang('Added').' '.get_lang('And').' '.count($UserUpdate).' '.get_lang('Modified').'<br/>';
121
+        }
122
+        else
123
+        {
124
+            print "> $name_session: ".count($UserAdd).get_lang('Added').' '.get_lang('And').' '.count($UserUpdate).' '.get_lang('Modified')."\n";
125
+        }
126 126
 
127
-		// Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter la session
128
-		$result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'");
129
-		$CourseList=array();
130
-		while($row=Database::fetch_array($result)) {
131
-			$CourseList[]= $row['c_id'];
132
-		}
127
+        // Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter la session
128
+        $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'");
129
+        $CourseList=array();
130
+        while($row=Database::fetch_array($result)) {
131
+            $CourseList[]= $row['c_id'];
132
+        }
133 133
 
134
-		foreach ($CourseList as $enreg_course) {
135
-			// On ajoute la relation entre l'utilisateur et le cours
136
-			foreach ($UserList as $enreg_user) {
137
-				$sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id,c_id,user_id)
134
+        foreach ($CourseList as $enreg_course) {
135
+            // On ajoute la relation entre l'utilisateur et le cours
136
+            foreach ($UserList as $enreg_user) {
137
+                $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id,c_id,user_id)
138 138
 						VALUES('$id_session','$enreg_course','$enreg_user')";
139
-				Database::query($sql);
140
-			}
141
-			$sql = "SELECT COUNT(user_id) as nbUsers " .
142
-					"FROM $tbl_session_rel_course_rel_user " .
143
-					"WHERE session_id='$id_session' AND c_id='$enreg_course'";
144
-			$rs = Database::query($sql);
145
-			list($nbr_users) = Database::fetch_array($rs);
146
-			$sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users
139
+                Database::query($sql);
140
+            }
141
+            $sql = "SELECT COUNT(user_id) as nbUsers " .
142
+                    "FROM $tbl_session_rel_course_rel_user " .
143
+                    "WHERE session_id='$id_session' AND c_id='$enreg_course'";
144
+            $rs = Database::query($sql);
145
+            list($nbr_users) = Database::fetch_array($rs);
146
+            $sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users
147 147
 					WHERE session_id='$id_session' AND c_id = '$enreg_course'";
148
-			Database::query($sql);
149
-		}
150
-		// On ajoute la relation entre l'utilisateur et la session
151
-		foreach($UserList as $enreg_user){
152
-			$sql = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) " .
153
-					"VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')";
154
-			Database::query($sql);
155
-		}
156
-		$sql = "SELECT COUNT(user_id) as nbUsers " .
157
-				"FROM $tbl_session_rel_user " .
158
-				"WHERE session_id='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
159
-		$rs = Database::query($sql);
160
-		list($nbr_users) = Database::fetch_array($rs);
161
-		$sql = "UPDATE $tbl_session SET nbr_users=$nbr_users WHERE id='$id_session'";
162
-		Database::query($sql);
163
-	}
148
+            Database::query($sql);
149
+        }
150
+        // On ajoute la relation entre l'utilisateur et la session
151
+        foreach($UserList as $enreg_user){
152
+            $sql = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) " .
153
+                    "VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')";
154
+            Database::query($sql);
155
+        }
156
+        $sql = "SELECT COUNT(user_id) as nbUsers " .
157
+                "FROM $tbl_session_rel_user " .
158
+                "WHERE session_id='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
159
+        $rs = Database::query($sql);
160
+        list($nbr_users) = Database::fetch_array($rs);
161
+        $sql = "UPDATE $tbl_session SET nbr_users=$nbr_users WHERE id='$id_session'";
162
+        Database::query($sql);
163
+    }
164 164
 }
Please login to merge, or discard this patch.