Passed
Push — 1.10.x ( 918f1f...c8b126 )
by Yannick
419:13 queued 372:02
created
main/document/edit_paint.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- *	This file allows creating new svg and png documents with an online editor.
5
- *
6
- *	@package chamilo.document
7
- *  @todo used the document_id instead of the curdirpath
8
- *
9
- * @author Juan Carlos Raña Trabado
10
- * @since 30/january/2011
4
+     *	This file allows creating new svg and png documents with an online editor.
5
+     *
6
+     *	@package chamilo.document
7
+     *  @todo used the document_id instead of the curdirpath
8
+     *
9
+     * @author Juan Carlos Raña Trabado
10
+     * @since 30/january/2011
11 11
 */
12 12
 require_once '../inc/global.inc.php';
13 13
 
@@ -61,42 +61,42 @@  discard block
 block discarded – undo
61 61
 /* Please, do not modify this dirname formatting */
62 62
 
63 63
 if (strstr($dir, '..')) {
64
-	$dir = '/';
64
+    $dir = '/';
65 65
 }
66 66
 
67 67
 if ($dir[0] == '.') {
68
-	$dir = substr($dir, 1);
68
+    $dir = substr($dir, 1);
69 69
 }
70 70
 
71 71
 if ($dir[0] != '/') {
72
-	$dir = '/'.$dir;
72
+    $dir = '/'.$dir;
73 73
 }
74 74
 
75 75
 if ($dir[strlen($dir) - 1] != '/') {
76
-	$dir .= '/';
76
+    $dir .= '/';
77 77
 }
78 78
 
79 79
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
80 80
 
81 81
 if (!is_dir($filepath)) {
82
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
83
-	$dir = '/';
82
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
83
+    $dir = '/';
84 84
 }
85 85
 
86 86
 //groups //TODO:clean
87 87
 if (!empty($groupId)) {
88
-	$interbreadcrumb[] = array ('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'));
89
-	$group_document = true;
90
-	$noPHP_SELF = true;
88
+    $interbreadcrumb[] = array ('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'));
89
+    $group_document = true;
90
+    $noPHP_SELF = true;
91 91
 }
92 92
 
93 93
 
94 94
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
95 95
 
96 96
 if (!$is_certificate_mode)
97
-	$interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents'));
97
+    $interbreadcrumb[]= array("url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(), "name"=> get_lang('Documents'));
98 98
 else
99
-	$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
99
+    $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
100 100
 
101 101
 // Interbreadcrumb for the current directory root path
102 102
 if (empty($document_data['parents'])) {
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 }
112 112
 
113 113
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights'] ||
114
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
114
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
115 115
 
116 116
 if (!$is_allowedToEdit) {
117
-	api_not_allowed(true);
117
+    api_not_allowed(true);
118 118
 }
119 119
 
120 120
 Event::event_access_tool(TOOL_DOCUMENT);
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 $locktitle="false";
147 147
 
148 148
 if ($_SERVER['HTTP_HOST']=="localhost") {
149
-	$path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
150
-	if (!file_exists($path_and_file)) {
151
-		$crossdomain='<?xml version="1.0"?>
149
+    $path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
150
+    if (!file_exists($path_and_file)) {
151
+        $crossdomain='<?xml version="1.0"?>
152 152
 			<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
153 153
 			<cross-domain-policy>
154 154
 				<allow-access-from domain="cdn.pixlr.com" />
155 155
 				<site-control permitted-cross-domain-policies="master-only"/>
156 156
 				<allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/>
157 157
 			</cross-domain-policy>';//more open domain="*"
158
-		@file_put_contents($path_and_file, $crossdomain);
159
-	}
160
-	$credentials="true";
158
+        @file_put_contents($path_and_file, $crossdomain);
159
+    }
160
+    $credentials="true";
161 161
 }
162 162
 else {
163
-	$credentials="false";
163
+    $credentials="false";
164 164
 }
165 165
 
166 166
 //make temp images
@@ -173,23 +173,23 @@  discard block
 block discarded – undo
173 173
 $htaccess=api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess';
174 174
 if (!file_exists($htaccess)) {
175 175
 
176
-	$htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes";
176
+    $htaccess_content="order deny,allow\r\nallow from all\r\nOptions -Indexes";
177 177
 
178
-	$fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w');
179
-	if ($fp) {
180
-		fwrite($fp, $htaccess_content);
181
-		fclose($fp);
182
-	}
178
+    $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w');
179
+    if ($fp) {
180
+        fwrite($fp, $htaccess_content);
181
+        fclose($fp);
182
+    }
183 183
 }
184 184
 
185 185
 $html_index=api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html';
186 186
 if (!file_exists($html_index)) {
187
-	$html_index_content="<html><head></head><body></body></html>";
188
-	$fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w');
189
-	if ($fp) {
190
-		fwrite($fp, $html_index_content);
191
-		fclose($fp);
192
-	}
187
+    $html_index_content="<html><head></head><body></body></html>";
188
+    $fp = @ fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w');
189
+    if ($fp) {
190
+        fwrite($fp, $html_index_content);
191
+        fclose($fp);
192
+    }
193 193
 }
194 194
 
195 195
 //encript temp name file
Please login to merge, or discard this patch.
main/document/create_document.php 1 patch
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- *	This file allows creating new html documents with an online WYSIWYG html editor.
5
- *
6
- *	@package chamilo.document
7
- */
4
+     *	This file allows creating new html documents with an online WYSIWYG html editor.
5
+     *
6
+     *	@package chamilo.document
7
+     */
8 8
 
9 9
 require_once '../inc/global.inc.php';
10 10
 
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 $is_certificate_mode = false;
78 78
 
79 79
 if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
80
-	$is_certificate_mode = true;
80
+    $is_certificate_mode = true;
81 81
 }
82 82
 
83 83
 if ($is_certificate_mode) {
84
-	$nameTools = get_lang('CreateCertificate');
84
+    $nameTools = get_lang('CreateCertificate');
85 85
 } else {
86
-	$nameTools = get_lang('CreateDocument');
86
+    $nameTools = get_lang('CreateDocument');
87 87
 }
88 88
 
89 89
 /*	Constants and variables */
@@ -136,26 +136,26 @@  discard block
 block discarded – undo
136 136
 
137 137
 // Please, do not modify this dirname formatting
138 138
 if (strstr($dir, '..')) {
139
-	$dir = '/';
139
+    $dir = '/';
140 140
 }
141 141
 
142 142
 if ($dir[0] == '.') {
143
-	$dir = substr($dir, 1);
143
+    $dir = substr($dir, 1);
144 144
 }
145 145
 
146 146
 if ($dir[0] != '/') {
147
-	$dir = '/'.$dir;
147
+    $dir = '/'.$dir;
148 148
 }
149 149
 
150 150
 if ($dir[strlen($dir) - 1] != '/') {
151
-	$dir .= '/';
151
+    $dir .= '/';
152 152
 }
153 153
 
154 154
 if ($is_certificate_mode) {
155
-	$document_id 	= DocumentManager::get_document_id(api_get_course_info(), '/certificates');
156
-	$document_data 	= DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
157
-	$folder_id = $document_data['id'];
158
-	$dir = '/certificates/';
155
+    $document_id 	= DocumentManager::get_document_id(api_get_course_info(), '/certificates');
156
+    $document_data 	= DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true);
157
+    $folder_id = $document_data['id'];
158
+    $dir = '/certificates/';
159 159
 }
160 160
 
161 161
 $doc_tree  = explode('/', $dir);
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 
167 167
     // Level correction for group documents.
168 168
     if (!empty($group_properties['directory'])) {
169
-    	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
169
+        $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
170 170
     }
171 171
 }
172 172
 $relative_url = '';
173 173
 for ($i = 0; $i < ($count_dir); $i++) {
174
-	$relative_url .= '../';
174
+    $relative_url .= '../';
175 175
 }
176 176
 
177 177
 if ($relative_url== '') {
178
-	$relative_url = '/';
178
+    $relative_url = '/';
179 179
 }
180 180
 
181 181
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
     'cols-size' => [2, 10, 0],
188 188
     'FullPage' => true,
189 189
     'InDocument' => true,
190
-	'CreateDocumentDir'    => $relative_url,
191
-	'CreateDocumentWebDir' => (empty($group_properties['directory']))
192
-                        		? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
193
-                        		: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
194
-	'BaseHref'             => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
190
+    'CreateDocumentDir'    => $relative_url,
191
+    'CreateDocumentWebDir' => (empty($group_properties['directory']))
192
+                                ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
193
+                                : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
194
+    'BaseHref'             => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
195 195
 );
196 196
 
