Completed
Push — 1.10.x ( 2be62b...254ea6 )
by Angel Fernando Quiroz
133:23 queued 88:52
created
main/resourcelinker/resourcelinker.inc.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -338,6 +338,10 @@
 block discarded – undo
338 338
 * @param icon        - if ="icon" then the small icon will appear
339 339
 *                      if ="wrap" then wrapped settings are used (and no icon is displayed)
340 340
 *                      if ="nolink" then only the name is returned with no href and no icon (note:only in this case, the result is not displayed, but returned)
341
+* @param string $completed
342
+* @param string $id_in_path
343
+* @param string $builder
344
+* @param string $icon
341 345
 * @todo this function is too long, rewrite
342 346
 */
343 347
 function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0)
Please login to merge, or discard this patch.
Spacing   +408 added lines, -408 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 */
25 25
 
26 26
 function unset_session_resources() {
27
-	$_SESSION['addedresource']='';
28
-	$_SESSION['addedresourceid']='';
27
+	$_SESSION['addedresource'] = '';
28
+	$_SESSION['addedresourceid'] = '';
29 29
 	Session::erase('addedresource');
30 30
 	Session::erase('addedresourceid');
31 31
 }
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	if ($level and $level != 0 and $level != 1)
48 48
 	{
49
-		$folder_up=$folder;
50
-		$folder_temp=explode('/',$folder);
51
-		$last=count($folder_temp)-1;
49
+		$folder_up = $folder;
50
+		$folder_temp = explode('/', $folder);
51
+		$last = count($folder_temp) - 1;
52 52
 		unset($folder_temp[$last]);
53
-		$folder_up=implode('/',$folder_temp);
53
+		$folder_up = implode('/', $folder_temp);
54 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 55
 	}
56 56
 }
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	// other tools do not have this feature. This only counts
69 69
 	if (api_is_allowed_to_edit())
70 70
 	{
71
-		$visibility="ip.visibility<>'2'";
71
+		$visibility = "ip.visibility<>'2'";
72 72
 	}
73 73
 	else
74 74
 	{
75
-		$visibility="ip.visibility='1'";
75
+		$visibility = "ip.visibility='1'";
76 76
 	}
77 77
 
78 78
 	$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
@@ -85,12 +85,12 @@  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))
88
+	$result = Database::query($sql);
89
+	while ($row = Database::fetch_array($result))
90 90
 	{
91 91
 		if (!$folder)
92 92
 		{
93
-			if (get_levels($row['path'])-1==1)
93
+			if (get_levels($row['path']) - 1 == 1)
94 94
 			{
95 95
 				// showing the right icon
96 96
 				if (file_or_folder($row['path']))
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 				if (file_or_folder($row['path']))
108 108
 				{
109 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 />';
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 111
 				}
112 112
 				else
113 113
 				{
114
-					echo substr($row['path'],1).' ';
115
-					echo showorhide_addresourcelink('Document',$row['id']);
114
+					echo substr($row['path'], 1).' ';
115
+					echo showorhide_addresourcelink('Document', $row['id']);
116 116
 					echo '<br />';
117 117
 				}
118 118
 			}
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 		{
122 122
 			// we calculate the level we are in by using the $folder in the url
123 123
 			// we put +1 because it does not start with an / and in the database it does
124
-			$level=get_levels($folder)+1;
124
+			$level = get_levels($folder) + 1;
125 125
 
126 126
 			// we calculate each level of the database entry
127
-			$file_level=get_levels($row['path'])-1;
127
+			$file_level = get_levels($row['path']) - 1;
128 128
 			// if the level of the database entry is equal to the level we ar in, we put it into an array
129 129
 			// as this is a potential good entry
130
-			if ($file_level==$level)
130
+			if ($file_level == $level)
131 131
 			{
132
-				$good_paths[]=$row['path'];
133
-				$good_ids[]=$row['id'];
132
+				$good_paths[] = $row['path'];
133
+				$good_ids[] = $row['id'];
134 134
 			}
135 135
 			//$haystack=$row['path'];
136 136
 			//$conform_folder=strstr($haystack, $folder);
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 		// we have all the potential good database entries, the good ones are those that start with $folder
150 150
 		foreach ($good_paths as $path)
151 151
 		{
152
-			if (strstr($path,$folder))
152
+			if (strstr($path, $folder))
153 153
 			{
154
-				$good_key=key($good_paths);
154
+				$good_key = key($good_paths);
155 155
 				// showing the right icon
156 156
 				if (file_or_folder($path))
157 157
 				{
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
 				// folders should be clickable
167 167
 				if (file_or_folder($path))
168 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);
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 172
 					//using the correct name of the folder
173
-					$folder_name=str_replace($folder.'/','',$path);
173
+					$folder_name = str_replace($folder.'/', '', $path);
174 174
 					echo "<a href='$newuri'>".$folder_name.'</a><br />';
175 175
 				}
176 176
 				else
177 177
 				{
178
-					echo str_replace("/$folder/", '',$path).' ';
179
-					echo showorhide_addresourcelink('Document',$good_ids[$good_key]);
178
+					echo str_replace("/$folder/", '', $path).' ';
179
+					echo showorhide_addresourcelink('Document', $good_ids[$good_key]);
180 180
 					echo '<br />';
181 181
 				}
182 182
 			}
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 	{
220 220
 		foreach ($addedresource as $resource_type)
221 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)]."')";
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 223
 			Database::query($sql);
224
-			$i=key($addedresource);
224
+			$i = key($addedresource);
225 225
 			next($addedresource);
226 226
 		}
227
-		$_SESSION['addedresource']='';
228
-		$_SESSION['addedresourceid']='';
227
+		$_SESSION['addedresource'] = '';
228
+		$_SESSION['addedresourceid'] = '';
229 229
 	}
230 230
 }
231 231
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  * @param $style this is used to style the link (for instance when a resource is hidden => the added resources should also be styled like they are hidden)
239 239
  * @todo use the constants for the type definitions.
240 240
  */
241
-function display_addedresource_link($type, $id, $style='')
241
+function display_addedresource_link($type, $id, $style = '')
242 242
 {
243 243
 	global $_course;
244 244
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 			break;
284 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';
286
+			$tbl_posts = $_course['dbNameGlu'].'bb_posts';
287
+			$tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
288
+			$TBL_FORUMS = $_course['dbNameGlu'].'bb_forums';
289 289
 			$result = Database::query("SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id");
290 290
 			$myrow = Database::fetch_array($result);
291 291
 			// grabbing the title of the post
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 			$dbTable = Database::get_course_table(TABLE_DOCUMENT);
308 308
 			$result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id");
309 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
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 313
 			$image = choose_image($filename);
314
-			$ext = explode('.',$filename);
315
-			$ext = strtolower($ext[sizeof($ext)-1]);
314
+			$ext = explode('.', $filename);
315
+			$ext = strtolower($ext[sizeof($ext) - 1]);
316 316
 			$myrow['path'] = rawurlencode($myrow['path']);
317
-			$in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png'));
317
+			$in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
318 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 319
 			break;
320 320
 		case 'Externallink':
@@ -349,391 +349,391 @@  discard block
 block discarded – undo
349 349
 
350 350
 	$length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
351 351
 
352
-	if ($builder != 'builder') $origin = 'learnpath';	//origin = learnpath in student view
352
+	if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view
353 353
 	$linktype = $type;
354 354
 	if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';
355 355
 
356 356
 	switch ($type)
357 357
 	{
358 358
 		case "Agenda":
359
-			$TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA);
359
+			$TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
360 360
 			$result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
361
-			$myrow=Database::fetch_array($result);
361
+			$myrow = Database::fetch_array($result);
362 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);
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 369
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
370 370
 			if ($icon != 'nolink')
371 371
 			{
372
-				if ($completed=='completed') {
372
+				if ($completed == 'completed') {
373 373
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
374
-				}	else {
374
+				} else {
375 375
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
376 376
 					//echo "&nbsp;";
377 377
 				}
378 378
 			}
379 379
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
380 380
 
381
-			if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
381
+			if ($myrow["title"] == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
382 382
 
383
-			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
383
+			if ($icon == 'nolink') { return(shorten($myrow["title"], $length)); }
384 384
 			if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; }
385 385
 			if ($builder != 'builder')
386 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";
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 389
 				if ($desc != '')
390 390
 				{
391 391
 					if ($icon != 'wrap')
392 392
 					{
393
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
393
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
394 394
 					}
395 395
 					else
396 396
 					{
397
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
397
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
398 398
 					}
399 399
 				}
400 400
 			}
401 401
 			else
402 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>";
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 404
 			}
405 405
 			break;
406 406
 
407 407
 		case "Ad_Valvas":
408 408
 			$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
409 409
 			$result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
410
-			$myrow=Database::fetch_array($result);
410
+			$myrow = Database::fetch_array($result);
411 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);
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 418
 
419 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'];
420
+			list($title, $text) = split('<br>', $myrow['content']);
421
+			if ($title == '') { $title = $myrow['content']; }
422
+			$title = $myrow['title'];
423
+			$text = $myrow['content'];
424 424
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
425 425
 			if ($icon != 'nolink')
426 426
 			{
427
-				if ($completed=='completed') {
427
+				if ($completed == 'completed') {
428 428
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
429
-				}	else {
429
+				} else {
430 430
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
431 431
 					//echo "&nbsp;";
432 432
 				}
433 433
 			}
434 434
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
435 435
 
436
-			if ($title=='') {
437
-				$type="Announcement";
436
+			if ($title == '') {
437
+				$type = "Announcement";
438 438
 				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
439 439
 				return(true);
440 440
 			}
441 441
 
442
-			if ($icon == 'nolink') { return(shorten($title,$length)); }
442
+			if ($icon == 'nolink') { return(shorten($title, $length)); }
443 443
 			if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; }
444 444
 			if ($builder != 'builder')
445 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";
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 448
 				if ($desc != '')
449 449
 				{
450 450
 					if ($icon != 'wrap')
451 451
 					{
452
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
452
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
453 453
 					}
454 454
 					else
455 455
 					{
456
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
456
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
457 457
 					}
458 458
 				}
459 459
 			}
460 460
 			else
461 461
 			{
462
-				echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>";
462
+				echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title, ($length - 3 * $level))."</a>";
463 463
 			}
464 464
 			break;
465 465
 
466 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);
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 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);
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 476
 
477 477
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
478 478
 			if ($icon != 'nolink')
479 479
 			{
480
-				if ($completed=='completed') {
480
+				if ($completed == 'completed') {
481 481
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
482
-				}	else {
482
+				} else {
483 483
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
484 484
 					//echo "&nbsp;";
485 485
 				}
486 486
 			}
487 487
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
488 488
 
489
-			if ($myrow["title"]=='')
489
+			if ($myrow["title"] == '')
490 490
 			{
491 491
 				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
492 492
 				return(true);
493 493
 			}
494 494
 
495
-			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
495
+			if ($icon == 'nolink') { return(shorten($myrow["title"], $length)); }
496 496
 			if ($icon == 'icon')
497 497
 			{
498
-				if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
498
+				if ($linktype == 'Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
499 499
 				   else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
500 500
 			}
501
-			$thelink=$myrow["url"];
501
+			$thelink = $myrow["url"];
502 502
 			if ($builder != 'builder')
503 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";
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 506
 				if ($desc != '')
507 507
 				{
508 508
 					if ($icon != 'wrap')
509 509
 					{
510
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
510
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
511 511
 					}
512 512
 					else
513 513
 					{
514
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
514
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
515 515
 					}
516 516
 				}
517 517
 			}
518 518
 			else
519 519
 			{
520
-				echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
520
+				echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"], ($length - 3 * $level))."</a>";
521 521
 			}
522 522
 			break;
523 523
 
524 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);
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 528
 
529
-			if ($builder=='builder') { $origin='builder'; }
529
+			if ($builder == 'builder') { $origin = 'builder'; }
530 530
 			  //this is needed for the exercise_submit.php can delete the session info about tests
531 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);
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 537
 
538 538
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
539 539
 			if ($icon != 'nolink')
540 540
 			{
541
-				if ($completed=='completed') {
541
+				if ($completed == 'completed') {
542 542
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
543
-				}	else {
543
+				} else {
544 544
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
545 545
 					//echo "&nbsp;";
546 546
 				}
547 547
 			}
548 548
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
549 549
 
550
-			if ($myrow["title"]=='') {
550
+			if ($myrow["title"] == '') {
551 551
 				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
552 552
 				return(true);
553 553
 			}
554 554
 
555
-			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
555
+			if ($icon == 'nolink') { return(shorten($myrow["title"], $length)); }
556 556
 			if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; }
557 557
 			if ($builder != 'builder')
558 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";
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 561
 				if ($desc != '')
562 562
 				{
563 563
 					if ($icon != 'wrap')
564 564
 					{
565
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
565
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
566 566
 					}
567 567
 					else
568 568
 					{
569
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
569
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
570 570
 					}
571 571
 				}
572 572
 			}
573 573
 			else
574 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>";
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 576
 			}
577 577
 			break;
578 578
 
579 579
 		case "HotPotatoes":
580
-			$TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT);
581
-			$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
580
+			$TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
581
+			$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
582 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);
583
+			$myrow = Database::fetch_array($result);
584
+			$path = $myrow["path"];
585
+			$name = GetQuizName($path, $documentPath);
586 586
 
587
-			if ($builder=='builder') { $origin='builder'; }
587
+			if ($builder == 'builder') { $origin = 'builder'; }
588 588
 			  //this is needed for the exercise_submit.php can delete the session info about tests
589 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);
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 595
 
596 596
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
597 597
 			if ($icon != 'nolink')
598 598
 			{
599
-				if ($completed=='completed') {
599
+				if ($completed == 'completed') {
600 600
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
601
-				}	else {
601
+				} else {
602 602
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
603 603
 					//echo "&nbsp;";
604 604
 				}
605 605
 			}
606 606
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
607 607
 
608
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
608
+			if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
609 609
 
610
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
610
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
611 611
 			if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; }
612 612
 
613 613
 			$cid = $_course['official_code'];
614 614
 
615 615
 			if ($builder != 'builder')
616 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";
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 619
 				if ($desc != '')
620 620
 				{
621 621
 					if ($icon != 'wrap')
622 622
 					{
623
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
623
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
624 624
 					}
625 625
 					else
626 626
 					{
627
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
627
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
628 628
 					}
629 629
 				}
630 630
 			}
631 631
 			else
632 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>";
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 634
 			}
635 635
 			break;
636 636
 
637 637
 		case "Forum":
638 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);
639
+			$result = Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
640
+			$myrow = Database::fetch_array($result);
641 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);
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 647
 
648 648
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
649 649
 			if ($icon != 'nolink')
650 650
 			{
651
-				if ($completed=='completed') {
651
+				if ($completed == 'completed') {
652 652
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
653
-				}	else {
653
+				} else {
654 654
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
655 655
 					//echo "&nbsp;";
656 656
 				}
657 657
 			}
658 658
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
659 659
 
660
-			if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
660
+			if ($myrow["forum_name"] == '') { $type = "Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
661 661
 
662
-			if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); }
662
+			if ($icon == 'nolink') { return(shorten($myrow["forum_name"], $length)); }
663 663
 			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
664
-			$forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
664
+			$forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
665 665
 			if ($builder != 'builder')
666 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";
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 669
 				if ($desc != '')
670 670
 				{
671 671
 					if ($icon != 'wrap')
672 672
 					{
673
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
673
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
674 674
 					}
675 675
 					else
676 676
 					{
677
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
677
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
678 678
 					}
679 679
 				}
680 680
 			}
681 681
 			else
682 682
 			{
683
-				echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
683
+				echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"], ($length - 3 * $level))."</a>";
684 684
 			}
685 685
 			break;
686 686
 
687 687
 		case "Thread":  //forum post
688 688
         //deprecated
689
-			$tbl_topics      = $_course['dbNameGlu'].'bb_topics';
690
-			$tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
689
+			$tbl_topics = $_course['dbNameGlu'].'bb_topics';
690
+			$tbl_posts = $_course['dbNameGlu'].'bb_posts';
691 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);
692
+			$sql = "SELECT * FROM $tbl_topics where topic_id=$id";
693
+			$result = Database::query($sql);
694
+			$myrow = Database::fetch_array($result);
695 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);
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 701
 
702 702
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
703 703
 			if ($icon != 'nolink')
704 704
 			{
705
-				if ($completed=='completed') {
705
+				if ($completed == 'completed') {
706 706
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
707
-				}	else {
707
+				} else {
708 708
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
709 709
 					//echo "&nbsp;";
710 710
 				}
711 711
 			}
712 712
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
713 713
 
714
-			if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
714
+			if ($myrow["topic_title"] == '') { $type = "Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
715 715
 
716
-			if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); }
716
+			if ($icon == 'nolink') { return(shorten($myrow["topic_title"], $length)); }
717 717
 			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
718 718
 			if ($builder != 'builder')
719 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";
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 722
 				if ($desc != '')
723 723
 				{
724 724
 					if ($icon != 'wrap')
725 725
 					{
726
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
726
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
727 727
 					}
728 728
 					else
729 729
 					{
730
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
730
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
731 731
 					}
732 732
 				}
733 733
 			}
734 734
 			else
735 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>";
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 737
 			}
738 738
 			break;
739 739
 
@@ -742,363 +742,363 @@  discard block
 block discarded – undo
742 742
 			$tbl_posts       = $_course['dbNameGlu'].'bb_posts';
743 743
 			$tbl_posts_text  = $_course['dbNameGlu'].'bb_posts_text';
744 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);
745
+			$result = Database::query("SELECT * FROM $tbl_posts where post_id=$id");
746
+			$myrow = Database::fetch_array($result);
747 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);
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 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);
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 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);
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 762
 
763 763
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
764 764
 			if ($icon != 'nolink')
765 765
 			{
766
-				if ($completed=='completed') {
766
+				if ($completed == 'completed') {
767 767
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
768
-				}	else {
768
+				} else {
769 769
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
770 770
 					//echo "&nbsp;";
771 771
 				}
772 772
 			}
773 773
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
774 774
 
775
-			if ($myrow_titel["post_title"]=='')
775
+			if ($myrow_titel["post_title"] == '')
776 776
 			{
777
-				$type="Forum";
777
+				$type = "Forum";
778 778
 				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
779 779
 			}
780 780
 
781
-			if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); }
781
+			if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"], $length)); }
782 782
 			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
783 783
 			if ($builder != 'builder')
784 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";
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 786
 				if ($desc != '')
787 787
 				{
788 788
 					if ($icon != 'wrap')
789 789
 					{
790
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
790
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
791 791
 					}
792 792
 					else
793 793
 					{
794
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
794
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
795 795
 					}
796 796
 				}
797 797
 			}
798 798
 			else
799 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>";
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 801
 			}
802 802
 			break;
803 803
 
804 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);
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 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
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 812
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
813 813
 
814
-			echo str_repeat("&nbsp;&gt;",$level);
814
+			echo str_repeat("&nbsp;&gt;", $level);
815 815
 
816 816
 			if ($icon != 'nolink') {
817
-				if ($completed=='completed') {
817
+				if ($completed == 'completed') {
818 818
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
819
-				}	else {
819
+				} else {
820 820
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
821 821
 					//echo "&nbsp;";
822 822
 				}
823 823
 			}
824 824
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
825
-			$image=choose_image($filename);
825
+			$image = choose_image($filename);
826 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'];
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 831
 
832
-			if (($myrow["path"]=='') and ($filename=='')) {
832
+			if (($myrow["path"] == '') and ($filename == '')) {
833 833
 				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
834 834
 				return(true);
835 835
 			}
836 836
 
837
-			if ($icon == 'nolink') { return(shorten($filename,$length)); }
837
+			if ($icon == 'nolink') { return(shorten($filename, $length)); }
838 838
 			if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; }
839 839
 			if ($builder != 'builder')
840 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>";
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 842
 				if ($desc != '')
843 843
 				{
844 844
 					if ($icon != 'wrap')
845 845
 					{
846
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
846
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
847 847
 					}
848 848
 					else
849 849
 					{
850
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
850
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
851 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";
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 853
 			}
854 854
 			else
855 855
 			{
856
-				$enableDocumentParsing='yes';
856
+				$enableDocumentParsing = 'yes';
857 857
 				if (!$enableDocumentParsing)
858 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>";
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 861
 				}
862 862
 				else
863 863
 				{
864
-					echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
864
+					echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename, ($length - 3 * $level))."</a>";
865 865
 				}
866 866
 			}
867 867
 			break;
868 868
 
869 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);
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 876
 
877 877
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
878 878
 			if ($icon != 'nolink')
879 879
 			{
880
-				if ($completed=='completed') {
880
+				if ($completed == 'completed') {
881 881
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
882
-				}	else {
882
+				} else {
883 883
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
884 884
 					//echo "&nbsp;";
885 885
 				}
886 886
 			}
887 887
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
888 888
 
889
-			if ($name=='')
889
+			if ($name == '')
890 890
 			{
891 891
 				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
892 892
 			}
893 893
 
894
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
894
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
895 895
 			if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; }
896 896
 			if ($builder != 'builder')
897 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";
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 899
 				if ($desc != '')
900 900
 				{
901 901
 					if ($icon != 'wrap')
902 902
 					{
903
-						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
903
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>";
904 904
 					}
905 905
 					else
906 906
 					{
907
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
907
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>";
908 908
 					}
909 909
 				}
910 910
 			}
911 911
 			else
912 912
 			{
913
-				echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
913
+				echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
914 914
 			}
915 915
 			break;
916 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);
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 923
 
924 924
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
925 925
 			if ($icon != 'nolink') {
926
-				if ($completed=='completed') {
926
+				if ($completed == 'completed') {
927 927
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
928
-				}	else {
928
+				} else {
929 929
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
930 930
 					//echo "&nbsp;";
931 931
 				}
932 932
 			}
933 933
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
934 934
 
935
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
935
+			if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
936 936
 
937
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
937
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
938 938
 			if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; }
939 939
 
940 940
 			if ($builder != 'builder')
941 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";
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 943
 				if ($desc != '') {
944 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>"; }
945
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; }
946 946
 					else {
947
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
947
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>"; }
948 948
 				}
949 949
 			} else {
950
-				echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
950
+				echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
951 951
 			}
952 952
 			break;
953 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);
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 960
 
961 961
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
962 962
 			if ($icon != 'nolink') {
963
-				if ($completed=='completed') {
963
+				if ($completed == 'completed') {
964 964
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
965
-				}	else {
965
+				} else {
966 966
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
967 967
 					//echo "&nbsp;";
968 968
 				}
969 969
 			}
970 970
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
971 971
 
972
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
972
+			if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
973 973
 
974
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
974
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
975 975
 			if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; }
976 976
 
977 977
 			if ($builder != 'builder')
978 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";
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 981
 				if ($desc != '') {
982 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>"; }
983
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; }
984 984
 					else {
985
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
985
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>"; }
986 986
 				}
987 987
 			} else {
988 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>";
989
+				echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
990 990
 			}
991 991
 			break;
992 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);
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 999
 
1000 1000
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1001 1001
 			if ($icon != 'nolink') {
1002
-				if ($completed=='completed') {
1002
+				if ($completed == 'completed') {
1003 1003
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1004
-				}	else {
1004
+				} else {
1005 1005
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1006 1006
 					//echo "&nbsp;";
1007 1007
 				}
1008 1008
 			}
1009 1009
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1010 1010
 
1011
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1011
+			if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1012 1012
 
1013
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
1013
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
1014 1014
 			if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; }
1015 1015
 
1016 1016
 			if ($builder != 'builder')
1017 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";
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 1019
 				if ($desc != '') {
1020 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>"; }
1021
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; }
1022 1022
 					else {
1023
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1023
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>"; }
1024 1024
 				}
1025 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>";
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 1028
 			}
1029 1029
 			break;
1030 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);
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 1037
 
1038 1038
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1039 1039
 			if ($icon != 'nolink') {
1040
-				if ($completed=='completed') {
1040
+				if ($completed == 'completed') {
1041 1041
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1042
-				}	else {
1042
+				} else {
1043 1043
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1044 1044
 					//echo "&nbsp;";
1045 1045
 				}
1046 1046
 			}
1047 1047
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1048 1048
 
1049
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1049
+			if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1050 1050
 
1051
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
1051
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
1052 1052
 			if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; }
1053 1053
 
1054 1054
 			if ($builder != 'builder')
1055 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";
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 1057
 				if ($desc != '') {
1058 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>"; }
1059
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; }
1060 1060
 					else {
1061
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1061
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>"; }
1062 1062
 				}
1063 1063
 			} else {
1064
-				echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1064
+				echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
1065 1065
 			}
1066 1066
 			break;
1067 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);
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 1074
 
1075 1075
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
1076 1076
 			if ($icon != 'nolink') {
1077
-				if ($completed=='completed') {
1077
+				if ($completed == 'completed') {
1078 1078
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1079
-				}	else {
1079
+				} else {
1080 1080
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1081 1081
 					//echo "&nbsp;";
1082 1082
 				}
1083 1083
 			}
1084 1084
 			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
1085 1085
 
1086
-			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1086
+			if ($name == '') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
1087 1087
 
1088
-			if ($icon == 'nolink') { return(shorten($name,$length)); }
1088
+			if ($icon == 'nolink') { return(shorten($name, $length)); }
1089 1089
 			if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; }
1090 1090
 
1091 1091
 			if ($builder != 'builder')
1092 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";
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 1094
 				if ($desc != '') {
1095 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>"; }
1096
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div></td></tr>"; }
1097 1097
 					else {
1098
-						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1098
+						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc, ($length - 3 * $level))."</div>"; }
1099 1099
 				}
1100 1100
 			} else {
1101
-				echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
1101
+				echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
1102 1102
 			}
1103 1103
 			break;
1104 1104
 	}//end huge switch-statement
@@ -1117,29 +1117,29 @@  discard block
 block discarded – undo
1117 1117
 function get_addedresource_link_in_learnpath($type, $id, $id_in_path)
1118 1118
 {
1119 1119
 	global $_course, $learnpath_id, $tbl_learnpath_item, $items;
1120
-	global $curDirPath, $_configuration, $enableDocumentParsing, $_user , $_cid;
1120
+	global $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;
1121 1121
 
1122 1122
 	$hyperlink_target_parameter = ""; //or e.g. target='_blank'
1123 1123
  $builder = 'player';
1124
-	$origin='learnpath';
1124
+	$origin = 'learnpath';
1125 1125
 
1126
-	$linktype=$type;
1127
-	if (($type=="Link _self") or ($type=="Link _blank")) { $type="Link"; }
1126
+	$linktype = $type;
1127
+	if (($type == "Link _self") or ($type == "Link _blank")) { $type = "Link"; }
1128 1128
 
1129 1129
  $link = '';
1130 1130
 
1131 1131
 	switch ($type)
1132 1132
 	{
1133 1133
 		case "Agenda":
1134
-			$TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA);;
1134
+			$TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); ;
1135 1135
 			$result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
1136
-			$myrow=Database::fetch_array($result);
1136
+			$myrow = Database::fetch_array($result);
1137 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'];
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 1143
 
1144 1144
 			if ($builder != 'builder')
1145 1145
 			{
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 		case "Ad_Valvas":
1155 1155
 			$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
1156 1156
 			$result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
1157
-			$myrow=Database::fetch_array($result);
1157
+			$myrow = Database::fetch_array($result);
1158 1158
 
1159 1159
 			if ($builder != 'builder')
1160 1160
 			{
@@ -1167,14 +1167,14 @@  discard block
 block discarded – undo
1167 1167
 			break;
1168 1168
 
1169 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);
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 1173
 
1174
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1175
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1174
+			$sql = "select * from $tbl_learnpath_item where id=$id_in_path";
1175
+			$result = Database::query($sql); $row = Database::fetch_array($result);
1176 1176
 
1177
-			$thelink=$myrow["url"];
1177
+			$thelink = $myrow["url"];
1178 1178
 			if ($builder != 'builder')
1179 1179
 			{
1180 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";
@@ -1186,16 +1186,16 @@  discard block
 block discarded – undo
1186 1186
 			break;
1187 1187
 
1188 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);
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 1192
 
1193
-			if ($builder=='builder') { $origin='builder'; }
1193
+			if ($builder == 'builder') { $origin = 'builder'; }
1194 1194
 			  //this is needed for the exercise_submit.php can delete the session info about tests
1195 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']; }
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 1199
 
1200 1200
 			if ($builder != 'builder')
1201 1201
 			{
@@ -1208,14 +1208,14 @@  discard block
 block discarded – undo
1208 1208
 			break;
1209 1209
 
1210 1210
 		case "HotPotatoes":
1211
-	  	    $TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT);
1212
-		    $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
1211
+	  	    $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
1212
+		    $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
1213 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);
1214
+		    $myrow = Database::fetch_array($result);
1215
+		    $path = $myrow["path"];
1216
+		  	$name = GetQuizName($path, $documentPath);
1217 1217
 
1218
-			if ($builder=='builder') { $origin='builder'; }
1218
+			if ($builder == 'builder') { $origin = 'builder'; }
1219 1219
 
1220 1220
 			$cid = $_course['official_code'];
1221 1221
 
@@ -1232,18 +1232,18 @@  discard block
 block discarded – undo
1232 1232
 		case "Forum":
1233 1233
         //deprecated
1234 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);
1235
+			$result = Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
1236
+			$myrow = Database::fetch_array($result);
1237 1237
 
1238
-			if ($builder=='builder') { $origin='builder'; }
1238
+			if ($builder == 'builder') { $origin = 'builder'; }
1239 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']; }
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 1243
 
