Completed
Push — 1.11.x ( 81dbf4...6ab6ac )
by José
86:12 queued 55:54
created
main/dropbox/index.php 1 patch
Indentation   +424 added lines, -424 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;
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 // Display the form for adding a new dropbox item.
52 52
 if ($action == 'add') {
53
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
54
-		api_not_allowed();
55
-	}
53
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
54
+        api_not_allowed();
55
+    }
56 56
     display_add_form(
57 57
         $dropbox_unid,
58 58
         $viewReceivedCategory,
@@ -62,56 +62,56 @@  discard block
 block discarded – undo
62 62
 }
63 63
 
64 64
 if (isset($_POST['submitWork'])) {
65
-	$check = Security::check_token();
66
-	if ($check) {
65
+    $check = Security::check_token();
66
+    if ($check) {
67 67
         store_add_dropbox();
68
-	}
68
+    }
69 69
 }
70 70
 
71 71
 // Display the form for adding a category
72 72
 if ($action == 'addreceivedcategory' || $action == 'addsentcategory') {
73
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
74
-		api_not_allowed();
75
-	}
76
-	$categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : '';
77
-	display_addcategory_form($categoryName, '', $_GET['action']);
73
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
74
+        api_not_allowed();
75
+    }
76
+    $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : '';
77
+    display_addcategory_form($categoryName, '', $_GET['action']);
78 78
 }
79 79
 
80 80
 // Editing a category: displaying the form
81 81
 if ($action == 'editcategory' && isset($_GET['id'])) {
82
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
83
-		api_not_allowed();
84
-	}
85
-	if (!$_POST) {
86
-		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
87
-			api_not_allowed();
88
-		}
89
-		display_addcategory_form('', $_GET['id'], 'editcategory');
90
-	}
82
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
83
+        api_not_allowed();
84
+    }
85
+    if (!$_POST) {
86
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
87
+            api_not_allowed();
88
+        }
89
+        display_addcategory_form('', $_GET['id'], 'editcategory');
90
+    }
91 91
 }
92 92
 
93 93
 // Storing a new or edited category
94 94
 if (isset($_POST['StoreCategory'])) {
95
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
96
-		api_not_allowed();
97
-	}
98
-	$return_information = store_addcategory();
99
-	if ($return_information['type'] == 'confirmation') {
100
-		Display :: display_confirmation_message($return_information['message']);
101
-	}
102
-	if ($return_information['type'] == 'error') {
103
-		Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
104
-		display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
105
-	}
95
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
96
+        api_not_allowed();
97
+    }
98
+    $return_information = store_addcategory();
99
+    if ($return_information['type'] == 'confirmation') {
100
+        Display :: display_confirmation_message($return_information['message']);
101
+    }
102
+    if ($return_information['type'] == 'error') {
103
+        Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
104
+        display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
105
+    }
106 106
 }
107 107
 
108 108
 
109 109
 // Move a File
110 110
 if (($action == 'movesent' || $action == 'movereceived') AND isset($_GET['move_id'])) {
111
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
112
-		api_not_allowed();
113
-	}
114
-	display_move_form(
111
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
112
+        api_not_allowed();
113
+    }
114
+    display_move_form(
115 115
         str_replace('move', '', $action),
116 116
         $_GET['move_id'],
117 117
         get_dropbox_categories(str_replace('move', '', $action)),
@@ -122,33 +122,33 @@  discard block
 block discarded – undo
122 122
     );
123 123
 }
124 124
 if (isset($_POST['do_move'])) {
125
-	Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
125
+    Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
126 126
 }
127 127
 
128 128
 // Delete a file
129 129
 if (($action == 'deletereceivedfile' || $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
130
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
131
-		api_not_allowed();
132
-	}
133
-	$dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
134
-	if ($action == 'deletereceivedfile') {
135
-		$dropboxfile->deleteReceivedWork($_GET['id']);
136
-		$message = get_lang('ReceivedFileDeleted');
137
-	}
138
-	if ($action == 'deletesentfile') {
139
-		$dropboxfile->deleteSentWork($_GET['id']);
140
-		$message = get_lang('SentFileDeleted');
141
-	}
142
-	Display :: display_confirmation_message($message);
130
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
131
+        api_not_allowed();
132
+    }
133
+    $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
134
+    if ($action == 'deletereceivedfile') {
135
+        $dropboxfile->deleteReceivedWork($_GET['id']);
136
+        $message = get_lang('ReceivedFileDeleted');
137
+    }
138
+    if ($action == 'deletesentfile') {
139
+        $dropboxfile->deleteSentWork($_GET['id']);
140
+        $message = get_lang('SentFileDeleted');
141
+    }
142
+    Display :: display_confirmation_message($message);
143 143
 }
144 144
 
145 145
 // Delete a category
146 146
 if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
147
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
148
-		api_not_allowed();
149
-	}
150
-	$message = delete_category($action, $_GET['id']);
151
-	Display :: display_confirmation_message($message);
147
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
148
+        api_not_allowed();
149
+    }
150
+    $message = delete_category($action, $_GET['id']);
151
+    Display :: display_confirmation_message($message);
152 152
 }
153 153
 
154 154
 // Do an action on multiple files
@@ -163,27 +163,27 @@  discard block
 block discarded – undo
163 163
     $postAction == 'delete_sent' ||
164 164
     $postAction == 'download_sent')
165 165
 ) {
166
-	$display_message = handle_multiple_actions();
167
-	Display :: display_normal_message($display_message);
166
+    $display_message = handle_multiple_actions();
167
+    Display :: display_normal_message($display_message);
168 168
 }
169 169
 
170 170
 // Store Feedback
171 171
 
172 172
 if (isset($_POST['feedback'])) {
173
-	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
174
-		api_not_allowed();
175
-	}
176
-	$check = Security::check_token();
177
-	if ($check) {
178
-		$display_message = store_feedback();
179
-		Display :: display_normal_message($display_message);
180
-		Security::check_token();
181
-	}
173
+    if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
174
+        api_not_allowed();
175
+    }
176
+    $check = Security::check_token();
177
+    if ($check) {
178
+        $display_message = store_feedback();
179
+        Display :: display_normal_message($display_message);
180
+        Security::check_token();
181
+    }
182 182
 }
183 183
 
184 184
 // Error Message
185 185
 if (isset($_GET['error']) AND !empty($_GET['error'])) {
186
-	Display :: display_normal_message(get_lang($_GET['error']));
186
+    Display :: display_normal_message(get_lang($_GET['error']));
187 187
 }
188 188
 
189 189
 $dropbox_data_sent = array();
@@ -191,96 +191,96 @@  discard block
 block discarded – undo
191 191
 $dropbox_data_recieved = array();
192 192
 
193 193
 if ($action != 'add') {
194
-	// Getting all the categories in the dropbox for the given user
195
-	$dropbox_categories = get_dropbox_categories();
196
-	// Greating the arrays with the categories for the received files and for the sent files
197
-	foreach ($dropbox_categories as $category) {
198
-		if ($category['received'] == '1') {
199
-			$dropbox_received_category[] = $category;
200
-		}
201
-		if ($category['sent'] == '1') {
202
-			$dropbox_sent_category[] = $category;
203
-		}
204
-	}
205
-
206
-	// ACTIONS
207
-	if ($view == 'received' || !$showSentReceivedTabs) {
208
-		//echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
209
-
210
-		// This is for the categories
211
-		if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
212
-			$view_dropbox_category_received = $viewReceivedCategory;
213
-		} else {
214
-			$view_dropbox_category_received = 0;
215
-		}
216
-
217
-		/* Menu Received */
218
-
219
-		if (api_get_session_id() == 0) {
220
-			echo '<div class="actions">';
221
-			if ($view_dropbox_category_received != 0  && api_is_allowed_to_session_edit(false, true)) {
222
-				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>";
223
-				echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
224
-				$movelist[0] = 'Root'; // move_received selectbox content
225
-			} else {
226
-				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>';
227
-			}
228
-			echo '</div>';
229
-		} else {
230
-			if (api_is_allowed_to_session_edit(false, true)) {
231
-				echo '<div class="actions">';
232
-				if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
233
-					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>";
234
-					echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
235
-					$movelist[0] = 'Root'; // move_received selectbox content
236
-				} else {
237
-					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>';
238
-				}
239
-				echo '</div>';
240
-			}
241
-		}
242
-	}
243
-
244
-	if (!$view || $view == 'sent' || !$showSentReceivedTabs) {
245
-		// This is for the categories
246
-		if (isset($viewSentCategory) AND $viewSentCategory != '') {
247
-			$view_dropbox_category_sent = $viewSentCategory;
248
-		} else {
249
-			$view_dropbox_category_sent = 0;
250
-		}
251
-
252
-		/* Menu Sent */
253
-
254
-		if (api_get_session_id() == 0) {
255
-			echo '<div class="actions">';
256
-			if ($view_dropbox_category_sent != 0) {
257
-				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>";
258
-				echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
259
-			} else {
260
-				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";
261
-			}
262
-			if (empty($viewSentCategory)) {
263
-				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>";
264
-			}
265
-			echo '</div>';
266
-		} else {
267
-			if (api_is_allowed_to_session_edit(false, true)) {
268
-				echo '<div class="actions">';
269
-				if ($view_dropbox_category_sent != 0) {
270
-					echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
271
-					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>";
272
-				} else {
273
-					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";
274
-				}
275
-				if (empty($viewSentCategory)) {
276
-					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>";
277
-				}
278
-				echo '</div>';
279
-			}
280
-		}
281
-	}
282
-	/*	THE MENU TABS */
283
-	if ($showSentReceivedTabs) {
194
+    // Getting all the categories in the dropbox for the given user
195
+    $dropbox_categories = get_dropbox_categories();
196
+    // Greating the arrays with the categories for the received files and for the sent files
197
+    foreach ($dropbox_categories as $category) {
198
+        if ($category['received'] == '1') {
199
+            $dropbox_received_category[] = $category;
200
+        }
201
+        if ($category['sent'] == '1') {
202
+            $dropbox_sent_category[] = $category;
203
+        }
204
+    }
205
+
206
+    // ACTIONS
207
+    if ($view == 'received' || !$showSentReceivedTabs) {
208
+        //echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
209
+
210
+        // This is for the categories
211
+        if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
212
+            $view_dropbox_category_received = $viewReceivedCategory;
213
+        } else {
214
+            $view_dropbox_category_received = 0;
215
+        }
216
+
217
+        /* Menu Received */
218
+
219
+        if (api_get_session_id() == 0) {
220
+            echo '<div class="actions">';
221
+            if ($view_dropbox_category_received != 0  && api_is_allowed_to_session_edit(false, true)) {
222
+                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>";
223
+                echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
224
+                $movelist[0] = 'Root'; // move_received selectbox content
225
+            } else {
226
+                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>';
227
+            }
228
+            echo '</div>';
229
+        } else {
230
+            if (api_is_allowed_to_session_edit(false, true)) {
231
+                echo '<div class="actions">';
232
+                if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
233
+                    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>";
234
+                    echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
235
+                    $movelist[0] = 'Root'; // move_received selectbox content
236
+                } else {
237
+                    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>';
238
+                }
239
+                echo '</div>';
240
+            }
241
+        }
242
+    }
243
+
244
+    if (!$view || $view == 'sent' || !$showSentReceivedTabs) {
245
+        // This is for the categories
246
+        if (isset($viewSentCategory) AND $viewSentCategory != '') {
247
+            $view_dropbox_category_sent = $viewSentCategory;
248
+        } else {
249
+            $view_dropbox_category_sent = 0;
250
+        }
251
+
252
+        /* Menu Sent */
253
+
254
+        if (api_get_session_id() == 0) {
255
+            echo '<div class="actions">';
256
+            if ($view_dropbox_category_sent != 0) {
257
+                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>";
258
+                echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
259
+            } else {
260
+                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";
261
+            }
262
+            if (empty($viewSentCategory)) {
263
+                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>";
264
+            }
265
+            echo '</div>';
266
+        } else {
267
+            if (api_is_allowed_to_session_edit(false, true)) {
268
+                echo '<div class="actions">';
269
+                if ($view_dropbox_category_sent != 0) {
270
+                    echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
271
+                    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>";
272
+                } else {
273
+                    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";
274
+                }
275
+                if (empty($viewSentCategory)) {
276
+                    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>";
277
+                }
278
+                echo '</div>';
279
+            }
280
+        }
281
+    }
282
+    /*	THE MENU TABS */
283
+    if ($showSentReceivedTabs) {
284 284
 ?>
285 285
 <ul class="nav nav-tabs">
286 286
     <li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> >
@@ -294,80 +294,80 @@  discard block
 block discarded – undo
294 294
     </li>
295 295
 </ul>
296 296
 <?php
297
-	}
297
+    }
298 298
     /*	RECEIVED FILES */