197 197
 if ($is_certificate_mode) {
@@ -203,36 +203,36 @@  discard block
 block discarded – undo
203 203
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
204 204
 
205 205
 if (!is_dir($filepath)) {
206
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
207
-	$dir = '/';
206
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
207
+    $dir = '/';
208 208
 }
209 209
 
210 210
 $to_group_id = 0;
211 211
 
212 212
 if (!$is_certificate_mode) {
213
-	if (api_is_in_group()) {
214
-		$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
215
-		$noPHP_SELF = true;
216
-		$to_group_id = api_get_group_id();
217
-		$path = explode('/', $dir);
218
-		if ('/'.$path[1] != $group_properties['directory']) {
219
-			api_not_allowed(true);
220
-		}
221
-	}
222
-	$interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents'));
213
+    if (api_is_in_group()) {
214
+        $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
215
+        $noPHP_SELF = true;
216
+        $to_group_id = api_get_group_id();
217
+        $path = explode('/', $dir);
218
+        if ('/'.$path[1] != $group_properties['directory']) {
219
+            api_not_allowed(true);
220
+        }
221
+    }
222
+    $interbreadcrumb[] = array("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents'));
223 223
 } else {
224
-	$interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
224
+    $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
225 225
 }
226 226
 
227 227
 if (!$is_allowed_in_course) {
228
-	api_not_allowed(true);
228
+    api_not_allowed(true);
229 229
 }
230 230
 
231 231
 if (!($is_allowed_to_edit ||
232 232
     $_SESSION['group_member_with_upload_rights'] ||
233 233
     DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id()))
234 234
 ) {
235
-	api_not_allowed(true);
235
+    api_not_allowed(true);
236 236
 }
237 237
 
238 238
 /*	Header */
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
 
241 241
 $display_dir = $dir;
242 242
 if (isset($group_properties)) {
243
-	$display_dir = explode('/', $dir);
244
-	unset($display_dir[0]);
245
-	unset($display_dir[1]);
246
-	$display_dir = implode('/', $display_dir);
243
+    $display_dir = explode('/', $dir);
244
+    unset($display_dir[0]);
245
+    unset($display_dir[1]);
246
+    $display_dir = implode('/', $display_dir);
247 247
 }
248 248
 
249 249
 $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 $form->addElement('header', $nameTools);
261 261
 
262 262
 if ($is_certificate_mode) {//added condition for certicate in gradebook
263
-	$form->addElement('hidden','certificate','true',array('id'=>'certificate'));
264
-	if (isset($_GET['selectcat'])) {
265
-		$form->addElement('hidden','selectcat', $select_cat);
263
+    $form->addElement('hidden','certificate','true',array('id'=>'certificate'));
264
+    if (isset($_GET['selectcat'])) {
265
+        $form->addElement('hidden','selectcat', $select_cat);
266 266
     }
267 267
 }
268 268
 
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 if ($is_certificate_mode) {
298 298
     $form->addText('title', get_lang('CertificateName'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
299 299
 } else {
300
-	$form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
300
+    $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
301 301
 }
302 302
 
303 303
 // Show read-only box only in groups
304 304
 if (!empty($groupId)) {
305
-	$group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
305
+    $group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
306 306
 }
307 307
 $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
308 308
 $form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
 // new document created
318 318
 
319 319
 if (!$is_certificate_mode &&
320
-	!DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
320
+    !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
321 321
 ) {
322
-	$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
322
+    $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
323 323
 
324
-	//$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
324
+    //$parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
325 325
         $parent_select = $form->addSelect('curdirpath', get_lang('DestinationDirectory'),null, array('cols-size' => [2, 10, 0]) );
326
-	// Following two conditions copied from document.inc.php::build_directory_selector()
327
-	$folder_titles = array();
326
+    // Following two conditions copied from document.inc.php::build_directory_selector()
327
+    $folder_titles = array();
328 328
 
329 329
     if (is_array($folders)) {
330 330
         $escaped_folders = array();
@@ -362,22 +362,22 @@  discard block
 block discarded – undo
362 362
         }
363 363
     }
364 364
 
365
-	if (empty($group_dir)) {
366
-		$parent_select -> addOption(get_lang('HomeDirectory'), '/');
367
-		if (is_array($folders)) {
368
-			foreach ($folders as & $folder) {
369
-				//Hide some folders
370
-				if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
365
+    if (empty($group_dir)) {
366
+        $parent_select -> addOption(get_lang('HomeDirectory'), '/');
367
+        if (is_array($folders)) {
368
+            foreach ($folders as & $folder) {
369
+                //Hide some folders
370
+                if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') {
371 371
                     continue;
372
-				}
373
-				//Admin setting for Hide/Show the folders of all users
374
-				if (api_get_setting('show_users_folders') == 'false' &&
372
+                }
373
+                //Admin setting for Hide/Show the folders of all users
374
+                if (api_get_setting('show_users_folders') == 'false' &&
375 375
                     (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_'))
376 376
                 ){
377
-					continue;
378
-				}
379
-				//Admin setting for Hide/Show Default folders to all users
380
-				if (api_get_setting('show_default_folders') == 'false' &&
377
+                    continue;
378
+                }
379
+                //Admin setting for Hide/Show Default folders to all users
380
+                if (api_get_setting('show_default_folders') == 'false' &&
381 381
                     (
382 382
                         $folder == '/images' ||
383 383
                         $folder == '/flash' ||
@@ -387,80 +387,80 @@  discard block
 block discarded – undo
387 387
                         $folder == '/video/flv'
388 388
                     )
389 389
                 ){
390
-					continue;
391
-				}
392
-				//Admin setting for Hide/Show chat history folder
393
-				if (api_get_setting('show_chat_folder') == 'false' &&
390
+                    continue;
391
+                }
392
+                //Admin setting for Hide/Show chat history folder
393
+                if (api_get_setting('show_chat_folder') == 'false' &&
394 394
                     $folder=='/chat_files'
395 395
                 ){
396
-					continue;
397
-				}
396
+                    continue;
397
+                }
398 398
 
399
-				$selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
400
-				$path_parts = explode('/', $folder);
401
-				$folder_titles[$folder] = cut($folder_titles[$folder], 80);
399
+                $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : '';
400
+                $path_parts = explode('/', $folder);
401
+                $folder_titles[$folder] = cut($folder_titles[$folder], 80);
402 402
                 $space_counter =count($path_parts) - 2;
403 403
                 if ($space_counter > 0) {
404 404
                     $label = str_repeat('&nbsp;&nbsp;&nbsp;', $space_counter).' &mdash; '.$folder_titles[$folder];
405 405
                 } else {
406 406
                     $label = ' &mdash; '.$folder_titles[$folder];
407 407
                 }
408
-				$parent_select -> addOption($label, $folder);
409
-				if ($selected != '') {
410
-					$parent_select->setSelected($folder);
411
-				}
412
-			}
413
-		}
414
-	} else {
415
-		foreach ($folders as & $folder) {
416
-			$selected = (substr($dir,0,-1)==$folder) ? ' selected="selected"' : '';
417
-			$label = $folder_titles[$folder];
418
-			if ($folder == $group_dir) {
419
-				$label = '/ ('.get_lang('HomeDirectory').')';
420
-			} else {
421
-				$path_parts = explode('/', str_replace($group_dir, '', $folder));
422
-				$label = cut($label, 80);
423
-				$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
424
-			}
425
-			$parent_select -> addOption($label, $folder);
426
-			if ($selected != '') {
427
-				$parent_select->setSelected($folder);
428
-			}
429
-		}
430
-	}
408
+                $parent_select -> addOption($label, $folder);
409
+                if ($selected != '') {
410
+                    $parent_select->setSelected($folder);
411
+                }
412
+            }
413
+        }
414
+    } else {
415
+        foreach ($folders as & $folder) {
416
+            $selected = (substr($dir,0,-1)==$folder) ? ' selected="selected"' : '';
417
+            $label = $folder_titles[$folder];
418
+            if ($folder == $group_dir) {
419
+                $label = '/ ('.get_lang('HomeDirectory').')';
420
+            } else {
421
+                $path_parts = explode('/', str_replace($group_dir, '', $folder));
422
+                $label = cut($label, 80);
423
+                $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
424
+            }
425
+            $parent_select -> addOption($label, $folder);
426
+            if ($selected != '') {
427
+                $parent_select->setSelected($folder);
428
+            }
429
+        }
430
+    }
431 431
 }
432 432
 
433 433
 $form->addHidden('dirValue', '');
434 434
 
435 435
 if ($is_certificate_mode) {
436
-	$form->addButtonCreate(get_lang('CreateCertificate'));
436
+    $form->addButtonCreate(get_lang('CreateCertificate'));
437 437
 } else {
438
-	$form->addButtonCreate(get_lang('CreateDoc'));
438
+    $form->addButtonCreate(get_lang('CreateDoc'));
439 439
 }
440 440
 
441 441
 $form->setDefaults($defaults);
442 442
 
443 443
 // If form validates -> save the new document
444 444
 if ($form->validate()) {
445
-	$values = $form->exportValues();
446
-	$readonly = isset($values['readonly']) ? 1 : 0;
447
-	$values['title'] = trim($values['title']);
445
+    $values = $form->exportValues();
446
+    $readonly = isset($values['readonly']) ? 1 : 0;
447
+    $values['title'] = trim($values['title']);
448 448
     
449 449
     if (!empty($values['dirValue'])) {
450 450
         $dir = $values['dirValue'];
451 451
     }
452 452
 
453 453
     if ($dir[strlen($dir) - 1] != '/') {
454
-		$dir .= '/';
455
-	}
454
+        $dir .= '/';
455
+    }
456 456
     $filepath = $filepath.$dir;
457 457
 
458 458
     // Setting the filename
459
-	$filename = $values['title'];
460
-	$filename = addslashes(trim($filename));
461
-	$filename = Security::remove_XSS($filename);
462
-	$filename = api_replace_dangerous_char($filename);
463
-	$filename = disable_dangerous_file($filename);
459
+    $filename = $values['title'];
460
+    $filename = addslashes(trim($filename));
461
+    $filename = Security::remove_XSS($filename);
462
+    $filename = api_replace_dangerous_char($filename);
463
+    $filename = disable_dangerous_file($filename);
464 464
     $filename .= DocumentManager::getDocumentSuffix(
465 465
         $_course,
466 466
         api_get_session_id(),
@@ -468,14 +468,14 @@  discard block
 block discarded – undo
468 468
     );
469 469
 
470 470
     // Setting the title
471
-	$title = $values['title'];
471
+    $title = $values['title'];
472 472
 
473 473
     // Setting the extension
474
-	$extension = 'html';
474
+    $extension = 'html';
475 475
 
476
-	$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
476
+    $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
477 477
 
478
-	/*if (strpos($content, '/css/frames.css') == false) {
478
+    /*if (strpos($content, '/css/frames.css') == false) {
479 479
 		$content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
480 480
 	}*/
481 481
 
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
         exit;
489 489
     }
490 490
 
491
-	if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
492
-		$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
491
+    if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
492
+        $content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/', $content);
493 493
 
494
-		fputs($fp, $content);
495
-		fclose($fp);
496
-		chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
494
+        fputs($fp, $content);
495
+        fclose($fp);
496
+        chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
497 497
 
498 498
         /*
499 499
 		if (!is_dir($filepath.'css')) {
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 			api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, null, null, null, null, $current_session_id);
512 512
 		}*/
513 513
 
514
-		$file_size = filesize($filepath.$filename.'.'.$extension);
515
-		$save_file_path = $dir.$filename.'.'.$extension;
514
+        $file_size = filesize($filepath.$filename.'.'.$extension);
515
+        $save_file_path = $dir.$filename.'.'.$extension;
516 516
 
517 517
         $document_id = add_document(
518 518
             $_course,
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
             $readonly
525 525
         );
526 526
 
527
-		if ($document_id) {
528
-			api_item_property_update(
527
+        if ($document_id) {
528
+            api_item_property_update(
529 529
                 $_course,
530 530
                 TOOL_DOCUMENT,
531 531
                 $document_id,
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
                 null,
538 538
                 $current_session_id
539 539
             );
540
-			// Update parent folders
541
-			item_property_update_on_folder($_course, $dir, $userId);
542
-			$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
543
-			$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
540
+            // Update parent folders
541
+            item_property_update_on_folder($_course, $dir, $userId);
542
+            $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
543
+            $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
544 544
             $new_title = htmlspecialchars($new_title);
545
-			if ($new_comment || $new_title) {
546
-				$ct = '';
545
+            if ($new_comment || $new_title) {
546
+                $ct = '';
547 547
                 $params = [];
548 548
                 if ($new_comment) {
549 549
                     $params['comment'] = $new_comment;
@@ -558,38 +558,38 @@  discard block
 block discarded – undo
558 558
                         ['c_id = ? AND id = ?' => [$course_id, $document_id]]
559 559
                     );
560 560
                 }
561
-			}
562
-			$dir= substr($dir,0,-1);
563
-			$selectcat = '';
564
-			if (isset($_REQUEST['selectcat']))
565
-				$selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']);
566
-			$certificate_condition = '';
567
-			if ($is_certificate_mode) {
568
-				$df = DocumentManager::get_default_certificate_id($_course['code']);
561
+            }
562
+            $dir= substr($dir,0,-1);
563
+            $selectcat = '';
564
+            if (isset($_REQUEST['selectcat']))
565
+                $selectcat = "&selectcat=".Security::remove_XSS($_REQUEST['selectcat']);
566
+            $certificate_condition = '';
567
+            if ($is_certificate_mode) {
568
+                $df = DocumentManager::get_default_certificate_id($_course['code']);
569 569
                 if (!isset($df)) {
570 570
                     DocumentManager::attach_gradebook_certificate ($_course['code'],$document_id);
571
-				}
572
-				$certificate_condition = '&certificate=true&curdirpath=/certificates';
573
-			}
574
-
575
-			header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
576
-			exit();
577
-		} else {
578
-			Display :: display_header($nameTools, 'Doc');
579
-			Display :: display_error_message(get_lang('Impossible'));
580
-			Display :: display_footer();
581
-		}
582
-	} else {
583
-		Display :: display_header($nameTools, 'Doc');
584
-		Display :: display_error_message(get_lang('Impossible'));
585
-		Display :: display_footer();
586
-	}
571
+                }
572
+                $certificate_condition = '&certificate=true&curdirpath=/certificates';
573
+            }
574
+
575
+            header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
576
+            exit();
577
+        } else {
578
+            Display :: display_header($nameTools, 'Doc');
579
+            Display :: display_error_message(get_lang('Impossible'));
580
+            Display :: display_footer();
581
+        }
582
+    } else {
583
+        Display :: display_header($nameTools, 'Doc');
584
+        Display :: display_error_message(get_lang('Impossible'));
585
+        Display :: display_footer();
586
+    }
587 587
 } else {
588
-	// Copied from document.php
589
-	$dir_array = explode('/', $dir);
590
-	$array_len = count($dir_array);
588
+    // Copied from document.php
589
+    $dir_array = explode('/', $dir);
590
+    $array_len = count($dir_array);
591 591
 
592
-	// Breadcrumb for the current directory root path
592
+    // Breadcrumb for the current directory root path
593 593
     if (!empty($document_data)) {
594 594
         if (empty($document_data['parents'])) {
595 595
             $interbreadcrumb[] = array(
@@ -606,31 +606,31 @@  discard block
 block discarded – undo
606 606
         }
607 607
     }
608 608
 
609
-	Display :: display_header($nameTools, "Doc");
610
-	// actions
609
+    Display :: display_header($nameTools, "Doc");
610
+    // actions
611 611
 
612
-	// link back to the documents overview
613
-	if ($is_certificate_mode) {
614
-		$actionsLeft =  '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.
612
+    // link back to the documents overview
613
+    if ($is_certificate_mode) {
614
+        $actionsLeft =  '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'.
615 615
             Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
616 616
         } else {
617
-		$actionsLeft = '<a href="document.php?curdirpath='.Security::remove_XSS($dir).'">'.
617
+        $actionsLeft = '<a href="document.php?curdirpath='.Security::remove_XSS($dir).'">'.
618 618
             Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
619 619
         }
620 620
         
621 621
         echo $toolbar = Display::toolbarAction('actions-documents', array(0 => $actionsLeft, 1 => ''));
622 622
                 
623 623
 
624
-	if ($is_certificate_mode) {
625
-		$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
624
+    if ($is_certificate_mode) {
625
+        $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
626 626
 
627
-		$str_info = '';
628
-		foreach ($all_information_by_create_certificate[0] as $info_value) {
629
-			$str_info.=$info_value.'<br/>';
630
-		}
631
-		$create_certificate = get_lang('CreateCertificateWithTags');
632
-		Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
633
-	}
627
+        $str_info = '';
628
+        foreach ($all_information_by_create_certificate[0] as $info_value) {
629
+            $str_info.=$info_value.'<br/>';
630
+        }
631
+        $create_certificate = get_lang('CreateCertificateWithTags');
632
+        Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false);
633
+    }
634 634
     // HTML-editor
635 635
     echo '<div class="row" style="overflow:hidden">
636 636
             <div id="template_col" class="col-md-2">
@@ -647,5 +647,5 @@  discard block
 block discarded – undo
647 647
                 '.$form->returnForm().'
648 648
             </div>
649 649
           </div>';
650
-	Display :: display_footer();
650
+    Display :: display_footer();
651 651
 }
Please login to merge, or discard this patch.
main/document/slideshowoptions.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     if ($image_resizing == 'noresizing' || $image_resizing == '') {
78 78
                             echo ' checked';
79 79
                     }
80
-		?>>
80
+        ?>>
81 81
             </label>
82 82
             <?php echo '<b>'. get_lang('NoResizing') . '</b>, ' . get_lang('NoResizingComment') ;?>
83 83
         </div>
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                         if ($image_resizing == 'resizing_auto' || $image_resizing == '') {
88 88
                                 echo ' checked';
89 89
                         }
90
-		?>>
90
+        ?>>
91 91
             </label>
92 92
             <?php echo '<b>'. get_lang('ResizingAuto') . '</b>, ' . get_lang('ResizingAutoComment');?>
93 93
 	</div>
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                             $width = $_SESSION['image_resizing_width'];
100 100
                             $height = $_SESSION['image_resizing_height'];
101 101
                     }
102
-		?>>
102
+        ?>>
103 103
             </label>
104 104
             <?php echo '<b>'. get_lang('Resizing') . '</b>, ' . get_lang('ResizingComment'); ?>
105 105
 	</div>
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
             <label class="col-sm-1 control-label"><?php echo get_lang('Width'); ?></label>
108 108
             <div class="col-sm-3">
109 109
                 <input class="form-control" name="width" type="text" id="width" <?php