1244
-			if ($myrow["forum_name"]=='') { $type="Forum"; }
1244
+			if ($myrow["forum_name"] == '') { $type = "Forum"; }
1245 1245
 
1246
-			$forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1246
+			$forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1247 1247
 			if ($builder != 'builder')
1248 1248
 			{
1249 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";
@@ -1256,15 +1256,15 @@  discard block
 block discarded – undo
1256 1256
 
1257 1257
 		case "Thread":  //forum post
1258 1258
         //deprecated
1259
-			$tbl_topics      = $_course['dbNameGlu'].'bb_topics';
1260
-			$tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
1259
+			$tbl_topics = $_course['dbNameGlu'].'bb_topics';
1260
+			$tbl_posts = $_course['dbNameGlu'].'bb_posts';
1261 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);
1262
+			$sql = "SELECT * FROM $tbl_topics where topic_id=$id";
1263
+			$result = Database::query($sql);
1264
+			$myrow = Database::fetch_array($result);
1265 1265
 
1266
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1267
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1266
+			$sql = "select * from $tbl_learnpath_item where id=$id_in_path";
1267
+			$result = Database::query($sql); $row = Database::fetch_array($result);
1268 1268
 
1269 1269
 			if ($builder != 'builder')
1270 1270
 			{
@@ -1311,16 +1311,16 @@  discard block
 block discarded – undo
1311 1311
 			break;
1312 1312
 
1313 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);
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 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
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 1321
 
1322
-			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
1323
-			$result=Database::query($sql);	$row=Database::fetch_array($result);
1322
+			$sql = "select * from $tbl_learnpath_item where id=$id_in_path";
1323
+			$result = Database::query($sql); $row = Database::fetch_array($result);
1324 1324
 
1325 1325
 			if ($builder != 'builder')
1326 1326
 			{
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
 			}
1330 1330
 			else
1331 1331
 			{
1332
-				$enableDocumentParsing='yes';
1332
+				$enableDocumentParsing = 'yes';
1333 1333
 				if (!$enableDocumentParsing)
1334 1334
 				{ //this is the solution for the non-parsing version in the builder
1335
-					$file=urlencode($myrow["path"]);
1335
+					$file = urlencode($myrow["path"]);
1336 1336
 					$link .= "../document/showinframes.php?file=$file";
1337 1337
 				}
1338 1338
 				else
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 			{
1375 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 1376
 			} else {
1377
-				$s=api_get_path(WEB_CODE_PATH)."course_description";
1377
+				$s = api_get_path(WEB_CODE_PATH)."course_description";
1378 1378
 				$link .= $s;
1379 1379
 			}
1380 1380
 			break;
@@ -1408,8 +1408,8 @@  discard block
 block discarded – undo
1408 1408
 	$addedresourceid = $_SESSION['addedresourceid'];
1409 1409
 	unset($addedresource[$resource_key]);
1410 1410
 	unset($addedresourceid[$resource_key]);
1411
-	$_SESSION['addedresource']=$addedresource;
1412
-	$_SESSION['addedresourceid']=$addedresourceid ;
1411
+	$_SESSION['addedresource'] = $addedresource;
1412
+	$_SESSION['addedresourceid'] = $addedresourceid;
1413 1413
 }
1414 1414
 
1415 1415
 /**
@@ -1442,9 +1442,9 @@  discard block
 block discarded – undo
1442 1442
 function delete_added_resource($type, $id)
1443 1443
 {
1444 1444
 	global $_course;
1445
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1445
+	$TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
1446 1446
 
1447
-	$sql="DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1447
+	$sql = "DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1448 1448
 	Database::query($sql);
1449 1449
 }
1450 1450
 
@@ -1455,9 +1455,9 @@  discard block
 block discarded – undo
1455 1455
 function delete_all_resources_type($type)
1456 1456
 {
1457 1457
   global $_course;
1458
-  $TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
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 1462
   Database::query($sql);
1463 1463
 }
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
 function check_added_resources($type, $id)
1469 1469
 {
1470 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)
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 1476
 		return true;
1477 1477
 	else
1478 1478
 		return false;
@@ -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"];
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 1497
 	}
1498
-	$_SESSION['addedresource']=$addedresource;
1499
-	$_SESSION['addedresourceid']=$addedresourceid;
1498
+	$_SESSION['addedresource'] = $addedresource;
1499
+	$_SESSION['addedresourceid'] = $addedresourceid;
1500 1500
 }
1501 1501
 
1502 1502
 /**
@@ -1506,12 +1506,12 @@  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 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'";
1514
+	$sql = "DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'";
1515 1515
 	//echo $sql;
1516 1516
 	Database::query($sql);
1517 1517
 
@@ -1525,25 +1525,25 @@  discard block
 block discarded – undo
1525 1525
 /**
1526 1526
 * this function is to display the resources that were added to a specific item
1527 1527
 */
1528
-function display_added_resources($type, $id, $style='')
1528
+function display_added_resources($type, $id, $style = '')
1529 1529
 {
1530 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' );
1531
+	$arr_icons = array('Agenda'=>'../img/agenda.gif', 'Ad Valvas'=>'../img/valves.gif', 'Link'=>'../img/links.gif', 'Exercise'=>'../img/quiz.gif');
1532 1532
 
1533 1533
 	global $_course, $origin;
1534
-	$TABLERESOURCE 		= Database::get_course_table(TABLE_LINKED_RESOURCES);
1534
+	$TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES);
1535 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))
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 1539
 	{
1540 1540
 		if ($origin != 'learnpath')
1541 1541
 		{
1542
-			display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ;
1542
+			display_addedresource_link($row['resource_type'], $row['resource_id'], $style);
1543 1543
 		}
1544 1544
 		else
1545 1545
 		{
1546
-			display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>";
1546
+			display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'], 'agendaitems', '', 'builder', 'icon'); echo "<br>";
1547 1547
 		}
1548 1548
 	}
1549 1549
 }
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 	global $locationkey;
1563 1563
 	global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
1564 1564
 
1565
-	if ($resourceaction=="removeresource")
1565
+	if ($resourceaction == "removeresource")
1566 1566
 	{
1567 1567
 		/* unneccessary because when editing we delete all the added resources from the
1568 1568
 		database and add all these from the session
@@ -1583,8 +1583,8 @@  discard block
 block discarded – undo
1583 1583
 		//echo "remove from session";
1584 1584
 		remove_resource($locationkey);
1585 1585
 	}
1586
-	$addedresource=$_SESSION['addedresource'];
1587
-	$addedresourceid=$_SESSION['addedresourceid'];
1586
+	$addedresource = $_SESSION['addedresource'];
1587
+	$addedresourceid = $_SESSION['addedresourceid'];
1588 1588
 	if (is_array($addedresource))
1589 1589
 	{
1590 1590
 		echo '<table>';
@@ -1592,16 +1592,16 @@  discard block
 block discarded – undo
1592 1592
 		{
1593 1593
 			//echo $resource.":".$addedresourceid[key($addedresource)];
1594 1594
 			echo '<tr><td>';
1595
-			display_addedresource_link($resource,$addedresourceid[key($addedresource)]);
1595
+			display_addedresource_link($resource, $addedresourceid[key($addedresource)]);
1596 1596
 			echo '</td><td width="30">';
1597 1597
 
1598 1598
 			// if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource
1599 1599
 			// should also contain this id.
1600
-			$test=parse_url($_SERVER['REQUEST_URI']);
1600
+			$test = parse_url($_SERVER['REQUEST_URI']);
1601 1601
 			$output = array();
1602
-			parse_str($test['query'],$output);
1602
+			parse_str($test['query'], $output);
1603 1603
 
1604
-			if ($showdeleteimg==1)
1604
+			if ($showdeleteimg == 1)
1605 1605
 			{
1606 1606
 				//if (strstr($_SERVER['REQUEST_URI'],"?id="))
1607 1607
 				//	{ echo " <a href='".api_get_self()."?id=".$output['id']."&amp;"; }
@@ -1635,8 +1635,8 @@  discard block
 block discarded – undo
1635 1635
 	global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
1636 1636
 	//global $_SESSION['addresource'];
1637 1637
 	//global $_SESSION['addresourceid'];
1638
-	$addedresource=$_SESSION['addedresource'];
1639
-	$addedresourceid=$_SESSION['addedresourceid'];
1638
+	$addedresource = $_SESSION['addedresource'];
1639
+	$addedresourceid = $_SESSION['addedresourceid'];
1640 1640
 
1641 1641
 	if (is_array($_SESSION['addedresource']))
1642 1642
 	{
@@ -1649,16 +1649,16 @@  discard block
 block discarded – undo
1649 1649
 			//print_r($addedresourceid);
1650 1650
 			//echo "<br>";
1651 1651
 
1652
-			if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id)
1652
+			if ($toolcompare == $type and $addedresourceid[key($addedresource)] == $id)
1653 1653
 			{
1654
-				$show=0;
1654
+				$show = 0;
1655 1655
 			}
1656 1656
 			next($addedresource);
1657 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)
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 1660
 		{
1661
-			if ($type=="Document")
1661
+			if ($type == "Document")
1662 1662
 			{
1663 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 1664
 			}
@@ -1670,9 +1670,9 @@  discard block
 block discarded – undo
1670 1670
 	}
1671 1671
 	else // if it is not an array, it is a string
1672 1672
 	{
1673
-		if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id)
1673
+		if ($_SESSION['addedresource'] !== $type or $_SESSION['addedresourceid'] !== $id)
1674 1674
 		{
1675
-			if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1675
+			if ($from_learnpath) { $lang_add_it_or_resource = get_lang('AddIt'); } else { $lang_add_it_or_resource = get_lang('AddResource'); }
1676 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 1677
 		}
1678 1678
 	}
Please login to merge, or discard this patch.
Braces   +75 added lines, -116 removed lines patch added patch discarded remove patch
@@ -69,8 +69,7 @@  discard block
 block discarded – undo
69 69
 	if (api_is_allowed_to_edit())
70 70
 	{
71 71
 		$visibility="ip.visibility<>'2'";
72
-	}
73
-	else
72
+	} else
74 73
 	{
75 74
 		$visibility="ip.visibility='1'";
76 75
 	}
@@ -96,8 +95,7 @@  discard block
 block discarded – undo
96 95
 				if (file_or_folder($row['path']))
97 96
 				{
98 97
 						echo '<img src="../img/file.gif" align="middle" />';
99
-				}
100
-				else
98
+				} else
101 99
 				{
102 100
 					$image = choose_image($row['path']);
103 101
 					echo "<img src=\"../img/$image\" align=\"middle\" />";
@@ -108,16 +106,14 @@  discard block
 block discarded – undo
108 106
 				{
109 107
 					echo "<a href='".api_get_self()."?content=Document";
110 108
 					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
109
+				} else
113 110
 				{
114 111
 					echo substr($row['path'],1).' ';
115 112
 					echo showorhide_addresourcelink('Document',$row['id']);
116 113
 					echo '<br />';
117 114
 				}
118 115
 			}
119
-		}
120
-		else
116
+		} else
121 117
 		{
122 118
 			// we calculate the level we are in by using the $folder in the url
123 119
 			// we put +1 because it does not start with an / and in the database it does
@@ -156,8 +152,7 @@  discard block
 block discarded – undo
156 152
 				if (file_or_folder($path))
157 153
 				{
158 154
 					echo '<img src="../img/file.gif" align="middle" />';
159
-				}
160
-				else
155
+				} else
161 156
 				{
162 157
 					$image = choose_image($path);
163 158
 					echo "<img src=\"../img/$image\" align=\"middle\" />";
@@ -172,8 +167,7 @@  discard block
 block discarded – undo
172 167
 					//using the correct name of the folder
173 168
 					$folder_name=str_replace($folder.'/','',$path);
174 169
 					echo "<a href='$newuri'>".$folder_name.'</a><br />';
175
-				}
176
-				else
170
+				} else
177 171
 				{
178 172
 					echo str_replace("/$folder/", '',$path).' ';
179 173
 					echo showorhide_addresourcelink('Document',$good_ids[$good_key]);
@@ -349,9 +343,14 @@  discard block
 block discarded – undo
349 343
 
350 344
 	$length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
351 345
 
352
-	if ($builder != 'builder') $origin = 'learnpath';	//origin = learnpath in student view
346
+	if ($builder != 'builder') {
347
+	    $origin = 'learnpath';
348
+	}
349
+	//origin = learnpath in student view
353 350
 	$linktype = $type;
354
-	if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';
351
+	if (($type == 'Link _self') or ($type == 'Link _blank')) {
352
+	    $type = 'Link';
353
+	}
355 354
 
356 355
 	switch ($type)
357 356
 	{
@@ -371,7 +370,7 @@  discard block
 block discarded – undo
371 370
 			{
372 371
 				if ($completed=='completed') {
373 372
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
374
-				}	else {
373
+				} else {
375 374
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
376 375
 					//echo "&nbsp;";
377 376
 				}
@@ -391,14 +390,12 @@  discard block
 block discarded – undo
391 390
 					if ($icon != 'wrap')
392 391
 					{
393 392
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
394
-					}
395
-					else
393
+					} else
396 394
 					{
397 395
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
398 396
 					}
399 397
 				}
400
-			}
401
-			else
398
+			} else
402 399
 			{
403 400
 				echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
404 401
 			}
@@ -426,7 +423,7 @@  discard block
 block discarded – undo
426 423
 			{
427 424
 				if ($completed=='completed') {
428 425
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
429
-				}	else {
426
+				} else {
430 427
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
431 428
 					//echo "&nbsp;";
432 429
 				}
@@ -450,14 +447,12 @@  discard block
 block discarded – undo
450 447
 					if ($icon != 'wrap')
451 448
 					{
452 449
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
453
-					}
454
-					else
450
+					} else
455 451
 					{
456 452
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
457 453
 					}
458 454
 				}
459
-			}
460
-			else
455
+			} else
461 456
 			{
462 457
 				echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>";
463 458
 			}
@@ -479,7 +474,7 @@  discard block
 block discarded – undo
479 474
 			{
480 475
 				if ($completed=='completed') {
481 476
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
482
-				}	else {
477
+				} else {
483 478
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
484 479
 					//echo "&nbsp;";
485 480
 				}
@@ -495,8 +490,7 @@  discard block
 block discarded – undo
495 490
 			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
496 491
 			if ($icon == 'icon')
497 492
 			{
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'>"; }
493
+				if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; } else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
500 494
 			}
501 495
 			$thelink=$myrow["url"];
502 496
 			if ($builder != 'builder')
@@ -508,14 +502,12 @@  discard block
 block discarded – undo
508 502
 					if ($icon != 'wrap')
509 503
 					{
510 504
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
511
-					}
512
-					else
505
+					} else
513 506
 					{
514 507
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
515 508
 					}
516 509
 				}
517
-			}
518
-			else
510
+			} else
519 511
 			{
520 512
 				echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
521 513
 			}
@@ -540,7 +532,7 @@  discard block
 block discarded – undo
540 532
 			{
541 533
 				if ($completed=='completed') {
542 534
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
543
-				}	else {
535
+				} else {
544 536
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
545 537
 					//echo "&nbsp;";
546 538
 				}
@@ -563,14 +555,12 @@  discard block
 block discarded – undo
563 555
 					if ($icon != 'wrap')
564 556
 					{
565 557
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
566
-					}
567
-					else
558
+					} else
568 559
 					{
569 560
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
570 561
 					}
571 562
 				}
572
-			}
573
-			else
563
+			} else
574 564
 			{
575 565
 				echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
576 566
 			}
@@ -598,7 +588,7 @@  discard block
 block discarded – undo
598 588
 			{
599 589
 				if ($completed=='completed') {
600 590
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
601
-				}	else {
591
+				} else {
602 592
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
603 593
 					//echo "&nbsp;";
604 594
 				}
@@ -621,14 +611,12 @@  discard block
 block discarded – undo
621 611
 					if ($icon != 'wrap')
622 612
 					{
623 613
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
624
-					}
625
-					else
614
+					} else
626 615
 					{
627 616
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
628 617
 					}
629 618
 				}
630
-			}
631
-			else
619
+			} else
632 620
 			{
633 621
 				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 622
 			}
@@ -650,7 +638,7 @@  discard block
 block discarded – undo
650 638
 			{
651 639
 				if ($completed=='completed') {
652 640
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
653
-				}	else {
641
+				} else {
654 642
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
655 643
 					//echo "&nbsp;";
656 644
 				}
@@ -671,14 +659,12 @@  discard block
 block discarded – undo
671 659
 					if ($icon != 'wrap')
672 660
 					{
673 661
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
674
-					}
675
-					else
662
+					} else
676 663
 					{
677 664
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
678 665
 					}
679 666
 				}
680
-			}
681
-			else
667
+			} else
682 668
 			{
683 669
 				echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
684 670
 			}
@@ -704,7 +690,7 @@  discard block
 block discarded – undo
704 690
 			{
705 691
 				if ($completed=='completed') {
706 692
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
707
-				}	else {
693
+				} else {
708 694
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
709 695
 					//echo "&nbsp;";
710 696
 				}
@@ -724,14 +710,12 @@  discard block
 block discarded – undo
724 710
 					if ($icon != 'wrap')
725 711
 					{
726 712
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
727
-					}
728
-					else
713
+					} else
729 714
 					{
730 715
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
731 716
 					}
732 717
 				}
733
-			}
734
-			else
718
+			} else
735 719
 			{
736 720
 				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 721
 			}
@@ -765,7 +749,7 @@  discard block
 block discarded – undo
765 749
 			{
766 750
 				if ($completed=='completed') {
767 751
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
768
-				}	else {
752
+				} else {
769 753
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
770 754
 					//echo "&nbsp;";
771 755
 				}
@@ -788,14 +772,12 @@  discard block
 block discarded – undo
788 772
 					if ($icon != 'wrap')
789 773
 					{
790 774
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
791
-					}
792
-					else
775
+					} else
793 776
 					{
794 777
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
795 778
 					}
796 779
 				}
797
-			}
798
-			else
780
+			} else
799 781
 			{
800 782
 				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 783
 			}
@@ -816,7 +798,7 @@  discard block
 block discarded – undo
816 798
 			if ($icon != 'nolink') {
817 799
 				if ($completed=='completed') {
818 800
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
819
-				}	else {
801
+				} else {
820 802
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
821 803
 					//echo "&nbsp;";
822 804
 				}
@@ -844,22 +826,19 @@  discard block
 block discarded – undo
844 826
 					if ($icon != 'wrap')
845 827
 					{
846 828
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
847
-					}
848
-					else
829
+					} else
849 830
 					{
850 831
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
851 832
 					}
852 833
 				} $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
834
+			} else
855 835
 			{
856 836
 				$enableDocumentParsing='yes';
857 837
 				if (!$enableDocumentParsing)
858 838
 				{ //this is the solution for the non-parsing version in the builder
859 839
 					$file=urlencode($myrow["path"]);
860 840
 					echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
861
-				}
862
-				else
841
+				} else
863 842
 				{
864 843
 					echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
865 844
 				}
@@ -879,7 +858,7 @@  discard block
 block discarded – undo
879 858
 			{
880 859
 				if ($completed=='completed') {
881 860
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
882
-				}	else {
861
+				} else {
883 862
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
884 863
 					//echo "&nbsp;";
885 864
 				}
@@ -901,14 +880,12 @@  discard block
 block discarded – undo
901 880
 					if ($icon != 'wrap')
902 881
 					{
903 882
 						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
904
-					}
905
-					else
883
+					} else
906 884
 					{
907 885
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
908 886
 					}
909 887
 				}
910
-			}
911
-			else
888
+			} else
912 889
 			{
913 890
 				echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
914 891
 			}
@@ -925,7 +902,7 @@  discard block
 block discarded – undo
925 902
 			if ($icon != 'nolink') {
926 903
 				if ($completed=='completed') {
927 904
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
928
-				}	else {
905
+				} else {
929 906
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
930 907
 					//echo "&nbsp;";
931 908
 				}
@@ -942,8 +919,7 @@  discard block
 block discarded – undo
942 919
 				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 920
 				if ($desc != '') {
944 921
 					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 {
922
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; } else {
947 923
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
948 924
 				}
949 925
 			} else {
@@ -962,7 +938,7 @@  discard block
 block discarded – undo
962 938
 			if ($icon != 'nolink') {
963 939
 				if ($completed=='completed') {
964 940
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
965
-				}	else {
941
+				} else {
966 942
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
967 943
 					//echo "&nbsp;";
968 944
 				}
@@ -980,8 +956,7 @@  discard block
 block discarded – undo
980 956
 				$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 957
 				if ($desc != '') {
982 958
 					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 {
959
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; } else {
985 960
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
986 961
 				}
987 962
 			} else {
@@ -1001,7 +976,7 @@  discard block
 block discarded – undo
1001 976
 			if ($icon != 'nolink') {
1002 977
 				if ($completed=='completed') {
1003 978
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1004
-				}	else {
979
+				} else {
1005 980
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1006 981
 					//echo "&nbsp;";
1007 982
 				}
@@ -1018,8 +993,7 @@  discard block
 block discarded – undo
1018 993
 				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 994
 				if ($desc != '') {
1020 995
 					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 {
996
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; } else {
1023 997
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1024 998
 				}
1025 999
 			} else {
@@ -1039,7 +1013,7 @@  discard block
 block discarded – undo
1039 1013
 			if ($icon != 'nolink') {
1040 1014
 				if ($completed=='completed') {
1041 1015
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1042
-				}	else {
1016
+				} else {
1043 1017
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1044 1018
 					//echo "&nbsp;";
1045 1019
 				}
@@ -1056,8 +1030,7 @@  discard block
 block discarded – undo
1056 1030
 				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 1031
 				if ($desc != '') {
1058 1032
 					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 {
1033
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; } else {
1061 1034
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1062 1035
 				}
1063 1036
 			} else {
@@ -1076,7 +1049,7 @@  discard block
 block discarded – undo
1076 1049
 			if ($icon != 'nolink') {
1077 1050
 				if ($completed=='completed') {
1078 1051
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
1079
-				}	else {
1052
+				} else {
1080 1053
 					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
1081 1054
 					//echo "&nbsp;";
1082 1055
 				}
@@ -1093,8 +1066,7 @@  discard block
 block discarded – undo
1093 1066
 				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 1067
 				if ($desc != '') {
1095 1068
 					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 {
1069
+						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; } else {
1098 1070
 						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
1099 1071
 				}
1100 1072
 			} else {
@@ -1144,8 +1116,7 @@  discard block
 block discarded – undo
1144 1116
 			if ($builder != 'builder')
1145 1117
 			{
1146 1118
 				$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
1119
+			} else
1149 1120
 			{
1150 1121
 				$link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id";
1151 1122
 			}
@@ -1159,8 +1130,7 @@  discard block
 block discarded – undo
1159 1130
 			if ($builder != 'builder')
1160 1131
 			{
1161 1132
 				$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
1133
+			} else
1164 1134
 			{
1165 1135
 				$link .= "../announcements/announcements.php?origin=$origin&ann_id=$id";
1166 1136
 			}
@@ -1178,8 +1148,7 @@  discard block
 block discarded – undo
1178 1148
 			if ($builder != 'builder')
1179 1149
 			{
1180 1150
 				$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
1151
+			} else
1183 1152
 			{
1184 1153
 				$link .= $thelink;
1185 1154
 			}
@@ -1200,8 +1169,7 @@  discard block
 block discarded – undo
1200 1169
 			if ($builder != 'builder')
1201 1170
 			{
1202 1171
 				$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
1172
+			} else
1205 1173
 			{
1206 1174
 				$link .= "../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"];
1207 1175
 			}
@@ -1222,8 +1190,7 @@  discard block
 block discarded – undo
1222 1190
 			if ($builder != 'builder')
1223 1191
 			{
1224 1192
 				$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
1193
+			} else
1227 1194
 			{
1228 1195
 				$link .= "../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."";
1229 1196
 			}
@@ -1247,8 +1214,7 @@  discard block
 block discarded – undo
1247 1214
 			if ($builder != 'builder')
1248 1215
 			{
1249 1216
 				$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
1217
+			} else
1252 1218
 			{
1253 1219
 				$link .= "../phpbb/viewforum.php?$forumparameters";
1254 1220
 			}
@@ -1269,8 +1235,7 @@  discard block
 block discarded – undo
1269 1235
 			if ($builder != 'builder')
1270 1236
 			{
1271 1237
 				$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
1238
+			} else
1274 1239
 			{
1275 1240
 				$link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
1276 1241
 			}
@@ -1326,16 +1291,14 @@  discard block
 block discarded – undo
1326 1291
 			{
1327 1292
 				$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 1293
 
1329
-			}
1330
-			else
1294
+			} else
1331 1295
 			{
1332 1296
 				$enableDocumentParsing='yes';
1333 1297
 				if (!$enableDocumentParsing)
1334 1298
 				{ //this is the solution for the non-parsing version in the builder
1335 1299
 					$file=urlencode($myrow["path"]);
1336 1300
 					$link .= "../document/showinframes.php?file=$file";
1337
-				}
1338
-				else
1301
+				} else
1339 1302
 				{
1340 1303
 					$link .= "../document/download.php?doc_url=".$myrow["path"];
1341 1304
 				}
@@ -1346,8 +1309,7 @@  discard block
 block discarded – undo
1346 1309
 			if ($builder != 'builder')
1347 1310
 			{
1348 1311
 				$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
1312
+			} else
1351 1313
 			{
1352 1314
 				$link .= "../work/work.php";
1353 1315
 			}
@@ -1472,11 +1434,12 @@  discard block
 block discarded – undo
1472 1434
 	$sql="SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
1473 1435
 	$result=Database::query($sql);
1474 1436
 	$number_added=Database::num_rows($result);
1475
-	if ($number_added<>0)
1476
-		return true;
1477
-	else
1478
-		return false;
1479
-}
1437
+	if ($number_added<>0) {
1438
+			return true;
1439
+	} else {
1440
+			return false;
1441
+	}
1442
+	}
1480 1443
 
1481 1444
 
1482 1445
 /**
@@ -1540,8 +1503,7 @@  discard block
 block discarded – undo
1540 1503
 		if ($origin != 'learnpath')
1541 1504
 		{
1542 1505
 			display_addedresource_link($row['resource_type'], $row['resource_id'], $style) ;
1543
-		}
1544
-		else
1506
+		} else
1545 1507
 		{
1546 1508
 			display_addedresource_link_in_learnpath($row['resource_type'], $row['resource_id'],'agendaitems','','builder','icon') ; echo "<br>";
1547 1509
 		}
@@ -1616,8 +1578,7 @@  discard block
 block discarded – undo
1616 1578
 			//$_SESSION['edit']=='';
1617 1579
 		}
1618 1580
 		echo '</table>';
1619
-	}
1620
-	else // it is a string
1581
+	} else // it is a string
1621 1582
 	{
1622 1583
 		echo '';
1623 1584
 	}
@@ -1661,14 +1622,12 @@  discard block
 block discarded – undo
1661 1622
 			if ($type=="Document")
1662 1623
 			{
1663 1624
 				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
1625
+			} else
1666 1626
 			{
1667 1627
 				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 1628
 			}
1669 1629
 		}
1670
-	}
1671
-	else // if it is not an array, it is a string
1630
+	} else // if it is not an array, it is a string
1672 1631
 	{
1673 1632
 		if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id)
1674 1633
 		{
Please login to merge, or discard this patch.
Indentation   +1390 added lines, -1390 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,41 +1580,41 @@  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
-				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 />";
1607
-			}
1608
-			echo '</td></tr>';
1609
-			next($addedresource);
1610
-			//$_SESSION['edit']=='';
1611
-		}
1612
-		echo '</table>';
1613
-	}
1614
-	else // it is a string
1615
-	{
1616
-		echo '';
1617
-	}
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
+                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 />";
1607
+            }
1608
+            echo '</td></tr>';
1609
+            next($addedresource);
1610
+            //$_SESSION['edit']=='';
1611
+        }
1612
+        echo '</table>';
1613
+    }
1614
+    else // it is a string
1615
+    {
1616
+        echo '';
1617
+    }
1618 1618
 } // end of the display_resources function
1619 1619
 
1620 1620
 
@@ -1626,49 +1626,49 @@  discard block
 block discarded – undo
1626 1626
 */
1627 1627
 function showorhide_addresourcelink($type, $id)
1628 1628
 {
1629
-	global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
1630
-	//global $_SESSION['addresource'];
1631
-	//global $_SESSION['addresourceid'];
1632
-	$addedresource=$_SESSION['addedresource'];
1633
-	$addedresourceid=$_SESSION['addedresourceid'];
1634
-
1635
-	if (is_array($_SESSION['addedresource']))
1636
-	{
1637
-		foreach ($addedresource as $toolcompare)
1638
-		{
1639
-			//echo $toolcompare;
1640
-			//echo "/".$type."/".$id."****";
1641
-			//$key=key($addedresource);
1642
-			//echo $addedresourceid[$key];
1643
-			//print_r($addedresourceid);
1644
-			//echo "<br>";
1645
-
1646
-			if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id)
1647
-			{
1648
-				$show=0;
1649
-			}
1650
-			next($addedresource);
1651
-		}
1652
-		if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1653
-		if ($show!==0)
1654
-		{
1655
-			if ($type=="Document")
1656
-			{
1657
-				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>";
1658
-			}
1659
-			else
1660
-			{
1661
-				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>";
1662
-			}
1663
-		}
1664
-	}
1665
-	else // if it is not an array, it is a string
1666
-	{
1667
-		if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id)
1668
-		{
1669
-			if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1670
-			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>";
1671
-		}
1672
-	}
1629
+    global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
1630
+    //global $_SESSION['addresource'];
1631
+    //global $_SESSION['addresourceid'];
1632
+    $addedresource=$_SESSION['addedresource'];
1633
+    $addedresourceid=$_SESSION['addedresourceid'];
1634
+
1635
+    if (is_array($_SESSION['addedresource']))
1636
+    {
1637
+        foreach ($addedresource as $toolcompare)
1638
+        {
1639
+            //echo $toolcompare;
1640
+            //echo "/".$type."/".$id."****";
1641
+            //$key=key($addedresource);
1642
+            //echo $addedresourceid[$key];
1643
+            //print_r($addedresourceid);
1644
+            //echo "<br>";
1645
+
1646
+            if ($toolcompare==$type and $addedresourceid[key($addedresource)]==$id)
1647
+            {
1648
+                $show=0;
1649
+            }
1650
+            next($addedresource);
1651
+        }
1652
+        if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1653
+        if ($show!==0)
1654
+        {
1655
+            if ($type=="Document")
1656
+            {
1657
+                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>";
1658
+            }
1659
+            else
1660
+            {
1661
+                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>";
1662
+            }
1663
+        }
1664
+    }
1665
+    else // if it is not an array, it is a string
1666
+    {
1667
+        if ($_SESSION['addedresource']!==$type or $_SESSION['addedresourceid']!==$id)
1668
+        {
1669
+            if ($from_learnpath) { $lang_add_it_or_resource=get_lang('AddIt'); } else { $lang_add_it_or_resource=get_lang('AddResource'); }
1670
+            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>";
1671
+        }
1672
+    }
1673 1673
 }