299
-	if ($view == 'received' || !$showSentReceivedTabs) {
300
-		// This is for the categories
301
-		if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
302
-			$view_dropbox_category_received = $viewReceivedCategory;
303
-		} else {
304
-			$view_dropbox_category_received = 0;
305
-		}
306
-
307
-		// Object initialisation
308
-		$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
309
-		 // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
310
-
311
-		// Constructing the array that contains the total number of feedback messages per document.
312
-		$number_feedback = get_total_number_feedback();
313
-
314
-		// Sorting and paging options
315
-		$sorting_options = array();
316
-		$paging_options = array();
317
-
318
-		// The headers of the sortable tables
319
-		$column_header = array();
320
-		$column_header[] = array('', false, '');
321
-		$column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
322
-		$column_header[] = array(get_lang('ReceivedTitle'), true, '');
323
-		$column_header[] = array(get_lang('Size'), true, '');
324
-		$column_header[] = array(get_lang('Authors'), true, '');
325
-		$column_header[] = array(get_lang('LastResent'), true);
326
-
327
-		if (api_get_session_id() == 0) {
328
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
329
-		} elseif (api_is_allowed_to_session_edit(false,true)) {
330
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
331
-		}
332
-
333
-		$column_header[] = array('RealDate', true);
334
-		$column_header[] = array('RealSize', true);
335
-
336
-		// An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
337
-		$column_show[] = 1;
338
-		$column_show[] = 1;
339
-		$column_show[] = 1;
340
-		$column_show[] = 1;
341
-		$column_show[] = 1;
342
-		$column_show[] = 1;
343
-
344
-		if (api_get_session_id() == 0) {
345
-			$column_show[] = 1;
346
-		} elseif (api_is_allowed_to_session_edit(false, true)) {
347
-			$column_show[] = 1;
348
-		}
349
-		$column_show[] = 0;
350
-
351
-		// Here we change the way how the columns are going to be sort
352
-		// in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
353
-		// because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
354
-
355
-		$column_order[3] = 8;
356
-		$column_order[5] = 7;
357
-
358
-		// The content of the sortable table = the received files
359
-		foreach ($dropbox_person -> receivedWork as $dropbox_file) {
360
-			$dropbox_file_data = array();
361
-			if ($view_dropbox_category_received == $dropbox_file->category) {
299
+    if ($view == 'received' || !$showSentReceivedTabs) {
300
+        // This is for the categories
301
+        if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
302
+            $view_dropbox_category_received = $viewReceivedCategory;
303
+        } else {
304
+            $view_dropbox_category_received = 0;
305
+        }
306
+
307
+        // Object initialisation
308
+        $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
309
+            // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
310
+
311
+        // Constructing the array that contains the total number of feedback messages per document.
312
+        $number_feedback = get_total_number_feedback();
313
+
314
+        // Sorting and paging options
315
+        $sorting_options = array();
316
+        $paging_options = array();
317
+
318
+        // The headers of the sortable tables
319
+        $column_header = array();
320
+        $column_header[] = array('', false, '');
321
+        $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
322
+        $column_header[] = array(get_lang('ReceivedTitle'), true, '');
323
+        $column_header[] = array(get_lang('Size'), true, '');
324
+        $column_header[] = array(get_lang('Authors'), true, '');
325
+        $column_header[] = array(get_lang('LastResent'), true);
326
+
327
+        if (api_get_session_id() == 0) {
328
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
329
+        } elseif (api_is_allowed_to_session_edit(false,true)) {
330
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
331
+        }
332
+
333
+        $column_header[] = array('RealDate', true);
334
+        $column_header[] = array('RealSize', true);
335
+
336
+        // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
337
+        $column_show[] = 1;
338
+        $column_show[] = 1;
339
+        $column_show[] = 1;
340
+        $column_show[] = 1;
341
+        $column_show[] = 1;
342
+        $column_show[] = 1;
343
+
344
+        if (api_get_session_id() == 0) {
345
+            $column_show[] = 1;
346
+        } elseif (api_is_allowed_to_session_edit(false, true)) {
347
+            $column_show[] = 1;
348
+        }
349
+        $column_show[] = 0;
350
+
351
+        // Here we change the way how the columns are going to be sort
352
+        // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
353
+        // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
354
+
355
+        $column_order[3] = 8;
356
+        $column_order[5] = 7;
357
+
358
+        // The content of the sortable table = the received files
359
+        foreach ($dropbox_person -> receivedWork as $dropbox_file) {
360
+            $dropbox_file_data = array();
361
+            if ($view_dropbox_category_received == $dropbox_file->category) {
362 362
                 // we only display the files that are in the category that we are in.
363
-				$dropbox_file_data[] = $dropbox_file->id;
363
+                $dropbox_file_data[] = $dropbox_file->id;
364 364
 
365
-				if (isset($_SESSION['_seen']) && !is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
366
-					$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
367
-				}
365
+                if (isset($_SESSION['_seen']) && !is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
366
+                    $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
367
+                }
368 368
 
369
-				// New icon
370
-				$new_icon = '';
369
+                // New icon
370
+                $new_icon = '';
371 371
                 if (isset($_SESSION['_seen'])) {
372 372
                     if ($dropbox_file->last_upload_date > $last_access &&
373 373
                         !in_array(
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
                     }
385 385
                 }
386 386
 
387
-				$link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
388
-				$dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
389
-				$dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
387
+                $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
388
+                $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
389
+                $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
390 390
                     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;
391
-				$file_size = $dropbox_file->filesize;
392
-				$dropbox_file_data[] = format_file_size($file_size);
391
+                $file_size = $dropbox_file->filesize;
392
+                $dropbox_file_data[] = format_file_size($file_size);
393 393
 
394 394
                 $authorInfo = api_get_user_info($dropbox_file->uploader_id);
395 395
                 if ($authorInfo) {
@@ -398,62 +398,62 @@  discard block
 block discarded – undo
398 398
                     $dropbox_file_data[] = '';
399 399
                 }
400 400
 
401
-				$last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
402
-				$dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
401
+                $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
402
+                $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
403 403
                     api_format_date($last_upload_date).'</span>';
404 404
 
405
-				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
405
+                $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
406 406
                 <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>
407 407
                 <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>
408 408
                 <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.'\');">'.
409 409
                 Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
410 410
 
411
-				// This is a hack to have an additional row in a sortable table
412
-
413
-				if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
414
-					$action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
415
-					$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>";
416
-				}
417
-				if (api_get_session_id() == 0) {
418
-					$dropbox_file_data[] = $action_icons;
419
-				} elseif (api_is_allowed_to_session_edit(false, true)) {
420
-					$dropbox_file_data[] = $action_icons;
421
-				}
422
-				$action_icons = '';
423
-				$dropbox_file_data[] = $last_upload_date;
424
-				$dropbox_file_data[] = $file_size;
425
-				$dropbox_data_recieved[] = $dropbox_file_data;
426
-			}
427
-		}
428
-
429
-		// The content of the sortable table = the categories (if we are not in the root)
430
-		if ($view_dropbox_category_received == 0) {
431
-			foreach ($dropbox_categories as $category) {
432
-			    /*  Note: This can probably be shortened since the categories
411
+                // This is a hack to have an additional row in a sortable table
412
+
413
+                if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
414
+                    $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
415
+                    $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>";
416
+                }
417
+                if (api_get_session_id() == 0) {
418
+                    $dropbox_file_data[] = $action_icons;
419
+                } elseif (api_is_allowed_to_session_edit(false, true)) {
420
+                    $dropbox_file_data[] = $action_icons;
421
+                }
422
+                $action_icons = '';
423
+                $dropbox_file_data[] = $last_upload_date;
424
+                $dropbox_file_data[] = $file_size;
425
+                $dropbox_data_recieved[] = $dropbox_file_data;
426
+            }
427
+        }
428
+
429
+        // The content of the sortable table = the categories (if we are not in the root)
430
+        if ($view_dropbox_category_received == 0) {
431
+            foreach ($dropbox_categories as $category) {
432
+                /*  Note: This can probably be shortened since the categories
433 433
 			    for the received files are already in the
434 434
 			    $dropbox_received_category array;*/
435
-				$dropbox_category_data = array();
436
-				if ($category['received'] == '1') {
437
-					$movelist[$category['cat_id']] = $category['cat_name'];
435
+                $dropbox_category_data = array();
436
+                if ($category['received'] == '1') {
437
+                    $movelist[$category['cat_id']] = $category['cat_name'];
438 438
                     // This is where the checkbox icon for the files appear
439
-					$dropbox_category_data[] = $category['cat_id'];
440
-					// The icon of the category
441
-					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">';
442
-					$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>';
443
-					$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>';
444
-					$dropbox_category_data[] = '';
445
-					$dropbox_category_data[] = '';
446
-					$dropbox_category_data[] = '';
447
-					$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>
439
+                    $dropbox_category_data[] = $category['cat_id'];
440
+                    // The icon of the category
441
+                    $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">';
442
+                    $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>';
443
+                    $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>';
444
+                    $dropbox_category_data[] = '';
445
+                    $dropbox_category_data[] = '';
446
+                    $dropbox_category_data[] = '';
447
+                    $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>
448 448
 										  <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>';
449
-				}
450
-				if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
451
-					$dropbox_data_recieved[] = $dropbox_category_data;
452
-				}
453
-			}
454
-		}
455
-
456
-		// Displaying the table
449
+                }
450
+                if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
451
+                    $dropbox_data_recieved[] = $dropbox_category_data;
452
+                }
453
+            }
454
+        }
455
+
456
+        // Displaying the table
457 457
         $additional_get_parameters = array(
458 458
             'view' => $view,
459 459
             'view_received_category' => $viewReceivedCategory,
@@ -464,15 +464,15 @@  discard block
 block discarded – undo
464 464
             'download_received' => get_lang('Download')
465 465
         );
466 466
 
467
-		if (is_array($movelist)) {
468
-			foreach ($movelist as $catid => $catname){
469
-				$selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname);
470
-			}
471
-		}
467
+        if (is_array($movelist)) {
468
+            foreach ($movelist as $catid => $catname){
469
+                $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname);
470
+            }
471
+        }
472 472
 
473
-		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
474
-			$selectlist = array();
475
-		}
473
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
474
+            $selectlist = array();
475
+        }
476 476
         echo '<div class="files-table">';
477 477
         Display::display_sortable_config_table(
478 478
             'dropbox',
@@ -486,154 +486,154 @@  discard block
 block discarded – undo
486 486
             $selectlist
487 487
         );
488 488
         echo '</div>';
489
-	}
490
-
491
-	/*	SENT FILES */
492
-
493
-	if (!$view || $view == 'sent' || !$showSentReceivedTabs) {
494
-		// This is for the categories
495
-		if (isset($viewSentCategory) AND $viewSentCategory != '') {
496
-			$view_dropbox_category_sent = $viewSentCategory;
497
-		} else {
498
-			$view_dropbox_category_sent = 0;
499
-		}
500
-
501
-		// Object initialisation
502
-		$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
503
-
504
-		// Constructing the array that contains the total number of feedback messages per document.
505
-		$number_feedback = get_total_number_feedback();
506
-
507
-		// Sorting and paging options
508
-		$sorting_options = array();
509
-		$paging_options = array();
510
-
511
-		// The headers of the sortable tables
512
-		$column_header = array();
513
-
514
-		$column_header[] = array('', false, '');
515
-		$column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
516
-		$column_header[] = array(get_lang('SentTitle'), true, '');
517
-		$column_header[] = array(get_lang('Size'), true, '');
518
-		$column_header[] = array(get_lang('SentTo'), true, '');
519
-		$column_header[] = array(get_lang('LastResent'), true, '');
520
-
521
-		if (api_get_session_id() == 0) {
522
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
523
-		} elseif (api_is_allowed_to_session_edit(false, true)) {
524
-			$column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
525
-		}
526
-
527
-		$column_header[] = array('RealDate', true);
528
-		$column_header[] = array('RealSize', true);
529
-
530
-		$column_show = array();
531
-		$column_order = array();
532
-
533
-		// An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
534
-		$column_show[] = 1;
535
-		$column_show[] = 1;
536
-		$column_show[] = 1;
537
-		$column_show[] = 1;
538
-		$column_show[] = 1;
539
-		$column_show[] = 1;
540
-		if (api_get_session_id() == 0) {
541
-			$column_show[] = 1;
542
-		} elseif (api_is_allowed_to_session_edit(false, true)) {
543
-			$column_show[] = 1;
544
-		}
545
-		$column_show[] = 0;
546
-
547
-		// Here we change the way how the colums are going to be sort
548
-		// in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
549
-		// because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
550
-
551
-		$column_order[3] = 8;
552
-		$column_order[5] = 7;
553
-
554
-		// The content of the sortable table = the received files
555
-		foreach ($dropbox_person->sentWork as $dropbox_file) {
556
-			$dropbox_file_data = array();
557
-
558
-			if ($view_dropbox_category_sent == $dropbox_file->category) {
559
-				$dropbox_file_data[] = $dropbox_file->id;
560
-				$link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
561
-				$dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
562
-				$dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
489
+    }
490
+
491
+    /*	SENT FILES */
492
+
493
+    if (!$view || $view == 'sent' || !$showSentReceivedTabs) {
494
+        // This is for the categories
495
+        if (isset($viewSentCategory) AND $viewSentCategory != '') {
496
+            $view_dropbox_category_sent = $viewSentCategory;
497
+        } else {
498
+            $view_dropbox_category_sent = 0;
499
+        }
500
+
501
+        // Object initialisation
502
+        $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
503
+
504
+        // Constructing the array that contains the total number of feedback messages per document.
505
+        $number_feedback = get_total_number_feedback();
506
+
507
+        // Sorting and paging options
508
+        $sorting_options = array();
509
+        $paging_options = array();
510
+
511
+        // The headers of the sortable tables
512
+        $column_header = array();
513
+
514
+        $column_header[] = array('', false, '');
515
+        $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
516
+        $column_header[] = array(get_lang('SentTitle'), true, '');
517
+        $column_header[] = array(get_lang('Size'), true, '');
518
+        $column_header[] = array(get_lang('SentTo'), true, '');
519
+        $column_header[] = array(get_lang('LastResent'), true, '');
520
+
521
+        if (api_get_session_id() == 0) {
522
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
523
+        } elseif (api_is_allowed_to_session_edit(false, true)) {
524
+            $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
525
+        }
526
+
527
+        $column_header[] = array('RealDate', true);
528
+        $column_header[] = array('RealSize', true);
529
+
530
+        $column_show = array();
531
+        $column_order = array();
532
+
533
+        // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
534
+        $column_show[] = 1;
535
+        $column_show[] = 1;
536
+        $column_show[] = 1;
537
+        $column_show[] = 1;
538
+        $column_show[] = 1;
539
+        $column_show[] = 1;
540
+        if (api_get_session_id() == 0) {
541
+            $column_show[] = 1;
542
+        } elseif (api_is_allowed_to_session_edit(false, true)) {
543
+            $column_show[] = 1;
544
+        }
545
+        $column_show[] = 0;
546
+
547
+        // Here we change the way how the colums are going to be sort
548
+        // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
549
+        // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
550
+
551
+        $column_order[3] = 8;
552
+        $column_order[5] = 7;
553
+
554
+        // The content of the sortable table = the received files
555
+        foreach ($dropbox_person->sentWork as $dropbox_file) {
556
+            $dropbox_file_data = array();
557
+
558
+            if ($view_dropbox_category_sent == $dropbox_file->category) {
559
+                $dropbox_file_data[] = $dropbox_file->id;
560
+                $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
561
+                $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>';
562
+                $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'.
563 563
                     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;
564
-				$file_size = $dropbox_file->filesize;
565
-				$dropbox_file_data[] = format_file_size($file_size);
564
+                $file_size = $dropbox_file->filesize;
565
+                $dropbox_file_data[] = format_file_size($file_size);
566 566
                 $receivers_celldata = null;
567
-				foreach ($dropbox_file->recipients as $recipient) {
568
-					$userInfo = api_get_user_info($recipient['user_id']);
569
-					$receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata;
570
-				}
571
-				$receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
572
-				$dropbox_file_data[] = $receivers_celldata;
573
-				$last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
574
-				$dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
575
-					api_format_date($last_upload_date).'</span>';
576
-
577
-				//$dropbox_file_data[] = $dropbox_file->author;
578
-				$receivers_celldata = '';
579
-
580
-				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
567
+                foreach ($dropbox_file->recipients as $recipient) {
568
+                    $userInfo = api_get_user_info($recipient['user_id']);
569
+                    $receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata;
570
+                }
571
+                $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
572
+                $dropbox_file_data[] = $receivers_celldata;
573
+                $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
574
+                $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
575
+                    api_format_date($last_upload_date).'</span>';
576
+
577
+                //$dropbox_file_data[] = $dropbox_file->author;
578
+                $receivers_celldata = '';
579
+
580
+                $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
581 581
                     <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>
582 582
                     <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>
583 583
                     <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>';
584
-				// This is a hack to have an additional row in a sortable table
585
-				if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
586
-					$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
587
-					$action_icons .= "<tr><td colspan=\"2\">";
588
-					$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>";
589
-					$action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
590
-				}
591
-				$dropbox_file_data[] = $action_icons;
592
-				$dropbox_file_data[] = $last_upload_date;
593
-				$dropbox_file_data[] = $file_size;
594
-				$action_icons = '';
595
-				$dropbox_data_sent[] = $dropbox_file_data;
596
-			}
597
-		}
584
+                // This is a hack to have an additional row in a sortable table
585
+                if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
586
+                    $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
587
+                    $action_icons .= "<tr><td colspan=\"2\">";
588
+                    $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>";
589
+                    $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
590
+                }
591
+                $dropbox_file_data[] = $action_icons;
592
+                $dropbox_file_data[] = $last_upload_date;
593
+                $dropbox_file_data[] = $file_size;
594
+                $action_icons = '';
595
+                $dropbox_data_sent[] = $dropbox_file_data;
596
+            }
597
+        }
598 598
 