110
-		if ($image_resizing == 'resizing') {
111
-			echo ' value="'.$width.'"';
112
-			echo ' class="enabled_input"';
110
+        if ($image_resizing == 'resizing') {
111
+            echo ' value="'.$width.'"';
112
+            echo ' class="enabled_input"';
113 113
                     } else {
114 114
                     echo ' class="disabled_input"';
115 115
                 }
116
-		?> >
116
+        ?> >
117 117
             </div>
118 118
             <div class="col-sm-8"></div>
119 119
         </div>
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
             <label class="col-sm-1 control-label"><?php echo get_lang('Height'); ?></label>
122 122
             <div class="col-sm-3">
123 123
                 <input class="form-control" name="height" type="text" id="height" <?php
124
-		if ($image_resizing == 'resizing') {
125
-			echo ' value="'.$height.'"';
126
-			echo ' class="enabled_input"';
127
-		} else {
124
+        if ($image_resizing == 'resizing') {
125
+            echo ' value="'.$height.'"';
126
+            echo ' class="enabled_input"';
127
+        } else {
128 128
                         echo ' class="disabled_input"';
129 129
                 }
130
-		?> >
130
+        ?> >
131 131
             </div>
132 132
             <div class="col-sm-8"></div>
133 133
         </div>
Please login to merge, or discard this patch.
main/document/record_audio.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 $document_data  = array();
24 24
 
25 25
 if (isset($_GET['id'])) {
26
-	$document_data = DocumentManager::get_document_data_by_id(
27
-		$_GET['id'],
28
-		api_get_course_id(),
29
-		true
30
-	);
26
+    $document_data = DocumentManager::get_document_data_by_id(
27
+        $_GET['id'],
28
+        api_get_course_id(),
29
+        true
30
+    );
31 31
 }
32 32
 
33 33
 if (empty($document_data)) {
@@ -46,46 +46,46 @@  discard block
 block discarded – undo
46 46
 // Please, do not modify this dirname formatting
47 47
 
48 48
 if (strstr($dir, '..')) {
49
-	$dir = '/';
49
+    $dir = '/';
50 50
 }
51 51
 
52 52
 if ($dir[0] == '.') {
53
-	$dir = substr($dir, 1);
53
+    $dir = substr($dir, 1);
54 54
 }
55 55
 
56 56
 if ($dir[0] != '/') {
57
-	$dir = '/'.$dir;
57
+    $dir = '/'.$dir;
58 58
 }
59 59
 
60 60
 if ($dir[strlen($dir) - 1] != '/') {
61
-	$dir .= '/';
61
+    $dir .= '/';
62 62
 }
63 63
 
64 64
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
65 65
 
66 66
 if (!is_dir($filepath)) {
67
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
68
-	$dir = '/';
67
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
68
+    $dir = '/';
69 69
 }
70 70
 
71 71
 if (!empty($groupId)) {
72
-	$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
73
-	$group = GroupManager :: get_group_properties($groupId);
74
-	$path = explode('/', $dir);
75
-	if ('/'.$path[1] != $group['directory']) {
76
-		api_not_allowed(true);
77
-	}
72
+    $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
73
+    $group = GroupManager :: get_group_properties($groupId);
74
+    $path = explode('/', $dir);
75
+    if ('/'.$path[1] != $group['directory']) {
76
+        api_not_allowed(true);
77
+    }
78 78
 }
79 79
 
80 80
 $interbreadcrumb[] = array("url" => "./document.php?id=".$document_id.'&'.api_get_cidreq(), "name" => get_lang('Documents'));
81 81
 
82 82
 if (!$is_allowed_in_course) {
83
-	api_not_allowed(true);
83
+    api_not_allowed(true);
84 84
 }
85 85
 
86 86
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
87
-	DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
88
-	api_not_allowed(true);
87
+    DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
88
+    api_not_allowed(true);
89 89
 }
90 90
 
91 91
 /*	Header */
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 
94 94
 $display_dir = $dir;
95 95
 if (isset ($group)) {
96
-	$display_dir = explode('/', $dir);
97
-	unset ($display_dir[0]);
98
-	unset ($display_dir[1]);
99
-	$display_dir = implode('/', $display_dir);
96
+    $display_dir = explode('/', $dir);
97
+    unset ($display_dir[0]);
98
+    unset ($display_dir[1]);
99
+    $display_dir = implode('/', $display_dir);
100 100
 }
101 101
 
102 102
 // Interbreadcrumb for the current directory root path
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 Display :: display_header($nameTools, 'Doc');
118 118
 
119 119
 echo '<div class="actions">';
120
-		echo '<a href="document.php?'.api_get_cidreq().'&id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
120
+        echo '<a href="document.php?'.api_get_cidreq().'&id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
121 121
 echo '</div>';
122 122
 
123 123
 ?>
@@ -178,24 +178,24 @@  discard block
 block discarded – undo
178 178
 Display::display_icon('microphone.png', get_lang('PressRecordButton'),'','128');
179 179
 echo '<br/>';
180 180
 echo '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">';
181
-	//echo '<param name="ShowRecordButton" value="false" />'; // default true
182
-	// echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true)
183
-	//echo '<param name="ShowSpeedButton" value="false" />'; // default true
184
-	//echo '<param name="ShowAudioLevel" value="false" />'; //  it displays the audiometer | (default true)
185
-	echo '<param name="ShowTime" value="true" />'; // default false
186
-	//echo '<param name="Color" value="#C0E0FF" />'; // default #FFFFFF
187
-	//echo '<param name="StartTime" value="10.5" />';
188
-	//echo '<param name="EndTime" value="65" />';
189
-	echo '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex)
190
-	//echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100)
191
-	//echo '<param name="MaxDuration" value="60" />';
192
-	//echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "")
181
+    //echo '<param name="ShowRecordButton" value="false" />'; // default true
182
+    // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true)
183
+    //echo '<param name="ShowSpeedButton" value="false" />'; // default true
184
+    //echo '<param name="ShowAudioLevel" value="false" />'; //  it displays the audiometer | (default true)
185
+    echo '<param name="ShowTime" value="true" />'; // default false
186
+    //echo '<param name="Color" value="#C0E0FF" />'; // default #FFFFFF
187
+    //echo '<param name="StartTime" value="10.5" />';
188
+    //echo '<param name="EndTime" value="65" />';
189
+    echo '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex)
190
+    //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100)
191
+    //echo '<param name="MaxDuration" value="60" />';
192
+    //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "")
193 193
 echo '</applet>';
194 194
 
195 195
 echo '<form name="form_nanogong">';
196
-	echo '<input placeholder="'.get_lang('InputNameHere').'" type="text" id="audio_title">';
197
-	echo '<input id="status" type="hidden" name="status" value="0">';
198
-	echo '<button class="upload" type="submit" value="'.get_lang('Send').'" onClick="submitVoice()" />'.get_lang('Send').'</button>';
196
+    echo '<input placeholder="'.get_lang('InputNameHere').'" type="text" id="audio_title">';
197
+    echo '<input id="status" type="hidden" name="status" value="0">';
198
+    echo '<button class="upload" type="submit" value="'.get_lang('Send').'" onClick="submitVoice()" />'.get_lang('Send').'</button>';
199 199
 echo '</form>';
200 200
 
201 201
 echo '</div>';
Please login to merge, or discard this patch.
main/document/exit_pixlr.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@
 block discarded – undo
24 24
 unset($_SESSION['temp_realpath_image']);
25 25
 
26 26
 if (!isset($_SESSION['exit_pixlr'])){
27
-	$location=api_get_path(WEB_CODE_PATH).'document/document.php';
28
-	echo '<script>window.parent.location.href="'.$location.'"</script>';
29
-	api_not_allowed(true);
27
+    $location=api_get_path(WEB_CODE_PATH).'document/document.php';
28
+    echo '<script>window.parent.location.href="'.$location.'"</script>';
29
+    api_not_allowed(true);
30 30
 } else {
31
-	echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>';
32
-	$location=api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']);
33
-	echo '<script>window.parent.location.href="'.$location.'"</script>';
34
-	unset($_SESSION['exit_pixlr']);
31
+    echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>';
32
+    $location=api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($_SESSION['exit_pixlr']);
33
+    echo '<script>window.parent.location.href="'.$location.'"</script>';
34
+    unset($_SESSION['exit_pixlr']);
35 35
 }
Please login to merge, or discard this patch.
main/document/remote.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /* See license terms in /license.txt */
3 3
 /**
4
- * Script that allows download of a specific file from external applications
5
- * @author Arnaud Ligot <[email protected]>, Based on work done for old videoconference application (I have about 30 minutes to write this peace of code so if somebody has more time, feel free to rewrite it...)
6
- * @package chamilo.document
7
- */
4
+     * Script that allows download of a specific file from external applications
5
+     * @author Arnaud Ligot <[email protected]>, Based on work done for old videoconference application (I have about 30 minutes to write this peace of code so if somebody has more time, feel free to rewrite it...)
6
+     * @package chamilo.document
7
+     */
8 8
 /**
9
- * Script that allows remote download of a file
10
- * @param string Action parameter (action=...)
11
- * @param string Course code (cidReq=...)
12
- * @param string Current working directory (cwd=...)
13
- * @return string JSON output
14
- */
9
+     * Script that allows remote download of a file
10
+     * @param string Action parameter (action=...)
11
+     * @param string Course code (cidReq=...)
12
+     * @param string Current working directory (cwd=...)
13
+     * @return string JSON output
14
+     */
15 15
 /* FIX for IE cache when using https */
16 16
 session_cache_limiter('none');
17 17
 /*==== DEBUG ====*/
Please login to merge, or discard this patch.
main/document/slideshow.inc.php 1 patch
Indentation   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,8 +15,6 @@  discard block
 block discarded – undo
15 15
 	This file has two large sections.
16 16
 	1. code that belongs in document.php, but to avoid clutter I put the code here
17 17
 	2. the function resize_image that handles the image resizing
18
-
19
-
20 18
  *	@author Patrick Cool
21 19
  *	@package chamilo.document
22 20
  *	@todo convert comments to be understandable to phpDocumentor
@@ -34,16 +32,16 @@  discard block
 block discarded – undo
34 32
  *							view is also possible when you choose not to resize the source images
35 33
  */
36 34
 function resize_image($image, $target_width, $target_height, $slideshow = 0) {
37
-	// Modifications by Ivan Tcholakov, 04-MAY-2009.
38
-	$result = array();
39
-	if ( (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing']== 'resizing') or $slideshow == 1) {
40
-		$new_sizes = api_resize_image($image, $target_width, $target_height);
41
-		$result[] = $new_sizes['height'];
42
-		$result[] = $new_sizes['width'];
43
-	} else {		
35
+    // Modifications by Ivan Tcholakov, 04-MAY-2009.
36
+    $result = array();
37
+    if ( (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing']== 'resizing') or $slideshow == 1) {
38
+        $new_sizes = api_resize_image($image, $target_width, $target_height);
39
+        $result[] = $new_sizes['height'];
40
+        $result[] = $new_sizes['width'];
41
+    } else {		
44 42
         $size = api_getimagesize($image);
45
-		$result[] = $size['height'];
46
-		$result[] = $size['width'];
47
-	}
48
-	return $result;
43
+        $result[] = $size['height'];
44
+        $result[] = $size['width'];
45
+    }
46
+    return $result;
49 47
 }
Please login to merge, or discard this patch.
main/document/create_paint.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 api_protect_course_script();
21 21
 api_block_anonymous_users();
22 22
 if (api_get_setting('enabled_support_paint') == 'false') {
23
-	api_not_allowed(true);
23
+    api_not_allowed(true);
24 24
 }
25 25
 
26 26
 $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
@@ -41,75 +41,75 @@  discard block
 block discarded – undo
41 41
 //path for pixlr save
42 42
 $_SESSION['paint_dir']=Security::remove_XSS($dir);
43 43
 if ($_SESSION['paint_dir']=='/'){
44
-	$_SESSION['paint_dir']='';
44
+    $_SESSION['paint_dir']='';
45 45
 }
46 46
 $_SESSION['paint_file']=get_lang('NewImage');
47 47
 
48 48
 // Please, do not modify this dirname formatting
49 49
 
50 50
 if (strstr($dir, '..')) {
51
-	$dir = '/';
51
+    $dir = '/';
52 52
 }
53 53
 
54 54
 if ($dir[0] == '.') {
55
-	$dir = substr($dir, 1);
55
+    $dir = substr($dir, 1);
56 56
 }
57 57
 
58 58
 if ($dir[0] != '/') {
59
-	$dir = '/'.$dir;
59
+    $dir = '/'.$dir;
60 60
 }
61 61
 
62 62
 if ($dir[strlen($dir) - 1] != '/') {
63
-	$dir .= '/';
63
+    $dir .= '/';
64 64
 }
65 65
 
66 66
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
67 67
 
68 68
 if (!is_dir($filepath)) {
69
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
70
-	$dir = '/';
69
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
70
+    $dir = '/';
71 71
 }
72 72
 
73 73
 $groupId = api_get_group_id();
74 74
 
75 75
 if (!empty($groupId)) {
76
-	$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
77
-	$noPHP_SELF = true;
78
-	$group = GroupManager::get_group_properties($groupId);
79
-	$path = explode('/', $dir);
80
-	if ('/'.$path[1] != $group['directory']) {
81
-		api_not_allowed(true);
82
-	}
76
+    $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
77
+    $noPHP_SELF = true;
78
+    $group = GroupManager::get_group_properties($groupId);
79
+    $path = explode('/', $dir);
80
+    if ('/'.$path[1] != $group['directory']) {
81
+        api_not_allowed(true);
82
+    }
83 83
 }
84 84
 
85 85
 $interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), "name" => get_lang('Documents'));
86 86
 
87 87
 if (!$is_allowed_in_course) {
88
-	api_not_allowed(true);
88
+    api_not_allowed(true);
89 89
 }
90 90
 
91 91
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
92
-	DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir),api_get_session_id()))) {
93
-	api_not_allowed(true);
92
+    DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir),api_get_session_id()))) {
93
+    api_not_allowed(true);
94 94
 }
95 95
 
96 96
 /*	Header */
97 97
 Event::event_access_tool(TOOL_DOCUMENT);
98 98
 $display_dir = $dir;
99 99
 if (isset ($group)) {
100
-	$display_dir = explode('/', $dir);
101
-	unset ($display_dir[0]);
102
-	unset ($display_dir[1]);
103
-	$display_dir = implode('/', $display_dir);
100
+    $display_dir = explode('/', $dir);
101
+    unset ($display_dir[0]);
102
+    unset ($display_dir[1]);
103
+    $display_dir = implode('/', $display_dir);
104 104
 }
105 105
 
106 106
 // Interbreadcrumb for the current directory root path
107 107
 if (empty($document_data['parents'])) {
108
-	$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
108
+    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
109 109
 } else {
110
-	foreach($document_data['parents'] as $document_sub_data) {
111
-		$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
112
-	}
110
+    foreach($document_data['parents'] as $document_sub_data) {
111
+        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
112
+    }
113 113
 }
114 114
 Display :: display_header($nameTools, 'Doc');
115 115
 
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
 $locktitle="false";
139 139
 
140 140
 if ($_SERVER['HTTP_HOST']=="localhost") {
141
-	$path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
142
-	if (!file_exists($path_and_file)) {
143
-		$crossdomain='<?xml version="1.0"?>
141
+    $path_and_file= api_get_path(SYS_SERVER_ROOT_PATH).'/crossdomain.xml';
142
+    if (!file_exists($path_and_file)) {
143
+        $crossdomain='<?xml version="1.0"?>
144 144
 			<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
145 145
 			<cross-domain-policy>
146 146
 				<allow-access-from domain="cdn.pixlr.com" />
147 147
 				<site-control permitted-cross-domain-policies="master-only"/>
148 148
 				<allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/>
149 149
 			</cross-domain-policy>';//more open domain="*"
150
-		@file_put_contents($path_and_file, $crossdomain);
151
-	}
152
-	$credentials="true";
150
+        @file_put_contents($path_and_file, $crossdomain);
151
+    }
152
+    $credentials="true";
153 153
 } else {
154
-	$credentials="false";
154
+    $credentials="false";
155 155
 }
156 156
 $pixlr_url = api_get_protocol().'://pixlr.com/editor/?title='.$title.'&image='.$image.'&loc='.$loc.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
157 157
 ?>
Please login to merge, or discard this patch.
main/resourcelinker/resourcelinker.inc.php 1 patch
Indentation   +1396 added lines, -1396 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 */
25 25
 
26 26
 function unset_session_resources() {
27
-	$_SESSION['addedresource']='';
28
-	$_SESSION['addedresourceid']='';
29
-	Session::erase('addedresource');
30
-	Session::erase('addedresourceid');
27
+    $_SESSION['addedresource']='';
28
+    $_SESSION['addedresourceid']='';
29
+    Session::erase('addedresource');
30
+    Session::erase('addedresourceid');
31 31
 }
32 32
 
33 33
 /**
@@ -35,24 +35,24 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function show_folder_up()
37 37
 {
38
-	global $folder;
39
-	global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
40
-
41
-	$level = get_levels($folder);
42
-
43
-	if ($level == 1)
44
-	{
45
-		echo "<a href='".api_get_self()."?content=Document&amp;source_forum=".$_GET['source_forum']."&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>";
46
-	}
47
-	if ($level and $level != 0 and $level != 1)
48
-	{
49
-		$folder_up=$folder;
50
-		$folder_temp=explode('/',$folder);
51
-		$last=count($folder_temp)-1;
52
-		unset($folder_temp[$last]);
53
-		$folder_up=implode('/',$folder_temp);
54
-		echo "<a href='".api_get_self()."?content=Document&amp;source_forum=".$_GET['source_forum']."&amp;folder=$folder_up&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>";
55
-	}
38
+    global $folder;
39
+    global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
40
+
41
+    $level = get_levels($folder);
42
+
43
+    if ($level == 1)
44
+    {
45
+        echo "<a href='".api_get_self()."?content=Document&amp;source_forum=".$_GET['source_forum']."&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>";
46
+    }
47
+    if ($level and $level != 0 and $level != 1)
48
+    {
49
+        $folder_up=$folder;
50
+        $folder_temp=explode('/',$folder);
51
+        $last=count($folder_temp)-1;
52
+        unset($folder_temp[$last]);
53
+        $folder_up=implode('/',$folder_temp);
54
+        echo "<a href='".api_get_self()."?content=Document&amp;source_forum=".$_GET['source_forum']."&amp;folder=$folder_up&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang('LevelUp')."</a>";
55
+    }
56 56
 }
57 57
 
58 58
 /**
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
  */
62 62
 function show_documents($folder)