1674 1674
 ?>
Please login to merge, or discard this patch.
main/user/user.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -735,7 +735,6 @@
 block discarded – undo
735 735
  * lock = the user can no longer use this account
736 736
  * @author Patrick Cool <[email protected]>, Ghent University
737 737
  * @param int $active the current state of the account
738
- * @param int $user_id The user id
739 738
  * @param string $urlParams
740 739
  *
741 740
  * @return string Some HTML-code with the lock/unlock button
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 $use_anonymous = true;
15 15
 require_once '../inc/global.inc.php';
16
-$current_course_tool  = TOOL_USER;
16
+$current_course_tool = TOOL_USER;
17 17
 $this_section = SECTION_COURSES;
18 18
 
19 19
 // notice for unauthorized people.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 //Can't auto unregister from a session
43 43
 if (!empty($sessionId)) {
44
-    $course_info['unsubscribe']  = 0;
44
+    $course_info['unsubscribe'] = 0;
45 45
 }
46 46
 
47 47
 /* Unregistering a user section	*/
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                             '#',
185 185
                             get_lang('UserPicture'),
186 186
                             get_lang('OfficialCode'),
187
-                            get_lang('FirstName') . ', ' . get_lang('LastName'),
187
+                            get_lang('FirstName').', '.get_lang('LastName'),
188 188
                             get_lang('Email'),
189 189
                             get_lang('Phone')
190 190
                         );
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                             '#',
194 194
                             get_lang('UserPicture'),
195 195
                             get_lang('OfficialCode'),
196
-                            get_lang('LastName') . ', ' . get_lang('FirstName'),
196
+                            get_lang('LastName').', '.get_lang('FirstName'),
197 197
                             get_lang('Email'),
198 198
                             get_lang('Phone')
199 199
                         );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                     if (api_is_multiple_url_enabled()) {
219 219
                         $sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ';
220 220
                     }
221
-                    $sql .=" WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id ";
221
+                    $sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id ";
222 222
                     $sql .= ' AND session_id = '.$sessionId;
223 223
 
224 224
                     if (api_is_multiple_url_enabled()) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                             true
253 253
                         );
254 254
                         if (!empty($extra_fields)) {
255
-                            foreach($extra_fields as $key => $extra_value) {
255
+                            foreach ($extra_fields as $key => $extra_value) {
256 256
                                 $user[$key] = $extra_value;
257 257
                             }
258 258
                         }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                                     $counter,
267 267
                                     $user_image,
268 268
                                     $user['official_code'],
269
-                                    $user['firstname'] . ', ' . $user['lastname'],
269
+                                    $user['firstname'].', '.$user['lastname'],
270 270
                                     $user['email'],
271 271
                                     $user['phone']
272 272
                                 );
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                                     $counter,
276 276
                                     $user_image,
277 277
                                     $user['official_code'],
278
-                                    $user['lastname'] . ', ' . $user['firstname'],
278
+                                    $user['lastname'].', '.$user['firstname'],
279 279
                                     $user['email'],
280 280
                                     $user['phone']
281 281
                                 );
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
                                     $counter,
355 355
                                     $user_image,
356 356
                                     $user['official_code'],
357
-                                    $user['firstname'] . ', ' . $user['lastname'],
357
+                                    $user['firstname'].', '.$user['lastname'],
358 358
                                     $user['email'],
359 359
                                     $user['phone']
360 360
                                 );
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                                     $counter,
364 364
                                     $user_image,
365 365
                                     $user['official_code'],
366
-                                    $user['lastname'] . ', ' . $user['firstname'],
366
+                                    $user['lastname'].', '.$user['firstname'],
367 367
                                     $user['email'],
368 368
                                     $user['phone']
369 369
                                 );
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
                 $userInfo = api_get_user_info($user_id);
701 701
                 $userPicture = $userInfo['avatar'];
702 702
 
703
-                $photo= '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />';
703
+                $photo = '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />';
704 704
 
705 705
                 $temp[] = $user_id;
706 706
                 $temp[] = $photo;
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
         if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
822 822
             // unregister
823 823
             if ($user_id != $current_user_id || api_is_platform_admin()) {
824
-                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.
824
+                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'.
825 825
                     get_lang('Unreg').'</a>&nbsp;';
826 826
             } else {
827 827
                 //$result .= Display::return_icon('unsubscribe_course_na.png', get_lang('Unreg'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
         // Show buttons for unsubscribe
832 832
         if ($course_info['unsubscribe'] == 1) {
833 833
             if ($user_id == $current_user_id) {
834
-                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.
834
+                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'.
835 835
                     get_lang('Unreg').'</a>&nbsp;';
836 836
             }
837 837
         }
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 
908 908
     // Actions column
909 909
     $table->set_header($header_nr++, get_lang('Action'), false);
910
-    $table->set_column_filter($header_nr-1, 'modify_filter');
910
+    $table->set_column_filter($header_nr - 1, 'modify_filter');
911 911
 
912 912
     if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
913 913
         $table->set_form_actions(array('unsubscribe' => get_lang('Unreg')), 'user');
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 } else {
916 916
     if ($course_info['unsubscribe'] == 1) {
917 917
         $table->set_header($header_nr++, get_lang('Action'), false);
918
-        $table->set_column_filter($header_nr-1, 'modify_filter');
918
+        $table->set_column_filter($header_nr - 1, 'modify_filter');
919 919
     }
920 920
 }
921 921
 
@@ -971,19 +971,19 @@  discard block
 block discarded – undo
971 971
     echo '<div class="col-md-6">';
972 972
     echo $icon;
973 973
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=csv&type='.$type.'">'.
974
-        Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
974
+        Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> ';
975 975
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=xls&type='.$type.'">'.
976
-        Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
976
+        Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> ';
977 977
 
978 978
     if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' ||
979 979
         api_is_platform_admin()
980 980
     ) {
981 981
         $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'.
982
-            Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> ';
982
+            Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM).'</a> ';
983 983
     }
984 984
 
985 985
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=pdf&type='.$type.'">'.
986
-        Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> ';
986
+        Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a> ';
987 987
     echo $actions;
988 988
 
989 989
     echo '</div>';
Please login to merge, or discard this patch.
main/webservices/additional_webservices.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 }
85 85
 
86 86
 /**
87
- * @param $directoryPath
87
+ * @param string $directoryPath
88 88
  * @return bool
89 89
  */
90 90
 function deleteDirectory($directoryPath)
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 {
20 20
     $fileData = $pptData['file_data'];
21 21
     $dataInfo = pathinfo($pptData['file_name']);
22
-    $fileName =  basename($pptData['file_name'], '.' . $dataInfo['extension']);
22
+    $fileName = basename($pptData['file_name'], '.'.$dataInfo['extension']);
23 23
     $fullFileName = $pptData['file_name'];
24 24
 
25 25
     $tempArchivePath = api_get_path(SYS_ARCHIVE_PATH);
26
-    $tempPath = $tempArchivePath . 'wsConvert/' . $fileName . '/';
27
-    $tempPathNewFiles = $tempArchivePath . 'wsConvert/' . $fileName . '-n/';
26
+    $tempPath = $tempArchivePath.'wsConvert/'.$fileName.'/';
27
+    $tempPathNewFiles = $tempArchivePath.'wsConvert/'.$fileName.'-n/';
28 28
 
29 29
     $perms = api_get_permissions_for_new_directories();
30 30
     if (!is_dir($tempPath)) {
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
     if (!is_dir($tempPathNewFiles)) {
34 34
         mkdir($tempPathNewFiles, $perms, true);
35 35
     }
36
-    if (!is_dir($tempPathNewFiles . $fileName)) {
37
-        mkdir($tempPathNewFiles . $fileName, $perms, true);
36
+    if (!is_dir($tempPathNewFiles.$fileName)) {
37
+        mkdir($tempPathNewFiles.$fileName, $perms, true);
38 38
     }
39 39
 
40 40
     $file = base64_decode($fileData);
41
-    file_put_contents($tempPath . $fullFileName, $file);
41
+    file_put_contents($tempPath.$fullFileName, $file);
42 42
 
43 43
     if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php
44
-        $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png');
45
-        $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar';
46
-        $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $classPath . '" DokeosConverter';
44
+        $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png');
45
+        $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar';
46
+        $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$classPath.'" DokeosConverter';
47 47
     } else {
48
-        $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png';
48
+        $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png';
49 49
         $classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar';
50
-        $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' DokeosConverter';
50
+        $cmd = 'cd '.$converterPath.' && java '.$classPath.' DokeosConverter';
51 51
     }
52 52
 
53
-    $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
54
-    $cmd .= ' -w 720 -h 540 -d oogie "' . $tempPath . $fullFileName.'"  "' . $tempPathNewFiles . $fileName . '.html"';
53
+    $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port');
54
+    $cmd .= ' -w 720 -h 540 -d oogie "'.$tempPath.$fullFileName.'"  "'.$tempPathNewFiles.$fileName.'.html"';
55 55
 
56 56
     $perms = api_get_permissions_for_new_files();
57
-    chmod($tempPathNewFiles . $fileName, $perms, true);
57
+    chmod($tempPathNewFiles.$fileName, $perms, true);
58 58
 
59 59
     $files = array();
60 60
     $return = 0;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $images = array();
65 65
         foreach ($files as $file) {
66 66
             $imageData = explode('||', $file);
67
-            $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles . $fileName . '/' . $imageData[1]));
67
+            $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles.$fileName.'/'.$imageData[1]));
68 68
         }
69 69
         $data = array(
70 70
             'files' => $files,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function deleteDirectory($directoryPath)
91 91
 {
92
-    $files = array_diff(scandir($directoryPath), array('.','..'));
92
+    $files = array_diff(scandir($directoryPath), array('.', '..'));
93 93
     foreach ($files as $file) {
94 94
         if (is_dir("$directoryPath/$file")) {
95 95
             deleteDirectory("$directoryPath/$file");
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 $webCodePath = api_get_path(WEB_CODE_PATH);
107 107
 $options = array(
108 108
     'uri' => $webPath,
109
-    'location' => $webCodePath . 'webservices/additional_webservices.php'
109
+    'location' => $webCodePath.'webservices/additional_webservices.php'
110 110
 );
111 111
 
112 112
 $soapServer = new SoapServer(NULL, $options);
Please login to merge, or discard this patch.
main/webservices/cm_webservice.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,6 +32,8 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param int Error code
34 34
 	 * @param string Error message
35
+	 * @param integer $code
36
+	 * @param string $message
35 37
 	 */
36 38
 	public function __construct($code, $message) {
37 39
 		$this->code = $code;
@@ -42,6 +44,7 @@  discard block
 block discarded – undo
42 44
 	 * Sets the error handler
43 45
 	 *
44 46
 	 * @param WSErrorHandler Error handler
47
+	 * @param WSCMSoapErrorHandler $handler
45 48
 	 */
46 49
 	public static function setErrorHandler($handler) {
47 50
 		if($handler instanceof WSErrorHandler) {
@@ -76,6 +79,7 @@  discard block
 block discarded – undo
76 79
 	 * Handle method
77 80
 	 *
78 81
 	 * @param WSError Error
82
+	 * @return void
79 83
 	 */
80 84
 	public function handle($error);
81 85
 }
@@ -102,7 +106,7 @@  discard block
 block discarded – undo
102 106
 	 * Verifies the API key
103 107
 	 *
104 108
 	 * @param string Secret key
105
-	 * @return mixed WSError in case of failure, null in case of success
109
+	 * @return WSCMError|null WSError in case of failure, null in case of success
106 110
 	 */
107 111
 	protected function verifyKey($secret_key) {
108 112
 		$ip = trim($_SERVER['REMOTE_ADDR']);
Please login to merge, or discard this patch.
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -6,120 +6,120 @@  discard block
 block discarded – undo
6 6
  * Error returned by one of the methods of the web service. Contains an error code and an error message
7 7
  */
8 8
 class WSCMError {
9
-	/**
10
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
11
-	 *
12
-	 * @var WSErrorHandler
13
-	 */
14
-	protected static $_handler;
9
+    /**
10
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
11
+     *
12
+     * @var WSErrorHandler
13
+     */
14
+    protected static $_handler;
15 15
 
16
-	/**
17
-	 * Error code
18
-	 *
19
-	 * @var int
20
-	 */
21
-	public $code;
16
+    /**
17
+     * Error code
18
+     *
19
+     * @var int
20
+     */
21
+    public $code;
22 22
 
23
-	/**
24
-	 * Error message
25
-	 *
26
-	 * @var string
27
-	 */
28
-	public $message;
23
+    /**
24
+     * Error message
25
+     *
26
+     * @var string
27
+     */
28
+    public $message;
29 29
 
30
-	/**
31
-	 * Constructor
32
-	 *
33
-	 * @param int Error code
34
-	 * @param string Error message
35
-	 */
36
-	public function __construct($code, $message) {
37
-		$this->code = $code;
38
-		$this->message = $message;
39
-	}
30
+    /**
31
+     * Constructor
32
+     *
33
+     * @param int Error code
34
+     * @param string Error message
35
+     */
36
+    public function __construct($code, $message) {
37
+        $this->code = $code;
38
+        $this->message = $message;
39
+    }
40 40
 
41
-	/**
42
-	 * Sets the error handler
43
-	 *
44
-	 * @param WSErrorHandler Error handler
45
-	 */
46
-	public static function setErrorHandler($handler) {
47
-		if($handler instanceof WSErrorHandler) {
48
-			self::$_handler = $handler;
49
-		}
50
-	}
41
+    /**
42
+     * Sets the error handler
43
+     *
44
+     * @param WSErrorHandler Error handler
45
+     */
46
+    public static function setErrorHandler($handler) {
47
+        if($handler instanceof WSErrorHandler) {
48
+            self::$_handler = $handler;
49
+        }
50
+    }
51 51
 
52
-	/**
53
-	 * Returns the error handler
54
-	 *
55
-	 * @return WSErrorHandler Error handler
56
-	 */
57
-	public static function getErrorHandler() {
58
-		return self::$_handler;
59
-	}
52
+    /**
53
+     * Returns the error handler
54
+     *
55
+     * @return WSErrorHandler Error handler
56
+     */
57
+    public static function getErrorHandler() {
58
+        return self::$_handler;
59
+    }
60 60
 
61
-	/**
62
-	 * Transforms the error into an array
63
-	 *
64
-	 * @return array Associative array with code and message
65
-	 */
66
-	public function toArray() {
67
-		return array('code' => $this->code, 'message' => $this->message);
68
-	}
61
+    /**
62
+     * Transforms the error into an array
63
+     *
64
+     * @return array Associative array with code and message
65
+     */
66
+    public function toArray() {
67
+        return array('code' => $this->code, 'message' => $this->message);
68
+    }
69 69
 }
70 70
 
71 71
 /**
72 72
  * Interface that must be implemented by any error handler
73 73
  */
74 74
 interface WSCMErrorHandler {
75
-	/**
76
-	 * Handle method
77
-	 *
78
-	 * @param WSError Error
79
-	 */
80
-	public function handle($error);
75
+    /**
76
+     * Handle method
77
+     *
78
+     * @param WSError Error
79
+     */
80
+    public function handle($error);
81 81
 }
82 82
 
83 83
 /**
84 84
  * Main class of the webservice. Webservice classes extend this class
85 85
  */
86 86
 class WSCM {
87
-	/**
88
-	 * Chamilo configuration
89
-	 *
90
-	 * @var array
91
-	 */
92
-	protected $_configuration;
87
+    /**
88
+     * Chamilo configuration
89
+     *
90
+     * @var array
91
+     */
92
+    protected $_configuration;
93 93
 
94
-	/**
95
-	 * Constructor
96
-	 */
97
-	public function __construct() {
98
-		$this->_configuration = $GLOBALS['_configuration'];
99
-	}
94
+    /**
95
+     * Constructor
96
+     */
97
+    public function __construct() {
98
+        $this->_configuration = $GLOBALS['_configuration'];
99
+    }
100 100
 
101
-	/**
102
-	 * Verifies the API key
103
-	 *
104
-	 * @param string Secret key
105
-	 * @return mixed WSError in case of failure, null in case of success
106
-	 */
107
-	protected function verifyKey($secret_key) {
108
-		$ip = trim($_SERVER['REMOTE_ADDR']);
109
-		// if we are behind a reverse proxy, assume it will send the
110
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
111
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
113
-		  $ip = trim($ip1);
114
-		}
115
-		$security_key = $ip.$this->_configuration['security_key'];
101
+    /**
102
+     * Verifies the API key
103
+     *
104
+     * @param string Secret key
105
+     * @return mixed WSError in case of failure, null in case of success
106
+     */
107
+    protected function verifyKey($secret_key) {
108
+        $ip = trim($_SERVER['REMOTE_ADDR']);
109
+        // if we are behind a reverse proxy, assume it will send the
110
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
111
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
+            list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
113
+            $ip = trim($ip1);
114
+        }
115
+        $security_key = $ip.$this->_configuration['security_key'];
116 116
 
117
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
118
-			return new WSCMError(1, "API key is invalid");
119
-		} else {
120
-			return null;
121
-		}
122
-	}
117
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
118
+            return new WSCMError(1, "API key is invalid");
119
+        } else {
120
+            return null;
121
+        }
122
+    }
123 123
 
124 124
         /**
125 125
          * Verifies if the user is valid
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
             $login = $username;
135 135
             $password = $pass;
136 136
 
137
-	    //lookup the user in the main database
137
+        //lookup the user in the main database
138 138
             $user_table = Database::get_main_table(TABLE_MAIN_USER);
139
-	    $sql = "SELECT user_id, username, password, auth_source, active, expiration_date
139
+        $sql = "SELECT user_id, username, password, auth_source, active, expiration_date
140 140
 	            FROM $user_table
141 141
 	            WHERE username = '".trim(addslashes($login))."'";
142
-	    $result = Database::query($sql);
142
+        $result = Database::query($sql);
143 143
 
144 144
             if (Database::num_rows($result) > 0) {
145 145
                 $uData = Database::fetch_array($result);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
         /**
173 173
          * Return the encrypted pass
174
-		 * @deprecated
174
+         * @deprecated
175 175
          * @param <String> $pass
176 176
          * @return <String> $pass encrypted
177 177
          */
@@ -180,112 +180,112 @@  discard block
 block discarded – undo
180 180
         }*/
181 181
 
182 182
         /**
183
-	 * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
184
-	 * in the system database
185
-	 *
186
-	 * @param string User id field name
187
-	 * @param string User id value
188
-	 * @return mixed System user id if the user was found, WSError otherwise
189
-	 */
190
-	protected function getUserId($user_id_field_name, $user_id_value) {
191
-		if($user_id_field_name == "chamilo_user_id") {
192
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
193
-				return intval($user_id_value);
194
-			} else {
195
-				return new WSCMError(100, "User not found");
196
-			}
197
-		} else {
198
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
-			if($user_id == 0) {
200
-				return new WSCMError(100, "User not found");
201
-			} else {
202
-				return $user_id;
203
-			}
204
-		}
205
-	}
183
+         * Gets the real user id based on the user id field name and value. Note that if the user id field name is "chamilo_user_id", it will use the user id
184
+         * in the system database
185
+         *
186
+         * @param string User id field name
187
+         * @param string User id value
188
+         * @return mixed System user id if the user was found, WSError otherwise
189
+         */
190
+    protected function getUserId($user_id_field_name, $user_id_value) {
191
+        if($user_id_field_name == "chamilo_user_id") {
192
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
193
+                return intval($user_id_value);
194
+            } else {
195
+                return new WSCMError(100, "User not found");
196
+            }
197
+        } else {
198
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
+            if($user_id == 0) {
200
+                return new WSCMError(100, "User not found");
201
+            } else {
202
+                return $user_id;
203
+            }
204
+        }
205
+    }
206 206
 
207
-	/**
208
-	 * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
209
-	 * in the system database
210
-	 *
211
-	 * @param string Course id field name
212
-	 * @param string Course id value
213
-	 * @return mixed System course id if the course was found, WSError otherwise
214
-	 */
215
-	protected function getCourseId($course_id_field_name, $course_id_value) {
216
-		if($course_id_field_name == "chamilo_course_id") {
217
-			if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218
-				return intval($course_id_value);
219
-			} else {
220
-				return new WSCMError(200, "Course not found");
221
-			}
222
-		} else {
223
-			$courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
224
-			if (empty($courseId)) {
225
-				return new WSCMError(200, "Course not found");
226
-			} else {
227
-				return $courseId;
228
-			}
229
-		}
230
-	}
207
+    /**
208
+     * Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
209
+     * in the system database
210
+     *
211
+     * @param string Course id field name
212
+     * @param string Course id value
213
+     * @return mixed System course id if the course was found, WSError otherwise
214
+     */
215
+    protected function getCourseId($course_id_field_name, $course_id_value) {
216
+        if($course_id_field_name == "chamilo_course_id") {
217
+            if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218
+                return intval($course_id_value);
219
+            } else {
220
+                return new WSCMError(200, "Course not found");
221
+            }
222
+        } else {
223
+            $courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
224
+            if (empty($courseId)) {
225
+                return new WSCMError(200, "Course not found");
226
+            } else {
227
+                return $courseId;
228
+            }
229
+        }
230
+    }
231 231
 
232
-	/**
233
-	 * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
234
-	 * in the system database
235
-	 *
236
-	 * @param string Session id field name
237
-	 * @param string Session id value
238
-	 * @return mixed System session id if the session was found, WSError otherwise
239
-	 */
240
-	protected function getSessionId($session_id_field_name, $session_id_value)
241
-	{
242
-		if ($session_id_field_name == "chamilo_session_id") {
243
-			$session = SessionManager::fetch((int)$session_id_value);
244
-			if(!empty($session)) {
245
-				return intval($session_id_value);
246
-			} else {
247
-				return new WSCMError(300, "Session not found");
248
-			}
249
-		} else {
250
-			$session_id = SessionManager::getSessionIdFromOriginalId(
251
-				$session_id_value,
252
-				$session_id_field_name
253
-			);
254
-			if($session_id == 0) {
255
-				return new WSCMError(300, "Session not found");
256
-			} else {
257
-				return $session_id;
258
-			}
259
-		}
260
-	}
232
+    /**
233
+     * Gets the real session id based on the session id field name and value. Note that if the session id field name is "chamilo_session_id", it will use the session id
234
+     * in the system database
235
+     *
236
+     * @param string Session id field name
237
+     * @param string Session id value
238
+     * @return mixed System session id if the session was found, WSError otherwise
239
+     */
240
+    protected function getSessionId($session_id_field_name, $session_id_value)
241
+    {
242
+        if ($session_id_field_name == "chamilo_session_id") {
243
+            $session = SessionManager::fetch((int)$session_id_value);
244
+            if(!empty($session)) {
245
+                return intval($session_id_value);
246
+            } else {
247
+                return new WSCMError(300, "Session not found");
248
+            }
249
+        } else {
250
+            $session_id = SessionManager::getSessionIdFromOriginalId(
251
+                $session_id_value,
252
+                $session_id_field_name
253
+            );
254
+            if($session_id == 0) {
255
+                return new WSCMError(300, "Session not found");
256
+            } else {
257
+                return $session_id;
258
+            }
259
+        }
260
+    }
261 261
 
262
-	/**
263
-	 * Handles an error by calling the WSError error handler
264
-	 *
265
-	 * @param WSError Error
266
-	 */
267
-	protected function handleError($error) {
268
-		$handler = WSCMError::getErrorHandler();
269
-		$handler->handle($error);
270
-	}
262
+    /**
263
+     * Handles an error by calling the WSError error handler
264
+     *
265
+     * @param WSError Error
266
+     */
267
+    protected function handleError($error) {
268
+        $handler = WSCMError::getErrorHandler();
269
+        $handler->handle($error);
270
+    }
271 271
 
272
-	/**
273
-	 * Gets a successful result
274
-	 *
275
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
276
-	 */
277
-	protected function getSuccessfulResult() {
278
-		return array('code' => 0, 'message' => 'Operation was successful');
279
-	}
272
+    /**
273
+     * Gets a successful result
274
+     *
275
+     * @return array Array with a code of 0 and a message 'Operation was successful'
276
+     */
277
+    protected function getSuccessfulResult() {
278
+        return array('code' => 0, 'message' => 'Operation was successful');
279
+    }
280 280
 
281
-	/**
282
-	 * Test function. Returns the string success
283
-	 *
284
-	 * @return string Success
285
-	 */
286
-	public function test() {
287
-		return "success";
288
-	}
281
+    /**
282
+     * Test function. Returns the string success
283
+     *
284
+     * @return string Success
285
+     */
286
+    public function test() {
287
+        return "success";
288
+    }
289 289
 
290 290
         /**
291 291
          * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param WSErrorHandler Error handler
45 45
 	 */