599 599
         $moveList = array();
600
-		// The content of the sortable table = the categories (if we are not in the root)
601
-		if ($view_dropbox_category_sent == 0) {
602
-			foreach ($dropbox_categories as $category) {
603
-				$dropbox_category_data = array();
600
+        // The content of the sortable table = the categories (if we are not in the root)
601
+        if ($view_dropbox_category_sent == 0) {
602
+            foreach ($dropbox_categories as $category) {
603
+                $dropbox_category_data = array();
604 604
 
605
-				if ($category['sent'] == '1') {
605
+                if ($category['sent'] == '1') {
606 606
 
607 607
                     $moveList[$category['cat_id']] = $category['cat_name'];
608
-					$dropbox_category_data[] = $category['cat_id'];
609
-					// This is where the checkbox icon for the files appear.
610
-					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">';
611
-					$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
612
-					$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>';
613
-					//$dropbox_category_data[] = '';
614
-					$dropbox_category_data[] = '';
615
-					//$dropbox_category_data[] = '';
616
-					$dropbox_category_data[] = '';
617
-					$dropbox_category_data[] = '';
618
-					$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'].'">'.
608
+                    $dropbox_category_data[] = $category['cat_id'];
609
+                    // This is where the checkbox icon for the files appear.
610
+                    $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">';
611
+                    $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
612
+                    $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>';
613
+                    //$dropbox_category_data[] = '';
614
+                    $dropbox_category_data[] = '';
615
+                    //$dropbox_category_data[] = '';
616
+                    $dropbox_category_data[] = '';
617
+                    $dropbox_category_data[] = '';
618
+                    $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'].'">'.
619 619
                                     Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
620 620
 									<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']).'\');">'.
621 621
                                     Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
622
-				}
623
-				if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
624
-					$dropbox_data_sent[] = $dropbox_category_data;
625
-				}
626
-			}
627
-		}
628
-
629
-		// Displaying the table
630
-		$additional_get_parameters = array(
622
+                }
623
+                if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
624
+                    $dropbox_data_sent[] = $dropbox_category_data;
625
+                }
626
+            }
627
+        }
628
+
629
+        // Displaying the table
630
+        $additional_get_parameters = array(
631 631
             'view' => $view,
632 632
             'view_received_category' => $viewReceivedCategory,
633 633
             'view_sent_category' => $viewSentCategory
634 634
         );
635 635
 
636
-		$selectlist = array(
636
+        $selectlist = array(
637 637
             'delete_received' => get_lang('Delete'),
638 638
             'download_received' => get_lang('Download')
639 639
         );
@@ -644,12 +644,12 @@  discard block
 block discarded – undo
644 644
             }
645 645
         }
646 646
 
647
-		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
648
-			$selectlist = array('download_received' => get_lang('Download'));
649
-		}
647
+        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
648
+            $selectlist = array('download_received' => get_lang('Download'));
649
+        }
650 650
 
651 651
         echo '<div class="files-table">';
652
-		Display::display_sortable_config_table(
652
+        Display::display_sortable_config_table(
653 653
             'dropbox',
654 654
             $column_header,
655 655
             $dropbox_data_sent,
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
             $selectlist
662 662
         );
663 663
         echo '</div>';
664
-	}
664
+    }
665 665
 }
666 666
 
667 667
 Display::display_footer();
Please login to merge, or discard this patch.
main/dropbox/dropbox_class.inc.php 1 patch
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
         }
77 77
     }
78 78
 
79
-	/**
80
-	 * private function creating a new work object
81
-	 *
82
-	 * @param int $uploader_id
83
-	 * @param string $title
84
-	 * @param string $description
85
-	 * @param string $author
86
-	 * @param string $filename
87
-	 * @param int $filesize
88
-	 *
89
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
90
-	 * 			As a consequence this parameter can be removed
91
-	 */
92
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
79
+    /**
80
+     * private function creating a new work object
81
+     *
82
+     * @param int $uploader_id
83
+     * @param string $title
84
+     * @param string $description
85
+     * @param string $author
86
+     * @param string $filename
87
+     * @param int $filesize
88
+     *
89
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
90
+     * 			As a consequence this parameter can be removed
91
+     */
92
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
93 93
     {
94 94
         // Fill in the properties
95 95
         $this->uploader_id = intval($uploader_id);
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
         // Check if object exists already. If it does, the old object is used
105 105
         // with updated information (authors, description, upload_date)
106 106
         $this->isOldWork = false;
107
-		$sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
107
+        $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
108 108
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
109 109
         $result = Database::query($sql);
110
-		$res = Database::fetch_array($result);
111
-		if ($res) {
112
-			$this->isOldWork = true;
113
-		}
114
-		// Insert or update the dropbox_file table and set the id property
115
-		if ($this->isOldWork) {
116
-			$this->id = $res['id'];
117
-			$this->upload_date = $res['upload_date'];
110
+        $res = Database::fetch_array($result);
111
+        if ($res) {
112
+            $this->isOldWork = true;
113
+        }
114
+        // Insert or update the dropbox_file table and set the id property
115
+        if ($this->isOldWork) {
116
+            $this->id = $res['id'];
117
+            $this->upload_date = $res['upload_date'];
118 118
 
119 119
             $params = [
120 120
                 'filesize' => $this->filesize,
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                 $params,
131 131
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
132 132
             );
133
-		} else {
134
-			$this->upload_date = $this->last_upload_date;
135
-			$params = [
133
+        } else {
134
+            $this->upload_date = $this->last_upload_date;
135
+            $params = [
136 136
                 'c_id' => $course_id,
137 137
                 'uploader_id' => $this->uploader_id,
138 138
                 'filename' => $this->filename,
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
                 'last_upload_date' => $this->last_upload_date,
145 145
                 'session_id' => api_get_session_id(),
146 146
                 'cat_id' => 0
147
-			];
147
+            ];
148 148
 
149
-			$this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150
-			if ($this->id) {
151
-				$sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
152
-				Database::query($sql);
153
-			}
154
-		}
149
+            $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150
+            if ($this->id) {
151
+                $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
152
+                Database::query($sql);
153
+            }
154
+        }
155 155
 
156 156
         $sql = "SELECT count(file_id) as count
157 157
         		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
166 166
             Database::query($sql);
167 167
         }
168
-	}
169
-
170
-	/**
171
-	 * private function creating existing object by retreiving info from db
172
-	 *
173
-	 * @param int $id
174
-	 */
175
-	public function _createExistingWork($id)
168
+    }
169
+
170
+    /**
171
+     * private function creating existing object by retreiving info from db
172
+     *
173
+     * @param int $id
174
+     */
175
+    public function _createExistingWork($id)
176 176
     {
177
-	    $course_id = api_get_course_int_id();
177
+        $course_id = api_get_course_int_id();
178 178
 
179 179
         $action = isset($_GET['action']) ? $_GET['action'] : null;
180 180
 
@@ -222,52 +222,52 @@  discard block
 block discarded – undo
222 222
             }
223 223
             $this->feedback2= $feedback2;
224 224
         }
225
-	}
225
+    }
226 226
 }
227 227
 
228 228
 class Dropbox_SentWork extends Dropbox_Work
229 229
 {
230
-	public $recipients;	//array of ['id']['name'] arrays
231
-
232
-	/**
233
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
234
-	 * depending on the number of parameters
235
-	 *
236
-	 * @param unknown_type $arg1
237
-	 * @param unknown_type $arg2
238
-	 * @param unknown_type $arg3
239
-	 * @param unknown_type $arg4
240
-	 * @param unknown_type $arg5
241
-	 * @param unknown_type $arg6
242
-	 * @param unknown_type $arg7
243
-	 * @return Dropbox_SentWork
244
-	 */
245
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
230
+    public $recipients;	//array of ['id']['name'] arrays
231
+
232
+    /**
233
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
234
+     * depending on the number of parameters
235
+     *
236
+     * @param unknown_type $arg1
237
+     * @param unknown_type $arg2
238
+     * @param unknown_type $arg3
239
+     * @param unknown_type $arg4
240
+     * @param unknown_type $arg5
241
+     * @param unknown_type $arg6
242
+     * @param unknown_type $arg7
243
+     * @return Dropbox_SentWork
244
+     */
245
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
246 246
     {
247
-		if (func_num_args() > 1) {
248
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
249
-		} else {
250
-			$this->_createExistingSentWork($arg1);
251
-		}
252
-	}
253
-
254
-	/**
255
-	 * private function creating a new SentWork object
256
-	 *
257
-	 * @param int $uploader_id
258
-	 * @param string $title
259
-	 * @param string $description
260
-	 * @param string $author
261
-	 * @param string $filename
262
-	 * @param int $filesize
263
-	 * @param array $recipient_ids
264
-	 */
265
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
247
+        if (func_num_args() > 1) {
248
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
249
+        } else {
250
+            $this->_createExistingSentWork($arg1);
251
+        }
252
+    }
253
+
254
+    /**
255
+     * private function creating a new SentWork object
256
+     *
257
+     * @param int $uploader_id
258
+     * @param string $title
259
+     * @param string $description
260
+     * @param string $author
261
+     * @param string $filename
262
+     * @param int $filesize
263
+     * @param array $recipient_ids
264
+     */
265
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
266 266
     {
267 267
         $dropbox_cnf = getDropboxConf();
268 268
         $_course = api_get_course_info();
269 269
 
270
-		// Call constructor of Dropbox_Work object
270
+        // Call constructor of Dropbox_Work object
271 271
         parent::__construct(
272 272
             $uploader_id,
273 273
             $title,
@@ -277,33 +277,33 @@  discard block
 block discarded – undo
277 277
             $filesize
278 278
         );
279 279
 
280
-		$course_id = api_get_course_int_id();
281
-
282
-		// Do sanity checks on recipient_ids array & property fillin
283
-		// The sanity check for ex-coursemembers is already done in base constructor
284
-		$uploader_id = (int) $uploader_id;
280
+        $course_id = api_get_course_int_id();
285 281
 
286
-		$justSubmit = false;
287
-		if (is_int($recipient_ids)) {
288
-			$justSubmit = true;
289
-			$recipient_ids = array($recipient_ids + $this->id);
290
-		} elseif (count($recipient_ids) == 0) {
291
-			$justSubmit = true;
292
-			$recipient_ids = array($uploader_id);
293
-		}
282
+        // Do sanity checks on recipient_ids array & property fillin
283
+        // The sanity check for ex-coursemembers is already done in base constructor
284
+        $uploader_id = (int) $uploader_id;
285
+
286
+        $justSubmit = false;
287
+        if (is_int($recipient_ids)) {
288
+            $justSubmit = true;
289
+            $recipient_ids = array($recipient_ids + $this->id);
290
+        } elseif (count($recipient_ids) == 0) {
291
+            $justSubmit = true;
292
+            $recipient_ids = array($uploader_id);
293
+        }
294 294
 
295
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
296
-			die(get_lang('GeneralError').' (code 209)');
297
-		}
295
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
296
+            die(get_lang('GeneralError').' (code 209)');
297
+        }
298 298
 