63 63
 {
64
-	global $_course;
65
-	global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
66
-
67
-	// documents are a special case: the teacher can add an invisible document (it will be viewable by the user)
68
-	// other tools do not have this feature. This only counts
69
-	if (api_is_allowed_to_edit())
70
-	{
71
-		$visibility="ip.visibility<>'2'";
72
-	}
73
-	else
74
-	{
75
-		$visibility="ip.visibility='1'";
76
-	}
77
-
78
-	$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
79
-	$document_table = Database::get_course_table(TABLE_DOCUMENT);
80
-	$sql = "SELECT * from $document_table docs, $item_property_table ip
64
+    global $_course;
65
+    global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
66
+
67
+    // documents are a special case: the teacher can add an invisible document (it will be viewable by the user)
68
+    // other tools do not have this feature. This only counts
69
+    if (api_is_allowed_to_edit())
70
+    {
71
+        $visibility="ip.visibility<>'2'";
72
+    }
73
+    else
74
+    {
75
+        $visibility="ip.visibility='1'";
76
+    }
77
+
78
+    $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
79
+    $document_table = Database::get_course_table(TABLE_DOCUMENT);
80
+    $sql = "SELECT * from $document_table docs, $item_property_table ip
81 81
 			WHERE
82 82
 			    docs.id=ip.ref AND
83 83
 			    ip.tool = '".TOOL_DOCUMENT."' AND
@@ -85,104 +85,104 @@  discard block
 block discarded – undo
85 85
 			    (ip.to_group_id = 0 OR i.to_group_id IS NULL) AND
86 86
 			    ip.to_user_id IS NULL
87 87
 			ORDER BY docs.path ASC";
88
-	$result=Database::query($sql);
89
-	while ($row=Database::fetch_array($result))
90
-	{
91
-		if (!$folder)
92
-		{
93
-			if (get_levels($row['path'])-1==1)
94
-			{
95
-				// showing the right icon
96
-				if (file_or_folder($row['path']))
97
-				{
98
-						echo '<img src="../img/file.gif" align="middle" />';
99
-				}
100
-				else
101
-				{
102
-					$image = choose_image($row['path']);
103
-					echo "<img src=\"../img/$image\" align=\"middle\" />";
104
-				}
105
-
106
-				// folders should be clickable
107
-				if (file_or_folder($row['path']))
108
-				{
109
-					echo "<a href='".api_get_self()."?content=Document";
110
-					echo "&amp;folder=".substr($row['path'],1)."&amp;source_id=$source_id&amp;source_forum=".$_GET['source_forum']."&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'>".substr($row['path'],1).'</a><br />';
111
-				}
112
-				else
113
-				{
114
-					echo substr($row['path'],1).' ';
115
-					echo showorhide_addresourcelink('Document',$row['id']);
116
-					echo '<br />';
117
-				}
118
-			}
119
-		}
120
-		else
121
-		{
122
-			// we calculate the level we are in by using the $folder in the url
123
-			// we put +1 because it does not start with an / and in the database it does
124
-			$level=get_levels($folder)+1;
125
-
126
-			// we calculate each level of the database entry
127
-			$file_level=get_levels($row['path'])-1;
128
-			// if the level of the database entry is equal to the level we ar in, we put it into an array
129
-			// as this is a potential good entry
130
-			if ($file_level==$level)
131
-			{
132
-				$good_paths[]=$row['path'];
133
-				$good_ids[]=$row['id'];
134
-			}
135
-			//$haystack=$row['path'];
136
-			//$conform_folder=strstr($haystack, $folder);
137
-			//if (str_replace($folder.'/','',$conform_folder)!==$folder)
138
-			//	{
139
-			//	$good_folders[]=$row['path'];
140
-				//echo str_replace($folder.'/','',$conform_folder);
141
-			//	echo '<br />';
142
-			//	}// if (str_replace($folder.'/','',$conform_folder)!==$folder)
143
-		} // else (if (!$folder))
144
-	} //while ($row=Database::fetch_array($result))
145
-
146
-	// this is code for the case that we are in a subfolder
147
-	if ($good_paths)
148
-	{
149
-		// we have all the potential good database entries, the good ones are those that start with $folder
150
-		foreach ($good_paths as $path)
151
-		{
152
-			if (strstr($path,$folder))
153
-			{
154
-				$good_key=key($good_paths);
155
-				// showing the right icon
156
-				if (file_or_folder($path))
157
-				{
158
-					echo '<img src="../img/file.gif" align="middle" />';
159
-				}
160
-				else
161
-				{
162
-					$image = choose_image($path);
163
-					echo "<img src=\"../img/$image\" align=\"middle\" />";
164
-				}
165
-
166
-				// folders should be clickable
167
-				if (file_or_folder($path))
168
-				{
169
-					$path=substr($path,1); // remove the first / in folder_up
170
-					$uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']);
171
-					$newuri=str_replace('add=','addnot=',$uri);
172
-					//using the correct name of the folder
173
-					$folder_name=str_replace($folder.'/','',$path);
174
-					echo "<a href='$newuri'>".$folder_name.'</a><br />';
175
-				}
176
-				else
177
-				{
178
-					echo str_replace("/$folder/", '',$path).' ';
179
-					echo showorhide_addresourcelink('Document',$good_ids[$good_key]);
180
-					echo '<br />';
181
-				}
182
-			}
183
-			next($good_paths);
184
-		}
185
-	}
88
+    $result=Database::query($sql);
89
+    while ($row=Database::fetch_array($result))
90
+    {
91
+        if (!$folder)
92
+        {
93
+            if (get_levels($row['path'])-1==1)
94
+            {
95
+                // showing the right icon
96
+                if (file_or_folder($row['path']))
97
+                {
98
+                        echo '<img src="../img/file.gif" align="middle" />';
99
+                }
100
+                else
101
+                {
102
+                    $image = choose_image($row['path']);
103
+                    echo "<img src=\"../img/$image\" align=\"middle\" />";
104
+                }
105
+
106
+                // folders should be clickable
107
+                if (file_or_folder($row['path']))
108
+                {
109
+                    echo "<a href='".api_get_self()."?content=Document";
110
+                    echo "&amp;folder=".substr($row['path'],1)."&amp;source_id=$source_id&amp;source_forum=".$_GET['source_forum']."&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'>".substr($row['path'],1).'</a><br />';
111
+                }
112
+                else
113
+                {
114
+                    echo substr($row['path'],1).' ';
115
+                    echo showorhide_addresourcelink('Document',$row['id']);
116
+                    echo '<br />';
117
+                }
118
+            }
119
+        }
120
+        else
121
+        {
122
+            // we calculate the level we are in by using the $folder in the url
123
+            // we put +1 because it does not start with an / and in the database it does
124
+            $level=get_levels($folder)+1;
125
+
126
+            // we calculate each level of the database entry
127
+            $file_level=get_levels($row['path'])-1;
128
+            // if the level of the database entry is equal to the level we ar in, we put it into an array
129
+            // as this is a potential good entry
130
+            if ($file_level==$level)
131
+            {
132
+                $good_paths[]=$row['path'];
133
+                $good_ids[]=$row['id'];
134
+            }
135
+            //$haystack=$row['path'];
136
+            //$conform_folder=strstr($haystack, $folder);
137
+            //if (str_replace($folder.'/','',$conform_folder)!==$folder)
138
+            //	{
139
+            //	$good_folders[]=$row['path'];
140
+                //echo str_replace($folder.'/','',$conform_folder);
141
+            //	echo '<br />';
142
+            //	}// if (str_replace($folder.'/','',$conform_folder)!==$folder)
143
+        } // else (if (!$folder))
144
+    } //while ($row=Database::fetch_array($result))
145
+
146
+    // this is code for the case that we are in a subfolder
147
+    if ($good_paths)
148
+    {
149
+        // we have all the potential good database entries, the good ones are those that start with $folder
150
+        foreach ($good_paths as $path)
151
+        {
152
+            if (strstr($path,$folder))
153
+            {
154
+                $good_key=key($good_paths);
155
+                // showing the right icon
156
+                if (file_or_folder($path))
157
+                {
158
+                    echo '<img src="../img/file.gif" align="middle" />';
159
+                }
160
+                else
161
+                {
162
+                    $image = choose_image($path);
163
+                    echo "<img src=\"../img/$image\" align=\"middle\" />";
164
+                }
165
+
166
+                // folders should be clickable
167
+                if (file_or_folder($path))
168
+                {
169
+                    $path=substr($path,1); // remove the first / in folder_up
170
+                    $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']);
171
+                    $newuri=str_replace('add=','addnot=',$uri);
172
+                    //using the correct name of the folder
173
+                    $folder_name=str_replace($folder.'/','',$path);
174
+                    echo "<a href='$newuri'>".$folder_name.'</a><br />';
175
+                }
176
+                else
177
+                {
178
+                    echo str_replace("/$folder/", '',$path).' ';
179
+                    echo showorhide_addresourcelink('Document',$good_ids[$good_key]);
180
+                    echo '<br />';
181
+                }
182
+            }
183
+            next($good_paths);
184
+        }
185
+    }
186 186
 }
187 187
 
188 188
 /**
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
  */
194 194
 function file_or_folder($filefolder)
195 195
 {
196
-	global $_course;
197
-	global $baseServDir;
196
+    global $_course;
197
+    global $baseServDir;
198 198
 
199
-	$courseDir   = $_course['path'].'/document';
200
-	$baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir;
199
+    $courseDir   = $_course['path'].'/document';
200
+    $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir;
201 201
 
202
-	return (is_dir($baseWorkDir.$filefolder) ? 1 : 0);
202
+    return (is_dir($baseWorkDir.$filefolder) ? 1 : 0);
203 203
 }
204 204
 
205 205
 /**
@@ -210,23 +210,23 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function store_resources($source_type, $source_id)
212 212
 {
213
-	global $_course;
214
-	$resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES);
215
-
216
-	$addedresource = $_SESSION['addedresource'];
217
-	$addedresourceid = $_SESSION['addedresourceid'];
218
-	if ($_SESSION['addedresource'])
219
-	{
220
-		foreach ($addedresource as $resource_type)
221
-		{
222
-			$sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')";
223
-			Database::query($sql);
224
-			$i=key($addedresource);
225
-			next($addedresource);
226
-		}
227
-		$_SESSION['addedresource']='';
228
-		$_SESSION['addedresourceid']='';
229
-	}
213
+    global $_course;
214
+    $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES);
215
+
216
+    $addedresource = $_SESSION['addedresource'];
217
+    $addedresourceid = $_SESSION['addedresourceid'];
218
+    if ($_SESSION['addedresource'])
219
+    {
220
+        foreach ($addedresource as $resource_type)
221
+        {
222
+            $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')";
223
+            Database::query($sql);
224
+            $i=key($addedresource);
225
+            next($addedresource);
226
+        }
227
+        $_SESSION['addedresource']='';
228
+        $_SESSION['addedresourceid']='';
229
+    }
230 230
 }
231 231
 
232 232
 /**
@@ -240,87 +240,87 @@  discard block
 block discarded – undo
240 240
  */
241 241
 function display_addedresource_link($type, $id, $style='')
242 242
 {
243
-	global $_course;
243
+    global $_course;
244 244
 
245
-	// styling the link of the added resource
246
-	if ($style <> '')
247
-	{
248
-		$styling = ' class="'.$style.'"';
249
-	}
245
+    // styling the link of the added resource
246
+    if ($style <> '')
247
+    {
248
+        $styling = ' class="'.$style.'"';
249
+    }
250 250
 
251 251
     $course_id = api_get_course_int_id();
252 252
 
253
-	switch ($type)
254
-	{
255
-		case 'Agenda':
256
-			$TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
257
-			$result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
258
-			$myrow = Database::fetch_array($result);
259
-			echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
260
-			break;
261
-		case 'Ad_Valvas':
262
-			$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
263
-			$result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
264
-			$myrow = Database::fetch_array($result);
265
-			echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
266
-			break;
267
-		case 'Link':Database::get_course_table(TABLE_LINK);
268
-			$result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
269
-			$myrow = Database::fetch_array($result);
270
-			echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&amp;link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n";
271
-			break;
272
-		case 'Exercise':
273
-			$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
274
-			$result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND  id=$id");
275
-			$myrow = Database::fetch_array($result);
276
-			echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n";
277
-			break;
278
-		case 'Forum':
279
-			$TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
280
-			$result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
281
-			$myrow = Database::fetch_array($result);
282
-			echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewforum.php?forum='.$myrow['forum_id'].'&amp;md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n";
283
-			break;
284
-		case 'Thread':  //=topics
253
+    switch ($type)
254
+    {
255
+        case 'Agenda':
256
+            $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
257
+            $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
258
+            $myrow = Database::fetch_array($result);
259
+            echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
260
+            break;
261
+        case 'Ad_Valvas':
262
+            $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
263
+            $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
264
+            $myrow = Database::fetch_array($result);
265
+            echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
266
+            break;
267
+        case 'Link':Database::get_course_table(TABLE_LINK);
268
+            $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
269
+            $myrow = Database::fetch_array($result);
270
+            echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&amp;link_url='.urlencode($myrow['url'])."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n";
271
+            break;
272
+        case 'Exercise':
273
+            $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
274
+            $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND  id=$id");
275
+            $myrow = Database::fetch_array($result);
276
+            echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n";
277
+            break;
278
+        case 'Forum':
279
+            $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
280
+            $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
281
+            $myrow = Database::fetch_array($result);
282
+            echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewforum.php?forum='.$myrow['forum_id'].'&amp;md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n";
283
+            break;
284
+        case 'Thread':  //=topics
285 285
         //deprecated
286
-			$tbl_posts		= $_course['dbNameGlu'].'bb_posts';
287
-			$tbl_posts_text	= $_course['dbNameGlu'].'bb_posts_text';
288
-			$TBL_FORUMS		= $_course['dbNameGlu'].'bb_forums';
289
-			$result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id");
290
-			$myrow = Database::fetch_array($result);
291
-			// grabbing the title of the post
292
-			$sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
293
-			$result_title = Database::query($sql_title);
294
-			$myrow_title = Database::fetch_array($result_title);
295
-			echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$myrow['topic_id'].'&amp;forum='.$myrow['forum_id'].'&amp;md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n";
296
-			break;
297
-		case 'Post':
286
+            $tbl_posts		= $_course['dbNameGlu'].'bb_posts';
287
+            $tbl_posts_text	= $_course['dbNameGlu'].'bb_posts_text';
288
+            $TBL_FORUMS		= $_course['dbNameGlu'].'bb_forums';
289
+            $result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id");
290
+            $myrow = Database::fetch_array($result);
291
+            // grabbing the title of the post
292
+            $sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
293
+            $result_title = Database::query($sql_title);
294
+            $myrow_title = Database::fetch_array($result_title);
295
+            echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$myrow['topic_id'].'&amp;forum='.$myrow['forum_id'].'&amp;md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n";
296
+            break;
297
+        case 'Post':
298 298
         //deprecated
299
-			$tbl_post = Database::get_course_table(TABLE_FORUM_POST);
300
-			$tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE);
301
-			$sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id";
302
-			$result = Database::query($sql);
303
-			$post = Database::fetch_object($result);
304
-			echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&amp;forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n";
305
-			break;
306
-		case 'Document':
307
-			$dbTable = Database::get_course_table(TABLE_DOCUMENT);
308
-			$result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id");
309
-			$myrow = Database::fetch_array($result);
310
-			$pathname = explode('/',$myrow['path']); // making a correct name for the link
311
-			$last = count($pathname) - 1;  // making a correct name for the link
312
-			$filename = $pathname[$last];  // making a correct name for the link
313
-			$image = choose_image($filename);
314
-			$ext = explode('.',$filename);
315
-			$ext = strtolower($ext[sizeof($ext)-1]);
316
-			$myrow['path'] = rawurlencode($myrow['path']);
317
-			$in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png'));
318
-			echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n";
319
-			break;
320
-		case 'Externallink':
321
-			echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n";
322
-			break;
323
-	}
299
+            $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
300
+            $tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE);
301
+            $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id";
302
+            $result = Database::query($sql);
303
+            $post = Database::fetch_object($result);
304
+            echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&amp;forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n";
305
+            break;
306
+        case 'Document':
307
+            $dbTable = Database::get_course_table(TABLE_DOCUMENT);
308
+            $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id");
309
+            $myrow = Database::fetch_array($result);
310
+            $pathname = explode('/',$myrow['path']); // making a correct name for the link
311
+            $last = count($pathname) - 1;  // making a correct name for the link
312
+            $filename = $pathname[$last];  // making a correct name for the link
313
+            $image = choose_image($filename);
314
+            $ext = explode('.',$filename);
315
+            $ext = strtolower($ext[sizeof($ext)-1]);
316
+            $myrow['path'] = rawurlencode($myrow['path']);
317
+            $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png'));
318
+            echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n";
319
+            break;
320
+        case 'Externallink':
321
+            echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n";
322
+            break;
323
+    }
324 324
 }
325 325
 
326 326
 /**
@@ -342,766 +342,766 @@  discard block
 block discarded – undo
342 342
 */
343 343
 function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0)