46 46
 	public static function setErrorHandler($handler) {
47
-		if($handler instanceof WSErrorHandler) {
47
+		if ($handler instanceof WSErrorHandler) {
48 48
 			self::$_handler = $handler;
49 49
 		}
50 50
 	}
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
 		// if we are behind a reverse proxy, assume it will send the
110 110
 		// HTTP_X_FORWARDED_FOR header and use this IP instead
111 111
 		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
112
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
112
+		  list($ip1, $ip2) = split(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
113 113
 		  $ip = trim($ip1);
114 114
 		}
115 115
 		$security_key = $ip.$this->_configuration['security_key'];
116 116
 
117
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
117
+		if (!api_is_valid_secret_key($secret_key, $security_key)) {
118 118
 			return new WSCMError(1, "API key is invalid");
119 119
 		} else {
120 120
 			return null;
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
                     // Check the user's password
150 150
                         if ($password == $uData['password'] AND (trim($login) == $uData['username'])) {
151 151
                         // Check if the account is active (not locked)
152
-                            if ($uData['active']=='1') {
152
+                            if ($uData['active'] == '1') {
153 153
                                 // Check if the expiration date has not been reached
154
-                                if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
154
+                                if ($uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date'] == '0000-00-00 00:00:00') {
155 155
                                     return "valid";
156 156
                                 }
157 157
                                 else
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 * @return mixed System user id if the user was found, WSError otherwise
189 189
 	 */
190 190
 	protected function getUserId($user_id_field_name, $user_id_value) {
191
-		if($user_id_field_name == "chamilo_user_id") {
192
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
191
+		if ($user_id_field_name == "chamilo_user_id") {
192
+			if (UserManager::is_user_id_valid(intval($user_id_value))) {
193 193
 				return intval($user_id_value);
194 194
 			} else {
195 195
 				return new WSCMError(100, "User not found");
196 196
 			}
197 197
 		} else {
198 198
 			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
199
-			if($user_id == 0) {
199
+			if ($user_id == 0) {
200 200
 				return new WSCMError(100, "User not found");
201 201
 			} else {
202 202
 				return $user_id;
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @return mixed System course id if the course was found, WSError otherwise
214 214
 	 */
215 215
 	protected function getCourseId($course_id_field_name, $course_id_value) {
216
-		if($course_id_field_name == "chamilo_course_id") {
217
-			if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
216
+		if ($course_id_field_name == "chamilo_course_id") {
217
+			if (CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
218 218
 				return intval($course_id_value);
219 219
 			} else {
220 220
 				return new WSCMError(200, "Course not found");
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	protected function getSessionId($session_id_field_name, $session_id_value)
241 241
 	{
242 242
 		if ($session_id_field_name == "chamilo_session_id") {
243
-			$session = SessionManager::fetch((int)$session_id_value);
244
-			if(!empty($session)) {
243
+			$session = SessionManager::fetch((int) $session_id_value);
244
+			if (!empty($session)) {
245 245
 				return intval($session_id_value);
246 246
 			} else {
247 247
 				return new WSCMError(300, "Session not found");
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 				$session_id_value,
252 252
 				$session_id_field_name
253 253
 			);
254
-			if($session_id == 0) {
254
+			if ($session_id == 0) {
255 255
 				return new WSCMError(300, "Session not found");
256 256
 			} else {
257 257
 				return $session_id;
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -153,18 +153,18 @@
 block discarded – undo
153 153
                                 // Check if the expiration date has not been reached
154 154
                                 if ($uData['expiration_date']>date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
155 155
                                     return "valid";
156
+                                } else {
157
+                                                                    return get_lang('AccountExpired');
156 158
                                 }
157
-                                else
158
-                                    return get_lang('AccountExpired');
159
+                            } else {
160
+                                                            return get_lang('AccountInactive');
159 161
                             }
160
-                            else
161
-                                return get_lang('AccountInactive');
162
+                        } else {
163
+                                                    return get_lang('InvalidId');
162 164
                         }
163
-                        else
164
-                            return get_lang('InvalidId');
165
+                    } else {
166
+                                            return get_lang('AccountURLInactive');
165 167
                     }
166
-                    else
167
-                        return get_lang('AccountURLInactive');
168 168
                 }
169 169
                 return get_lang('InvalidId');
170 170
         }
Please login to merge, or discard this patch.
main/webservices/cm_webservice_inbox.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -204,6 +204,9 @@
 block discarded – undo
204 204
 
205 205
     }
206 206
 
207
+    /**
208
+     * @param integer $user_id
209
+     */
207 210
     protected function set_message_as_read($user_id, $message_id){
208 211
         $table_message = Database::get_main_table(TABLE_MESSAGE);
209 212
         $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';";
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
             $table_message = Database::get_main_table(TABLE_MESSAGE);
38 38
 
39 39
             $sql_query = "SELECT id FROM $table_message " .
40
-                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
41
-                                     " ORDER BY send_date LIMIT $from,$number_of_items";
40
+                                        " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
41
+                                        " ORDER BY send_date LIMIT $from,$number_of_items";
42 42
 
43 43
             $sql_result = Database::query($sql_query);
44 44
             $message = "#";
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $table_message = Database::get_main_table(TABLE_MESSAGE);
87 87
 
88 88
             $sql_query = "SELECT ".$field_table." FROM $table_message " .
89
-                                     " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
89
+                                        " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
90 90
 
91 91
             $sql_result = Database::query($sql_query);
92 92
             $result = Database::fetch_row($sql_result);
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
             $table_message = Database::get_main_table(TABLE_MESSAGE);
108 108
 
109 109
             $sql_query = "SELECT id FROM $table_message " .
110
-					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
111
-					 "ORDER BY send_date LIMIT $from,$number_of_items";
110
+                        "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
111
+                        "ORDER BY send_date LIMIT $from,$number_of_items";
112 112
 
113 113
             $sql_result = Database::query($sql_query);
114 114
             $message = "#";
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $table_message = Database::get_main_table(TABLE_MESSAGE);
158 158
 
159 159
             $sql_query = "SELECT ".$field_table." FROM $table_message " .
160
-                                     " WHERE user_sender_id=".$user_id." AND id=".$id;
160
+                                        " WHERE user_sender_id=".$user_id." AND id=".$id;
161 161
 
162 162
             $sql_result = Database::query($sql_query);
163 163
             $result = Database::fetch_row($sql_result);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
             $table_message = Database::get_main_table(TABLE_MESSAGE);
189 189
 
190 190
             $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ".
191
-                           " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
191
+                            " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
192 192
             $result = Database::query($query);
193 193
 
194 194
             $query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) ".
195
-                           " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
195
+                            " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".api_get_utc_datetime()."','$subject','$content','$group_id','$parent_id', '".api_get_utc_datetime()."')";
196 196
             $result = Database::query($query);
197 197
 
198 198
             $inbox_last_id = Database::insert_id();
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function unreadMessage($username, $password)
14 14
     {
15
-        if($this->verifyUserPass($username, $password) == "valid")
15
+        if ($this->verifyUserPass($username, $password) == "valid")
16 16
         {
17 17
             $table_message = Database::get_main_table(TABLE_MESSAGE);
18 18
             $user_id = UserManager::get_user_id_from_username($username);
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function get_message_id($username, $password, $from, $number_of_items)
32 32
     {
33
-        if($this->verifyUserPass($username, $password) == "valid")
33
+        if ($this->verifyUserPass($username, $password) == "valid")
34 34
         {
35 35
             $user_id = UserManager::get_user_id_from_username($username);
36 36
 
37 37
             $table_message = Database::get_main_table(TABLE_MESSAGE);
38 38
 
39
-            $sql_query = "SELECT id FROM $table_message " .
40
-                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)" .
39
+            $sql_query = "SELECT id FROM $table_message ".
40
+                                     " WHERE user_receiver_id=".$user_id." AND msg_status IN (0,1)".
41 41
                                      " ORDER BY send_date LIMIT $from,$number_of_items";
42 42
 
43 43
             $sql_result = Database::query($sql_query);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function get_message_data($username, $password, $message_id, $field)
57 57
     {
58
-        if($this->verifyUserPass($username, $password) == "valid")
58
+        if ($this->verifyUserPass($username, $password) == "valid")
59 59
         {
60 60
             $htmlcode = false;
61 61
             $user_id = UserManager::get_user_id_from_username($username);
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 
86 86
             $table_message = Database::get_main_table(TABLE_MESSAGE);
87 87
 
88
-            $sql_query = "SELECT ".$field_table." FROM $table_message " .
88
+            $sql_query = "SELECT ".$field_table." FROM $table_message ".
89 89
                                      " WHERE user_receiver_id=".$user_id." AND id=".$message_id;
90 90
 
91 91
             $sql_result = Database::query($sql_query);
92 92
             $result = Database::fetch_row($sql_result);
93 93
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
94 94
 
95
-        }else
95
+        } else
96 96
             return get_lang('InvalidId');
97 97
 
98 98
 
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function get_message_id_sent($username, $password, $from, $number_of_items)
102 102
     {
103
-        if($this->verifyUserPass($username, $password) == "valid")
103
+        if ($this->verifyUserPass($username, $password) == "valid")
104 104
         {
105 105
             $user_id = UserManager::get_user_id_from_username($username);
106 106
 
107 107
             $table_message = Database::get_main_table(TABLE_MESSAGE);
108 108
 
109
-            $sql_query = "SELECT id FROM $table_message " .
110
-					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." " .
109
+            $sql_query = "SELECT id FROM $table_message ".
110
+					 "WHERE user_sender_id=".$user_id." AND msg_status=".MESSAGE_STATUS_OUTBOX." ".
111 111
 					 "ORDER BY send_date LIMIT $from,$number_of_items";
112 112
 
113 113
             $sql_result = Database::query($sql_query);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function get_message_data_sent($username, $password, $id, $field)
128 128
     {
129
-        if($this->verifyUserPass($username, $password) == "valid")
129
+        if ($this->verifyUserPass($username, $password) == "valid")
130 130
         {
131 131
             $htmlcode = false;
132 132
             switch ($field)
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
             $table_message = Database::get_main_table(TABLE_MESSAGE);
158 158
 
159
-            $sql_query = "SELECT ".$field_table." FROM $table_message " .
159
+            $sql_query = "SELECT ".$field_table." FROM $table_message ".
160 160
                                      " WHERE user_sender_id=".$user_id." AND id=".$id;
161 161
 
162 162
             $sql_result = Database::query($sql_query);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
166 166
 
167
-        }else
167
+        } else
168 168
             return get_lang('InvalidId');
169 169
 
170 170
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     public function message_send($username, $password, $receiver_user_id, $subject, $content)
174 174
     {
175 175
         //TODO: verificar data de envio. Esta divergindo de data!
176
-        if($this->verifyUserPass($username, $password) == "valid")
176
+        if ($this->verifyUserPass($username, $password) == "valid")
177 177
         {
178 178
             $group_id = intval(0);
179 179
             $parent_id = intval(0);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
     }
206 206
 
207
-    protected function set_message_as_read($user_id, $message_id){
207
+    protected function set_message_as_read($user_id, $message_id) {
208 208
         $table_message = Database::get_main_table(TABLE_MESSAGE);
209 209
         $query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".$user_id." AND id='".$message_id."';";
210 210
         $result = Database::query($query);
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 
49 49
             return $message;
50 50
 
51
-        } else
52
-            return get_lang('InvalidId');
51
+        } else {
52
+                    return get_lang('InvalidId');
53
+        }
53 54
 
54 55
     }
55 56
 
@@ -92,8 +93,9 @@  discard block
 block discarded – undo
92 93
             $result = Database::fetch_row($sql_result);
93 94
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
94 95
 
95
-        }else
96
-            return get_lang('InvalidId');
96
+        } else {
97
+                    return get_lang('InvalidId');
98
+        }
97 99
 
98 100
 
99 101
     }
@@ -118,8 +120,9 @@  discard block
 block discarded – undo
118 120
 
119 121
             return $message;
120 122
 
121
-        } else
122
-            return get_lang('InvalidId');
123
+        } else {
124
+                    return get_lang('InvalidId');
125
+        }
123 126
 
124 127
     }
125 128
 
@@ -164,8 +167,9 @@  discard block
 block discarded – undo
164 167
 
165 168
             return (htmlcode) ? html_entity_decode($result[0]) : $result[0];
166 169
 
167
-        }else
168
-            return get_lang('InvalidId');
170
+        } else {
171
+                    return get_lang('InvalidId');
172
+        }
169 173
 
170 174
 
171 175
     }
@@ -199,8 +203,9 @@  discard block
 block discarded – undo
199 203
 
200 204
             return $inbox_last_id;
201 205
 
202
-        } else
203
-            return get_lang('InvalidId');
206
+        } else {
207
+                    return get_lang('InvalidId');
208
+        }
204 209
 
205 210
     }
206 211
 
Please login to merge, or discard this patch.
main/webservices/cm_webservice_user.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
     /**
138 138
     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139 139
     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
140
+    * @param string[] $order_by a list of fields on which sort
141 141
     * @return array An array with all users of the platform.
142 142
     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         global $charset;
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98
-		    $user_id = UserManager::get_user_id_from_username($username);
98
+            $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100 100
             $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
101 101
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 
136 136
 
137 137
     /**
138
-    * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
-    * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
-    * @param array $order_by a list of fields on which sort
141
-    * @return array An array with all users of the platform.
142
-    * @todo optional course code parameter, optional sorting parameters...
138
+     * Get a list of users of which the given conditions match with a LIKE '%cond%'
139
+     * @param array $conditions a list of condition (exemple : status=>STUDENT)
140
+     * @param array $order_by a list of fields on which sort
141
+     * @return array An array with all users of the platform.
142
+     * @todo optional course code parameter, optional sorting parameters...
143 143
      *@todo Use the UserManager class
144 144
      * @todo security filter order by
145
-    */
145
+     */
146 146
     private static function get_user_list_like_start($conditions = array(), $order_by = array())
147 147
     {
148 148
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function find_id_user($username, $password, $name)
15 15
     {
16
-        if($this->verifyUserPass($username, $password) == "valid")
16
+        if ($this->verifyUserPass($username, $password) == "valid")
17 17
         {
18 18
 
19 19
             $listResult = "#";
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
             }
41 41
 
42 42
             $listArrayResult = array_unique($listArray);
43
-            foreach($listArrayResult as $result)
43
+            foreach ($listArrayResult as $result)
44 44
             {
45
-                $listResult .= $result . "#";
45
+                $listResult .= $result."#";
46 46
             }
47 47
 
48 48
             return $listResult;
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
         if ($this->verifyUserPass($username, $password) == "valid") {
98 98
 		    $user_id = UserManager::get_user_id_from_username($username);
99 99
             $message_title = get_lang('Invitation');
100
-            $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
100
+            $count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message);
101 101
 
102 102
             if ($count_is_true) {
103
-                return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
103
+                return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false);
104 104
             } else {
105
-                return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
105
+                return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false);
106 106
             }
107 107
         }
108 108
         return get_lang('InvalidId');
Please login to merge, or discard this patch.
main/webservices/lp.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -20,6 +20,9 @@
 block discarded – undo
20 20
 
21 21
 define('WS_ERROR_SECRET_KEY', 1);
22 22
 
23
+/**
24
+ * @param integer $code
25
+ */
23 26
 function return_error($code) {
24 27
     $fault = null;
25 28
     switch ($code) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -581,7 +581,7 @@
 block discarded – undo
581 581
     /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
582 582
     $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/
583 583
 
584
-     $courseInfo = CourseManager::getCourseInfoFromOriginalId(
584
+        $courseInfo = CourseManager::getCourseInfoFromOriginalId(
585 585
         $courseIdValue,
586 586
         $courseIdName
587 587
     );
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
     if ($debug) {
68
-        error_log("checkip " . intval($check_ip));
68
+        error_log("checkip ".intval($check_ip));
69 69
     }
70 70
 
71 71
     if ($check_ip) {
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 );
121 121
 
122 122
 // Register the method to expose
123
-$server->register('WSImportLP',                            // method name
124
-    array('params' => 'tns:params'),  // input parameters
125
-    array('return' => 'xsd:string'),                                        // output parameters
126
-    'urn:WSLP',                                                   // namespace
127
-    'urn:WSLP#WSImportLP',                       // soapaction
128
-    'rpc',                                                                  // style
129
-    'encoded',                                                              // use
123
+$server->register('WSImportLP', // method name
124
+    array('params' => 'tns:params'), // input parameters
125
+    array('return' => 'xsd:string'), // output parameters
126
+    'urn:WSLP', // namespace
127
+    'urn:WSLP#WSImportLP', // soapaction
128
+    'rpc', // style
129
+    'encoded', // use
130 130
     'This service adds users'                                               // documentation
131 131
 );
132 132
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     $uniqueFile = uniqid();
185 185
     $userId = 1; // admin
186
-    $filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile;
186
+    $filePath = api_get_path(SYS_ARCHIVE_PATH).$uniqueFile;
187 187
     file_put_contents($filePath, $fileData);
188 188
 
189 189
     $fileName = $params['filename'];
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
     'all',
258 258
     '',
259 259
     array(
260
-        'id'    => array('name' => 'id',    'type' => 'xsd:string'),
261
-        'name'  => array('name' => 'name',  'type' => 'xsd:string'),
260
+        'id'    => array('name' => 'id', 'type' => 'xsd:string'),
261
+        'name'  => array('name' => 'name', 'type' => 'xsd:string'),
262 262
     )
263 263
 );
264 264
 
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 );
275 275
 
276 276
 // Register the method to expose
277
-$server->register('WSGetLpList',                            // method name
278
-    array('params' => 'tns:paramsGetLpList'),  // input parameters
279
-    array('return' => 'tns:lpList'),                                        // output parameters
280
-    'urn:WSLP',                                                   // namespace
281
-    'urn:WSLP#WSGetLpList',                       // soapaction
282
-    'rpc',                                                                  // style
283
-    'encoded',                                                              // use
277
+$server->register('WSGetLpList', // method name
278
+    array('params' => 'tns:paramsGetLpList'), // input parameters
279
+    array('return' => 'tns:lpList'), // output parameters
280
+    'urn:WSLP', // namespace
281
+    'urn:WSLP#WSGetLpList', // soapaction
282
+    'rpc', // style
283
+    'encoded', // use
284 284
     'This service adds users'                                               // documentation
285 285
 );
286 286
 
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 );
370 370
 
371 371
 // Register the method to expose
372
-$server->register('WSDeleteLp',                            // method name
373
-    array('params' => 'tns:paramsDeleteLp'),  // input parameters
374
-    array('return' => 'xsd:string'),                                        // output parameters
375
-    'urn:WSLP',                                                   // namespace
376
-    'urn:WSLP#WSDeleteLp',                       // soapaction
377
-    'rpc',                                                                  // style
378
-    'encoded',                                                              // use
372
+$server->register('WSDeleteLp', // method name
373
+    array('params' => 'tns:paramsDeleteLp'), // input parameters
374
+    array('return' => 'xsd:string'), // output parameters
375
+    'urn:WSLP', // namespace
376
+    'urn:WSLP#WSDeleteLp', // soapaction
377
+    'rpc', // style
378
+    'encoded', // use
379 379
     'This service deletes a LP'                                               // documentation
380 380
 );
381 381
 
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
     if ($lp) {
435 435
         if ($debug) error_log("LP deleted $lpId");
436 436
 
437
-        $course_dir = $courseInfo['directory'] . '/document';
437
+        $course_dir = $courseInfo['directory'].'/document';
438 438
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
439
-        $base_work_dir = $sys_course_path . $course_dir;
439
+        $base_work_dir = $sys_course_path.$course_dir;
440 440
 
441 441
         $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId);
442 442
 
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
     'all',
496 496
     '',
497 497
     array(
498
-        'data'  => array('name' => 'data',  'type' => 'xsd:string'),
499
-        'title'  => array('name' => 'title',  'type' => 'xsd:string'),
500
-        'filename'  => array('name' => 'filename',  'type' => 'xsd:string'),
498
+        'data'  => array('name' => 'data', 'type' => 'xsd:string'),
499
+        'title'  => array('name' => 'title', 'type' => 'xsd:string'),
500
+        'filename'  => array('name' => 'filename', 'type' => 'xsd:string'),
501 501
     )
502 502
 );
503 503
 
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 );
549 549
 
550 550
 // Register the method to expose
551
-$server->register('WSCreateLp',                            // method name
552
-    array('params' => 'tns:paramsCreateLp'),  // input parameters
553
-    array('return' => 'xsd:string'),                                        // output parameters
554
-    'urn:WSLP',                                                   // namespace
555
-    'urn:WSLP#WSCreateLp',                       // soapaction
556
-    'rpc',                                                                  // style
557
-    'encoded',                                                              // use
551
+$server->register('WSCreateLp', // method name
552
+    array('params' => 'tns:paramsCreateLp'), // input parameters
553
+    array('return' => 'xsd:string'), // output parameters
554
+    'urn:WSLP', // namespace
555
+    'urn:WSLP#WSCreateLp', // soapaction
556
+    'rpc', // style
557
+    'encoded', // use
558 558
     'This service creates a LP'                                               // documentation
559 559
 );
560 560
 
Please login to merge, or discard this patch.
Braces   +48 added lines, -20 removed lines patch added patch discarded remove patch
@@ -48,19 +48,22 @@  discard block
 block discarded – undo
48 48
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
49 49
         $ip = trim($ip1);
50 50
     }
51
-    if ($debug)
52
-        error_log("ip: $ip");
51
+    if ($debug) {
52
+            error_log("ip: $ip");
53
+    }
53 54
     // Check if a file that limits access from webservices exists and contains
54 55
     // the restraining check
55 56
     if (is_file('webservice-auth-ip.conf.php')) {
56 57
         include 'webservice-auth-ip.conf.php';
57
-        if ($debug)
58
-            error_log("webservice-auth-ip.conf.php file included");
58
+        if ($debug) {
59
+                    error_log("webservice-auth-ip.conf.php file included");
60
+        }
59 61
         if (!empty($ws_auth_ip)) {
60 62
             $check_ip = true;
61 63
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
62
-            if ($debug)
63
-                error_log("ip_matches: $ip_matches");
64
+            if ($debug) {
65
+                            error_log("ip_matches: $ip_matches");
66
+            }
64 67
         }
65 68
     }
66 69
 
@@ -76,8 +79,9 @@  discard block
 block discarded – undo
76 79
     }
77 80
     $result = api_is_valid_secret_key($secret_key, $security_key);
78 81
     //error_log($secret_key.'-'.$security_key);
79
-    if ($debug)
80
-        error_log('WSHelperVerifyKey result: '.intval($result));
82
+    if ($debug) {
83
+            error_log('WSHelperVerifyKey result: '.intval($result));
84
+    }
81 85
     return $result;
82 86
 }
83 87
 
@@ -140,7 +144,9 @@  discard block
 block discarded – undo
140 144
     if (!WSHelperVerifyKey($params)) {
141 145
         return return_error(WS_ERROR_SECRET_KEY);
142 146
     }
143
-    if ($debug) error_log('WSImportLP');
147
+    if ($debug) {
148
+        error_log('WSImportLP');
149
+    }
144 150
 
145 151
     $courseIdName = $params['course_id_name'];
146 152
     $courseIdValue = $params['course_id_value'];
@@ -156,7 +162,9 @@  discard block
 block discarded – undo
156 162
     $courseId = $courseInfo['real_id'];
157 163
 
158 164
     if (empty($courseInfo)) {
159
-        if ($debug) error_log('Course not found');
165
+        if ($debug) {
166
+            error_log('Course not found');
167
+        }
160 168
         return 'Course not found';
161 169
     }
162 170
 
@@ -169,7 +177,9 @@  discard block
 block discarded – undo
169 177
 
170 178
         if (empty($sessionId)) {
171 179
 
172
-            if ($debug) error_log('Session not found');
180
+            if ($debug) {
181
+                error_log('Session not found');
182
+            }
173 183
             return 'Session not found';
174 184
         }
175 185
     }
@@ -196,7 +206,9 @@  discard block
 block discarded – undo
196 206
     $manifest = $oScorm->import_package($fileInfo, '', $courseInfo);
197 207
 
198 208
     if (!$manifest) {
199
-        if ($debug) error_log('manifest.xml file not found');
209
+        if ($debug) {
210
+            error_log('manifest.xml file not found');
211
+        }
200 212
         //if api_set_failure
201 213
         return 'manifest.xml file not found';
202 214
     }
@@ -215,10 +227,14 @@  discard block
 block discarded – undo
215 227
         $oScorm->set_maker($maker, $courseId);
216 228
         //$oScorm->set_jslib('scorm_api.php');
217 229
 
218
-        if ($debug) error_log('scorm was added');
230
+        if ($debug) {
231
+            error_log('scorm was added');
232
+        }
219 233
         return 1;
220 234
     } else {
221
-        if ($debug) error_log('manifest data empty');
235
+        if ($debug) {
236
+            error_log('manifest data empty');
237
+        }
222 238
         return 'manifest data empty';
223 239
     }
224 240
 }
@@ -311,7 +327,9 @@  discard block
 block discarded – undo
311 327
     );
312 328
 
313 329
     if (empty($courseInfo)) {
314
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
330
+        if ($debug) {
331
+            error_log("Course not found: $courseIdName : $courseIdValue");
332
+        }
315 333
         return 'Course not found';
316 334
     }
317 335
 
@@ -326,7 +344,9 @@  discard block
 block discarded – undo
326 344
 
327 345
         if (empty($sessionId)) {
328 346
 
329
-            if ($debug) error_log('Session not found');
347
+            if ($debug) {
348
+                error_log('Session not found');
349
+            }
330 350
             return 'Session not found';
331 351
         }
332 352
     }
@@ -407,7 +427,9 @@  discard block
 block discarded – undo
407 427
     );
408 428
 
409 429
     if (empty($courseInfo)) {
410
-        if ($debug) error_log("Course not found: $courseIdName : $courseIdValue");
430
+        if ($debug) {
431
+            error_log("Course not found: $courseIdName : $courseIdValue");
432
+        }
411 433
         return 'Course not found';
412 434
     }
413 435
     $courseId = $courseInfo['real_id'];
@@ -432,7 +454,9 @@  discard block
 block discarded – undo
432 454
 
433 455
     $lp = new learnpath($courseCode, $lpId, null);
434 456
     if ($lp) {
435
-        if ($debug) error_log("LP deleted $lpId");
457
+        if ($debug) {
458
+            error_log("LP deleted $lpId");
459
+        }
436 460
 
437 461
         $course_dir = $courseInfo['directory'] . '/document';
438 462
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
@@ -448,7 +472,9 @@  discard block
 block discarded – undo
448 472
                 if ($item) {
449 473
                     $documentId = $item->get_path();
450 474
 
451
-                    if ($debug) error_log("lp item id found #$itemId");
475
+                    if ($debug) {
476
+                        error_log("lp item id found #$itemId");
477
+                    }
452 478
 
453 479
                     $documentInfo = DocumentManager::get_document_data_by_id(
454 480
                         $documentId,
@@ -474,7 +500,9 @@  discard block
 block discarded – undo
474 500
                         }
475 501
                     }
476 502
                 } else {
477
-                    if ($debug) error_log("Document not found #$itemId");
503
+                    if ($debug) {
504
+                        error_log("Document not found #$itemId");
505
+                    }
478 506
                 }
479 507
             }
480 508
         }
Please login to merge, or discard this patch.
main/webservices/registration.soap.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -2617,6 +2617,9 @@
 block discarded – undo
2617 2617
     )
2618 2618
 );
2619 2619
 
2620
+/**
2621
+ * @param string $type
2622
+ */
2620 2623
 function WSHelperActionOnUsers($params, $type) {
2621 2624
     if(!WSHelperVerifyKey($params)) {
2622 2625
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
Braces   +169 added lines, -62 removed lines patch added patch discarded remove patch
@@ -63,19 +63,22 @@  discard block
 block discarded – undo
63 63
         list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
64 64
         $ip = trim($ip1);
65 65
     }
66
-    if ($debug)
67
-        error_log("ip: $ip");
66
+    if ($debug) {
67
+            error_log("ip: $ip");
68
+    }
68 69
     // Check if a file that limits access from webservices exists and contains
69 70
     // the restraining check
70 71
     if (is_file('webservice-auth-ip.conf.php')) {
71 72
         include 'webservice-auth-ip.conf.php';
72
-        if ($debug)
73
-            error_log("webservice-auth-ip.conf.php file included");
73
+        if ($debug) {
74
+                    error_log("webservice-auth-ip.conf.php file included");
75
+        }
74 76
         if (!empty($ws_auth_ip)) {
75 77
             $check_ip = true;
76 78
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
77
-            if ($debug)
78
-                error_log("ip_matches: $ip_matches");
79
+            if ($debug) {
80
+                            error_log("ip_matches: $ip_matches");
81
+            }
79 82
         }
80 83
     }
81 84
 
@@ -92,8 +95,9 @@  discard block
 block discarded – undo
92 95
 
93 96
     $result = api_is_valid_secret_key($secret_key, $security_key);
94 97
 
95
-    if ($debug)
96
-        error_log('WSHelperVerifyKey result: '.intval($result));
98
+    if ($debug) {
99
+            error_log('WSHelperVerifyKey result: '.intval($result));
100
+    }
97 101
     return $result;
98 102
 }
99 103
 
@@ -553,7 +557,9 @@  discard block
 block discarded – undo
553 557
 
554 558
     // First check wether the login already exists
555 559
     if (!UserManager::is_username_available($loginName)) {
556
-        if ($debug) error_log("Username $loginName is not available");
560
+        if ($debug) {
561
+            error_log("Username $loginName is not available");
562
+        }
557 563
         return 0;
558 564
     }
559 565
 
@@ -1012,7 +1018,9 @@  discard block
 block discarded – undo
1012 1018
     if (empty($userId) && empty($sessionId) && empty($courseId)) {
1013 1019
         // try original values
1014 1020
 
1015
-        if ($debug) error_log('try original values');
1021
+        if ($debug) {
1022
+            error_log('try original values');
1023
+        }
1016 1024
 
1017 1025
         $userIdName = isset($params['original_user_id_name']) ? $params['original_user_id_name'] : 0;
1018 1026
         $userIdValue = isset($params['original_user_id_value']) ? $params['original_user_id_value'] : 0;
@@ -1044,9 +1052,15 @@  discard block
 block discarded – undo
1044 1052
         );
1045 1053
     }
1046 1054
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1055
+    if ($debug) {
1056
+        error_log('$userId found: '. $userId);
1057
+    }
1058
+    if ($debug) {
1059
+        error_log('$courseId found: '. $courseId);
1060
+    }
1061
+    if ($debug) {
1062
+        error_log('$sessionId found: '. $sessionId);
1063
+    }
1050 1064
 
1051 1065
     return [
1052 1066
         'user_id' => $userId,
@@ -1076,13 +1090,17 @@  discard block
 block discarded – undo
1076 1090
 {
1077 1091
     global $debug;
1078 1092
 
1079
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1093
+    if ($debug) {
1094
+        error_log('WSSubscribeTeacherToSessionCourse');
1095
+    }
1080 1096
 
1081 1097
     if (!WSHelperVerifyKey($params)) {
1082 1098
         return returnError(WS_ERROR_SECRET_KEY);
1083 1099
     }
1084 1100
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1101
+    if ($debug) {
1102
+        error_log('Params '. print_r($params, 1));
1103
+    }
1086 1104
 
1087 1105
     $params = parseCourseSessionUserParams($params);
1088 1106
 
@@ -1095,13 +1113,17 @@  discard block
 block discarded – undo
1095 1113
     $result = 0;
1096 1114
 
1097 1115
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1116
+        if ($debug) {
1117
+            error_log('Coaches:  '. print_r($coaches, 1));
1118
+        }
1099 1119
         if (in_array($userId, $coaches)) {
1100 1120
             $result = 1;
1101 1121
         }
1102 1122
     }
1103 1123
 
1104
-    if ($debug) error_log('Result:  '. $result);
1124
+    if ($debug) {
1125
+        error_log('Result:  '. $result);
1126
+    }
1105 1127
 
1106 1128
     return $result;
1107 1129
 }
@@ -1127,13 +1149,17 @@  discard block
 block discarded – undo
1127 1149
 {
1128 1150
     global $debug;
1129 1151
 
1130
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1152
+    if ($debug) {
1153
+        error_log('WSSubscribeTeacherToSessionCourse');
1154
+    }
1131 1155
 
1132 1156
     if (!WSHelperVerifyKey($params)) {
1133 1157
         return returnError(WS_ERROR_SECRET_KEY);
1134 1158
     }
1135 1159
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1160
+    if ($debug) {
1161
+        error_log('Params '. print_r($params, 1));
1162
+    }
1137 1163
 
1138 1164
     $params = parseCourseSessionUserParams($params);
1139 1165
 
@@ -1147,7 +1173,9 @@  discard block
 block discarded – undo
1147 1173
     $result = 0;
1148 1174
 
1149 1175
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1176
+        if ($debug) {
1177
+            error_log('Coaches:  ' . print_r($coaches, 1));
1178
+        }
1151 1179
         if (!in_array($userId, $coaches)) {
1152 1180
             $result = 1;
1153 1181
         }
@@ -1155,7 +1183,9 @@  discard block
 block discarded – undo
1155 1183
         $result = 1;
1156 1184
     }