299
-		foreach ($recipient_ids as $rec) {
300
-			if (empty($rec)) {
301
-			    continue;
299
+        foreach ($recipient_ids as $rec) {
300
+            if (empty($rec)) {
301
+                continue;
302 302
             }
303 303
 
304 304
             //this check is done when validating submitted data
305
-			$this->recipients[] = array('id' => $rec);
306
-		}
305
+            $this->recipients[] = array('id' => $rec);
306
+        }
307 307
 
308 308
         $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
309 309
         $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
         $mailId = get_mail_id_base();
314 314
 
315 315
         // Insert data in dropbox_post and dropbox_person table for each recipient
316
-		foreach ($this->recipients as $rec) {
316
+        foreach ($this->recipients as $rec) {
317 317
             $file_id = (int)$this->id;
318 318
             $user_id = (int)$rec['id'];
319
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
319
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
320 320
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
321
-	        Database::query($sql);
321
+            Database::query($sql);
322 322
             // If work already exists no error is generated
323 323
 
324 324
             /**
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
                 }
336 336
             }
337 337
 
338
-			// Update item_property table for each recipient
339
-			if (($ownerid = $this->uploader_id) > $mailId) {
340
-			    $ownerid = getUserOwningThisMailing($ownerid);
341
-			}
342
-			if (($recipid = $rec["id"]) > $mailId) {
343
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
344
-			}
338
+            // Update item_property table for each recipient
339
+            if (($ownerid = $this->uploader_id) > $mailId) {
340
+                $ownerid = getUserOwningThisMailing($ownerid);
341
+            }
342
+            if (($recipid = $rec["id"]) > $mailId) {
343
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
344
+            }
345 345
             api_item_property_update(
346 346
                 $_course,
347 347
                 TOOL_DROPBOX,
@@ -351,90 +351,90 @@  discard block
 block discarded – undo
351 351
                 null,
352 352
                 $recipid
353 353
             );
354
-		}
355
-	}
356
-
357
-	/**
358
-	 * private function creating existing object by retreiving info from db
359
-	 *
360
-	 * @param unknown_type $id
361
-	 */
362
-	public function _createExistingSentWork($id)
354
+        }
355
+    }
356
+
357
+    /**
358
+     * private function creating existing object by retreiving info from db
359
+     *
360
+     * @param unknown_type $id
361
+     */
362
+    public function _createExistingSentWork($id)
363 363
     {
364 364
         $id = intval($id);
365 365
 
366
-		$course_id = api_get_course_int_id();
366
+        $course_id = api_get_course_int_id();
367 367
 
368
-		// Call constructor of Dropbox_Work object
369
-		parent::__construct($id);
368
+        // Call constructor of Dropbox_Work object
369
+        parent::__construct($id);
370 370
 
371
-		// Fill in recipients array
372
-		$this->recipients = array();
373
-		$sql = "SELECT dest_user_id, feedback_date, feedback
371
+        // Fill in recipients array
372
+        $this->recipients = array();
373
+        $sql = "SELECT dest_user_id, feedback_date, feedback
374 374
 				FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
375 375
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
376 376
         $result = Database::query($sql);
377
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
378
-			// Check for deleted users
379
-			$dest_user_id = $res['dest_user_id'];
380
-			$user_info = api_get_user_info($dest_user_id);
381
-			//$this->category = $res['cat_id'];
382
-			if (!$user_info) {
383
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
384
-			} else {
385
-				$this->recipients[] = array(
377
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
378
+            // Check for deleted users
379
+            $dest_user_id = $res['dest_user_id'];
380
+            $user_info = api_get_user_info($dest_user_id);
381
+            //$this->category = $res['cat_id'];
382
+            if (!$user_info) {
383
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
384
+            } else {
385
+                $this->recipients[] = array(
386 386
                     'id' => $dest_user_id,
387 387
                     'name' => $user_info['complete_name'],
388 388
                     'user_id' => $dest_user_id,
389
-				    'feedback_date' => $res['feedback_date'],
389
+                    'feedback_date' => $res['feedback_date'],
390 390
                     'feedback' => $res['feedback']
391 391
                 );
392
-			}
393
-		}
394
-	}
392
+            }
393
+        }
394
+    }
395 395
 }
396 396
 
397 397
 class Dropbox_Person
398 398
 {
399
-	// The receivedWork and the sentWork arrays are sorted.
400
-	public $receivedWork;	// an array of Dropbox_Work objects
401
-	public $sentWork;		// an array of Dropbox_SentWork objects
402
-
403
-	public $userId = 0;
404
-	public $isCourseAdmin = false;
405
-	public $isCourseTutor = false;
406
-	public $_orderBy = '';	// private property that determines by which field
407
-
408
-	/**
409
-	 * Constructor for recreating the Dropbox_Person object
410
-	 *
411
-	 * @param int $userId
412
-	 * @param bool $isCourseAdmin
413
-	 * @param bool $isCourseTutor
414
-	 * @return Dropbox_Person
415
-	 */
416
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
399
+    // The receivedWork and the sentWork arrays are sorted.
400
+    public $receivedWork;	// an array of Dropbox_Work objects
401
+    public $sentWork;		// an array of Dropbox_SentWork objects
402
+
403
+    public $userId = 0;
404
+    public $isCourseAdmin = false;
405
+    public $isCourseTutor = false;
406
+    public $_orderBy = '';	// private property that determines by which field
407
+
408
+    /**
409
+     * Constructor for recreating the Dropbox_Person object
410
+     *
411
+     * @param int $userId
412
+     * @param bool $isCourseAdmin
413
+     * @param bool $isCourseTutor
414
+     * @return Dropbox_Person
415
+     */
416
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
417 417
     {
418
-	    $course_id = api_get_course_int_id();
418
+        $course_id = api_get_course_int_id();
419 419
 
420
-		// Fill in properties
420
+        // Fill in properties
421 421
         $this->userId = $userId;
422 422
         $this->isCourseAdmin = $isCourseAdmin;
423 423
         $this->isCourseTutor = $isCourseTutor;
424 424
         $this->receivedWork = array();
425 425
         $this->sentWork = array();
426 426
 
427
-		// Note: perhaps include an ex coursemember check to delete old files
427
+        // Note: perhaps include an ex coursemember check to delete old files
428 428
 
429
-		$session_id = api_get_session_id();
430
-		$condition_session = api_get_session_condition($session_id);
429
+        $session_id = api_get_session_id();
430
+        $condition_session = api_get_session_condition($session_id);
431 431
 
432
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
433
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
434
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
432
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
433
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
434
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
435 435
 
436 436
         // Find all entries where this person is the recipient
437
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
437
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
438 438
                 FROM $post_tbl r
439 439
                 INNER JOIN $person_tbl p
440 440
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
444 444
 
445 445
         $result = Database::query($sql);
446
-		while ($res = Database::fetch_array($result)) {
447
-			$temp = new Dropbox_Work($res['file_id']);
448
-			$temp->category = $res['cat_id'];
449
-			$this->receivedWork[] = $temp;
450
-		}
451
-		// Find all entries where this person is the sender/uploader
446
+        while ($res = Database::fetch_array($result)) {
447
+            $temp = new Dropbox_Work($res['file_id']);
448
+            $temp->category = $res['cat_id'];
449
+            $this->receivedWork[] = $temp;
450
+        }
451
+        // Find all entries where this person is the sender/uploader
452 452
         $sql = "SELECT DISTINCT f.id
453 453
 				FROM $file_tbl f
454 454
 				INNER JOIN $person_tbl p
@@ -459,160 +459,160 @@  discard block
 block discarded – undo
459 459
                     $condition_session
460 460
                 ";
461 461
         $result = Database::query($sql);
462
-		while ($res = Database::fetch_array($result)) {
463
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
464
-		}
465
-	}
466
-
467
-	/**
468
-	 * Deletes all the received work of this person
469
-	 */
470
-	public function deleteAllReceivedWork()
462
+        while ($res = Database::fetch_array($result)) {
463
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
464
+        }
465
+    }
466
+
467
+    /**
468
+     * Deletes all the received work of this person
469
+     */
470
+    public function deleteAllReceivedWork()
471 471
     {
472
-	    $course_id = api_get_course_int_id();
473
-		// Delete entries in person table concerning received works
474
-		foreach ($this->receivedWork as $w) {
472
+        $course_id = api_get_course_int_id();
473
+        // Delete entries in person table concerning received works
474
+        foreach ($this->receivedWork as $w) {
475 475
             $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
476 476
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
477
-			Database::query($sql);
478
-		}
477
+            Database::query($sql);
478
+        }
479 479
         // Check for unused files
480
-		removeUnusedFiles();
481
-	}
482
-
483
-	/**
484
-	 * Deletes all the received categories and work of this person
485
-	 * @param integer $id
486
-	 */
487
-	public function deleteReceivedWorkFolder($id)
480
+        removeUnusedFiles();
481
+    }
482
+
483
+    /**
484
+     * Deletes all the received categories and work of this person
485
+     * @param integer $id
486
+     */
487
+    public function deleteReceivedWorkFolder($id)
488 488
     {
489 489
         $course_id = api_get_course_int_id();
490 490
 
491
-		$id = intval($id);
492
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
491
+        $id = intval($id);
492
+        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
493 493
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
494
-		if (!Database::query($sql)) return false;
495
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
494
+        if (!Database::query($sql)) return false;
495
+        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
496 496
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497
-		if (!Database::query($sql)) return false;
498
-		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
497
+        if (!Database::query($sql)) return false;
498
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
499 499
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
500
-		if (!Database::query($sql)) return false;
501
-		return true;
502
-	}
503
-
504
-	/**
505
-	 * Deletes a received dropbox file of this person with id=$id
506
-	 *
507
-	 * @param integer $id
508
-	 */
509
-	public function deleteReceivedWork($id)
500
+        if (!Database::query($sql)) return false;
501
+        return true;
502
+    }
503
+
504
+    /**
505
+     * Deletes a received dropbox file of this person with id=$id
506
+     *
507
+     * @param integer $id
508
+     */
509
+    public function deleteReceivedWork($id)
510 510
     {
511
-	    $course_id = api_get_course_int_id();
512
-		$id = intval($id);
513
-
514
-		// index check
515
-		$found = false;
516
-		foreach ($this->receivedWork as $w) {
517
-			if ($w->id == $id) {
518
-			   $found = true;
519
-			   break;
520
-			}
521
-		}
522
-
523
-		if (!$found) {
524
-			if (!$this->deleteReceivedWorkFolder($id)) {
525
-				die(get_lang('GeneralError').' (code 216)');
526
-			}
527
-		}
528
-		// Delete entries in person table concerning received works
511
+        $course_id = api_get_course_int_id();
512
+        $id = intval($id);
513
+
514
+        // index check
515
+        $found = false;
516
+        foreach ($this->receivedWork as $w) {
517
+            if ($w->id == $id) {
518
+                $found = true;
519
+                break;
520
+            }
521
+        }
522
+
523
+        if (!$found) {
524
+            if (!$this->deleteReceivedWorkFolder($id)) {
525
+                die(get_lang('GeneralError').' (code 216)');
526
+            }
527
+        }
528
+        // Delete entries in person table concerning received works
529 529
         $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
530 530
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
531
-		Database::query($sql);
532
-		removeUnusedFiles();	// Check for unused files
533
-	}
534
-
535
-	/**
536
-	 * Deletes all the sent dropbox files of this person
537
-	 */
538
-	public function deleteAllSentWork()
531
+        Database::query($sql);
532
+        removeUnusedFiles();	// Check for unused files
533
+    }
534
+
535
+    /**
536
+     * Deletes all the sent dropbox files of this person
537
+     */
538
+    public function deleteAllSentWork()
539 539
     {
540
-	    $course_id = api_get_course_int_id();
541
-		//delete entries in person table concerning sent works
542
-		foreach ($this->sentWork as $w) {
540
+        $course_id = api_get_course_int_id();
541
+        //delete entries in person table concerning sent works
542
+        foreach ($this->sentWork as $w) {
543 543
             $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
544 544
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
545
-			Database::query($sql);
546
-			removeMoreIfMailing($w->id);
547
-		}
548
-		removeUnusedFiles();	// Check for unused files
549
-	}
550
-
551
-	/**
552
-	 * Deletes a sent dropbox file of this person with id=$id
553
-	 *
554
-	 * @param unknown_type $id
555
-	 */
556
-	public function deleteSentWork($id)
545
+            Database::query($sql);
546
+            removeMoreIfMailing($w->id);
547
+        }
548
+        removeUnusedFiles();	// Check for unused files
549
+    }
550
+
551
+    /**
552
+     * Deletes a sent dropbox file of this person with id=$id
553
+     *
554
+     * @param unknown_type $id
555
+     */
556
+    public function deleteSentWork($id)
557 557
     {
558
-	    $course_id = api_get_course_int_id();
559
-
560
-		$id = intval($id);
561
-
562
-		// index check
563
-		$found = false;
564
-		foreach ($this->sentWork as $w) {
565
-			if ($w->id == $id) {
566
-			   $found = true;
567
-			   break;
568
-			}
569
-		}
570
-		if (!$found) {
571
-			if (!$this->deleteReceivedWorkFolder($id)) {
572
-				die(get_lang('GeneralError').' (code 219)');
573
-			}
574
-		}
575
-		//$file_id = $this->sentWork[$index]->id;
576
-		// Delete entries in person table concerning sent works
558
+        $course_id = api_get_course_int_id();
559
+
560
+        $id = intval($id);
561
+
562
+        // index check
563
+        $found = false;
564
+        foreach ($this->sentWork as $w) {
565
+            if ($w->id == $id) {
566
+                $found = true;
567
+                break;
568
+            }
569
+        }
570
+        if (!$found) {
571
+            if (!$this->deleteReceivedWorkFolder($id)) {
572
+                die(get_lang('GeneralError').' (code 219)');
573
+            }
574
+        }
575
+        //$file_id = $this->sentWork[$index]->id;
576
+        // Delete entries in person table concerning sent works
577 577
         $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
578 578
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
579
-		Database::query($sql);
580
-		removeMoreIfMailing($id);
581
-		removeUnusedFiles();	// Check for unused files
582
-	}
583
-
584
-	/**
585
-	 * Updates feedback for received work of this person with id=$id
586
-	 *
587
-	 * @param string $id
588
-	 * @param string $text
589
-	 */
590
-	public function updateFeedback($id, $text)
579
+        Database::query($sql);
580
+        removeMoreIfMailing($id);
581
+        removeUnusedFiles();	// Check for unused files
582
+    }
583
+
584
+    /**
585
+     * Updates feedback for received work of this person with id=$id
586
+     *
587
+     * @param string $id
588
+     * @param string $text
589
+     */
590
+    public function updateFeedback($id, $text)
591 591
     {
592
-	    $course_id = api_get_course_int_id();
592
+        $course_id = api_get_course_int_id();
593 593
         $_course = api_get_course_info();
594 594
         $dropbox_cnf = getDropboxConf();
595 595
 
596
-		$id = intval($id);
596
+        $id = intval($id);
597 597
 
598
-		// index check
599
-		$found = false;
600
-		$wi = -1;
601
-		foreach ($this->receivedWork as $w) {
602
-			$wi++;
603
-			if ($w->id == $id){
604
-			   $found = true;
605
-			   break;
606
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
607
-		}
598
+        // index check
599
+        $found = false;
600
+        $wi = -1;
601
+        foreach ($this->receivedWork as $w) {
602
+            $wi++;
603
+            if ($w->id == $id){
604
+                $found = true;
605
+                break;
606
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
607
+        }
608 608
 
609
-		if (!$found) {
610
-			return false;
611
-		}
609
+        if (!$found) {
610
+            return false;
611
+        }
612 612
 
613
-		$feedback_date = api_get_utc_datetime();
614
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
615
-		$this->receivedWork[$wi]->feedback = $text;
613
+        $feedback_date = api_get_utc_datetime();
614
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
615
+        $this->receivedWork[$wi]->feedback = $text;
616 616
 
617 617
         $params = [
618 618
             'feedback_date' => $feedback_date,
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
             ]
631 631
         );
632 632
 
633
-		// Update item_property table
633
+        // Update item_property table
634 634
         $mailId = get_mail_id_base();
635
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
636
-		    $ownerid = getUserOwningThisMailing($ownerid);
637
-		}
635
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
636
+            $ownerid = getUserOwningThisMailing($ownerid);
637
+        }
638 638
 