344 344
 {
345
-	global $learnpath_id, $tbl_learnpath_item, $items;
346
-	global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;
347
-
348
-	$hyperlink_target_parameter = ''; //or e.g. 'target="_blank"'
349
-
350
-	$length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
351
-
352
-	if ($builder != 'builder') $origin = 'learnpath';	//origin = learnpath in student view
353
-	$linktype = $type;
354
-	if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';
355
-
356
-	switch ($type)
357
-	{
358
-		case "Agenda":
359
-			$TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA);
360
-			$result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
361
-			$myrow=Database::fetch_array($result);
362
-
363
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
364
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
365
-			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
366
-			$desc=$row['description'];
367
-			$agenda_id=$row['item_id'];
368
-			echo str_repeat("&nbsp;&gt;",$level);
369
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
370
-			if ($icon != 'nolink')
371
-			{
372
-				if ($completed=='completed') {
373
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
374
-				}	else {
375
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
376
-					//echo "&nbsp;";
377
-				}
378
-			}
379
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
380
-
381
-			if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
382
-
383
-			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
384
-			if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; }
385
-			if ($builder != 'builder')
386
-			{
387
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
388
-        		$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
389
-				if ($desc != '')
390
-				{
391
-					if ($icon != 'wrap')
392
-					{
393
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
394
-					}
395
-					else
396
-					{
397
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
398
-					}
399
-				}
400
-			}
401
-			else
402
-			{
403
-				echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
404
-			}
405
-			break;
406
-
407
-		case "Ad_Valvas":
408
-			$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
409
-			$result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
410
-			$myrow=Database::fetch_array($result);
411
-
412
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
413
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
414
-			if ($row['title'] != '') { $myrow["content"]=$row['title']; }
415
-			$desc=$row['description'];
416
-			$ann_id=$row['item_id'];
417
-			echo str_repeat("&nbsp;&gt;",$level);
418
-
419
-			// the title and the text are in the content field and we only want to display the title
420
-			list($title, $text)=split('<br>',$myrow['content']);
421
-			if ($title=='') { $title=$myrow['content']; }
422
-			$title=$myrow['title'];
423
-			$text=$myrow['content'];
424
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
425
-			if ($icon != 'nolink')
426
-			{
427
-				if ($completed=='completed') {
428
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
429
-				}	else {
430
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
431
-					//echo "&nbsp;";
432
-				}
433
-			}
434
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
435
-
436
-			if ($title=='') {
437
-				$type="Announcement";
438
-				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
439
-				return(true);
440
-			}
441
-
442
-			if ($icon == 'nolink') { return(shorten($title,$length)); }
443
-			if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; }
444
-			if ($builder != 'builder')
445
-			{
446
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>";
447
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path";
448
-				if ($desc != '')
449
-				{
450
-					if ($icon != 'wrap')
451
-					{
452
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
453
-					}
454
-					else
455
-					{
456
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
457
-					}
458
-				}
459
-			}
460
-			else
461
-			{
462
-				echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>";
463
-			}
464
-			break;
465
-
466
-		case "Link" :
467
-			$TABLETOOLLINK	= Database::get_course_table(TABLE_LINK);
468
-			$result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
469
-			$myrow=Database::fetch_array($result);
470
-
471
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
472
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
473
-			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
474
-			$desc=$row['description'];
475
-			echo str_repeat("&nbsp;&gt;",$level);
476
-
477
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
478
-			if ($icon != 'nolink')
479
-			{
480
-				if ($completed=='completed') {
481
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
482
-				}	else {
483
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
484
-					//echo "&nbsp;";
485
-				}
486
-			}
487
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
488
-
489
-			if ($myrow["title"]=='')
490
-			{
491
-				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
492
-				return(true);
493
-			}
494
-
495
-			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
496
-			if ($icon == 'icon')
497
-			{
498
-				if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
499
-				   else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
500
-			}
501
-			$thelink=$myrow["url"];
502
-			if ($builder != 'builder')
503
-			{
504
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
505
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
506
-				if ($desc != '')
507
-				{
508
-					if ($icon != 'wrap')
509
-					{
510
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
511
-					}
512
-					else
513
-					{
514
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
515
-					}
516
-				}
517
-			}
518
-			else
519
-			{
520
-				echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
521
-			}
522
-			break;
523
-
524
-		case "Exercise":
525
-			$TBL_EXERCICES  = Database::get_course_table(TABLE_QUIZ_TEST);
526
-			$result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
527
-			$myrow=Database::fetch_array($result);
528
-
529
-			if ($builder=='builder') { $origin='builder'; }
530
-			  //this is needed for the exercise_submit.php can delete the session info about tests
531
-
532
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
533
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
534
-			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
535
-			$desc=$row['description'];
536
-			echo str_repeat("&nbsp;&gt;",$level);
537
-
538
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
539
-			if ($icon != 'nolink')
540
-			{
541
-				if ($completed=='completed') {
542
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
543
-				}	else {
544
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
545
-					//echo "&nbsp;";
546
-				}
547
-			}
548
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
549
-
550
-			if ($myrow["title"]=='') {
551
-				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
552
-				return(true);
553
-			}
554
-
555
-			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
556
-			if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; }
557
-			if ($builder != 'builder')
558
-			{
559
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
560
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
561
-				if ($desc != '')
562
-				{
563
-					if ($icon != 'wrap')
564
-					{
565
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
566
-					}
567
-					else
568
-					{
569
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
570
-					}
571
-				}
572
-			}
573
-			else
574
-			{
575
-				echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
576
-			}
577
-			break;
578
-
579
-		case "HotPotatoes":
580
-			$TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT);
581
-			$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
582
-			$result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
583
-			$myrow= Database::fetch_array($result);
584
-			$path=$myrow["path"];
585
-			$name=GetQuizName($path,$documentPath);
586
-
587
-			if ($builder=='builder') { $origin='builder'; }
588
-			  //this is needed for the exercise_submit.php can delete the session info about tests
589
-
590
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
591
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
592
-			if ($row['title'] != '') { $name=$row['title']; }
593
-			$desc=$row['description'];
594
-			echo str_repeat("&nbsp;&gt;",$level);
595
-
596
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
597
-			if ($icon != 'nolink')
598
-			{
599
-				if ($completed=='completed') {
600
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
601
-				}	else {
602
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
603
-					//echo "&nbsp;";
604
-				}
605
-			}
606
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
607
-
608
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
609
-
610
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
611
-			if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; }
612
-
613
-			$cid = $_course['official_code'];
614
-
615
-			if ($builder != 'builder')
616
-			{
617
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
618
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
619
-				if ($desc != '')
620
-				{
621
-					if ($icon != 'wrap')
622
-					{
623
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
624
-					}
625
-					else
626
-					{
627
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
628
-					}
629
-				}
630
-			}
631
-			else
632
-			{
633
-				echo "&nbsp;<a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
634
-			}
635
-			break;
636
-
637
-		case "Forum":
638
-			$TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
639
-			$result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
640
-			$myrow=Database::fetch_array($result);
641
-
642
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
643
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
644
-			if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; }
645
-			$desc=$row['description'];
646
-			echo str_repeat("&nbsp;&gt;",$level);
647
-
648
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
649
-			if ($icon != 'nolink')
650
-			{
651
-				if ($completed=='completed') {
652
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
653
-				}	else {
654
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
655
-					//echo "&nbsp;";
656
-				}
657
-			}
658
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
659
-
660
-			if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
661
-
662
-			if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); }
663
-			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
664
-			$forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
665
-			if ($builder != 'builder')
666
-			{
667
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
668
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
669
-				if ($desc != '')
670
-				{
671
-					if ($icon != 'wrap')
672
-					{
673
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
674
-					}
675
-					else
676
-					{
677
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
678
-					}
679
-				}
680
-			}
681
-			else
682
-			{
683
-				echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
684
-			}
685
-			break;
686
-
687
-		case "Thread":  //forum post
345
+    global $learnpath_id, $tbl_learnpath_item, $items;
346
+    global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;
347
+
348
+    $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"'
349
+
350
+    $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
351
+
352
+    if ($builder != 'builder') $origin = 'learnpath';	//origin = learnpath in student view
353
+    $linktype = $type;
354
+    if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';
355
+
356
+    switch ($type)
357
+    {
358
+        case "Agenda":
359
+            $TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA);
360
+            $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
361
+            $myrow=Database::fetch_array($result);
362
+
363
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
364
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
365
+            if ($row['title'] != '') { $myrow["title"]=$row['title']; }
366
+            $desc=$row['description'];
367
+            $agenda_id=$row['item_id'];
368
+            echo str_repeat("&nbsp;&gt;",$level);
369
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
370
+            if ($icon != 'nolink')
371
+            {
372
+                if ($completed=='completed') {
373
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
374
+                }	else {
375
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
376
+                    //echo "&nbsp;";
377
+                }
378
+            }
379
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
380
+
381
+            if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
382
+
383
+            if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
384
+            if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; }
385
+            if ($builder != 'builder')
386
+            {
387
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
388
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
389
+                if ($desc != '')
390
+                {
391
+                    if ($icon != 'wrap')
392
+                    {
393
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
394
+                    }
395
+                    else
396
+                    {
397
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
398
+                    }
399
+                }
400
+            }
401
+            else
402
+            {
403
+                echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
404
+            }
405
+            break;
406
+
407
+        case "Ad_Valvas":
408
+            $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
409
+            $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
410
+            $myrow=Database::fetch_array($result);
411
+
412
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
413
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
414
+            if ($row['title'] != '') { $myrow["content"]=$row['title']; }
415
+            $desc=$row['description'];
416
+            $ann_id=$row['item_id'];
417
+            echo str_repeat("&nbsp;&gt;",$level);
418
+
419
+            // the title and the text are in the content field and we only want to display the title
420
+            list($title, $text)=split('<br>',$myrow['content']);
421
+            if ($title=='') { $title=$myrow['content']; }
422
+            $title=$myrow['title'];
423
+            $text=$myrow['content'];
424
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
425
+            if ($icon != 'nolink')
426
+            {
427
+                if ($completed=='completed') {
428
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
429
+                }	else {
430
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
431
+                    //echo "&nbsp;";
432
+                }
433
+            }
434
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
435
+
436
+            if ($title=='') {
437
+                $type="Announcement";
438
+                echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
439
+                return(true);
440
+            }
441
+
442
+            if ($icon == 'nolink') { return(shorten($title,$length)); }
443
+            if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; }
444
+            if ($builder != 'builder')
445
+            {
446
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>";
447
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path";
448
+                if ($desc != '')
449
+                {
450
+                    if ($icon != 'wrap')
451
+                    {
452
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
453
+                    }
454
+                    else
455
+                    {
456
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
457
+                    }
458
+                }
459
+            }
460
+            else
461
+            {
462
+                echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>";
463
+            }
464
+            break;
465
+
466
+        case "Link" :
467
+            $TABLETOOLLINK	= Database::get_course_table(TABLE_LINK);
468
+            $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
469
+            $myrow=Database::fetch_array($result);
470
+
471
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
472
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
473
+            if ($row['title'] != '') { $myrow["title"]=$row['title']; }
474
+            $desc=$row['description'];
475
+            echo str_repeat("&nbsp;&gt;",$level);
476
+
477
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
478
+            if ($icon != 'nolink')
479
+            {
480
+                if ($completed=='completed') {
481
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
482
+                }	else {
483
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
484
+                    //echo "&nbsp;";
485
+                }
486
+            }
487
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
488
+
489
+            if ($myrow["title"]=='')
490
+            {
491
+                echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
492
+                return(true);
493
+            }
494
+
495
+            if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
496
+            if ($icon == 'icon')
497
+            {
498
+                if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
499
+                    else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
500
+            }
501
+            $thelink=$myrow["url"];
502
+            if ($builder != 'builder')
503
+            {
504
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
505
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
506
+                if ($desc != '')
507
+                {
508
+                    if ($icon != 'wrap')
509
+                    {
510
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
511
+                    }
512
+                    else
513
+                    {
514
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
515
+                    }
516
+                }
517
+            }
518
+            else
519
+            {
520
+                echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
521
+            }
522
+            break;
523
+
524
+        case "Exercise":
525
+            $TBL_EXERCICES  = Database::get_course_table(TABLE_QUIZ_TEST);
526
+            $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
527
+            $myrow=Database::fetch_array($result);
528
+
529
+            if ($builder=='builder') { $origin='builder'; }
530
+                //this is needed for the exercise_submit.php can delete the session info about tests
531
+
532
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
533
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
534
+            if ($row['title'] != '') { $myrow["title"]=$row['title']; }
535
+            $desc=$row['description'];
536
+            echo str_repeat("&nbsp;&gt;",$level);
537
+
538
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
539
+            if ($icon != 'nolink')
540
+            {
541
+                if ($completed=='completed') {
542
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
543
+                }	else {
544
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
545
+                    //echo "&nbsp;";
546
+                }
547
+            }
548
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
549
+
550
+            if ($myrow["title"]=='') {
551
+                echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
552
+                return(true);
553
+            }
554
+
555
+            if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
556
+            if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; }
557
+            if ($builder != 'builder')
558
+            {
559
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
560
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
561
+                if ($desc != '')
562
+                {
563
+                    if ($icon != 'wrap')
564
+                    {
565
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
566
+                    }
567
+                    else
568
+                    {
569
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
570
+                    }
571
+                }
572
+            }
573
+            else
574
+            {
575
+                echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
576
+            }
577
+            break;
578
+
579
+        case "HotPotatoes":
580
+            $TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT);
581
+            $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
582
+            $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
583
+            $myrow= Database::fetch_array($result);
584
+            $path=$myrow["path"];
585
+            $name=GetQuizName($path,$documentPath);
586
+
587
+            if ($builder=='builder') { $origin='builder'; }
588
+                //this is needed for the exercise_submit.php can delete the session info about tests
589
+
590
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
591
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
592
+            if ($row['title'] != '') { $name=$row['title']; }
593
+            $desc=$row['description'];
594
+            echo str_repeat("&nbsp;&gt;",$level);
595
+
596
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
597
+            if ($icon != 'nolink')
598
+            {
599
+                if ($completed=='completed') {
600
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
601
+                }	else {
602
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
603
+                    //echo "&nbsp;";
604
+                }
605
+            }
606
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
607
+
608
+            if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
609
+
610
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
611
+            if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; }
612
+
613
+            $cid = $_course['official_code'];
614
+
615
+            if ($builder != 'builder')
616
+            {
617
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
618
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
619
+                if ($desc != '')
620
+                {
621
+                    if ($icon != 'wrap')
622
+                    {
623
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
624
+                    }
625
+                    else
626
+                    {
627
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
628
+                    }
629
+                }
630
+            }
631
+            else
632
+            {
633
+                echo "&nbsp;<a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
634
+            }
635
+            break;
636
+
637
+        case "Forum":
638
+            $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
639
+            $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
640
+            $myrow=Database::fetch_array($result);
641
+
642
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
643
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
644
+            if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; }
645
+            $desc=$row['description'];
646
+            echo str_repeat("&nbsp;&gt;",$level);
647
+
648
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
649
+            if ($icon != 'nolink')
650
+            {
651
+                if ($completed=='completed') {
652
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
653
+                }	else {
654
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
655
+                    //echo "&nbsp;";
656
+                }
657
+            }
658
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
659
+
660
+            if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
661
+
662
+            if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); }
663
+            if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
664
+            $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
665
+            if ($builder != 'builder')
666
+            {
667
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
668
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
669
+                if ($desc != '')
670
+                {
671
+                    if ($icon != 'wrap')
672
+                    {
673
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
674
+                    }
675
+                    else
676
+                    {
677
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
678
+                    }
679
+                }
680
+            }
681
+            else
682
+            {
683
+                echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
684
+            }
685
+            break;
686
+
687
+        case "Thread":  //forum post
688 688
         //deprecated
689
-			$tbl_topics      = $_course['dbNameGlu'].'bb_topics';
690
-			$tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
691
-			$TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
692
-			$sql="SELECT * FROM $tbl_topics where topic_id=$id";
693
-			$result= Database::query($sql);
694
-			$myrow=Database::fetch_array($result);
695
-
696
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
697
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
698
-			if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; }
699
-			$desc=$row['description'];
700
-			echo str_repeat("&nbsp;&gt;",$level);
701
-
702
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
703
-			if ($icon != 'nolink')
704
-			{
705
-				if ($completed=='completed') {
706
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
707
-				}	else {
708
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
709
-					//echo "&nbsp;";
710
-				}
711
-			}
712
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
713
-
714
-			if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
715
-
716
-			if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); }
717
-			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
718
-			if ($builder != 'builder')
719
-			{
720
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
721
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
722
-				if ($desc != '')
723
-				{
724
-					if ($icon != 'wrap')
725
-					{
726
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
727
-					}
728
-					else
729
-					{
730
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
731
-					}
732
-				}
733
-			}
734
-			else
735
-			{
736
-				echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
737
-			}
738
-			break;
739
-
740
-		case "Post":
689
+            $tbl_topics      = $_course['dbNameGlu'].'bb_topics';
690
+            $tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
691
+            $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
692
+            $sql="SELECT * FROM $tbl_topics where topic_id=$id";
693
+            $result= Database::query($sql);
694
+            $myrow=Database::fetch_array($result);
695
+
696
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
697
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
698
+            if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; }
699
+            $desc=$row['description'];
700
+            echo str_repeat("&nbsp;&gt;",$level);
701
+
702
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
703
+            if ($icon != 'nolink')
704
+            {
705
+                if ($completed=='completed') {
706
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
707
+                }	else {
708
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
709
+                    //echo "&nbsp;";
710
+                }
711
+            }
712
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
713
+
714
+            if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
715
+
716
+            if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); }
717
+            if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
718
+            if ($builder != 'builder')
719
+            {
720
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
721
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
722
+                if ($desc != '')
723
+                {
724
+                    if ($icon != 'wrap')
725
+                    {
726
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
727
+                    }
728
+                    else
729
+                    {
730
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
731
+                    }
732
+                }
733
+            }
734
+            else
735
+            {
736
+                echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
737
+            }
738
+            break;
739
+
740
+        case "Post":
741 741
         //deprecated