1157 1185
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1186
+    if ($debug) {
1187
+        error_log('Final Result: '. $result);
1188
+    }
1159 1189
 
1160 1190
     return $result;
1161 1191
 }
@@ -1207,8 +1237,12 @@  discard block
 block discarded – undo
1207 1237
 {
1208 1238
     global $_user, $_configuration, $debug;
1209 1239
     $debug = 1;
1210
-    if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1240
+    if ($debug) {
1241
+        error_log('WSCreateUserPasswordCrypted');
1242
+    }
1243
+    if ($debug) {
1244
+        error_log(print_r($params,1));
1245
+    }
1212 1246
 
1213 1247
     if (!WSHelperVerifyKey($params)) {
1214 1248
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1244,22 +1278,30 @@  discard block
 block discarded – undo
1244 1278
         if ($_configuration['password_encryption'] === $encrypt_method ) {
1245 1279
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1280
                 $msg = "Encryption $encrypt_method is invalid";
1247
-                if ($debug) error_log($msg);
1281
+                if ($debug) {
1282
+                    error_log($msg);
1283
+                }
1248 1284
                 return $msg;
1249 1285
 
1250 1286
             } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
1251 1287
                 $msg = "Encryption $encrypt_method is invalid";
1252
-                if ($debug) error_log($msg);
1288
+                if ($debug) {
1289
+                    error_log($msg);
1290
+                }
1253 1291
                 return $msg;
1254 1292
             }
1255 1293
         } else {
1256 1294
             $msg = "This encryption $encrypt_method is not configured";
1257
-            if ($debug) error_log($msg);
1295
+            if ($debug) {
1296
+                error_log($msg);
1297
+            }
1258 1298
             return $msg;
1259 1299
         }
1260 1300
     } else {
1261 1301
         $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
1262
-        if ($debug) error_log($msg);
1302
+        if ($debug) {
1303
+            error_log($msg);
1304
+        }
1263 1305
         return $msg;
1264 1306
     }
1265 1307
 
@@ -1279,10 +1321,14 @@  discard block
 block discarded – undo
1279 1321
         $original_user_id_name
1280 1322
     );
1281 1323
 
1282
-    if ($debug) error_log('Ready to create user');
1324
+    if ($debug) {
1325
+        error_log('Ready to create user');
1326
+    }
1283 1327
 
1284 1328
     if ($user_id > 0) {
1285
-        if ($debug) error_log('User found with id: '.$user_id);
1329
+        if ($debug) {
1330
+            error_log('User found with id: '.$user_id);
1331
+        }
1286 1332
 
1287 1333
         // Check whether user is not active
1288 1334
         //@todo why this condition exists??
@@ -1293,7 +1339,9 @@  discard block
 block discarded – undo
1293 1339
         $count_check_user = Database::num_rows($resu);
1294 1340
         if ($count_check_user > 0) {
1295 1341
 
1296
-            if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1342
+            if ($debug) {
1343
+                error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1344
+            }
1297 1345
 
1298 1346
             $sql = "UPDATE $table_user SET
1299 1347
                     lastname='".Database::escape_string($lastName)."',
@@ -1313,7 +1361,9 @@  discard block
 block discarded – undo
1313 1361
                     active='1',
1314 1362
                     hr_dept_id=".intval($hr_dept_id);
1315 1363
             $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1316
-            if ($debug) error_log($sql);
1364
+            if ($debug) {
1365
+                error_log($sql);
1366
+            }
1317 1367
             Database::query($sql);
1318 1368
 
1319 1369
             if (is_array($extra_list) && count($extra_list) > 0) {
@@ -1330,11 +1380,15 @@  discard block
 block discarded – undo
1330 1380
             }
1331 1381
             return $r_check_user[0];
1332 1382
         } else {
1333
-            if ($debug) error_log('User exists but is active. Cant be updated');
1383
+            if ($debug) {
1384
+                error_log('User exists but is active. Cant be updated');
1385
+            }
1334 1386
             return 0;
1335 1387
         }
1336 1388
     } else {
1337
-        if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1389
+        if ($debug) {
1390
+            error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1391
+        }
1338 1392
     }
1339 1393
 
1340 1394
     // Default language.
@@ -1350,7 +1404,9 @@  discard block
 block discarded – undo
1350 1404
 
1351 1405
     // First check wether the login already exists
1352 1406
     if (!UserManager::is_username_available($loginName)) {
1353
-        if ($debug) error_log("Username $loginName is not available");
1407
+        if ($debug) {
1408
+            error_log("Username $loginName is not available");
1409
+        }
1354 1410
         return 0;
1355 1411
     }
1356 1412
 
@@ -1372,7 +1428,9 @@  discard block
 block discarded – undo
1372 1428
             expiration_date     = '".Database::escape_string($expiration_date)."',
1373 1429
             hr_dept_id          = '".Database::escape_string($hr_dept_id)."',
1374 1430
             active              = '".Database::escape_string($active)."'";
1375
-    if ($debug) error_log($sql);
1431
+    if ($debug) {
1432
+        error_log($sql);
1433
+    }
1376 1434
 
1377 1435
     Database::query($sql);
1378 1436
     $return = Database::insert_id();
@@ -1384,7 +1442,9 @@  discard block
 block discarded – undo
1384 1442
 
1385 1443
         $url_id = api_get_current_access_url_id();
1386 1444
         UrlManager::add_user_to_url($return, $url_id);
1387
-        if ($debug) error_log("Adding user_id = $return to URL id $url_id ");
1445
+        if ($debug) {
1446
+            error_log("Adding user_id = $return to URL id $url_id ");
1447
+        }
1388 1448
 
1389 1449
         // Create extra field for the original_user_id_name
1390 1450
         UserManager::create_extra_field(
@@ -1421,7 +1481,9 @@  discard block
 block discarded – undo
1421 1481
             }
1422 1482
         }
1423 1483
     } else {
1424
-        if ($debug) error_log('Error while inserting a user');
1484
+        if ($debug) {
1485
+            error_log('Error while inserting a user');
1486
+        }
1425 1487
         return 0;
1426 1488
     }
1427 1489
 
@@ -4480,7 +4542,9 @@  discard block
 block discarded – undo
4480 4542
     if (!WSHelperVerifyKey($params)) {
4481 4543
         return returnError(WS_ERROR_SECRET_KEY);
4482 4544
     }
4483
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4545
+    if ($debug) {
4546
+        error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4547
+    }
4484 4548
 
4485 4549
     $results = array();
4486 4550
     $userscourses = $params['userscourses'];
@@ -4499,7 +4563,9 @@  discard block
 block discarded – undo
4499 4563
             $original_user_id['original_user_id_value'],
4500 4564
             $original_user_id['original_user_id_name']
4501 4565
         );
4502
-        if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4566
+        if ($debug) {
4567
+            error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4568
+        }
4503 4569
 
4504 4570
         if ($user_id == 0) {
4505 4571
             // If user was not found, there was a problem
@@ -4517,13 +4583,19 @@  discard block
 block discarded – undo
4517 4583
                 // Course was not found
4518 4584
                 $resultValue = 0;
4519 4585
             } else {
4520
-                if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4586
+                if ($debug) {
4587
+                    error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4588
+                }
4521 4589
                 $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false);
4522 4590
                 if ($result) {
4523 4591
                     $resultValue = 1;
4524
-                    if ($debug) error_log('WSSubscribeUserToCourse subscribed');
4592
+                    if ($debug) {
4593
+                        error_log('WSSubscribeUserToCourse subscribed');
4594
+                    }
4525 4595
                 } else {
4526
-                    if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: ');
4596
+                    if ($debug) {
4597
+                        error_log('WSSubscribeUserToCourse NOT subscribed: ');
4598
+                    }
4527 4599
                 }
4528 4600
             }
4529 4601
         }
@@ -4581,8 +4653,12 @@  discard block
 block discarded – undo
4581 4653
 function WSSubscribeUserToCourseSimple($params) {
4582 4654
     global $debug;
4583 4655
 
4584
-    if ($debug) error_log('WSSubscribeUserToCourseSimple');
4585
-    if ($debug) error_log('Params '. print_r($params, 1));
4656
+    if ($debug) {
4657
+        error_log('WSSubscribeUserToCourseSimple');
4658
+    }
4659
+    if ($debug) {
4660
+        error_log('Params '. print_r($params, 1));
4661
+    }
4586 4662
     if (!WSHelperVerifyKey($params)) {
4587 4663
         return returnError(WS_ERROR_SECRET_KEY);
4588 4664
     }
@@ -4597,7 +4673,9 @@  discard block
 block discarded – undo
4597 4673
     if (empty($user_data)) {
4598 4674
         // If user was not found, there was a problem
4599 4675
         $result = "User $user_id does not exist";
4600
-        if ($debug) error_log($result);
4676
+        if ($debug) {
4677
+            error_log($result);
4678
+        }
4601 4679
         return $result;
4602 4680
     }
4603 4681
     if (!empty($course_code)) {
@@ -4605,14 +4683,22 @@  discard block
 block discarded – undo
4605 4683
         if (empty($course_data)) {
4606 4684
             // Course was not found
4607 4685
             $result = "Course $course_code does not exist in the platform ";
4608
-            if ($debug) error_log($result);
4686
+            if ($debug) {
4687
+                error_log($result);
4688
+            }
4609 4689
         } else {
4610
-            if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4690
+            if ($debug) {
4691
+                error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4692
+            }
4611 4693
             if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) {
4612 4694
                 $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions ';
4613
-                if ($debug) error_log($result);
4695
+                if ($debug) {
4696
+                    error_log($result);
4697
+                }
4614 4698
             } else {
4615
-                if ($debug) error_log('User registered to the course: '.$course_data['code']);
4699
+                if ($debug) {
4700
+                    error_log('User registered to the course: '.$course_data['code']);
4701
+                }
4616 4702
                 $result = 1;
4617 4703
             }
4618 4704
         }
@@ -4664,8 +4750,12 @@  discard block
 block discarded – undo
4664 4750
 // define the method WSGetUser
4665 4751
 function WSGetUser($params) {
4666 4752
     global $debug;
4667
-    if ($debug) error_log('WSGetUser');
4668
-    if ($debug) error_log('$params: '.print_r($params, 1));
4753
+    if ($debug) {
4754
+        error_log('WSGetUser');
4755
+    }
4756
+    if ($debug) {
4757
+        error_log('$params: '.print_r($params, 1));
4758
+    }
4669 4759
 
4670 4760
     if (!WSHelperVerifyKey($params)) {
4671 4761
         return returnError(WS_ERROR_SECRET_KEY);
@@ -4718,8 +4808,12 @@  discard block
 block discarded – undo
4718 4808
 // define the method WSGetUserFromUsername
4719 4809
 function WSGetUserFromUsername($params) {
4720 4810
     global $debug;
4721
-    if ($debug) error_log('WSGetUserFromUsername');
4722
-    if ($debug) error_log('$params: '.print_r($params, 1));
4811
+    if ($debug) {
4812
+        error_log('WSGetUserFromUsername');
4813
+    }
4814
+    if ($debug) {
4815
+        error_log('$params: '.print_r($params, 1));
4816
+    }
4723 4817
 
4724 4818
     if (!WSHelperVerifyKey($params)) {
4725 4819
         return returnError(WS_ERROR_SECRET_KEY);
@@ -5169,7 +5263,9 @@  discard block
 block discarded – undo
5169 5263
                 $orig_session_id_value[] = $original_session_id_value;
5170 5264
                 $results[] = 1;
5171 5265
 
5172
-                if ($debug) error_log("subscribe user:$user_id to session $sessionId");
5266
+                if ($debug) {
5267
+                    error_log("subscribe user:$user_id to session $sessionId");
5268
+                }
5173 5269
             }
5174 5270
         }
5175 5271
     } // end principal foreach
@@ -5253,7 +5349,9 @@  discard block
 block discarded – undo
5253 5349
                 SESSION_VISIBLE_READ_ONLY,
5254 5350
                 false
5255 5351
             );
5256
-            if ($debug) error_log('User registered to the course: '.$session_id);
5352
+            if ($debug) {
5353
+                error_log('User registered to the course: '.$session_id);
5354
+            }
5257 5355
             $result = 1;
5258 5356
         }
5259 5357
     }
@@ -5399,7 +5497,9 @@  discard block
 block discarded – undo
5399 5497
                 $orig_session_id_value[] = $original_session_id_value;
5400 5498
                 $results[] = 1;
5401 5499
 
5402
-                if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session");
5500
+                if ($debug) {
5501
+                    error_log("Unsubscribe user:$user_id to session:$id_session");
5502
+                }
5403 5503
             }
5404 5504
         }
5405 5505
     } // end principal foreach
@@ -5546,7 +5646,9 @@  discard block
 block discarded – undo
5546 5646
         return returnError(WS_ERROR_SECRET_KEY);
5547 5647
     }
5548 5648
 
5549
-    if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5649
+    if ($debug) {
5650
+        error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5651
+    }
5550 5652
 
5551 5653
     $coursessessions_params = $params['coursessessions'];
5552 5654
     $results = array();
@@ -5584,7 +5686,9 @@  discard block
 block discarded – undo
5584 5686
                     array($courseInfo['real_id']),
5585 5687
                     false
5586 5688
                 );
5587
-                if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5689
+                if ($debug) {
5690
+                    error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5691
+                }
5588 5692
 
5589 5693
                 $results[] = 1;
5590 5694
                 $orig_course_id_value[] = $original_session_id_value;
@@ -5935,8 +6039,7 @@  discard block
 block discarded – undo
5935 6039
             UserManager::create_extra_field($params['original_user_id_name'], 1, $params['original_user_id_name'], '');
5936 6040
             // Save the external system's id into user_field_value table.
5937 6041
             UserManager::update_extra_field_value($user_id, $params['original_user_id_name'], $params['original_user_id_value']);
5938
-        }
5939
-        else {
6042
+        } else {
5940 6043
             return 0;
5941 6044
         }
5942 6045
     }
@@ -6086,8 +6189,12 @@  discard block
 block discarded – undo
6086 6189
 {
6087 6190
     global $debug;
6088 6191
 
6089
-    if ($debug) error_log('WSUserSubscribedInCourse');
6090
-    if ($debug) error_log('Params '. print_r($params, 1));
6192
+    if ($debug) {
6193
+        error_log('WSUserSubscribedInCourse');
6194
+    }
6195
+    if ($debug) {
6196
+        error_log('Params '. print_r($params, 1));
6197
+    }
6091 6198
     if (!WSHelperVerifyKey($params)) {
6092 6199
 
6093 6200
         return returnError(WS_ERROR_SECRET_KEY);
Please login to merge, or discard this patch.
Spacing   +455 added lines, -455 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
     if ($debug) {
83
-        error_log("checkip " . intval($check_ip));
83
+        error_log("checkip ".intval($check_ip));
84 84
     }
85 85
 
86 86
     if ($check_ip) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     '',
139 139
     'SOAP-ENC:Array',
140 140
     array(),
141
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:extras[]')),
141
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:extras[]')),
142 142
     'tns:extras'
143 143
 );
144 144
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     '',
172 172
     'SOAP-ENC:Array',
173 173
     array(),
174
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')),
174
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:usersParams[]')),
175 175
     'tns:usersParams'
176 176
 );
177 177
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
     '',
211 211
     'SOAP-ENC:Array',
212 212
     array(),
213
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:result_createUsers[]')),'tns:result_createUsers'
213
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsers[]')), 'tns:result_createUsers'
214 214
 );
215 215
 
216 216
 // Register the method to expose
217
-$server->register('WSCreateUsers',                 // method name
218
-    array('createUsers' => 'tns:createUsers'),     // input parameters
219
-    array('return' => 'tns:results_createUsers'),  // output parameters
220
-    'urn:WSRegistration',                          // namespace
221
-    'urn:WSRegistration#WSCreateUsers',            // soapaction
222
-    'rpc',                                         // style
223
-    'encoded',                                     // use
217
+$server->register('WSCreateUsers', // method name
218
+    array('createUsers' => 'tns:createUsers'), // input parameters
219
+    array('return' => 'tns:results_createUsers'), // output parameters
220
+    'urn:WSRegistration', // namespace
221
+    'urn:WSRegistration#WSCreateUsers', // soapaction
222
+    'rpc', // style
223
+    'encoded', // use
224 224
     'This service adds a user'                     // documentation
225 225
 );
226 226
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             continue;
402 402
         }
403 403
 
404
-        $results[] =  $userId;
404
+        $results[] = $userId;
405 405
 
406 406
     } // end principal foreach
407 407
 
@@ -447,13 +447,13 @@  discard block
 block discarded – undo
447 447
 
448 448
 
449 449
 // Register the method to expose
450
-$server->register('WSCreateUser',                // method name
451
-    array('createUser' => 'tns:createUser'),     // input parameters
452
-    array('return' => 'xsd:string'),             // output parameters
453
-    'urn:WSRegistration',                        // namespace
454
-    'urn:WSRegistration#WSCreateUser',           // soapaction
455
-    'rpc',                                       // style
456
-    'encoded',                                   // use
450
+$server->register('WSCreateUser', // method name
451
+    array('createUser' => 'tns:createUser'), // input parameters
452
+    array('return' => 'xsd:string'), // output parameters
453
+    'urn:WSRegistration', // namespace
454
+    'urn:WSRegistration#WSCreateUser', // soapaction
455
+    'rpc', // style
456
+    'encoded', // use
457 457
     'This service adds a user'                   // documentation
458 458
 );
459 459
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     }
559 559
 
560 560
     if (isset($original_user_id_name) && isset($original_user_id_value)) {
561
-        $_SESSION['ws_' . $original_user_id_name] = $original_user_id_value;
561
+        $_SESSION['ws_'.$original_user_id_name] = $original_user_id_value;
562 562
     }
563 563
 
564 564
     /** @var User $user */
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
         );
607 607
 
608 608
         if (isset($original_user_id_name) && isset($original_user_id_value)) {
609
-            unset($_SESSION['ws_' . $original_user_id_name]);
609
+            unset($_SESSION['ws_'.$original_user_id_name]);
610 610
         }
611 611
 
612 612
         if (is_array($extra_list) && count($extra_list) > 0) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         'language'              => array('name' => 'language', 'type' => 'xsd:string'),
659 659
         'phone'                 => array('name' => 'phone', 'type' => 'xsd:string'),
660 660
         'expiration_date'       => array('name' => 'expiration_date', 'type' => 'xsd:string'),
661
-        'official_code'         => array('name' => 'official_code',    'type' => 'xsd:string'),
661
+        'official_code'         => array('name' => 'official_code', 'type' => 'xsd:string'),
662 662
         'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
663 663
         'original_user_id_value'=> array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
664 664
         'extra'                 => array('name' => 'extra', 'type' => 'tns:extrasList')
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     'all',
687 687
     '',
688 688
     array(
689
-        'users'         => array('name' => 'users',      'type' => 'tns:createUsersPassEncryptParamsList'),
689
+        'users'         => array('name' => 'users', 'type' => 'tns:createUsersPassEncryptParamsList'),
690 690
         'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
691 691
     )
692 692
 );
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 );
717 717
 
718 718
 // Register the method to expose