639 639
         api_item_property_update(
640 640
             $_course,
@@ -646,33 +646,33 @@  discard block
 block discarded – undo
646 646
             $ownerid
647 647
         );
648 648
 
649
-	}
649
+    }
650 650
 
651
-	/**
652
-	 * Filter the received work
653
-	 * @param string $type
654
-	 * @param string $value
655
-	 */
656
-	public function filter_received_work($type, $value)
651
+    /**
652
+     * Filter the received work
653
+     * @param string $type
654
+     * @param string $value
655
+     */
656
+    public function filter_received_work($type, $value)
657 657
     {
658 658
         $dropbox_cnf = getDropboxConf();
659
-    	$new_received_work = array();
659
+        $new_received_work = array();
660 660
         $mailId = get_mail_id_base();
661 661
         foreach ($this->receivedWork as $work) {
662
-			switch ($type) {
663
-				case 'uploader_id':
664
-					if ($work->uploader_id == $value ||
665
-						($work->uploader_id > $mailId &&
662
+            switch ($type) {
663
+                case 'uploader_id':
664
+                    if ($work->uploader_id == $value ||
665
+                        ($work->uploader_id > $mailId &&
666 666
                         getUserOwningThisMailing($work->uploader_id) == $value)
667 667
                     ) {
668
-						$new_received_work[] = $work;
669
-					}
670
-					break;
671
-				default:
672
-					$new_received_work[] = $work;
668
+                        $new_received_work[] = $work;
669
+                    }
670
+                    break;
671
+                default:
672
+                    $new_received_work[] = $work;
673 673
                     break;
674
-			}
675
-		}
676
-		$this->receivedWork = $new_received_work;
677
-	}
674
+            }
675
+        }
676
+        $this->receivedWork = $new_received_work;
677
+    }
678 678
 }
Please login to merge, or discard this patch.
main/gradebook/lib/be/forumthreadlink.class.php 1 patch
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -10,46 +10,46 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ForumThreadLink extends AbstractLink
12 12
 {
13
-	private $forum_thread_table = null;
14
-	private $itemprop_table = null;
15
-
16
-	/**
17
-	 * Constructor
18
-	 */
19
-	public function __construct()
20
-	{
21
-		parent::__construct();
22
-		$this->set_type(LINK_FORUM_THREAD);
23
-	}
24
-
25
-	/**
26
-	 * @return string
27
-	 */
28
-	public function get_type_name()
29
-	{
30
-		return get_lang('ForumThreads');
31
-	}
32
-
33
-	/**
34
-	 * @return bool
35
-	 */
36
-	public function is_allowed_to_change_name()
37
-	{
38
-		return false;
39
-	}
40
-
41
-	/**
42
-	 * Generate an array of exercises that a teacher hasn't created a link for.
43
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
44
-	 */
45
-	public function get_not_created_links()
46
-	{
47
-		if (empty($this->course_code)) {
48
-			die('Error in get_not_created_links() : course code not set');
49
-		}
50
-
51
-		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
52
-		$sql = 'SELECT thread_id,thread_title,thread_title_qualify 
13
+    private $forum_thread_table = null;
14
+    private $itemprop_table = null;
15
+
16
+    /**
17
+     * Constructor
18
+     */
19
+    public function __construct()
20
+    {
21
+        parent::__construct();
22
+        $this->set_type(LINK_FORUM_THREAD);
23
+    }
24
+
25
+    /**
26
+     * @return string
27
+     */
28
+    public function get_type_name()
29
+    {
30
+        return get_lang('ForumThreads');
31
+    }
32
+
33
+    /**
34
+     * @return bool
35
+     */
36
+    public function is_allowed_to_change_name()
37
+    {
38
+        return false;
39
+    }
40
+
41
+    /**
42
+     * Generate an array of exercises that a teacher hasn't created a link for.
43
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
44
+     */
45
+    public function get_not_created_links()
46
+    {
47
+        if (empty($this->course_code)) {
48
+            die('Error in get_not_created_links() : course code not set');
49
+        }
50
+
51
+        $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
52
+        $sql = 'SELECT thread_id,thread_title,thread_title_qualify 
53 53
 		        FROM '.$this->get_forum_thread_table().'
54 54
 			    forum_thread WHERE thread_id NOT IN
55 55
 			    (
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                 ) 
61 61
                 AND forum_thread.session_id='.api_get_session_id();
62 62
 
63
-		$result = Database::query($sql);
63
+        $result = Database::query($sql);
64 64
 
65 65
         $cats = array();
66 66
         while ($data = Database::fetch_array($result)) {
@@ -75,29 +75,29 @@  discard block
 block discarded – undo
75 75
         }
76 76
 
77 77
         return $cats;
78
-	}
79
-
80
-	/**
81
-	 * Generate an array of all exercises available.
82
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
83
-	 */
84
-	public function get_all_links()
85
-	{
86
-		if (empty($this->course_code)) {
87
-			die('Error in get_not_created_links() : course code not set');
88
-		}
89
-
90
-		$tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
91
-		$tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
92
-		$session_id = api_get_session_id();
93
-
94
-		if ($session_id) {
95
-			$session_condition = 'tl.session_id='.api_get_session_id();
96
-		} else {
97
-			$session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)';
98
-		}
99
-
100
-		$sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify
78
+    }
79
+
80
+    /**
81
+     * Generate an array of all exercises available.
82
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
83
+     */
84
+    public function get_all_links()
85
+    {
86
+        if (empty($this->course_code)) {
87
+            die('Error in get_not_created_links() : course code not set');
88
+        }
89
+
90
+        $tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
91
+        $tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
92
+        $session_id = api_get_session_id();
93
+
94
+        if ($session_id) {
95
+            $session_condition = 'tl.session_id='.api_get_session_id();
96
+        } else {
97
+            $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)';
98
+        }
99
+
100
+        $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify
101 101
 				FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip
102 102
 				ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id)
103 103
 				WHERE
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
                     '.$session_condition.'
109 109
                 ';
110 110
 
111
-		$result = Database::query($sql);
112
-		while ($data = Database::fetch_array($result)) {
113
-			if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") {
114
-				$cats[] = array($data['thread_id'], $data['thread_title_qualify']);
115
-			} else {
116
-				$cats[] = array($data['thread_id'], $data['thread_title']);
117
-			}
118
-		}
119
-		$my_cats = isset($cats) ? $cats : null;
111
+        $result = Database::query($sql);
112
+        while ($data = Database::fetch_array($result)) {
113
+            if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") {
114
+                $cats[] = array($data['thread_id'], $data['thread_title_qualify']);
115
+            } else {
116
+                $cats[] = array($data['thread_id'], $data['thread_title']);
117
+            }
118
+        }
119
+        $my_cats = isset($cats) ? $cats : null;
120 120
 
121
-		return $my_cats;
122
-	}
121
+        return $my_cats;
122
+    }
123 123
 
124 124
     /**
125
-    * Has anyone done this exercise yet ?
126
-    * @return boolean
127
-    */
125
+     * Has anyone done this exercise yet ?
126
+     * @return boolean
127
+     */
128 128
     public function has_results()
129 129
     {
130 130
         $table = Database :: get_course_table(TABLE_FORUM_POST);
@@ -138,50 +138,50 @@  discard block
 block discarded – undo
138 138
         $number = Database::fetch_row($result);
139 139
 
140 140
         return $number[0] != 0;
141
-	}
141
+    }
142 142
 
143
-	/**
144
-	 * @param int    $stud_id
143
+    /**
144
+     * @param int    $stud_id
145 145
      * @param string $type
146 146
      *
147
-	 * @return array|null
148
-	 */
149
-	public function calc_score($stud_id = null, $type = null)
150
-	{
147
+     * @return array|null
148
+     */
149
+    public function calc_score($stud_id = null, $type = null)
150
+    {
151 151
         require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
152 152
         $threadInfo = get_thread_information('', $this->get_ref_id());
153 153
 
154
-		$thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
154
+        $thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
155 155
 
156 156
         $sessionId = $this->get_session_id();
157 157
         $sessionCondition = api_get_session_condition($sessionId, true, false, 'session_id');
158 158
 
159
-		$sql = 'SELECT thread_qualify_max
159
+        $sql = 'SELECT thread_qualify_max
160 160
 		        FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)."
161 161
   				WHERE 
162 162
   				    c_id = ".$this->course_id." AND 
163 163
   				    thread_id = '".$this->get_ref_id()."'
164 164
   				    $sessionCondition
165 165
                 ";
166
-		$query = Database::query($sql);
167
-		$assignment = Database::fetch_array($query);
166
+        $query = Database::query($sql);
167
+        $assignment = Database::fetch_array($query);
168 168
 
169
-		$sql = "SELECT * FROM $thread_qualify
169
+        $sql = "SELECT * FROM $thread_qualify
170 170
 				WHERE 
171 171
 				    c_id = ".$this->course_id." AND 
172 172
 				    thread_id = ".$this->get_ref_id()."
173 173
 				    $sessionCondition
174 174
                 ";
175
-		if (isset($stud_id)) {
176
-			$sql .= ' AND user_id = '.intval($stud_id);
177
-		}
175
+        if (isset($stud_id)) {
176
+            $sql .= ' AND user_id = '.intval($stud_id);
177
+        }
178 178
 
179
-		// order by id, that way the student's first attempt is accessed first
180
-		$sql .= ' ORDER BY qualify_time DESC';
181
-		$scores = Database::query($sql);
179
+        // order by id, that way the student's first attempt is accessed first
180
+        $sql .= ' ORDER BY qualify_time DESC';
181
+        $scores = Database::query($sql);
182 182
 
183
-		// for 1 student
184
-		if (isset($stud_id)) {
183
+        // for 1 student
184
+        if (isset($stud_id)) {
185 185
             if ($threadInfo['thread_peer_qualify'] == 0) {
186 186
                 // Classic way of calculate score
187 187
                 if ($data = Database::fetch_array($scores)) {
@@ -209,175 +209,175 @@  discard block
 block discarded – undo
209 209
                 }
210 210
                 return [$score/$counter, $assignment['thread_qualify_max']];
211 211
             }
212
-		} else {
213
-			// All students -> get average
214
-			$students = array();  // user list, needed to make sure we only
215
-			// take first attempts into account
216
-			$counter = 0;
217
-			$sum = 0;
218
-			$bestResult = 0;
219
-			$weight = 0;
220
-			$sumResult = 0;
221
-
222
-			while ($data = Database::fetch_array($scores)) {
223
-				if (!(array_key_exists($data['user_id'], $students))) {
224
-					if ($assignment['thread_qualify_max'] != 0) {
225
-						$students[$data['user_id']] = $data['qualify'];
226
-						$counter++;
227
-						$sum += $data['qualify'] / $assignment['thread_qualify_max'];
228
-						$sumResult += $data['qualify'];
229
-						if ($data['qualify'] > $bestResult) {
230
-							$bestResult = $data['qualify'];
231
-						}
232
-						$weight = $assignment['thread_qualify_max'];
233
-					}
234
-				}
235
-			}
236
-
237
-			if ($counter == 0) {
238
-				return null;
239
-			} else {
240
-				switch ($type) {
241
-					case 'best':
242
-						return array($bestResult, $weight);
243
-						break;
244
-					case 'average':
245
-						return array($sumResult/$counter, $weight);
246
-						break;
247
-					case 'ranking':
248
-						return AbstractLink::getCurrentUserRanking($stud_id, $students);
249
-						break;
250
-					default:
251
-						return array($sum, $counter);
252
-						break;
253
-				}
254
-			}
255
-		}
256
-	}
257
-
258
-	/**
259
-	 * Lazy load function to get the database table of the student publications
260
-	 */
261
-	private function get_forum_thread_table()
262
-	{
263
-		return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD);
264
-	}
265
-
266
-	public function needs_name_and_description()
267
-	{
268
-		return false;
269
-	}
270
-
271
-	public function needs_max()
272
-	{
273
-		return false;
274
-	}
275
-
276
-	public function needs_results()
277
-	{
278
-		return false;
279
-	}
212
+        } else {
213
+            // All students -> get average
214
+            $students = array();  // user list, needed to make sure we only
215
+            // take first attempts into account
216
+            $counter = 0;
217
+            $sum = 0;
218
+            $bestResult = 0;
219
+            $weight = 0;
220
+            $sumResult = 0;
221
+
222
+            while ($data = Database::fetch_array($scores)) {
223
+                if (!(array_key_exists($data['user_id'], $students))) {
224
+                    if ($assignment['thread_qualify_max'] != 0) {
225
+                        $students[$data['user_id']] = $data['qualify'];
226
+                        $counter++;
227
+                        $sum += $data['qualify'] / $assignment['thread_qualify_max'];
228
+                        $sumResult += $data['qualify'];
229
+                        if ($data['qualify'] > $bestResult) {
230
+                            $bestResult = $data['qualify'];
231
+                        }
232
+                        $weight = $assignment['thread_qualify_max'];
233
+                    }
234
+                }
235
+            }
236
+
237
+            if ($counter == 0) {
238
+                return null;
239
+            } else {
240
+                switch ($type) {
241
+                    case 'best':
242
+                        return array($bestResult, $weight);
243
+                        break;
244
+                    case 'average':
245
+                        return array($sumResult/$counter, $weight);
246
+                        break;
247
+                    case 'ranking':
248
+                        return AbstractLink::getCurrentUserRanking($stud_id, $students);
249
+                        break;
250
+                    default:
251
+                        return array($sum, $counter);
252
+                        break;
253
+                }
254
+            }
255
+        }
256
+    }
257
+
258
+    /**
259
+     * Lazy load function to get the database table of the student publications
260
+     */
261
+    private function get_forum_thread_table()
262
+    {
263
+        return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD);
264
+    }
265
+
266
+    public function needs_name_and_description()
267
+    {
268
+        return false;
269
+    }
270
+
271
+    public function needs_max()
272
+    {
273
+        return false;
274
+    }
275
+
276
+    public function needs_results()
277
+    {
278
+        return false;
279
+    }
280 280
 
281 281
     /**
282 282
      * @return string
283 283
      */
284
-	public function get_name()
285
-	{
286
-		$this->get_exercise_data();
287
-		$thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
288
-		$thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
289
-		if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
290
-			return $this->exercise_data['thread_title_qualify'];
291
-		} else {
292
-			return $thread_title;
293
-		}
294
-	}
284
+    public function get_name()
285
+    {
286
+        $this->get_exercise_data();
287
+        $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
288
+        $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
289
+        if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
290
+            return $this->exercise_data['thread_title_qualify'];
291
+        } else {
292
+            return $thread_title;
293
+        }
294
+    }
295 295
 