742
-			$tbl_posts       = $_course['dbNameGlu'].'bb_posts';
743
-			$tbl_posts_text  = $_course['dbNameGlu'].'bb_posts_text';
744
-			$TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
745
-			$result= Database::query("SELECT * FROM $tbl_posts where post_id=$id");
746
-			$myrow=Database::fetch_array($result);
747
-			// grabbing the title of the post
748
-			$sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
749
-			$result_titel=Database::query($sql_titel);
750
-			$myrow_titel=Database::fetch_array($result_titel);
751
-
752
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
753
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
754
-			if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; }
755
-			$desc=$row['description'];
756
-			echo str_repeat("&nbsp;&gt;",$level);
757
-
758
-			$posternom=$myrow['nom'];				$posterprenom=$myrow['prenom'];
759
-			$posttime=$myrow['post_time'];			$posttext=$myrow_titel['post_text'];
760
-			$posttitle=$myrow_titel['post_title'];
761
-			$posttext = str_replace('"',"'",$posttext);
762
-
763
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
764
-			if ($icon != 'nolink')
765
-			{
766
-				if ($completed=='completed') {
767
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
768
-				}	else {
769
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
770
-					//echo "&nbsp;";
771
-				}
772
-			}
773
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
774
-
775
-			if ($myrow_titel["post_title"]=='')
776
-			{
777
-				$type="Forum";
778
-				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
779
-			}
780
-
781
-			if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); }
782
-			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
783
-			if ($builder != 'builder')
784
-			{
785
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
786
-				if ($desc != '')
787
-				{
788
-					if ($icon != 'wrap')
789
-					{
790
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
791
-					}
792
-					else
793
-					{
794
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
795
-					}
796
-				}
797
-			}
798
-			else
799
-			{
800
-				echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>";
801
-			}
802
-			break;
803
-
804
-		case "Document":
805
-			$dbTable  = Database::get_course_table(TABLE_DOCUMENT);
806
-			$result=Database::query("SELECT * FROM $dbTable WHERE id=$id");
807
-			$myrow=Database::fetch_array($result);
808
-
809
-			$pathname=explode("/",$myrow["path"]); // making a correct name for the link
810
-			$last=count($pathname)-1;  // making a correct name for the link
811
-			$filename=$pathname[$last];  // making a correct name for the link
812
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
813
-
814
-			echo str_repeat("&nbsp;&gt;",$level);
815
-
816
-			if ($icon != 'nolink') {
817
-				if ($completed=='completed') {
818
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
819
-				}	else {
820
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
821
-					//echo "&nbsp;";
822
-				}
823
-			}
824
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
825
-			$image=choose_image($filename);
826
-
827
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
828
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
829
-			if ($row['title'] != '') { $filename=$row['title']; }
830
-			$desc=$row['description'];
831
-
832
-			if (($myrow["path"]=='') and ($filename=='')) {
833
-				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
834
-				return(true);
835
-			}
836
-
837
-			if ($icon == 'nolink') { return(shorten($filename,$length)); }
838
-			if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; }
839
-			if ($builder != 'builder')
840
-			{
841
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>";
842
-				if ($desc != '')
843
-				{
844
-					if ($icon != 'wrap')
845
-					{
846
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
847
-					}
848
-					else
849
-					{
850
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
851
-					}
852
-				} $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
853
-			}
854
-			else
855
-			{
856
-				$enableDocumentParsing='yes';
857
-				if (!$enableDocumentParsing)
858
-				{ //this is the solution for the non-parsing version in the builder
859
-					$file=urlencode($myrow["path"]);
860
-					echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
861
-				}
862
-				else
863
-				{
864
-					echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
865
-				}
866
-			}
867
-			break;
868
-
869
-		case "Assignments":
870
-			$name=get_lang('Assignments');
871
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
872
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
873
-			if ($row['title'] != '') { $name=$row['title']; }
874
-			$desc=$row['description'];
875
-			echo str_repeat("&nbsp;&gt;",$level);
876
-
877
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
878
-			if ($icon != 'nolink')
879
-			{
880
-				if ($completed=='completed') {
881
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
882
-				}	else {
883
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
884
-					//echo "&nbsp;";
885
-				}
886
-			}
887
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
888
-
889
-			if ($name=='')
890
-			{
891
-				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
892
-			}
893
-
894
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
895
-			if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; }
896
-			if ($builder != 'builder')
897
-			{
898
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
899
-				if ($desc != '')
900
-				{
901
-					if ($icon != 'wrap')
902
-					{
903
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
904
-					}
905
-					else
906
-					{
907
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
908
-					}
909
-				}
910
-			}
911
-			else
912
-			{
913
-				echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
914
-			}
915
-			break;
916
-		case "Dropbox":
917
-			$name=get_lang('Dropbox');
918
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
919
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
920
-			if ($row['title'] != '') { $name=$row['title']; }
921
-			$desc=$row['description'];
922
-			echo str_repeat("&nbsp;&gt;",$level);
923
-
924
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
925
-			if ($icon != 'nolink') {
926
-				if ($completed=='completed') {
927
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
928
-				}	else {
929
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
930
-					//echo "&nbsp;";
931
-				}
932
-			}
933
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
934
-
935
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
936
-
937
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
938
-			if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; }
939
-
940
-			if ($builder != 'builder')
941
-			{
942
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
943
-				if ($desc != '') {
944
-					if ($icon != 'wrap') {
945
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
946
-					else {
947
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
948
-				}
949
-			} else {
950
-				echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
951
-			}
952
-			break;
953
-		case "Introduction_text":
954
-			$name=get_lang('IntroductionText');
955
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
956
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
957
-			if ($row['title'] != '') { $name=$row['title']; }
958
-			$desc=$row['description'];
959
-			echo str_repeat("&nbsp;&gt;",$level);
960
-
961
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
962
-			if ($icon != 'nolink') {
963
-				if ($completed=='completed') {
964
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
965
-				}	else {
966
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
967
-					//echo "&nbsp;";
968
-				}
969
-			}
970
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
971
-
972
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
973
-
974
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
975
-			if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; }
976
-
977
-			if ($builder != 'builder')
978
-			{
979
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
980
-				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
981
-				if ($desc != '') {
982
-					if ($icon != 'wrap') {
983
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
984
-					else {
985
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
986
-				}
987
-			} else {
988
-				$s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
989
-				echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
990
-			}
991
-			break;
992
-		case "Course_description":
993
-			$name=get_lang('CourseDescription');
994
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
995
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
996
-			if ($row['title'] != '') { $name=$row['title']; }
997
-			$desc=$row['description'];
998
-			echo str_repeat("&nbsp;&gt;",$level);
999
-
1000
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1001
-			if ($icon != 'nolink') {
1002
-				if ($completed=='completed') {
1003
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1004
-				}	else {
1005
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1006
-					//echo "&nbsp;";
1007
-				}
1008
-			}
1009
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1010
-
1011
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1012
-
1013
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
1014
-			if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; }
1015
-
1016
-			if ($builder != 'builder')
1017
-			{
1018
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
1019
-				if ($desc != '') {
1020
-					if ($icon != 'wrap') {
1021
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
1022
-					else {
1023
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1024
-				}
1025
-			} else {
1026
-				$s=api_get_path(WEB_CODE_PATH)."course_description";
1027
-				echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1028
-			}
1029
-			break;
1030
-		case "Groups":
1031
-			$name=get_lang('Groups');
1032
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1033
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1034
-			if ($row['title'] != '') { $name=$row['title']; }
1035
-			$desc=$row['description'];
1036
-			echo str_repeat("&nbsp;&gt;",$level);
1037
-
1038
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1039
-			if ($icon != 'nolink') {
1040
-				if ($completed=='completed') {
1041
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1042
-				}	else {
1043
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1044
-					//echo "&nbsp;";
1045
-				}
1046
-			}
1047
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1048
-
1049
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1050
-
1051
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
1052
-			if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; }
1053
-
1054
-			if ($builder != 'builder')
1055
-			{
1056
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
1057
-				if ($desc != '') {
1058
-					if ($icon != 'wrap') {
1059
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
1060
-					else {
1061
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1062
-				}
1063
-			} else {
1064
-				echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1065
-			}
1066
-			break;
1067
-		case "Users":
1068
-			$name=get_lang('Users');
1069
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1070
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1071
-			if ($row['title'] != '') { $name=$row['title']; }
1072
-			$desc=$row['description'];
1073
-			echo str_repeat("&nbsp;&gt;",$level);
1074
-
1075
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1076
-			if ($icon != 'nolink') {
1077
-				if ($completed=='completed') {
1078
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1079
-				}	else {
1080
-					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1081
-					//echo "&nbsp;";
1082
-				}
1083
-			}
1084
-			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1085
-
1086
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1087
-
1088
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
1089
-			if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; }
1090
-
1091
-			if ($builder != 'builder')
1092
-			{
1093
-				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
1094
-				if ($desc != '') {
1095
-					if ($icon != 'wrap') {
1096
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
1097
-					else {
1098
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1099
-				}
1100
-			} else {
1101
-				echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1102
-			}
1103
-			break;
1104
-	}//end huge switch-statement
742
+            $tbl_posts       = $_course['dbNameGlu'].'bb_posts';
743
+            $tbl_posts_text  = $_course['dbNameGlu'].'bb_posts_text';
744
+            $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
745
+            $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id");
746
+            $myrow=Database::fetch_array($result);
747
+            // grabbing the title of the post
748
+            $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
749
+            $result_titel=Database::query($sql_titel);
750
+            $myrow_titel=Database::fetch_array($result_titel);
751
+
752
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
753
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
754
+            if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; }
755
+            $desc=$row['description'];
756
+            echo str_repeat("&nbsp;&gt;",$level);
757
+
758
+            $posternom=$myrow['nom'];				$posterprenom=$myrow['prenom'];
759
+            $posttime=$myrow['post_time'];			$posttext=$myrow_titel['post_text'];
760
+            $posttitle=$myrow_titel['post_title'];
761
+            $posttext = str_replace('"',"'",$posttext);
762
+
763
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
764
+            if ($icon != 'nolink')
765
+            {
766
+                if ($completed=='completed') {
767
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
768
+                }	else {
769
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
770
+                    //echo "&nbsp;";
771
+                }
772
+            }
773
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
774
+
775
+            if ($myrow_titel["post_title"]=='')
776
+            {
777
+                $type="Forum";
778
+                echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
779
+            }
780
+
781
+            if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); }
782
+            if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
783
+            if ($builder != 'builder')
784
+            {
785
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
786
+                if ($desc != '')
787
+                {
788
+                    if ($icon != 'wrap')
789
+                    {
790
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
791
+                    }
792
+                    else
793
+                    {
794
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
795
+                    }
796
+                }
797
+            }
798
+            else
799
+            {
800
+                echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>";
801
+            }
802
+            break;
803
+
804
+        case "Document":
805
+            $dbTable  = Database::get_course_table(TABLE_DOCUMENT);
806
+            $result=Database::query("SELECT * FROM $dbTable WHERE id=$id");
807
+            $myrow=Database::fetch_array($result);
808
+
809
+            $pathname=explode("/",$myrow["path"]); // making a correct name for the link
810
+            $last=count($pathname)-1;  // making a correct name for the link
811
+            $filename=$pathname[$last];  // making a correct name for the link
812
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
813
+
814
+            echo str_repeat("&nbsp;&gt;",$level);
815
+
816
+            if ($icon != 'nolink') {
817
+                if ($completed=='completed') {
818
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
819
+                }	else {
820
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
821
+                    //echo "&nbsp;";
822
+                }
823
+            }
824
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
825
+            $image=choose_image($filename);
826
+
827
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
828
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
829
+            if ($row['title'] != '') { $filename=$row['title']; }
830
+            $desc=$row['description'];
831
+
832
+            if (($myrow["path"]=='') and ($filename=='')) {
833
+                echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
834
+                return(true);
835
+            }
836
+
837
+            if ($icon == 'nolink') { return(shorten($filename,$length)); }
838
+            if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; }
839
+            if ($builder != 'builder')
840
+            {
841
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>";
842
+                if ($desc != '')
843
+                {
844
+                    if ($icon != 'wrap')
845
+                    {
846
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
847
+                    }
848
+                    else
849
+                    {
850
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
851
+                    }
852
+                } $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
853
+            }
854
+            else
855
+            {
856
+                $enableDocumentParsing='yes';
857
+                if (!$enableDocumentParsing)
858
+                { //this is the solution for the non-parsing version in the builder
859
+                    $file=urlencode($myrow["path"]);
860
+                    echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
861
+                }
862
+                else
863
+                {
864
+                    echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
865
+                }
866
+            }
867
+            break;
868
+
869
+        case "Assignments":
870
+            $name=get_lang('Assignments');
871
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
872
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
873
+            if ($row['title'] != '') { $name=$row['title']; }
874
+            $desc=$row['description'];
875
+            echo str_repeat("&nbsp;&gt;",$level);
876
+
877
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
878
+            if ($icon != 'nolink')
879
+            {
880
+                if ($completed=='completed') {
881
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
882
+                }	else {
883
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
884
+                    //echo "&nbsp;";
885
+                }
886
+            }
887
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
888
+
889
+            if ($name=='')
890
+            {
891
+                echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
892
+            }
893
+
894
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
895
+            if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; }
896
+            if ($builder != 'builder')
897
+            {
898
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
899
+                if ($desc != '')
900
+                {
901
+                    if ($icon != 'wrap')
902
+                    {
903
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
904
+                    }
905
+                    else
906
+                    {
907
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
908
+                    }
909
+                }
910
+            }
911
+            else
912
+            {
913
+                echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
914
+            }
915
+            break;
916
+        case "Dropbox":
917
+            $name=get_lang('Dropbox');
918
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
919
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
920
+            if ($row['title'] != '') { $name=$row['title']; }
921
+            $desc=$row['description'];
922
+            echo str_repeat("&nbsp;&gt;",$level);
923
+
924
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
925
+            if ($icon != 'nolink') {
926
+                if ($completed=='completed') {
927
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
928
+                }	else {
929
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
930
+                    //echo "&nbsp;";
931
+                }
932
+            }
933
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
934
+
935
+            if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
936
+
937
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
938
+            if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; }
939
+
940
+            if ($builder != 'builder')
941
+            {
942
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
943
+                if ($desc != '') {
944
+                    if ($icon != 'wrap') {
945
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
946
+                    else {
947
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
948
+                }
949
+            } else {
950
+                echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
951
+            }
952
+            break;
953
+        case "Introduction_text":
954
+            $name=get_lang('IntroductionText');
955
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
956
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
957
+            if ($row['title'] != '') { $name=$row['title']; }
958
+            $desc=$row['description'];
959
+            echo str_repeat("&nbsp;&gt;",$level);
960
+
961
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
962
+            if ($icon != 'nolink') {
963
+                if ($completed=='completed') {
964
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
965
+                }	else {
966
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
967
+                    //echo "&nbsp;";
968
+                }
969
+            }
970
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
971
+
972
+            if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
973
+
974
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
975
+            if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; }
976
+
977
+            if ($builder != 'builder')
978
+            {
979
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
980
+                $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
981
+                if ($desc != '') {
982
+                    if ($icon != 'wrap') {
983
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
984
+                    else {
985
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
986
+                }
987
+            } else {
988
+                $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
989
+                echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
990
+            }
991
+            break;
992
+        case "Course_description":
993
+            $name=get_lang('CourseDescription');
994
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
995
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
996
+            if ($row['title'] != '') { $name=$row['title']; }
997
+            $desc=$row['description'];
998
+            echo str_repeat("&nbsp;&gt;",$level);
999
+
1000
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1001
+            if ($icon != 'nolink') {
1002
+                if ($completed=='completed') {
1003
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1004
+                }	else {
1005
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1006
+                    //echo "&nbsp;";
1007
+                }
1008
+            }
1009
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1010
+
1011
+            if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1012
+
1013
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
1014
+            if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; }
1015
+
1016
+            if ($builder != 'builder')
1017
+            {
1018
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
1019
+                if ($desc != '') {
1020
+                    if ($icon != 'wrap') {
1021
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
1022
+                    else {
1023
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1024
+                }
1025
+            } else {
1026
+                $s=api_get_path(WEB_CODE_PATH)."course_description";
1027
+                echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1028
+            }
1029
+            break;
1030
+        case "Groups":
1031
+            $name=get_lang('Groups');
1032
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1033
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1034
+            if ($row['title'] != '') { $name=$row['title']; }
1035
+            $desc=$row['description'];
1036
+            echo str_repeat("&nbsp;&gt;",$level);
1037
+
1038
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1039
+            if ($icon != 'nolink') {
1040
+                if ($completed=='completed') {
1041
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1042
+                }	else {
1043
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1044
+                    //echo "&nbsp;";
1045
+                }
1046
+            }
1047
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1048
+
1049
+            if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1050
+
1051
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
1052
+            if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; }
1053
+
1054
+            if ($builder != 'builder')
1055
+            {
1056
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
1057
+                if ($desc != '') {
1058
+                    if ($icon != 'wrap') {
1059
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
1060
+                    else {
1061
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1062
+                }
1063
+            } else {
1064
+                echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1065
+            }
1066
+            break;
1067
+        case "Users":
1068
+            $name=get_lang('Users');
1069
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1070
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1071
+            if ($row['title'] != '') { $name=$row['title']; }
1072
+            $desc=$row['description'];
1073
+            echo str_repeat("&nbsp;&gt;",$level);
1074
+
1075
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1076
+            if ($icon != 'nolink') {
1077
+                if ($completed=='completed') {
1078
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1079
+                }	else {
1080
+                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1081
+                    //echo "&nbsp;";
1082
+                }
1083
+            }
1084
+            if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1085
+
1086
+            if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1087
+
1088
+            if ($icon == 'nolink') { return(shorten($name,$length)); }
1089
+            if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; }
1090
+
1091
+            if ($builder != 'builder')
1092
+            {
1093
+                echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
1094
+                if ($desc != '') {
1095
+                    if ($icon != 'wrap') {
1096
+                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
1097
+                    else {
1098
+                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1099
+                }
1100
+            } else {
1101
+                echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1102
+            }
1103
+            break;
1104
+    }//end huge switch-statement
1105 1105
 }
1106 1106
 
1107 1107
 /**
@@ -1116,168 +1116,168 @@  discard block
 block discarded – undo
1116 1116
 */
1117 1117
 function get_addedresource_link_in_learnpath($type, $id, $id_in_path)
1118 1118
 {
1119
-	global $_course, $learnpath_id, $tbl_learnpath_item, $items;
1120
-	global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid;
1121
-
1122
-	$hyperlink_target_parameter = ""; //or e.g. target='_blank'
1123
- $builder = 'player';
1124
-	$origin='learnpath';
1125
-
1126
-	$linktype=$type;
1127
-	if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; }
1128
-
1129
- $link = '';
1130
-
1131
-	switch ($type)
1132
-	{
1133
-		case "Agenda":
1134
-			$TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA);;
1135
-			$result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
1136
-			$myrow=Database::fetch_array($result);
1137
-
1138
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1139
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1140
-			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
1141
-			$desc=$row['description'];
1142
-			$agenda_id=$row['item_id'];
1143
-
1144
-			if ($builder != 'builder')
1145
-			{
1146
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
1147
-			}
1148
-			else
1149
-			{
1150
-				$link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id";
1151
-			}
1152
-			break;
1153
-
1154
-		case "Ad_Valvas":
1155
-			$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
1156
-			$result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
1157
-			$myrow=Database::fetch_array($result);
1158
-
1159
-			if ($builder != 'builder')
1160
-			{
1161
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path";
1162
-			}
1163
-			else
1164
-			{
1165
-				$link .= "../announcements/announcements.php?origin=$origin&ann_id=$id";
1166
-			}
1167
-			break;
1168
-
1169
-		case "Link" :
1170
-			$TABLETOOLLINK	= Database::get_course_table(TABLE_LINK);
1171
-			$result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
1172
-			$myrow=Database::fetch_array($result);
1173
-
1174
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1175
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1176
-
1177
-			$thelink=$myrow["url"];
1178
-			if ($builder != 'builder')
1179
-			{
1180
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
1181
-			}
1182
-			else
1183
-			{
1184
-				$link .= $thelink;
1185
-			}
1186
-			break;
1187
-
1188
-		case "Exercise":
1189
-			$TBL_EXERCICES  = Database::get_course_table(TABLE_QUIZ_TEST);
1190
-			$result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
1191
-			$myrow=Database::fetch_array($result);
1192
-
1193
-			if ($builder=='builder') { $origin='builder'; }
1194
-			  //this is needed for the exercise_submit.php can delete the session info about tests
1195
-
1196
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1197
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1198
-			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
1199
-
1200
-			if ($builder != 'builder')
1201
-			{
1202
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
1203
-			}
1204
-			else
1205
-			{
1206
-				$link .= "../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"];
1207
-			}
1208
-			break;
1209
-
1210
-		case "HotPotatoes":
1211
-	  	    $TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT);
1212
-		    $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
1213
-			$result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
1214
-		    $myrow= Database::fetch_array($result);
1215
-		    $path=$myrow["path"];
1216
-		  	$name=GetQuizName($path,$documentPath);
1217
-
1218
-			if ($builder=='builder') { $origin='builder'; }
1219
-
1220
-			$cid = $_course['official_code'];
1221
-
1222
-			if ($builder != 'builder')
1223
-			{
1224
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
1225
-			}
1226
-			else
1227
-			{
1228
-				$link .= "../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."";
1229
-			}
1230
-			break;
1231
-
1232
-		case "Forum":
1119
+    global $_course, $learnpath_id, $tbl_learnpath_item, $items;
1120
+    global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid;
1121
+
1122
+    $hyperlink_target_parameter = ""; //or e.g. target='_blank'
1123
+    $builder = 'player';
1124
+    $origin='learnpath';
1125
+
1126
+    $linktype=$type;
1127
+    if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; }
1128
+
1129
+    $link = '';
1130
+
1131
+    switch ($type)
1132
+    {
1133
+        case "Agenda":
1134
+            $TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA);;
1135
+            $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
1136
+            $myrow=Database::fetch_array($result);
1137
+
1138
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1139
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1140
+            if ($row['title'] != '') { $myrow["title"]=$row['title']; }
1141
+            $desc=$row['description'];
1142
+            $agenda_id=$row['item_id'];
1143
+
1144
+            if ($builder != 'builder')
1145
+            {
1146
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
1147
+            }
1148
+            else
1149
+            {
1150
+                $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id";
1151
+            }
1152
+            break;
1153
+
1154
+        case "Ad_Valvas":
1155
+            $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
1156
+            $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
1157
+            $myrow=Database::fetch_array($result);
1158
+
1159
+            if ($builder != 'builder')
1160
+            {
1161
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path";
1162
+            }
1163
+            else
1164
+            {
1165
+                $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id";
1166
+            }
1167
+            break;
1168
+
1169
+        case "Link" :
1170
+            $TABLETOOLLINK	= Database::get_course_table(TABLE_LINK);
1171
+            $result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
1172
+            $myrow=Database::fetch_array($result);
1173
+
1174
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1175
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1176
+
1177
+            $thelink=$myrow["url"];
1178
+            if ($builder != 'builder')
1179
+            {
1180
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
1181
+            }
1182
+            else
1183
+            {
1184
+                $link .= $thelink;
1185
+            }
1186
+            break;
1187
+
1188
+        case "Exercise":
1189
+            $TBL_EXERCICES  = Database::get_course_table(TABLE_QUIZ_TEST);
1190
+            $result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
1191
+            $myrow=Database::fetch_array($result);
1192
+
1193
+            if ($builder=='builder') { $origin='builder'; }
1194
+                //this is needed for the exercise_submit.php can delete the session info about tests
1195
+
1196
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1197
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1198
+            if ($row['title'] != '') { $myrow["title"]=$row['title']; }
1199
+
1200
+            if ($builder != 'builder')
1201
+            {
1202
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
1203
+            }
1204
+            else
1205
+            {
1206
+                $link .= "../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"];
1207
+            }
1208
+            break;
1209
+
1210
+        case "HotPotatoes":
1211
+              $TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT);
1212
+            $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
1213
+            $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
1214
+            $myrow= Database::fetch_array($result);
1215
+            $path=$myrow["path"];
1216
+                $name=GetQuizName($path,$documentPath);
1217
+
1218
+            if ($builder=='builder') { $origin='builder'; }
1219
+
1220
+            $cid = $_course['official_code'];
1221
+
1222
+            if ($builder != 'builder')
1223
+            {
1224
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
1225
+            }
1226
+            else
1227
+            {
1228
+                $link .= "../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."";
1229
+            }
1230
+            break;
1231
+
1232
+        case "Forum":
1233 1233
         //deprecated