719
-$server->register('WSCreateUsersPasswordCrypted',                            // method name
719
+$server->register('WSCreateUsersPasswordCrypted', // method name
720 720
     array('createUsersPasswordCrypted' => 'tns:createUsersPasswordCrypted'), // input parameters
721
-    array('return' => 'tns:results_createUsersPassEncrypt'),                 // output parameters
722
-    'urn:WSRegistration',                                                    // namespace
723
-    'urn:WSRegistration#WSCreateUsersPasswordCrypted',                       // soapaction
724
-    'rpc',                                                                   // style
725
-    'encoded',                                                               // use
721
+    array('return' => 'tns:results_createUsersPassEncrypt'), // output parameters
722
+    'urn:WSRegistration', // namespace
723
+    'urn:WSRegistration#WSCreateUsersPasswordCrypted', // soapaction
724
+    'rpc', // style
725
+    'encoded', // use
726 726
     'This service adds users to the system'                                  // documentation
727 727
 );
728 728
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $salt = '';
770 770
 
771 771
         if (!empty($_configuration['password_encryption'])) {
772
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
772
+            if ($_configuration['password_encryption'] === $encrypt_method) {
773 773
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
774 774
                     $msg = "Encryption $encrypt_method is invalid";
775 775
                     $results[] = $msg;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 
793 793
         if (is_array($extra_list) && count($extra_list) > 0) {
794 794
             foreach ($extra_list as $extra) {
795
-                if($extra['field_name'] == 'salt') {
795
+                if ($extra['field_name'] == 'salt') {
796 796
                     $salt = $extra['field_value'];
797 797
                     break;
798 798
                 }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
                         active='1',
848 848
                         hr_dept_id=".intval($hr_dept_id);
849 849
 
850
-                $sql .=  " WHERE user_id='".$r_check_user[0]."'";
850
+                $sql .= " WHERE user_id='".$r_check_user[0]."'";
851 851
                 Database::query($sql);
852 852
 
853 853
                 if (is_array($extra_list) && count($extra_list) > 0) {
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 
968 968
     $count_results = count($results);
969 969
     $output = array();
970
-    for($i = 0; $i < $count_results; $i++) {
970
+    for ($i = 0; $i < $count_results; $i++) {
971 971
         $output[] = array(
972 972
             'original_user_id_value' => $orig_user_id_value[$i],
973 973
             'result' => $results[$i],
@@ -986,9 +986,9 @@  discard block
 block discarded – undo
986 986
     'all',
987 987
     '',
988 988
     array(
989
-        'user_id' => array('name' => 'course',     'type' => 'xsd:string'), // Chamilo user Id
990
-        'session_id' => array('name' => 'user_id',    'type' => 'xsd:string'), // Current Session course ID
991
-        'course_id' =>array('name' => 'courseId',      'type' => 'xsd:string'), // Course Real Id
989
+        'user_id' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id
990
+        'session_id' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID
991
+        'course_id' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id
992 992
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
993 993
 
994 994
         // optional
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
         );
1045 1045
     }
1046 1046
 
1047
-    if ($debug) error_log('$userId found: '. $userId);
1048
-    if ($debug) error_log('$courseId found: '. $courseId);
1049
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1047
+    if ($debug) error_log('$userId found: '.$userId);
1048
+    if ($debug) error_log('$courseId found: '.$courseId);
1049
+    if ($debug) error_log('$sessionId found: '.$sessionId);
1050 1050
 
1051 1051
     return [
1052 1052
         'user_id' => $userId,
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
         return returnError(WS_ERROR_SECRET_KEY);
1083 1083
     }
1084 1084
 
1085
-    if ($debug) error_log('Params '. print_r($params, 1));
1085
+    if ($debug) error_log('Params '.print_r($params, 1));
1086 1086
 
1087 1087
     $params = parseCourseSessionUserParams($params);
1088 1088
 
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
     $result = 0;
1096 1096
 
1097 1097
     if (!empty($coaches)) {
1098
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1098
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1099 1099
         if (in_array($userId, $coaches)) {
1100 1100
             $result = 1;
1101 1101
         }
1102 1102
     }
1103 1103
 
1104
-    if ($debug) error_log('Result:  '. $result);
1104
+    if ($debug) error_log('Result:  '.$result);
1105 1105
 
1106 1106
     return $result;
1107 1107
 }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
         return returnError(WS_ERROR_SECRET_KEY);
1134 1134
     }
1135 1135
 
1136
-    if ($debug) error_log('Params '. print_r($params, 1));
1136
+    if ($debug) error_log('Params '.print_r($params, 1));
1137 1137
 
1138 1138
     $params = parseCourseSessionUserParams($params);
1139 1139
 
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
     $result = 0;
1148 1148
 
1149 1149
     if (!empty($coaches)) {
1150
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1150
+        if ($debug) error_log('Coaches:  '.print_r($coaches, 1));
1151 1151
         if (!in_array($userId, $coaches)) {
1152 1152
             $result = 1;
1153 1153
         }
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
         $result = 1;
1156 1156
     }
1157 1157
 
1158
-    if ($debug) error_log('Final Result: '. $result);
1158
+    if ($debug) error_log('Final Result: '.$result);
1159 1159
 
1160 1160
     return $result;
1161 1161
 }
@@ -1173,32 +1173,32 @@  discard block
 block discarded – undo
1173 1173
     'all',
1174 1174
     '',
1175 1175
     array(
1176
-        'firstname'                 => array('name' => 'firstname',                 'type' => 'xsd:string'),
1177
-        'lastname'                  => array('name' => 'lastname',                  'type' => 'xsd:string'),
1178
-        'status'                    => array('name' => 'status',                    'type' => 'xsd:string'),
1179
-        'email'                     => array('name' => 'email',                     'type' => 'xsd:string'),
1180
-        'loginname'                 => array('name' => 'loginname',                 'type' => 'xsd:string'),
1181
-        'password'                  => array('name' => 'password',                  'type' => 'xsd:string'), //encripted password using the encrypt_method
1182
-        'encrypt_method'            => array('name' => 'encrypt_method',            'type' => 'xsd:string'),
1183
-        'language'                  => array('name' => 'language',                  'type' => 'xsd:string'),
1184
-        'phone'                     => array('name' => 'phone',                     'type' => 'xsd:string'),
1185
-        'expiration_date'           => array('name' => 'expiration_date',           'type' => 'xsd:string'),
1186
-        'official_code'             => array('name' => 'official_code',             'type' => 'xsd:string'),
1187
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
1188
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
1189
-        'extra'                     => array('name' => 'extra',                     'type' => 'tns:extrasList'),
1190
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
1176
+        'firstname'                 => array('name' => 'firstname', 'type' => 'xsd:string'),
1177
+        'lastname'                  => array('name' => 'lastname', 'type' => 'xsd:string'),
1178
+        'status'                    => array('name' => 'status', 'type' => 'xsd:string'),
1179
+        'email'                     => array('name' => 'email', 'type' => 'xsd:string'),
1180
+        'loginname'                 => array('name' => 'loginname', 'type' => 'xsd:string'),
1181
+        'password'                  => array('name' => 'password', 'type' => 'xsd:string'), //encripted password using the encrypt_method
1182
+        'encrypt_method'            => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
1183
+        'language'                  => array('name' => 'language', 'type' => 'xsd:string'),
1184
+        'phone'                     => array('name' => 'phone', 'type' => 'xsd:string'),
1185
+        'expiration_date'           => array('name' => 'expiration_date', 'type' => 'xsd:string'),
1186
+        'official_code'             => array('name' => 'official_code', 'type' => 'xsd:string'),
1187
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
1188
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
1189
+        'extra'                     => array('name' => 'extra', 'type' => 'tns:extrasList'),
1190
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
1191 1191
     )
1192 1192
 );
1193 1193
 
1194 1194
 // Register the method to expose
1195
-$server->register('WSCreateUserPasswordCrypted',                            // method name
1196
-    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'),  // input parameters
1197
-    array('return' => 'xsd:string'),                                        // output parameters
1198
-    'urn:WSRegistration',                                                   // namespace
1199
-    'urn:WSRegistration#WSCreateUserPasswordCrypted',                       // soapaction
1200
-    'rpc',                                                                  // style
1201
-    'encoded',                                                              // use
1195
+$server->register('WSCreateUserPasswordCrypted', // method name
1196
+    array('createUserPasswordCrypted' => 'tns:createUserPasswordCrypted'), // input parameters
1197
+    array('return' => 'xsd:string'), // output parameters
1198
+    'urn:WSRegistration', // namespace
1199
+    'urn:WSRegistration#WSCreateUserPasswordCrypted', // soapaction
1200
+    'rpc', // style
1201
+    'encoded', // use
1202 1202
     'This service adds users'                                               // documentation
1203 1203
 );
1204 1204
 
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
     global $_user, $_configuration, $debug;
1209 1209
     $debug = 1;
1210 1210
     if ($debug) error_log('WSCreateUserPasswordCrypted');
1211
-    if ($debug) error_log(print_r($params,1));
1211
+    if ($debug) error_log(print_r($params, 1));
1212 1212
 
1213 1213
     if (!WSHelperVerifyKey($params)) {
1214 1214
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
     $extra_list = isset($params['extra']) ? $params['extra'] : '';
1242 1242
 
1243 1243
     if (!empty($_configuration['password_encryption'])) {
1244
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
1244
+        if ($_configuration['password_encryption'] === $encrypt_method) {
1245 1245
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1246 1246
                 $msg = "Encryption $encrypt_method is invalid";
1247 1247
                 if ($debug) error_log($msg);
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
             if (!is_null($auth_source)) {
1304 1304
                 $sql .= " auth_source='".Database::escape_string($auth_source)."',";
1305 1305
             }
1306
-            $sql .=    "
1306
+            $sql .= "
1307 1307
                     password='".Database::escape_string($password)."',
1308 1308
                     email='".Database::escape_string($email)."',
1309 1309
                     status='".Database::escape_string($status)."',
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
                     expiration_date='".Database::escape_string($expiration_date)."',
1313 1313
                     active='1',
1314 1314
                     hr_dept_id=".intval($hr_dept_id);
1315
-            $sql .=    " WHERE user_id='".$r_check_user[0]."'";
1315
+            $sql .= " WHERE user_id='".$r_check_user[0]."'";
1316 1316
             if ($debug) error_log($sql);
1317 1317
             Database::query($sql);
1318 1318
 
@@ -1492,13 +1492,13 @@  discard block
 block discarded – undo
1492 1492
 );
1493 1493
 
1494 1494
 // Register the method to expose
1495
-$server->register('WSEditUserCredentials',                      // method name
1496
-    array('editUserCredentials' => 'tns:editUserCredentials'),  // input parameters
1497
-    array('return' => 'xsd:string'),                            // output parameters
1498
-    'urn:WSRegistration',                                       // namespace
1499
-    'urn:WSRegistration#WSEditUserCredentials',                 // soapaction
1500
-    'rpc',                                                      // style
1501
-    'encoded',                                                  // use
1495
+$server->register('WSEditUserCredentials', // method name
1496
+    array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters
1497
+    array('return' => 'xsd:string'), // output parameters
1498
+    'urn:WSRegistration', // namespace
1499
+    'urn:WSRegistration#WSEditUserCredentials', // soapaction
1500
+    'rpc', // style
1501
+    'encoded', // use
1502 1502
     'This service edits the username and password of a user'    // documentation
1503 1503
 );
1504 1504
 
@@ -1597,13 +1597,13 @@  discard block
 block discarded – undo
1597 1597
 );
1598 1598
 
1599 1599
 // Register the method to expose
1600
-$server->register('WSEditUsers',                // method name
1601
-    array('editUsers' => 'tns:editUsers'),      // input parameters
1600
+$server->register('WSEditUsers', // method name
1601
+    array('editUsers' => 'tns:editUsers'), // input parameters
1602 1602
     array('return' => 'tns:results_editUsers'), // output parameters
1603
-    'urn:WSRegistration',                       // namespace
1604
-    'urn:WSRegistration#WSEditUsers',           // soapaction
1605
-    'rpc',                                      // style
1606
-    'encoded',                                  // use
1603
+    'urn:WSRegistration', // namespace
1604
+    'urn:WSRegistration#WSEditUsers', // soapaction
1605
+    'rpc', // style
1606
+    'encoded', // use
1607 1607
     'This service edits a user from wiener'     // documentation
1608 1608
 );
1609 1609
 
@@ -1795,13 +1795,13 @@  discard block
 block discarded – undo
1795 1795
 );
1796 1796
 
1797 1797
 // Register the method to expose
1798
-$server->register('WSEditUser',              // method name
1799
-    array('editUser' => 'tns:editUser'),     // input parameters
1800
-    array('return' => 'xsd:string'),         // output parameters
1801
-    'urn:WSRegistration',                    // namespace
1802
-    'urn:WSRegistration#WSEditUser',         // soapaction
1803
-    'rpc',                                   // style
1804
-    'encoded',                               // use
1798
+$server->register('WSEditUser', // method name
1799
+    array('editUser' => 'tns:editUser'), // input parameters
1800
+    array('return' => 'xsd:string'), // output parameters
1801
+    'urn:WSRegistration', // namespace
1802
+    'urn:WSRegistration#WSEditUser', // soapaction
1803
+    'rpc', // style
1804
+    'encoded', // use
1805 1805
     'This service edits a user from wiener'  // documentation
1806 1806
 );
1807 1807
 
@@ -1972,13 +1972,13 @@  discard block
 block discarded – undo
1972 1972
 );
1973 1973
 
1974 1974
 // Register the method to expose
1975
-$server->register('WSEditUserWithPicture',              // method name
1976
-    array('editUserWithPicture' => 'tns:editUserWithPicture'),     // input parameters
1977
-    array('return' => 'xsd:string'),                    // output parameters
1978
-    'urn:WSRegistration',                               // namespace
1979
-    'urn:WSRegistration#WSEditUserWithPicture',         // soapaction
1980
-    'rpc',                                              // style
1981
-    'encoded',                                          // use
1975
+$server->register('WSEditUserWithPicture', // method name
1976
+    array('editUserWithPicture' => 'tns:editUserWithPicture'), // input parameters
1977
+    array('return' => 'xsd:string'), // output parameters
1978
+    'urn:WSRegistration', // namespace
1979
+    'urn:WSRegistration#WSEditUserWithPicture', // soapaction
1980
+    'rpc', // style
1981
+    'encoded', // use
1982 1982
     'This service edits a user from wiener'             // documentation
1983 1983
 );
1984 1984
 
@@ -2036,8 +2036,8 @@  discard block
 block discarded – undo
2036 2036
     $tempDir = api_get_path(SYS_ARCHIVE_PATH);
2037 2037
     // Make sure the file download was OK by checking the HTTP headers for OK
2038 2038
     if (strpos(get_headers($picture_url)[0], "OK")) {
2039
-        file_put_contents($tempDir . $filename, file_get_contents($picture_url));
2040
-        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir . $filename);
2039
+        file_put_contents($tempDir.$filename, file_get_contents($picture_url));
2040
+        $pictureUri = UserManager::update_user_picture($user_id, $filename, $tempDir.$filename);
2041 2041
     }
2042 2042
 
2043 2043
     if ($user_id == 0) {
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
         ->setExpirationDate($expiration_date)
2109 2109
         ->setHrDeptId($hr_dept_id)
2110 2110
         ->setActive(true)
2111
-        ->setPictureUri($pictureUri);;
2111
+        ->setPictureUri($pictureUri); ;
2112 2112
 
2113 2113
     if (!is_null($creator_id)) {
2114 2114
         $user->setCreatorId($creator_id);
@@ -2205,13 +2205,13 @@  discard block
 block discarded – undo
2205 2205
 );
2206 2206
 
2207 2207
 // Register the method to expose
2208
-$server->register('WSEditUsersPasswordCrypted',                           // method name
2209
-    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'),  // input parameters
2210
-    array('return' => 'tns:results_editUsersPasswordCrypted'),            // output parameters
2211
-    'urn:WSRegistration',                                                 // namespace
2212
-    'urn:WSRegistration#WSEditUsersPasswordCrypted',                      // soapaction
2213
-    'rpc',                                                                // style
2214
-    'encoded',                                                            // use
2208
+$server->register('WSEditUsersPasswordCrypted', // method name
2209
+    array('editUsersPasswordCrypted' => 'tns:editUsersPasswordCrypted'), // input parameters
2210
+    array('return' => 'tns:results_editUsersPasswordCrypted'), // output parameters
2211
+    'urn:WSRegistration', // namespace
2212
+    'urn:WSRegistration#WSEditUsersPasswordCrypted', // soapaction
2213
+    'rpc', // style
2214
+    'encoded', // use
2215 2215
     'This service edits a user'                                           // documentation
2216 2216
 );
2217 2217
 
@@ -2219,7 +2219,7 @@  discard block
 block discarded – undo
2219 2219
 function WSEditUsersPasswordCrypted($params) {
2220 2220
     global $_configuration;
2221 2221
 
2222
-    if(!WSHelperVerifyKey($params)) {
2222
+    if (!WSHelperVerifyKey($params)) {
2223 2223
         return returnError(WS_ERROR_SECRET_KEY);
2224 2224
     }
2225 2225
 
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
 
2257 2257
             $password = $user_param['password'];
2258 2258
             $encrypt_method = $user_param['encrypt_method'];
2259
-            if ($_configuration['password_encryption'] === $encrypt_method ) {
2259
+            if ($_configuration['password_encryption'] === $encrypt_method) {
2260 2260
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2261 2261
                     $msg = "Encryption $encrypt_method is invalid";
2262 2262
                     $results[] = $msg;
@@ -2271,11 +2271,11 @@  discard block
 block discarded – undo
2271 2271
                 $results[] = $msg;
2272 2272
                 continue;
2273 2273
             }
2274
-        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])){
2274
+        } elseif (!empty($user_param['password']) && empty($user_param['encrypt_method'])) {
2275 2275
             $msg = "If password is not empty the encrypt_method param is required ";
2276 2276
             $results[] = $msg;
2277 2277
             continue;
2278
-        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])){
2278
+        } elseif (empty($user_param['password']) && !empty($user_param['encrypt_method'])) {
2279 2279
             $msg = "If encrypt_method is not empty the password param is required ";
2280 2280
             $results[] = $msg;
2281 2281
             continue;
@@ -2411,13 +2411,13 @@  discard block
 block discarded – undo
2411 2411
 );
2412 2412
 
2413 2413
 // Register the method to expose
2414
-$server->register('WSEditUserPasswordCrypted',                         // method name
2414
+$server->register('WSEditUserPasswordCrypted', // method name
2415 2415
     array('editUserPasswordCrypted' => 'tns:editUserPasswordCrypted'), // input parameters
2416
-    array('return' => 'xsd:string'),                                   // output parameters
2417
-    'urn:WSRegistration',                                              // namespace
2418
-    'urn:WSRegistration#WSEditUserPasswordCrypted',                    // soapaction
2419
-    'rpc',                                                             // style
2420
-    'encoded',                                                         // use
2416
+    array('return' => 'xsd:string'), // output parameters
2417
+    'urn:WSRegistration', // namespace
2418
+    'urn:WSRegistration#WSEditUserPasswordCrypted', // soapaction
2419
+    'rpc', // style
2420
+    'encoded', // use
2421 2421
     'This service edits a user'                                        // documentation
2422 2422
 );
2423 2423
 
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
     if (!empty($params['password']) && !empty($params['encrypt_method'])) {
2462 2462
         $password = $params['password'];
2463 2463
         $encrypt_method = $params['encrypt_method'];
2464
-        if ($_configuration['password_encryption'] === $encrypt_method ) {
2464
+        if ($_configuration['password_encryption'] === $encrypt_method) {
2465 2465
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
2466 2466
                 $msg = "Encryption $encrypt_method is invalid";
2467 2467
                 return $msg;
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
     '',
2607 2607
     'SOAP-ENC:Array',
2608 2608
     array(),
2609
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id'
2609
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_id[]')), 'tns:user_id'
2610 2610
 );
2611 2611
 
2612 2612
 $server->wsdl->addComplexType(
@@ -2622,35 +2622,35 @@  discard block
 block discarded – undo
2622 2622
 );
2623 2623
 
2624 2624
 function WSHelperActionOnUsers($params, $type) {
2625
-    if(!WSHelperVerifyKey($params)) {
2625
+    if (!WSHelperVerifyKey($params)) {
2626 2626
         return returnError(WS_ERROR_SECRET_KEY);
2627 2627
     }
2628 2628
 
2629 2629
     $original_user_ids = $params['ids'];
2630
-    foreach($original_user_ids as $original_user_id) {
2630
+    foreach ($original_user_ids as $original_user_id) {
2631 2631
         $user_id = UserManager::get_user_id_from_original_id(
2632 2632
             $original_user_id['original_user_id_value'],
2633 2633
             $original_user_id['original_user_id_name']
2634 2634
         );
2635
-        if($user_id > 0) {
2636
-            if($type == "delete") {
2635
+        if ($user_id > 0) {
2636
+            if ($type == "delete") {
2637 2637
                 UserManager::delete_user($user_id);
2638
-            } else if($type == "disable") {
2638
+            } else if ($type == "disable") {
2639 2639
                 UserManager::disable($user_id);
2640
-            } else if($type == "enable") {
2640
+            } else if ($type == "enable") {
2641 2641
                 UserManager::enable($user_id);
2642 2642
             }
2643 2643
         }
2644 2644
     }
2645 2645
 }
2646 2646
 
2647
-$server->register('WSDeleteUsers',                         // method name
2648
-    array('user_ids' => 'tns:user_ids'),                   // input parameters
2649
-    array(),                                               // output parameters
2650
-    'urn:WSRegistration',                                  // namespace
2651
-    'urn:WSRegistration#WSDeleteUsers',                    // soapaction
2652
-    'rpc',                                                 // style
2653
-    'encoded',                                             // use
2647
+$server->register('WSDeleteUsers', // method name
2648
+    array('user_ids' => 'tns:user_ids'), // input parameters
2649
+    array(), // output parameters
2650
+    'urn:WSRegistration', // namespace
2651
+    'urn:WSRegistration#WSDeleteUsers', // soapaction
2652
+    'rpc', // style
2653
+    'encoded', // use
2654 2654
     'Deletes users provided as parameters from the system' // documentation
2655 2655
 );
2656 2656
 
@@ -2659,13 +2659,13 @@  discard block
 block discarded – undo
2659 2659
 }
2660 2660
 
2661 2661
 /** WSDisableUsers **/
2662
-$server->register('WSDisableUsers',                         // method name
2663
-    array('user_ids' => 'tns:user_ids'),                    // input parameters
2664
-    array(),                                                // output parameters
2665
-    'urn:WSRegistration',                                   // namespace
2666
-    'urn:WSRegistration#WSDisableUsers',                    // soapaction
2667
-    'rpc',                                                  // style
2668
-    'encoded',                                              // use
2662
+$server->register('WSDisableUsers', // method name
2663
+    array('user_ids' => 'tns:user_ids'), // input parameters
2664
+    array(), // output parameters
2665
+    'urn:WSRegistration', // namespace
2666
+    'urn:WSRegistration#WSDisableUsers', // soapaction
2667
+    'rpc', // style
2668
+    'encoded', // use
2669 2669
     'Disables users provided as parameters from the system' // documentation
2670 2670
 );
2671 2671
 
@@ -2674,13 +2674,13 @@  discard block
 block discarded – undo
2674 2674
 }
2675 2675
 
2676 2676
 /** WSEnableUsers **/
2677
-$server->register('WSEnableUsers',            // method name
2678
-    array('user_ids' => 'tns:user_ids'),      // input parameters
2679
-    array(),                                  // output parameters
2680
-    'urn:WSRegistration',                     // namespace
2681
-    'urn:WSRegistration#WSEnableUsers',       // soapaction
2682
-    'rpc',                                    // style
2683
-    'encoded',                                // use
2677
+$server->register('WSEnableUsers', // method name
2678
+    array('user_ids' => 'tns:user_ids'), // input parameters
2679
+    array(), // output parameters
2680
+    'urn:WSRegistration', // namespace
2681
+    'urn:WSRegistration#WSEnableUsers', // soapaction
2682
+    'rpc', // style
2683
+    'encoded', // use
2684 2684
     'Enables users provided as parameters'    // documentation
2685 2685
 );
2686 2686
 
@@ -2730,7 +2730,7 @@  discard block
 block discarded – undo
2730 2730
     '',
2731 2731
     'SOAP-ENC:Array',
2732 2732
     array(),
2733
-    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams'
2733
+    array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseParams[]')), 'tns:createCourseParams'
2734 2734
 );
2735 2735
 
2736 2736
 // Register the data structures used by the service
@@ -2771,13 +2771,13 @@  discard block
 block discarded – undo
2771 2771
 );
2772 2772
 
2773 2773
 // Register the method to expose
2774
-$server->register('WSCreateCourse',                // method name
2775
-    array('createCourse' => 'tns:createCourse'),   // input parameters
2774
+$server->register('WSCreateCourse', // method name
2775
+    array('createCourse' => 'tns:createCourse'), // input parameters
2776 2776
     array('return' => 'tns:results_createCourse'), // output parameters
2777
-    'urn:WSRegistration',                          // namespace
2778
-    'urn:WSRegistration#WSCreateCourse',           // soapaction
2779
-    'rpc',                                         // style
2780
-    'encoded',                                     // use
2777
+    'urn:WSRegistration', // namespace
2778
+    'urn:WSRegistration#WSCreateCourse', // soapaction
2779
+    'rpc', // style
2780
+    'encoded', // use
2781 2781
     'This service adds a course'                   // documentation
2782 2782
 );
2783 2783
 
@@ -2833,7 +2833,7 @@  discard block
 block discarded – undo
2833 2833
                             category_code='".Database::escape_string($category_code)."',
2834 2834
                             tutor_name='".Database::escape_string($tutor_name)."',
2835 2835
                             visual_code='".Database::escape_string($wanted_code)."'";
2836
-                if($visibility !== null) {
2836
+                if ($visibility !== null) {
2837 2837
                     $sql .= ", visibility = '$visibility' ";
2838 2838
                 }
2839 2839
                 $sql .= " WHERE id='".$courseInfo['real_id']."'";
@@ -2883,7 +2883,7 @@  discard block
 block discarded – undo
2883 2883
         $params['title'] = $title;
2884 2884
         $params['wanted_code'] = $wanted_code;
2885 2885
         $params['category_code'] = $category_code;
2886
-        $params['course_category']    = $category_code;
2886
+        $params['course_category'] = $category_code;
2887 2887
         $params['tutor_name'] = $tutor_name;
2888 2888
         $params['course_language'] = $course_language;
2889 2889
         $params['user_id'] = api_get_user_id();
@@ -3014,13 +3014,13 @@  discard block
 block discarded – undo
3014 3014
 
3015 3015
 
3016 3016
 // Register the method to expose
3017
-$server->register('WSCreateCourseByTitle',                     // method name
3017
+$server->register('WSCreateCourseByTitle', // method name
3018 3018
     array('createCourseByTitle' => 'tns:createCourseByTitle'), // input parameters
3019
-    array('return' => 'tns:results_createCourseByTitle'),      // output parameters
3020
-    'urn:WSRegistration',                                      // namespace
3021
-    'urn:WSRegistration#WSCreateCourseByTitle',                // soapaction
3022
-    'rpc',                                                     // style
3023
-    'encoded',                                                 // use
3019
+    array('return' => 'tns:results_createCourseByTitle'), // output parameters
3020
+    'urn:WSRegistration', // namespace
3021
+    'urn:WSRegistration#WSCreateCourseByTitle', // soapaction
3022
+    'rpc', // style
3023
+    'encoded', // use
3024 3024
     'This service adds a course by title'                      // documentation
3025 3025
 );
3026 3026
 
@@ -3251,18 +3251,18 @@  discard block
 block discarded – undo
3251 3251
 );
3252 3252
 
3253 3253
 // Register the method to expose
3254
-$server->register('WSEditCourse',                // method name
3255
-    array('editCourse' => 'tns:editCourse'),     // input parameters
3254
+$server->register('WSEditCourse', // method name
3255
+    array('editCourse' => 'tns:editCourse'), // input parameters
3256 3256
     array('return' => 'tns:results_editCourse'), // output parameters
3257
-    'urn:WSRegistration',                        // namespace
3258
-    'urn:WSRegistration#WSEditCourse',           // soapaction
3259
-    'rpc',                                       // style
3260
-    'encoded',                                   // use
3257
+    'urn:WSRegistration', // namespace
3258
+    'urn:WSRegistration#WSEditCourse', // soapaction
3259
+    'rpc', // style
3260
+    'encoded', // use
3261 3261
     'This service edits a course'                // documentation
3262 3262
 );
3263 3263
 
3264 3264
 // Define the method WSEditCourse
3265
-function WSEditCourse($params){
3265
+function WSEditCourse($params) {
3266 3266
 
3267 3267
     global $_configuration;
3268 3268
     if (!WSHelperVerifyKey($params)) {
@@ -3417,13 +3417,13 @@  discard block
 block discarded – undo
3417 3417
 
3418 3418
 
3419 3419
 // Register the method to expose
3420
-$server->register('WSCourseDescription',                    // method name
3421
-    array('courseDescription' => 'tns:courseDescription'),  // input parameters
3422
-    array('return' => 'tns:fields_course_desc_list'),       // output parameters
3423
-    'urn:WSRegistration',                                   // namespace
3424
-    'urn:WSRegistration#WSCourseDescription',               // soapaction
3425
-    'rpc',                                                  // style
3426
-    'encoded',                                              // use
3420
+$server->register('WSCourseDescription', // method name
3421
+    array('courseDescription' => 'tns:courseDescription'), // input parameters
3422
+    array('return' => 'tns:fields_course_desc_list'), // output parameters
3423
+    'urn:WSRegistration', // namespace
3424
+    'urn:WSRegistration#WSCourseDescription', // soapaction
3425
+    'rpc', // style
3426
+    'encoded', // use
3427 3427
     'This service edits a course description'               // documentation
3428 3428
 );
3429 3429
 
@@ -3476,14 +3476,14 @@  discard block
 block discarded – undo
3476 3476
     }
3477 3477
 
3478 3478
     while ($row = Database::fetch_array($result)) {
3479
-        $ind = (int)$row['id'];
3479
+        $ind = (int) $row['id'];
3480 3480
         $array_course_desc_title[$ind] = $row['title'];
3481 3481
         $array_course_desc_content[$ind] = $row['content'];
3482 3482
     }
3483 3483
 
3484 3484
     $count_results = count($default_titles);
3485 3485
     $output = array();
3486
-    for($i = 1; $i <= $count_results; $i++) {
3486
+    for ($i = 1; $i <= $count_results; $i++) {
3487 3487
         $output[] = array(
3488 3488
             'course_desc_id' => $array_course_desc_id[$i],
3489 3489
             'course_desc_default_title' => $array_course_desc_default_title[$i],
@@ -3563,13 +3563,13 @@  discard block
 block discarded – undo
3563 3563
 
3564 3564
 
3565 3565
 // Register the method to expose
3566
-$server->register('WSEditCourseDescription',                       // method name
3566
+$server->register('WSEditCourseDescription', // method name
3567 3567
     array('editCourseDescription' => 'tns:editCourseDescription'), // input parameters
3568
-    array('return' => 'tns:results_editCourseDescription'),        // output parameters
3569
-    'urn:WSRegistration',                                          // namespace
3570
-    'urn:WSRegistration#WSEditCourseDescription',                  // soapaction
3571
-    'rpc',                                                         // style
3572
-    'encoded',                                                     // use
3568
+    array('return' => 'tns:results_editCourseDescription'), // output parameters
3569
+    'urn:WSRegistration', // namespace
3570
+    'urn:WSRegistration#WSEditCourseDescription', // soapaction
3571
+    'rpc', // style
3572
+    'encoded', // use
3573 3573
     'This service edits a course description'                      // documentation
3574 3574
 );
3575 3575
 
@@ -3613,7 +3613,7 @@  discard block
 block discarded – undo
3613 3613
         $course_desc_title = Database::escape_string($course_desc_title);
3614 3614
         $course_desc_content = Database::escape_string($course_desc_content);
3615 3615
 
3616
-        $course_desc_id = (int)$course_desc_id;
3616
+        $course_desc_id = (int) $course_desc_id;
3617 3617
         if ($course_desc_id > 8 && $course_desc_id < 1) {
3618 3618
             $results[] = 0; // course_desc_id invalid.
3619 3619
             continue;
@@ -3647,7 +3647,7 @@  discard block
 block discarded – undo
3647 3647
 
3648 3648
     $count_results = count($results);
3649 3649
     $output = array();
3650
-    for($i = 0; $i < $count_results; $i++) {
3650
+    for ($i = 0; $i < $count_results; $i++) {
3651 3651
         $output[] = array(
3652 3652
             'original_course_id_value' => $orig_course_id_value[$i],
3653 3653
             'result' => $results[$i],
@@ -3719,13 +3719,13 @@  discard block
 block discarded – undo
3719 3719
     'tns:result_deleteCourse'
3720 3720
 );
3721 3721
 
3722
-$server->register('WSDeleteCourse',                // method name
3723
-    array('deleteCourse' => 'tns:deleteCourse'),   // input parameters
3722
+$server->register('WSDeleteCourse', // method name
3723
+    array('deleteCourse' => 'tns:deleteCourse'), // input parameters
3724 3724
     array('return' => 'tns:results_deleteCourse'), // output parameters
3725
-    'urn:WSRegistration',                          // namespace
3726
-    'urn:WSRegistration#WSDeleteCourse',           // soapaction
3727
-    'rpc',                                         // style
3728
-    'encoded',                                     // use
3725
+    'urn:WSRegistration', // namespace
3726
+    'urn:WSRegistration#WSDeleteCourse', // soapaction
3727
+    'rpc', // style
3728
+    'encoded', // use
3729 3729
     'This service deletes a course '               // documentation
3730 3730
 );
3731 3731
 
@@ -3851,13 +3851,13 @@  discard block
 block discarded – undo
3851 3851
 );
3852 3852
 
3853 3853
 // Register the method to expose
3854
-$server->register('WSCreateSession',                // method name
3855
-    array('createSession' => 'tns:createSession'),  // input parameters
3854
+$server->register('WSCreateSession', // method name
3855
+    array('createSession' => 'tns:createSession'), // input parameters
3856 3856
     array('return' => 'tns:results_createSession'), // output parameters
3857
-    'urn:WSRegistration',                           // namespace
3858
-    'urn:WSRegistration#WSCreateSession',           // soapaction
3859
-    'rpc',                                          // style
3860
-    'encoded',                                      // use
3857
+    'urn:WSRegistration', // namespace
3858
+    'urn:WSRegistration#WSCreateSession', // soapaction
3859
+    'rpc', // style
3860
+    'encoded', // use
3861 3861
     'This service edits a session'                  // documentation
3862 3862
 );
3863 3863
 
@@ -3911,8 +3911,8 @@  discard block
 block discarded – undo
3911 3911
         }
3912 3912
 
3913 3913
         if (empty($nolimit)) {
3914
-            $date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start) . ' 00:00:00';
3915
-            $date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end) . ' 23:59:59';
3914
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start).' 00:00:00';
3915
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end).' 23:59:59';
3916 3916
         } else {
3917 3917
             $date_start = "";
3918 3918
             $date_end = "";
@@ -3930,7 +3930,7 @@  discard block
 block discarded – undo
3930 3930
             }
3931 3931
             $results[] = 0;
3932 3932
             continue;
3933
-        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,  $day_end, $year_end))) {
3933
+        } elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
3934 3934
             $results[] = 0;
3935 3935
             if ($debug) {
3936 3936
                 error_log("There's an error with the end date: $month_end - $day_end - $year_end");
@@ -4033,7 +4033,7 @@  discard block
 block discarded – undo
4033 4033
 
4034 4034
     $count_results = count($results);
4035 4035
     $output = array();
4036
-    for($i = 0; $i < $count_results; $i++) {
4036
+    for ($i = 0; $i < $count_results; $i++) {
4037 4037
         $output[] = array(
4038 4038
             'original_session_id_value' => $orig_session_id_value[$i],
4039 4039
             'result' => $results[$i],
@@ -4118,13 +4118,13 @@  discard block
 block discarded – undo
4118 4118
 
4119 4119
 
4120 4120
 // Register the method to expose
4121
-$server->register('WSEditSession',                // method name
4122
-    array('editSession' => 'tns:editSession'),    // input parameters
4121
+$server->register('WSEditSession', // method name
4122
+    array('editSession' => 'tns:editSession'), // input parameters
4123 4123
     array('return' => 'tns:results_editSession'), // output parameters
4124
-    'urn:WSRegistration',                         // namespace
4125
-    'urn:WSRegistration#WSEditSession',           // soapaction
4126
-    'rpc',                                        // style
4127
-    'encoded',                                    // use
4124
+    'urn:WSRegistration', // namespace
4125
+    'urn:WSRegistration#WSEditSession', // soapaction
4126
+    'rpc', // style
4127
+    'encoded', // use
4128 4128
     'This service edits a session'                // documentation
4129 4129
 );
4130 4130
 
@@ -4174,11 +4174,11 @@  discard block
 block discarded – undo
4174 4174
         }
4175 4175
 
4176 4176
         if (empty($nolimit)) {
4177
-            $date_start="$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start);
4178
-            $date_end="$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end);
4177
+            $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start);
4178
+            $date_end = "$year_end-".(($month_end < 10) ? "0$month_end" : $month_end)."-".(($day_end < 10) ? "0$day_end" : $day_end);
4179 4179
         } else {
4180
-            $date_start="";
4181
-            $date_end="";
4180
+            $date_start = "";
4181
+            $date_end = "";
4182 4182
         }
4183 4183
         if (empty($name)) {
4184 4184
             $results[] = 0; //SessionNameIsRequired
@@ -4322,13 +4322,13 @@  discard block
 block discarded – undo
4322 4322
     'tns:result_deleteSession'
4323 4323
 );
4324 4324
 
4325
-$server->register('WSDeleteSession',                // method name
4326
-    array('deleteSession' => 'tns:deleteSession'),  // input parameters
4325
+$server->register('WSDeleteSession', // method name
4326
+    array('deleteSession' => 'tns:deleteSession'), // input parameters
4327 4327
     array('return' => 'tns:results_deleteSession'), // output parameters
4328
-    'urn:WSRegistration',                           // namespace
4329
-    'urn:WSRegistration#WSDeleteSession',           // soapaction
4330
-    'rpc',                                          // style
4331
-    'encoded',                                      // use
4328
+    'urn:WSRegistration', // namespace
4329
+    'urn:WSRegistration#WSDeleteSession', // soapaction
4330
+    'rpc', // style
4331
+    'encoded', // use
4332 4332
     'This service deletes a session '               // documentation
4333 4333
 );
4334 4334
 
@@ -4410,10 +4410,10 @@  discard block
 block discarded – undo
4410 4410
     'struct',
4411 4411
     'all',
4412 4412
     '',
4413
-    array (
4413
+    array(
4414 4414
         'course_id' => array('name' => 'course_id', 'type' => 'tns:course_id'),
4415
-        'user_id'   => array('name' => 'user_id',   'type' => 'tns:user_id'),
4416
-        'status'    => array('name' => 'status',    'type' => 'xsd:int')
4415
+        'user_id'   => array('name' => 'user_id', 'type' => 'tns:user_id'),
4416
+        'status'    => array('name' => 'status', 'type' => 'xsd:int')
4417 4417
     )
4418 4418
 );
4419 4419
 
@@ -4423,9 +4423,9 @@  discard block
 block discarded – undo
4423 4423
     'struct',
4424 4424
     'all',
4425 4425
     '',
4426
-    array (
4427
-        'userscourses'  => array('name' => 'userscourses',  'type' => 'tns:user_course_status_array'), //removed []
4428
-        'secret_key'    => array('name' => 'secret_key',    'type' => 'xsd:string')
4426
+    array(
4427
+        'userscourses'  => array('name' => 'userscourses', 'type' => 'tns:user_course_status_array'), //removed []
4428
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4429 4429
     )
4430 4430
 );
4431 4431
 
@@ -4450,9 +4450,9 @@  discard block
 block discarded – undo
4450 4450
     'all',
4451 4451
     '',
4452 4452
     array(
4453
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4454
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4455
-        'result'                    => array('name' => 'result',                    'type' => 'xsd:int')
4453
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4454
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4455
+        'result'                    => array('name' => 'result', 'type' => 'xsd:int')
4456 4456
     )
4457 4457
 );
4458 4458
 
@@ -4468,13 +4468,13 @@  discard block
 block discarded – undo
4468 4468
 );
4469 4469
 
4470 4470
 // Register the method to expose
4471
-$server->register('WSSubscribeUserToCourse',                            // method name
4472
-    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'),  // input parameters
4471
+$server->register('WSSubscribeUserToCourse', // method name
4472
+    array('subscribeUserToCourse' => 'tns:subscribeUserToCourse_arg'), // input parameters
4473 4473
     array('return' => 'tns:subscribeUserToCourse_return_global'),
4474
-    'urn:WSRegistration',                                               // namespace
4475
-    'urn:WSRegistration#WSSubscribeUserToCourse',                       // soapaction
4476
-    'rpc',                                                              // style
4477
-    'encoded',                                                          // use
4474
+    'urn:WSRegistration', // namespace
4475
+    'urn:WSRegistration#WSSubscribeUserToCourse', // soapaction
4476
+    'rpc', // style
4477
+    'encoded', // use
4478 4478
     'This service subscribes a user to a course'                        // documentation
4479 4479
 );
4480 4480
 
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
     if (!WSHelperVerifyKey($params)) {
4485 4485
         return returnError(WS_ERROR_SECRET_KEY);
4486 4486
     }
4487
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4487
+    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params, 1));
4488 4488
 
4489 4489
     $results = array();
4490 4490
     $userscourses = $params['userscourses'];
@@ -4552,8 +4552,8 @@  discard block
 block discarded – undo
4552 4552
     'all',
4553 4553
     '',
4554 4554
     array(
4555
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
4556
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
4555
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
4556
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
4557 4557
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
4558 4558
     )
4559 4559
 );
@@ -4566,18 +4566,18 @@  discard block
 block discarded – undo
4566 4566
     'struct',
4567 4567
     'all',
4568 4568
     '',
4569
-    array('message' => array('name' => 'message',    'type' => 'xsd:string'))
4569
+    array('message' => array('name' => 'message', 'type' => 'xsd:string'))
4570 4570
 );
4571 4571
 
4572 4572
 
4573 4573
 // Register the method to expose
4574
-$server->register('WSSubscribeUserToCourseSimple',                                 // method name
4574
+$server->register('WSSubscribeUserToCourseSimple', // method name
4575 4575
     array('subscribeUserToCourseSimple' => 'tns:subscribeUserToCourseSimple_arg'), // input parameters
4576
-    array('return' => 'xsd:string'),                                               // output parameters
4577
-    'urn:WSRegistration',                                                          // namespace
4578
-    'urn:WSRegistration#WSSubscribeUserToCourseSimple',                            // soapaction
4579
-    'rpc',                                                                         // style
4580
-    'encoded',                                                                     // use
4576
+    array('return' => 'xsd:string'), // output parameters
4577
+    'urn:WSRegistration', // namespace
4578
+    'urn:WSRegistration#WSSubscribeUserToCourseSimple', // soapaction
4579
+    'rpc', // style
4580
+    'encoded', // use
4581 4581
     'This service subscribes a user to a course in a simple way'                   // documentation
4582 4582
 );
4583 4583
 
@@ -4586,7 +4586,7 @@  discard block
 block discarded – undo
4586 4586
     global $debug;
4587 4587
 
4588 4588
     if ($debug) error_log('WSSubscribeUserToCourseSimple');
4589
-    if ($debug) error_log('Params '. print_r($params, 1));
4589
+    if ($debug) error_log('Params '.print_r($params, 1));
4590 4590
     if (!WSHelperVerifyKey($params)) {
4591 4591
         return returnError(WS_ERROR_SECRET_KEY);
4592 4592
     }
@@ -4634,9 +4634,9 @@  discard block
 block discarded – undo
4634 4634
     'all',
4635 4635
     '',
4636 4636
     array(
4637
-        'original_user_id_value'      => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
4638
-        'original_user_id_name'       => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4639
-        'secret_key'                  => array('name' => 'secret_key',                'type' => 'xsd:string')
4637
+        'original_user_id_value'      => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
4638
+        'original_user_id_name'       => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4639
+        'secret_key'                  => array('name' => 'secret_key', 'type' => 'xsd:string')
4640 4640
     )
4641 4641
 );
4642 4642
 
@@ -4647,21 +4647,21 @@  discard block
 block discarded – undo
4647 4647
     'struct',
4648 4648
     'all',
4649 4649
     '',
4650
-    array (
4651
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'),
4652
-        'firstname'    => array('name' => 'firstname',  'type' => 'xsd:string'),
4653
-        'lastname'     => array('name' => 'lastname',   'type' => 'xsd:string'),
4650
+    array(
4651
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'),
4652
+        'firstname'    => array('name' => 'firstname', 'type' => 'xsd:string'),
4653
+        'lastname'     => array('name' => 'lastname', 'type' => 'xsd:string'),
4654 4654
     )
4655 4655
 );
4656 4656
 
4657 4657
 // Register the method to expose
4658
-$server->register('WSGetUser',                   // method name
4659
-    array('GetUser' => 'tns:GetUserArg'),        // input parameters
4660
-    array('return' => 'tns:User'),               // output parameters
4661
-    'urn:WSRegistration',                        // namespace
4662
-    'urn:WSRegistration#WSGetUser',              // soapaction
4663
-    'rpc',                                       // style
4664
-    'encoded',                                   // use
4658
+$server->register('WSGetUser', // method name
4659
+    array('GetUser' => 'tns:GetUserArg'), // input parameters
4660
+    array('return' => 'tns:User'), // output parameters
4661
+    'urn:WSRegistration', // namespace
4662
+    'urn:WSRegistration#WSGetUser', // soapaction
4663
+    'rpc', // style
4664
+    'encoded', // use
4665 4665
     'This service get user information by id'    // documentation
4666 4666
 );
4667 4667
 
@@ -4705,17 +4705,17 @@  discard block
 block discarded – undo
4705 4705
     '',
4706 4706
     array(
4707 4707
         'username'      => array('name' => 'username', 'type' => 'xsd:string'),
4708
-        'secret_key'    => array('name' => 'secret_key','type' => 'xsd:string')
4708
+        'secret_key'    => array('name' => 'secret_key', 'type' => 'xsd:string')
4709 4709
     )
4710 4710
 );
4711 4711
 // Register the method to expose
4712
-$server->register('WSGetUserFromUsername',                     // method name
4713
-    array('GetUserFromUsername' => 'tns:GetUserArgUsername'),  // input params
4714
-    array('return' => 'tns:User'),                             // output parameters
4715
-    'urn:WSRegistration',                                      // namespace
4716
-    'urn:WSRegistration#WSGetUserFromUsername',                // soapaction
4717
-    'rpc',                                                     // style
4718
-    'encoded',                                                 // use
4712
+$server->register('WSGetUserFromUsername', // method name
4713
+    array('GetUserFromUsername' => 'tns:GetUserArgUsername'), // input params
4714
+    array('return' => 'tns:User'), // output parameters
4715
+    'urn:WSRegistration', // namespace
4716
+    'urn:WSRegistration#WSGetUserFromUsername', // soapaction
4717
+    'rpc', // style
4718
+    'encoded', // use
4719 4719
     'This service get user information by username'            // documentation
4720 4720
 );
4721 4721
 
@@ -4756,10 +4756,10 @@  discard block
 block discarded – undo
4756 4756
     'all',
4757 4757
     '',
4758 4758
     array(
4759
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
4760
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
4761
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
4762
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
4759
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
4760
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
4761
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
4762
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
4763 4763
     )
4764 4764
 );
4765 4765
 
@@ -4812,13 +4812,13 @@  discard block
 block discarded – undo
4812 4812
 );
4813 4813
 
4814 4814
 // Register the method to expose
4815
-$server->register('WSUnsubscribeUserFromCourse',                         // method name
4815
+$server->register('WSUnsubscribeUserFromCourse', // method name
4816 4816
     array('unsuscribeUserFromCourse' => 'tns:unsuscribeUserFromCourse'), // input parameters
4817
-    array('return' => 'tns:results_unsuscribeUserFromCourse'),           // output parameters
4818
-    'urn:WSRegistration',                                                // namespace
4819
-    'urn:WSRegistration#WSUnsubscribeUserFromCourse',                    // soapaction
4820
-    'rpc',                                                               // style
4821
-    'encoded',                                                           // use
4817
+    array('return' => 'tns:results_unsuscribeUserFromCourse'), // output parameters
4818
+    'urn:WSRegistration', // namespace
4819
+    'urn:WSRegistration#WSUnsubscribeUserFromCourse', // soapaction
4820
+    'rpc', // style
4821
+    'encoded', // use
4822 4822
     'This service unsubscribes a user from a course'                     // documentation
4823 4823
 );
4824 4824
 
@@ -4830,7 +4830,7 @@  discard block
 block discarded – undo
4830 4830
     }
4831 4831
 
4832 4832
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
4833
-    $table_course     = Database :: get_main_table(TABLE_MAIN_COURSE);
4833
+    $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
4834 4834
     $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
4835 4835
 
4836 4836
     $userscourses_params = $params['userscourses'];
@@ -4840,8 +4840,8 @@  discard block
 block discarded – undo
4840 4840
     foreach ($userscourses_params as $usercourse_param) {
4841 4841
 
4842 4842
         $original_user_id_values     = $usercourse_param['original_user_id_values'];
4843
-        $original_user_id_name         = $usercourse_param['original_user_id_name'];
4844
-        $original_course_id_value     = $usercourse_param['original_course_id_value'];
4843
+        $original_user_id_name = $usercourse_param['original_user_id_name'];
4844
+        $original_course_id_value = $usercourse_param['original_course_id_value'];
4845 4845
         $original_course_id_name     = $usercourse_param['original_course_id_name'];
4846 4846
         $orig_course_id_value[] = $original_course_id_value;
4847 4847
 
@@ -4862,7 +4862,7 @@  discard block
 block discarded – undo
4862 4862
             $usersList[] = $user_id;
4863 4863
         }
4864 4864
 
4865
-        $orig_user_id_value[] = implode(',',$usersList);
4865
+        $orig_user_id_value[] = implode(',', $usersList);
4866 4866
 
4867 4867
         $courseInfo = CourseManager::getCourseInfoFromOriginalId(
4868 4868
             $original_course_id_value,
@@ -4895,7 +4895,7 @@  discard block
 block discarded – undo
4895 4895
 
4896 4896
     $count_results = count($results);
4897 4897
     $output = array();
4898
-    for($i = 0; $i < $count_results; $i++) {
4898
+    for ($i = 0; $i < $count_results; $i++) {
4899 4899
         $output[] = array(
4900 4900
             'original_user_id_values' => $orig_user_id_value[$i],
4901 4901
             'original_course_id_value' => $orig_course_id_value[$i],
@@ -4924,13 +4924,13 @@  discard block
 block discarded – undo
4924 4924
 
4925 4925
 
4926 4926
 // Register the method to expose
4927
-$server->register('WSUnSubscribeUserFromCourseSimple',                         // method name
4927
+$server->register('WSUnSubscribeUserFromCourseSimple', // method name
4928 4928
     array('unSubscribeUserFromCourseSimple' => 'tns:unSubscribeUserFromCourseSimple'), // input parameters
4929
-    array('return' => 'tns:result_createUsersPassEncrypt'),           // output parameters
4930
-    'urn:WSRegistration',                                                // namespace
4931
-    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple',                    // soapaction
4932
-    'rpc',                                                               // style
4933
-    'encoded',                                                           // use
4929
+    array('return' => 'tns:result_createUsersPassEncrypt'), // output parameters
4930
+    'urn:WSRegistration', // namespace
4931
+    'urn:WSRegistration#WSUnSubscribeUserFromCourseSimple', // soapaction
4932
+    'rpc', // style
4933
+    'encoded', // use
4934 4934
     'This service unsubscribe a user from a course'                     // documentation
4935 4935
 );
4936 4936
 /**
@@ -5000,10 +5000,10 @@  discard block
 block discarded – undo
5000 5000
     'all',
5001 5001
     '',
5002 5002
     array(
5003
-        'original_user_id_values'   => array('name' => 'original_user_id_values',   'type' => 'tns:originalUsersList'),
5004
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5005
-        'original_course_id_value'  => array('name' => 'original_course_id_value',  'type' => 'xsd:string'),
5006
-        'original_course_id_name'   => array('name' => 'original_course_id_value',  'type' => 'xsd:string')
5003
+        'original_user_id_values'   => array('name' => 'original_user_id_values', 'type' => 'tns:originalUsersList'),
5004
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5005
+        'original_course_id_value'  => array('name' => 'original_course_id_value', 'type' => 'xsd:string'),
5006
+        'original_course_id_name'   => array('name' => 'original_course_id_value', 'type' => 'xsd:string')
5007 5007
     )
5008 5008
 );
5009 5009
 
@@ -5097,13 +5097,13 @@  discard block
 block discarded – undo
5097 5097
 
5098 5098
 
5099 5099
 // Register the method to expose
5100
-$server->register('WSSuscribeUsersToSession',                          // method name
5100
+$server->register('WSSuscribeUsersToSession', // method name
5101 5101
     array('subscribeUsersToSession' => 'tns:subscribeUsersToSession'), // input parameters
5102
-    array('return' => 'tns:results_subscribeUsersToSession'),          // output parameters
5103
-    'urn:WSRegistration',                                              // namespace
5104
-    'urn:WSRegistration#WSSuscribeUsersToSession',                     // soapaction
5105
-    'rpc',                                                             // style
5106
-    'encoded',                                                         // use
5102
+    array('return' => 'tns:results_subscribeUsersToSession'), // output parameters
5103
+    'urn:WSRegistration', // namespace
5104
+    'urn:WSRegistration#WSSuscribeUsersToSession', // soapaction
5105
+    'rpc', // style
5106
+    'encoded', // use
5107 5107
     'This service subscribes a user to a session'                      // documentation
5108 5108
 );
5109 5109
 
@@ -5180,7 +5180,7 @@  discard block
 block discarded – undo
5180 5180
 
5181 5181
     $count_results = count($results);
5182 5182
     $output = array();
5183
-    for($i = 0; $i < $count_results; $i++) {
5183
+    for ($i = 0; $i < $count_results; $i++) {
5184 5184
         $output[] = array(
5185 5185
             'original_user_id_values' => $orig_user_id_value[$i],
5186 5186
             'original_session_id_value' => $orig_session_id_value[$i],
@@ -5200,25 +5200,25 @@  discard block
 block discarded – undo
5200 5200
     'all',
5201 5201
     '',
5202 5202
     array(
5203
-        'session'    => array('name' => 'session',    'type' => 'xsd:string'), // Session ID
5204
-        'user_id'    => array('name' => 'user_id',    'type' => 'xsd:string'), // Chamilo user_id
5203
+        'session'    => array('name' => 'session', 'type' => 'xsd:string'), // Session ID
5204
+        'user_id'    => array('name' => 'user_id', 'type' => 'xsd:string'), // Chamilo user_id
5205 5205
         'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string')
5206 5206
     )
5207 5207
 );
5208
-$server->register('WSSubscribeUserToSessionSimple',                                   // method name
5209
-    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'),  // input parameters
5210
-    array('return' => 'xsd:string'),                                                  // output parameters
5211
-    'urn:WSRegistration',                                                             // namespace
5212
-    'urn:WSRegistration#WSSubscribeUserToSessionSimple',                              // soapaction
5213
-    'rpc',                                                                            // style
5214
-    'encoded',                                                                        // use
5208
+$server->register('WSSubscribeUserToSessionSimple', // method name
5209
+    array('subscribeUserToSessionSimple' => 'tns:subscribeUserToSessionSimple_arg'), // input parameters
5210
+    array('return' => 'xsd:string'), // output parameters
5211
+    'urn:WSRegistration', // namespace
5212
+    'urn:WSRegistration#WSSubscribeUserToSessionSimple', // soapaction
5213
+    'rpc', // style
5214
+    'encoded', // use
5215 5215
     'This service subscribes a user to a session in a simple way'                     // documentation
5216 5216
 );
5217 5217
 function WSSubscribeUserToSessionSimple($params) {
5218 5218
     global $debug;
5219 5219
 
5220 5220
     if ($debug) {
5221
-        error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']');
5221
+        error_log('WSSubscribeUserToSessionSimple with params=['.serialize($params).']');
5222 5222
     }
5223 5223
 
5224 5224
     // Check security key
@@ -5227,8 +5227,8 @@  discard block
 block discarded – undo
5227 5227
     }
5228 5228
 
5229 5229
     // Get input parameters
5230
-    $session_id = intval($params['session']);  // Session ID
5231
-    $user_id    = intval($params['user_id']);  // Chamilo user id
5230
+    $session_id = intval($params['session']); // Session ID
5231
+    $user_id    = intval($params['user_id']); // Chamilo user id
5232 5232
 
5233 5233
     // Get user id
5234 5234
     $user_data = api_get_user_info($user_id);
@@ -5329,13 +5329,13 @@  discard block
 block discarded – undo
5329 5329
 );
5330 5330
 
5331 5331
 // Register the method to expose
5332
-$server->register('WSUnsuscribeUsersFromSession',                              // method name
5332
+$server->register('WSUnsuscribeUsersFromSession', // method name
5333 5333
     array('unsubscribeUsersFromSession' => 'tns:unsubscribeUsersFromSession'), // input parameters
5334
-    array('return' => 'tns:results_unsubscribeUsersFromSession'),              // output parameters
5335
-    'urn:WSRegistration',                                                      // namespace
5336
-    'urn:WSRegistration#WSUnsuscribeUsersFromSession',                         // soapaction
5337
-    'rpc',                                                                     // style
5338
-    'encoded',                                                                 // use
5334
+    array('return' => 'tns:results_unsubscribeUsersFromSession'), // output parameters
5335
+    'urn:WSRegistration', // namespace
5336
+    'urn:WSRegistration#WSUnsuscribeUsersFromSession', // soapaction
5337
+    'rpc', // style
5338
+    'encoded', // use
5339 5339
     'This service unsubscribes a user to a session'                            // documentation
5340 5340
 );
5341 5341
 
@@ -5349,7 +5349,7 @@  discard block
 block discarded – undo
5349 5349
     global $debug;
5350 5350
 
5351 5351
     if ($debug) {
5352
-        error_log('WSUnsuscribeUsersFromSession with params=[' . serialize($params). ']');
5352
+        error_log('WSUnsuscribeUsersFromSession with params=['.serialize($params).']');
5353 5353
     }
5354 5354
 
5355 5355
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
@@ -5441,7 +5441,7 @@  discard block
 block discarded – undo
5441 5441
     'all',
5442 5442
     '',
5443 5443
     array(
5444
-        'course_code'   => array('name' => 'course_code',   'type' => 'xsd:string'),
5444
+        'course_code'   => array('name' => 'course_code', 'type' => 'xsd:string'),
5445 5445
     )
5446 5446
 );
5447 5447
 
@@ -5477,9 +5477,9 @@  discard block
 block discarded – undo
5477 5477
     '',
5478 5478
     array(
5479 5479
         'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'tns:originalCoursesList'),
5480
-        'original_course_id_name'   => array('name' => 'original_course_id_name',   'type' => 'xsd:string'),
5480
+        'original_course_id_name'   => array('name' => 'original_course_id_name', 'type' => 'xsd:string'),
5481 5481
         'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'),
5482
-        'original_session_id_name'  => array('name' => 'original_session_id_name',  'type' => 'xsd:string')
5482
+        'original_session_id_name'  => array('name' => 'original_session_id_name', 'type' => 'xsd:string')
5483 5483
     )
5484 5484
 );
5485 5485
 
@@ -5532,13 +5532,13 @@  discard block
 block discarded – undo
5532 5532
 );
5533 5533
 
5534 5534
 // Register the method to expose
5535
-$server->register('WSSuscribeCoursesToSession',                            // method name
5535
+$server->register('WSSuscribeCoursesToSession', // method name
5536 5536
     array('subscribeCoursesToSession' => 'tns:subscribeCoursesToSession'), // input parameters
5537
-    array('return' => 'tns:results_subscribeCoursesToSession'),            // output parameters
5538
-    'urn:WSRegistration',                                                  // namespace
5539
-    'urn:WSRegistration#WSSuscribeCoursesToSession',                       // soapaction
5540
-    'rpc',                                                                 // style
5541
-    'encoded',                                                             // use
5537
+    array('return' => 'tns:results_subscribeCoursesToSession'), // output parameters
5538
+    'urn:WSRegistration', // namespace
5539
+    'urn:WSRegistration#WSSuscribeCoursesToSession', // soapaction
5540
+    'rpc', // style
5541
+    'encoded', // use
5542 5542
     'This service subscribes a course to a session'                        // documentation
5543 5543
 );
5544 5544
 
@@ -5676,13 +5676,13 @@  discard block
 block discarded – undo
5676 5676
 
5677 5677
 
5678 5678
 // Register the method to expose
5679
-$server->register('WSUnsuscribeCoursesFromSession',                                // method name
5679
+$server->register('WSUnsuscribeCoursesFromSession', // method name
5680 5680
     array('unsubscribeCoursesFromSession' => 'tns:unsubscribeCoursesFromSession'), // input parameters
5681
-    array('return' => 'tns:results_unsubscribeCoursesFromSession'),                // output parameters
5682
-    'urn:WSRegistration',                                                          // namespace
5683
-    'urn:WSRegistration#WSUnsuscribeCoursesFromSession',                           // soapaction
5684
-    'rpc',                                                                         // style
5685
-    'encoded',                                                                     // use
5681
+    array('return' => 'tns:results_unsubscribeCoursesFromSession'), // output parameters
5682
+    'urn:WSRegistration', // namespace
5683
+    'urn:WSRegistration#WSUnsuscribeCoursesFromSession', // soapaction
5684
+    'rpc', // style
5685
+    'encoded', // use
5686 5686
     'This service subscribes a course to a session'                                // documentation
5687 5687
 );
5688 5688
 
@@ -5789,7 +5789,7 @@  discard block
 block discarded – undo
5789 5789
 
5790 5790
     $count_results = count($results);
5791 5791
     $output = array();
5792
-    for($i = 0; $i < $count_results; $i++) {
5792
+    for ($i = 0; $i < $count_results; $i++) {
5793 5793
         $output[] = array(
5794 5794
             'original_course_id_values' => $orig_course_id_value[$i],
5795 5795
             'original_session_id_value' => $orig_session_id_value[$i],
@@ -5847,13 +5847,13 @@  discard block
 block discarded – undo
5847 5847
 
5848 5848
 
5849 5849
 // Register the method to expose
5850
-$server->register('WSListCourses',                                                  // method name
5850
+$server->register('WSListCourses', // method name
5851 5851
     array('listCourseInput' => 'tns:listCourseInput'), // input parameters
5852
-    array('return' => 'tns:courses'),                                               // output parameters
5853
-    'urn:WSRegistration',                                                           // namespace
5854
-    'urn:WSRegistration#WSListCourses',                                             // soapaction
5855
-    'rpc',                                                                          // style
5856
-    'encoded',                                                                      // use
5852
+    array('return' => 'tns:courses'), // output parameters
5853
+    'urn:WSRegistration', // namespace
5854
+    'urn:WSRegistration#WSListCourses', // soapaction
5855
+    'rpc', // style
5856
+    'encoded', // use
5857 5857
     'This service list courses available on the system'                             // documentation
5858 5858
 );
5859 5859
 
@@ -5933,27 +5933,27 @@  discard block
 block discarded – undo
5933 5933
     'all',
5934 5934
     '',
5935 5935
     array(
5936
-        'original_user_id_name'     => array('name' => 'original_user_id_name',     'type' => 'xsd:string'),
5937
-        'original_user_id_value'    => array('name' => 'original_user_id_value',    'type' => 'xsd:string'),
5938
-        'chamilo_username'          => array('name' => 'chamilo_username',          'type' => 'xsd:string'),
5939
-        'secret_key'                => array('name' => 'secret_key',                'type' => 'xsd:string')
5936
+        'original_user_id_name'     => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
5937
+        'original_user_id_value'    => array('name' => 'original_user_id_value', 'type' => 'xsd:string'),
5938
+        'chamilo_username'          => array('name' => 'chamilo_username', 'type' => 'xsd:string'),
5939
+        'secret_key'                => array('name' => 'secret_key', 'type' => 'xsd:string')
5940 5940
     )
5941 5941
 );
5942 5942
 
5943 5943
 // Register the method to expose
5944
-$server->register('WSUpdateUserApiKey',      // method name
5944
+$server->register('WSUpdateUserApiKey', // method name
5945 5945
     array('userApiKey' => 'tns:userApiKey'), // input parameters
5946
-    array('return' => 'xsd:string'),         // output parameters
5947
-    'urn:WSRegistration',                    // namespace
5948
-    'urn:WSRegistration#WSListCourses',      // soapaction
5949
-    'rpc',                                   // style
5950
-    'encoded',                               // use
5946
+    array('return' => 'xsd:string'), // output parameters
5947
+    'urn:WSRegistration', // namespace
5948
+    'urn:WSRegistration#WSListCourses', // soapaction
5949
+    'rpc', // style
5950
+    'encoded', // use
5951 5951
     'This service return user api key'       // documentation
5952 5952
 );
5953 5953
 
5954 5954
 
5955 5955
 function WSUpdateUserApiKey($params) {
5956
-    if(!WSHelperVerifyKey($params)) {
5956
+    if (!WSHelperVerifyKey($params)) {
5957 5957
         return returnError(WS_ERROR_SECRET_KEY);
5958 5958
     }
5959 5959
 
@@ -5995,11 +5995,11 @@  discard block
 block discarded – undo
5995 5995
     'all',
5996 5996
     '',
5997 5997
     array(
5998
-        'from'  => array('name' => 'from',  'type' => 'xsd:int'),
5999
-        'to'    => array('name' => 'to',    'type' => 'xsd:int'),
6000
-        'date_start'  => array('name' => 'date_start',  'type' => 'xsd:string'),
6001
-        'date_end'    => array('name' => 'date_end',    'type' => 'xsd:string'),
6002
-        'secret_key'  => array('name' => 'secret_key',  'type' => 'xsd:string')
5998
+        'from'  => array('name' => 'from', 'type' => 'xsd:int'),
5999
+        'to'    => array('name' => 'to', 'type' => 'xsd:int'),
6000
+        'date_start'  => array('name' => 'date_start', 'type' => 'xsd:string'),
6001
+        'date_end'    => array('name' => 'date_end', 'type' => 'xsd:string'),
6002
+        'secret_key'  => array('name' => 'secret_key', 'type' => 'xsd:string')
6003 6003
     )
6004 6004
 );
6005 6005
 
@@ -6010,11 +6010,11 @@  discard block
 block discarded – undo
6010 6010
     'all',
6011 6011
     '',
6012 6012
     array(
6013
-        'id' => array ('name' => 'id'  , 'type' => 'xsd:int'),
6014
-        'title' => array ('name' => 'title', 'type' => 'xsd:string'),
6015
-        'url' => array ('name' => 'url', 'type' => 'xsd:string'),
6016
-        'date_start' => array ('name' => 'date_start', 'type' => 'xsd:string'),
6017
-        'date_end' => array ('name' => 'date_end', 'type' => 'xsd:string'),
6013
+        'id' => array('name' => 'id', 'type' => 'xsd:int'),
6014
+        'title' => array('name' => 'title', 'type' => 'xsd:string'),
6015
+        'url' => array('name' => 'url', 'type' => 'xsd:string'),
6016
+        'date_start' => array('name' => 'date_start', 'type' => 'xsd:string'),
6017
+        'date_end' => array('name' => 'date_end', 'type' => 'xsd:string'),
6018 6018
     )
6019 6019
 );
6020 6020
 
@@ -6033,13 +6033,13 @@  discard block
 block discarded – undo
6033 6033
 );
6034 6034
 
6035 6035
 // Register the method to expose
6036
-$server->register('WSListSessions',           // method name
6037
-    array('input'  => 'tns:session_arg'),     // input parameters
6038
-    array('return' => 'tns:sessions'),        // output parameters
6039
-    'urn:WSRegistration',                     // namespace
6040
-    'urn:WSRegistration#WSListSessions',      // soapaction
6041
-    'rpc',                                    // style
6042
-    'encoded',                                // use
6036
+$server->register('WSListSessions', // method name
6037
+    array('input'  => 'tns:session_arg'), // input parameters
6038
+    array('return' => 'tns:sessions'), // output parameters
6039
+    'urn:WSRegistration', // namespace
6040
+    'urn:WSRegistration#WSListSessions', // soapaction
6041
+    'rpc', // style
6042
+    'encoded', // use
6043 6043
     'This service returns a list of sessions' // documentation
6044 6044
 );
6045 6045
 
@@ -6097,20 +6097,20 @@  discard block
 block discarded – undo
6097 6097
     'all',
6098 6098
     '',
6099 6099
     array(
6100
-        'course'       => array('name' => 'course',     'type' => 'xsd:string'), //Course string code
6101
-        'user_id'      => array('name' => 'user_id',    'type' => 'xsd:string'), //Chamilo user_id
6100
+        'course'       => array('name' => 'course', 'type' => 'xsd:string'), //Course string code
6101
+        'user_id'      => array('name' => 'user_id', 'type' => 'xsd:string'), //Chamilo user_id
6102 6102
         'secret_key'   => array('name' => 'secret_key', 'type' => 'xsd:string')
6103 6103
     )
6104 6104
 );
6105 6105
 
6106 6106
 // Register the method to expose
6107
-$server->register('WSUserSubscribedInCourse',                            // method name
6108
-    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'),    // input parameters
6109
-    array('return' => 'xsd:string'),                                        // output parameters
6110
-    'urn:WSRegistration',                                                    // namespace
6111
-    'urn:WSRegistration#WSUserSubscribedInCourse',                       // soapaction
6112
-    'rpc',                                                                    // style
6113
-    'encoded',                                                                // use
6107
+$server->register('WSUserSubscribedInCourse', // method name
6108
+    array('UserSubscribedInCourse' => 'tns:UserSubscribedInCourse'), // input parameters
6109
+    array('return' => 'xsd:string'), // output parameters
6110
+    'urn:WSRegistration', // namespace
6111
+    'urn:WSRegistration#WSUserSubscribedInCourse', // soapaction
6112
+    'rpc', // style
6113
+    'encoded', // use
6114 6114
     'This service checks if user assigned to course'    // documentation
6115 6115
 );
6116 6116
 
@@ -6124,7 +6124,7 @@  discard block
 block discarded – undo
6124 6124
     global $debug;
6125 6125
 
6126 6126
     if ($debug) error_log('WSUserSubscribedInCourse');
6127
-    if ($debug) error_log('Params '. print_r($params, 1));
6127
+    if ($debug) error_log('Params '.print_r($params, 1));
6128 6128
     if (!WSHelperVerifyKey($params)) {
6129 6129
 
6130 6130
         return returnError(WS_ERROR_SECRET_KEY);
@@ -6132,7 +6132,7 @@  discard block
 block discarded – undo
6132 6132
     $courseCode  = $params['course']; //Course code
6133 6133
     $userId      = $params['user_id']; //chamilo user id
6134 6134
 
6135
-    return (CourseManager::is_user_subscribed_in_course($userId,$courseCode));
6135
+    return (CourseManager::is_user_subscribed_in_course($userId, $courseCode));
6136 6136
 }
6137 6137
 
6138 6138
 
@@ -6160,8 +6160,8 @@  discard block
 block discarded – undo
6160 6160
     'all',
6161 6161
     '',
6162 6162
     array(
6163
-        'variable' => array('name'=>'variable','type'=>'xsd:string'),
6164
-        'value' => array('name'=>'value','type'=>'xsd:string')
6163
+        'variable' => array('name'=>'variable', 'type'=>'xsd:string'),
6164
+        'value' => array('name'=>'value', 'type'=>'xsd:string')
6165 6165
     )
6166 6166
 );
6167 6167
 
@@ -6223,12 +6223,12 @@  discard block
 block discarded – undo
6223 6223
 //Reister WSSearchSession
6224 6224
 $server->register(
6225 6225
     'WSSearchSession',
6226
-    array('SearchSession' => 'tns:SearchSession'),      // input parameters
6227
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6228
-    'urn:WSRegistration',                               // namespace
6229
-    'urn:WSRegistration#WSSearchSession',               // soapaction
6230
-    'rpc',                                              // style
6231
-    'encoded',                                          // use
6226
+    array('SearchSession' => 'tns:SearchSession'), // input parameters
6227
+    array('return' => 'tns:searchedSessionList'), // output parameters
6228
+    'urn:WSRegistration', // namespace
6229
+    'urn:WSRegistration#WSSearchSession', // soapaction
6230
+    'rpc', // style
6231
+    'encoded', // use
6232 6232
     'This service to get a session list filtered by name, description or short description extra field'    // documentation
6233 6233
 );
6234 6234
 
@@ -6283,12 +6283,12 @@  discard block
 block discarded – undo
6283 6283
 //Reister WSFetchSession
6284 6284
 $server->register(
6285 6285
     'WSFetchSession',
6286
-    array('SearchSession' => 'tns:FetchSession'),                    // input parameters
6287
-    array('return' => 'tns:searchedSessionList'),       // output parameters
6288
-    'urn:WSRegistration',                               // namespace
6289
-    'urn:WSRegistration#WSFetchSession',                // soapaction
6290
-    'rpc',                                              // style
6291
-    'encoded',                                          // use
6286
+    array('SearchSession' => 'tns:FetchSession'), // input parameters
6287
+    array('return' => 'tns:searchedSessionList'), // output parameters
6288
+    'urn:WSRegistration', // namespace
6289
+    'urn:WSRegistration#WSFetchSession', // soapaction
6290
+    'rpc', // style
6291
+    'encoded', // use
6292 6292
     'This service get a session by its id. Optionally can get its extra fields values'    // documentation
6293 6293
 );
6294 6294
 
@@ -6365,16 +6365,16 @@  discard block
 block discarded – undo
6365 6365
 );
6366 6366
 // Register the method to expose
6367 6367
 $server->register(
6368
-    'WSCertificatesList',                           // method name
6368
+    'WSCertificatesList', // method name
6369 6369
     array(
6370
-        'startingDate' => 'xsd:string',             // input parameters
6370
+        'startingDate' => 'xsd:string', // input parameters
6371 6371
         'endingDate' => 'xsd:string'
6372 6372
     ),
6373
-    array('return' => 'tns:certificatesList'),      // output parameters
6374
-    'urn:WSRegistration',                           // namespace
6375
-    'urn:WSRegistration#WSCertificatesList',        // soapaction
6376
-    'rpc',                                          // style
6377
-    'encoded',                                      // use
6373
+    array('return' => 'tns:certificatesList'), // output parameters
6374
+    'urn:WSRegistration', // namespace
6375
+    'urn:WSRegistration#WSCertificatesList', // soapaction
6376
+    'rpc', // style
6377
+    'encoded', // use
6378 6378
     'This service returns a list of certificates'   // documentation
6379 6379
 );
6380 6380
 
@@ -6440,13 +6440,13 @@  discard block
 block discarded – undo
6440 6440
 );
6441 6441
 
6442 6442
 // Register the method to expose
6443
-$server->register('WSCreateGroup',              // method name
6444
-    array('createGroup' => 'tns:createGroup'),  // input parameters
6445
-    array('return' => 'xsd:string'),            // output parameters
6446
-    'urn:WSRegistration',                       // namespace
6447
-    'urn:WSRegistration#WSCreateGroup',         // soapaction
6448
-    'rpc',                                      // style
6449
-    'encoded',                                  // use
6443
+$server->register('WSCreateGroup', // method name
6444
+    array('createGroup' => 'tns:createGroup'), // input parameters
6445
+    array('return' => 'xsd:string'), // output parameters
6446
+    'urn:WSRegistration', // namespace
6447
+    'urn:WSRegistration#WSCreateGroup', // soapaction
6448
+    'rpc', // style
6449
+    'encoded', // use
6450 6450
     'This service adds a group'                 // documentation
6451 6451
 );
6452 6452
 
@@ -6489,13 +6489,13 @@  discard block
 block discarded – undo
6489 6489
 );
6490 6490
 
6491 6491
 // Register the method to expose
6492
-$server->register('WSUpdateGroup',              // method name
6493
-    array('updateGroup' => 'tns:updateGroup'),  // input parameters
6494
-    array('return' => 'xsd:string'),            // output parameters
6495
-    'urn:WSRegistration',                       // namespace
6496
-    'urn:WSRegistration#WSUpdateGroup',         // soapaction
6497
-    'rpc',                                      // style
6498
-    'encoded',                                  // use
6492
+$server->register('WSUpdateGroup', // method name
6493
+    array('updateGroup' => 'tns:updateGroup'), // input parameters
6494
+    array('return' => 'xsd:string'), // output parameters
6495
+    'urn:WSRegistration', // namespace
6496
+    'urn:WSRegistration#WSUpdateGroup', // soapaction
6497
+    'rpc', // style
6498
+    'encoded', // use
6499 6499
     'This service updates a group'              // documentation
6500 6500
 );
6501 6501
 
@@ -6540,13 +6540,13 @@  discard block
 block discarded – undo
6540 6540
 );
6541 6541
 
6542 6542
 // Register the method to expose
6543
-$server->register('WSDeleteGroup',              // method name
6544
-    array('deleteGroup' => 'tns:deleteGroup'),  // input parameters
6545
-    array('return' => 'xsd:string'),            // output parameters
6546
-    'urn:WSRegistration',                       // namespace
6547
-    'urn:WSRegistration#WSDeleteGroup',         // soapaction
6548
-    'rpc',                                      // style
6549
-    'encoded',                                  // use
6543
+$server->register('WSDeleteGroup', // method name
6544
+    array('deleteGroup' => 'tns:deleteGroup'), // input parameters
6545
+    array('return' => 'xsd:string'), // output parameters
6546
+    'urn:WSRegistration', // namespace
6547
+    'urn:WSRegistration#WSDeleteGroup', // soapaction
6548
+    'rpc', // style
6549
+    'encoded', // use
6550 6550
     'This service deletes a group'              // documentation
6551 6551
 );
6552 6552
 
@@ -6583,13 +6583,13 @@  discard block
 block discarded – undo
6583 6583
 );
6584 6584
 
6585 6585
 // Register the method to expose
6586
-$server->register('GroupBindToParent',                      // method name
6587
-    array('groupBindToParent' => 'tns:groupBindToParent'),  // input parameters
6588
-    array('return' => 'xsd:string'),                        // output parameters
6589
-    'urn:WSRegistration',                                   // namespace
6590
-    'urn:WSRegistration#GroupBindToParent',                 // soapaction
6591
-    'rpc',                                                  // style
6592
-    'encoded',                                              // use
6586
+$server->register('GroupBindToParent', // method name
6587
+    array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters
6588
+    array('return' => 'xsd:string'), // output parameters
6589
+    'urn:WSRegistration', // namespace
6590
+    'urn:WSRegistration#GroupBindToParent', // soapaction
6591
+    'rpc', // style
6592
+    'encoded', // use
6593 6593
     'This service binds a group to a parent'                // documentation
6594 6594
 );
6595 6595
 
@@ -6625,13 +6625,13 @@  discard block
 block discarded – undo
6625 6625
 );
6626 6626
 
6627 6627
 // Register the method to expose
6628
-$server->register('GroupUnbindFromParent',                          // method name
6629
-    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'),  // input parameters
6630
-    array('return' => 'xsd:string'),                                // output parameters
6631
-    'urn:WSRegistration',                                           // namespace
6632
-    'urn:WSRegistration#GroupUnbindFromParent',                     // soapaction
6633
-    'rpc',                                                          // style
6634
-    'encoded',                                                      // use
6628
+$server->register('GroupUnbindFromParent', // method name
6629
+    array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters
6630
+    array('return' => 'xsd:string'), // output parameters
6631
+    'urn:WSRegistration', // namespace
6632
+    'urn:WSRegistration#GroupUnbindFromParent', // soapaction
6633
+    'rpc', // style
6634
+    'encoded', // use
6635 6635
     'This service unbinds a group from its parent'                  // documentation
6636 6636
 );
6637 6637
 
@@ -6665,13 +6665,13 @@  discard block
 block discarded – undo
6665 6665
 );
6666 6666
 
6667 6667
 // Register the method to expose
6668
-$server->register('WSAddUserToGroup',                   // method name
6669
-    array('addUserToGroup' => 'tns:addUserToGroup'),    // input parameters
6670
-    array('return' => 'xsd:string'),                    // output parameters
6671
-    'urn:WSRegistration',                               // namespace
6672
-    'urn:WSRegistration#WSAddUserToGroup',              // soapaction
6673
-    'rpc',                                              // style
6674
-    'encoded',                                          // use
6668
+$server->register('WSAddUserToGroup', // method name
6669
+    array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters
6670
+    array('return' => 'xsd:string'), // output parameters
6671
+    'urn:WSRegistration', // namespace
6672
+    'urn:WSRegistration#WSAddUserToGroup', // soapaction
6673
+    'rpc', // style
6674
+    'encoded', // use
6675 6675
     'This service adds a user to a group'               // documentation
6676 6676
 );
6677 6677
 
@@ -6708,13 +6708,13 @@  discard block
 block discarded – undo
6708 6708
 );
6709 6709
 
6710 6710
 // Register the method to expose
6711
-$server->register('WSUpdateUserRoleInGroup',                        // method name
6712
-    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'),  // input parameters
6713
-    array('return' => 'xsd:string'),                                // output parameters
6714
-    'urn:WSRegistration',                                           // namespace
6715
-    'urn:WSRegistration#WSUpdateUserRoleInGroup',                   // soapaction
6716
-    'rpc',                                                          // style
6717
-    'encoded',                                                      // use
6711
+$server->register('WSUpdateUserRoleInGroup', // method name
6712
+    array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters
6713
+    array('return' => 'xsd:string'), // output parameters
6714
+    'urn:WSRegistration', // namespace
6715
+    'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction
6716
+    'rpc', // style
6717
+    'encoded', // use
6718 6718
     'This service updates a user role in group'                     // documentation
6719 6719
 );
6720 6720
 
@@ -6753,13 +6753,13 @@  discard block
 block discarded – undo
6753 6753
 );
6754 6754
 
6755 6755
 // Register the method to expose
6756
-$server->register('WSDeleteUserFromGroup',                      // method name
6757
-    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'),  // input parameters
6758
-    array('return' => 'xsd:string'),                            // output parameters
6759
-    'urn:WSRegistration',                                       // namespace
6760
-    'urn:WSRegistration#WSDeleteUserFromGroup',                 // soapaction
6761
-    'rpc',                                                      // style
6762
-    'encoded',                                                  // use
6756
+$server->register('WSDeleteUserFromGroup', // method name
6757
+    array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters
6758
+    array('return' => 'xsd:string'), // output parameters
6759
+    'urn:WSRegistration', // namespace
6760
+    'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction
6761
+    'rpc', // style
6762
+    'encoded', // use
6763 6763
     'This service deletes a user from a group'                  // documentation
6764 6764
 );
6765 6765
 
Please login to merge, or discard this patch.
main/webservices/webservice.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,8 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param int Error code
39 39
 	 * @param string Error message
40
+	 * @param integer $code
41
+	 * @param string $message
40 42
 	 */
41 43
 	public function __construct($code, $message) {
42 44
 		$this->code = $code;
@@ -47,6 +49,7 @@  discard block
 block discarded – undo
47 49
 	 * Sets the error handler
48 50
 	 *
49 51
 	 * @param WSErrorHandler Error handler
52
+	 * @param WSSoapErrorHandler $handler
50 53
 	 */
51 54
 	public static function setErrorHandler($handler) {
52 55
 		if($handler instanceof WSErrorHandler) {
@@ -81,6 +84,7 @@  discard block
 block discarded – undo
81 84
 	 * Handle method
82 85
 	 *
83 86
 	 * @param WSError Error
87
+	 * @return void
84 88
 	 */
85 89
 	public function handle($error);
86 90
 }
@@ -107,7 +111,7 @@  discard block
 block discarded – undo
107 111
 	 * Verifies the API key
108 112
 	 *
109 113
 	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
114
+	 * @return WSError|null WSError in case of failure, null in case of success
111 115
 	 */
112 116
 	protected function verifyKey($secret_key) {
113 117
 		$ip = trim($_SERVER['REMOTE_ADDR']);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param WSErrorHandler Error handler
50 50
 	 */
51 51
 	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
52
+		if ($handler instanceof WSErrorHandler) {
53 53
 			self::$_handler = $handler;
54 54
 		}
55 55
 	}
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 		// if we are behind a reverse proxy, assume it will send the
115 115
 		// HTTP_X_FORWARDED_FOR header and use this IP instead
116 116
 		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
117
+			list($ip1, $ip2) = preg_split('/,/', $_SERVER['HTTP_X_FORWARDED_FOR']);
118 118
 			$ip = trim($ip1);
119 119
 		}
120 120
 		$security_key = $ip.$this->_configuration['security_key'];
121 121
 
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
122
+		if (!api_is_valid_secret_key($secret_key, $security_key)) {
123 123
 			return new WSError(1, "API key is invalid");
124 124
 		} else {
125 125
 			return null;
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 * @return mixed System user id if the user was found, WSError otherwise
137 137
 	 */
138 138
 	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
139
+		if ($user_id_field_name == "chamilo_user_id") {
140
+			if (UserManager::is_user_id_valid(intval($user_id_value))) {
141 141
 				return intval($user_id_value);
142 142
 			} else {
143 143
 				return new WSError(100, "User not found");
144 144
 			}
145 145
 		} else {
146 146
 			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
147
+			if ($user_id == 0) {
148 148
 				return new WSError(100, "User not found");
149 149
 			} else {
150 150
 				return $user_id;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	protected function getSessionId($session_id_field_name, $session_id_value)
198 198
 	{
199 199
 		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
200
+			$session = SessionManager::fetch((int) $session_id_value);
201 201
 			if (!empty($session)) {
202 202
 				return intval($session_id_value);
203 203
 			} else {
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -11,237 +11,237 @@
 block discarded – undo
11 11
  */
12 12
 class WSError
13 13
 {
14
-	/**
15
-	 * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
-	 *
17
-	 * @var WSErrorHandler
18
-	 */
19
-	protected static $_handler;
20
-
21
-	/**
22
-	 * Error code
23
-	 *
24
-	 * @var int
25
-	 */
26
-	public $code;
27
-
28
-	/**
29
-	 * Error message
30
-	 *
31
-	 * @var string
32
-	 */
33
-	public $message;
34
-
35
-	/**
36
-	 * Constructor
37
-	 *
38
-	 * @param int Error code
39
-	 * @param string Error message
40
-	 */
41
-	public function __construct($code, $message) {
42
-		$this->code = $code;
43
-		$this->message = $message;
44
-	}
45
-
46
-	/**
47
-	 * Sets the error handler
48
-	 *
49
-	 * @param WSErrorHandler Error handler
50
-	 */
51
-	public static function setErrorHandler($handler) {
52
-		if($handler instanceof WSErrorHandler) {
53
-			self::$_handler = $handler;
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Returns the error handler
59
-	 *
60
-	 * @return WSErrorHandler Error handler
61
-	 */
62
-	public static function getErrorHandler() {
63
-		return self::$_handler;
64
-	}
65
-
66
-	/**
67
-	 * Transforms the error into an array
68
-	 *
69
-	 * @return array Associative array with code and message
70
-	 */
71
-	public function toArray() {
72
-		return array('code' => $this->code, 'message' => $this->message);
73
-	}
14
+    /**
15
+     * Error handler. This needs to be a class that implements the interface WSErrorHandler
16
+     *
17
+     * @var WSErrorHandler
18
+     */
19
+    protected static $_handler;
20
+
21
+    /**
22
+     * Error code
23
+     *
24
+     * @var int
25
+     */
26
+    public $code;
27
+
28
+    /**
29
+     * Error message
30
+     *
31
+     * @var string
32
+     */
33
+    public $message;
34
+
35
+    /**
36
+     * Constructor
37
+     *
38
+     * @param int Error code
39
+     * @param string Error message
40
+     */
41
+    public function __construct($code, $message) {
42
+        $this->code = $code;
43
+        $this->message = $message;
44
+    }
45
+
46
+    /**
47
+     * Sets the error handler
48
+     *
49
+     * @param WSErrorHandler Error handler
50
+     */
51
+    public static function setErrorHandler($handler) {
52
+        if($handler instanceof WSErrorHandler) {
53
+            self::$_handler = $handler;
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Returns the error handler
59
+     *
60
+     * @return WSErrorHandler Error handler
61
+     */
62
+    public static function getErrorHandler() {
63
+        return self::$_handler;
64
+    }
65
+
66
+    /**
67
+     * Transforms the error into an array
68
+     *
69
+     * @return array Associative array with code and message
70
+     */
71
+    public function toArray() {
72
+        return array('code' => $this->code, 'message' => $this->message);
73
+    }
74 74
 }
75 75
 
76 76
 /**
77 77
  * Interface that must be implemented by any error handler
78 78
  */
79 79
 interface WSErrorHandler {
80
-	/**
81
-	 * Handle method
82
-	 *
83
-	 * @param WSError Error
84
-	 */
85
-	public function handle($error);
80
+    /**
81
+     * Handle method
82
+     *
83
+     * @param WSError Error
84
+     */
85
+    public function handle($error);
86 86
 }
87 87
 
88 88
 /**
89 89
  * Main class of the webservice. Webservice classes extend this class
90 90
  */
91 91
 class WS {
92
-	/**
93
-	 * Chamilo configuration
94
-	 *
95
-	 * @var array
96
-	 */
97
-	protected $_configuration;
98
-
99
-	/**
100
-	 * Constructor
101
-	 */
102
-	public function __construct() {
103
-		$this->_configuration = $GLOBALS['_configuration'];
104
-	}
105
-
106
-	/**
107
-	 * Verifies the API key
108
-	 *
109
-	 * @param string Secret key
110
-	 * @return mixed WSError in case of failure, null in case of success
111
-	 */
112
-	protected function verifyKey($secret_key) {
113
-		$ip = trim($_SERVER['REMOTE_ADDR']);
114
-		// if we are behind a reverse proxy, assume it will send the
115
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
116
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
-			list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
-			$ip = trim($ip1);
119
-		}
120
-		$security_key = $ip.$this->_configuration['security_key'];
121
-
122
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
-			return new WSError(1, "API key is invalid");
124
-		} else {
125
-			return null;
126
-		}
127
-	}
128
-
129
-	/**
130
-	 * Gets the real user id based on the user id field name and value.
131
-	 * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
-	 * in the system database
133
-	 *
134
-	 * @param string User id field name
135
-	 * @param string User id value
136
-	 * @return mixed System user id if the user was found, WSError otherwise
137
-	 */
138
-	protected function getUserId($user_id_field_name, $user_id_value) {
139
-		if($user_id_field_name == "chamilo_user_id") {
140
-			if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
-				return intval($user_id_value);
142
-			} else {
143
-				return new WSError(100, "User not found");
144
-			}
145
-		} else {
146
-			$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
-			if($user_id == 0) {
148
-				return new WSError(100, "User not found");
149
-			} else {
150
-				return $user_id;
151
-			}
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Gets the real course id based on the course id field name and value.
157
-	 * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
-	 * in the system database
159
-	 *
160
-	 * @param string Course id field name
161
-	 * @param string Course id value
162
-	 * @return mixed System course id if the course was found, WSError otherwise
163
-	 */
164
-	protected function getCourseId($course_id_field_name, $course_id_value)
165
-	{
166
-		if ($course_id_field_name == "chamilo_course_id") {
167
-			if (CourseManager::get_course_code_from_course_id(
168
-					intval($course_id_value)
169
-				) != null
170
-			) {
171
-				return intval($course_id_value);
172
-			} else {
173
-				return new WSError(200, "Course not found");
174
-			}
175
-		} else {
176
-			$courseId = CourseManager::get_course_code_from_original_id(
177
-				$course_id_value,
178
-				$course_id_field_name
179
-			);
180
-			if (!empty($courseId)) {
181
-				return $courseId;
182
-			} else {
183
-				return new WSError(200, "Course not found");
184
-			}
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * Gets the real session id based on the session id field name and value.
190
-	 * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
-	 * in the system database
192
-	 *
193
-	 * @param string Session id field name
194
-	 * @param string Session id value
195
-	 * @return mixed System session id if the session was found, WSError otherwise
196
-	 */
197
-	protected function getSessionId($session_id_field_name, $session_id_value)
198
-	{
199
-		if ($session_id_field_name == "chamilo_session_id") {
200
-			$session = SessionManager::fetch((int)$session_id_value);
201
-			if (!empty($session)) {
202
-				return intval($session_id_value);
203
-			} else {
204
-				return new WSError(300, "Session not found");
205
-			}
206
-		} else {
207
-			$session_id = SessionManager::getSessionIdFromOriginalId(
208
-				$session_id_value,
209
-				$session_id_field_name
210
-			);
211
-			if ($session_id == 0) {
212
-				return new WSError(300, "Session not found");
213
-			} else {
214
-				return $session_id;
215
-			}
216
-		}
217
-	}
218
-
219
-	/**
220
-	 * Handles an error by calling the WSError error handler
221
-	 *
222
-	 * @param WSError Error
223
-	 */
224
-	protected function handleError($error) {
225
-		$handler = WSError::getErrorHandler();
226
-		$handler->handle($error);
227
-	}
228
-
229
-	/**
230
-	 * Gets a successful result
231
-	 *
232
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
233
-	 */
234
-	protected function getSuccessfulResult() {
235
-		return array('code' => 0, 'message' => 'Operation was successful');
236
-	}
237
-
238
-	/**
239
-	 * Test function. Returns the string success
240
-	 *
241
-	 * @return string Success
242
-	 */
243
-	public function test() {
244
-		return "success";
245
-	}
92
+    /**
93
+     * Chamilo configuration
94
+     *
95
+     * @var array
96
+     */
97
+    protected $_configuration;
98
+
99
+    /**
100
+     * Constructor
101
+     */
102
+    public function __construct() {
103
+        $this->_configuration = $GLOBALS['_configuration'];
104
+    }
105
+
106
+    /**
107
+     * Verifies the API key
108
+     *
109
+     * @param string Secret key
110
+     * @return mixed WSError in case of failure, null in case of success
111
+     */
112
+    protected function verifyKey($secret_key) {
113
+        $ip = trim($_SERVER['REMOTE_ADDR']);
114
+        // if we are behind a reverse proxy, assume it will send the
115
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
116
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
117
+            list($ip1,$ip2) = preg_split('/,/',$_SERVER['HTTP_X_FORWARDED_FOR']);
118
+            $ip = trim($ip1);
119
+        }
120
+        $security_key = $ip.$this->_configuration['security_key'];
121
+
122
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
123
+            return new WSError(1, "API key is invalid");
124
+        } else {
125
+            return null;
126
+        }
127
+    }
128
+
129
+    /**
130
+     * Gets the real user id based on the user id field name and value.
131
+     * Note that if the user id field name is "chamilo_user_id", it will use the user id
132
+     * in the system database
133
+     *
134
+     * @param string User id field name
135
+     * @param string User id value
136
+     * @return mixed System user id if the user was found, WSError otherwise
137
+     */
138
+    protected function getUserId($user_id_field_name, $user_id_value) {
139
+        if($user_id_field_name == "chamilo_user_id") {
140
+            if(UserManager::is_user_id_valid(intval($user_id_value))) {
141
+                return intval($user_id_value);
142
+            } else {
143
+                return new WSError(100, "User not found");
144
+            }
145
+        } else {
146
+            $user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
147
+            if($user_id == 0) {
148
+                return new WSError(100, "User not found");
149
+            } else {
150
+                return $user_id;
151
+            }
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Gets the real course id based on the course id field name and value.
157
+     * Note that if the course id field name is "chamilo_course_id", it will use the course id
158
+     * in the system database
159
+     *
160
+     * @param string Course id field name
161
+     * @param string Course id value
162
+     * @return mixed System course id if the course was found, WSError otherwise
163
+     */
164
+    protected function getCourseId($course_id_field_name, $course_id_value)
165
+    {
166
+        if ($course_id_field_name == "chamilo_course_id") {
167
+            if (CourseManager::get_course_code_from_course_id(
168
+                    intval($course_id_value)
169
+                ) != null
170
+            ) {
171
+                return intval($course_id_value);
172
+            } else {
173
+                return new WSError(200, "Course not found");
174
+            }
175
+        } else {
176
+            $courseId = CourseManager::get_course_code_from_original_id(
177
+                $course_id_value,
178
+                $course_id_field_name
179
+            );
180
+            if (!empty($courseId)) {
181
+                return $courseId;
182
+            } else {
183
+                return new WSError(200, "Course not found");
184
+            }
185
+        }
186
+    }
187
+
188
+    /**
189
+     * Gets the real session id based on the session id field name and value.
190
+     * Note that if the session id field name is "chamilo_session_id", it will use the session id
191
+     * in the system database
192
+     *
193
+     * @param string Session id field name
194
+     * @param string Session id value
195
+     * @return mixed System session id if the session was found, WSError otherwise
196
+     */
197
+    protected function getSessionId($session_id_field_name, $session_id_value)
198
+    {
199
+        if ($session_id_field_name == "chamilo_session_id") {
200
+            $session = SessionManager::fetch((int)$session_id_value);
201
+            if (!empty($session)) {
202
+                return intval($session_id_value);
203
+            } else {
204
+                return new WSError(300, "Session not found");
205
+            }
206
+        } else {
207
+            $session_id = SessionManager::getSessionIdFromOriginalId(
208
+                $session_id_value,
209
+                $session_id_field_name
210
+            );
211
+            if ($session_id == 0) {
212
+                return new WSError(300, "Session not found");
213
+            } else {
214
+                return $session_id;
215
+            }
216
+        }
217
+    }
218
+
219
+    /**
220
+     * Handles an error by calling the WSError error handler
221
+     *
222
+     * @param WSError Error
223
+     */
224
+    protected function handleError($error) {
225
+        $handler = WSError::getErrorHandler();
226
+        $handler->handle($error);
227
+    }
228
+
229
+    /**
230
+     * Gets a successful result
231
+     *
232
+     * @return array Array with a code of 0 and a message 'Operation was successful'
233
+     */
234
+    protected function getSuccessfulResult() {
235
+        return array('code' => 0, 'message' => 'Operation was successful');
236
+    }
237
+
238
+    /**
239
+     * Test function. Returns the string success
240
+     *
241
+     * @return string Success
242
+     */
243
+    public function test() {
244
+        return "success";
245
+    }
246 246
 }
247 247
 
Please login to merge, or discard this patch.