296 296
     /**
297 297
      * @return string
298 298
      */
299
-	public function get_description()
300
-	{
301
-		return '';//$this->exercise_data['description'];
302
-	}
303
-
304
-	/**
305
-	 * Check if this still links to an exercise
306
-	 */
307
-	public function is_valid_link()
308
-	{
309
-		$sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
299
+    public function get_description()
300
+    {
301
+        return '';//$this->exercise_data['description'];
302
+    }
303
+
304
+    /**
305
+     * Check if this still links to an exercise
306
+     */
307
+    public function is_valid_link()
308
+    {
309
+        $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
310 310
         		WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
311
-		$result = Database::query($sql);
312
-		$number = Database::fetch_row($result);
313
-		return ($number[0] != 0);
314
-	}
315
-
316
-	public function get_test_id()
317
-	{
318
-		return 'DEBUG:ID';
319
-	}
320
-
321
-	public function get_link()
322
-	{
323
-		$sessionId = api_get_session_id();
324
-		//it was extracts the forum id
325
-		$sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
311
+        $result = Database::query($sql);
312
+        $number = Database::fetch_row($result);
313
+        return ($number[0] != 0);
314
+    }
315
+
316
+    public function get_test_id()
317
+    {
318
+        return 'DEBUG:ID';
319
+    }
320
+
321
+    public function get_link()
322
+    {
323
+        $sessionId = api_get_session_id();
324
+        //it was extracts the forum id
325
+        $sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
326 326
     			WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId."";
327
-		$result = Database::query($sql);
328
-		$row    = Database::fetch_array($result,'ASSOC');
329
-		$forum_id=$row['forum_id'];
330
-
331
-		$url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
332
-		return $url;
333
-	}
334
-
335
-	private function get_exercise_data()
336
-	{
337
-		$session_id = api_get_session_id();
338
-		if ($session_id) {
339
-			$session_condition = 'session_id='.api_get_session_id();
340
-		} else {
341
-			$session_condition = '(session_id = 0 OR session_id IS NULL)';
342
-		}
343
-
344
-		if (!isset($this->exercise_data)) {
345
-			$sql = 'SELECT * FROM '.$this->get_forum_thread_table().'
327
+        $result = Database::query($sql);
328
+        $row    = Database::fetch_array($result,'ASSOC');
329
+        $forum_id=$row['forum_id'];
330
+
331
+        $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
332
+        return $url;
333
+    }
334
+
335
+    private function get_exercise_data()
336
+    {
337
+        $session_id = api_get_session_id();
338
+        if ($session_id) {
339
+            $session_condition = 'session_id='.api_get_session_id();
340
+        } else {
341
+            $session_condition = '(session_id = 0 OR session_id IS NULL)';
342
+        }
343
+
344
+        if (!isset($this->exercise_data)) {
345
+            $sql = 'SELECT * FROM '.$this->get_forum_thread_table().'
346 346
                     WHERE c_id = '.$this->course_id.' AND  thread_id = '.$this->get_ref_id().' AND '.$session_condition;
347
-			$query = Database::query($sql);
348
-			$this->exercise_data = Database::fetch_array($query);
349
-		}
350
-		return $this->exercise_data;
351
-	}
352
-
353
-	public function get_icon_name()
354
-	{
355
-		return 'forum';
356
-	}
357
-
358
-	function save_linked_data()
359
-	{
360
-		$weight = (float)$this->get_weight();
361
-		$ref_id = $this->get_ref_id();
362
-
363
-		if (!empty($ref_id)) {
364
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.'
347
+            $query = Database::query($sql);
348
+            $this->exercise_data = Database::fetch_array($query);
349
+        }
350
+        return $this->exercise_data;
351
+    }
352
+
353
+    public function get_icon_name()
354
+    {
355
+        return 'forum';
356
+    }
357
+
358
+    function save_linked_data()
359
+    {
360
+        $weight = (float)$this->get_weight();
361
+        $ref_id = $this->get_ref_id();
362
+
363
+        if (!empty($ref_id)) {
364
+            $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.'
365 365
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
366
-			Database::query($sql);
367
-		}
368
-	}
369
-
370
-	function delete_linked_data()
371
-	{
372
-		$ref_id = $this->get_ref_id();
373
-		if (!empty($ref_id)) {
374
-			//Cleans forum
375
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET
366
+            Database::query($sql);
367
+        }
368
+    }
369
+
370
+    function delete_linked_data()
371
+    {
372
+        $ref_id = $this->get_ref_id();
373
+        if (!empty($ref_id)) {
374
+            //Cleans forum
375
+            $sql = 'UPDATE '.$this->get_forum_thread_table().' SET
376 376
 			        thread_qualify_max = 0,
377 377
 			        thread_weight = 0,
378 378
 			        thread_title_qualify = ""
379 379
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
380
-			Database::query($sql);
381
-		}
382
-	}
380
+            Database::query($sql);
381
+        }
382
+    }
383 383
 }
Please login to merge, or discard this patch.
main/exercise/Hpdownload.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 //Event::event_download($doc_url);
24 24
 if (isset($_course['path'])) {
25 25
     $course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
26
-	$full_file_name = $course_path.Security::remove_XSS($doc_url);
26
+    $full_file_name = $course_path.Security::remove_XSS($doc_url);
27 27
 } else {
28 28
     $course_path = api_get_path(SYS_COURSE_PATH).$cid.'/document';
29
-	$full_file_name = $course_path.Security::remove_XSS($doc_url);
29
+    $full_file_name = $course_path.Security::remove_XSS($doc_url);
30 30
 }
31 31
 
32 32
 if(!is_file($full_file_name)) {
33
-	exit;
33
+    exit;
34 34
 }
35 35
 
36 36
 if (!Security::check_abs_path($full_file_name, $course_path.'/')) {
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 $extension=strtolower($extension[sizeof($extension)-1]);
42 42
 
43 43
 switch($extension) {
44
-	case 'gz':		$content_type='application/x-gzip';			break;
45
-	case 'zip':		$content_type='application/zip';			break;
46
-	case 'pdf':		$content_type='application/pdf';			break;
47
-	case 'png':		$content_type='image/png';					break;
48
-	case 'gif':		$content_type='image/gif';					break;
49
-	case 'jpg':		$content_type='image/jpeg';					break;
50
-	case 'txt':		$content_type='text/plain';					break;
51
-	case 'htm':		$content_type='text/html';					break;
52
-	case 'html':	$content_type='text/html';					break;
53
-	default:		$content_type='application/octet-stream';	break;
44
+    case 'gz':		$content_type='application/x-gzip';			break;
45
+    case 'zip':		$content_type='application/zip';			break;
46
+    case 'pdf':		$content_type='application/pdf';			break;
47
+    case 'png':		$content_type='image/png';					break;
48
+    case 'gif':		$content_type='image/gif';					break;
49
+    case 'jpg':		$content_type='image/jpeg';					break;
50
+    case 'txt':		$content_type='text/plain';					break;
51
+    case 'htm':		$content_type='text/html';					break;
52
+    case 'html':	$content_type='text/html';					break;
53
+    default:		$content_type='application/octet-stream';	break;
54 54
 }
55 55
 
56 56
 header('Content-disposition: filename='.$filename);
@@ -68,30 +68,30 @@  discard block
 block discarded – undo
68 68
 */
69 69
 
70 70
 if ($content_type == 'text/html') {
71
-	$directory_name = dirname($full_file_name);
71
+    $directory_name = dirname($full_file_name);
72 72
 
73
-	$dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
73
+    $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
74 74
 
75
-	if($dir[strlen($dir)-1] != '/') {
76
-		$dir.='/';
77
-	}
75
+    if($dir[strlen($dir)-1] != '/') {
76
+        $dir.='/';
77
+    }
78 78
 
79 79
 
80
-	//Parse whole file at one
81
-	$fp = fopen($full_file_name, "r");
82
-	$file_content = fread ($fp, filesize ($full_file_name));
83
-	fclose($fp);
80
+    //Parse whole file at one
81
+    $fp = fopen($full_file_name, "r");
82
+    $file_content = fread ($fp, filesize ($full_file_name));
83
+    fclose($fp);
84 84
     $exercisePath = api_get_self();
85
-  	$exfile = explode('/',$exercisePath);
86
-  	$exfile = $exfile[sizeof($exfile)-1];
87
-  	$exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
88
-  	$exercisePath = $exercisePath;
85
+        $exfile = explode('/',$exercisePath);
86
+        $exfile = $exfile[sizeof($exfile)-1];
87
+        $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
88
+        $exercisePath = $exercisePath;
89 89
 
90
-		$content = $file_content;
91
-		$mit = "function Finish(){";
90
+        $content = $file_content;
91
+        $mit = "function Finish(){";
92 92
 
93
-		$js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
94
-		"function mySaveScore() // This function included by Dokeos System\n".
93
+        $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
94
+        "function mySaveScore() // This function included by Dokeos System\n".
95 95
 "{\n".
96 96
 "   if (SaveScoreVariable==0)\n".
97 97
 "		{\n".
@@ -109,23 +109,23 @@  discard block
 block discarded – undo
109 109
 "// Must be included \n".
110 110
 "function Finish(){\n".
111 111
 " mySaveScore();";
112
-		$newcontent = str_replace($mit,$js_content,$content);
112
+        $newcontent = str_replace($mit,$js_content,$content);
113 113
 
114
-		$prehref="javascript:void(0);";
115
-		$posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
116
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
114
+        $prehref="javascript:void(0);";
115
+        $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
116
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
117 117
 
118 118
 
119
-		$prehref="class=\"GridNum\" onclick=";
120
-		$posthref="class=\"GridNum\" onMouseover=";
121
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
119
+        $prehref="class=\"GridNum\" onclick=";
120
+        $posthref="class=\"GridNum\" onMouseover=";
121
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
122 122
 
123 123
 
124
-		header('Content-length: '.strlen($newcontent));
125
-		// Dipsp.
126
-		echo $newcontent;
124
+        header('Content-length: '.strlen($newcontent));
125
+        // Dipsp.
126
+        echo $newcontent;
127 127
 
128
-	exit();
128
+    exit();
129 129
 }
130 130
 
131 131
 //normal case, all non-html files
Please login to merge, or discard this patch.
main/document/create_document.php 1 patch
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 $is_certificate_mode = false;
62 62
 
63 63
 if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
64
-	$is_certificate_mode = true;
64
+    $is_certificate_mode = true;
65 65
 }
66 66
 
67 67
 if ($is_certificate_mode) {
68
-	$nameTools = get_lang('CreateCertificate');
68
+    $nameTools = get_lang('CreateCertificate');
69 69
 } else {
70
-	$nameTools = get_lang('CreateDocument');
70
+    $nameTools = get_lang('CreateDocument');
71 71
 }
72 72
 
73 73
 /*	Constants and variables */
@@ -124,26 +124,26 @@  discard block
 block discarded – undo
124 124
 
125 125
 // Please, do not modify this dirname formatting
126 126
 if (strstr($dir, '..')) {
127
-	$dir = '/';
127
+    $dir = '/';
128 128
 }
129 129
 
130 130
 if ($dir[0] == '.') {
131
-	$dir = substr($dir, 1);
131
+    $dir = substr($dir, 1);
132 132
 }
133 133
 
134 134
 if ($dir[0] != '/') {
135
-	$dir = '/'.$dir;
135
+    $dir = '/'.$dir;
136 136
 }
137 137
 
138 138
 if ($dir[strlen($dir) - 1] != '/') {
139
-	$dir .= '/';
139
+    $dir .= '/';
140 140
 }
141 141
 
142 142
 if ($is_certificate_mode) {
143
-	$document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates');
144
-	$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
145
-	$folder_id = $document_data['id'];
146
-	$dir = '/certificates/';
143
+    $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates');
144
+    $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
145
+    $folder_id = $document_data['id'];
146
+    $dir = '/certificates/';
147 147
 }
148 148
 
149 149
 $doc_tree  = explode('/', $dir);
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
 
155 155
     // Level correction for group documents.
156 156
     if (!empty($group_properties['directory'])) {
157
-    	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
157
+        $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
158 158
     }
159 159
 }
160 160
 $relative_url = '';
161 161
 for ($i = 0; $i < ($count_dir); $i++) {
162
-	$relative_url .= '../';
162
+    $relative_url .= '../';
163 163
 }
164 164
 
165 165
 if ($relative_url== '') {
166
-	$relative_url = '/';
166
+    $relative_url = '/';
167 167
 }
168 168
 
169 169
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
     'cols-size' => [2, 10, 0],
176 176
     'FullPage' => true,
177 177
     'InDocument' => true,
178
-	'CreateDocumentDir' => $relative_url,
179
-	'CreateDocumentWebDir' => (empty($group_properties['directory']))
180
-                        		? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
181
-                        		: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
182
-	'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
178
+    'CreateDocumentDir' => $relative_url,
179
+    'CreateDocumentWebDir' => (empty($group_properties['directory']))
180
+                                ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
181
+                                : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
182
+    'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
183 183
 );
184 184
 
185 185
 if ($is_certificate_mode) {
@@ -191,41 +191,41 @@  discard block
 block discarded – undo
191 191
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
192 192
 
193 193
 if (!is_dir($filepath)) {
194
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
195
-	$dir = '/';
194
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
195
+    $dir = '/';
196 196
 }
197 197
 
198 198
 $to_group_id = 0;
199 199
 if (!$is_certificate_mode) {
200
-	if (api_is_in_group()) {
200
+    if (api_is_in_group()) {
201 201
         $interbreadcrumb[] = array(
202 202
             "url" => "../group/group_space.php?".api_get_cidreq(),
203 203
             "name" => get_lang('GroupSpace'),
204 204
         );
205
-		$noPHP_SELF = true;
206
-		$to_group_id = $group_properties['iid'];
207
-		$path = explode('/', $dir);
208
-		if ('/'.$path[1] != $group_properties['directory']) {
209
-			api_not_allowed(true);
210
-		}
211
-	}
205
+        $noPHP_SELF = true;
206
+        $to_group_id = $group_properties['iid'];
207
+        $path = explode('/', $dir);
208
+        if ('/'.$path[1] != $group_properties['directory']) {
209
+            api_not_allowed(true);
210
+        }
211
+    }
212 212
     $interbreadcrumb[] = array(
213 213
         "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
214 214
         "name" => get_lang('Documents'),
215 215
     );
216 216
 } else {
217
-	$interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
217
+    $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
218 218
 }
219 219
 
220 220
 if (!$is_allowed_in_course) {
221
-	api_not_allowed(true);
221
+    api_not_allowed(true);
222 222
 }
223 223
 
224 224
 if (!($is_allowed_to_edit ||
225 225
     $groupRights ||
226 226
     DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id()))
227 227
 ) {
228
-	api_not_allowed(true);
228
+    api_not_allowed(true);
229 229
 }