1234
-			$TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
1235
-			$result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
1236
-			$myrow=Database::fetch_array($result);
1237
-
1238
-			if ($builder=='builder') { $origin='builder'; }
1239
-
1240
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1241
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1242
-			if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; }
1243
-
1244
-			if ($myrow["forum_name"]=='') { $type="Forum"; }
1245
-
1246
-			$forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1247
-			if ($builder != 'builder')
1248
-			{
1249
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
1250
-			}
1251
-			else
1252
-			{
1253
-				$link .= "../phpbb/viewforum.php?$forumparameters";
1254
-			}
1255
-			break;
1256
-
1257
-		case "Thread":  //forum post
1234
+            $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
1235
+            $result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
1236
+            $myrow=Database::fetch_array($result);
1237
+
1238
+            if ($builder=='builder') { $origin='builder'; }
1239
+
1240
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1241
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1242
+            if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; }
1243
+
1244
+            if ($myrow["forum_name"]=='') { $type="Forum"; }
1245
+
1246
+            $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1247
+            if ($builder != 'builder')
1248
+            {
1249
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
1250
+            }
1251
+            else
1252
+            {
1253
+                $link .= "../phpbb/viewforum.php?$forumparameters";
1254
+            }
1255
+            break;
1256
+
1257
+        case "Thread":  //forum post
1258 1258
         //deprecated
1259
-			$tbl_topics      = $_course['dbNameGlu'].'bb_topics';
1260
-			$tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
1261
-			$TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
1262
-			$sql="SELECT * FROM $tbl_topics where topic_id=$id";
1263
-			$result= Database::query($sql);
1264
-			$myrow=Database::fetch_array($result);
1265
-
1266
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1267
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1268
-
1269
-			if ($builder != 'builder')
1270
-			{
1271
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
1272
-			}
1273
-			else
1274
-			{
1275
-				$link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1276
-			}
1277
-			break;
1278
-
1279
-		case "Post":
1280
-			/* todo REVIEW THIS SECTION - NOT USING VALID TABLES ANYMORE
1259
+            $tbl_topics      = $_course['dbNameGlu'].'bb_topics';
1260
+            $tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
1261
+            $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
1262
+            $sql="SELECT * FROM $tbl_topics where topic_id=$id";
1263
+            $result= Database::query($sql);
1264
+            $myrow=Database::fetch_array($result);
1265
+
1266
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1267
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1268
+
1269
+            if ($builder != 'builder')
1270
+            {
1271
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
1272
+            }
1273
+            else
1274
+            {
1275
+                $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1276
+            }
1277
+            break;
1278
+
1279
+        case "Post":
1280
+            /* todo REVIEW THIS SECTION - NOT USING VALID TABLES ANYMORE
1281 1281
 			$tbl_posts       = $_course['dbNameGlu'].'bb_posts';
1282 1282
 			$tbl_posts_text  = $_course['dbNameGlu'].'bb_posts_text';
1283 1283
 			$TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
@@ -1308,94 +1308,94 @@  discard block
 block discarded – undo
1308 1308
 				$link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1309 1309
 			}
1310 1310
 			*/
1311
-			break;
1312
-
1313
-		case "Document":
1314
-			$dbTable  = Database::get_course_table(TABLE_DOCUMENT);
1315
-			$result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE);
1316
-			$myrow=Database::fetch_array($result);
1317
-
1318
-			$pathname=explode("/",$myrow["path"]); // making a correct name for the link
1319
-			$last=count($pathname)-1;  // making a correct name for the link
1320
-			$filename=$pathname[$last];  // making a correct name for the link
1321
-
1322
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1323
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1324
-
1325
-			if ($builder != 'builder')
1326
-			{
1327
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
1328
-
1329
-			}
1330
-			else
1331
-			{
1332
-				$enableDocumentParsing='yes';
1333
-				if (!$enableDocumentParsing)
1334
-				{ //this is the solution for the non-parsing version in the builder
1335
-					$file=urlencode($myrow["path"]);
1336
-					$link .= "../document/showinframes.php?file=$file";
1337
-				}
1338
-				else
1339
-				{
1340
-					$link .= "../document/download.php?doc_url=".$myrow["path"];
1341
-				}
1342
-			}
1343
-			break;
1344
-
1345
-		case "Assignments":
1346
-			if ($builder != 'builder')
1347
-			{
1348
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
1349
-			}
1350
-			else
1351
-			{
1352
-				$link .= "../work/work.php";
1353
-			}
1354
-			break;
1355
-		case "Dropbox":
1356
-			if ($builder != 'builder')
1357
-			{
1358
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
1359
-			} else {
1360
-				$link .= "../dropbox/index.php";
1361
-			}
1362
-			break;
1363
-		case "Introduction_text":
1364
-			if ($builder != 'builder')
1365
-			{
1366
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
1367
-			} else {
1368
-				$s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
1369
-				$link .= $s;
1370
-			}
1371
-			break;
1372
-		case "Course_description":
1373
-			if ($builder != 'builder')
1374
-			{
1375
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
1376
-			} else {
1377
-				$s=api_get_path(WEB_CODE_PATH)."course_description";
1378
-				$link .= $s;
1379
-			}
1380
-			break;
1381
-		case "Groups":
1382
-
1383
-			if ($builder != 'builder')
1384
-			{
1385
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
1386
-			} else {
1387
-				$link .= "../group/group.php?origin=$origin";
1388
-			}
1389
-			break;
1390
-		case "Users":
1391
-			if ($builder != 'builder')
1392
-			{
1393
-				$link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
1394
-			} else {
1395
-				$link .= "../user/user.php?origin=$origin";
1396
-			}
1397
-			break;
1398
-	}//end huge switch-statement
1311
+            break;
1312
+
1313
+        case "Document":
1314
+            $dbTable  = Database::get_course_table(TABLE_DOCUMENT);
1315
+            $result=Database::query("SELECT * FROM $dbTable WHERE id=$id",__FILE__,__LINE);
1316
+            $myrow=Database::fetch_array($result);
1317
+
1318
+            $pathname=explode("/",$myrow["path"]); // making a correct name for the link
1319
+            $last=count($pathname)-1;  // making a correct name for the link
1320
+            $filename=$pathname[$last];  // making a correct name for the link
1321
+
1322
+            $sql="select * from $tbl_learnpath_item where id=$id_in_path";
1323
+            $result=Database::query($sql);	$row=Database::fetch_array($result);
1324
+
1325
+            if ($builder != 'builder')
1326
+            {
1327
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
1328
+
1329
+            }
1330
+            else
1331
+            {
1332
+                $enableDocumentParsing='yes';
1333
+                if (!$enableDocumentParsing)
1334
+                { //this is the solution for the non-parsing version in the builder
1335
+                    $file=urlencode($myrow["path"]);
1336
+                    $link .= "../document/showinframes.php?file=$file";
1337
+                }
1338
+                else
1339
+                {
1340
+                    $link .= "../document/download.php?doc_url=".$myrow["path"];
1341
+                }
1342
+            }
1343
+            break;
1344
+
1345
+        case "Assignments":
1346
+            if ($builder != 'builder')
1347
+            {
1348
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
1349
+            }
1350
+            else
1351
+            {
1352
+                $link .= "../work/work.php";
1353
+            }
1354
+            break;
1355
+        case "Dropbox":
1356
+            if ($builder != 'builder')
1357
+            {
1358
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
1359
+            } else {
1360
+                $link .= "../dropbox/index.php";
1361
+            }
1362
+            break;
1363
+        case "Introduction_text":
1364
+            if ($builder != 'builder')
1365
+            {
1366
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
1367
+            } else {
1368
+                $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
1369
+                $link .= $s;
1370
+            }
1371
+            break;
1372
+        case "Course_description":
1373
+            if ($builder != 'builder')
1374
+            {
1375
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
1376
+            } else {
1377
+                $s=api_get_path(WEB_CODE_PATH)."course_description";
1378
+                $link .= $s;
1379
+            }
1380
+            break;
1381
+        case "Groups":
1382
+
1383
+            if ($builder != 'builder')
1384
+            {
1385
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
1386
+            } else {
1387
+                $link .= "../group/group.php?origin=$origin";
1388
+            }
1389
+            break;
1390
+        case "Users":
1391
+            if ($builder != 'builder')
1392
+            {
1393
+                $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
1394
+            } else {
1395
+                $link .= "../user/user.php?origin=$origin";
1396
+            }
1397
+            break;
1398
+    }//end huge switch-statement
1399 1399
     return $link;