230 230
 
231 231
 /*	Header */
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 
234 234
 $display_dir = $dir;
235 235
 if (isset($group_properties)) {
236
-	$display_dir = explode('/', $dir);
237
-	unset($display_dir[0]);
238
-	unset($display_dir[1]);
239
-	$display_dir = implode('/', $display_dir);
236
+    $display_dir = explode('/', $dir);
237
+    unset($display_dir[0]);
238
+    unset($display_dir[1]);
239
+    $display_dir = implode('/', $display_dir);
240 240
 }
241 241
 
242 242
 $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 $form->addElement('header', $nameTools);
254 254
 
255 255
 if ($is_certificate_mode) {//added condition for certicate in gradebook
256
-	$form->addElement('hidden','certificate','true',array('id'=>'certificate'));
257
-	if (isset($_GET['selectcat'])) {
258
-		$form->addElement('hidden','selectcat', $select_cat);
256
+    $form->addElement('hidden','certificate','true',array('id'=>'certificate'));
257
+    if (isset($_GET['selectcat'])) {
258
+        $form->addElement('hidden','selectcat', $select_cat);
259 259
     }
260 260
 }
261 261
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 // new document created
315 315
 
316 316
 if (!$is_certificate_mode &&
317
-	!DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
317
+    !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
318 318
 ) {
319 319
     $folders = DocumentManager::get_all_document_folders(
320 320
         $_course,
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         array('cols-size' => [2, 10, 0])
330 330
     );
331 331
 
332
-	$folder_titles = array();
332
+    $folder_titles = array();
333 333
     if (is_array($folders)) {
334 334
         $escaped_folders = array();
335 335
         foreach ($folders as $key => & $val) {
@@ -366,22 +366,22 @@  discard block
 block discarded – undo
366 366
         }
367 367
     }
368 368
 
369
-	if (empty($group_dir)) {
370
-		$parent_select -> addOption(get_lang('HomeDirectory'), '/');
371
-		if (is_array($folders)) {
372
-			foreach ($folders as & $folder) {
373
-				//Hide some folders
374
-				if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
369
+    if (empty($group_dir)) {
370
+        $parent_select -> addOption(get_lang('HomeDirectory'), '/');
371
+        if (is_array($folders)) {
372
+            foreach ($folders as & $folder) {
373
+                //Hide some folders
374
+                if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
375 375
                     continue;
376
-				}
377
-				//Admin setting for Hide/Show the folders of all users
378
-				if (api_get_setting('show_users_folders') == 'false' &&
376
+                }
377
+                //Admin setting for Hide/Show the folders of all users
378
+                if (api_get_setting('show_users_folders') == 'false' &&
379 379
                     (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_'))
380 380
                 ){
381
-					continue;
382
-				}
383
-				//Admin setting for Hide/Show Default folders to all users
384
-				if (api_get_setting('show_default_folders') == 'false' &&
381
+                    continue;
382
+                }
383
+                //Admin setting for Hide/Show Default folders to all users
384
+                if (api_get_setting('show_default_folders') == 'false' &&
385 385
                     (
386 386
                         $folder == '/images' ||
387 387
                         $folder == '/flash' ||
@@ -391,82 +391,82 @@  discard block
 block discarded – undo
391 391
                         $folder == '/video/flv'
392 392
                     )
393 393
                 ){
394
-					continue;
395
-				}
396
-				//Admin setting for Hide/Show chat history folder
397
-				if (api_get_setting('show_chat_folder') == 'false' &&
394
+                    continue;
395
+                }
396
+                //Admin setting for Hide/Show chat history folder
397
+                if (api_get_setting('show_chat_folder') == 'false' &&
398 398
                     $folder=='/chat_files'
399 399
                 ){
400
-					continue;
401
-				}
400
+                    continue;
401
+                }
402 402
 
403
-				$selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
404
-				$path_parts = explode('/', $folder);
405
-				$folder_titles[$folder] = cut($folder_titles[$folder], 80);
403
+                $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
404
+                $path_parts = explode('/', $folder);
405
+                $folder_titles[$folder] = cut($folder_titles[$folder], 80);
406 406
                 $space_counter =count($path_parts) - 2;
407 407
                 if ($space_counter > 0) {
408 408
                     $label = str_repeat('&nbsp;&nbsp;&nbsp;', $space_counter).' &mdash; '.$folder_titles[$folder];
409 409
                 } else {
410 410
                     $label = ' &mdash; '.$folder_titles[$folder];
411 411
                 }
412
-				$parent_select -> addOption($label, $folder);
413
-				if ($selected != '') {
414
-					$parent_select->setSelected($folder);
415
-				}
416
-			}
417
-		}
418
-	} else {
419
-		if (is_array($folders) && !empty($folders)) {
420
-			foreach ($folders as & $folder) {
421
-				$selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
422
-				$label = $folder_titles[$folder];
423
-				if ($folder == $group_dir) {
424
-					$label = '/ (' . get_lang('HomeDirectory') . ')';
425
-				} else {
426
-					$path_parts = explode('/', str_replace($group_dir, '', $folder));
427
-					$label = cut($label, 80);
428
-					$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
429
-				}
430
-				$parent_select->addOption($label, $folder);
431
-				if ($selected != '') {
432
-					$parent_select->setSelected($folder);
433
-				}
434
-			}
435
-		}
436
-	}
412
+                $parent_select -> addOption($label, $folder);
413
+                if ($selected != '') {
414
+                    $parent_select->setSelected($folder);
415
+                }
416
+            }
417
+        }
418
+    } else {
419
+        if (is_array($folders) && !empty($folders)) {
420
+            foreach ($folders as & $folder) {
421
+                $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
422
+                $label = $folder_titles[$folder];
423
+                if ($folder == $group_dir) {
424
+                    $label = '/ (' . get_lang('HomeDirectory') . ')';
425
+                } else {
426
+                    $path_parts = explode('/', str_replace($group_dir, '', $folder));
427
+                    $label = cut($label, 80);
428
+                    $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
429
+                }
430
+                $parent_select->addOption($label, $folder);
431
+                if ($selected != '') {
432
+                    $parent_select->setSelected($folder);
433
+                }
434
+            }
435
+        }
436
+    }
437 437
 }
438 438
 
439 439
 $form->addHidden('dirValue', '');
440 440
 
441 441
 if ($is_certificate_mode) {
442
-	$form->addButtonCreate(get_lang('CreateCertificate'));
442
+    $form->addButtonCreate(get_lang('CreateCertificate'));
443 443
 } else {
444
-	$form->addButtonCreate(get_lang('CreateDoc'));
444
+    $form->addButtonCreate(get_lang('CreateDoc'));
445 445
 }
446 446
 
447 447
 $form->setDefaults($defaults);
448 448
 
449 449
 // If form validates -> save the new document
450 450
 if ($form->validate()) {
451
-	$values = $form->exportValues();
452
-	$readonly = isset($values['readonly']) ? 1 : 0;
453
-	$values['title'] = trim($values['title']);
451
+    $values = $form->exportValues();
452
+    $readonly = isset($values['readonly']) ? 1 : 0;
453
+    $values['title'] = trim($values['title']);
454 454
 
455 455
     if (!empty($values['dirValue'])) {
456 456
         $dir = $values['dirValue'];
457 457
     }
458 458
 
459 459
     if ($dir[strlen($dir) - 1] != '/') {
460
-		$dir .= '/';
461
-	}
460
+        $dir .= '/';
461
+    }
462 462
     $filepath = $filepath.$dir;
463 463
 
464 464
     // Setting the filename
465
-	$filename = $values['title'];
466
-	$filename = addslashes(trim($filename));
467
-	$filename = Security::remove_XSS($filename);
468
-	$filename = api_replace_dangerous_char($filename);
469
-	$filename = disable_dangerous_file($filename);
465
+    $filename = $values['title'];
466
+    $filename = addslashes(trim($filename));
467
+    $filename = Security::remove_XSS($filename);
468
+    $filename = api_replace_dangerous_char($filename);
469
+    $filename = disable_dangerous_file($filename);
470 470
     $filename .= DocumentManager::getDocumentSuffix(
471 471
         $_course,
472 472
         api_get_session_id(),
@@ -474,14 +474,14 @@  discard block
 block discarded – undo
474 474
     );
475 475
 
476 476
     // Setting the title
477
-	$title = $values['title'];
477
+    $title = $values['title'];
478 478
 
479 479
     // Setting the extension
480
-	$extension = 'html';
480
+    $extension = 'html';
481 481
 
482
-	$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
482
+    $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
483 483
 
484
-	/*if (strpos($content, '/css/frames.css') == false) {
484
+    /*if (strpos($content, '/css/frames.css') == false) {
485 485
 		$content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
486 486
 	}*/
487 487
 
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
         exit;
495 495
     }
496 496
 
497
-	if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
498
-		//$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
499
-		$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content);
497
+    if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
498
+        //$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
499
+        $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].api_get_path(REL_COURSE_PATH), $content);
500 500
 
501
-		fputs($fp, $content);
502
-		fclose($fp);
503
-		chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
501
+        fputs($fp, $content);
502
+        fclose($fp);
503
+        chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
504 504
 
505 505
         /*
506 506
 		if (!is_dir($filepath.'css')) {
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 			api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, null, null, null, null, $current_session_id);
519 519
 		}*/
520 520
 
521
-		$file_size = filesize($filepath.$filename.'.'.$extension);
522
-		$save_file_path = $dir.$filename.'.'.$extension;
521
+        $file_size = filesize($filepath.$filename.'.'.$extension);
522
+        $save_file_path = $dir.$filename.'.'.$extension;
523 523
 
524 524
         $document_id = add_document(
525 525
             $_course,
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
             $readonly
532 532
         );
533 533
 
534
-		if ($document_id) {
535
-			api_item_property_update(
534
+        if ($document_id) {
535
+            api_item_property_update(
536 536
                 $_course,
537 537
                 TOOL_DOCUMENT,
538 538
                 $document_id,
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
                 null,
545 545
                 $current_session_id
546 546
             );
547
-			// Update parent folders
548
-			item_property_update_on_folder($_course, $dir, $userId);
549
-			$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
550
-			$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
547
+            // Update parent folders
548
+            item_property_update_on_folder($_course, $dir, $userId);
549
+            $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
550
+            $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
551 551
             $new_title = htmlspecialchars($new_title);
552
-			if ($new_comment || $new_title) {
553
-				$ct = '';
552
+            if ($new_comment || $new_title) {
553
+                $ct = '';
554 554
                 $params = [];
555 555
                 if ($new_comment) {
556 556
                     $params['comment'] = $new_comment;
@@ -565,39 +565,39 @@  discard block
 block discarded – undo
565 565
                         ['c_id = ? AND id = ?' => [$course_id, $document_id]]
566 566
                     );
567 567
                 }
568
-			}
569
-			$dir= substr($dir,0,-1);
570
-			$selectcat = '';
568
+            }
569
+            $dir= substr($dir,0,-1);
570
+            $selectcat = '';
571 571
             if (isset($_REQUEST['selectcat'])) {
572 572
                 $selectcat = "&selectcat=".intval($_REQUEST['selectcat']);
573 573
             }
574
-			$certificate_condition = '';
575
-			if ($is_certificate_mode) {
576
-				$df = DocumentManager::get_default_certificate_id($_course['code']);
574
+            $certificate_condition = '';
575
+            if ($is_certificate_mode) {
576
+                $df = DocumentManager::get_default_certificate_id($_course['code']);
577 577
                 if (!isset($df)) {
578 578
                     DocumentManager::attach_gradebook_certificate($_course['code'],$document_id);
579
-				}
580
-				$certificate_condition = '&certificate=true&curdirpath=/certificates';
581
-			}
579
+                }
580
+                $certificate_condition = '&certificate=true&curdirpath=/certificates';
581
+            }
582 582
             Display::addFlash(Display::return_message(get_lang('ItemAdded')));
583
-			header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
584
-			exit();
585
-		} else {
586
-			Display :: display_header($nameTools, 'Doc');
587
-			Display :: display_error_message(get_lang('Impossible'));
588
-			Display :: display_footer();
589
-		}
590
-	} else {
591
-		Display :: display_header($nameTools, 'Doc');
592
-		Display :: display_error_message(get_lang('Impossible'));
593
-		Display :: display_footer();
594
-	}
583
+            header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
584
+            exit();
585
+        } else {
586
+            Display :: display_header($nameTools, 'Doc');
587
+            Display :: display_error_message(get_lang('Impossible'));
588
+            Display :: display_footer();
589
+        }
590
+    } else {
591
+        Display :: display_header($nameTools, 'Doc');
592
+        Display :: display_error_message(get_lang('Impossible'));
593
+        Display :: display_footer();
594
+    }
595 595
 } else {
596
-	// Copied from document.php
597
-	$dir_array = explode('/', $dir);
598
-	$array_len = count($dir_array);
596
+    // Copied from document.php
597
+    $dir_array = explode('/', $dir);
598
+    $array_len = count($dir_array);
599 599
 
600
-	// Breadcrumb for the current directory root path
600
+    // Breadcrumb for the current directory root path
601 601
     if (!empty($document_data)) {
602 602
         if (empty($document_data['parents'])) {
603 603
             $interbreadcrumb[] = array(
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
         }
615 615
     }
616 616
 
617
-	Display :: display_header($nameTools, "Doc");
618
-	// actions
617
+    Display :: display_header($nameTools, "Doc");
618
+    // actions
619 619
 
620
-	// link back to the documents overview
621
-	if ($is_certificate_mode) {
620
+    // link back to the documents overview
621
+    if ($is_certificate_mode) {
622 622
             $actionsLeft =  '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.
623 623
                 Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
624 624
             $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.
@@ -633,19 +633,19 @@  discard block
 block discarded – undo
633 633
 
634 634
     echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft));
635 635
 
636
-	if ($is_certificate_mode) {
636
+    if ($is_certificate_mode) {
637 637
         $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
638 638
             api_get_user_id(),
639 639
             api_get_course_id()
640 640
         );
641 641
 
642
-		$str_info = '';
643
-		foreach ($all_information_by_create_certificate[0] as $info_value) {
644
-			$str_info.=$info_value.'<br/>';
645
-		}
646
-		$create_certificate = get_lang('CreateCertificateWithTags');
647
-		Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
648
-	}
642
+        $str_info = '';
643
+        foreach ($all_information_by_create_certificate[0] as $info_value) {
644
+            $str_info.=$info_value.'<br/>';
645
+        }
646
+        $create_certificate = get_lang('CreateCertificateWithTags');
647
+        Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
648
+    }
649 649
 
650 650
     // HTML-editor
651 651
     echo '<div class="page-create">
@@ -661,5 +661,5 @@  discard block
 block discarded – undo
661 661
                 '.$form->returnForm().'
662 662
             </div>
663 663
           </div></div>';
664
-	Display :: display_footer();
664
+    Display :: display_footer();
665 665
 }