1400 1400
 }
1401 1401
 
@@ -1404,12 +1404,12 @@  discard block
 block discarded – undo
1404 1404
 */
1405 1405
 function remove_resource($resource_key)
1406 1406
 {
1407
-	$addedresource = $_SESSION['addedresource'];
1408
-	$addedresourceid = $_SESSION['addedresourceid'];
1409
-	unset($addedresource[$resource_key]);
1410
-	unset($addedresourceid[$resource_key]);
1411
-	$_SESSION['addedresource']=$addedresource;
1412
-	$_SESSION['addedresourceid']=$addedresourceid ;
1407
+    $addedresource = $_SESSION['addedresource'];
1408
+    $addedresourceid = $_SESSION['addedresourceid'];
1409
+    unset($addedresource[$resource_key]);
1410
+    unset($addedresourceid[$resource_key]);
1411
+    $_SESSION['addedresource']=$addedresource;
1412
+    $_SESSION['addedresourceid']=$addedresourceid ;
1413 1413
 }
1414 1414
 
1415 1415
 /**
@@ -1418,8 +1418,8 @@  discard block
 block discarded – undo
1418 1418
 */
1419 1419
 function show_addresource_button($additionalparameters = '')
1420 1420
 {
1421
-	global $charset;
1422
-	echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />';
1421
+    global $charset;
1422
+    echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(get_lang('Attachment'), ENT_QUOTES, $charset).'" '.$additionalparameters.' />';
1423 1423
 }
1424 1424
 
1425 1425
 /**
@@ -1441,11 +1441,11 @@  discard block
 block discarded – undo
1441 1441
 */
1442 1442
 function delete_added_resource($type, $id)
1443 1443
 {
1444
-	global $_course;
1445
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1444
+    global $_course;
1445
+    $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1446 1446
 
1447
-	$sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1448
-	Database::query($sql);
1447
+    $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1448
+    Database::query($sql);
1449 1449
 }
1450 1450
 
1451 1451
 /**
@@ -1454,12 +1454,12 @@  discard block
 block discarded – undo
1454 1454
 */
1455 1455
 function delete_all_resources_type($type)
1456 1456
 {
1457
-  global $_course;
1458
-  $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1457
+    global $_course;
1458
+    $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1459 1459
 
1460
-  $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type'";
1460
+    $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type'";
1461 1461
 
1462
-  Database::query($sql);
1462
+    Database::query($sql);
1463 1463
 }
1464 1464
 
1465 1465
 /**
@@ -1467,15 +1467,15 @@  discard block
 block discarded – undo
1467 1467
 */
1468 1468
 function check_added_resources($type, $id)
1469 1469
 {
1470
-	global $_course, $origin;
1471
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1472
-	$sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1473
-	$result=Database::query($sql);
1474
-	$number_added=Database::num_rows($result);
1475
-	if ($number_added<>0)
1476
-		return true;
1477
-	else
1478
-		return false;
1470
+    global $_course, $origin;
1471
+    $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1472
+    $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1473
+    $result=Database::query($sql);
1474
+    $number_added=Database::num_rows($result);
1475
+    if ($number_added<>0)
1476
+        return true;
1477
+    else
1478
+        return false;
1479 1479
 }
1480 1480
 
1481 1481
 
@@ -1485,18 +1485,18 @@  discard block
 block discarded – undo
1485 1485
 */
1486 1486
 function edit_added_resources($type, $id)
1487 1487
 {
1488
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1488
+    $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1489 1489
     $course_id = api_get_course_int_id();
1490 1490
     $id = intval($id);
1491 1491
     $type = Database::escape_string($type);
1492
-	$sql="SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id=$id";
1493
-	$result=Database::query($sql);
1494
-	while ($row=Database::fetch_array($result))	{
1495
-		$addedresource[]=$row["resource_type"];
1496
-		$addedresourceid[]=$row["resource_id"];
1497
-	}
1498
-	$_SESSION['addedresource']=$addedresource;
1499
-	$_SESSION['addedresourceid']=$addedresourceid;
1492
+    $sql="SELECT * FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' and source_id=$id";
1493
+    $result=Database::query($sql);
1494
+    while ($row=Database::fetch_array($result))	{
1495
+        $addedresource[]=$row["resource_type"];
1496
+        $addedresourceid[]=$row["resource_id"];
1497
+    }
1498
+    $_SESSION['addedresource']=$addedresource;
1499
+    $_SESSION['addedresourceid']=$addedresourceid;
1500 1500
 }
1501 1501
 
1502 1502
 /**
@@ -1506,20 +1506,20 @@  discard block
 block discarded – undo
1506 1506
 */
1507 1507
 function update_added_resources($type, $id)
1508 1508
 {
1509
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1509
+    $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1510 1510
     $course_id = api_get_course_int_id();
1511 1511
     $id = intval($id);
1512 1512
     $type = Database::escape_string($type);
1513
-	// delete all the added resources for this item in the database;
1514
-	$sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'";
1515
-	//echo $sql;
1516
-	Database::query($sql);
1513
+    // delete all the added resources for this item in the database;
1514
+    $sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'";
1515
+    //echo $sql;
1516
+    Database::query($sql);
1517 1517
 
1518
-	// store the resources from the session into the database
1519
-	store_resources($type, $id);
1518
+    // store the resources from the session into the database
1519
+    store_resources($type, $id);
1520 1520
 
1521
-	//delete_added_resource_($type, $id);
1522
-	unset_session_resources();
1521
+    //delete_added_resource_($type, $id);
1522
+    unset_session_resources();
1523 1523
 }
1524 1524
 
1525 1525
 /**
@@ -1527,25 +1527,25 @@  discard block
 block discarded – undo
1527 1527
 */
1528 1528
 function display_added_resources($type, $id, $style='')
1529 1529
 {
1530
-	// the array containing the icons
1531
-	$arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' );
1532
-
1533
-	global $_course, $origin;
1534
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1535
-
1536
-	$sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1537
-	$result=Database::query($sql);
1538
-	while ($row=Database::fetch_array($result))
1539
-	{
1540
-		if ($origin != 'learnpath')
1541
-		{
1542
-			display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ;
1543
-		}
1544
-		else
1545
-		{
1546
-			display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>";
1547
-		}
1548
-	}
1530
+    // the array containing the icons
1531
+    $arr_icons=array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif' );
1532
+
1533
+    global $_course, $origin;
1534
+    $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1535
+
1536
+    $sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1537
+    $result=Database::query($sql);
1538
+    while ($row=Database::fetch_array($result))
1539
+    {
1540
+        if ($origin != 'learnpath')
1541
+        {
1542
+            display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ;
1543
+        }
1544
+        else
1545
+        {
1546
+            display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>";
1547
+        }
1548
+    }
1549 1549
 }
1550 1550
 
1551 1551
 
@@ -1556,15 +1556,15 @@  discard block
 block discarded – undo
1556 1556
 */
1557 1557
 function display_resources($showdeleteimg)
1558 1558
 {
1559
-	global $action;
1560
-	global $resourceaction;
1561
-	global $id;
1562
-	global $locationkey;
1563
-	global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
1564
-
1565
-	if ($resourceaction=="removeresource")
1566
-	{
1567
-		/* unneccessary because when editing we delete all the added resources from the
1559
+    global $action;
1560
+    global $resourceaction;
1561
+    global $id;
1562
+    global $locationkey;
1563
+    global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
1564
+
1565
+    if ($resourceaction=="removeresource")
1566
+    {
1567
+        /* unneccessary because when editing we delete all the added resources from the
1568 1568
 		database and add all these from the session
1569 1569
 		if ($action=="edit") // we have an edit and thus we delete from the database and from the session
1570 1570
 		{
@@ -1580,47 +1580,47 @@  discard block
 block discarded – undo
1580 1580
 		}
1581 1581
 		else // we remove from the session
1582 1582
 		{*/
1583
-		//echo "remove from session";
1584
-		remove_resource($locationkey);
1585
-	}
1586
-	$addedresource=$_SESSION['addedresource'];
1587
-	$addedresourceid=$_SESSION['addedresourceid'];
1588
-	if (is_array($addedresource))
1589
-	{
1590
-		echo '<table>';
1591
-		foreach ($addedresource as $resource)
1592
-		{
1593
-			//echo $resource.":".$addedresourceid[key($addedresource)];
1594
-			echo '<tr><td>';
1595
-			display_addedresource_link($resource,$addedresourceid[key($addedresource)]);
1596
-			echo '</td><td width="30">';
1597
-
1598
-			// if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource
1599
-			// should also contain this id.
1600
-			$test=parse_url($_SERVER['REQUEST_URI']);
1601
-			$output = array();
1602
-			parse_str($test['query'],$output);
1603
-
1604
-			if ($showdeleteimg==1)
1605
-			{
1606
-				//if (strstr($_SERVER['REQUEST_URI'],"?id="))
1607
-				//	{ echo " <a href='".api_get_self()."?id=".$output['id']."&amp;"; }
1608
-				//else
1609
-				//	{ echo " <a href='".api_get_self()."?"; }
1610
-				//action=$action&id=$id&
1611
-				//echo "action=$action&amp;id=$id&amp;originalresource=no&amp;resourceaction=removeresource&amp;key=".key($addedresource)."'><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />";
1612
-				echo "<a href=".api_get_self()."?showresources=true&amp;source_forum=".$_GET['source_forum']."&amp;resourceaction=removeresource&amp;locationkey=".key($addedresource)."&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />";
1613
-			}
1614
-			echo '</td></tr>';
1615
-			next($addedresource);
1616
-			//$_SESSION['edit']=='';
1617
-		}
1618
-		echo '</table>';
1619
-	}
1620
-	else // it is a string
1621
-	{
1622
-		echo '';
1623
-	}
1583
+        //echo "remove from session";
1584
+        remove_resource($locationkey);
1585
+    }
1586
+    $addedresource=$_SESSION['addedresource'];
1587
+    $addedresourceid=$_SESSION['addedresourceid'];
1588
+    if (is_array($addedresource))
1589
+    {
1590
+        echo '<table>';
1591
+        foreach ($addedresource as $resource)
1592
+        {
1593
+            //echo $resource.":".$addedresourceid[key($addedresource)];
1594
+            echo '<tr><td>';
1595
+            display_addedresource_link($resource,$addedresourceid[key($addedresource)]);
1596
+            echo '</td><td width="30">';
1597
+
1598
+            // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource
1599
+            // should also contain this id.
1600
+            $test=parse_url($_SERVER['REQUEST_URI']);
1601
+            $output = array();
1602
+            parse_str($test['query'],$output);
1603
+
1604
+            if ($showdeleteimg==1)
1605
+            {
1606
+                //if (strstr($_SERVER['REQUEST_URI'],"?id="))
1607
+                //	{ echo " <a href='".api_get_self()."?id=".$output['id']."&amp;"; }
1608
+                //else
1609
+                //	{ echo " <a href='".api_get_self()."?"; }
1610
+                //action=$action&id=$id&
1611
+                //echo "action=$action&amp;id=$id&amp;originalresource=no&amp;resourceaction=removeresource&amp;key=".key($addedresource)."'><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />";
1612
+                echo "<a href=".api_get_self()."?showresources=true&amp;source_forum=".$_GET['source_forum']."&amp;resourceaction=removeresource&amp;locationkey=".key($addedresource)."&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />";
1613
+            }
1614
+            echo '</td></tr>';
1615
+            next($addedresource);
1616
+            //$_SESSION['edit']=='';
1617
+        }
1618
+        echo '</table>';
1619
+    }
1620
+    else // it is a string
1621
+    {
1622
+        echo '';
1623
+    }
1624 1624
 } // end of the display_resources function
1625 1625
 
1626 1626
 
@@ -1632,49 +1632,49 @@  discard block
 block discarded – undo
1632 1632
 */
1633 1633
 function showorhide_addresourcelink($type, $id)
1634 1634
 {
1635
-	global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
1636
-	//global $_SESSION['addresource'];
1637
-	//global $_SESSION['addresourceid'];
1638
-	$addedresource=$_SESSION['addedresource'];
1639
-	$addedresourceid=$_SESSION['addedresourceid'];
1640
-
1641
-	if (is_array($_SESSION['addedresource']))
1642
-	{
1643
-		foreach ($addedresource as $toolcompare)
1644
-		{
1645
-			//echo $toolcompare;
1646
-			//echo "/".$type."/".$id."****";
1647
-			//$key=key($addedresource);
1648
-			//echo $addedresourceid[$key];
1649
-			//print_r($addedresourceid);
1650
-			//echo "<br>";
1651
-
1652
-			if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id)
1653
-			{
1654
-				$show=0;
1655
-			}
1656
-			next($addedresource);
1657
-		}
1658
-		if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1659
-		if ($show!==0)
1660
-		{
1661
-			if ($type=="Document")
1662
-			{
1663
-				echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>";
1664
-			}
1665
-			else
1666
-			{
1667
-				echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
1668
-			}
1669
-		}
1670
-	}
1671
-	else // if it is not an array, it is a string
1672
-	{
1673
-		if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id)
1674
-		{
1675
-			if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1676
-			echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
1677
-		}
1678
-	}
1635
+    global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
1636
+    //global $_SESSION['addresource'];
1637
+    //global $_SESSION['addresourceid'];
1638
+    $addedresource=$_SESSION['addedresource'];
1639
+    $addedresourceid=$_SESSION['addedresourceid'];
1640
+
1641
+    if (is_array($_SESSION['addedresource']))
1642
+    {
1643
+        foreach ($addedresource as $toolcompare)
1644
+        {
1645
+            //echo $toolcompare;
1646
+            //echo "/".$type."/".$id."****";
1647
+            //$key=key($addedresource);
1648
+            //echo $addedresourceid[$key];
1649
+            //print_r($addedresourceid);
1650
+            //echo "<br>";
1651
+
1652
+            if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id)
1653
+            {
1654
+                $show=0;
1655
+            }
1656
+            next($addedresource);
1657
+        }
1658
+        if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1659
+        if ($show!==0)
1660
+        {
1661
+            if ($type=="Document")
1662
+            {
1663
+                echo "<a href=".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>";
1664
+            }
1665
+            else
1666
+            {
1667
+                echo "<a href='".api_get_self()."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
1668
+            }
1669
+        }
1670
+    }
1671
+    else // if it is not an array, it is a string
1672
+    {
1673
+        if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id)
1674
+        {
1675
+            if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1676
+            echo "<a href='".api_get_self()."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
1677
+        }
1678
+    }
1679 1679
 }
1680 1680
 ?>
Please login to merge, or discard this patch.