Please login to merge, or discard this patch.
main/install/install.lib.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
         $html .= '<label class="checkbox-inline">
1714 1714
                         <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1715 1715
                     </label>';
1716
-         $html .= '<label class="checkbox-inline">
1716
+            $html .= '<label class="checkbox-inline">
1717 1717
                     <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1718 1718
                 </label>';
1719 1719
         $html .= '</div>';
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
     </div>';
1748 1748
 
1749 1749
     echo panel($html, get_lang('Platform'), 'platform');
1750
- ?>
1750
+    ?>
1751 1751
     <div class='form-group'>
1752 1752
         <div class="col-sm-6">
1753 1753
             <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>
@@ -3068,10 +3068,10 @@  discard block
 block discarded – undo
3068 3068
                     $sessionId = $row['session_id'];
3069 3069
                     $workId = $row['id'];
3070 3070
                     $itemInfo = api_get_item_property_info(
3071
-                      $courseId,
3072
-                       'work',
3073
-                      $workId,
3074
-                      $sessionId
3071
+                        $courseId,
3072
+                        'work',
3073
+                        $workId,
3074
+                        $sessionId
3075 3075
                     );
3076 3076
                     $courseInfo = api_get_course_info_by_id($courseId);
3077 3077
                     if (empty($item_info)) {
Please login to merge, or discard this patch.
main/webservices/cm_webservice.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
  */
83 83
 interface WSCMErrorHandler
84 84
 {
85
-	/**
86
-	 * Handle method
87
-	 *
88
-	 * @param WSError Error
89
-	 */
90
-	public function handle($error);
85
+    /**
86
+     * Handle method
87
+     *
88
+     * @param WSError Error
89
+     */
90
+    public function handle($error);
91 91
 }
92 92
 
93 93
 /**
@@ -95,57 +95,57 @@  discard block
 block discarded – undo
95 95
  */
96 96
 class WSCM
97 97
 {
98
-	/**
99
-	 * Chamilo configuration
100
-	 *
101
-	 * @var array
102
-	 */
103
-	protected $_configuration;
98
+    /**
99
+     * Chamilo configuration
100
+     *
101
+     * @var array
102
+     */
103
+    protected $_configuration;
104 104
 
105
-	/**
106
-	 * Constructor
107
-	 */
108
-	public function __construct()
105
+    /**
106
+     * Constructor
107
+     */
108
+    public function __construct()
109 109
     {
110
-		$this->_configuration = $GLOBALS['_configuration'];
111
-	}
110
+        $this->_configuration = $GLOBALS['_configuration'];
111
+    }
112 112
 
113
-	/**
114
-	 * Verifies the API key
115
-	 *
116
-	 * @param string Secret key
117
-	 * @return mixed WSError in case of failure, null in case of success
118
-	 */
119
-	protected function verifyKey($secret_key)
113
+    /**
114
+     * Verifies the API key
115
+     *
116
+     * @param string Secret key
117
+     * @return mixed WSError in case of failure, null in case of success
118
+     */
119
+    protected function verifyKey($secret_key)
120 120
     {
121
-		$ip = trim($_SERVER['REMOTE_ADDR']);
122
-		// if we are behind a reverse proxy, assume it will send the
123
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
124
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
125
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
126
-		  $ip = trim($ip1);
127
-		}
128
-		$security_key = $ip.$this->_configuration['security_key'];
121
+        $ip = trim($_SERVER['REMOTE_ADDR']);
122
+        // if we are behind a reverse proxy, assume it will send the
123
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
124
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
125
+            list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
126
+            $ip = trim($ip1);
127
+        }
128
+        $security_key = $ip.$this->_configuration['security_key'];
129 129
 
130
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
131
-			return new WSCMError(1, "API key is invalid");
132
-		} else {
133
-			return null;
134
-		}
135
-	}
130
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
131
+            return new WSCMError(1, "API key is invalid");
132
+        } else {
133
+            return null;
134
+        }
135
+    }
136 136
 
137
-	/**
138
-	 * Verifies if the user is valid
139
-	 *
140
-	 * @param <String> $username of the user in chamilo
141
-	 * @param <String> $pass of the same user (in MD5 of SHA)
142
-	 *
143
-	 * return "valid" if username e password are correct! Else, return a message error
144
-	 */
145
-	public function verifyUserPass($username, $pass)
137
+    /**
138
+     * Verifies if the user is valid
139
+     *
140
+     * @param <String> $username of the user in chamilo
141
+     * @param <String> $pass of the same user (in MD5 of SHA)
142
+     *
143
+     * return "valid" if username e password are correct! Else, return a message error
144
+     */
145
+    public function verifyUserPass($username, $pass)
146 146
     {
147
-		$login = $username;
148
-		$password = $pass;
147
+        $login = $username;
148
+        $password = $pass;
149 149
 
150 150
         $userRepo = UserManager::getRepository();
151 151
         /** @var User $uData */
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
             }
179 179
         }
180 180
         return get_lang('InvalidId');
181
-	}
181
+    }
182 182
 
183
-	/**
184
-	 * Gets the real user id based on the user id field name and value.
185
-	 * Note that if the user id field name is "chamilo_user_id", it will use the user id
186
-	 * in the system database
187
-	 *
188
-	 * @param string User id field name
189
-	 * @param string User id value
190
-	 * @return mixed System user id if the user was found, WSError otherwise
191
-	 */
183
+    /**
184
+     * Gets the real user id based on the user id field name and value.
185
+     * Note that if the user id field name is "chamilo_user_id", it will use the user id
186
+     * in the system database
187
+     *
188
+     * @param string User id field name
189
+     * @param string User id value
190
+     * @return mixed System user id if the user was found, WSError otherwise
191
+     */
192 192
     protected function getUserId($user_id_field_name, $user_id_value)
193 193
     {
194 194
         if ($user_id_field_name == "chamilo_user_id") {
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
         }
211 211
     }
212 212
 
213
-	/**
214
-	 * Gets the real course id based on the course id field name and value.
215
-	 * Note that if the course id field name is "chamilo_course_id", it will use the course id
216
-	 * in the system database
217
-	 *
218
-	 * @param string Course id field name
219
-	 * @param string Course id value
220
-	 * @return mixed System course id if the course was found, WSError otherwise
221
-	 */
222
-	protected function getCourseId($course_id_field_name, $course_id_value)
213
+    /**
214
+     * Gets the real course id based on the course id field name and value.
215
+     * Note that if the course id field name is "chamilo_course_id", it will use the course id
216
+     * in the system database
217
+     *
218
+     * @param string Course id field name
219
+     * @param string Course id value
220
+     * @return mixed System course id if the course was found, WSError otherwise
221
+     */
222
+    protected function getCourseId($course_id_field_name, $course_id_value)
223 223
     {
224 224
         if ($course_id_field_name == "chamilo_course_id") {
225 225
             if (CourseManager::get_course_code_from_course_id($course_id_value) != null) {
@@ -238,78 +238,78 @@  discard block
 block discarded – undo
238 238
                 return $courseId;
239 239
             }
240 240
         }
241
-	}
241
+    }
242 242
 
243
-	/**
244
-	 * Gets the real session id based on the session id field name and value.
245
-	 * Note that if the session id field name is "chamilo_session_id", it will use the session id
246
-	 * in the system database
247
-	 *
248
-	 * @param string Session id field name
249
-	 * @param string Session id value
250
-	 * @return mixed System session id if the session was found, WSError otherwise
251
-	 */
252
-	protected function getSessionId($session_id_field_name, $session_id_value)
253
-	{
254
-		if ($session_id_field_name == "chamilo_session_id") {
255
-			$session = SessionManager::fetch((int)$session_id_value);
256
-			if(!empty($session)) {
257
-				return intval($session_id_value);
258
-			} else {
259
-				return new WSCMError(300, "Session not found");
260
-			}
261
-		} else {
262
-			$session_id = SessionManager::getSessionIdFromOriginalId(
263
-				$session_id_value,
264
-				$session_id_field_name
265
-			);
266
-			if($session_id == 0) {
267
-				return new WSCMError(300, "Session not found");
268
-			} else {
269
-				return $session_id;
270
-			}
271
-		}
272
-	}
243
+    /**
244
+     * Gets the real session id based on the session id field name and value.
245
+     * Note that if the session id field name is "chamilo_session_id", it will use the session id
246
+     * in the system database
247
+     *
248
+     * @param string Session id field name
249
+     * @param string Session id value
250
+     * @return mixed System session id if the session was found, WSError otherwise
251
+     */
252
+    protected function getSessionId($session_id_field_name, $session_id_value)
253
+    {
254
+        if ($session_id_field_name == "chamilo_session_id") {
255
+            $session = SessionManager::fetch((int)$session_id_value);
256
+            if(!empty($session)) {
257
+                return intval($session_id_value);
258
+            } else {
259
+                return new WSCMError(300, "Session not found");
260
+            }
261
+        } else {
262
+            $session_id = SessionManager::getSessionIdFromOriginalId(
263
+                $session_id_value,
264
+                $session_id_field_name
265
+            );
266
+            if($session_id == 0) {
267
+                return new WSCMError(300, "Session not found");
268
+            } else {
269
+                return $session_id;
270
+            }
271
+        }
272
+    }
273 273
 
274
-	/**
275
-	 * Handles an error by calling the WSError error handler
276
-	 *
277
-	 * @param WSError Error
278
-	 */
279
-	protected function handleError($error)
280
-	{
281
-		$handler = WSCMError::getErrorHandler();
282
-		$handler->handle($error);
283
-	}
274
+    /**
275
+     * Handles an error by calling the WSError error handler
276
+     *
277
+     * @param WSError Error
278
+     */
279
+    protected function handleError($error)
280
+    {
281
+        $handler = WSCMError::getErrorHandler();
282
+        $handler->handle($error);
283
+    }
284 284
 
285
-	/**
286
-	 * Gets a successful result
287
-	 *
288
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
289
-	 */
290
-	protected function getSuccessfulResult()
291
-	{
292
-		return array('code' => 0, 'message' => 'Operation was successful');
293
-	}
285
+    /**
286
+     * Gets a successful result
287
+     *
288
+     * @return array Array with a code of 0 and a message 'Operation was successful'
289
+     */
290
+    protected function getSuccessfulResult()
291
+    {
292
+        return array('code' => 0, 'message' => 'Operation was successful');
293
+    }
294 294
 
295
-	/**
296
-	 * Test function. Returns the string success
297
-	 *
298
-	 * @return string Success
299
-	 */
300
-	public function test()
301
-	{
302
-		return "success";
303
-	}
295
+    /**
296
+     * Test function. Returns the string success
297
+     *
298
+     * @return string Success
299
+     */
300
+    public function test()
301
+    {
302
+        return "success";
303
+    }
304 304
 
305
-	/**
306
-	 * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
307
-	 * @param <type> $string
308
-	 * @return <type> $string
309
-	 */
310
-	public function nl2br_revert($string)
305
+    /**
306
+     * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
307
+     * @param <type> $string
308
+     * @return <type> $string
309
+     */
310
+    public function nl2br_revert($string)
311 311
     {
312
-		return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string);
313
-	}
312
+        return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string);
313
+    }
314 314
 }
315 315
 
Please login to merge, or discard this patch.
main/webservices/cm_webservice_user.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function find_id_user($username, $password, $name)
15 15
     {
16
-         if ($this->verifyUserPass($username, $password) == "valid") {
16
+            if ($this->verifyUserPass($username, $password) == "valid") {
17 17
             $listResult = "#";
18 18
 
19 19
             $listArrayResult = Array();
20 20
             $listArray = Array();
21 21
 
22 22
             $list = $this->get_user_list_like_start(array('firstname'=>$name), array('firstname'));
23
-             foreach ($list as $userData) {
24
-                 $listArray[] = $userData['user_id'];
25
-             }
23
+                foreach ($list as $userData) {
24
+                    $listArray[] = $userData['user_id'];
25
+                }
26 26
 
27 27
             $list = $this->get_user_list_like_start(array('lastname'=>$name), array('firstname'));
28
-             foreach ($list as $userData) {
29
-                 $listArray[] = $userData['user_id'];
30
-             }
28
+                foreach ($list as $userData) {
29
+                    $listArray[] = $userData['user_id'];
30
+                }
31 31
 
32 32
             $list = $this->get_user_list_like_start(array('email'=>$name), array('firstname'));
33 33
             foreach ($list as $userData) {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         global $charset;
91 91
         if ($this->verifyUserPass($username, $password) == "valid") {
92
-		    $user_id = UserManager::get_user_id_from_username($username);
92
+            $user_id = UserManager::get_user_id_from_username($username);
93 93
             $message_title = get_lang('Invitation');
94 94
             $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
95 95
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 
130 130
 
131 131
     /**
132
-    * Get a list of users of which the given conditions match with a LIKE '%cond%'
133
-    * @param array $conditions a list of condition (exemple : status=>STUDENT)
134
-    * @param array $order_by a list of fields on which sort
135
-    * @return array An array with all users of the platform.
136
-    * @todo optional course code parameter, optional sorting parameters...
132
+     * Get a list of users of which the given conditions match with a LIKE '%cond%'
133
+     * @param array $conditions a list of condition (exemple : status=>STUDENT)
134
+     * @param array $order_by a list of fields on which sort
135
+     * @return array An array with all users of the platform.
136
+     * @todo optional course code parameter, optional sorting parameters...
137 137
      *@todo Use the UserManager class
138 138
      * @todo security filter order by
139
-    */
139
+     */
140 140
     private static function get_user_list_like_start($conditions = array(), $order_by = array())
141 141
     {
142 142
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.
main/gradebook/lib/be/studentpublicationlink.class.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@
 block discarded – undo
195 195
         $parentId = !$assignment ? 0 : $assignment->getId();
196 196
 
197 197
         if (empty($session)) {
198
-           $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
198
+            $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
199 199
                    WHERE
200 200
                         a.cId = :course AND
201 201
                         a.active = :active AND
Please login to merge, or discard this patch.