Ver Fonte

Feature #306 - Trimming totally trailing whitespace in php-source files, part 2, 140 files.

Ivan Tcholakov há 15 anos atrás
pai
commit
b1872644bf
100 ficheiros alterados com 2774 adições e 2773 exclusões
  1. 8 8
      main/install/compare_db.php
  2. 1 1
      main/install/configuration.dist.php
  3. 3 3
      main/install/install_db.inc.php
  4. 38 38
      main/install/install_functions.inc.php
  5. 22 22
      main/install/install_upgrade.lib.php
  6. 32 32
      main/install/update-db-1.6.x-1.8.0.inc.php
  7. 13 13
      main/install/update-db-1.8.0-1.8.2.inc.php
  8. 13 13
      main/install/update-db-1.8.2-1.8.3.inc.php
  9. 14 14
      main/install/update-db-1.8.3-1.8.4.inc.php
  10. 37 37
      main/install/update-db-1.8.4-1.8.5.inc.php
  11. 143 143
      main/install/update-db-1.8.5-1.8.6.inc.php
  12. 40 40
      main/install/update-db-1.8.6-1.8.6.1.inc.php
  13. 60 60
      main/install/update-db-scorm-1.6.x-1.8.0.inc.php
  14. 13 13
      main/install/update-files-1.6.x-1.8.0.inc.php
  15. 2 2
      main/install/update-files-1.8.3-1.8.4.inc.php
  16. 2 2
      main/install/update-files-1.8.4-1.8.5.inc.php
  17. 17 17
      main/install/update-files-1.8.5-1.8.6.inc.php
  18. 9 9
      main/install/update-files-1.8.6-1.8.6.1.inc.php
  19. 83 83
      main/install/update_db.inc.php
  20. 1 1
      main/install/update_files.inc.php
  21. 18 18
      main/install/upgrade.php
  22. 9 9
      main/install/upgrade_lib.php
  23. 68 68
      main/link/link.php
  24. 15 15
      main/link/link_goto.php
  25. 17 17
      main/link/linkfunctions.php
  26. 26 26
      main/messages/inbox.php
  27. 2 2
      main/messages/index.php
  28. 78 78
      main/messages/message.class.php
  29. 10 10
      main/messages/new_message.php
  30. 1 1
      main/messages/notify.php
  31. 27 27
      main/messages/outbox.php
  32. 2 2
      main/messages/plugin.php
  33. 5 5
      main/messages/send_message.php
  34. 8 8
      main/messages/send_message_to_userfriend.inc.php
  35. 3 3
      main/messages/view_message.php
  36. 4 4
      main/messaging/email_editor.php
  37. 1 1
      main/metadata/doc/dcex.php
  38. 18 18
      main/metadata/doc/mdApiTest.php
  39. 42 42
      main/metadata/doc/testMiniDom.php
  40. 13 13
      main/metadata/doc/testXht.php
  41. 12 12
      main/metadata/importdocs.php
  42. 65 65
      main/metadata/importlinks.php
  43. 26 26
      main/metadata/index.php
  44. 47 47
      main/metadata/md_document.php
  45. 64 64
      main/metadata/md_funcs.php
  46. 64 64
      main/metadata/md_link.php
  47. 16 16
      main/metadata/md_mix.php
  48. 64 64
      main/metadata/md_phpdig.php
  49. 4 4
      main/metadata/openobject.php
  50. 6 6
      main/metadata/phpdig/config.php
  51. 32 32
      main/metadata/phpdig/search.php
  52. 20 20
      main/metadata/playscormmdset.inc.php
  53. 21 21
      main/metadata/search.php
  54. 11 11
      main/metadata/statistics.php
  55. 7 7
      main/metadata/update_indexabletext.php
  56. 65 65
      main/newscorm/aicc.class.php
  57. 4 4
      main/newscorm/aiccBlock.class.php
  58. 2 2
      main/newscorm/aiccItem.class.php
  59. 4 4
      main/newscorm/aiccObjective.class.php
  60. 5 5
      main/newscorm/aiccResource.class.php
  61. 53 53
      main/newscorm/aicc_api.php
  62. 14 14
      main/newscorm/aicc_hacp.php
  63. 7 7
      main/newscorm/audiorecorder.inc.php
  64. 1 1
      main/newscorm/back_compat.inc.php
  65. 3 3
      main/newscorm/blank.php
  66. 3 3
      main/newscorm/display_audiorecorder.php
  67. 1 1
      main/newscorm/document.php
  68. 169 169
      main/newscorm/learnpath.class.php
  69. 133 133
      main/newscorm/learnpathItem.class.php
  70. 5 5
      main/newscorm/learnpathList.class.php
  71. 63 63
      main/newscorm/learnpath_functions.inc.php
  72. 11 11
      main/newscorm/lp_add.php
  73. 104 104
      main/newscorm/lp_add_item.php
  74. 39 39
      main/newscorm/lp_admin_view.php
  75. 11 11
      main/newscorm/lp_ajax_last_update_status.php
  76. 15 15
      main/newscorm/lp_ajax_save_item.php
  77. 1 1
      main/newscorm/lp_ajax_save_objectives.php
  78. 3 3
      main/newscorm/lp_ajax_switch_item.php
  79. 7 7
      main/newscorm/lp_author_image.php
  80. 28 28
      main/newscorm/lp_build.php
  81. 14 14
      main/newscorm/lp_comm.server.php
  82. 10 10
      main/newscorm/lp_content.php
  83. 138 138
      main/newscorm/lp_controller.php
  84. 15 15
      main/newscorm/lp_edit.php
  85. 57 57
      main/newscorm/lp_edit_item.php
  86. 33 33
      main/newscorm/lp_edit_item_prereq.php
  87. 2 2
      main/newscorm/lp_export.php
  88. 2 2
      main/newscorm/lp_header.php
  89. 21 21
      main/newscorm/lp_list.php
  90. 1 1
      main/newscorm/lp_list_search.php
  91. 1 1
      main/newscorm/lp_log.php
  92. 2 2
      main/newscorm/lp_message.php
  93. 33 33
      main/newscorm/lp_move_item.php
  94. 8 8
      main/newscorm/lp_nav.php
  95. 1 1
      main/newscorm/lp_save.php
  96. 132 132
      main/newscorm/lp_stats.php
  97. 9 9
      main/newscorm/lp_upload.php
  98. 96 96
      main/newscorm/lp_view.php
  99. 35 34
      main/newscorm/lp_view_item.php
  100. 36 36
      main/newscorm/openoffice_document.class.php

+ 8 - 8
main/install/compare_db.php

@@ -16,7 +16,7 @@
  * Change these parameters to compare between an old and a new database install.
  * You will need to create a course called 'COURSE' on each side to be able to compare the
  * courses databases.
- * If you have given fancy names to your databases, you will need to modify these names 
+ * If you have given fancy names to your databases, you will need to modify these names
  * in the two $bases_* variables definitions below.
  * Also, make sure about the prefix possibly used in front of the normal prefix for courses
  * databases (i.e. 'zPrefix_course' contains 'z' as additional prefix).
@@ -57,10 +57,10 @@ foreach($bases_new as $num_base=>$base)
 	$tables_db_new=array();
 	$tables_db_old=array();
 	$dump=array();
-	
+
 	//display current processed database
 	echo "<h2>Now analysing differences between databases <em>$base</em> and <em>".$bases_old[$num_base]."</em></h2>";
-	
+
 	//get a list of tables for this database
 	$query_new="SHOW TABLES FROM ".$bases_new[$num_base];
 	$result_new=mysql_query($query_new,$db_new);
@@ -110,7 +110,7 @@ foreach($bases_new as $num_base=>$base)
 			else
 			{
 				$i=0;
-				
+
 				//check for removed, new or modified fields
 				$fields_old = array();
 				$fields_new = array();
@@ -145,7 +145,7 @@ foreach($bases_new as $num_base=>$base)
 				foreach($new_fields as $dummy=>$val){
 					$new_fields[$dummy] = '++'.$val.'++';
 				}
-				$old_fields = array_diff($fields_old,$fields_new); 
+				$old_fields = array_diff($fields_old,$fields_new);
 				foreach($old_fields as $dummy=>$val){
 					$old_fields[$dummy] = '--'.$val.'--';
 				}
@@ -156,7 +156,7 @@ foreach($bases_new as $num_base=>$base)
 						'changed_fields'=>$modif_fields,
 						'new_fields'=>$new_fields,
 					);
-				}				
+				}
 			}
 			$tables_db_new[]=$table['table_name'];
 		}
@@ -176,7 +176,7 @@ foreach($bases_new as $num_base=>$base)
 			$modif_tables[]='---'.$enreg.'---';
 		}
 		//$modif_tables=array_unique($modif_tables); //deprecated with the structure complexification
-		
+
 	}else{ //this database was removed in the new version
 		$query="SHOW TABLES FROM ".$bases_old[$num_base];
 		$result=mysql_query($query,$db_old) or die(mysql_error());
@@ -194,7 +194,7 @@ foreach($bases_new as $num_base=>$base)
 		}
 
 		$modif_tables=array_unique($modif_tables);
-		echo "<h3>This database has been removed!</h3>";	
+		echo "<h3>This database has been removed!</h3>";
 	}
 	echo "<h3>Differences between each table</h3>" .
 			"- fields display under each table's name, <br>" .

+ 1 - 1
main/install/configuration.dist.php

@@ -114,7 +114,7 @@ $phpMyAdminPath              							= '';
 $_configuration['verbose_backup']						= false;
 // security word for password recovery
 $_configuration['security_key']      					= '{SECURITY_KEY}';
-// Hash function method 
+// Hash function method
 $userPasswordCrypted          							= '{ENCRYPT_PASSWORD}';
 // You may have to restart your web server if you change this
 $storeSessionInDb             							= false;

+ 3 - 3
main/install/install_db.inc.php

@@ -15,7 +15,7 @@ require_once("install_upgrade.lib.php");
 ==============================================================================
 		MAIN CODE
 ==============================================================================
-*/ 
+*/
 
 //this page can only be access through including from the install script.
 
@@ -59,11 +59,11 @@ switch ($encryptPassForm) {
 	case 'md5' :
 	$passToStore=md5($passForm);
 	break;
-	case 'sha1' : 
+	case 'sha1' :
 	$passToStore=sha1($passForm);
 	break;
 	case 'none' :
-	$passToStore=($passForm); 
+	$passToStore=($passForm);
 	break;
 }
 /*

+ 38 - 38
main/install/install_functions.inc.php

@@ -173,7 +173,7 @@ function get_config_param($param,$updatePath='')
 			error_log('Could not find config file in '.$updatePath.' in get_config_param()',0);
 			return null;
 		}
-	}	
+	}
 	if(file_exists($updatePath.'main/inc/installedVersion.inc.php'))
 	{
 		$updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php';
@@ -187,7 +187,7 @@ function get_config_param($param,$updatePath='')
 		if(file_exists($updatePath.$updateFromInstalledVersionFile))
 		{
 			$temp2 = file_to_array($updatePath.$updateFromInstalledVersionFile);
-		}		
+		}
 		$configFile=array();
 		$temp=file_to_array($updatePath.$updateFromConfigFile);
 		$temp = array_merge($temp,$temp2);
@@ -241,18 +241,18 @@ function get_config_param($param,$updatePath='')
 					$configFile[$enreg[0]]=$enreg[1];
 
 					$a=explode("'",$enreg[0]);
-					$key_tmp=$a[1];							
-					if($key_tmp== $param)					
-					{					
-						$val=$enreg[1];					
-					} 
+					$key_tmp=$a[1];
+					if($key_tmp== $param)
+					{
+						$val=$enreg[1];
+					}
 				}
 			}
 		}
 
 		return $val;
-	} 
-	else 
+	}
+	else
 	{
 		error_log('Config array could not be found in get_config_param()',0);
 		return null;
@@ -453,7 +453,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath='', $upd
 				<td class="requirements-item"><a href="http://xapian.org/" target="_blank">Xapian</a> '.get_lang('support').' ('.get_lang('Optional').')</td>
 				<td class="requirements-value">'.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).'</td>
 			</tr>
-				
+
 		  </table>';
 	echo '	</div>';
 	echo '</div>';
@@ -559,7 +559,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath='', $upd
             //</tr>'.
             //'<tr>
             //    <td class="requirements-item">'.session_save_path().'</td>
-            //    <td class="requirements-value">'.(is_writable(session_save_path()) 
+            //    <td class="requirements-value">'.(is_writable(session_save_path())
 			//		? '<strong><font color="green">'.get_lang('Writable').'</font></strong>'
 			//		: '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>').'</td>
             //</tr>'.
@@ -590,7 +590,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath='', $upd
 			<tr>
 			<td colspan="2" align="center">
 				<button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Back');?>" ><?php echo get_lang('Back');?></button>
-				<input type="hidden" name="is_executable" id="is_executable" value="-" />	
+				<input type="hidden" name="is_executable" id="is_executable" value="-" />
 				<button type="submit" class="next" name="<?php echo (isset($_POST['step2_update_6'])?'step2_update_6':'step2_update_8');?>" value="<?php echo get_lang('Next');?> &gt;" ><?php echo get_lang('Next');?></button>
 			</td>
 			</tr>
@@ -666,7 +666,7 @@ function display_requirements($installType, $badUpdatePath, $updatePath='', $upd
 				echo '<li>'.$value.'</li>';
 			}
 			echo '</ul>';
-			echo '</div>';			
+			echo '</div>';
 		}
 		// check wether a Dokeos configuration file already exists.
 		elseif(file_exists('../inc/conf/configuration.php'))
@@ -742,7 +742,7 @@ function display_license_agreement()
 * @param	string	Extra notice (to show on the right side)
 * @param	boolean	Whether to display in update mode
 * @param	string	Additional attribute for the <tr> element
-* @return	void	Direct output	
+* @return	void	Direct output
 */
 function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute='')
 {
@@ -754,15 +754,15 @@ function display_database_parameter($install_type, $parameter_name, $form_field_
 	}
 	else
 	{
-		if ($form_field_name=='dbPassForm') { 
+		if ($form_field_name=='dbPassForm') {
 			$inputtype = 'password';
 		} else {
 			$inputtype = 'text';
 		}
-		
+
 		//Slightly limit the length of the database prefix to avoid
 		//having to cut down the databases names later on
-		if ($form_field_name=='dbPrefixForm') { 
+		if ($form_field_name=='dbPrefixForm') {
 			$maxlength = '15';
 		} else {
 			$maxlength = MAX_FORM_FIELD_LENGTH;
@@ -810,7 +810,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
 			$dbStatsForm=$_configuration['statistics_database'];
 			$dbScormForm=$_configuration['scorm_database'];
 			$dbUserForm=$_configuration['user_personal_database'];
-	
+
 			$dbScormExists=true;
 		}
 
@@ -848,7 +848,7 @@ function display_database_settings_form($installType, $dbHostForm, $dbUsernameFo
 		echo "<h2>" . display_step_sequence() .get_lang("DBSetting") . "</h2>";
 		echo get_lang("DBSettingIntro");
 	}
-	
+
 	?>
 	<br /><br />
 	</td>
@@ -1000,19 +1000,19 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 	echo "<tr>\n";
 	echo '<td>'.get_lang('MainLang')."&nbsp;&nbsp;</td>\n";
 	if($installType == 'update')
-	{		
+	{
 		echo '<td><input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES, $charset).'" />'.$languageForm."</td>\n";
 	}
 	else // new installation
 	{
-		
+
 	echo '<td>';
-	
+
 	$array_lang = array('asturian','english','italian','french','slovenian','spanish');
 
 	////Only display Language have 90% +
-	echo "\t\t<select name=\"languageForm\">\n";	
-				
+	echo "\t\t<select name=\"languageForm\">\n";
+
 	foreach ($array_lang as $key => $value)	{
 		echo '<option value="'.$value.'"';
 		if($value == $languageForm) echo ' selected="selected"';
@@ -1020,11 +1020,11 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 	}
 
 	echo "\t\t</select>\n";
-	
+
 	//Display all language
 	/*echo "<select name=\"languageForm\">\n";
 		$dirname='../lang/';
-		
+
 		if ($dir=@opendir($dirname)) {
 			$lang_files = array();
 				while (($file = readdir($dir)) !== false) {
@@ -1035,8 +1035,8 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 			closedir($dir);
 		}
 		sort($lang_files);
-				
-		
+
+
 		foreach ($lang_files as $file) {
 			echo '<option value="'.$file.'"';
 				if($file == $languageForm) echo ' selected="selected"';
@@ -1052,10 +1052,10 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 	//Second parameter: Dokeos URL
 	echo "<tr>\n";
 	echo '<td>'.get_lang('DokeosURL').' (<font color="red">'.get_lang('ThisFieldIsRequired')."</font>)&nbsp;&nbsp;</td>\n";
-	
+
 	if($installType == 'update') echo '<td>'.api_htmlentities($urlForm, ENT_QUOTES, $charset)."</td>\n";
 	else echo '<td><input type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES, $charset).'" />'."</td>\n";
-	
+
 	echo "</tr>\n";
 
 	//Parameter 3: administrator's email
@@ -1088,7 +1088,7 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 
 	//Parameter 11: institute (short) name
 	display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm);
-	
+
 	/*
 	 //old method
 	  	<tr>
@@ -1103,13 +1103,13 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 	  </td>
 	  <?php endif; ?>
 	</tr>
-	
+
 	 */
-	
+
 	?>
 	<tr>
 	  <td><?php echo get_lang("EncryptMethodUserPass"); ?> :</td>
- 
+
 	  <?php if($installType == 'update'): ?>
 	  <td><input type="hidden" name="encryptPassForm" value="<?php echo $encryptPassForm; ?>" /><?php  echo $encryptPassForm; ?></td>
 	  <?php else: ?>
@@ -1120,11 +1120,11 @@ function display_configuration_settings_form($installType, $urlForm, $languageFo
 	  </td>
 	  <?php endif; ?>
 	</tr>
-	
+
 
-	
-	
-	
+
+
+
 	<tr>
 	  <td><?php echo get_lang("AllowSelfReg"); ?> :</td>
 

+ 22 - 22
main/install/install_upgrade.lib.php

@@ -8,7 +8,7 @@
 * - write a .htaccess file in the courses folder for extra security;
 * - write the Dokeos config file containing important settings like database names
 * and paswords and other options.
-* 
+*
 * Ideas for future additions:
 * - a function get_old_version_settings to retrieve the config file settings
 *   of older versions before upgrading.
@@ -76,7 +76,7 @@ function fill_current_settings_table($current_settings_table, $installation_sett
 	$allowSelfReg = $installation_settings['allow_self_registration'];
 	$allowSelfRegProf = $installation_settings['allow_teacher_self_registration'];
 	$adminPhoneForm = $installation_settings['admin_phone_form'];
-	
+
 	$file_path = dirname(__FILE__).'/'.SETTING_CURRENT_DATA_FILENAME;
 	$add_setting_current_sql = "LOAD DATA INFILE '".mysql_real_escape_string($file_path)."' INTO TABLE $current_settings_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'';";
 	@ mysql_query($add_setting_current_sql);
@@ -159,7 +159,7 @@ function write_dokeos_config_file($path)
     $seek = array('\\','//');
     $destroy = array('/','/');
 	$rootSys = str_replace($seek,$destroy,realpath($pathForm).'/');
-	
+
 	$file_path = dirname(__FILE__).'/'.DOKEOS_CONFIG_FILENAME;
 	$content = file_get_contents($file_path);
 	$config['{DATE_GENERATED}'] = date('r');
@@ -180,8 +180,8 @@ function write_dokeos_config_file($path)
 	$config['{URL_APPEND_PATH}'] = $urlAppendPath;
 	$config['{PLATFORM_LANGUAGE}'] = $languageForm;
 	$config['{SECURITY_KEY}'] = md5(uniqid(rand().time()));
-	$config['{ENCRYPT_PASSWORD}'] = $encryptPassForm; 
-	
+	$config['{ENCRYPT_PASSWORD}'] = $encryptPassForm;
+
 	$config['SESSION_LIFETIME'] = $session_lifetime;
 	$config['{NEW_VERSION}'] = $new_version;
 	$config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable);
@@ -189,7 +189,7 @@ function write_dokeos_config_file($path)
 	{
 		$content = str_replace($key, $value, $content);
 	}
-	
+
 	$fp = @ fopen($path, 'w');
 
 	if (!$fp)
@@ -224,17 +224,17 @@ function write_dokeos_config_file($path)
 function load_main_database($installation_settings)
 {
 	$dokeos_main_sql_file_string = file_get_contents(DOKEOS_MAIN_DATABASE_FILE);
-	
+
 	//replace symbolic parameters with user-specified values
 	foreach ($installation_settings as $key => $value)
 	{
 		$dokeos_main_sql_file_string = str_replace($key, mysql_real_escape_string($value), $dokeos_main_sql_file_string);
 	}
-	
+
 	//split in array of sql strings
 	$sql_instructions = array();
 	$success = split_sql_file($sql_instructions, $dokeos_main_sql_file_string);
-	
+
 	//execute the sql instructions
 	$count = count($sql_instructions);
 	for ($i = 0; $i < $count; $i++)
@@ -251,11 +251,11 @@ function load_main_database($installation_settings)
 function load_database_script($db_script)
 {
 	$dokeos_sql_file_string = file_get_contents($db_script);
-	
+
 	//split in array of sql strings
 	$sql_instructions = array();
 	$success = split_sql_file($sql_instructions, $dokeos_sql_file_string);
-	
+
 	//execute the sql instructions
 	$count = count($sql_instructions);
 	for ($i = 0; $i < $count; $i++)
@@ -267,7 +267,7 @@ function load_database_script($db_script)
 
 /**
  * Function copied and adapted from phpMyAdmin 2.6.0 PMA_splitSqlFile (also GNU GPL)
- * 
+ *
  * Removes comment lines and splits up large sql files into individual queries
  *
  * Last revision: September 23, 2001 - gandon
@@ -337,7 +337,7 @@ function split_sql_file(&$ret, $sql)
                 } // end if...elseif...else
             } // end for
         } // end if (in string)
-       
+
         // lets skip comments (/*, -- and #)
         else if (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) {
             $i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
@@ -392,7 +392,7 @@ function split_sql_file(&$ret, $sql)
 
 /**
  * Get an SQL file's contents
- * 
+ *
  * This function bases its parsing on the pre-set format of the specific SQL files in
  * the install/upgrade procedure:
  * Lines starting with "--" are comments (but need to be taken into account as they also hold sections names)
@@ -443,7 +443,7 @@ function get_sql_file_contents($file,$section,$print_errors=true)
 			if(preg_match('/^-- xx([A-Z]*)xx/',$line,$result))
 			{	//we got a section name here
 				if($result[1] == strtoupper($section))
-				{	//we have the section we are looking for, start recording 
+				{	//we have the section we are looking for, start recording
 					$record = true;
 				}
 				else
@@ -471,18 +471,18 @@ function get_sql_file_contents($file,$section,$print_errors=true)
 function directory_to_array($directory)
 {
 	$array_items = array();
-	if ($handle = opendir($directory)) 
+	if ($handle = opendir($directory))
 	{
-		while (false !== ($file = readdir($handle))) 
+		while (false !== ($file = readdir($handle)))
 		{
-			if ($file != "." && $file != "..") 
+			if ($file != "." && $file != "..")
 			{
-				if (is_dir($directory. "/" . $file)) 
+				if (is_dir($directory. "/" . $file))
 				{
-					$array_items = array_merge($array_items, directory_to_array($directory. "/" . $file));					
-					$file = $directory . "/" . $file;					
+					$array_items = array_merge($array_items, directory_to_array($directory. "/" . $file));
+					$file = $directory . "/" . $file;
 					$array_items[] = preg_replace("/\/\//si", "/", $file);
-				}	
+				}
 			}
 		}
 		closedir($handle);

+ 32 - 32
main/install/update-db-1.6.x-1.8.0.inc.php

@@ -67,9 +67,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -129,7 +129,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -160,7 +160,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -176,7 +176,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','stats');
 		if(count($s_q_list)>0)
@@ -189,7 +189,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -217,7 +217,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -246,7 +246,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
 		$prefix = $_configuration['table_prefix'];
@@ -259,7 +259,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(strlen($dbNameForm)>40){
 			error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 		}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}else{
 			mysql_select_db($dbNameForm);
 			$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -285,14 +285,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					{
 						mysql_select_db($row_course['db_name']);
 					}
-					
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
 							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);
@@ -304,7 +304,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							}
 						}
 					}
-	
+
 					//prepare reusable users list to avoid repetition of the SQL query, but only select
 					//users from the current course to avoid blowing the memory limit
 					$users_list = array();
@@ -317,12 +317,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					{
 						$users_list[$user_row['fn'].' '.$user_row['ln']] = $user_row['ui'];
 					}
-	
+
 					//update course manually
 					//update group_category.forum_state ?
 					//update group_info.tutor_id (put it in group_tutor table?) ?
 					//update group_info.forum_state, forum_id ?
-					
+
 					//update forum tables (migrate from bb_ tables to forum_ tables)
 					//migrate categories
 					$prefix_course = $prefix;
@@ -368,7 +368,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						$res = mysql_query($sql);
 						$lastforumid = mysql_insert_id();
 						$order++;
-	
+
 						//add item_property - forums were not put into item_properties before
 						$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
 								"VALUES ('forum','1','$lastforumid','ForumAdded','1','1')";
@@ -406,7 +406,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						//error_log($sql,0);
 						$res = mysql_query($sql);
 						$lastthreadid = mysql_insert_id();
-						
+
 						//add item_property - forum threads were not put into item_properties before
 						$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
 								"VALUES ('forum_thread','1','$lastthreadid','ForumThreadAdded','1','1')";
@@ -444,7 +444,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						//error_log($sql,0);
 						$res = mysql_query($sql);
 						$lastpostid = mysql_insert_id();
-						
+
 						//add item_property - forum threads were not put into item_properties before
 						$sql = "INSERT INTO ".$prefix_course."item_property(tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
 								"VALUES ('forum_post','1','$lastpostid','ForumPostAdded','1','1')";
@@ -471,7 +471,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	if(!$only_test){
 		include('update-db-scorm-1.6.x-1.8.0.inc.php');
 	}
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -492,7 +492,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -508,7 +508,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql','stats');
 		if(count($s_q_list)>0)
@@ -521,7 +521,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -549,7 +549,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -575,7 +575,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(strlen($dbNameForm)>40){
 			error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 		}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}else{
 			mysql_select_db($dbNameForm);
 			$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -625,15 +625,15 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			}
 		}
 	}
-	
+
 	// upgrade user categories sort
 	$table_user_categories = $dbUserForm.'.user_course_category';
-	
-	
+
+
 	$sql = 'SELECT * FROM '.$table_user_categories.' ORDER BY user_id, title';
-	
+
 	$rs = api_sql_query($sql, __FILE__, __LINE__);
-	
+
 	$sort = 0;
 	$old_user = 0;
 	while($cat = Database :: fetch_array($rs))
@@ -643,14 +643,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
                 $old_user = $cat['user_id'];
                 $sort = 0;
         }
-        $sort++; 
+        $sort++;
         $sql = 'UPDATE '.$table_user_categories.' SET
 	            sort = '.intval($sort).'
 	            WHERE id='.intval($cat['id']);
         api_sql_query($sql, __FILE__, __LINE__);
 	}
-	        
-	
+
+
 }
 else
 {

+ 13 - 13
main/install/update-db-1.8.0-1.8.2.inc.php

@@ -67,9 +67,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -129,7 +129,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -160,7 +160,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -176,10 +176,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql','stats');
-	
+
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list
@@ -190,7 +190,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -218,7 +218,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -247,7 +247,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
 		$prefix = $_configuration['table_prefix'];
@@ -260,7 +260,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(strlen($dbNameForm)>40){
 			error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 		}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}else{
 			mysql_select_db($dbNameForm);
 			$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -286,14 +286,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					{
 						mysql_select_db($row_course['db_name']);
 					}
-					
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
 							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);

+ 13 - 13
main/install/update-db-1.8.2-1.8.3.inc.php

@@ -67,9 +67,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -129,7 +129,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -160,7 +160,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -176,10 +176,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.8.2-1.8.3-pre.sql','stats');
-	
+
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list
@@ -190,7 +190,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -218,7 +218,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -247,7 +247,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
 		$prefix = $_configuration['table_prefix'];
@@ -260,7 +260,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(strlen($dbNameForm)>40){
 			error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 		}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}else{
 			mysql_select_db($dbNameForm);
 			$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -286,14 +286,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					{
 						mysql_select_db($row_course['db_name']);
 					}
-					
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
 							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);

+ 14 - 14
main/install/update-db-1.8.3-1.8.4.inc.php

@@ -67,9 +67,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -129,7 +129,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -160,7 +160,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -176,10 +176,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.8.3-1.8.4-pre.sql','stats');
-	
+
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list
@@ -190,7 +190,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -218,7 +218,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -247,7 +247,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
 		$prefix = $_configuration['table_prefix'];
@@ -260,7 +260,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(strlen($dbNameForm)>40){
 			error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 		}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}else{
 			mysql_select_db($dbNameForm);
 			$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
@@ -286,14 +286,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					{
 						mysql_select_db($row_course['db_name']);
 					}
-					
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
 							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);
@@ -328,7 +328,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						$vis = 'v';
 						$input = stripslashes($row_lp['name']);
 						$input = str_replace("'", "''", $input);
-						$input = str_replace('"', "''", $input);							
+						$input = str_replace('"', "''", $input);
 						$mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row_lp['id'];
 						$sql2="SELECT * FROM $tbl_tool where (name='$input' and image='scormbuilder.gif' and link LIKE '$mylink%')";
 

+ 37 - 37
main/install/update-db-1.8.4-1.8.5.inc.php

@@ -49,9 +49,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -111,7 +111,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -142,7 +142,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -158,10 +158,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','stats');
-	
+
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list
@@ -172,7 +172,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -200,7 +200,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -229,12 +229,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
-		$prefix =  get_config_param ('table_prefix');			
+		$prefix =  get_config_param ('table_prefix');
 	}
-	
+
 	//get the courses databases queries list (c_q_list)
 	$c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','course');
 
@@ -247,7 +247,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		}
 		elseif(!in_array($dbNameForm,$dblist))
 		{
-			error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+			error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}
 		else
 		{
@@ -274,24 +274,24 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					 * without a database name
 					 */
 					if (!$singleDbForm) //otherwise just use the main one
-					{									
+					{
 						mysql_select_db($row_course['db_name']);
 					}
-				
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
-							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);												
+							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);
 						}
 						else
 						{
-							$res = mysql_query($query);						
+							$res = mysql_query($query);
 							if($log)
 							{
 								error_log("In ".$row_course['db_name'].", executed: $query",0);
@@ -300,12 +300,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					}
 
 					$mytable = $row_course['db_name'].".lp_item";
-					
+
 					if($singleDbForm)
 					{
 						$mytable = "$prefix{$row_course['db_name']}_lp_item";
 					}
-										
+
 					$mysql = "SELECT * FROM $mytable WHERE min_score != 0 AND prerequisite != ''";
 					$myres = mysql_query($query);
 
@@ -322,44 +322,44 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 								{
 									$mysql3 = "UPDATE $mytable SET min_score = 0 WHERE id = '".$myrow['id']."'";
 									$myres3 = mysql_query($mysql3);
-									//echo $mysql3."<br />"; 
+									//echo $mysql3."<br />";
 								}
 							}
 						}
 					}
-										
+
 					// Work Tool Folder Update
 					// we search into DB all the folders in the work tool
 					if($singleDbForm)
-					{																								
-						$my_course_table = "$prefix{$row_course['db_name']}_student_publication";																
+					{
+						$my_course_table = "$prefix{$row_course['db_name']}_student_publication";
 					}
 					else
-					{															
+					{
 						$my_course_table = $row_course['db_name'].".student_publication";
-					}					
-					
+					}
+
 					$sys_course_path = $_configuration['root_sys'].$_configuration['course_folder'];
-													
+
 					$course_dir=$sys_course_path.$row_course['directory'].'/work';
 
-					$dir_to_array =directory_to_array($course_dir,true);					
+					$dir_to_array =directory_to_array($course_dir,true);
 					$only_dir=array();
 
 					$sql_select= "SELECT filetype FROM " . $my_course_table . " WHERE  filetype = 'folder'";
 					$result = mysql_query($sql_select);
 					$num_row=mysql_num_rows($result);
-					
-					// check if there are already folder registered  
+
+					// check if there are already folder registered
 					if ($num_row == 0)
-					{			
+					{
 						for($i=0;$i<count($dir_to_array);$i++)
 						{
-							$only_dir[]=substr($dir_to_array[$i],strlen($course_dir), strlen($dir_to_array[$i]));				
+							$only_dir[]=substr($dir_to_array[$i],strlen($course_dir), strlen($dir_to_array[$i]));
 						}
-		
+
 						for($i=0;$i<count($only_dir);$i++)
-						{							
+						{
 							$sql_insert_all= "INSERT INTO " . $my_course_table . " SET url = '" . $only_dir[$i] . "', " .
 											"title        = '',
 											description 	= '',
@@ -368,11 +368,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 											accepted	= '1',
 											filetype	= 'folder',
 											post_group_id 	= '0',
-											sent_date	= '0000-00-00 00:00:00' ";		  
+											sent_date	= '0000-00-00 00:00:00' ";
 							mysql_query($sql_insert_all);
 						}
 					}
-		
+
 				}
 			}
 		}

+ 143 - 143
main/install/update-db-1.8.5-1.8.6.inc.php

@@ -49,9 +49,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -111,7 +111,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -142,7 +142,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -158,36 +158,36 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
-		// Filling the access_url_rel_user table with access_url_id by default = 1			
+
+		// Filling the access_url_rel_user table with access_url_id by default = 1
 		$query = "SELECT user_id FROM $dbNameForm.user";
-		
-		$result_users = mysql_query($query);		
-		while ($row= mysql_fetch_array($result_users,MYSQL_NUM)) {		
-			$user_id = $row[0];	
-			$sql="INSERT INTO $dbNameForm.access_url_rel_user SET user_id=$user_id, access_url_id=1";					
+
+		$result_users = mysql_query($query);
+		while ($row= mysql_fetch_array($result_users,MYSQL_NUM)) {
+			$user_id = $row[0];
+			$sql="INSERT INTO $dbNameForm.access_url_rel_user SET user_id=$user_id, access_url_id=1";
 			$res = mysql_query($sql);
 			//Updating user image
 			$query = "SELECT picture_uri FROM $dbNameForm.user WHERE user_id=$user_id";
-			$res = mysql_query($query);		
+			$res = mysql_query($query);
 			$picture_uri = mysql_fetch_array($res,MYSQL_NUM);
 			$file =  $picture_uri[0];
 			$dir = api_get_path(SYS_CODE_PATH).'upload/users/';
 			$image_repository = file_exists($dir.$file)? $dir.$file:$dir.$user_id.'/'.$file;
-			
+
 			if (!is_dir($dir.$user_id)) {
-					$perm = octdec(!empty($perm)?$perm:'0777');							
-					@mkdir($dir.$user_id, $perm);					
-			}						
-						
-			if (file_exists($image_repository)) {												
+					$perm = octdec(!empty($perm)?$perm:'0777');
+					@mkdir($dir.$user_id, $perm);
+			}
+
+			if (file_exists($image_repository)) {
 				chmod($dir.$user_id, 0777);
 				if (is_dir($dir.$user_id)) {
 					$picture_location = $dir.$user_id.'/'.$file;
 					$big_picture_location = $dir.$user_id.'/big_'.$file;
-					
-					$temp = new image($image_repository);						
-					
+
+					$temp = new image($image_repository);
+
 					$picture_infos=getimagesize($image_repository);
 
 					$thumbwidth = 150;
@@ -196,14 +196,14 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					}
 
 					$new_height = ($picture_infos[0] > 0)?round(($thumbwidth/$picture_infos[0])*$picture_infos[1]) : 0;
-		
+
 					$temp->resize($thumbwidth,$new_height,0);
 
 					$type=$picture_infos[2];
-					
+
 					// original picture
 					$big_temp = new image($image_repository);
-		
+
 					    switch (!empty($type)) {
 						    case 2 : $temp->send_image('JPG',$picture_location);
 						    		 $big_temp->send_image('JPG',$big_picture_location);
@@ -214,23 +214,23 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						    case 1 : $temp->send_image('GIF',$picture_location);
 						    		 $big_temp->send_image('JPG',$big_picture_location);
 						    		 break;
-					    }	
-					if ($image_repository == $dir.$file) {				
-					   @unlink($image_repository);	
+					    }
+					if ($image_repository == $dir.$file) {
+					   @unlink($image_repository);
 					}
-				} 				
-			} 						
+				}
+			}
 		}
 		// Filling the access_url_rel_session table with access_url_id by default = 1
 		$query = "SELECT id FROM $dbNameForm.session";
 		$result = mysql_query($query);
-		while ($row= mysql_fetch_array($result,MYSQL_NUM)) {			
-			$sql="INSERT INTO $dbNameForm.access_url_rel_session SET session_id=".$row[0].", access_url_id=1";			
+		while ($row= mysql_fetch_array($result,MYSQL_NUM)) {
+			$sql="INSERT INTO $dbNameForm.access_url_rel_session SET session_id=".$row[0].", access_url_id=1";
 			$res = mysql_query($sql);
 		}
-		
-		//Since the parser of the migration DB  does not work for this kind of inserts (HTML) we move it here	
-		
+
+		//Since the parser of the migration DB  does not work for this kind of inserts (HTML) we move it here
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleCourseTitle\', \'TemplateTitleCourseTitleDescription\', \'coursetitle.gif\', \'
 		<head>
@@ -238,23 +238,23 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		            	<style type="text/css">
 		            	.gris_title         	{
 		            		color: silver;
-		            	}            	
+		            	}
 		            	h1
 		            	{
 		            		text-align: right;
 		            	}
 						</style>
-		  
+
 		            </head>
 		            <body>
 					<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 					<tbody>
-					<tr>			
+					<tr>
 					<td style="vertical-align: middle; width: 50%;" colspan="1" rowspan="1">
 						<h1>TITULUS 1<br>
 						<span class="gris_title">TITULUS 2</span><br>
 						</h1>
-					</td>			
+					</td>
 					<td style="width: 50%;">
 						<img style="width: 100px; height: 100px;" alt="dokeos logo" src="{COURSE_DIR}images/logo_dokeos.png"></td>
 					</tr>
@@ -266,39 +266,39 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					</body>
 		\');';
 		$res = mysql_query($sql);
-		
+
 		/*
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleCheckList\', \'TemplateTitleCheckListDescription\', \'checklist.gif\', \'
 		      <head>
-			               {CSS}	              
+			               {CSS}
 			            </head>
 			            <body>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 						<tbody>
 						<tr>
-						<td style="vertical-align: top; width: 66%;">						
+						<td style="vertical-align: top; width: 66%;">
 						<h3>Lorem ipsum dolor sit amet</h3>
 						<ul>
 							<li>consectetur adipisicing elit</li>
 							<li>sed do eiusmod tempor incididunt</li>
 							<li>ut labore et dolore magna aliqua</li>
 						</ul>
-						
-						<h3>Ut enim ad minim veniam</h3>							
+
+						<h3>Ut enim ad minim veniam</h3>
 						<ul>
 							<li>quis nostrud exercitation ullamco</li>
 							<li>laboris nisi ut aliquip ex ea commodo consequat</li>
 							<li>Excepteur sint occaecat cupidatat non proident</li>
 						</ul>
-						
-						<h3>Sed ut perspiciatis unde omnis</h3>				
+
+						<h3>Sed ut perspiciatis unde omnis</h3>
 						<ul>
 							<li>iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam</li>
 							<li>eaque ipsa quae ab illo inventore veritatis</li>
 							<li>et quasi architecto beatae vitae dicta sunt explicabo.&nbsp;</li>
 						</ul>
-						
+
 						</td>
 						<td style="background: transparent url({IMG_DIR}postit.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; width: 33%; text-align: center; vertical-align: bottom;">
 						<h3>Ut enim ad minima</h3>
@@ -314,21 +314,21 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						</p>
 						</body>
 		\');';
-		
+
 		$res = mysql_query($sql);
 		*/
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleTeacher\', \'TemplateTitleTeacherDescription\', \'yourinstructor.gif\', \'
 		<head>
 		                   {CSS}
-		                   <style type="text/css">	            
+		                   <style type="text/css">
 			            	.text
-			            	{	            	
+			            	{
 			            		font-weight: normal;
 			            	}
 							</style>
-		                </head>                    
+		                </head>
 		                <body>
 							<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 							<tbody>
@@ -352,16 +352,16 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							<p><br>
 							<br>
 							</p>
-						</body>	
+						</body>
 		\');
 		';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleLeftList\', \'TemplateTitleListLeftListDescription\', \'leftlist.gif\', \'
 		<head>
 			           {CSS}
-			       </head>		    
+			       </head>
 				    <body>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 						<tbody>
@@ -391,13 +391,13 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					<p><br>
 					<br>
 					</p>
-					</body> 
+					</body>
 		\');';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleLeftRightList\', \'TemplateTitleLeftRightListDescription\', \'leftrightlist.gif\', \'
-		
+
 		<head>
 			           {CSS}
 				    </head>
@@ -442,11 +442,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					<p><br>
 					<br>
 					</p>
-					</body> 
-		
+					</body>
+
 		\');';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleRightList\', \'TemplateTitleRightListDescription\', \'rightlist.gif\', \'
 			<head>
@@ -482,21 +482,21 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					<p><br>
 					<br>
 					</p>
-					</body>  
+					</body>
 		\');';
 		$res = mysql_query($sql);
-		
+
 		/*
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleComparison\', \'TemplateTitleComparisonDescription\', \'compare.gif\', \'
 		<head>
-		            {CSS}        
+		            {CSS}
 		            </head>
-		            
+
 		            <body>
-		            	<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">				
+		            	<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 						<tr>
-							<td style="height: 10%; width: 33%;"></td> 
+							<td style="height: 10%; width: 33%;"></td>
 							<td style="vertical-align: top; width: 33%;" colspan="1" rowspan="2">&nbsp;<img style="width: 180px; height: 271px;" alt="trainer" src="{COURSE_DIR}images/trainer/trainer_standing.png "><br>
 							</td>
 							<td style="height: 10%; width: 33%;"></td>
@@ -508,18 +508,18 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					<td style="background: transparent url({IMG_DIR}faded_grey.png ) repeat scroll center top; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; vertical-align: top; text-align: left; width: 33%;">
 					Convallis
 					ut.&nbsp;Cras dui magna.</td>
-					</tr>			
+					</tr>
 					</body>
 		\');';
 		$res = mysql_query($sql);
 		*/
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleDiagram\', \'TemplateTitleDiagramDescription\', \'diagram.gif\', \'
 			<head>
 			                   {CSS}
 						    </head>
-						    
+
 							<body>
 							<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 							<tbody>
@@ -544,11 +544,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							<p><br>
 							<br>
 							</p>
-							</body>				    
+							</body>
 		\');
 		';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleDesc\', \'TemplateTitleCheckListDescription\', \'description.gif\', \'
 		<head>
@@ -564,7 +564,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 									<br>Ut enim ad minim veniam<br><br><br>
 									<img style="width: 48px; height: 49px; float: left;" alt="03" src="{COURSE_DIR}images/small/03.png " hspace="5">Duis aute irure dolor in reprehenderit<br><br><br>
 									<img style="width: 48px; height: 49px; float: left;" alt="04" src="{COURSE_DIR}images/small/04.png " hspace="5">Neque porro quisquam est</td>
-									
+
 								<td style="vertical-align: top; width: 50%; text-align: right;" colspan="1" rowspan="1">
 									<img style="width: 300px; height: 291px;" alt="Gearbox" src="{COURSE_DIR}images/diagrams/gearbox.jpg "><br></td>
 								</tr><tr></tr>
@@ -573,18 +573,18 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 								<p><br>
 								<br>
 								</p>
-							</body>	
+							</body>
 		\');
 		';
 		$res = mysql_query($sql);
-		
+
 		/*
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleObjectives\', \'TemplateTitleObjectivesDescription\', \'courseobjectives.gif\', \'
 		<head>
-			               {CSS}                    
-					    </head>	
-					    
+			               {CSS}
+					    </head>
+
 					    <body>
 							<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 							<tbody>
@@ -615,11 +615,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						<p><br>
 						<br>
 						</p>
-						</body>		
+						</body>
 		\');';
 		$res = mysql_query($sql);
 		*/
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleCycle\', \'TemplateTitleCycleDescription\', \'cyclechart.gif\', \'
 		<head>
@@ -629,24 +629,24 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			               {
 			               	color: white; font-weight: bold;
 			               }
-			               </style>                    
+			               </style>
 					    </head>
-					    	
-					    	    
+
+
 					    <body>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="8" cellspacing="6">
 						<tbody>
 						<tr>
 							<td style="text-align: center; vertical-align: bottom; height: 10%;" colspan="3" rowspan="1">
 								<img style="width: 250px; height: 76px;" alt="arrow" src="{COURSE_DIR}images/diagrams/top_arrow.png ">
-							</td>				
-						</tr>			
+							</td>
+						</tr>
 						<tr>
 							<td style="height: 5%; width: 45%; vertical-align: top; background-color: rgb(153, 153, 153); text-align: center;">
 								<span class="title">Lorem ipsum</span>
 							</td>
-								
-							<td style="height: 5%; width: 10%;"></td>					
+
+							<td style="height: 5%; width: 10%;"></td>
 							<td style="height: 5%; vertical-align: top; background-color: rgb(153, 153, 153); text-align: center;">
 								<span class="title">Sed ut perspiciatis</span>
 							</td>
@@ -660,7 +660,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 										<li>adipisci velit, sed quia non numquam</li>
 										<li>eius modi tempora incidunt ut labore et dolore magnam</li>
 									</ul>
-						</td>			
+						</td>
 						<td style="width: 10%;"></td>
 						<td style="background-color: rgb(204, 204, 255); width: 45%; vertical-align: top;">
 							<ul>
@@ -675,23 +675,23 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							<td style="height: 10%; vertical-align: top;" colspan="3" rowspan="1">
 							<img style="width: 250px; height: 76px;" alt="arrow" src="{COURSE_DIR}images/diagrams/bottom_arrow.png ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
 						</td>
-						</tr>			
+						</tr>
 						</tbody>
 						</table>
 						<p><br>
 						<br>
 						</p>
-						</body>	
+						</body>
 		\');';
 		$res = mysql_query($sql);
-		
+
 		/*
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleLearnerWonder\', \'TemplateTitleLearnerWonderDescription\', \'learnerwonder.gif\', \'
 		<head>
-		               {CSS}                    
+		               {CSS}
 				    </head>
-				    
+
 				    <body>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 						<tbody>
@@ -728,30 +728,30 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		';
 		$res = mysql_query($sql);
 		*/
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleTimeline\', \'TemplateTitleTimelineDescription\', \'phasetimeline.gif\', \'
 		<head>
-		               {CSS} 
+		               {CSS}
 						<style>
 						.title
-						{				
-							font-weight: bold; text-align: center; 	
-						}			
-						</style>                
-				    </head>	
-				    
+						{
+							font-weight: bold; text-align: center;
+						}
+						</style>
+				    </head>
+
 				    <body>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="8" cellspacing="5">
 						<tbody>
-						<tr class="title">				
+						<tr class="title">
 							<td style="vertical-align: top; height: 3%; background-color: rgb(224, 224, 224);">Lorem ipsum</td>
 							<td style="height: 3%;"></td>
 							<td style="vertical-align: top; height: 3%; background-color: rgb(237, 237, 237);">Perspiciatis</td>
 							<td style="height: 3%;"></td>
 							<td style="vertical-align: top; height: 3%; background-color: rgb(245, 245, 245);">Nemo enim</td>
 						</tr>
-						
+
 						<tr>
 							<td style="vertical-align: top; width: 30%; background-color: rgb(224, 224, 224);">
 								<ul>
@@ -764,7 +764,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							<td>
 								<img style="width: 32px; height: 32px;" alt="arrow" src="{COURSE_DIR}images/small/arrow.png ">
 							</td>
-							
+
 							<td style="vertical-align: top; width: 30%; background-color: rgb(237, 237, 237);">
 								<ul>
 									<li>ut labore</li>
@@ -775,7 +775,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							<td>
 								<img style="width: 32px; height: 32px;" alt="arrow" src="{COURSE_DIR}images/small/arrow.png ">
 							</td>
-							
+
 							<td style="vertical-align: top; background-color: rgb(245, 245, 245); width: 30%;">
 								<ul>
 									<li>neque porro</li>
@@ -794,12 +794,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		\');
 		';
 		$res = mysql_query($sql);
-		
+
 		/*
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleStopAndThink\', \'TemplateTitleStopAndThinkDescription\', \'stopthink.gif\', \'
 		<head>
-		               {CSS}                    
+		               {CSS}
 				    </head>
 				    <body>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
@@ -829,7 +829,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		\');';
 		$res = mysql_query($sql);
 		*/
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleTable\', \'TemplateTitleCheckListDescription\', \'table.gif\', \'
 		<head>
@@ -839,15 +839,15 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						{
 							font-weight: bold; text-align: center;
 						}
-						
+
 						.items
 						{
 							text-align: right;
-						}	
-		  				
-		
+						}
+
+
 							</style>
-		  
+
 					    </head>
 					    <body>
 					    <br />
@@ -895,22 +895,22 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 						</body>
 		\');';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleAudio\', \'TemplateTitleAudioDescription\', \'audiocomment.gif\', \'
 		<head>
-		               {CSS}                    
+		               {CSS}
 				    </head>
 		                   <body>
 							<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 							<tbody>
 							<tr>
-							<td>					
+							<td>
 							<div align="center">
 							<span style="text-align: center;">
 								<embed  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="300" height="20" bgcolor="#FFFFFF" src="{REL_PATH}main/inc/lib/mediaplayer/player.swf" allowfullscreen="false" allowscriptaccess="always" flashvars="file={COURSE_DIR}audio/ListeningComprehension.mp3&amp;autostart=true"></embed>
-		                    </span></div>     
-							
+		                    </span></div>
+
 							<br>
 							</td>
 							<td colspan="1" rowspan="3"><br>
@@ -927,16 +927,16 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 							<p><br>
 							<br>
 							</p>
-							</body>	
+							</body>
 		\');';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleVideo\', \'TemplateTitleVideoDescription\', \'video.gif\', \'
 		<head>
 		            	{CSS}
 					</head>
-					
+
 					<body>
 					<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 720px; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 					<tbody>
@@ -992,19 +992,19 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					</body>
 		\'); ';
 		$res = mysql_query($sql);
-		
+
 		$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
 		(\'TemplateTitleFlash\', \'TemplateTitleFlashDescription\', \'flash.gif\', \'
 		<head>
-		               {CSS}                    
-				    </head>				    
+		               {CSS}
+				    </head>
 				    <body>
 				    <center>
 						<table style="background: transparent url({IMG_DIR}faded_blue_horizontal.png ) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; text-align: left; width: 100%; height: 400px;" border="0" cellpadding="15" cellspacing="6">
 						<tbody>
 							<tr>
 							<td align="center">
-							<embed width="700" height="300" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="{COURSE_DIR}flash/SpinEchoSequence.swf" play="true" loop="true" menu="true"></embed></span><br /> 				          													
+							<embed width="700" height="300" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="{COURSE_DIR}flash/SpinEchoSequence.swf" play="true" loop="true" menu="true"></embed></span><br />
 							</td>
 							</tr>
 						</tbody>
@@ -1016,7 +1016,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					</body>
 		\'); ';
 		$res = mysql_query($sql);
-		
+
         // Check if course_module exists, as it was not installed in Dokeos 1.8.5 because of a broken query, and $sql = 'INSERT it if necessary
         $query = "SELECT * FROM $dbNameForm.course_module";
         $result = mysql_query($query);
@@ -1068,10 +1068,10 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
             }
         }
 
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','stats');
-	
+
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list
@@ -1082,7 +1082,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -1110,7 +1110,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -1125,7 +1125,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		}
 		//the SCORM database doesn't need a change in the pre-migrate part - ignore
 	}
-	
+
 
 	/*
 	-----------------------------------------------------------
@@ -1140,12 +1140,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
-		$prefix =  get_config_param ('table_prefix');			
+		$prefix =  get_config_param ('table_prefix');
 	}
-	
+
 	//get the courses databases queries list (c_q_list)
 	$c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','course');
 
@@ -1158,7 +1158,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		}
 		elseif(!in_array($dbNameForm,$dblist))
 		{
-			error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+			error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}
 		else
 		{
@@ -1185,40 +1185,40 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					 * without a database name
 					 */
 					if (!$singleDbForm) //otherwise just use the main one
-					{									
+					{
 						mysql_select_db($row_course['db_name']);
 					}
-                    
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
-							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);												
+							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);
 						}
 						else
 						{
-							$res = mysql_query($query);						
+							$res = mysql_query($query);
 							if($log)
 							{
 								error_log("In ".$row_course['db_name'].", executed: $query",0);
 							}
 						}
 					}
-                    
+
                     $t_d = $row_course['db_name'].".document";
                     $t_ip = $row_course['db_name'].".item_property";
-                    
+
                     if($singleDbForm)
                     {
                         $t_d = "$prefix{$row_course['db_name']}_document";
                         $t_ip = "$prefix{$row_course['db_name']}_item_property";
                     }
-                    // shared documents folder   
+                    // shared documents folder
                     $query = "INSERT INTO $t_d (path,title,filetype,size) VALUES ('/shared_folder','".get_lang('SharedDocumentsDirectory')."','folder','0')";
                     $myres = mysql_query($query);
                     if ($myres !== false) {

+ 40 - 40
main/install/update-db-1.8.6-1.8.6.1.inc.php

@@ -49,9 +49,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -111,7 +111,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	// that we want to change the main databases as well...
 	$only_test = false;
 	$log = 0;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		if ($singleDbForm)
 		{
@@ -142,7 +142,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbNameForm)>40){
 				error_log('Database name '.$dbNameForm.' is too long, skipping',0);
 			}elseif(!in_array($dbNameForm,$dblist)){
-				error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+				error_log('Database '.$dbNameForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbNameForm);
 				foreach($m_q_list as $query){
@@ -158,11 +158,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				}
 			}
 		}
-		
-		
+
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','stats');
-	
+
 		if(count($s_q_list)>0)
 		{
 			//now use the $s_q_list
@@ -173,7 +173,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbStatsForm)>40){
 				error_log('Database name '.$dbStatsForm.' is too long, skipping',0);
 			}elseif(!in_array($dbStatsForm,$dblist)){
-				error_log('Database '.$dbStatsForm.' was not found, skipping',0);				
+				error_log('Database '.$dbStatsForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbStatsForm);
 				foreach($s_q_list as $query){
@@ -201,7 +201,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			if(strlen($dbUserForm)>40){
 				error_log('Database name '.$dbUserForm.' is too long, skipping',0);
 			}elseif(!in_array($dbUserForm,$dblist)){
-				error_log('Database '.$dbUserForm.' was not found, skipping',0);				
+				error_log('Database '.$dbUserForm.' was not found, skipping',0);
 			}else{
 				mysql_select_db($dbUserForm);
 				foreach($u_q_list as $query){
@@ -216,7 +216,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		}
 		//the SCORM database doesn't need a change in the pre-migrate part - ignore
 	}
-	
+
 
 	/*
 	-----------------------------------------------------------
@@ -231,12 +231,12 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	-----------------------------------------------------------
 	*/
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
-		$prefix =  get_config_param ('table_prefix');			
+		$prefix =  get_config_param ('table_prefix');
 	}
-	
+
 	//get the courses databases queries list (c_q_list)
 	$c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql','course');
 
@@ -249,7 +249,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		}
 		elseif(!in_array($dbNameForm,$dblist))
 		{
-			error_log('Database '.$dbNameForm.' was not found, skipping',0);				
+			error_log('Database '.$dbNameForm.' was not found, skipping',0);
 		}
 		else
 		{
@@ -276,75 +276,75 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 					 * without a database name
 					 */
 					if (!$singleDbForm) //otherwise just use the main one
-					{									
+					{
 						mysql_select_db($row_course['db_name']);
 					}
-                    
+
 					foreach($c_q_list as $query)
 					{
 						if ($singleDbForm) //otherwise just use the main one
 						{
-							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);												
+							$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix{$row_course['db_name']}_$2$3",$query);
 						}
-						
+
 						if($only_test)
 						{
 							error_log("mysql_query(".$row_course['db_name'].",$query)",0);
 						}
 						else
 						{
-							$res = mysql_query($query);						
+							$res = mysql_query($query);
 							if($log)
 							{
 								error_log("In ".$row_course['db_name'].", executed: $query",0);
 							}
 						}
 					}
-					
+
 					$t_wiki = $row_course['db_name'].".wiki";
                     $t_wiki_conf = $row_course['db_name'].".wiki_conf";
-                    
+
                     if($singleDbForm)
-                    {                        
+                    {
                         $t_wiki = "$prefix{$row_course['db_name']}_wiki";
                         $t_wiki_conf = "$prefix{$row_course['db_name']}_wiki_conf";
                     }
-                    
+
                     //update correct page_id to wiki table, actually only store 0
                     $query = "SELECT id, reflink FROM $t_wiki";
                     $res_page = mysql_query($query);
-                    $wiki_id = $reflink = array(); 
+                    $wiki_id = $reflink = array();
 
 					if (mysql_num_rows($res_page) > 0 ) {
-	                    while ($row_page = mysql_fetch_row($res_page)) {                    	
+	                    while ($row_page = mysql_fetch_row($res_page)) {
 	                    	$wiki_id[] = $row_page[0];
-	                    	$reflink[] = $row_page[1];                    	 
+	                    	$reflink[] = $row_page[1];
 	                    }
 					}
-                                        
+
                     $reflink_unique = array_unique($reflink);
                     $reflink_flip = array_flip($reflink_unique);
-                    
-                    if (is_array($wiki_id)) {  					 
-	                    foreach ($wiki_id as $key=>$wiki_page) {                   	                    	
+
+                    if (is_array($wiki_id)) {
+	                    foreach ($wiki_id as $key=>$wiki_page) {
 	                    	$pag_id = $reflink_flip[$reflink[$key]];
 	                    	$sql= "UPDATE $t_wiki SET page_id='".($pag_id + 1)."' WHERE id = '$wiki_page'";
-	                    	$res_update = mysql_query($sql);		                     		       					       				                        	
-	                    }					
+	                    	$res_update = mysql_query($sql);
+	                    }
                     }
 
-                    //insert page_id into wiki_conf table, actually this table is empty					
-				   	$query = "SELECT DISTINCT page_id FROM $t_wiki ORDER BY page_id";	
+                    //insert page_id into wiki_conf table, actually this table is empty
+				   	$query = "SELECT DISTINCT page_id FROM $t_wiki ORDER BY page_id";
 				   	$myres_wiki = mysql_query($query);
-				   	
-				   	if (mysql_num_rows($myres_wiki) > 0 ) {					
+
+				   	if (mysql_num_rows($myres_wiki) > 0 ) {
 					   	while ($row_wiki = mysql_fetch_row($myres_wiki)) {
 					   		$page_id = $row_wiki[0];
-					   		$query="INSERT INTO ".$t_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3) VALUES ('".$page_id."','','','','','','','')";				   
-	                   		$myres_wiki_conf = mysql_query($query); 					   	
+					   		$query="INSERT INTO ".$t_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3) VALUES ('".$page_id."','','','','','','','')";
+	                   		$myres_wiki_conf = mysql_query($query);
 					   	}
 				   	}
-					
+
    				}
 			}
 		}

+ 60 - 60
main/install/update-db-scorm-1.6.x-1.8.0.inc.php

@@ -1,8 +1,8 @@
 <?php //$id: $
 /**
- * Script handling the migration between an old Dokeos platform (<1.8.0) to 
+ * Script handling the migration between an old Dokeos platform (<1.8.0) to
  * setup the new database system (4 scorm tables inside the course's database)
- * @package dokeos.scorm 
+ * @package dokeos.scorm
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
 /**
@@ -80,7 +80,7 @@ while ($row = Database::fetch_array($res))
     $courses_list[] = $row['db_name'];
     $courses_id_list[$row['code']] = $row['db_name'];
     $courses_id_full_table_prefix_list[$row['code']] = $dbname;
-    $courses_dir_list[$row['code']] = $row['directory']; 
+    $courses_dir_list[$row['code']] = $row['directory'];
 }
 if($loglevel>0){error_log("Tables created/deleted for all courses",0);}
 
@@ -116,7 +116,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
     $my_new_lp_item = $db.$new_lp_item;
     $my_new_lp_view = $db.$new_lp_view;
     $my_new_lp_item_view = $db.$new_lp_item_view;
-    
+
     //migrate learnpaths
     $sql_test = "SELECT * FROM $my_new_lp";
     $res_test = mysql_query($sql_test);
@@ -148,19 +148,19 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
         $max_dsp_lp = $dsp_ord;
     }
     //echo "<pre>lp_ids:".print_r($lp_ids,true)."</pre>\n";
-    
+
 
     //MIGRATING LEARNPATH CHAPTERS
     $sql_lp_chap = "ALTER TABLE $lp_chap ADD INDEX ( parent_chapter_id, display_order )";
-    $res_lp_chap = api_sql_query($sql_lp_chap,__FILE__,__LINE__); 
+    $res_lp_chap = api_sql_query($sql_lp_chap,__FILE__,__LINE__);
 
     $sql_lp_chap = "SELECT * FROM $lp_chap ORDER BY parent_chapter_id, display_order";
     //echo "$sql_lp_chap<br />\n";
-    $res_lp_chap = api_sql_query($sql_lp_chap,__FILE__,__LINE__);   
+    $res_lp_chap = api_sql_query($sql_lp_chap,__FILE__,__LINE__);
     while($row = Database::fetch_array($res_lp_chap))
     {
         //echo "Treating chapter id : ".$row['id']."<br />\n";
-        
+
         //TODO build path for this chapter (although there is no real path for any chapter)
         //TODO find out how to calculate the "next_item_id" with the "ordre" field
         $my_lp_item = $my_new_lp_item;
@@ -200,7 +200,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
         if($old_parent_chap != 0){
             $new_chap = $lp_chap_items[$old_chap];
             $new_parent = $lp_chap_items[$old_parent_chap];
-            if(isset($new_chap) && $new_chap != '' 
+            if(isset($new_chap) && $new_chap != ''
                 && isset($new_parent) && $new_parent != '')
             {
                 $sql_par_chap = "UPDATE $my_new_lp_item " .
@@ -219,7 +219,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
                     "SET previous_item_id = $last " .
                     "WHERE id = $new_id";
             $res_upd_chaps = api_sql_query($sql_upd_chaps,__FILE__,__LINE__);
-        
+
             $next = 0;
             if(!empty($ordered_chaps[$parent_chap][$order+1])){
                 $next = $ordered_chaps[$parent_chap][$order+1];
@@ -232,7 +232,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
         }
     }
     unset($ordered_chaps);
-    
+
     //migrate learnpath_items
     //TODO define this array thanks to types defined in the learnpath_building scripts
     //TODO set order correctly
@@ -257,16 +257,16 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
         'Course_description' => TOOL_COURSE_DESCRIPTION,
         'Groups'    => TOOL_GROUP,
         'Users'     => TOOL_USER,
-        
+
         //'chapter' => 'dokeos_chapter', Chapters should all be in learnpath_chapter, no matter the nesting level
-        
+
     );
     //MIGRATING LEARNPATH ITEMS
     $sql_lp_item = "ALTER TABLE $lp_item ADD INDEX ( chapter_id, display_order)";
-    $res_lp_item = api_sql_query($sql_lp_item,__FILE__,__LINE__);   
+    $res_lp_item = api_sql_query($sql_lp_item,__FILE__,__LINE__);
     $sql_lp_item = "SELECT * FROM $lp_item ORDER BY chapter_id, display_order";
     //echo "$sql_lp_item<br />\n";
-    $res_lp_item = api_sql_query($sql_lp_item,__FILE__,__LINE__);   
+    $res_lp_item = api_sql_query($sql_lp_item,__FILE__,__LINE__);
     while($row = Database::fetch_array($res_lp_item))
     {
         //echo "Treating chapter ".$row['chapter_id'].", item ".$row['id']."<br />\n";
@@ -346,7 +346,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
             if(empty($in_id) OR $in_id == false) die('Could not insert lp_item: '.$ins_sql);
             $lp_items[$parent_lps[$row['chapter_id']]][$row['id']] = $in_id;
             $lp_ordered_items[$parent_lps[$row['chapter_id']]][$row['chapter_id']][] = $in_id;
-        }       
+        }
     }
     //echo "<pre>lp_items:".print_r($lp_items,true)."</pre>\n";
     // complete next_item_id field by going through the new table and looking at parent_id and display_order
@@ -400,9 +400,9 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
         api_sql_query($upd,__FILE__,__LINE__);
         $last = $item_id;
     }
-    
+
     //echo "</pre>\n";
-    
+
     //MIGRATING THE learnpath_user TABLE (results)
     $mysql = "ALTER TABLE $my_new_lp_item_view ADD INDEX (lp_view_id)";
     $myres = api_sql_query($mysql,__FILE__,__LINE__);
@@ -428,7 +428,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
                 //used it, but now it's been removed
                 //echo "Somehow we also miss a lp_ids[".$row['learnpath_id']."] here<br />\n";
                 $incoherences ++;
-            }else{              
+            }else{
                 $mylpid = $lp_ids[$row['learnpath_id']];
                 $sql_ins_view = "INSERT INTO $my_new_lp_view(" .
                         "lp_id," .
@@ -550,7 +550,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
             if(!empty($matches[3]) && (strtolower(substr($matches[3],-15))=='imsmanifest.xml') && !is_file(realpath(urldecode($matches[3]))) )
             {
                 //echo "Removing link $link from tools<br />";
-                $sql_tool_upd = "DELETE FROM $tbl_tool WHERE id = ".$row_tool['id']; 
+                $sql_tool_upd = "DELETE FROM $tbl_tool WHERE id = ".$row_tool['id'];
                 error_log('New LP - Migration - Updating tool table (dead link): '.$sql_tool_upd,0);
                 //make sure there is a way of retrieving which links were updated (to revert)
                 fwrite($fh,$sql_tool_upd." AND link ='$link'");
@@ -569,7 +569,7 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
     $tbl_intro = $db.TABLE_TOOL_INTRO;
     $sql_i = "SELECT * FROM $tbl_intro WHERE id='course_homepage'";
     $res_i = api_sql_query($sql_i,__FILE__,__LINE__);
-    //$link_to_course1 = 'scorm/scormdocument.php'; 
+    //$link_to_course1 = 'scorm/scormdocument.php';
     while($row_i = Database::fetch_array($res_i)){
         $intro = $row_i['intro_text'];
         $update = 0;
@@ -595,9 +595,9 @@ foreach($courses_id_full_table_prefix_list as $course_code => $db)
             api_sql_query($sql_upd,__FILE__,__LINE__);
         }
     }
-    
-    
-        
+
+
+
     if($loglevel>0){error_log("Done!".$msg,0);}
     //flush();
     //ob_flush();
@@ -648,7 +648,7 @@ $scormdocuments_lps = array();
 while($course_row = Database::fetch_array($res_crs)){
 
     if($loglevel>0){error_log("Now dealing with course ".$course_row['code']."...",0);}
-    //check the validity of this new course     
+    //check the validity of this new course
     $my_course_code = $course_row['code'];
 
     //reinit the scormdocuments list
@@ -665,23 +665,23 @@ while($course_row = Database::fetch_array($res_crs)){
     if($loglevel>1){error_log("$sql_scodoc",0);}
     $res_scodoc = api_sql_query($sql_scodoc,__FILE__,__LINE__);
     while($row_scodoc = Database::fetch_array($res_scodoc)){
-        
+
         //check if there's more than one slash in total
         if(strpos($row_scodoc['path'],'/',1)===false){
             $tmp_path = $row_scodoc['path'];
             if($loglevel>1){error_log("++Now opening $tmp_path",0);}
-            
+
             //add a prefixing slash if there is none
             if(substr($tmp_path,0,1)!='/'){
                 $tmp_path = '/'.$tmp_path;
             }
-            
+
             //if the path is just a slash, empty it
             if($tmp_path=='/'){
                 $tmp_path='';
             }
-            
-            //there is only one 'slash' sign at the beginning, 
+
+            //there is only one 'slash' sign at the beginning,
             //or none at all, so we assume
             //it is a main directory that should be taken as path
             $courses_dir = $sys_course_path.''.$courses_dir_list[$my_course_code].'/scorm'.$tmp_path;
@@ -722,7 +722,7 @@ while($course_row = Database::fetch_array($res_crs)){
     $sql_i = "SELECT * FROM $tbl_intro WHERE id='course_homepage'";
     //echo $sql_i;
     $res_i = api_sql_query($sql_i,__FILE__,__LINE__);
-    //$link_to_course1 = 'scorm/scormdocument.php'; 
+    //$link_to_course1 = 'scorm/scormdocument.php';
     while($row_scodoc = Database::fetch_array($res_i)){
         $intro = $row_scodoc['intro_text'];
         //echo $intro."<br />\n";
@@ -744,7 +744,7 @@ while($course_row = Database::fetch_array($res_crs)){
                     $mymatch = str_replace($sys_course_path,$upd_course_path,$mymatch);
                     if(!empty($mymatch) && (strtolower(substr($mymatch,-15))=='imsmanifest.xml') && is_file(realpath(urldecode($mymatch))) )
                     {
-                        
+
                         //echo $mymatch." seems ok<br />";
                         //found a new scorm course in the old directory
                         $courses_dir = $upd_course_path.''.$courses_dir_list[$my_course_code].'/scorm';
@@ -779,7 +779,7 @@ while($course_row = Database::fetch_array($res_crs)){
             }
         }
     }
-    
+
     //prepare the new course's space in the scorms array
     $scorms[$my_course_code] = array();
 
@@ -810,7 +810,7 @@ while($course_row = Database::fetch_array($res_crs)){
             $scorms[$my_course_code][$my_path] = $my_content_id;
         }
     }
-    //check if all the lps from scormdocuments_lps are already in the course array, 
+    //check if all the lps from scormdocuments_lps are already in the course array,
     //otherwise add them (and set ID of 0 so no tracking will be available)
     foreach($scormdocuments_lps as $path){
         if(!in_array($path,array_keys($scorms[$my_course_code]))){
@@ -868,7 +868,7 @@ foreach($scorms as $my_course_code => $paths_list )
     $my_content_id = $old_id;
     $my_path = $my_path;
     $my_name = basename($my_path);
-    
+
     if($loglevel>1){error_log("Try importing LP $my_path from imsmanifest first as it is more reliable",0);}
 
     //Setup the ims path (path to the imsmanifest.xml file)
@@ -877,7 +877,7 @@ foreach($scorms as $my_course_code => $paths_list )
     $courses_dir = $upd_course_path.$courses_dir_list[$my_course_code];
     $sco_path_temp = ($my_path=='/')?'':$my_path;
     $sco_middle_path = (empty($sco_path_temp)?'':(substr($sco_path_temp,0,1)=='/')?substr($sco_path_temp,1).'/':$sco_path_temp.'/'); //same thing as sco_path_temp but with reversed slashes
-    $ims = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml'; 
+    $ims = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml';
 
     if(is_file($ims)){
         //echo "Path $ims exists, importing...(line ".__LINE__.")<br />";
@@ -891,7 +891,7 @@ foreach($scorms as $my_course_code => $paths_list )
         //the title is already escaped in the method
         $oScorm->import_manifest($my_course_code);
         //TODO add code to update the path in that new lp created, as it probably uses / where
-        //$sco_path_temp should be used... 
+        //$sco_path_temp should be used...
         $lp_ids[$my_content_id] = $oScorm->lp_id; //contains the old LP ID => the new LP ID
         if($loglevel>1){error_log(" @@@ Created scorm lp ".$oScorm->lp_id." from imsmanifest [".$ims."] in course $my_course_code",0);}
         $lp_course[$my_content_id] = $courses_id_list[$my_course_code]; //contains the old learnpath ID => the course DB name
@@ -918,11 +918,11 @@ foreach($scorms as $my_course_code => $paths_list )
             $my_type        = 'sco';
             //$my_item_path = $scorm_lp_paths[$my_content_id]['path'];
             $my_item_path   = '';
-            
+
             //echo "&nbsp;&nbsp;FOUND item belonging to old learnpath num $my_content_id so belongs to course ".$lp_course[$my_content_id]."<br />\n";
-            $my_new_lp_item = $db_name.$new_lp_item;    
-            $my_new_lp_view = $db_name.$new_lp_view;    
-            $my_new_lp_item_view = $db_name.$new_lp_item_view;  
+            $my_new_lp_item = $db_name.$new_lp_item;
+            $my_new_lp_view = $db_name.$new_lp_view;
+            $my_new_lp_item_view = $db_name.$new_lp_item_view;
 
             /*
              * Check if a view is needed
@@ -973,7 +973,7 @@ foreach($scorms as $my_course_code => $paths_list )
             }
         }
 
-    }       
+    }
     else{
         //echo "Could not find $ims... Proceeding from database...(line ".__LINE__.")<br />";
         if($loglevel>1){error_log("This is a normal SCORM path",0);}
@@ -1012,14 +1012,14 @@ foreach($scorms as $my_course_code => $paths_list )
         $lp_course[$my_content_id] = $courses_id_list[$my_course_code]; //contains the old learnpath ID => the course DB name
         $lp_course_code[$my_content_id] = $my_course_code;
         $max_dsp_lp++;
-    
+
         //Setup the ims path (path to the imsmanifest.xml file)
         //echo "Looking for course with code ".$lp_course_code[$my_content_id]." (using $my_content_id)<br />\n";
         $courses_dir = $sys_course_path.$courses_dir_list[$lp_course_code[$my_content_id]];
         //$scorm_lp_paths[$my_content_id]['path'] = str_replace(' ','\\ ',$scorm_lp_paths[$my_content_id]['path']);
         $sco_path_temp = ($scorm_lp_paths[$my_content_id]['path']=='/')?'':$scorm_lp_paths[$my_content_id]['path'];
-        $scorm_lp_paths[$my_content_id]['ims'] = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml'; 
-        
+        $scorm_lp_paths[$my_content_id]['ims'] = $courses_dir.'/scorm'.$sco_path_temp.'/imsmanifest.xml';
+
         //generate an imsmanifest object to get more info about the learnpath from the file
         $oScorm = new scorm();
         //check if imsmanifest.xml exists at this location. If not, ignore the imsmanifest.
@@ -1035,16 +1035,16 @@ foreach($scorms as $my_course_code => $paths_list )
             //$my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1',$oScorm->manifest_encoding);
             $my_lp_title = api_convert_encoding($oScorm->get_title(),'ISO-8859-1','UTF-8');
             if(!empty($my_lp_title)){
-                $my_new_lp = $db_name.$new_lp;  
+                $my_new_lp = $db_name.$new_lp;
                 $my_sql = "UPDATE $my_new_lp " .
                         "SET name = '$my_lp_title', " .
                         "default_encoding = '".strtoupper($oScorm->manifest_encoding)."' " .
                         "WHERE id = ".$lp_ids[$my_content_id];
                 if($loglevel>1){error_log("Updating title and encoding: ".$my_sql,0);}
-                $my_res = api_sql_query($my_sql,__FILE__,__LINE__); 
+                $my_res = api_sql_query($my_sql,__FILE__,__LINE__);
             }
         }
-    
+
         /*
          * QUERY SCORM ITEMS FROM SCORM_SCO_DATA
          * The danger here is that we might have several users for the same data, and so
@@ -1065,12 +1065,12 @@ foreach($scorms as $my_course_code => $paths_list )
             $my_type        = 'sco';
             //$my_item_path = $scorm_lp_paths[$my_content_id]['path'];
             $my_item_path   = '';
-            
+
             //echo "&nbsp;&nbsp;FOUND item belonging to old learnpath num $my_content_id so belongs to course ".$lp_course[$my_content_id]."<br />\n";
-            $my_new_lp_item = $db_name.$new_lp_item;    
-            $my_new_lp_view = $db_name.$new_lp_view;    
-            $my_new_lp_item_view = $db_name.$new_lp_item_view;  
-            
+            $my_new_lp_item = $db_name.$new_lp_item;
+            $my_new_lp_view = $db_name.$new_lp_view;
+            $my_new_lp_item_view = $db_name.$new_lp_item_view;
+
             /*
              * Query items from the new table to check if it doesn't exist already
              * Otherwise insert it
@@ -1163,11 +1163,11 @@ foreach($scorms as $my_course_code => $paths_list )
         /*
          * Set all information that might be more correct coming from imsmanifest
          */
-        
+
         //$my_new_lp = $db_name.$new_lp;
-        //$my_new_lp_item = $db_name.$new_lp_item;  
-        //$my_new_lp_view = $db_name.$new_lp_view;  
-        //$my_new_lp_item_view = $db_name.$new_lp_item_view;    
+        //$my_new_lp_item = $db_name.$new_lp_item;
+        //$my_new_lp_view = $db_name.$new_lp_view;
+        //$my_new_lp_item_view = $db_name.$new_lp_item_view;
         //$sel_sql = "SELECT * FROM $my_new_lp WHERE id = $in_id";
         //$res = @mysql_query($sel_sql);
         //if(!$res){
@@ -1200,7 +1200,7 @@ foreach($scorms as $my_course_code => $paths_list )
                     $new_id = $lp_item_refs[$in_id][$subarray['identifier']];
                     $next = 0;
                     $dsp = $subarray['rel_order'];
-                    if($subarray['level']>$level){  
+                    if($subarray['level']>$level){
                         //getting one level deeper, just consult
                         $parent_id = $previous;
                         array_push($stock,$previous);
@@ -1240,7 +1240,7 @@ foreach($scorms as $my_course_code => $paths_list )
                     if(!empty($prereq)){
                         $update_prereq = "prerequisite = '$prereq', ";
                     }
-                    
+
                     //we had previous data about this element, update
                     $sql2 = "UPDATE $my_new_lp_item " .
                             "SET parent_item_id = $parent_id, " .
@@ -1272,7 +1272,7 @@ foreach($scorms as $my_course_code => $paths_list )
     $tbl_intro = $db_name.TABLE_TOOL_INTRO;
     $sql_i = "SELECT * FROM $tbl_intro WHERE id='course_homepage'";
     $res_i = api_sql_query($sql_i,__FILE__,__LINE__);
-    //$link_to_course1 = 'scorm/scormdocument.php'; 
+    //$link_to_course1 = 'scorm/scormdocument.php';
     while($row_i = Database::fetch_array($res_i)){
         $intro = $row_i['intro_text'];
         $out = array();

+ 13 - 13
main/install/update-files-1.6.x-1.8.0.inc.php

@@ -24,13 +24,13 @@
 /**
 ==============================================================================
 * Updates the Dokeos files from version 1.6.x to version 1.8.0
-* IMPORTANT: This script has to be included by install/index.php or 
+* IMPORTANT: This script has to be included by install/index.php or
 * update_courses.php
 *
-* DOKEOS_INSTALL is defined in the install/index.php (means that we are in 
+* DOKEOS_INSTALL is defined in the install/index.php (means that we are in
 * the regular upgrade process)
-* 
-* DOKEOS_COURSE_UPDATE is defined in update_courses.php (means we are 
+*
+* DOKEOS_COURSE_UPDATE is defined in update_courses.php (means we are
 * executing update_courses.php to update courses separately)
 *
 * When DOKEOS_INSTALL or DOKEOS_COURSE_UPDATE are defined, do for every course:
@@ -54,10 +54,10 @@ require_once('install_upgrade.lib.php');
 function insert_db($db_name, $folder_name, $text){
 
 	$_course['dbName'] = $db_name;
-	
+
 	$doc_id = add_document_180($_course, '/'.$folder_name, 'folder', 0, ucfirst($text));
 	api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', 1);
-	
+
 }
 
 /*
@@ -75,19 +75,19 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	$sql = "SELECT * FROM course";
 	error_log('Getting courses for files updates: '.$sql,0);
 	$result=mysql_query($sql);
-	
+
 	$perm = api_get_setting('permissions_for_new_directories');
 	$perm = octdec(!empty($perm)?$perm:'0770');
 	$old_umask = umask(0);
 	while($courses_directories=mysql_fetch_array($result)){
-		
+
 		$currentCourseRepositorySys = $sys_course_path.$courses_directories["directory"]."/";
 		$db_name = $courses_directories["db_name"];
 		$origCRS = $updatePath.'courses/'.$courses_directories["directory"];
 
 		if(!is_dir($origCRS)){
 			error_log('Directory '.$origCRS.' does not exist. Skipping.',0);
-			continue;	
+			continue;
 		}
 		//move everything to the new hierarchy (from old path to new path)
 		error_log('Renaming '.$origCRS.' to '.$sys_course_path.$courses_directories["directory"],0);
@@ -128,7 +128,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(!is_dir($currentCourseRepositorySys."upload")){
 			mkdir($currentCourseRepositorySys."upload",$perm);
 		}
-		
+
 		//upload > blog
 		if(!is_dir($currentCourseRepositorySys."upload/blog")){
 			mkdir($currentCourseRepositorySys."upload/blog",$perm);
@@ -141,7 +141,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		if(!is_dir($currentCourseRepositorySys."upload/test")){
 			mkdir($currentCourseRepositorySys."upload/test",$perm);
 		}
-		
+
 		//Updating index file in courses directories to change claroline/ into main/
 		$content = '<?php'."\n".
 				'$cidReq="'.$courses_directories['code'].'";'."\n" .
@@ -152,7 +152,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		$fp = @ fopen($currentCourseRepositorySys.'index.php', 'w');
 		if ($fp)
 		{
-			error_log('Writing redirection file in '.$currentCourseRepositorySys.'index.php',0);			
+			error_log('Writing redirection file in '.$currentCourseRepositorySys.'index.php',0);
 			fwrite($fp, $content);
 			fclose($fp);
 		}else{
@@ -182,7 +182,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	rename($updatePath.'claroline/upload/linked_files',$pathForm.'main/upload/linked_files');
 	error_log('Renaming '.$updatePath.'claroline/upload/video to '.$pathForm.'main/upload/video',0);
 	rename($updatePath.'claroline/upload/video',$pathForm.'main/upload/video');
-		
+
 	/*
 	if (defined('DOKEOS_INSTALL'))
 	{

+ 2 - 2
main/install/update-files-1.8.3-1.8.4.inc.php

@@ -32,7 +32,7 @@
 * permissions on upgrade).
 * Being in configuration.php, it benefits from the configuration.dist.php
 * advantages that a new version doesn't overwrite it, thus letting the old
-* version be available until the end of the installation. 
+* version be available until the end of the installation.
 * @package dokeos.install
 ==============================================================================
 */
@@ -76,7 +76,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	}
 	if(!$found_stable)
 	{
-		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");		
+		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
 	}
 	fwrite($fh,'?>');
 	fclose($fh);

+ 2 - 2
main/install/update-files-1.8.4-1.8.5.inc.php

@@ -11,7 +11,7 @@
 * permissions on upgrade).
 * Being in configuration.php, it benefits from the configuration.dist.php
 * advantages that a new version doesn't overwrite it, thus letting the old
-* version be available until the end of the installation. 
+* version be available until the end of the installation.
 * @package dokeos.install
 ==============================================================================
 */
@@ -55,7 +55,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	}
 	if(!$found_stable)
 	{
-		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");		
+		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
 	}
 	fwrite($fh,'?>');
 	fclose($fh);

+ 17 - 17
main/install/update-files-1.8.5-1.8.6.inc.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /* See license terms in /dokeos_license.txt */
 /**
 ==============================================================================
@@ -11,7 +11,7 @@
 * permissions on upgrade).
 * Being in configuration.php, it benefits from the configuration.dist.php
 * advantages that a new version doesn't overwrite it, thus letting the old
-* version be available until the end of the installation. 
+* version be available until the end of the installation.
 * @package dokeos.install
 ==============================================================================
 */
@@ -40,7 +40,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
 		}
 		elseif(stristr($line,'$userPasswordCrypted'))
-		{			
+		{
 			$line = '$userPasswordCrypted 									= \''.($userPasswordCrypted).'\';'."\r\n";
 		}
 		elseif(stristr($line,'?>'))
@@ -59,13 +59,13 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	}
 	if(!$found_stable)
 	{
-		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");		
+		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
 	}
 	fwrite($fh,'?>');
-	fclose($fh);	
-	
+	fclose($fh);
+
 	$sys_course_path = $pathForm.'courses/';
-	
+
 	//$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
 	//linking
 	$link = mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
@@ -74,16 +74,16 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	$sql = "SELECT * FROM $db_name.course";
 	error_log('Getting courses for files updates: '.$sql,0);
 	$result=mysql_query($sql);
-	
+
 	$perm = api_get_setting('permissions_for_new_directories');
 	$perm = octdec(!empty($perm)?$perm:'0770');
 	$old_umask = umask(0);
-	
-	
+
+
 	while($courses_directories=mysql_fetch_array($result))
-	{		
+	{
 		$currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';
-		
+
 		$db_name = $courses_directories['db_name'];
 		$origCRS = $updatePath.'courses/'.$courses_directories['directory'];
 
@@ -95,7 +95,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		error_log('Renaming '.$origCRS.' to '.$sys_course_path.$courses_directories['directory'],0);
 		rename($origCRS,$sys_course_path.$courses_directories['directory']);
 		error_log('Creating dirs in '.$currentCourseRepositorySys,0);
-	
+
 		//DOCUMENT FOLDER
 
         //document > shared_folder
@@ -113,17 +113,17 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		//upload > learning_path
 		if(!is_dir($currentCourseRepositorySys."upload/learning_path")){
 			mkdir($currentCourseRepositorySys."upload/learning_path",$perm);
-		}	
+		}
 
 		//upload > learning_path > images
 		if(!is_dir($currentCourseRepositorySys."upload/learning_path/images")){
 			mkdir($currentCourseRepositorySys."upload/learning_path/images",$perm);
-		}		
+		}
 
-		//upload > calendar 
+		//upload > calendar
 		if(!is_dir($currentCourseRepositorySys."upload/calendar")){
 			mkdir($currentCourseRepositorySys."upload/calendar",$perm);
-		}	
+		}
 
 		//upload > calendar > images
 		if(!is_dir($currentCourseRepositorySys."upload/calendar/images")){

+ 9 - 9
main/install/update-files-1.8.6-1.8.6.1.inc.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /* See license terms in /dokeos_license.txt */
 /**
 ==============================================================================
@@ -11,7 +11,7 @@
 * permissions on upgrade).
 * Being in configuration.php, it benefits from the configuration.dist.php
 * advantages that a new version doesn't overwrite it, thus letting the old
-* version be available until the end of the installation. 
+* version be available until the end of the installation.
 * @package dokeos.install
 ==============================================================================
 */
@@ -40,7 +40,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
 		}
 		elseif(stristr($line,'$userPasswordCrypted'))
-		{			
+		{
 			$line = '$userPasswordCrypted 									= \''.($userPasswordCrypted).'\';'."\r\n";
 		}
 		elseif(stristr($line,'?>'))
@@ -59,22 +59,22 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	}
 	if(!$found_stable)
 	{
-		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");		
+		fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
 	}
 	fwrite($fh,'?>');
-	fclose($fh);	
-	
-	
+	fclose($fh);
+
+
 	$perm = api_get_setting('permissions_for_new_directories');
 	$perm = octdec(!empty($perm)?$perm:'0770');
 	$old_umask = umask(0);
-	
+
 	////create a specific directory for global thumbails
 	//home > default_platform_document > template_thumb
 	if(!is_dir($pathForm.'home/default_platform_document/template_thumb')){
 		mkdir($pathForm.'home/default_platform_document/template_thumb',$perm);
 	}
-	
+
 }
 else
 {

+ 83 - 83
main/install/update_db.inc.php

@@ -60,9 +60,9 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 
 		exit ();
 	}
-	
-	//get_config_param() comes from install_functions.inc.php and 
-	//actually gets the param from 
+
+	//get_config_param() comes from install_functions.inc.php and
+	//actually gets the param from
 	$_configuration['db_glue'] = get_config_param('dbGlu');
 
 	if ($singleDbForm)
@@ -114,7 +114,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 	//if this script has been included by index.php, not update_courses.php, so
 	// that we want to change the main databases as well...
 	$only_test = false;
-	if (defined('DOKEOS_INSTALL')) 
+	if (defined('DOKEOS_INSTALL'))
 	{
 		/**
 		 * Update the databases "pre" migration
@@ -151,7 +151,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		//$sql_upd = "UPDATE user SET registration_date=NOW()";
 		//$res_upd = mysql_query($sql_upd);
 		//end of manual updates
-		
+
 		//get the stats queries list (s_q_list)
 		$s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','stats');
 		if(count($s_q_list)>0)
@@ -195,8 +195,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		/*
 		$language_table = "`$dbNameForm`.`language`";
 		fill_language_table($language_table);
-		
-		//set the settings from the form or the old config into config settings. 
+
+		//set the settings from the form or the old config into config settings.
 		//These settings are considered "safe" because they are entered by the admin
 		$installation_settings['institution_form'] = $institutionForm;
 		$installation_settings['institution_url_form'] = $institutionUrlForm;
@@ -208,11 +208,11 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 		$installation_settings['allow_self_registration'] = $allowSelfReg;
 		$installation_settings['allow_teacher_self_registration'] = $allowSelfRegProf;
 		$installation_settings['admin_phone_form'] = $adminPhoneForm;
-		
+
 		//put the settings into the settings table (taken from CSV file)
 		$current_settings_table = "`$dbNameForm`.`settings_current`";
 		fill_current_settings_table($current_settings_table, $installation_settings);
-		
+
 		//put the options into the options table (taken from CSV file)
 		$settings_options_table = "`$dbNameForm`.`settings_options`";
 		fill_settings_options_table($settings_options_table);
@@ -275,7 +275,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 				//update group_category.forum_state
 				//update group_info.tutor_id (put it in group_tutor table?)
 				//update group_info.forum_state, forum_id
-				
+
 				//update forum tables (migrate from bb_ tables to forum_ tables)
 				//migrate categories
 				$sql_orig = "SELECT * FROM bb_categories";
@@ -423,16 +423,16 @@ else
 
 
 /**
-* This function stores the forum category in the database. The new category is added to the end. 
+* This function stores the forum category in the database. The new category is added to the end.
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
 */
 function store_forumcategory($values)
 {
-	global $table_categories; 
+	global $table_categories;
 	global $_course;
-	global $_user; 
-	
+	global $_user;
+
 	// find the max cat_order. The new forum category is added at the end => max cat_order + &
 	$sql="SELECT MAX(cat_order) as sort_max FROM ".mysql_real_escape_string($table_categories);
 	$result=api_sql_query($sql);
@@ -440,22 +440,22 @@ function store_forumcategory($values)
 	$new_max=$row['sort_max']+1;
 
 	$sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".mysql_real_escape_string($values['forum_category_title'])."','".mysql_real_escape_string($values['forum_category_comment'])."','".mysql_real_escape_string($new_max)."')";
-	api_sql_query($sql); 
+	api_sql_query($sql);
 	$last_id=mysql_insert_id();
 	api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_user['user_id']);
 	return array('id'=>$last_id,'title'=>$values['forum_category_title']) ;
 }
 
 /**
-* This function stores the forum in the database. The new forum is added to the end. 
+* This function stores the forum in the database. The new forum is added to the end.
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
 */
 function store_forum($values)
 {
-	global $table_forums; 
+	global $table_forums;
 	global $_course;
-	global $_user; 
+	global $_user;
 
 	// find the max forum_order for the given category. The new forum is added at the end => max cat_order + &
 	$sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".mysql_real_escape_string($values['forum_category']);
@@ -463,9 +463,9 @@ function store_forum($values)
 	$row=mysql_fetch_array($result);
 	$new_max=$row['sort_max']+1;
 
-	
-	$sql="INSERT INTO ".$table_forums." 
-				(forum_title, forum_comment, forum_category, allow_anonymous, allow_edit, approval_direct_post, allow_attachments, allow_new_threads, default_view, forum_of_group, forum_group_public_private, forum_order) 
+
+	$sql="INSERT INTO ".$table_forums."
+				(forum_title, forum_comment, forum_category, allow_anonymous, allow_edit, approval_direct_post, allow_attachments, allow_new_threads, default_view, forum_of_group, forum_group_public_private, forum_order)
 				VALUES ('".mysql_real_escape_string($values['forum_title'])."',
 					'".mysql_real_escape_string($values['forum_comment'])."',
 					'".mysql_real_escape_string($values['forum_category'])."',
@@ -473,46 +473,46 @@ function store_forum($values)
 					'".mysql_real_escape_string($values['students_can_edit_group']['students_can_edit'])."',
 					'".mysql_real_escape_string($values['approval_direct_group']['approval_direct'])."',
 					'".mysql_real_escape_string($values['allow_attachments_group']['allow_attachments'])."',
-					'".mysql_real_escape_string($values['allow_new_threads_group']['allow_new_threads'])."', 
-					'".mysql_real_escape_string($values['default_view_type_group']['default_view_type'])."', 
-					'".mysql_real_escape_string($values['group_forum'])."', 
-					'".mysql_real_escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."', 
+					'".mysql_real_escape_string($values['allow_new_threads_group']['allow_new_threads'])."',
+					'".mysql_real_escape_string($values['default_view_type_group']['default_view_type'])."',
+					'".mysql_real_escape_string($values['group_forum'])."',
+					'".mysql_real_escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."',
 					'".mysql_real_escape_string($new_max)."')";
-	api_sql_query($sql, __LINE__,__FILE__); 
+	api_sql_query($sql, __LINE__,__FILE__);
 	$last_id=mysql_insert_id();
 	api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_user['user_id']);
 	return array('id'=>$last_id, 'title'=>$values['forum_title']);
 }
 
 /**
-* This function stores a new thread. This is done through an entry in the forum_thread table AND 
+* This function stores a new thread. This is done through an entry in the forum_thread table AND
 * in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet))
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
 */
 function store_thread($values)
 {
-	global $table_threads; 
-	global $table_posts; 
-	global $_user; 
-	global $_course; 
-	global $current_forum; 
-	
+	global $table_threads;
+	global $table_posts;
+	global $_user;
+	global $_course;
+	global $current_forum;
+
 	// We first store an entry in the forum_thread table because the thread_id is used in the forum_post table
-	$sql="INSERT INTO $table_threads (thread_title, forum_id, thread_poster_id, thread_poster_name, thread_views, thread_date, thread_sticky) 
+	$sql="INSERT INTO $table_threads (thread_title, forum_id, thread_poster_id, thread_poster_name, thread_views, thread_date, thread_sticky)
 			VALUES ('".mysql_real_escape_string($values['post_title'])."',
 					'".mysql_real_escape_string($values['forum_id'])."',
-					'".mysql_real_escape_string($values['user_id'])."', 
-					'".mysql_real_escape_string($values['poster_name'])."', 
-					'".mysql_real_escape_string($values['topic_views'])."', 
+					'".mysql_real_escape_string($values['user_id'])."',
+					'".mysql_real_escape_string($values['poster_name'])."',
+					'".mysql_real_escape_string($values['topic_views'])."',
 					'".mysql_real_escape_string($values['post_date'])."',
 					'".mysql_real_escape_string($values['thread_sticky'])."')";
 	$result=api_sql_query($sql, __LINE__, __FILE__);
 	$last_thread_id=mysql_insert_id();
 	api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_user['user_id']);
 	// if the forum properties tell that the posts have to be approved we have to put the whole thread invisible
-	// because otherwise the students will see the thread and not the post in the thread. 
-	// we also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have 
+	// because otherwise the students will see the thread and not the post in the thread.
+	// we also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have
 	// to make the thread visible AND the post
 	if ($values['visible']==0)
 	{
@@ -520,7 +520,7 @@ function store_thread($values)
 		$visible=1;
 	}
 
-	return $last_thread_id; 
+	return $last_thread_id;
 }
 
 /**
@@ -532,21 +532,21 @@ function store_thread($values)
 */
 function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id)
 {
-	global $phpbb_threads; 
-	global $table_forums; 
-	
+	global $phpbb_threads;
+	global $table_forums;
+
 	$table_users = Database :: get_main_table(TABLE_MAIN_USER);
-	
-	$sql_phpbb_threads="SELECT forum.*, users.user_id 
-							FROM $phpbb_threads forum, $table_users users 
-							WHERE forum_id='".mysql_real_escape_string($phpbb_forum_id)."' 
+
+	$sql_phpbb_threads="SELECT forum.*, users.user_id
+							FROM $phpbb_threads forum, $table_users users
+							WHERE forum_id='".mysql_real_escape_string($phpbb_forum_id)."'
 							AND forum.nom=users.lastname AND forum.prenom=users.firstname
 							";
 	$result_phpbb_threads=api_sql_query($sql_phpbb_threads);
 	$threads_counter=0;
 	while ($row_phpbb_threads=mysql_fetch_array($result_phpbb_threads))
 	{
-		$values['post_title']=$row_phpbb_threads['topic_title']; 
+		$values['post_title']=$row_phpbb_threads['topic_title'];
 		$values['forum_id']=$new_forum_id;
 		$values['user_id']=$row_phpbb_threads['user_id'];
 		$values['poster_name']=0;
@@ -556,19 +556,19 @@ function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id)
 		$values['visible']=$row_phpbb_threads['visible'];
 		//my_print_r($values);
 		$new_forum_thread_id=store_thread($values);
-		
+
 		// now we migrate the posts of the given thread
 		$posts_counter=$posts_counter+migrate_posts_of_thread($row_phpbb_threads['topic_id'], $new_forum_thread_id, $new_forum_id);
-		
+
 		$threads_counter++;
 	}
-	
+
 	// Now we update the forum_forum table with the total number of posts for the given forum.
-	$sql="UPDATE $table_forums 
+	$sql="UPDATE $table_forums
 			SET forum_posts='".mysql_real_escape_string($posts_counter)."',
-			forum_threads='".mysql_real_escape_string($threads_counter)."' 
+			forum_threads='".mysql_real_escape_string($threads_counter)."'
 			WHERE forum_id='".mysql_real_escape_string($new_forum_id)."'";
-	//echo $sql; 
+	//echo $sql;
 	$result=api_sql_query($sql);
 	return array("threads"=>$threads_counter, "posts"=>$posts_counter);
 }
@@ -583,20 +583,20 @@ function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id)
 function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_forum_id)
 {
 	global $phpbb_posts;
-	global $phpbb_poststext; 
-	global $table_posts; 
-	global $table_threads; 
-	global $added_resources; 
-	
+	global $phpbb_poststext;
+	global $table_posts;
+	global $table_threads;
+	global $added_resources;
+
 	$table_users = Database :: get_main_table(TABLE_MAIN_USER);
 	$table_added_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
-	
-	
+
+
 	$post_counter=0;
-	
-	$sql_phpbb_posts="SELECT posts.*, posts_text.*, users.user_id, users.lastname, users.firstname FROM $phpbb_posts posts, $phpbb_poststext posts_text, $table_users users 
+
+	$sql_phpbb_posts="SELECT posts.*, posts_text.*, users.user_id, users.lastname, users.firstname FROM $phpbb_posts posts, $phpbb_poststext posts_text, $table_users users
 						WHERE posts.post_id=posts_text.post_id
-						AND posts.nom=users.lastname 
+						AND posts.nom=users.lastname
 						AND posts.prenom=users.firstname
 						AND posts.topic_id='".mysql_real_escape_string($phpbb_thread_id)."'
 						";
@@ -607,15 +607,15 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo
 		$values['post_title']=$row_phpbb_posts['post_title'];
 		$values['post_text']=$row_phpbb_posts['post_text'];
 		$values['thread_id']=$new_forum_thread_id;
-		$values['forum_id']=$new_forum_id; 
-		$values['user_id']=$row_phpbb_posts['user_id']; 
+		$values['forum_id']=$new_forum_id;
+		$values['user_id']=$row_phpbb_posts['user_id'];
 		$values['post_date']=$row_phpbb_posts['post_time'];
 		$values['post_notification']=$row_phpbb_posts['topic_notify'];
-		$values['post_parent_id']=0; 
-		$values['visible']=1;		
-	
+		$values['post_parent_id']=0;
+		$values['visible']=1;
+
 		// We first store an entry in the forum_post table
-		$sql="INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id,  post_date, post_notification, post_parent_id, visible) 
+		$sql="INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id,  post_date, post_notification, post_parent_id, visible)
 				VALUES ('".mysql_real_escape_string($values['post_title'])."',
 						'".mysql_real_escape_string($values['post_text'])."',
 						'".mysql_real_escape_string($values['thread_id'])."',
@@ -628,12 +628,12 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo
 		$result=api_sql_query($sql, __LINE__, __FILE__);
 		$post_counter++;
 		$last_post_id=mysql_insert_id();
-		
-		
+
+
 		// We check if there added resources and if so we update them
 		if (in_array($row_phpbb_posts['post_id'],$added_resources))
 		{
-			$sql_update_added_resource="UPDATE $table_added_resources 
+			$sql_update_added_resource="UPDATE $table_added_resources
 					SET source_type='forum_post', source_id='".mysql_real_escape_string($last_post_id)."'
 					WHERE source_type='".mysql_real_escape_string(TOOL_BB_POST)."' AND source_id='".mysql_real_escape_string($row_phpbb_posts['post_id'])."'";
 			echo $sql_update_added_resource;
@@ -642,15 +642,15 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo
 
 
 	}
-	
-	// update the thread_last_post of the post table AND the 
-	$sql="UPDATE $table_threads SET thread_last_post='".mysql_real_escape_string($last_post_id)."', 
+
+	// update the thread_last_post of the post table AND the
+	$sql="UPDATE $table_threads SET thread_last_post='".mysql_real_escape_string($last_post_id)."',
 			thread_replies='".mysql_real_escape_string($post_counter-1)."'
 			WHERE thread_id='".mysql_real_escape_string($new_forum_thread_id)."'";
-	//echo $sql; 
+	//echo $sql;
 	$result=api_sql_query($sql, __LINE__, __FILE__);
-	//echo $sql; 
-	return $post_counter; 
+	//echo $sql;
+	return $post_counter;
 }
 
 /**
@@ -663,7 +663,7 @@ function get_added_resources()
 	$table_added_resources = Database::get_course_table(TABLE_LINKED_RESOURCES);
 	$return_array=array();
 
-	// TODO: now we also migrate the added resources. 
+	// TODO: now we also migrate the added resources.
 	$sql_added_resources="SELECT * FROM $table_added_resources WHERE source_type='".mysql_real_escape_string(TOOL_BB_POST)."'";
 	$result=api_sql_query($sql_added_resources);
 	while ($row=mysql_fetch_array($result))
@@ -674,16 +674,16 @@ function get_added_resources()
 }
 
 /**
-* This function gets the forum category information based on the name 
+* This function gets the forum category information based on the name
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here.
 */
 function get_forumcategory_id_by_name($forum_category_name)
 {
 	global $table_categories;
-	
+
 	$sql="SELECT cat_id FROM $table_categories WHERE cat_title='".mysql_real_escape_string($forum_category_name)."'";
-	//echo $sql; 
+	//echo $sql;
 	$result=api_sql_query($sql,__LINE__,__FILE__);
 	$row=mysql_fetch_array($result);
 	//echo $row['cat_id'];

+ 1 - 1
main/install/update_files.inc.php

@@ -177,7 +177,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
 			fputs($fp, '<?php
 															$cidReq = "'.$key.'";
 															$dbname = "'.str_replace($dbPrefixForm, '', $mysql_base_course).'";
-									
+
 															include("../../main/course_home/course_home.php");
 															?>');
 

+ 18 - 18
main/install/upgrade.php

@@ -3,10 +3,10 @@
 /**
 ==============================================================================
 * In this file we're working on a well-organised upgrade script to
-* upgrade directly from Dokeos 1.6.x to Dokeos 1.8.3 
+* upgrade directly from Dokeos 1.6.x to Dokeos 1.8.3
 *
 * For this upgrade we assume there is an old_dokeos directory and the new
-* software is in a new_dokeos directory. While we're busy developing we 
+* software is in a new_dokeos directory. While we're busy developing we
 * work in this one  - large - separate file so not to disturb the other
 * existing classes - the existing code remains working.
 *
@@ -35,12 +35,12 @@
 * The function get_installed_version($old_installation_path, $parameter)
 * can be used to detect version numbers.
 */
-	
+
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 session_start();
 
 ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.'../inc/lib/pear');
@@ -85,7 +85,7 @@ $update_from_18_version = array('1.8.0','1.8.1','1.8.2');
 ==============================================================================
 		CLASSES
 ==============================================================================
-*/ 
+*/
 
 /**
  * Page in the install wizard to select the language which will be used during
@@ -314,7 +314,7 @@ class Page_DatabaseSettings extends HTML_QuickForm_Page
 		//$this->addRule('database_personal_messenger', 'ThisFieldIsRequired', 'required');
 		//$this->addElement('text', 'database_profiler', get_lang("ProfilerDatabase"), array ('size' => '40'));
 		//$this->addRule('database_profiler', 'ThisFieldIsRequired', 'required');
-		
+
 		$enable_tracking[] = & $this->createElement('radio', 'enable_tracking', null, get_lang("Yes"), 1);
 		$enable_tracking[] = & $this->createElement('radio', 'enable_tracking', null, get_lang("No"), 0);
 		$this->addGroup($enable_tracking, 'tracking', get_lang("EnableTracking"), '&nbsp;', false);
@@ -543,21 +543,21 @@ class ActionProcess extends HTML_QuickForm_Action
 			<img src="../img/bluelogo.gif" alt="logo" align="right"/>
 		<?php
 		echo '<pre>';
-		
+
 		global $repository_database;
 		global $weblcms_database;
 		global $personal_calendar_database;
 		global $user_database;
 		global $personal_messenger_database;
 		global $profiler_database;
-		
+
 		$repository_database = $values['database_repository'];
 		$weblcms_database = $values['database_weblcms'];
 		$personal_calendar_database = $values['database_personal_calendar'];
 		$user_database = $values['database_user'];
 		$personal_messenger_database = $values['database_personal_messenger'];
 		$profiler_database = $values['database_profiler'];
-		
+
 		/*full_database_install($values);
 		full_file_install($values);
 		create_admin_in_user_table($values);
@@ -582,7 +582,7 @@ class ActionProcess extends HTML_QuickForm_Action
 ==============================================================================
 		FUNCTIONS
 ==============================================================================
-*/ 
+*/
 
 function display_upgrade_header($text_dir, $dokeos_version, $install_type, $update_from_version)
 {
@@ -603,7 +603,7 @@ function display_upgrade_header($text_dir, $dokeos_version, $install_type, $upda
 	<?php } ?>
 	</head>
 	<body dir="<?php echo $text_dir ?>">
-	
+
 	<div id="header">
 		<div id="header1"><?php echo get_lang('DokeosInstallation').' &mdash; '.get_lang('Version_').' '.$dokeos_version; ?><?php if($install_type == 'new') echo ' &ndash; '.get_lang('NewInstallation'); else if($install_type == 'update') echo ' &ndash; '.get_lang('UpdateFromDokeosVersion').implode('|',$update_from_version); ?></div>
 		<div class="clear"></div>
@@ -679,13 +679,13 @@ function check_update_path($path)
 	{
 		//search for 1.6.x installation
 		$version = get_installed_version($path, 'platformVersion');
-		
+
 		//search for 1.8.x installation
 		//if (! isset($version) || $version == '')
 		//{
 		//   $version = get_installed_version($path, 'dokeos_version');
 		//}
-		
+
 		if (in_array($version, $update_from_version))
 		{
 			return true;
@@ -723,9 +723,9 @@ function get_installed_version($old_installation_path, $parameter)
  *
  * IMPORTANT
  * - Before Dokeos 1.8 the main code folder was called 'claroline'. Since Dokeos 1.8
- * this folder is called 'main' -> we have to make a difference based on previous 
+ * this folder is called 'main' -> we have to make a difference based on previous
  * version.
- * - The version may be in the config file or in the installedVersion file... 
+ * - The version may be in the config file or in the installedVersion file...
  *
  * WARNING - this function relies heavily on global variables $updateFromConfigFile
  * and $configFile, and also changes these globals. This can be rewritten.
@@ -825,12 +825,12 @@ function get_config_param($param,$path)
 		return $val;
 	}
 }
-	
+
 /*
 ==============================================================================
 		MAIN CODE
 ==============================================================================
-*/ 
+*/
 global $current_active_step;
 $current_active_step = '1';
 $install_type = 'update';
@@ -880,7 +880,7 @@ if( isset($values['old_version_path']) && $values['old_version_path'] != '/var/w
 		$defaults['encrypt_password'] = 'md5';
 	} elseif (get_config_param('userPasswordCrypted',$path)==0){
 		$defaults['encrypt_password'] = 'none';
-	}	
+	}
 	//$defaults['encrypt_password'] = get_config_param('userPasswordCrypted',$path);
 	$defaults['self_reg'] = get_config_param('allowSelfReg',$path);
 }

+ 9 - 9
main/install/upgrade_lib.php

@@ -2,19 +2,19 @@
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2007, various contributors
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
@@ -56,7 +56,7 @@ function upgrade_16x_to_180($values)
 		UPGRADES TO GENERAL DATABASES before course upgrades
 	*/
 
-	//MAIN database section	
+	//MAIN database section
 	//Get the list of queries to upgrade the main database
 	$main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','main');
 	if(count($main_query_list) > 0)
@@ -68,7 +68,7 @@ function upgrade_16x_to_180($values)
 		}
 	}
 
-	//TRACKING database section	
+	//TRACKING database section
 	//Get the list of queries to upgrade the statistics/tracking database
 	$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','stats');
 	if(count($tracking_query_list) > 0)
@@ -80,7 +80,7 @@ function upgrade_16x_to_180($values)
 		}
 	}
 
-	//USER database section	
+	//USER database section
 	//Get the list of queries to upgrade the user database
 	$user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','user');
 	if(count($user_query_list) > 0)
@@ -150,7 +150,7 @@ function upgrade_16x_to_180($values)
 		}
 	}
 
-	$prefix = ''; 
+	$prefix = '';
 	if ($singleDbForm)
 	{
 		$prefix = $_configuration['table_prefix'];

+ 68 - 68
main/link/link.php

@@ -60,29 +60,29 @@ $(document).ready( function() {
 	for (i=0;i<$(".actions").length;i++) {
 		if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
 			$(".actions:eq("+i+")").hide();
-		}		
+		}
 	}
-	
+
 	$("#div_target").attr("style","display:none;")//hide
-	
-	$("#id_check_target").click(function () { 
+
+	$("#id_check_target").click(function () {
       if($(this).attr("checked")==true) {
       	$("#div_target").attr("style","display:block;")//show
       } else {
      	 $("#div_target").attr("style","display:none;")//hide
       }
     });
-	
-    $(window).load(function () { 
+
+    $(window).load(function () {
       if($("#id_check_target").attr("checked")==true) {
       	$("#div_target").attr("style","display:block;")//show
       } else {
      	 $("#div_target").attr("style","display:none;")//hide
       }
     });
-	
-	
- } ); 
+
+
+ } );
 
  </script>';
 
@@ -113,7 +113,7 @@ if (isset($_GET['action']) && $_GET['action']=='addlink') {
 	$nameTools = '';
 	$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
 	$interbreadcrumb[] = array ('url' => 'link.php?action=addlink', 'name' => get_lang('AddLink'));
-}	
+}
 
 if (isset($_GET['action']) && $_GET['action']=='addcategory') {
 	$nameTools = '';
@@ -125,9 +125,9 @@ if (isset($_GET['action']) && $_GET['action']=='editlink') {
 	$nameTools = '';
 	$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
 	$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditLink'));
-}	 	
-	
-				
+}
+
+
 // Database Table definitions
 $tbl_link = Database::get_course_table(TABLE_LINK);
 $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
@@ -158,7 +158,7 @@ $nameTools = get_lang("Links");
 
 if(isset($_GET['action'])) {
 	switch($_GET['action']) {
-		case "addlink":		
+		case "addlink":
 			if($link_submitted)
 			{
 				if(!addlinkcategory("link"))	// here we add a link
@@ -167,7 +167,7 @@ if(isset($_GET['action'])) {
 				}
 			}
 			break;
-		case "addcategory":		
+		case "addcategory":
 			if($category_submitted)
 			{
 				if(!addlinkcategory("category"))	// here we add a category
@@ -175,7 +175,7 @@ if(isset($_GET['action'])) {
 					unset($submitCategory);
 				}
 			}
-			break;		
+			break;
 		case "importcsv":
 			if($_POST["submitImport"])
 			{
@@ -185,7 +185,7 @@ if(isset($_GET['action'])) {
 		case "deletelink":
 			deletelinkcategory("link"); // here we delete a link
 			break;
-			
+
 		case "deletecategory":
 			deletelinkcategory("category"); // here we delete a category
 			break;
@@ -212,7 +212,7 @@ if(isset($_GET['action'])) {
 Display::display_introduction_section(TOOL_LINK);
 
 
-if (is_allowed_to_edit() and isset($_GET['action'])) {	
+if (is_allowed_to_edit() and isset($_GET['action'])) {
 	echo '<div class="actions">';
 	echo '<a href="link.php?cidReq='.Security::remove_XSS($_GET['cidReq']).'&amp;urlview='.Security::remove_XSS($_GET['urlview']).'">'.Display::return_icon('back.png',get_lang('BackToLinksOverview')).get_lang('BackToLinksOverview').'</a>';
 	echo '</div>';
@@ -220,7 +220,7 @@ if(api_get_setting('search_enabled')=='true') {
 	if (!extension_loaded('xapian')) {
 		Display::display_error_message(get_lang('SearchXapianModuleNotInstaled'));
 	}
-}	
+}
 	// Displaying the correct title and the form for adding a category or link. This is only shown when nothing
 	// has been submitted yet, hence !isset($submitLink)
 	if (($_GET['action']=="addlink" or $_GET['action']=="editlink") and empty($_POST['submitLink'])) {
@@ -247,7 +247,7 @@ if(api_get_setting('search_enabled')=='true') {
 						<input type="text" name="urllink" size="50" value="' . (empty($urllink)?'http://':api_htmlentities($urllink, ENT_COMPAT, $charset)) . '" />
 					</div>
 				</div>';
-		
+
 		echo '	<div class="row">
 					<div class="label">
 						'.get_lang('LinkName').'
@@ -278,7 +278,7 @@ if(api_get_setting('search_enabled')=='true') {
 						<div class="formw">';
 			echo '			<select name="selectcategory">';
 			echo '			<option value="0">--</option>';
-			while ($myrow = Database::fetch_array($resultcategories)) 
+			while ($myrow = Database::fetch_array($resultcategories))
 			{
 				echo "		<option value=\"".$myrow["id"]."\"";
 				if ($myrow["id"]==$category)
@@ -287,8 +287,8 @@ if(api_get_setting('search_enabled')=='true') {
 			}
 			echo '			</select>';
 			echo '		</div>
-					</div>';			
-			
+					</div>';
+
 		}
 
 		echo '	<div class="row">
@@ -298,7 +298,7 @@ if(api_get_setting('search_enabled')=='true') {
 					<div class="formw">
 						<input id="id_check_target" class="checkbox" type="checkbox" name="onhomepage" id="onhomepage" value="1"'.$onhomepage.'><label for="onhomepage"> '.get_lang('Yes').'</label>
 					</div>
-				</div>';		
+				</div>';
 		echo '	<div class="row" id="div_target">
 					<div class="label">
 						'.get_lang('AddTargetOfLinkOnHomepage').'
@@ -324,8 +324,8 @@ if(api_get_setting('search_enabled')=='true') {
 						</div>
 						<div class="formw">
 							<input class="checkbox" type="checkbox" name="index_document" id="index_document" checked="checked"><label for="index_document"> '.get_lang('Yes').'</label>
-						</div>';			
-			
+						</div>';
+
 			foreach ($specific_fields as $specific_field) {
 				//Author : <input name="A" type="text" />
 
@@ -343,26 +343,26 @@ if(api_get_setting('search_enabled')=='true') {
 					}
 				}
 
-				$sf_textbox = '	
+				$sf_textbox = '
 						<div class="row">
 							<div class="label">%s</div>
 							<div class="formw">
 								<input name="%s" type="text" value="%s"/>
 							</div>
-						</div>';				
-				
+						</div>';
+
 				echo sprintf($sf_textbox, $specific_field['name'], $specific_field['code'], $default_values);
 			}
-		}	
-		
+		}
+
 		echo '	<div class="row">
 					<div class="label">
 					</div>
 					<div class="formw">
 						<button class="save" type="Submit" name="submitLink" value="OK">'.get_lang('SaveLink').'</button>
 					</div>
-				</div>';	
-	
+				</div>';
+
 		echo '</form>';
 	} elseif(($_GET['action']=="addcategory" or $_GET['action']=="editcategory") and !$submitCategory) {
 		echo '<div class="row">';
@@ -379,7 +379,7 @@ if(api_get_setting('search_enabled')=='true') {
 		{
 			echo "<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
 		}
-		
+
 		echo '	<div class="row">
 					<div class="label">
 						<span class="form_required">*</span> '.get_lang('CategoryName').'
@@ -388,7 +388,7 @@ if(api_get_setting('search_enabled')=='true') {
 						<input type="text" name="category_title" size="50" value="'.api_htmlentities($category_title,ENT_QUOTES,$charset).'" />
 					</div>
 				</div>';
-		
+
 		echo '	<div class="row">
 					<div class="label">
 						'.get_lang('Description').'
@@ -397,15 +397,15 @@ if(api_get_setting('search_enabled')=='true') {
 						<textarea rows="3" cols="50" name="description">'.api_htmlentities($description,ENT_QUOTES,$charset).'</textarea>
 					</div>
 				</div>';
-		
+
 		echo '	<div class="row">
 					<div class="label">
 					</div>
 					<div class="formw">
 						<button class="save" type="submit" name="submitCategory">'.$my_cat_title.' </button>
 					</div>
-				</div>';		
-		
+				</div>';
+
 		echo "</form>";
 	}
 	/*elseif(($_GET['action']=="importcsv") and !$submitImport)  // RH start
@@ -428,7 +428,7 @@ if (!empty($up)) {
 	movecatlink($up);
 }
 
-if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['action']!='addlink') || $link_submitted || $category_submitted) {	
+if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='addcategory' && $_GET['action']!='addlink') || $link_submitted || $category_submitted) {
 	/*
 	-----------------------------------------------------------
 		Action Links
@@ -467,18 +467,18 @@ if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='
 	//Starting the table which contains the categories
 	$sqlcategories="SELECT * FROM ".$tbl_categories." ORDER BY display_order DESC";
 	$resultcategories=api_sql_query($sqlcategories);
-		
+
 	echo '<table class="data_table">';
 	// displaying the links which have no category (thus category = 0 or NULL), if none present this will not be displayed
 	$sqlLinks = "SELECT * FROM ".$tbl_link." WHERE category_id=0 or category_id IS NULL";
 	$result = api_sql_query($sqlLinks);
-	$numberofzerocategory=Database::num_rows($result);		
+	$numberofzerocategory=Database::num_rows($result);
 	if ($numberofzerocategory!==0) {
 		echo "<tr><th style=\"font-weight: bold; text-align:left;padding-left: 10px;\"><i>".get_lang('General')."</i></th></tr>";
-		echo '</table>';	
-		showlinksofcategory(0);		
+		echo '</table>';
+		showlinksofcategory(0);
 	}
-		
+
 	$i=0;
 	$catcounter=1;
 	$view="0";
@@ -499,61 +499,61 @@ if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='
 		// if the $urlview has a 1 for this categorie, this means it is expanded and should be desplayed as a
 		// - instead of a +, the category is no longer clickable and all the links of this category are displayed
 		$myrow["description"]=text_filter($myrow["description"]);
-		
+
 		if ($urlview[$i]=="1")
 		{
 			$newurlview=$urlview;
 			$newurlview[$i]="0";
-			
+
 			echo '<tr>';
 				echo '<table class="data_table">';
-				echo '<tr>';			
+				echo '<tr>';
 					echo '<th width="81%"  style="font-weight: bold; text-align:left;padding-left: 5px;">';
 					echo '<a href="'.api_get_self()."?".api_get_cidreq()."&urlview=".Security::remove_XSS($newurlview)."\">";
 					echo "<img src=../img/remove.gif>&nbsp;&nbsp;".api_htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."</a><br/>&nbsp;&nbsp;&nbsp;".$myrow["description"];
-					
+
 					if (is_allowed_to_edit())
-						{	
-							echo '<th>';	
+						{
+							echo '<th>';
 							showcategoryadmintools($myrow["id"]);
-							echo '</th>';			
+							echo '</th>';
 						}
-					echo '</th>';						
+					echo '</th>';
 				echo '</tr>';
-				echo '</table>';		
-				echo showlinksofcategory($myrow["id"]);						
-			echo '</tr>';			
+				echo '</table>';
+				echo showlinksofcategory($myrow["id"]);
+			echo '</tr>';
 		}
 		else
-		{		
+		{
 			echo '<tr>';
 				echo '<table class="data_table">';
-				echo '<tr>';			
+				echo '<tr>';
 					echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;"><a href="'.api_get_self()."?".api_get_cidreq()."&urlview=";
 					echo is_array($view)?implode('',$view):$view;
 					echo "\"><img src=../img/add.gif>&nbsp;&nbsp;".  api_htmlentities($myrow["category_title"],ENT_QUOTES,$charset);
 					echo'</a><br />&nbsp;&nbsp;&nbsp;';
-					echo $myrow["description"];						
+					echo $myrow["description"];
 						if (is_allowed_to_edit())
-						{		
-							echo '<th style="text-align:center;">';	
-							showcategoryadmintools($myrow["id"]);			
+						{
+							echo '<th style="text-align:center;">';
+							showcategoryadmintools($myrow["id"]);
 							echo '</th>';
 						}
-					echo '</th>';			
+					echo '</th>';
 				echo '</tr>';
-				
-				
-				echo '</table>';						
-			echo '</tr>';				
+
+
+				echo '</table>';
+			echo '</tr>';
 		}
 		// displaying the link of the category
 		$i++;
 	}
 	echo '</table>';
 	////////////////////////////////////////////////////////////////////////////
-}		
-		
+}
+
 
 
 Display::display_footer();

+ 15 - 15
main/link/link_goto.php

@@ -1,27 +1,27 @@
-<?php // $Id: link_goto.php 22201 2009-07-17 19:57:03Z cfasanando $ 
+<?php // $Id: link_goto.php 22201 2009-07-17 19:57:03Z cfasanando $
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004-2005 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 * This page is used to launch an event when a user clicks
 * on a page linked in a course.
 * - It gets name of URL
@@ -30,18 +30,18 @@
 *                                                               |
 * Need the liens.id, user.user_id et cours.code when called
 * ?link_id=$myrow[0]&link_url=$myrow[1]                           |
-* url is given to avoid a new select          
+* url is given to avoid a new select
 *
 * @author Thomas Depraetere, Hugues Peeters, Christophe Gesch� - original versions
 * @package dokeos.link
-============================================================================== 
+==============================================================================
 */
-	
+
 /*
-============================================================================== 
+==============================================================================
 		INIT SECTION
-============================================================================== 
-*/ 
+==============================================================================
+*/
 
 include('../inc/global.inc.php');
 $this_section=SECTION_COURSES;

+ 17 - 17
main/link/linkfunctions.php

@@ -254,7 +254,7 @@ function deletelinkcategory($type)
 		// make a restore function possible for the platform administrator
 		if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) {
 			$sql="UPDATE $tbl_link SET on_homepage='0' WHERE id='".Database::escape_string($_GET['id'])."'";
-			Database::query($sql,__FILE__,__LINE__);			
+			Database::query($sql,__FILE__,__LINE__);
 		}
 
 		api_item_property_update($_course, TOOL_LINK, $id, "delete", $_user['user_id']);
@@ -393,7 +393,7 @@ function editlinkcategory($type)
                 $link_title = $_POST['title'];
                 $link_description = $_POST['description'];
 
-                // actually, it consists on delete terms from db, insert new ones, create a new search engine document, and remove the old one 
+                // actually, it consists on delete terms from db, insert new ones, create a new search engine document, and remove the old one
 	            // get search_did
 	            $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
 	            $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
@@ -559,14 +559,14 @@ function showlinksofcategory($catid)
 	$sqlLinks = "SELECT * FROM ".$tbl_link." link, ".$TABLE_ITEM_PROPERTY." itemproperties WHERE itemproperties.tool='".TOOL_LINK."' AND link.id=itemproperties.ref AND  link.category_id='".$catid."' AND (itemproperties.visibility='0' OR itemproperties.visibility='1')ORDER BY link.display_order DESC";
 	$result = api_sql_query($sqlLinks);
 	$numberoflinks = Database::num_rows($result);
-	
+
 	echo '<table class="data_table" width="100%">';
 	$i = 1;
 	while ($myrow = Database::fetch_array($result))
 	{
 		if($i%2==0) $css_class = 'row_odd';
 		else $css_class = 'row_even';
-		
+
 		$myrow[3] = text_filter($myrow[3]);
 		if ($myrow['visibility'] == '1')
 		{
@@ -579,22 +579,22 @@ function showlinksofcategory($catid)
 				echo "<tr class='".$css_class."'>", "<td align=\"center\" valign=\"middle\" width=\"15\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\" class=\"invisible\">", Display::return_icon('file_html_na.gif', get_lang('Link')),"</a></td>", "<td width=\"80%\" valign=\"top\">", "<a href=\"link_goto.php?".api_get_cidreq()."&link_id=", $myrow[0], "&amp;link_url=", urlencode($myrow[1]), "\" target=\"_blank\"  class=\"invisible\">", api_htmlentities($myrow[2],ENT_QUOTES,$charset), "</a>\n", "<br />", $myrow[3], "";
 			}
 		}
-		
+
 		echo '<td style="text-align:center;">';
 		if (api_is_allowed_to_edit())
 		{
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editlink&amp;category=".(!empty($category)?$category:'')."&amp;id=".$myrow[0]." &amp;urlview=$urlview \"  title=\"".get_lang('Modify')."\"  >", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\" />", "</a>";			
+			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=editlink&amp;category=".(!empty($category)?$category:'')."&amp;id=".$myrow[0]." &amp;urlview=$urlview \"  title=\"".get_lang('Modify')."\"  >", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"", get_lang('Modify'), "\" />", "</a>";
 			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=deletelink&amp;id=", $myrow[0], "&amp;urlview=", $urlview, "\" onclick=\"javascript:if(!confirm('".get_lang('LinkDelconfirm')."')) return false;\"  title=\"".get_lang('Delete')."\" >", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"", get_lang('Delete'), "\" />", "</a>";
 			// DISPLAY MOVE UP COMMAND only if it is not the top link
 			if ($i != 1)
 			{
 				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&urlview=".$urlview."&amp;up=", $myrow["id"], "\"  title=\"".get_lang('Up')."\"   >", "<img src=../img/up.gif border=0 alt=\"".get_lang('Up')."\"/>", "</a>\n";
 			}
-			else 
+			else
 			{
 				echo '<img src="'.api_get_path(WEB_IMG_PATH).'up_na.gif" border=0 alt="'.get_lang('Up').'"/>';
-			}	
-			
+			}
+
 			// DISPLAY MOVE DOWN COMMAND only if it is not the bottom link
 			if ($i < $numberoflinks)
 			{
@@ -602,18 +602,18 @@ function showlinksofcategory($catid)
 			}
 			else
 			{
-				echo '<img src="'.api_get_path(WEB_IMG_PATH).'down_na.gif" border=0 alt="'.get_lang('Down').'"/>';	
+				echo '<img src="'.api_get_path(WEB_IMG_PATH).'down_na.gif" border=0 alt="'.get_lang('Down').'"/>';
 			}
-			
+
 			if ($myrow['visibility'] == "1")
 			{
-				echo '<a href="link.php?'.api_get_cidreq().'&action=invisible&amp;id='.$myrow['id'].'&amp;scope=link&amp;urlview='.$urlview.'" title="'.get_lang('Hide').'"><img src="../img/visible.gif" border="0" /></a>'; 
+				echo '<a href="link.php?'.api_get_cidreq().'&action=invisible&amp;id='.$myrow['id'].'&amp;scope=link&amp;urlview='.$urlview.'" title="'.get_lang('Hide').'"><img src="../img/visible.gif" border="0" /></a>';
 			}
 			if ($myrow['visibility'] == "0")
 			{
  				echo '<a href="link.php?'.api_get_cidreq().'&action=visible&amp;id='.$myrow['id'].'&amp;scope=link&amp;urlview='.$urlview.'" title="'.get_lang('Show').'"><img src="../img/invisible.gif" border="0" /></a>';
 			}
-		} 
+		}
 		echo '</td>';
 		echo '</tr>';
 		$i ++;
@@ -633,15 +633,15 @@ function showcategoryadmintools($categoryid)
 	echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=editcategory&amp;id='.$categoryid.'&amp;urlview='.$urlview.'"  title='.get_lang('Modify').' "><img src="../img/edit.gif" border="0" alt="'.get_lang('Modify').' "/></a>';
 	echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=deletecategory&amp;id=", $categoryid, "&amp;urlview=$urlview\" onclick=\"javascript:if(!confirm('".get_lang('CategoryDelconfirm')."')) return false;\">", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"", get_lang('Delete'), "\"/>", "</a>";
 
-	// DISPLAY MOVE UP COMMAND only if it is not the top link	
+	// DISPLAY MOVE UP COMMAND only if it is not the top link
 	if ($catcounter != 1)
 	{
 		echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&catmove=true&amp;up=", $categoryid, "&amp;urlview=$urlview\"  title=\"".get_lang('Up')."\" >", "<img src=../img/up.gif border=0 alt=\"".get_lang('Up')."\"/>", "</a>\n";
 	}
 	else
 	{
-		echo '<img src="'.api_get_path(WEB_IMG_PATH).'up_na.gif" border=0 alt="'.get_lang('Up').'"/>';	
-	}	
+		echo '<img src="'.api_get_path(WEB_IMG_PATH).'up_na.gif" border=0 alt="'.get_lang('Up').'"/>';
+	}
 	// DISPLAY MOVE DOWN COMMAND only if it is not the bottom link
 	if ($catcounter < $aantalcategories)
 	{
@@ -650,7 +650,7 @@ function showcategoryadmintools($categoryid)
 	else
 	{
 		echo '<img src="'.api_get_path(WEB_IMG_PATH).'down_na.gif" border=0 alt="'.get_lang('Down').'"/>';
-	}		
+	}
 	$catcounter ++;
 }
 

+ 26 - 26
main/messages/inbox.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -6,8 +6,8 @@
 	Copyright (c) 2009 Dokeos SPRL
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)	
-	Copyright (c) 2009 Isaac Flores Paz <isaac.flores@dokeos.com>	
+	Copyright (c) Evie, Free University of Brussels (Belgium)
+	Copyright (c) 2009 Isaac Flores Paz <isaac.flores@dokeos.com>
 
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
@@ -27,8 +27,8 @@
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
-// name of the language file that needs to be included 
+*/
+// name of the language file that needs to be included
 $language_file = array('registration','messages','userInfo','admin','index');
 $cidReset=true;
 require_once '../inc/global.inc.php';
@@ -37,7 +37,7 @@ require_once api_get_path(LIBRARY_PATH).'message.lib.php';
 api_block_anonymous_users();
 if (isset($_GET['messages_page_nr'])) {
 	if (api_get_setting('allow_social_tool')=='true' &&  api_get_setting('allow_message_tool')=='true') {
-		header('Location:../social/index.php?pager="'.Security::remove_XSS($_GET['messages_page_nr']).'"&remote=2#remote-tab-2');	
+		header('Location:../social/index.php?pager="'.Security::remove_XSS($_GET['messages_page_nr']).'"&remote=2#remote-tab-2');
 	}
 }
 if (api_get_setting('allow_message_tool')!='true'){
@@ -45,26 +45,26 @@ if (api_get_setting('allow_message_tool')!='true'){
 }
 $htmlHeadXtra[]='<script language="javascript">
 <!--
-function enviar(miforma) 
-{ 
+function enviar(miforma)
+{
 	if(confirm("'.get_lang("SureYouWantToDeleteSelectedMessages").'"))
 		miforma.submit();
-} 
+}
 function select_all(formita)
-{ 
-   for (i=0;i<formita.elements.length;i++) 
+{
+   for (i=0;i<formita.elements.length;i++)
 	{
-      		if(formita.elements[i].type == "checkbox") 			
-				formita.elements[i].checked=1			
+      		if(formita.elements[i].type == "checkbox")
+				formita.elements[i].checked=1
 	}
 }
 function deselect_all(formita)
-{ 
-   for (i=0;i<formita.elements.length;i++) 
+{
+   for (i=0;i<formita.elements.length;i++)
 	{
-      		if(formita.elements[i].type == "checkbox") 			
-				formita.elements[i].checked=0			
-	}	
+      		if(formita.elements[i].type == "checkbox")
+				formita.elements[i].checked=0
+	}
 }
 //-->
 </script>';
@@ -85,13 +85,13 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
 		//allow to insert messages
 		$info_reply=explode(base64_encode('&%ff..x'),$_GET['form_reply']);
 		$count_reply=count($info_reply);
-		$button_sent=urldecode($info_reply[4]);	
+		$button_sent=urldecode($info_reply[4]);
 	}
 	/***********************************************/
 	if ( isset($_GET['form_delete']) ) {
 		//allow to delete messages
 		$info_delete=explode(',',$_GET['form_delete']);
-		$count_delete=(count($info_delete)-1);	
+		$count_delete=(count($info_delete)-1);
 	}
 	/***********************************************/
 
@@ -107,7 +107,7 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
 		if (count($user_email_prepare)==1) {
 			$user_email=trim($user_email_prepare[0]);
 		} elseif (count($user_email_prepare)==3) {
-			$user_email=trim($user_email_prepare[1]);	
+			$user_email=trim($user_email_prepare[1]);
 		}
 		$user_id_by_email=MessageManager::get_user_id_by_email($user_email);
 
@@ -127,7 +127,7 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
 		}
 	} elseif (trim($info_delete[0])=='delete' ) {
 		for ($i=1;$i<=$count_delete;$i++) {
-			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]);	
+			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]);
 		}
 			$message_box=get_lang('SelectedMessagesDeleted');
 			Display::display_normal_message(api_xml_http_response_encode($message_box),false);
@@ -150,7 +150,7 @@ if ($request===false) {
 		'name' => get_lang('Inbox')
 	);
 	Display::display_header('');
-	$link_ref="new_message.php";	
+	$link_ref="new_message.php";
 } else {
 	$link_ref="../messages/new_message.php?rs=1";
 }
@@ -168,7 +168,7 @@ if (!isset($_GET['del_msg'])) {
 	for ($i=0;$i<$num_msg;$i++) {
 		if($_POST[$i]) {
 			//the user_id was necesarry to delete a message??
-			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]);			
+			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]);
 		}
 	}
 	inbox_display();
@@ -176,9 +176,9 @@ if (!isset($_GET['del_msg'])) {
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 if ($request===false) {
 	Display::display_footer();
 }

+ 2 - 2
main/messages/index.php

@@ -6,7 +6,7 @@
 	Copyright (c) 2009 Dokeos SPRL
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)		
+	Copyright (c) Evie, Free University of Brussels (Belgium)
 
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
@@ -31,7 +31,7 @@ if (api_get_setting('allow_message_tool')!='true'){
 	api_not_allowed();
 }
 
-if(api_get_user_id()!=0) {	
+if(api_get_user_id()!=0) {
 	echo '<script language="javascript" type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'messages/cookies.js"> </script> ';
 	echo '<script language="javascript" type="text/javascript">set_url("'.api_get_path(WEB_CODE_PATH).'messages/notify.php") ; notificar()</script> ';
 	$number_of_new_messages = get_new_messages();

+ 78 - 78
main/messages/message.class.php

@@ -18,16 +18,16 @@
 
 	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
-	
+
 ==============================================================================
 */
 require_once api_get_path(LIBRARY_PATH).'/main_api.lib.php';
 require_once api_get_path(LIBRARY_PATH).'/online.inc.php';
 
-class MessageManager 
-{	
+class MessageManager
+{
 	function MessageManager() {
-		
+
 	}
 	public static function get_online_user_list($current_user_id) {
 		$min=30;
@@ -39,14 +39,14 @@ class MessageManager
 		}
 		return $online_user_list;
 	}
-	
+
 	/**
 	* Displays info stating that the message is sent successfully.
 	*/
 	public static function display_success_message($uid) {
 			global $charset;
 		if ($_SESSION['social_exist']===true) {
-			$redirect="#remote-tab-2";	
+			$redirect="#remote-tab-2";
 			if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
 				$success=get_lang('MessageSentTo').
 				"&nbsp;<b>".
@@ -56,8 +56,8 @@ class MessageManager
 				$success=get_lang('MessageSentTo').
 				"&nbsp;<b>".
 				GetFullUserName($uid).
-				"</b>";			
-			}				
+				"</b>";
+			}
 		} else {
 				$success=get_lang('MessageSentTo').
 				"&nbsp;<b>".
@@ -66,29 +66,29 @@ class MessageManager
 		}
 		Display::display_confirmation_message(api_xml_http_response_encode($success), false);
 	}
-	
+
 	/**
 	* Displays the wysiwyg html editor.
 	*/
 	public static function display_html_editor_area($name, $resp) {
 		api_disp_html_area($name, get_lang('TypeYourMessage'), '', '', null, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250'));
 	}
-	
+
 	/**
 	* Get the new messages for the current user from the database.
 	*/
 	public static function get_new_messages() {
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		if (!api_get_user_id()) {
 			return false;
 		}
-		$i=0;		
+		$i=0;
 		$query = "SELECT * FROM $table_message WHERE user_receiver_id=".api_get_user_id()." AND msg_status=1";
 		$result = api_sql_query($query,__FILE__,__LINE__);
 		$i = Database::num_rows($result);
 		return $i;
 	}
-	
+
 	/**
 	* Get the list of user_ids of users who are online.
 	*/
@@ -101,18 +101,18 @@ class MessageManager
 		}
 		return $user_id_list;
 	}
-	
+
 	/**
 	 * Gets the total number of messages, used for the inbox sortable table
 	 */
 	public static function get_number_of_messages () {
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE msg_status IN (0,1) AND user_receiver_id=".api_get_user_id();
 		$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
 		$result = Database::fetch_array($sql_result);
 		return $result['number_messages'];
 	}
-	
+
 	/**
 	 * Gets information about some messages, used for the inbox sortable table
 	 * @param int $from
@@ -125,9 +125,9 @@ class MessageManager
 		$number_of_items = intval($number_of_items);
 		$column = intval($column);
 		if (!in_array($direction, array('ASC', 'DESC')))
-			$direction = 'ASC'; 
-			 
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+			$direction = 'ASC';
+
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$request=api_is_xml_http_request();
 		$sql_query = "SELECT id as col0, user_sender_id as col1, title as col2, send_date as col3, msg_status as col4 FROM $table_message " .
 					 "WHERE user_receiver_id=".api_get_user_id()." AND msg_status IN (0,1)" .
@@ -137,21 +137,21 @@ class MessageManager
 		$message_list = array ();
 		while ($result = Database::fetch_row($sql_result)) {
 			if ($request===true) {
-				$message[0] = '<input type="checkbox" value='.$result[0].' name="id[]">';		
+				$message[0] = '<input type="checkbox" value='.$result[0].' name="id[]">';
 			 } else {
-				$message[0] = ($result[0]);	 	
+				$message[0] = ($result[0]);
 			 }
-			 
+
 			if ($request===true) {
 				if($result[4]==0)
-            	{ 
+            	{
 					$message[1] = Display::return_icon('mail_open.png',get_lang('AlreadyReadMessage'));//Message already read
 				}
 				else
 				{
-					$message[1] = Display::return_icon('mail.png',get_lang('UnReadMessage'));//Message without reading 
+					$message[1] = Display::return_icon('mail.png',get_lang('UnReadMessage'));//Message without reading
 				}
-						
+
 				$message[2] = '<a onclick="get_action_url_and_show_messages(1,'.$result[0].')" href="javascript:void(0)">'.GetFullUserName($result[1]).'</a>';
 				$message[3] = '<a onclick="get_action_url_and_show_messages(1,'.$result[0].')" href="javascript:void(0)">'.str_replace("\\","",$result[2]).'</a>';
 				$message[5] = '<a onclick="reply_to_messages(\'show\','.$result[0].',\'\')" href="javascript:void(0)">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
@@ -160,19 +160,19 @@ class MessageManager
 				$message[2] = '<a href="view_message.php?id='.$result[0].'">'.GetFullUserName(($result[1])).'</a>';;
 				$message[3] = '<a href="view_message.php?id='.$result[0].'">'.$result[2].'</a>';
 				$message[5] = '<a href="new_message.php?re_id='.$result[0].'">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
-						  '&nbsp;&nbsp;<a delete_one_message('.$result[0].') href="#inbox.php?action=deleteone&id='.$result[0].'">'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).'</a>';	
+						  '&nbsp;&nbsp;<a delete_one_message('.$result[0].') href="#inbox.php?action=deleteone&id='.$result[0].'">'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).'</a>';
 			}
 			$message[4] = ($result[3]); //date stays the same
 			foreach($message as $key => $value) {
 				$message[$key] = api_xml_http_response_encode($value);
 			}
 			$message_list[] = $message;
-			
+
 			$i++;
 		}
 		return $message_list;
 	}
-	
+
 	 public static function send_message ($receiver_user_id, $title, $content) {
         global $charset;
         if (is_numeric($receiver_user_id)) {
@@ -183,7 +183,7 @@ class MessageManager
 			$sql = "SELECT COUNT(*) as count FROM $table_message WHERE user_sender_id = ".api_get_user_id()." AND user_receiver_id='".Database::escape_string($receiver_user_id)."' AND title = '".Database::escape_string($title)."' AND content ='".Database::escape_string($content)."' ";
 			$res_exist = api_sql_query($sql,__FILE__,__LINE__);
 			$row_exist = Database::fetch_array($res_exist,'ASSOC');
-			if ($row_exist['count'] ==0) {  
+			if ($row_exist['count'] ==0) {
 				$query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content ) ".
 						 " VALUES (".
 				 		 "'".api_get_user_id()."', '".Database::escape_string($receiver_user_id)."', '1', '".date('Y-m-d H:i:s')."','".Database::escape_string($title)."','".Database::escape_string($content)."'".
@@ -200,12 +200,12 @@ class MessageManager
         } else {
         	return false;
         }
-        
+
 		return false;
 	}
-	
-	 public static function delete_message_by_user_receiver ($user_receiver_id,$id) {	
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+
+	 public static function delete_message_by_user_receiver ($user_receiver_id,$id) {
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$id = Database::escape_string($id);
 		$sql="SELECT COUNT(*) as count FROM $table_message WHERE id=".$id." AND msg_status<>4;";
 		$rs=api_sql_query($sql,__FILE__,__LINE__);
@@ -214,33 +214,33 @@ class MessageManager
 			$query = "DELETE FROM $table_message " .
 			"WHERE user_receiver_id=".Database::escape_string($user_receiver_id)." AND id=".$id;
 			$result = api_sql_query($query,__FILE__,__LINE__);
-			return $result;	
+			return $result;
 		} else {
 			return false;
 		}
 	}
 	/**
-	 * Set status deleted 
+	 * Set status deleted
 	 * @author Isaac FLores Paz <isaac.flores@dokeos.com>
 	 * @param  integer
 	 * @param  integer
 	 * @return array
 	 */
 	public static function delete_message_by_user_sender ($user_sender_id,$id) {
-		$table_message = Database::get_main_table(TABLE_MESSAGE);		
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$query = "DELETE FROM $table_message " .
-				 "WHERE user_sender_id=".Database::escape_string($user_sender_id)." AND id=".Database::escape_string($id);		
+				 "WHERE user_sender_id=".Database::escape_string($user_sender_id)." AND id=".Database::escape_string($id);
 		$result = api_sql_query($query,__FILE__,__LINE__);
-		return $result;		
+		return $result;
 	}
 	public static function update_message ($user_id, $id) {
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$query = "UPDATE $table_message SET msg_status = '0' WHERE msg_status<>4 AND user_receiver_id=".Database::escape_string($user_id)." AND id='".Database::escape_string($id)."'";
-		$result = api_sql_query($query,__FILE__,__LINE__);	
+		$result = api_sql_query($query,__FILE__,__LINE__);
 	}
-	
+
 	 public static function get_message_by_user ($user_id,$id) {
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$query = "SELECT * FROM $table_message WHERE user_receiver_id=".Database::escape_string($user_id)." AND id='".Database::escape_string($id)."'";
 		$result = api_sql_query($query,__FILE__,__LINE__);
 		return $row = Database::fetch_array($result);
@@ -253,18 +253,18 @@ class MessageManager
 	 * @return boolean
 	 */
 	 public static function exist_message ($user_id, $id) {
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$query = "SELECT id FROM $table_message WHERE user_receiver_id=".Database::escape_string($user_id)." AND id='".Database::escape_string($id)."'";
 		$result = api_sql_query($query,__FILE__,__LINE__);
 		$num = Database::num_rows($result);
 		if ($num>0)
 			return true;
 		else
-			return false;	
+			return false;
 	}
 	/**
 	 * Gets information about messages sent
-	 * @author Isaac FLores Paz <isaac.flores@dokeos.com> 
+	 * @author Isaac FLores Paz <isaac.flores@dokeos.com>
 	 * @param  integer
 	 * @param  integer
 	 * @param  string
@@ -272,29 +272,29 @@ class MessageManager
 	 */
 	 public static function get_message_data_sent ($from, $number_of_items, $column, $direction) {
 	 	global $charset;
-	 	
+
 	 	$from = intval($from);
 		$number_of_items = intval($number_of_items);
 		$column = intval($column);
 		if (!in_array($direction, array('ASC', 'DESC')))
-			$direction = 'ASC'; 
-			
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+			$direction = 'ASC';
+
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$request=api_is_xml_http_request();
 		$sql_query = "SELECT id as col0, user_sender_id as col1, title as col2, send_date as col3, user_receiver_id as col4, msg_status as col5 FROM $table_message " .
 					 "WHERE user_sender_id=".api_get_user_id()." AND msg_status=4 " .
 					 "ORDER BY col$column $direction LIMIT $from,$number_of_items";
-		
+
 		$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
 		$i = 0;
 		$message_list = array ();
 		while ($result = Database::fetch_row($sql_result)) {
 			if ($request===true) {
-				$message[0] = '<input type="checkbox" value='.$result[0].' name="out[]">';		
+				$message[0] = '<input type="checkbox" value='.$result[0].' name="out[]">';
 			 } else {
-				$message[0] = ($result[0]);	 	
+				$message[0] = ($result[0]);
 			 }
-			 
+
 			if ($request===true) {
 			   if ($result[5]==4)
 			   {
@@ -325,7 +325,7 @@ class MessageManager
 	 * @return integer
 	 */
 	 public static function get_number_of_messages_sent () {
-		$table_message = Database::get_main_table(TABLE_MESSAGE); 
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		$sql_query = "SELECT COUNT(*) as number_messages FROM $table_message WHERE msg_status=4 AND user_sender_id=".api_get_user_id();
 		$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
 		$result = Database::fetch_array($sql_result);
@@ -334,7 +334,7 @@ class MessageManager
 	public static function show_message_box () {
 		global $charset;
 		$table_message = Database::get_main_table(TABLE_MESSAGE);
-		if (isset($_GET['id_send']) && is_numeric($_GET['id_send'])) {			
+		if (isset($_GET['id_send']) && is_numeric($_GET['id_send'])) {
 			$query = "SELECT * FROM $table_message WHERE user_sender_id=".api_get_user_id()." AND id=".Database::escape_string($_GET['id_send'])." AND msg_status=4;";
 			$result = api_sql_query($query,__FILE__,__LINE__);
 		    $path='outbox.php';
@@ -353,7 +353,7 @@ class MessageManager
 		$reply='';
 		for ($i=0;$i<count($user_con);$i++)
 			if ($row[1]==$user_con[$i])
-				$band=1;	
+				$band=1;
 		if ($band==1 && !isset($_GET['id_send'])) {
 			if (is_numeric($_GET['id'])) {
 				$reply = '<a onclick="reply_to_messages(\'show\','.Security::remove_XSS($_GET['id']).',\'\')" href="javascript:void(0)">'.Display::return_icon('message_reply.png',api_xml_http_response_encode(get_lang('ReplyToMessage'))).api_xml_http_response_encode(get_lang('ReplyToMessage')).'</a>';
@@ -361,7 +361,7 @@ class MessageManager
 		}
 		echo '<div class=actions>';
 		echo '<a onclick="close_div_show(\'div_content_messages\')" href="javascript:void(0)">'.Display::return_icon('folder_up.gif',api_xml_http_response_encode(get_lang('BackToInbox'))).api_xml_http_response_encode(get_lang('BackToInbox')).'</a>';
-		echo $reply; 
+		echo $reply;
 		echo '<a onclick="delete_one_message('.$row[0].')" href="javascript:void(0)"  >'.Display::return_icon('message_delete.png',api_xml_http_response_encode(get_lang('DeleteMessage'))).''.api_xml_http_response_encode(get_lang('DeleteMessage')).'</a>';
 		echo '</div><br />';
 		echo '
@@ -369,19 +369,19 @@ class MessageManager
 		    <TR>
 		      <TD width=10>&nbsp; </TD>
 		      <TD vAlign=top width="100%">
-		      	<TABLE>      
+		      	<TABLE>
 		            <TR>
-		              <TD width="100%">                              
+		              <TD width="100%">
 		                    <TR> <h1>'.str_replace("\\","",api_xml_http_response_encode($row[5])).'</h1></TR>
-		              </TD>              		
-		              <TR>                       
+		              </TD>
+		              <TR>
 		              	<TD>'.api_xml_http_response_encode(get_lang('From').'&nbsp;<b>'.GetFullUserName($row[1]).'</b> '.api_strtolower(get_lang('To')).'&nbsp;  <b>'.GetFullUserName($row[2])).'</b> </TD>
-		              </TR>                    
+		              </TR>
 		              <TR>
-		              <TD >'.api_xml_http_response_encode(get_lang('Date').'&nbsp; '.$row[4]).'</TD>                      
-		              </TR>              
-		            </TR>          
-		        </TABLE>	      		
+		              <TD >'.api_xml_http_response_encode(get_lang('Date').'&nbsp; '.$row[4]).'</TD>
+		              </TR>
+		            </TR>
+		        </TABLE>
 		        <br />
 		        <TABLE height=209 width="100%" bgColor=#ffffff>
 		          <TBODY>
@@ -399,18 +399,18 @@ class MessageManager
 		global $charset;
 		$table_message = Database::get_main_table(TABLE_MESSAGE);
 		if (is_numeric($_GET['id_send'])) {
-			$query = "SELECT * FROM $table_message WHERE user_sender_id=".api_get_user_id()." AND id=".Database::escape_string($_GET['id_send'])." AND msg_status=4;";		
+			$query = "SELECT * FROM $table_message WHERE user_sender_id=".api_get_user_id()." AND id=".Database::escape_string($_GET['id_send'])." AND msg_status=4;";
 			$result = api_sql_query($query,__FILE__,__LINE__);
 		}
 		$path='outbox.php';
-		
+
 		$row = Database::fetch_array($result);
 		$user_con = self::users_connected_by_id();
 		$band=0;
 		$reply='';
 		for ($i=0;$i<count($user_con);$i++)
 			if ($row[1]==$user_con[$i])
-				$band=1;	
+				$band=1;
 		echo '<div class=actions>';
 		echo '<a onclick="close_and_open_outbox()" href="javascript:void(0)">'.Display::return_icon('folder_up.gif',api_xml_http_response_encode(get_lang('BackToOutbox'))).api_xml_http_response_encode(get_lang('BackToOutbox')).'</a>';
 		echo '<a onclick="delete_one_message_outbox('.$row[0].')" href="javascript:void(0)"  >'.Display::return_icon('message_delete.png',api_xml_http_response_encode(get_lang('DeleteMessage'))).api_xml_http_response_encode(get_lang('DeleteMessage')).'</a>';
@@ -420,19 +420,19 @@ class MessageManager
 		    <TR>
 		      <TD width=10>&nbsp; </TD>
 		      <TD vAlign=top width="100%">
-		      	<TABLE>      
+		      	<TABLE>
 		            <TR>
-		              <TD width="100%">                              
+		              <TD width="100%">
 		                    <TR> <h1>'.str_replace("\\","",api_xml_http_response_encode($row[5])).'</h1></TR>
-		              </TD>              		
-		              <TR>                       
+		              </TD>
+		              <TR>
 		              	<TD>'.api_xml_http_response_encode(get_lang('From').'&nbsp;<b>'.GetFullUserName($row[1]).'</b> '.api_strtolower(get_lang('To')).'&nbsp;  <b>'.GetFullUserName($row[2])).'</b> </TD>
-		              </TR>                    
+		              </TR>
 		              <TR>
-		              <TD >'.api_xml_http_response_encode(get_lang('Date').'&nbsp; '.$row[4]).'</TD>                      
-		              </TR>              
-		            </TR>          
-		        </TABLE>	      		
+		              <TD >'.api_xml_http_response_encode(get_lang('Date').'&nbsp; '.$row[4]).'</TD>
+		              </TR>
+		            </TR>
+		        </TABLE>
 		        <br />
 		        <TABLE height=209 width="100%" bgColor=#ffffff>
 		          <TBODY>

+ 10 - 10
main/messages/new_message.php

@@ -6,7 +6,7 @@
 	Copyright (c) 2009 Dokeos SPRL
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)		
+	Copyright (c) Evie, Free University of Brussels (Belgium)
 	Copyright (c) 2009 Isaac Flores Paz <isaac.flores.paz@gmail.com>
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
@@ -74,7 +74,7 @@ function validate(form,list)
 $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready(function (){
-	cont=0;	
+	cont=0;
       $("#id_text_name").bind("keyup", function(){
       	name=$("#id_text_name").get(0).value;
 		$.ajax({
@@ -96,9 +96,9 @@ $(document).ready(function (){
 				 });
 				}
 		});
-      });  
+      });
 });
-	</script>';	
+	</script>';
 
 $nameTools = api_xml_http_response_encode(get_lang('ComposeMessage'));
 
@@ -214,7 +214,7 @@ if (isset($_GET['rs'])) {
 	);
 
 if ($request===false) {
-	Display::display_header('');	
+	Display::display_header('');
 }
 
 //api_display_tool_title($nameTools);
@@ -234,22 +234,22 @@ if (!isset($_POST['compose'])) {
 } else {
 	$restrict=isset($_POST['id_text_name']) ? $_POST['id_text_name'] : false;
 	if ($restrict===false && isset($_GET['re_id'])) {
-		
+
 	}
 	if (isset($_GET['re_id'])) {
 		$default['title'] = api_xml_http_response_encode($_POST['title']);
 		$default['content'] = api_xml_http_response_encode($_POST['content']);
 		//$default['user_list'] = $_POST['user_list'];
-		manage_form($default);	
+		manage_form($default);
 	} else {
 		if ($restrict) {
 			$default['title'] = api_xml_http_response_encode($_POST['title']);
-			$default['id_text_name'] = api_xml_http_response_encode($_POST['id_text_name']); 
+			$default['id_text_name'] = api_xml_http_response_encode($_POST['id_text_name']);
 			$default['user_list'] = $_POST['user_list'];
 			manage_form($default);
 		} else {
-			Display::display_error_message(api_xml_http_response_encode(get_lang('ErrorSendingMessage')));		
-		}	
+			Display::display_error_message(api_xml_http_response_encode(get_lang('ErrorSendingMessage')));
+		}
 	}
 }
 /*

+ 1 - 1
main/messages/notify.php

@@ -6,7 +6,7 @@
 	Copyright (c) 2009 Dokeos SPRL
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)		
+	Copyright (c) Evie, Free University of Brussels (Belgium)
 
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".

+ 27 - 27
main/messages/outbox.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -7,7 +7,7 @@
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) 2009 Isaac Flores Paz <florespaz@bidsoftperu.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)		
+	Copyright (c) Evie, Free University of Brussels (Belgium)
 
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
@@ -27,8 +27,8 @@
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
-// name of the language file that needs to be included 
+*/
+// name of the language file that needs to be included
 $language_file = array('registration','messages','userInfo','admin');
 $cidReset=true;
 require_once '../inc/global.inc.php';
@@ -37,7 +37,7 @@ require_once api_get_path(LIBRARY_PATH).'message.lib.php';
 api_block_anonymous_users();
 if (isset($_GET['messages_page_nr'])) {
 	if (api_get_setting('allow_social_tool')=='true' &&  api_get_setting('allow_message_tool')=='true') {
-		header('Location:../social/index.php?pager="'.Security::remove_XSS($_GET['messages_page_nr']).'"&remote=3#remote-tab-3');	
+		header('Location:../social/index.php?pager="'.Security::remove_XSS($_GET['messages_page_nr']).'"&remote=3#remote-tab-3');
 	}
 }
 if (api_get_setting('allow_message_tool')!='true'){
@@ -45,26 +45,26 @@ if (api_get_setting('allow_message_tool')!='true'){
 }
 $htmlHeadXtra[]='<script language="javascript">
 <!--
-function enviar(miforma) 
-{ 
+function enviar(miforma)
+{
 	if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
 		miforma.submit();
-} 
+}
 function select_all(formita)
-{ 
-   for (i=0;i<formita.elements.length;i++) 
+{
+   for (i=0;i<formita.elements.length;i++)
 	{
-      		if(formita.elements[i].type == "checkbox") 			
-				formita.elements[i].checked=1			
+      		if(formita.elements[i].type == "checkbox")
+				formita.elements[i].checked=1
 	}
 }
 function deselect_all(formita)
-{ 
-   for (i=0;i<formita.elements.length;i++) 
+{
+   for (i=0;i<formita.elements.length;i++)
 	{
-      		if(formita.elements[i].type == "checkbox") 			
-				formita.elements[i].checked=0			
-	}	
+      		if(formita.elements[i].type == "checkbox")
+				formita.elements[i].checked=0
+	}
 }
 //-->
 </script>';
@@ -100,7 +100,7 @@ $count_delete_outbox=(count($info_delete_outbox)-1);
 /**************************************************************/
 if( trim($info_delete_outbox[0])=='delete' ) {
 	for ($i=1;$i<=$count_delete_outbox;$i++) {
-		MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);	
+		MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
 	}
 		$message_box=get_lang('SelectedMessagesDeleted').
 			'&nbsp
@@ -108,7 +108,7 @@ if( trim($info_delete_outbox[0])=='delete' ) {
 			get_lang('BackToOutbox').
 			'</a>';
 		Display::display_normal_message(api_xml_http_response_encode($message_box),false);
-	    exit;	
+	    exit;
 }
 /**************************************************************/
 $table_message = Database::get_main_table(TABLE_MESSAGE);
@@ -119,28 +119,28 @@ $user_sender_id=api_get_user_id();
 if ($_REQUEST['action']=='delete') {
 	$delete_list_id=array();
 	if (isset($_POST['out'])) {
-		$delete_list_id=$_POST['out'];	
+		$delete_list_id=$_POST['out'];
 	}
 	if (isset($_POST['id'])) {
-		$delete_list_id=$_POST['id'];			
+		$delete_list_id=$_POST['id'];
 	}
 	for ($i=0;$i<count($delete_list_id);$i++) {
-		MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);		
+		MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
 	}
 	$delete_list_id=array();
-	outbox_display();		
+	outbox_display();
 } elseif ($_REQUEST['action']=='deleteone') {
 	$delete_list_id=array();
 	$id=Security::remove_XSS($_GET['id']);
 	MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
-	$delete_list_id=array();		
-	outbox_display();	
+	$delete_list_id=array();
+	outbox_display();
 }else {
-	outbox_display();	
+	outbox_display();
 }
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
 */
 if ($request===false) {

+ 2 - 2
main/messages/plugin.php

@@ -2,11 +2,11 @@
 /**
  * This script is a configuration file for the messages plugin. You can use it as a master for other plugins.
  * These settings will be used in the administration interface for plugins (Dokeos configuration settings->Plugins)
- * @package dokeos.plugin 
+ * @package dokeos.plugin
  * @author Evie, Free University of Brussels
  */
 /**
- * Plugin details (must be present) 
+ * Plugin details (must be present)
  */
 //the plugin title
 $plugin_info['title']='Messages';

+ 5 - 5
main/messages/send_message.php

@@ -6,8 +6,8 @@
 	Copyright (c) 2009 Dokeos SPRL
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)	
-	Copyright (c) 2009 Isaac Flores Paz <isaac.flores@dokeos.com>	
+	Copyright (c) Evie, Free University of Brussels (Belgium)
+	Copyright (c) 2009 Isaac Flores Paz <isaac.flores@dokeos.com>
 
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
@@ -48,7 +48,7 @@ if ($panel_id==2) {
     <td height="20"><?php echo api_xml_http_response_encode(get_lang('WriteAMessage'));  ?> :<br/><textarea id="txt_area_invite" rows="3" cols="25"></textarea></td>
     <td height="20"><input type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendInviteMessage')); ?>" onclick="action_database_panel('4','<?php echo $user_id;?>')" /></td>
 <?php
-} 
+}
 if ($panel_id==1) {
 ?>
     <td height="20"><?php echo api_xml_http_response_encode(get_lang('To')); ?> &nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?></td>
@@ -56,7 +56,7 @@ if ($panel_id==1) {
     <td height="20"><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br/><textarea id="txt_area_invite" rows="3" cols="25"></textarea></td>
     <td height="20"><input type="button" value="<?php echo api_xml_http_response_encode(get_lang('NewMessage')); ?>" onclick="hide_display_message()" />&nbsp;&nbsp;&nbsp; <input type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $user_id;?>')" /></td>
 <?php
-} 
+}
 if ($panel_id==3) {
 ?>
 <dl>
@@ -73,6 +73,6 @@ if ($panel_id==4) {
 	}
 	UserFriend::send_invitation_friend_user($user_id,$subject_message,$content_message);
 } elseif ($panel_id==5) {
-	UserFriend::send_invitation_friend_user($user_id,$subject_message,$content_message);	
+	UserFriend::send_invitation_friend_user($user_id,$subject_message,$content_message);
 }
 ?>

+ 8 - 8
main/messages/send_message_to_userfriend.inc.php

@@ -29,10 +29,10 @@ if ( isset($_REQUEST['user_friend']) ) {
 ?>
 <table width="600" border="0" height="220">
     <tr height="180">
-        <td>    
+        <td>
         <div class="message-content-body-left">
 			<img class="message-image-info" src="<?php echo $info_path_friend['dir'].$info_path_friend['file']; ?>"/>
-			<?php 
+			<?php
 			if ($panel != 1) {
 				echo '<br /><center>'.api_xml_http_response_encode(api_get_person_name($info_user_friend['firstName'], $info_user_friend['lastName'])).'</center>';
 			}
@@ -41,7 +41,7 @@ if ( isset($_REQUEST['user_friend']) ) {
 <div class="message-content-body-right">
 <div id="id_content_panel_init">
 			<dl>
-<?php 
+<?php
 		if (api_get_setting('allow_message_tool')=='true') {
 			if ($panel == 1) {
                 //normal message
@@ -50,19 +50,19 @@ if ( isset($_REQUEST['user_friend']) ) {
 		  		 <br />
 		 		 <br /><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br /><input id="txt_subject_id" type="text" style="width:300px;"><br/>
 		   		 <br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br /><textarea id="txt_area_invite" rows="4" cols="41"></textarea>
-		   		 <br /><br />		    	  
+		   		 <br /><br />
 		   		 <button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $userfriend_id;?>')"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
 <?php
 			} else {
                 // friend invitation message
 				echo api_xml_http_response_encode(get_lang('AddPersonalMessage'));  ?> :<br /><br />
 				<textarea id="txt_area_invite" rows="5" cols="41"></textarea><br /><br />
- 				<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $userfriend_id;?>')" ><?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')) ?></button>	   
-<?php					
+ 				<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $userfriend_id;?>')" ><?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')) ?></button>
+<?php
 				}
-			}            
+			}
 ?>
-			</dl>			
+			</dl>
 </div>
         </td>
     </tr>

+ 3 - 3
main/messages/view_message.php

@@ -6,7 +6,7 @@
 	Copyright (c) 2009 Dokeos SPRL
 	Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
 	Copyright (c) Facultad de Matematicas, UADY (México)
-	Copyright (c) Evie, Free University of Brussels (Belgium)	
+	Copyright (c) Evie, Free University of Brussels (Belgium)
 	Copyright (c) 2009 Isaac Flores Paz <isaac.flores.paz@gmail.com>
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
@@ -47,7 +47,7 @@ if (isset($_GET['id_send']) || isset($_GET['id'])) {
 		$interbreadcrumb[]= array (
 				'url' => '../social/'.$_SESSION['social_dest'].'?#remote-tab-2',
 				'name' => get_lang('SocialNetwork')
-		);	
+		);
 		$interbreadcrumb[]= array (
 			'url' => 'inbox.php',
 			'name' => get_lang('Inbox')
@@ -69,7 +69,7 @@ if (isset($_GET['id_send']) || isset($_GET['id'])) {
 		'url' => 'outbox.php',
 		'name' => get_lang('Outbox')
 	);
-	}	
+	}
 }
 /*
 ==============================================================================

+ 4 - 4
main/messaging/email_editor.php

@@ -23,10 +23,10 @@
  * Dokeos' users.
  * It can be called from the JavaScript library email_links.lib.php which
  * overtakes the mailto: links to use the internal interface instead.
- * @author	Yannick Warnier <ywarnier@beeznest.org> 
+ * @author	Yannick Warnier <ywarnier@beeznest.org>
  */
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "index";
 
 require_once"../inc/global.inc.php";
@@ -50,10 +50,10 @@ if(!empty($_POST['submit_email']) && !empty($_POST['email_title']) && !empty($_P
 	$email_administrator=Security::remove_XSS($_POST['dest']);
 	$user_id=api_get_user_id();
 	$title=Security::remove_XSS($_POST['email_title']);
-	$content=Security::remove_XSS($_POST['email_text']);	
+	$content=Security::remove_XSS($_POST['email_text']);
 	if(!empty($_user['mail'])){
 		api_send_mail($email_administrator,$title,$text,"From: ".$_user['mail']."\r\n");
-		UserManager::send_message_in_outbox ($email_administrator,$user_id,$title, $content);		
+		UserManager::send_message_in_outbox ($email_administrator,$user_id,$title, $content);
 	}else{
 		api_send_mail($email_administrator,$title,$text);
 	}

+ 1 - 1
main/metadata/doc/dcex.php

@@ -9,7 +9,7 @@ $mdObj = new mdobject($_course, $docId);  // e.g. '12'
 
 // Fetch example:
 if (is_array($dcelems = $mdStore->mds_get_dc_elements($mdObj)))
-	echo '<div>', htmlspecialchars($dcelems['Identifier']), ': ', 
+	echo '<div>', htmlspecialchars($dcelems['Identifier']), ': ',
 	    htmlspecialchars($dcelems['Description']), '</div>';
 
 // Store example:

+ 18 - 18
main/metadata/doc/mdApiTest.php

@@ -6,7 +6,7 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: MD API test and demo
 *
 *   The API allows other Dokeos scripts to define & manipulate metadata
@@ -14,7 +14,7 @@
 *   In this example, MD is defined for 'Document.1001', 1002, 1003
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 require("../md_funcs.php");
@@ -22,9 +22,9 @@ require("../md_funcs.php");
 define('EID_TYPE', 'Document');
 require('../md_' . strtolower(EID_TYPE) . '.php');
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 /*
-$language_file = 'Whatever'; 
+$language_file = 'Whatever';
 */
 require("../../inc/global.inc.php");
 
@@ -52,13 +52,13 @@ foreach(array(1001, 1002, 1003) as $eid_id)
 {
     $mdObj = new mdobject($_course, $eid_id);  // see 'md_' . EID_TYPE . '.php'
     $eid = $mdObj->mdo_eid;
-    
+
     $titlePath = $mdObj->mdo_dcmap_v['Title'];   // no IEEE dependencies here...
-    
+
     if (($mdt_rec = $mdStore->mds_get($eid)) === FALSE)
     {
          $mdt = $mdObj->mdo_generate_default_xml_metadata();
-         
+
          $xmlDoc = new xmddoc(explode("\n", $mdt));
          if (!$xmlDoc->error)
          {
@@ -74,7 +74,7 @@ foreach(array(1001, 1002, 1003) as $eid_id)
          }
 
          $mdStore->mds_put($eid, $mdt, 'mdxmltext', FALSE);
-         echo '<a href="../index.php?eid=', urlencode($eid), '">', 
+         echo '<a href="../index.php?eid=', urlencode($eid), '">',
             htmlspecialchars($eid), '</a><br>';
     }
 }
@@ -98,14 +98,14 @@ $map_lang = 'string/@language';
 $dcmap_e_kwplace = 'metadata/lom/general'; $dcmap_e_kwelem = 'keyword';
 $dcmap_e_keyword = $dcmap_e_kwplace . '/' . $dcmap_e_kwelem;
 
-$mda =  $mdObj->mdo_dcmap_v['Description'] . '=Nouvelle description' . 
-        "\n" . $mdObj->mdo_dcmap_e['Coverage'] . "~" . 
-        "\n" . $dcmap_e_kwplace . '!' . $dcmap_e_kwelem . 
-        "\n" . $dcmap_e_keyword . "[-1]!string=afrique" . 
-        "\n" . $dcmap_e_keyword . "[-1]/" . $map_lang . "=en" . 
-        "\n" . $mdObj->mdo_dcmap_e['Title'] . ',' . 
-            $mdObj->mdo_dcmap_e['Description'] . ',' . 
-            $dcmap_e_keyword . ";" . $map_lang . "=fr" . 
+$mda =  $mdObj->mdo_dcmap_v['Description'] . '=Nouvelle description' .
+        "\n" . $mdObj->mdo_dcmap_e['Coverage'] . "~" .
+        "\n" . $dcmap_e_kwplace . '!' . $dcmap_e_kwelem .
+        "\n" . $dcmap_e_keyword . "[-1]!string=afrique" .
+        "\n" . $dcmap_e_keyword . "[-1]/" . $map_lang . "=en" .
+        "\n" . $mdObj->mdo_dcmap_e['Title'] . ',' .
+            $mdObj->mdo_dcmap_e['Description'] . ',' .
+            $dcmap_e_keyword . ";" . $map_lang . "=fr" .
         "";  // update metadata of 'Document.1003' - see md_funcs
         // note we don't go far with IEEE independence...
 $mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xmlDoc, $mda, $eid, $trace);
@@ -119,7 +119,7 @@ $mdObj = new mdobject($_course, '1003');
 $mdStore->mds_put_dc_elements($mdObj, array('Coverage' => 'broad...', 'Type' => 'aggressive text'));
 // Coverage won't work, because that element has been removed above...
 $dcelem = $mdStore->mds_get_dc_elements($mdObj);
-foreach (array('Identifier', 'Title', 'Language', 'Description', 'Coverage', 
+foreach (array('Identifier', 'Title', 'Language', 'Description', 'Coverage',
                         'Type', 'Date', 'Creator', 'Format', 'Rights') as $dce)
 {
     echo $dce, '= ', htmlspecialchars($dcelem[$dce]), '<br>';
@@ -130,7 +130,7 @@ echo '<br>';
 $mdObj = new mdobject($_course, '1002');
 $mdStore->mds_put_dc_elements($mdObj, array('Coverage' => 'broad...'));
 $dcelem = $mdStore->mds_get_dc_elements($mdObj);
-foreach (array('Identifier', 'Title', 'Language', 'Description', 'Coverage', 
+foreach (array('Identifier', 'Title', 'Language', 'Description', 'Coverage',
                         'Type', 'Date', 'Creator', 'Format', 'Rights') as $dce)
 {
     echo $dce, '= ', htmlspecialchars($dcelem[$dce]), '<br>';

+ 42 - 42
main/metadata/doc/testMiniDom.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: XMD test and demo
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -20,7 +20,7 @@ function file_get_contents_n($filename)  // normalize \r and \r\n to \n
     $fp = fopen($filename, 'rb');
     $buffer = fread($fp, filesize($filename));
     fclose($fp);  // note file_get_contents is >= PHP 4.3.0
-    
+
     return str_replace("\r", "\n", str_replace("\r\n", "\n", $buffer));
 }
 
@@ -33,7 +33,7 @@ $testdoc = new xmddoc('<docroot/>');  // docroot is element 0
 
 function showDoc($title, $morestuff = '')
 {
-    global $testdoc; echo '<h4>', $title, '</h4>', '<pre>', 
+    global $testdoc; echo '<h4>', $title, '</h4>', '<pre>',
         htmlspecialchars($morestuff ? $morestuff : $testdoc->xmd_xml()), '</pre>';
 }
 
@@ -67,7 +67,7 @@ $testdoc->xmd_set_attribute(0, 'owner', 'haentjens');  // new value
 showDoc('Text removed from 1st sometag, docroot owner changed');
 
 $testdoc->xmd_remove_element($sometag2);
-$sometag2 = $testdoc->xmd_add_text_element('çà', 'alors!');
+$sometag2 = $testdoc->xmd_add_text_element('��', 'alors!');
 
 showDoc('2nd sometag replaced by new subelement with French name');
 
@@ -90,7 +90,7 @@ foreach ($testdoc->attributes[$sometag1] as $name => $value)
 
 showDoc('Namespace-URI of subtag, of 1st sometag attributes', $stuff);
 
-$subsub = $testdoc->xmd_add_element('urn:sample-default:subsub', $subtag, 
+$subsub = $testdoc->xmd_add_element('urn:sample-default:subsub', $subtag,
     array('xmlns' => 'urn:sample-default', 'someatt' => 'somevalue'));
 $subsubsub = $testdoc->xmd_add_element('urn:sample-default:subsubsub', $subsub);
 
@@ -117,18 +117,18 @@ showDoc("After update 'newtag/~', ''");
 
 $keepdoc = $testdoc;
 
-$wrongdoc = "<html>\n  <body>\n    <p>Text</p>\n    <p>More text" . 
+$wrongdoc = "<html>\n  <body>\n    <p>Text</p>\n    <p>More text" .
     "\n  </body>\n</html>";
 $testdoc = new xmddoc(explode("\n", $wrongdoc));
 
-showDoc('Xml doc with syntax error + error message', 
+showDoc('Xml doc with syntax error + error message',
     $wrongdoc . "\n\n" . $testdoc->error);
 
 $xmlFile = 'imsmanifest_reload.xml';
 
-($presXmlFileContents = @file_get_contents_n($xmlFile)) 
+($presXmlFileContents = @file_get_contents_n($xmlFile))
     or die('XML file  ' . htmlspecialchars($xmlFile) . ' is missing...');
-    
+
 showDoc('XML file to be parsed', $presXmlFileContents);
 
 $testdoc = new xmddoc(explode("\n", $presXmlFileContents));
@@ -139,47 +139,47 @@ if ($testdoc->error) die($xmlFile . ':<br><br>' . $testdoc->error);
 $testdoc->xmd_update_many('metadata/lom/general/title,metadata/lom/general/description', 'langstring/@lang', 'fr');
 $testdoc->xmd_copy_foreign_child($keepdoc, $keepdoc->xmd_select_single_element('sometag[2]'));
 
-showDoc('After parsing, and after changing 2* langstring/@lang to fr, ' . 
+showDoc('After parsing, and after changing 2* langstring/@lang to fr, ' .
     'and after adding a foreign doc, reconstruction from memory');
-    
-showDoc('Element tagname of first metadata/lom/* element', 
+
+showDoc('Element tagname of first metadata/lom/* element',
     $testdoc->name[$testdoc->xmd_select_single_element('metadata/lom/*')]);
-    
-showDoc('Element namespace URI of metadata/lom/*[2]', 
+
+showDoc('Element namespace URI of metadata/lom/*[2]',
     $testdoc->xmd_get_ns_uri($testdoc->xmd_select_single_element('metadata/lom/*[2]')));
-    
-showDoc('Number of metadata/lom/* elements', 
+
+showDoc('Number of metadata/lom/* elements',
     count($testdoc->xmd_select_elements('metadata/lom/*')));
 
-showDoc('Number of resources/resource/file elements with @href', 
+showDoc('Number of resources/resource/file elements with @href',
     count($testdoc->xmd_select_elements_where_notempty(
         'resources/resource/file', '@href')));
 
-$elems = $testdoc->xmd_select_elements_where('resources/resource', 
+$elems = $testdoc->xmd_select_elements_where('resources/resource',
             'file[1]/@href', 'three.html');
 showDoc('Resource identifier where file[1]/@href is three.html',
     $testdoc->xmd_value('@identifier', $elems[0]));
-    
-$elems = $testdoc->xmd_select_elements_where('resources/resource', '@identifier', 
+
+$elems = $testdoc->xmd_select_elements_where('resources/resource', '@identifier',
     $testdoc->xmd_value('organizations/organization/item[2]/@identifierref'));
 showDoc('Resource href for item[2]',
     $testdoc->xmd_value('@href', $elems[0]));
-    
+
 $stuff = '';
-foreach (array('@identifier', 'metadata/schema', '*/*/*/*[1]/langstring', 
+foreach (array('@identifier', 'metadata/schema', '*/*/*/*[1]/langstring',
         'resources/resource[3]/@href', 'resources/resource[3]/file/@href',
-        'resources/resource[3]/@*', 'resources/resource[3]/-/@href', 
-        'resources/resource[3]/+/@href', 'resources/resource[1]/-/@href', 
-        'resources/../../../../../../../@identifier', '@*', 'resources/@*', 
-        'organizations/organization/item[4]/title', 
-        'organizations/organization/item[-2]/title', 
-        'organizations/organization/item[4]/@*', 
-        'organizations/organization/item[4]/@*item', 
-        'organizations/organization/item[2]/+item/title', 
-        'organizations/organization/item[2]/+/+/+/title', 
-        'organizations/organization/item[2]/-item', 
-        'organizations/organization/item[1]/-item', 
-        'organizations/organization/item[1]/-', 
+        'resources/resource[3]/@*', 'resources/resource[3]/-/@href',
+        'resources/resource[3]/+/@href', 'resources/resource[1]/-/@href',
+        'resources/../../../../../../../@identifier', '@*', 'resources/@*',
+        'organizations/organization/item[4]/title',
+        'organizations/organization/item[-2]/title',
+        'organizations/organization/item[4]/@*',
+        'organizations/organization/item[4]/@*item',
+        'organizations/organization/item[2]/+item/title',
+        'organizations/organization/item[2]/+/+/+/title',
+        'organizations/organization/item[2]/-item',
+        'organizations/organization/item[1]/-item',
+        'organizations/organization/item[1]/-',
         'organizations/organization/item[1]/-/@.'
         ) as $path)
     $stuff .= $path . ' => ' . $testdoc->xmd_value($path) . "\n";
@@ -189,7 +189,7 @@ showDoc('Values of: @identifier, metadata/schema, ... (see below)', $stuff);
 
 function showHtml($path)
 {
-    global $testdoc; echo '<h4>Html-value of ', htmlspecialchars($path), 
+    global $testdoc; echo '<h4>Html-value of ', htmlspecialchars($path),
         '</h4><pre>', $testdoc->xmd_html_value($path), '</pre>';
 }
 
@@ -208,19 +208,19 @@ showHtml('Titles:  -% organizations/organization/item/title ,  %- .');
 showHtml('<ul><li> -% resources/resource/file/../@identifier </li><li> %- </li></ul>');
 
 showHtml('metadata/lom/general/description/langstring');
-echo '<h5>The same, but in a HTML construct:</h5>', 
+echo '<h5>The same, but in a HTML construct:</h5>',
     $testdoc->xmd_html_value('metadata/lom/general/description/langstring');
 
 
 function getmicrotime()
-{ 
-   list($usec, $sec) = explode(" ",microtime()); 
-   return ((float)$usec + (float)$sec); 
+{
+   list($usec, $sec) = explode(" ",microtime());
+   return ((float)$usec + (float)$sec);
 }
 
 $xmlFile = 'imsmanifest_reload.xml';
 
-($presXmlFileContents = @file_get_contents_n($xmlFile)) 
+($presXmlFileContents = @file_get_contents_n($xmlFile))
     or die('XML file  ' . htmlspecialchars($xmlFile) . ' is missing...');
 $presXmlFileContents = explode("\n", $presXmlFileContents);
 
@@ -237,7 +237,7 @@ $seconds = getmicrotime() - $seconds;
 showDoc('Time to cache', $seconds);
 
 $seconds = getmicrotime();
-$testdoc = new xmddoc($testdoc2->names, $testdoc2->numbers, 
+$testdoc = new xmddoc($testdoc2->names, $testdoc2->numbers,
     $testdoc2->textstring);
 $seconds = getmicrotime() - $seconds;
 

+ 13 - 13
main/metadata/doc/testXht.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: XHT test and demo
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 require('../../inc/lib/xmd.lib.php');
@@ -45,11 +45,11 @@ $testdoc = new xmddoc(
             <imsmd:description>
               <imsmd:langstring xml:lang="en">Simple exemplar content package
 
-          
+
 , this description was
                          modified
-by                         
-               René                       
+by
+               Ren�
                                        </imsmd:langstring>
             </imsmd:description>
           </imsmd:general>
@@ -64,7 +64,7 @@ if ($testdoc->error) die($testdoc->error);
 
 // TEMPLATES ------------------------------------------------------------------>
 
-$xhtDoc = new xhtdoc( 
+$xhtDoc = new xhtdoc(
 <<<EOD
 <!-- {-HTTP-} -->
 
@@ -99,7 +99,7 @@ There are {-R keywords/keyword P empty-}{-P number-} keywords...<br><br>
 {-R Langnames C LEVEL1-}<br><br>
 
 {-D author {-V author-}-}
-{-T author != empty 
+{-T author != empty
 <h5>There is an author</h5>
 <!-- Note1: T tests parameters, not XML values directly -->
 <!-- Note2: the space after 'empty' is necessary! - see below
@@ -148,7 +148,7 @@ This text is re-calculated when the cache is no longer valid.
 
 {-P rdepth-}.{-P number-}
 
- 
+
 <!-- {--} -->
 EOD
 );
@@ -164,7 +164,7 @@ function get_lang($word)
 {
     if ($word == 'Kw') return 'Keyword';
     elseif ($word == 'Am') return '"Automatic"';
-    elseif ($word == 'Langnames') 
+    elseif ($word == 'Langnames')
         return array("de"=>"German", "fr"=>"French", "nl"=>"Dutch");
     else return 'To be translated';
 }
@@ -178,7 +178,7 @@ function md_cache($newtext)  // callback from template (for cached HTML)
     if ($newtext === FALSE)  // this is always the first callback
     {
         $cachedHtmlIsValid = FALSE;  // in real examples, not always
-        
+
         if ($cachedHtmlIsValid)
             return 'Cached HTML';
         else
@@ -199,12 +199,12 @@ function md_cache($newtext)  // callback from template (for cached HTML)
 foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra)
     if ($httpXtra) header($httpXtra);
 
-echo "<html>\n<head>", $xhtDoc->xht_fill_template('HEAD'), 
+echo "<html>\n<head>", $xhtDoc->xht_fill_template('HEAD'),
     "\n</head>\n\n<body>\n";
 
 $xhtDoc->xht_dbgn = 0;  // for template debug info, set to e.g. 10000
 
-echo $xhtDoc->xht_fill_template('MAIN'), 
+echo $xhtDoc->xht_fill_template('MAIN'),
     '<br><br>Child nodes of "description":';
 
 foreach($testdoc->children[$testdoc->xmd_select_single_element('description')] as $child)
@@ -213,6 +213,6 @@ echo "\n\n</body>\n</html>\n";
 
 if ($xhtDoc->xht_dbgn) echo $xhtDoc->xht_dbgo;
 
-// Note: XML document and templates would normally be fetched from (different) 
+// Note: XML document and templates would normally be fetched from (different)
 // external sources, such as a file or a DB record...
 ?>

+ 12 - 12
main/metadata/importdocs.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: index all course documents with PhpDig
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -23,12 +23,12 @@ define('OF_EID_TYPE', "eid LIKE '" . EID_TYPE . ".%'");
 
 require('md_' . strtolower(EID_TYPE) . '.php');
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = 'md_' . strtolower(EID_TYPE);
 include('../inc/global.inc.php');
 $nameTools = get_lang('Tool');
 
-($nameTools && get_lang('Sorry')) or give_up( 
+($nameTools && get_lang('Sorry')) or give_up(
     'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'");
 
 $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
@@ -74,22 +74,22 @@ while ($row = mysql_fetch_array($result))  // load indexabletexts in memory
 if (count($idt) && file_exists($phpDigIncCn))
 {
     require($phpDigIncCn);  // switch to PhpDig DB
-    
+
     foreach ($idt as $url => $text)
     if (ereg('^http://([^/]+)/(.+)/([^/]+)\?cidReq=(.+)$', $url, $regs))
     {
         $path = $regs[2] .'/'; $file = $regs[3] . '?cidReq=' . $regs[4];
-        if ($site_id = remove_engine_entries('http://' . $regs[1] .'/', 
+        if ($site_id = remove_engine_entries('http://' . $regs[1] .'/',
                 $path, $file))
         {
             echo '<table>', "\n";
-            index_words($site_id, $path, $file, 
-                get_first_words($text, $path, $file), 
+            index_words($site_id, $path, $file,
+                get_first_words($text, $path, $file),
                 get_keywords($text));
             echo '</table>', "\n";
         }
     }
-    
+
     if(isset($db))
     {
     	mysql_select_db($_configuration['main_database'], $db);  // back to Dokeos
@@ -102,9 +102,9 @@ else
 
 if (false && file_exists($phpDigIncCn))  // future: buttons for operations
 {
-    echo '<form action="' .api_get_self(). '" method="post">', "\n", 
-        '<input type="submit" name="dmo" value="', get_lang('Import', 'noDLTT'), '">', "\n", 
-        '<input type="submit" name="dmo" value="', get_lang('Remove', 'noDLTT'), '">', "\n", 
+    echo '<form action="' .api_get_self(). '" method="post">', "\n",
+        '<input type="submit" name="dmo" value="', get_lang('Import', 'noDLTT'), '">', "\n",
+        '<input type="submit" name="dmo" value="', get_lang('Remove', 'noDLTT'), '">', "\n",
         '</form>', "\n";
 }
 

+ 65 - 65
main/metadata/importlinks.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: create table entries for a category of Link-type items
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -23,12 +23,12 @@ define('OF_EID_TYPE', "eid LIKE '" . EID_TYPE . ".%'");
 
 require('md_' . strtolower(EID_TYPE) . '.php');
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = 'md_' . strtolower(EID_TYPE);
 include('../inc/global.inc.php');
 $nameTools = get_lang('Tool');
 
-($nameTools && get_lang('Sorry')) or give_up( 
+($nameTools && get_lang('Sorry')) or give_up(
     'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'");
 
 $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
@@ -61,11 +61,11 @@ function check_andor_get($row, $get = '', $check = '', $tobe = '')
 	$regs = array(); // for use with ereg()
 
 	if ($get == $mdCat && !$check)  // cheat to be quicker
-		if (ereg('<coverage>[^<]*<string language="..">([^<]+)<\/string>', 
+		if (ereg('<coverage>[^<]*<string language="..">([^<]+)<\/string>',
 			$row['mdxmltext'], $regs)) return strtr($regs[1], $htmldecode);
 
 	if ($check == $mdCat && !$get)  // cheat to be quicker
-		if (ereg('<coverage>[^<]*<string language="..">([^<]+)<\/string>', 
+		if (ereg('<coverage>[^<]*<string language="..">([^<]+)<\/string>',
 			$row['mdxmltext'], $regs))
 				return (strtr($regs[1], $htmldecode) == $tobe);
 
@@ -84,15 +84,15 @@ function check_andor_get($row, $get = '', $check = '', $tobe = '')
 function get_cat($catname)
 {
     global $_course; $cateq = "category_title='". addslashes($catname) . "'";
-    
+
     $linkcat_table = Database::get_course_table(TABLE_LINK_CATEGORY);
     $result = api_sql_query("SELECT id FROM $linkcat_table WHERE " . $cateq, __FILE__, __LINE__);
-    
+
     if (mysql_num_rows($result) >= 1 && ($row = mysql_fetch_array($result)))
         return $row['id'];  // several categories with same name: take first
-    
+
     return FALSE;
-}    
+}
 
 
 // SET CURRENT LINKS CATEGORY - HEADER ---------------------------------------->
@@ -102,11 +102,11 @@ unset($lci);  // category-id
 if (isset($lcn))  // category_title
 {
     $lcn = substr(ereg_replace("[^\x20-\x7E\xA1-\xFF]", "", $lcn), 0, 255);
-    
+
     $uceids = array(); $mceids = array();
-    
+
     $result = $mdStore->mds_get_many('eid,mdxmltext', OF_EID_TYPE);
-    
+
     while ($row = mysql_fetch_array($result))
         if (check_andor_get($row, '', $mdCat, $lcn)) $uceids[] = $row['eid'];
 
@@ -114,34 +114,34 @@ if (isset($lcn))  // category_title
     {
         $link_table = Database::get_course_table(TABLE_LINK);
         $result = api_sql_query("SELECT id FROM $link_table WHERE category_id=" . $lci, __FILE__, __LINE__);
-        
+
         while ($row = mysql_fetch_array($result))
         {
             $lceids[$id = (int) $row['id']] = ($eid = EID_TYPE . '.' . $id);
-            
+
             if (in_array($eid, $uceids)) $mceids[] = $eid;
         }
-        
-        $hdrInfo = ' ' . get_lang('WorkOn') . ' ' . htmlspecialchars($lcn, ENT_QUOTES, $charset) . 
+
+        $hdrInfo = ' ' . get_lang('WorkOn') . ' ' . htmlspecialchars($lcn, ENT_QUOTES, $charset) .
             ', LC-id=&nbsp;' . htmlspecialchars($lci, ENT_QUOTES, $charset);
     }
     elseif ($lcn)
     {
-        $hdrInfo = ' (' . htmlspecialchars($lcn, ENT_QUOTES, $charset) . 
+        $hdrInfo = ' (' . htmlspecialchars($lcn, ENT_QUOTES, $charset) .
             ': ' . get_lang('NotInDB') . ')';
     }
     else
         unset($lcn);
 
     $uceids = array_diff($uceids, $mceids);  // old entries with no link
-    
+
     if (count($lceids) && count($uceids))
     {
         $mdStore->mds_delete_many($uceids); $ufos = mysql_affected_rows();
     }
 
     $interbreadcrumb[]= array(
-        'url' => api_get_self() . '?lcn=' . urlencode($lcn), 
+        'url' => api_get_self() . '?lcn=' . urlencode($lcn),
         'name'=> get_lang('Continue') . ' ' . htmlspecialchars($lcn, ENT_QUOTES, $charset));
 }
 
@@ -153,7 +153,7 @@ Display::display_header($nameTools);
 
 // OPERATIONS ----------------------------------------------------------------->
 
-if ($ufos) echo '<h3>', $ufos, ' ', get_lang('RemainingFor'), ' ', 
+if ($ufos) echo '<h3>', $ufos, ' ', get_lang('RemainingFor'), ' ',
         htmlspecialchars($lcn, ENT_QUOTES, $charset), '</h3>', "\n";
 
 if (isset($slo)) echo '<h3>', $slo, '</h3>', "\n";  // selected links op
@@ -164,12 +164,12 @@ if ($slo == get_lang('Create') && count($lceids))
     foreach ($lceids as $id => $eid)
     {
         $mdObj = new mdobject($_course, $id); $xht = $mdObj->mdo_define_htt();
-        $mdStore->mds_put($eid, $mdt = $mdObj->mdo_generate_default_xml_metadata(), 
+        $mdStore->mds_put($eid, $mdt = $mdObj->mdo_generate_default_xml_metadata(),
             'mdxmltext', '?');
         $xht->xht_xmldoc = new xmddoc(explode("\n", $mdt));
-        $mdStore->mds_put($eid, $xht->xht_fill_template('INDEXABLETEXT'), 
+        $mdStore->mds_put($eid, $xht->xht_fill_template('INDEXABLETEXT'),
             'indexabletext');
-        echo '<span class="lbs" onClick="', "javascript: makeWindow('index.php?eid=", 
+        echo '<span class="lbs" onClick="', "javascript: makeWindow('index.php?eid=",
             urlencode($eid), "', '', '')\">", htmlspecialchars($eid, ENT_QUOTES, $charset), '</span> ';
     }
     echo '<br>';
@@ -177,37 +177,37 @@ if ($slo == get_lang('Create') && count($lceids))
 elseif ($slo == get_lang('Remove') && count($lceids))
 {
     $mdStore->mds_delete_many($mceids); $aff = mysql_affected_rows();
-    
-    echo $aff, ' MDEs/ ', count($lceids), ' ', get_lang('MdCallingTool'), 
-        '<br><br><b>', get_lang('AllRemovedFor'), 
+
+    echo $aff, ' MDEs/ ', count($lceids), ' ', get_lang('MdCallingTool'),
+        '<br><br><b>', get_lang('AllRemovedFor'),
         ' ', htmlspecialchars($lcn, ENT_QUOTES, $charset), '</b><br />';
 }
 elseif ($slo == get_lang('Remove') && count($mceids))  // obsolete category
 {
     $mdStore->mds_delete_many($mceids);
-    
+
     echo get_lang('AllRemovedFor'), ' ', htmlspecialchars($lcn, ENT_QUOTES, $charset), '<br />';
 }
 elseif ($slo == get_lang('Index') && file_exists($phpDigIncCn) && count($mceids))
 {
-    $result = $mdStore->mds_get_many('eid,mdxmltext,indexabletext', 
-        OF_EID_TYPE . " AND eid IN ('" . 
+    $result = $mdStore->mds_get_many('eid,mdxmltext,indexabletext',
+        OF_EID_TYPE . " AND eid IN ('" .
         implode("','", array_map('addslashes', $mceids)) . "')");
-    
+
     while ($row = mysql_fetch_array($result))  // load indexabletexts in memory
         $idt[check_andor_get($row, $mdUrl)] = $row['indexabletext'];
-    
+
     require($phpDigIncCn);  // switch to PhpDig DB
-    
+
     foreach ($idt as $url => $text)
     {
         $pu = parse_url($url);
         if (!isset($pu['scheme'])) $pu['scheme'] = "http";
-        
+
         if (isset($pu['host']))
         {
             $url = $pu['scheme'] . "://" . $pu['host'] . "/"; $file = '';
-            
+
             if (($path = $pu['path']))
             if (substr($path, -1) == '/') $path = substr($path, 1);
             else
@@ -215,27 +215,27 @@ elseif ($slo == get_lang('Index') && file_exists($phpDigIncCn) && count($mceids)
                 $pi = pathinfo($path); $path = $pi['dirname'];
                 if ($path{0} == '\\') $path = substr($path, 1);
                 if ($path{0} == '/')  $path = substr($path, 1) . '/';
-                
+
                 $file = $pi['basename'];
             }
-            
-            $file .= ($pu['query'] ? '?'.$pu['query'] : '') . 
+
+            $file .= ($pu['query'] ? '?'.$pu['query'] : '') .
                     ($pu['fragment'] ? '#'.$pu['fragment'] : '');
-            
-            
+
+
             if ($site_id = remove_engine_entries($url, $path, $file))
             {
                 echo '<table>', "\n";
-                index_words($site_id, $path, $file, 
-                    get_first_words($text, $url . $path, $file), 
+                index_words($site_id, $path, $file,
+                    get_first_words($text, $url . $path, $file),
                     get_keywords($text));
                 echo '</table>', "\n";
             }
             else
             {
                 echo '<table>', "\n";
-                echo '<tr><td>', htmlspecialchars($url, ENT_QUOTES, $charset), 
-                    '</td><td>', htmlspecialchars($path, ENT_QUOTES, $charset), 
+                echo '<tr><td>', htmlspecialchars($url, ENT_QUOTES, $charset),
+                    '</td><td>', htmlspecialchars($path, ENT_QUOTES, $charset),
                     '</td><td>', htmlspecialchars($file, ENT_QUOTES, $charset), '</td></tr>';
                 echo '</table>', "\n";
             }
@@ -245,22 +245,22 @@ elseif ($slo == get_lang('Index') && file_exists($phpDigIncCn) && count($mceids)
             if ($site_id = remove_engine_entries($url = 'mailto:' . $pu['path'], ''))
             {
                 echo '<table>', "\n";
-                index_words($site_id, '', '', 
-                    get_first_words($text, $url, ''), 
+                index_words($site_id, '', '',
+                    get_first_words($text, $url, ''),
                     get_keywords($text));
                 echo '</table>', "\n";
             }
             else
             {
                 echo '<table>', "\n";
-                echo '<tr><td>', htmlspecialchars($url, ENT_QUOTES, $charset), 
-                    '</td><td>', htmlspecialchars($path, ENT_QUOTES, $charset), 
+                echo '<tr><td>', htmlspecialchars($url, ENT_QUOTES, $charset),
+                    '</td><td>', htmlspecialchars($path, ENT_QUOTES, $charset),
                     '</td><td>', htmlspecialchars($file, ENT_QUOTES, $charset), '</td></tr>';
                 echo '</table>', "\n";
             }
         }
     }
-    
+
     if(isset($db))
     {
     	mysql_select_db($_configuration['main_database'], $db);  // back to Dokeos
@@ -290,8 +290,8 @@ if (count($perCat))
     echo '<table>', "\n";
     foreach ($perCat as $cat => $number)
     {
-        echo '<tr><td>', $cat == $lcn ? '' : '(', htmlspecialchars($cat, ENT_QUOTES, $charset), 
-            $cat == $lcn ? '' : ')', ':</td><td align="right">', 
+        echo '<tr><td>', $cat == $lcn ? '' : '(', htmlspecialchars($cat, ENT_QUOTES, $charset),
+            $cat == $lcn ? '' : ')', ':</td><td align="right">',
             $number, '</td></tr>', "\n";
     }
     echo '</table>', "\n";
@@ -299,7 +299,7 @@ if (count($perCat))
 
 if (isset($lci))
 {
-    echo '<br><br>', htmlspecialchars($lcn, ENT_QUOTES, $charset), ' ', get_lang('MdCallingTool'), 
+    echo '<br><br>', htmlspecialchars($lcn, ENT_QUOTES, $charset), ' ', get_lang('MdCallingTool'),
         ': ', count($lceids), '<br />', "\n";
 }
 
@@ -309,19 +309,19 @@ if (isset($lci))
 
 echo '<h3>', $nameTools, $hdrInfo, '</h3>', "\n";
 
-echo '<form action="' .api_get_self(). '?lcn=' . urlencode($lcn) . 
-    '" method="post">', "\n"; 
+echo '<form action="' .api_get_self(). '?lcn=' . urlencode($lcn) .
+    '" method="post">', "\n";
 
-if (count($lceids)) echo 
+if (count($lceids)) echo
     '<input type="submit" name="slo" value="', get_lang('Create'), '">', "\n";
-if ($perCat[$lcn]) echo 
+if ($perCat[$lcn]) echo
     '<input type="submit" name="slo" value="', get_lang('Remove'), '">', "\n";
-if ($perCat[$lcn] && file_exists($phpDigIncCn)) echo 
+if ($perCat[$lcn] && file_exists($phpDigIncCn)) echo
     '<input type="submit" name="slo" value="', get_lang('Index'), '">', "\n";
 
 echo '</form>', "\n";
 
-if (count($perCat)) foreach ($perCat as $cat => $number) 
+if (count($perCat)) foreach ($perCat as $cat => $number)
     $perCat[$cat] = '(' . htmlspecialchars($cat, ENT_QUOTES, $charset) . ')';
 
 $linkcat_table = Database::get_course_table(TABLE_LINK_CATEGORY);
@@ -337,21 +337,21 @@ while ($row = mysql_fetch_array($result))
 if (count($dups))
 {
     $warning = get_lang('WarningDups');;
-    
+
     foreach ($dups as $cat) unset($perCat[$cat]);
 }
 
 echo '<h3>', get_lang('OrElse'), $warning, '</h3>', "\n",  // select new target
-    '<table><tr><td align="right" class="alternativeBgDark">', "\n", 
-    '<form action="'.api_get_self().'" method="post">', "\n", 
+    '<table><tr><td align="right" class="alternativeBgDark">', "\n",
+    '<form action="'.api_get_self().'" method="post">', "\n",
     get_lang('SLC'), ' :', "\n", '<select name="lcn">', "\n",
     '<option value=""></option>', "\n";
-    
-    foreach ($perCat as $cat => $text) echo '<option value="' . 
-        htmlspecialchars($cat, ENT_QUOTES, $charset) . '"' . 
+
+    foreach ($perCat as $cat => $text) echo '<option value="' .
+        htmlspecialchars($cat, ENT_QUOTES, $charset) . '"' .
         ($cat == $lcn ? ' selected' : '') . '>' . $text . '</option>', "\n";
 
-echo '</select><input type="submit" value="', '  '.get_lang('Ok').'  ', '">', "\n", 
+echo '</select><input type="submit" value="', '  '.get_lang('Ok').'  ', '">', "\n",
     '</form>', "\n", '</td></tr></table>', "\n";
 
 Display::display_footer();

+ 26 - 26
main/metadata/index.php

@@ -2,11 +2,11 @@
                                                              <!-- 2005/05/19 -->
 
 <!-- Copyright (C) 2005 rene.haentjens@UGent.be -  see metadata/md_funcs.php -->
-    
+
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: view/edit metadata of a Dokeos course object
 *
 *   URL parameters:
@@ -16,7 +16,7 @@
 *   - dbg=  debuginfo start number, e.g. 10000
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -44,8 +44,8 @@ if (LFN != 'md_' . strtolower(EID_TYPE))    $urlp .= '&lfn=' . urlencode(LFN);
 if (HTT != LFN)                             $urlp .= '&htt=' . urlencode(HTT);
 if (DBG)                                    $urlp .= '&dbg=' . urlencode(DBG);
 
-// name of the language file that needs to be included 
-$language_file = LFN; 
+// name of the language file that needs to be included
+$language_file = LFN;
 require("../inc/global.inc.php");
 $this_section=SECTION_COURSES;
 
@@ -64,11 +64,11 @@ $mdObj = new mdobject($_course, EID_ID);  // see 'md_' . EID_TYPE . '.php'
 
 // Construct assoclist $langLangs from language table ------------------------->
 
-$result = api_sql_query("SELECT isocode FROM " . 
-    Database :: get_main_table(TABLE_MAIN_LANGUAGE) . 
+$result = api_sql_query("SELECT isocode FROM " .
+    Database :: get_main_table(TABLE_MAIN_LANGUAGE) .
     " WHERE available='1' ORDER BY isocode ASC", __FILE__, __LINE__);
 
-$sep = ":"; $langLangs = $sep . "xx" . $sep . "xx"; 
+$sep = ":"; $langLangs = $sep . "xx" . $sep . "xx";
 
 while ($row = mysql_fetch_array($result))
     if (($isocode = $row['isocode']))
@@ -84,18 +84,18 @@ $mdStore = new mdstore($is_allowed_to_edit);
 if (($mdt_rec = $mdStore->mds_get(EID)) === FALSE)  // no record, default XML
      $mdt = $mdObj->mdo_generate_default_xml_metadata();
 else $mdt = $mdt_rec;
-    
+
 $xhtxmldoc = new xmddoc(explode("\n", $mdt));
 
 $httfile = ($xhtxmldoc->error) ? 'md_editxml.htt' : HTT . '.htt';
 
-if (!$xhtxmldoc->error && $mdt_rec !== FALSE && 
+if (!$xhtxmldoc->error && $mdt_rec !== FALSE &&
         method_exists($mdObj, 'mdo_override'))
     $mdt = $mdObj->mdo_override($xhtxmldoc);
 
 $xhtDoc = define_htt($httfile, $urlp, $_course['path']);
 
-define('HSH', md5($mdt . LFN . $nameTools . get_lang('Sorry') . $httfile . 
+define('HSH', md5($mdt . LFN . $nameTools . get_lang('Sorry') . $httfile .
     implode('{}', $xhtDoc->htt_array)));  // cached HTML depends on LFN+HTT
 
 $xhtDoc->xht_param['traceinfo'] = $xhtxmldoc->error;
@@ -107,10 +107,10 @@ if ($is_allowed_to_edit) $xhtDoc->xht_param['isallowedtoedit'] = 'TRUE';
 
 if ($is_allowed_to_edit && isset($_POST['mda']))  // MD updates to Doc and DB
 {
-    $mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xhtDoc->xht_xmldoc, 
-        get_magic_quotes_gpc() ? stripslashes($_POST['mda']) : $_POST['mda'], 
+    $mdt = $mdStore->mds_update_xml_and_mdt($mdObj, $xhtDoc->xht_xmldoc,
+        get_magic_quotes_gpc() ? stripslashes($_POST['mda']) : $_POST['mda'],
         EID, $xhtDoc->xht_param['traceinfo'], $mdt_rec !== FALSE);
-    
+
     if ($mdt_rec !== FALSE)
     {
          if (strpos($xhtDoc->xht_param['traceinfo'], 'DELETE') !== FALSE)
@@ -118,36 +118,36 @@ if ($is_allowed_to_edit && isset($_POST['mda']))  // MD updates to Doc and DB
     }
     else if (strpos($xhtDoc->xht_param['traceinfo'], 'INSERT') !== FALSE)
             $xhtDoc->xht_param['dbrecord'] = 'TRUE';
-    
+
     if (method_exists($mdObj, 'mdo_storeback'))
         $mdObj->mdo_storeback($xhtDoc->xht_xmldoc);
-        
+
     $mdt_rec = FALSE;  // cached HTML obsolete, must re-apply templates
 }
 elseif ($is_allowed_to_edit && $_POST['mdt'])  // md_editxml.htt
 {
-    $mdStore->mds_put(EID, 
-        get_magic_quotes_gpc() ? stripslashes($_POST['mdt']) : $_POST['mdt'], 
+    $mdStore->mds_put(EID,
+        get_magic_quotes_gpc() ? stripslashes($_POST['mdt']) : $_POST['mdt'],
         'mdxmltext', '?');
     $mdStore->mds_put(EID, HSH, 'md5');
-    
+
     $xhtDoc->xht_param['dbrecord'] = 'TRUE';
-    
+
     $mdt = ''; $xhtDoc->xht_param['traceinfo'] = get_lang('PressAgain');
-    
+
     $mdt_rec = FALSE;  // cached HTML obsolete, must re-apply templates
 }
 
 $xhtDoc->xht_param['mdt'] = $mdt;
 
-define('CACHE_IS_VALID', isset($mdt_rec) && $mdt_rec !== FALSE && 
+define('CACHE_IS_VALID', isset($mdt_rec) && $mdt_rec !== FALSE &&
     HSH && HSH == $mdStore->mds_get(EID, 'md5'));
 
-    
+
 function md_part($part, $newtext)  // callback from template (HTML cache in DB)
 {
     global $mdStore;
-    
+
     if ($newtext === FALSE)
     {
         if (!CACHE_IS_VALID) return FALSE;
@@ -157,7 +157,7 @@ function md_part($part, $newtext)  // callback from template (HTML cache in DB)
     {
         $mdStore->mds_put(EID, HSH, 'md5');
         $mdStore->mds_put(EID, $newtext, $part);
-        
+
         return $newtext;
     }
 }
@@ -185,7 +185,7 @@ $noPHP_SELF = TRUE;  // in breadcrumps
 Display::display_header($nameTools); echo "\n";
 
 $xhtDoc->xht_dbgn = DBG;  // for template debug info, set to e.g. 10000
-if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] = 
+if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] =
     '<h5>Trace information</h5>' . htmlspecialchars($ti, ENT_QUOTES, $charset);
 
 echo $xhtDoc->xht_fill_template('METADATA'), "\n";

+ 47 - 47
main/metadata/md_document.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: class mdobject for Document-type items
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 class mdobject
@@ -58,54 +58,54 @@ EOD
 function mdo_generate_default_xml_metadata()
 {
     global $iso639_2_code, $ieee_xml;
-    
+
     $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info();
-    
-    if ($xhtDoc->htt_error) 
+
+    if ($xhtDoc->htt_error)
         give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error);
-    
+
     $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc('');
     if ($xhtDoc->xht_xmldoc->error) give_up($xhtDoc->xht_xmldoc->error);
-    
+
     $xhtDoc->xht_param['siteUri'] = make_uri();
-    
-    $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . 
+
+    $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] .
         '.Document.' . $this->mdo_id;  // 2005-05-30: path->sysCode
-    
-    $xhtDoc->xht_param['location'] = api_get_path(WEB_PATH) . 
-        'main/metadata/openobject.php?cidReq=' . 
-        urlencode($this->mdo_course['sysCode']) . '&eid=' . 
+
+    $xhtDoc->xht_param['location'] = api_get_path(WEB_PATH) .
+        'main/metadata/openobject.php?cidReq=' .
+        urlencode($this->mdo_course['sysCode']) . '&eid=' .
         urlencode($this->mdo_eid);
-    
+
     $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code);
     $xhtDoc->xht_param['lang'] =   strtolower($iso639_2_code);
-    
-    $xhtDoc->xht_param['title'] = 
-        $this->mdo_title ? $this->mdo_title : 
+
+    $xhtDoc->xht_param['title'] =
+        $this->mdo_title ? $this->mdo_title :
             ($this->mdo_path ? $this->mdo_path : get_lang('MdTitle', ''));
-    $xhtDoc->xht_param['description'] = 
+    $xhtDoc->xht_param['description'] =
         $this->mdo_comment ? $this->mdo_comment : get_lang('MdDescription', '');
     $xhtDoc->xht_param['coverage'] = get_lang('MdCoverage', '');
 
     if (isset($_user))
     {
-        $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . 
+        $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" .
             api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) .
             "\\nEMAIL:".$_user['mail'] . "\\nEND:VCARD\\n";
     }
-    
+
     $xhtDoc->xht_param['dateTime'] = date('Y-m-d');
-    
+
     if ($this->mdo_filetype == 'folder') $format = "inode/directory";
     else
     {
         require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
         $format = DocumentManager::file_get_mime_type($this->mdo_path);
     }
-        
+
     $xhtDoc->xht_param['format'] = $format;
-    
-    $xhtDoc->xht_param['size'] = (($s = filesize(get_course_path() . 
+
+    $xhtDoc->xht_param['size'] = (($s = filesize(get_course_path() .
         $this->mdo_course['path'] . '/document' . $this->mdo_path))) ? $s : '0';
 
     return $xhtDoc->xht_fill_template('XML');
@@ -116,39 +116,39 @@ function mdo_add_breadcrump_nav()
 {
     global $interbreadcrumb, $langFormats;
     $regs = array(); // for use with ereg()
-    
+
     $docurl = api_get_self();  // should be .../main/xxx/yyy.php
     if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$', $docurl, $regs))
         $docurl = $regs[1] . '/document/document.php';
-    
-    $interbreadcrumb[]= array ('url' => $docurl, 
+
+    $interbreadcrumb[]= array ('url' => $docurl,
         "name"=> get_lang('MdCallingTool'));
-    
+
     if (($docpath = $this->mdo_path))
     {
         $docpath = substr($docpath, 0, strrpos($docpath, '/'));
-    
-        if (strlen($docpath) > 1) $interbreadcrumb[]= array ('url' => 
-            $docurl . '?curdirpath=' . urlencode($docpath) . 
-            ($this->mdo_group ? '&gidReq=' . $this->mdo_group : ''), "name" => 
+
+        if (strlen($docpath) > 1) $interbreadcrumb[]= array ('url' =>
+            $docurl . '?curdirpath=' . urlencode($docpath) .
+            ($this->mdo_group ? '&gidReq=' . $this->mdo_group : ''), "name" =>
             htmlspecialchars(substr($docpath, strrpos($docpath, '/') + 1)));
     }
-    
+
     // Complete assoclist $langFormats from mime types
-    
+
     require_once(api_get_path(LIBRARY_PATH) . 'xht.lib.php');
     require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
-    
+
     $sep = $langFormats{0} ? $langFormats{0} : ":";
     $arrFormats = xht_explode_assoclist($langFormats);
-    
+
     foreach (DocumentManager::file_get_mime_type(TRUE) as $format)
         if (!isset($arrFormats[$format]))
             $langFormats .= ",, " . $format . $sep . $format;
-    
+
     if (!isset($arrFormats["inode/directory"]))
         $langFormats .= ",, inode/directory" . $sep . "inode/directory";
-        
+
     if (substr($langFormats, 0, 3) == ",, ")
         $langFormats = $sep . substr($langFormats, 3);
 }
@@ -157,15 +157,15 @@ function mdo_add_breadcrump_nav()
 function mdobject($_course, $id)
 {
     global $ieee_dcmap_e, $ieee_dcmap_v;  // md_funcs
-    
+
     $this->mdo_course = $_course; $this->mdo_type = 'Document';
     $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id;
-    
+
     $this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v;
-    
+
     $document_table = Database::get_course_table(TABLE_DOCUMENT);
     if (($docinfo = @mysql_fetch_array(api_sql_query(
-            "SELECT path,title,comment,filetype FROM $document_table WHERE id='" . 
+            "SELECT path,title,comment,filetype FROM $document_table WHERE id='" .
             addslashes($id) . "'", __FILE__, __LINE__))))
     {
         $this->mdo_path =     $docinfo['path'];
@@ -173,20 +173,20 @@ function mdobject($_course, $id)
         $this->mdo_comment =  $docinfo['comment'];
         $this->mdo_filetype = $docinfo['filetype'];
         $this->mdo_group =    '';  // 2005-05-30: find group_id, if any
-        
+
         $group_info = Database::get_course_table(TABLE_GROUP);
         if (($result = api_sql_query(
                 "SELECT id,secret_directory FROM $group_info",  __FILE__, __LINE__)))
             while (($row = mysql_fetch_array($result)))
-                if (($secdir = $row['secret_directory'] . '/') == 
+                if (($secdir = $row['secret_directory'] . '/') ==
                         substr($this->mdo_path, 0, strlen($secdir)))
                 {
                     $this->mdo_group = $row['id']; break;
                 }
-    
+
           // 2005-05-30: use direct URL
-          $this->mdo_url =  api_get_path(WEB_COURSE_PATH) . $_course['path'] . 
-            '/document' . str_replace('%2F', '/', urlencode($this->mdo_path)) . 
+          $this->mdo_url =  api_get_path(WEB_COURSE_PATH) . $_course['path'] .
+            '/document' . str_replace('%2F', '/', urlencode($this->mdo_path)) .
             ($this->mdo_group ? '?gidReq=' . $this->mdo_group : '');
     }
 }

+ 64 - 64
main/metadata/md_funcs.php

@@ -6,7 +6,7 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *   Dokeos Metadata: common functions and mdstore class
 *
 *   This script requires xmd.lib.php and xht.lib.php (Dokeos inc/lib).
@@ -26,7 +26,7 @@
 *                   assign value to subpath (see also xmd_update_many)
 *
 *   @package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -39,7 +39,7 @@ if (isset($getpostvars) && is_array($getpostvars))
         $val = isset($_POST[$gpvar]) ? $_POST[$gpvar] : $_GET[$gpvar];
         $GLOBALS[$gpvar] = get_magic_quotes_gpc() ? stripslashes($val) : $val;
     }
-    
+
 function fgc($filename)
 {
     $fp = fopen($filename, 'rb'); $buffer = fread($fp, filesize($filename));
@@ -50,9 +50,9 @@ function fgc($filename)
 function give_up($msg)
 {
 	global $charset;
-    echo '<p align="center">MetaData:<br /><b>? ', 
+    echo '<p align="center">MetaData:<br /><b>? ',
         htmlspecialchars($msg, ENT_QUOTES, $charset), '</b></p>'; exit;
-} 
+}
 
 
 function getpar($name, $description, $default = '')
@@ -60,9 +60,9 @@ function getpar($name, $description, $default = '')
     $value = isset($_GET[$value = api_strtolower($name)]) ? $_GET[$value] : '';
     $value = get_magic_quotes_gpc() ? stripslashes($value) : $value;
     if (!$value) $value = $default;
-    if ($value == '') give_up('URL parameter ' . api_strtoupper($name) . ' - ' . 
+    if ($value == '') give_up('URL parameter ' . api_strtoupper($name) . ' - ' .
                 $description . ' - is required');
-    
+
     define(api_strtoupper($name), $value);
 }
 
@@ -86,25 +86,25 @@ function define_htt($htt_file, $urlp, $course_path)
 
     ($htt_file_contents = @fgc($htt_file))
         or give_up('Templates file "' . $htt_file . '" is missing...');
-    
+
     $xhtDoc = new xhtdoc($htt_file_contents);
-    if ($xhtDoc->htt_error) 
+    if ($xhtDoc->htt_error)
         give_up('Templates file "' . $htt_file . '": ' . $xhtDoc->htt_error);
-    
+
     $xhtDoc->xht_param['self'] = api_get_self() . $urlp;
-    
+
     $xhtDoc->xht_param['dateTime'] = date('Y-m-d');
-    
+
     $ckw = $course_path . '/CourseKwds.js';
     define('KEYWORDS_CACHE', get_course_path() . $ckw);
-    
-    if (file_exists(KEYWORDS_CACHE)) $kcdt = 
+
+    if (file_exists(KEYWORDS_CACHE)) $kcdt =
         htmlspecialchars(date('Y/m/d H:i:s', filemtime(KEYWORDS_CACHE)), ENT_QUOTES, $charset);
-    
+
     $xhtDoc->xht_param['keywordscache'] = $kcdt ?
-        '<script type="text/javascript" src="' . get_course_web() . $ckw . '"></script>' . 
+        '<script type="text/javascript" src="' . get_course_web() . $ckw . '"></script>' .
         '<br /><small><i>(CourseKwds cache: ' . $kcdt . ')</i></small>' : '';
-    
+
     return $xhtDoc;
 }
 
@@ -112,20 +112,20 @@ function define_htt($htt_file, $urlp, $course_path)
 function make_uri()
 {
     $regs = array(); // for use with ereg()
-    
+
     $uri = strtr(ereg_replace(
-        "[^0-9A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\*\(\('!_.-]", "_", 
+        "[^0-9A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\*\(\('!_.-]", "_",
         api_get_setting('siteName')), "\\", "_");  // allow letdigs, and _-.()'!*
-    
-    if (($p = strpos($uri, '.')) !== FALSE) 
+
+    if (($p = strpos($uri, '.')) !== FALSE)
         $uri = substr($uri, 0, $p);
     if (ereg('^([^/]+//)?([^/\?]+)[/\?]',api_get_path(WEB_PATH).'/',$regs))
         if (ereg('([^\.]+)(\.ca)?(\.[^\.]+)?', strrev($regs[2]), $regs))
-            $uri = str_replace('.', '-', 
+            $uri = str_replace('.', '-',
                 strrev($regs[1].$regs[2].$regs[3])) . ':' . $uri;
     $uri = 'urn:' . strtolower($uri);
     while (substr($uri, -1)=='.') $uri = substr($uri,0,-1);
-    
+
     return $uri;
 }
 
@@ -209,16 +209,16 @@ $ieee_dcmap_v = array(
 
 // KEYWORD TREE --------------------------------------------------------------->
 
-function define_kwds($mdo) 
+function define_kwds($mdo)
 {
-    if (!($newtext = trim(@fgc(get_course_path() . $mdo->mdo_course['path'] . 
+    if (!($newtext = trim(@fgc(get_course_path() . $mdo->mdo_course['path'] .
             '/document' . $mdo->mdo_path ))))
     {
         unlink(KEYWORDS_CACHE); return;
     }
                                     // templates to define the tree as JScript object
     $xhtDocKw = new xhtdoc(<<<EOD
-    
+
 <!-- {-KWTREE_OBJECT-} -->
 
 KWTREE_OBJECT = {n:"", ti:"{-X @title-}"
@@ -227,27 +227,27 @@ KWTREE_OBJECT = {n:"", ti:"{-X @title-}"
 document.write(traverseKwObj(KWTREE_OBJECT, '', 0)); KWDS_ARRAY.sort();
 
 <!-- {-DOWN_THE_KWTREE-} -->
-{-T number > 1 , -}{n:"{-V @.-}"{-D cm {-X @comment-}-}{-T cm != empty , cm:"{-P cm-}"-}{-D pt {-X @postit-}-}{-T pt != empty , pt:"{-P pt-}"-}{-R * P empty-}{-T number >= 1 
+{-T number > 1 , -}{n:"{-V @.-}"{-D cm {-X @comment-}-}{-T cm != empty , cm:"{-P cm-}"-}{-D pt {-X @postit-}-}{-T pt != empty , pt:"{-P pt-}"-}{-R * P empty-}{-T number >= 1
 , c:[-}{-T number >= 1 R * C DOWN_THE_KWTREE-}{-R * P empty-}{-T number >= 1 ]-}}
 
 <!-- {--} -->
 EOD
     );  // traverseKwObj (md_script) generates clickable tree and populates KWDS_ARRAY
 
-    
-    if ($xhtDocKw->htt_error) 
+
+    if ($xhtDocKw->htt_error)
         give_up('KwdTree template (metadata/md_funcs): ' . $xhtDocKw->htt_error);
-    
+
     $xhtDocKw->xht_xmldoc = new xmddoc(explode("\n", $newtext));
     if ($xhtDocKw->xht_xmldoc->error)
-        give_up('CourseKwds (metadata/md_funcs): XML error: ' . 
+        give_up('CourseKwds (metadata/md_funcs): XML error: ' .
         $xhtDocKw->xht_xmldoc->error);
-    
+
     if (count($xhtDocKw->xht_xmldoc->children[0]) < 2)
     {
         unlink(KEYWORDS_CACHE); return;
     }
-    
+
     $fileHandler = @fopen(KEYWORDS_CACHE, 'w');
     @fwrite($fileHandler, $xhtDocKw->xht_fill_template('KWTREE_OBJECT'));
     @fclose($fileHandler);
@@ -263,26 +263,26 @@ var $mds_something;
 
 function mds_get($eid, $column = 'mdxmltext', $must_exist = '')  // none: FALSE
 {
-    if (($mdt = mysql_fetch_array($this->_query("SELECT " . $column . 
+    if (($mdt = mysql_fetch_array($this->_query("SELECT " . $column .
         " FROM " . MDS_TABLE . " WHERE ", $eid)))) return $mdt[$column];
-    
+
     if ($must_exist) give_up($must_exist . $this->_coldat('eid', $eid));
-    
+
     return FALSE;
 }
 
 function mds_get_dc_elements($mdo)  // no record: FALSE
 {
     if (!($mdt = $this->mds_get($mdo->mdo_eid))) return FALSE;
-    
+
     $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE;
-    
+
     $result = array();
     foreach ($mdo->mdo_dcmap_v as $dce => $xp)
     {
         $result[$dce] = $xmlDoc->xmd_value($xp);
     }
-    
+
     return $result;
 }
 
@@ -291,21 +291,21 @@ function mds_get_many($columns, $where_clause)
     $cols = '';
     foreach (explode(',', $columns) as $col) $cols .= "," . trim($col);
     if (!$cols) return;
-    
-    return $this->_query("SELECT " . api_substr($cols, 1) . 
+
+    return $this->_query("SELECT " . api_substr($cols, 1) .
         " FROM " . MDS_TABLE . " WHERE ". $where_clause);
 }
 
 function mds_put($eid, $data, $column = 'mdxmltext', $exists = TRUE)
 {
     if ($exists === TRUE)
-        return $this->_query("UPDATE " . MDS_TABLE . " SET " . 
+        return $this->_query("UPDATE " . MDS_TABLE . " SET " .
             $this->_coldat($column, $data) . " WHERE ", $eid);
     elseif ($exists === FALSE)
-        return $this->_query("INSERT INTO " . MDS_TABLE . " SET " . 
+        return $this->_query("INSERT INTO " . MDS_TABLE . " SET " .
             $this->_coldat($column, $data) . ", ", $eid);
     else  // user doesn't know, check first whether the record exists
-        return $this->mds_put($eid, $data, $column, 
+        return $this->mds_put($eid, $data, $column,
             !($this->mds_get($eid) === FALSE));
 }
 
@@ -316,16 +316,16 @@ function mds_put_dc_elements($mdo, $dcelem)
         $mdt = $mdo->mdo_generate_default_xml_metadata(); $exists = FALSE;
     }
     else $exists = TRUE;
-    
+
     $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE;
-    
+
     foreach ($dcelem as $dce => $value)
     {
         $xmlDoc->xmd_update($mdo->mdo_dcmap_v[$dce], (string) $value);
     }
-    
+
     $this->mds_put($mdo->mdo_eid, '', 'md5', $exists);
-    
+
     return $this->mds_put($mdo->mdo_eid, $xmlDoc->xmd_xml());
 }
 
@@ -348,27 +348,27 @@ function mds_delete_offspring($eid, $sep = '.')
 function mds_delete_many($idarray)
 {
     if (!is_array($idarray) || count($idarray) == 0) return FALSE;
-    
-    return $this->_query("DELETE FROM " . MDS_TABLE . " WHERE eid IN ('" . 
+
+    return $this->_query("DELETE FROM " . MDS_TABLE . " WHERE eid IN ('" .
         implode("','", array_map('addslashes', $idarray)) . "')");
 }
 
-function mds_update_xml_and_mdt($mdo, &$xmlDoc, $mda, $eid, &$traceinfo, 
+function mds_update_xml_and_mdt($mdo, &$xmlDoc, $mda, $eid, &$traceinfo,
         $exists = TRUE)  // note: $xmlDoc and $traceinfo passed by reference
 {
-    foreach (explode("\n", 
+    foreach (explode("\n",
            str_replace("\r", "\n", str_replace("\r\n", "\n", $mda))) as $update)
     {
         if (!$update) continue;
-        
+
         if (($nameLth = strpos($update, '=')))  // e.g. 'gen/tit/str=new'
         {
             if (($text = api_substr($update, $nameLth + 1)) === FALSE) $text = '';
-            
+
             if (!($path = trim(api_substr($update, 0, $nameLth)))) continue;
-            
+
             if (($sc = api_strpos($path, ';')))  // e.g. 'gen/tit,gen/des;str@lang'
-                $xmlDoc->xmd_update_many(api_substr($path, 0, $sc), 
+                $xmlDoc->xmd_update_many(api_substr($path, 0, $sc),
                     api_substr($path, $sc + 1), $text);
             else
                 $xmlDoc->xmd_update($path, $text);
@@ -394,12 +394,12 @@ function mds_update_xml_and_mdt($mdo, &$xmlDoc, $mda, $eid, &$traceinfo,
                 $x = $xmlDoc->xmd_update(trim($update), '');
             }
         }
-        
+
         if ($update) $traceinfo .= $update . '- ';
     }
-    
+
     $mdt = $xmlDoc->xmd_xml();
-    
+
     if ($exists === FALSE)
     {
         $this->mds_put($eid, $mdt, 'mdxmltext', FALSE);
@@ -410,19 +410,19 @@ function mds_update_xml_and_mdt($mdo, &$xmlDoc, $mda, $eid, &$traceinfo,
         $this->mds_put($eid, $mdt, 'mdxmltext');
         $traceinfo .= 'UPDATE ' . $eid . '- ';
     }
-    
+
     return $mdt;
 }
 
 function mdstore($allow_create)
 {
     global $_course; if (!isset($_course)) return;
-    
+
     define('MDS_TABLE', Database::get_course_table(TABLE_METADATA));
 
     if (!api_sql_query("SELECT eid FROM " . MDS_TABLE))
     if ($allow_create)
-        $this->_query("CREATE TABLE " . MDS_TABLE . " (    " . 
+        $this->_query("CREATE TABLE " . MDS_TABLE . " (    " .
                 "eid varchar(250) NOT NULL," .      // entry-id, e.g. doc.1
                 "mdxmltext text default ''," .      // MD-text, XML-formatted
                 "md5 char(32) default ''," .        // hash-validator
@@ -447,7 +447,7 @@ function _query($sql, $eid = '', $sep = '')
 {
     if ($eid) $sql .= $sep ? $this->_coldatstart('eid', $eid . $sep) :
         $this->_coldat('eid', $eid);
-    
+
     return api_sql_query($sql, __FILE__, __LINE__);
 }
 
@@ -459,7 +459,7 @@ function _query($sql, $eid = '', $sep = '')
     modify it under the terms of the GNU General Public License
     as published by the Free Software Foundation; either version 2
     of the License, or (at your option) any later version.
-    
+
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ 64 - 64
main/metadata/md_link.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: class mdobject for Link-type objects
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 class mdobject
@@ -54,28 +54,28 @@ EOD
 function mdo_generate_default_xml_metadata()
 {
     global $iso639_2_code, $ieee_xml;
-    
+
     $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info();
-    
-    if ($xhtDoc->htt_error) 
+
+    if ($xhtDoc->htt_error)
         give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error);
-    
+
     $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc('');
     if ($xhtDoc->xht_xmldoc->error) give_up($xhtDoc->xht_xmldoc->error);
-    
+
     $xhtDoc->xht_param['siteUri'] = make_uri();
-    
-    $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . 
+
+    $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] .
         '.Link.' . $this->mdo_id;  // 2005-05-30: path->sysCode
-    
+
     $xhtDoc->xht_param['location'] = $this->mdo_url . '';
-    
+
     $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code);
     $xhtDoc->xht_param['lang'] =   strtolower($iso639_2_code);
-    
-    $xhtDoc->xht_param['title'] = 
+
+    $xhtDoc->xht_param['title'] =
         $this->mdo_title ? $this->mdo_title : get_lang('MdTitle');
-    
+
     if (($d = $this->mdo_description))
     {
         if ($keywords = $this->_find_keywords($d)) $d = array_pop($keywords);
@@ -83,32 +83,32 @@ function mdo_generate_default_xml_metadata()
     }
     else
         $xhtDoc->xht_param['description'] = get_lang('MdDescription');
-    
-    $xhtDoc->xht_param['coverage'] = $this->mdo_category_title ? 
+
+    $xhtDoc->xht_param['coverage'] = $this->mdo_category_title ?
         $this->mdo_category_title : get_lang('MdCoverage');
 
     if (isset($_user))
     {
-        $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . 
-            api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . 
+        $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" .
+            api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) .
             "\\nEMAIL:".$_user['mail'] . "\\nEND:VCARD\\n";
     }
-    
+
     $xhtDoc->xht_param['dateTime'] = date('Y-m-d');
-    
+
     $xhtDoc->xht_param['format'] = ''; $xhtDoc->xht_param['size'] = '0';
-    
+
     if (count($keywords))
     {
-        $xd = new xmddoc(explode("\n", 
+        $xd = new xmddoc(explode("\n",
             $mdt = $xhtDoc->xht_fill_template('XML')));
         if ($xd->error) return $mdt;  // and worry later
-        
+
         $this->_add_keywords($xd, $keywords);
-        
+
         return $xd->xmd_xml();
     }
-    
+
     return $xhtDoc->xht_fill_template('XML');
 }
 
@@ -118,22 +118,22 @@ function mdo_override(&$xmlDoc)  // by ref!
     if ($this->mdo_url)
     {
         $xmlDoc->xmd_update('metadata/lom/technical/location', $this->mdo_url);
-        
+
         $ge = $xmlDoc->xmd_select_single_element("metadata/lom/general");
-        
+
         $xmlDoc->xmd_update('title[1]/string', $this->mdo_title, $ge);
         $xmlDoc->xmd_update('coverage[1]/string', $this->mdo_category_title, $ge);
-        
+
         if (($d = $this->mdo_description))
             if ($keywords = $this->_find_keywords($d)) $d = array_pop($keywords);
-        
+
         $xmlDoc->xmd_update('description[1]/string', $d, $ge);
-        
+
         $xmlDoc->xmd_remove_nodes($xmlDoc->xmd_select_elements('keyword', $ge), $ge);
-        
+
         if (count($keywords)) $this->_add_keywords($xmlDoc, $keywords);
     }
-    
+
     return $xmlDoc->xmd_xml();
 }
 
@@ -141,34 +141,34 @@ function mdo_override(&$xmlDoc)  // by ref!
 function mdo_storeback(&$xmlDoc)  // by ref!
 {
     if (!$this->mdo_url) return;  // no record in link table, most probably
-    
+
     if (!($v = $xmlDoc->xmd_value('metadata/lom/technical/location'))) return;
-    
+
     if ($v != $this->mdo_url)
     { $this->mdo_url = $v;   $u .= ", url = '" . addslashes($v) . "'"; }
-    
+
     $ge = $xmlDoc->xmd_select_single_element("metadata/lom/general");
-    
+
     $v = $xmlDoc->xmd_value('title[1]/string', $ge);
     if ($v != $this->mdo_title)
     { $this->mdo_title = $v; $u .= ", title = '" . addslashes($v) . "'"; }
-    
+
     $vd = $xmlDoc->xmd_value('description[1]/string', $ge);
     $vk = $xmlDoc->xmd_value('keyword/string', $ge, array('in' => ', '));
-    $v = $vk ? '<i kw="' . htmlspecialchars($vk) . '">' . 
-        ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>', 
+    $v = $vk ? '<i kw="' . htmlspecialchars($vk) . '">' .
+        ereg_replace('\[((/?(b|big|i|small|sub|sup|u))|br/)\]', '<\\1>',
             htmlspecialchars($vd)) . '</i>' : $vd;
-    
+
     if ($v != $this->mdo_description)
     {
-        $this->mdo_description = $v; 
+        $this->mdo_description = $v;
         $u .= ", description = '" . addslashes($v) . "'";
     }
-    
+
     // do not store back a modified coverage as category...
-    
+
     $link_table = Database::get_course_table(TABLE_LINK);
-    if ($u) api_sql_query("UPDATE $link_table SET " . substr($u, 2) . 
+    if ($u) api_sql_query("UPDATE $link_table SET " . substr($u, 2) .
         " WHERE id='" . addslashes($this->mdo_id) . "'", __FILE__, __LINE__);
 }
 
@@ -176,14 +176,14 @@ function mdo_storeback(&$xmlDoc)  // by ref!
 function mdo_add_breadcrump_nav()
 {
     global $interbreadcrumb;
-    
+
     $regs = array(); // for use with ereg()
-    
+
     $docurl = api_get_self();  // should be .../main/xxx/yyy.php
     if (ereg('^(.+[^/\.]+)/[^/\.]+/[^/\.]+.[^/\.]+$', $docurl, $regs))
         $docurl = $regs[1] . '/link/link.php';
-    
-    $interbreadcrumb[]= array ('url' => $docurl, 
+
+    $interbreadcrumb[]= array ('url' => $docurl,
         "name"=> get_lang('MdCallingTool'));
 }
 
@@ -191,25 +191,25 @@ function mdo_add_breadcrump_nav()
 function mdobject($_course, $id)
 {
     global $ieee_dcmap_e, $ieee_dcmap_v;  // md_funcs
-    
+
     $this->mdo_course = $_course; $this->mdo_type = 'Link';
     $this->mdo_id = $id; $this->mdo_eid = $this->mdo_type . '.' . $id;
-    
+
     $this->mdo_dcmap_e = $ieee_dcmap_e; $this->mdo_dcmap_v = $ieee_dcmap_v;
-    
+
     $link_table = Database::get_course_table(TABLE_LINK);
     if (($linkinfo = @mysql_fetch_array(api_sql_query(
-            "SELECT url,title,description,category_id FROM $link_table WHERE id='" . 
+            "SELECT url,title,description,category_id FROM $link_table WHERE id='" .
             addslashes($id) . "'", __FILE__, __LINE__))))
     {
         $this->mdo_url =         $linkinfo['url'];
         $this->mdo_title =       $linkinfo['title'];
         $this->mdo_description = $linkinfo['description'];
         $this->mdo_category =    ($lci = $linkinfo['category_id']);
-        
+
         $linkcat_table = Database::get_course_table(TABLE_LINK_CATEGORY);
         if (($catinfo = @mysql_fetch_array(api_sql_query(
-                "SELECT category_title FROM $linkcat_table WHERE id='" . 
+                "SELECT category_title FROM $linkcat_table WHERE id='" .
                 addslashes($lci) . "'", __FILE__, __LINE__))))
             $this->mdo_category_title =    $catinfo['category_title'];
     }
@@ -219,39 +219,39 @@ function mdobject($_course, $id)
 function _find_keywords($d)
 {
     $dd = new xmddoc($d); if ($dd->error) return NULL;
-    
+
     $regs = array(); // for use with ereg()
-    
+
     foreach ($dd->attributes[0] as $name => $value)
         if ($name == 'kw' && ereg('^<?([^>]+)>?$', $value, $regs))
         {
             $kwa = array_map('trim', explode(',', $regs[1]));
-            
-            if (ereg('^<' . ($tag = $dd->name[0]) . '[^>]*>(.*)</'.$tag.'>$', 
+
+            if (ereg('^<' . ($tag = $dd->name[0]) . '[^>]*>(.*)</'.$tag.'>$',
                     $d, $regs))  // e.g. <i kw="...">A &amp; <b>B</b>!</i>
             {
                 $htdc = array_flip(get_html_translation_table(HTML_ENTITIES));
                 $d = strtr(ereg_replace(  // first  <b>  -> [b] etc.
-                    '<((/?(b|big|i|small|sub|sup|u))|br/)>', '[\\1]', 
+                    '<((/?(b|big|i|small|sub|sup|u))|br/)>', '[\\1]',
                     ($regs[1])), $htdc);  // then  &amp; ->  &  etc.
                 $d = strtr(str_replace("\r\n", " ", $d), "\r\n", "  ");
             }
             else $d = $dd->xmd_text();
-            
+
             array_push($kwa, $d); return $kwa;
         }
-    
+
     return NULL;
 }
 
 function _add_keywords(&$xmlDoc, $keywords)  // by ref!
 {
     $ge = $xmlDoc->xmd_select_single_element("metadata/lom/general");
-    $dl = array("language" => 
+    $dl = array("language" =>
         $xmlDoc->xmd_value("description/string/@language", $ge));
-    
+
     foreach ($keywords as $kw)
-        $xmlDoc->xmd_add_text_element("string", $kw, 
+        $xmlDoc->xmd_add_text_element("string", $kw,
             $xmlDoc->xmd_add_element("keyword", $ge), $dl);
 }
 

+ 16 - 16
main/metadata/md_mix.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: reduced class mdobject for Search, for a Mix of objects
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 class mdobject
@@ -32,43 +32,43 @@ var $mdo_base_url;
 function mdobject($_course, $eid)
 {
     if (!($dotpos = strpos($eid, '.'))) return;
-    
+
     $this->mdo_course = $_course; $this->mdo_eid = $eid;
     $this->mdo_type = ($type = substr($eid, 0, $dotpos));
     $this->mdo_id = ($id = substr($eid, $dotpos + 1));
-    
+
     if ($type == 'Document' || $type == 'Scorm')
     {
-        $table = $type == 'Scorm' ? 
+        $table = $type == 'Scorm' ?
             Database::get_course_table(TABLE_SCORMDOC) :
             Database::get_course_table(TABLE_DOCUMENT);
-    
+
         if (($dotpos = strpos($id, '.')))
         {
             $urlp = '?sid=' . urlencode(substr($id, $dotpos+1));
             $id = substr($id, 0, $dotpos);
         }
-    
+
         if (($docinfo = @mysql_fetch_array(api_sql_query(
-                "SELECT path,comment,filetype FROM 
-                 $table WHERE id='" . 
+                "SELECT path,comment,filetype FROM
+                 $table WHERE id='" .
                 addslashes($id) . "'", __FILE__, __LINE__))))
         {
             $this->mdo_path =     $docinfo['path'];
             $this->mdo_comment =  $docinfo['comment'];
             $this->mdo_filetype = $docinfo['filetype'];
-        
+
             if ($type == 'Scorm')
             {
-                $this->mdo_base_url =  get_course_web() . 
+                $this->mdo_base_url =  get_course_web() .
                     $this->mdo_course['path'] . '/scorm' . $this->mdo_path;
                 $this->mdo_url =  $this->mdo_base_url . '/index.php' . $urlp;
             }
             else
             {
-                $this->mdo_url =  api_get_path(WEB_PATH) . 'main/document/' . 
-                    (($this->mdo_filetype == 'file') ? 'download' : 'document').'.php?'. 
-                    (($this->mdo_filetype == 'file') ? 'doc_url=' : 'curdirpath=') . 
+                $this->mdo_url =  api_get_path(WEB_PATH) . 'main/document/' .
+                    (($this->mdo_filetype == 'file') ? 'download' : 'document').'.php?'.
+                    (($this->mdo_filetype == 'file') ? 'doc_url=' : 'curdirpath=') .
                     urlencode($this->mdo_path);
             }
         }
@@ -77,8 +77,8 @@ function mdobject($_course, $eid)
     {
         $link_table = Database::get_course_table(TABLE_LINK);
         if (($linkinfo = @mysql_fetch_array(api_sql_query(
-                "SELECT url,title,description,category_id FROM 
-                 $link_table WHERE id='" . addslashes($id) . 
+                "SELECT url,title,description,category_id FROM
+                 $link_table WHERE id='" . addslashes($id) .
                 "'", __FILE__, __LINE__))))
         {
             $this->mdo_url = $linkinfo['url'];

+ 64 - 64
main/metadata/md_phpdig.php

@@ -6,29 +6,29 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: PhpDig connection
 *
 *   If PhpDig 1.8.3 is installed in a Dokeos course site, then MD items
 *   can be indexed for search (via PhpDig's search screen search.php).
-*   
-*   The functions below inject the words of metadata/indexabletext directly 
+*
+*   The functions below inject the words of metadata/indexabletext directly
 *   into PhpDig's tables. Affected tables:
-*   
+*
 *   keywords: key_id, twoletters, keyword (lowercase, accents removed)
 *
 *   sites:    site_id, site_url (e.g. http://xx.yy.zz/), upddate, ...
 *
-*   spider:   spider_id, site_id, upddate, num_words, first_words, 
+*   spider:   spider_id, site_id, upddate, num_words, first_words,
 *                   path (e.g. uu/vv/ww/), file (e.g. index.php?sid=xxx), ...
 *
 *   engine:   spider_id, key_id, weight
 *
-*   Most of the function code is a simplified version of real PhpDig code 
+*   Most of the function code is a simplified version of real PhpDig code
 *   released under the GNU GPL V2, see www.phpdig.net.
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -51,12 +51,12 @@ define('SUMMARY_DISPLAY_LENGTH', 700);
 define('PHPDIG_ENCODING', strtolower($charset));
 define('SMALL_WORDS_SIZE', 2);
 define('MAX_WORDS_SIZE',50);
-define('WORDS_CHARS_LATIN1', '[:alnum:]ðþßµ');
+define('WORDS_CHARS_LATIN1', '[:alnum:]��ߵ');
 
-foreach (array( 'A'=>'ÀÁÂÃÄÅ', 'a'=>'àáâãäå', 'O'=>'ÒÓÔÕÖØ', 'o'=>'òóôõöø', 
-                'E'=>'ÈÉÊË', 'e'=>'èéêë', 'C'=>'Ç', 'c'=>'ç', 'I'=>'ÌÍÎÏ', 
-                'i'=>'ìíîï', 'U'=>'ÙÚÛÜ', 'u'=>'ùúûü', 'Y'=>'Ý', 'y'=>'ÿý', 
-                'N'=>'Ñ', 'n'=>'ñ') as $without => $allwith)
+foreach (array( 'A'=>'������', 'a'=>'������', 'O'=>'������', 'o'=>'������',
+                'E'=>'����', 'e'=>'����', 'C'=>'�', 'c'=>'�', 'I'=>'����',
+                'i'=>'����', 'U'=>'����', 'u'=>'����', 'Y'=>'�', 'y'=>'��',
+                'N'=>'�', 'n'=>'�') as $without => $allwith)
     foreach (explode('!', chunk_split($allwith, 1, '!')) as $with)
     if ($with)  // because last one will be empty!
     {
@@ -65,30 +65,30 @@ foreach (array( 'A'=>'
 define('LETTERS_WITH_ACCENTS', $letterswith);
 define('SAME_WITHOUT_ACCENTS', $letterswithout);
 
-(strlen(LETTERS_WITH_ACCENTS) == strlen(SAME_WITHOUT_ACCENTS)) 
+(strlen(LETTERS_WITH_ACCENTS) == strlen(SAME_WITHOUT_ACCENTS))
     or give_up('LETTERS_WITH_ACCENTS problem in md_phpdig.php');
 
 
 function find_site($url)
 {
     $site_url = "site_url = '" . addslashes($url) . "'";
-    
-    $result = api_sql_query("SELECT site_id FROM " . PHPDIG_DB_PREFIX . 
+
+    $result = api_sql_query("SELECT site_id FROM " . PHPDIG_DB_PREFIX .
         "sites WHERE " . $site_url, __FILE__, __LINE__);  // find site
-    
+
     if (mysql_num_rows($result) == 1)
     {
         $row = mysql_fetch_array($result); return (int) $row['site_id'];
     }
     else
     {
-        $result = api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX . 
+        $result = api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX .
             "sites SET " . $site_url, __FILE__, __LINE__);  // new site
         $site_id = mysql_insert_id();
-        
-        $result = api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX . 
+
+        $result = api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX .
             "site_page (site_id,num_page) VALUES ('$site_id', '0')");
-        
+
         return $site_id;
     }
 }
@@ -100,58 +100,58 @@ function remove_engine_entries($url, $path, $file = '')
     $and_path = " AND path = '" . addslashes($path) . "'";
     if ($file) $and_path .= " AND file LIKE '" . addslashes(
         str_replace(array('_', '%'), array('\_', '\%'), $file)) . "%'";
-    
-    $result = api_sql_query("SELECT spider_id FROM " . PHPDIG_DB_PREFIX . 
-        "spider WHERE site_id=" . ($site_id = find_site($url)) . $and_path, 
+
+    $result = api_sql_query("SELECT spider_id FROM " . PHPDIG_DB_PREFIX .
+        "spider WHERE site_id=" . ($site_id = find_site($url)) . $and_path,
         __FILE__, __LINE__);  // find page(s)
-    
+
     while ($row = mysql_fetch_array($result))
     {
-        api_sql_query("DELETE FROM " . PHPDIG_DB_PREFIX . 
-            "engine WHERE spider_id=" . (int)$row['spider_id'], 
+        api_sql_query("DELETE FROM " . PHPDIG_DB_PREFIX .
+            "engine WHERE spider_id=" . (int)$row['spider_id'],
             __FILE__, __LINE__);  // delete all references to keywords
         $aff .= ' +' . mysql_affected_rows();
     }
-    
-    api_sql_query("DELETE FROM " . PHPDIG_DB_PREFIX . 
-        "spider WHERE site_id=" . $site_id . $and_path, 
+
+    api_sql_query("DELETE FROM " . PHPDIG_DB_PREFIX .
+        "spider WHERE site_id=" . $site_id . $and_path,
         __FILE__, __LINE__);  // delete page
-    
-    echo htmlspecialchars($url . $path . $file, ENT_QUOTES, $charset), ' (site_id ', 
-        $site_id, '): ', mysql_affected_rows(), $aff, 
+
+    echo htmlspecialchars($url . $path . $file, ENT_QUOTES, $charset), ' (site_id ',
+        $site_id, '): ', mysql_affected_rows(), $aff,
         ' pages + word references removed from index.<br />';
-    
+
     return $site_id;
 }
 
 function index_words($site_id, $path, $file, $first_words, $keywords)
 {
     global $common_words;
-    
-    $spider_set_path_etc = "spider SET path='" . addslashes($path) . 
-        "',file='" . addslashes($file) . "',first_words='" . 
+
+    $spider_set_path_etc = "spider SET path='" . addslashes($path) .
+        "',file='" . addslashes($file) . "',first_words='" .
         addslashes($first_words) . "',site_id='$site_id'";
         // do not set upddate,md5,num_words,last_modified,filesize
-    
-    api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX . $spider_set_path_etc, 
+
+    api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX . $spider_set_path_etc,
         __FILE__, __LINE__);
-    
+
     $spider_id = mysql_insert_id(); $new = 0;
-    
+
     foreach ($keywords as $key => $w)
-    if (strlen($key) > SMALL_WORDS_SIZE and strlen($key) <= MAX_WORDS_SIZE and 
-            !isset($common_words[$key]) and 
+    if (strlen($key) > SMALL_WORDS_SIZE and strlen($key) <= MAX_WORDS_SIZE and
+            !isset($common_words[$key]) and
             ereg('^['.WORDS_CHARS_LATIN1.'#$]', $key))
     {
-        $result = api_sql_query("SELECT key_id FROM " . PHPDIG_DB_PREFIX . 
-            "keywords WHERE keyword = '" . addslashes($key) . "'", 
+        $result = api_sql_query("SELECT key_id FROM " . PHPDIG_DB_PREFIX .
+            "keywords WHERE keyword = '" . addslashes($key) . "'",
             __FILE__, __LINE__);
-        
+
         if (mysql_num_rows($result) == 0)
         {
-            api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX . 
-                "keywords (keyword,twoletters) VALUES ('" . addslashes($key) . 
-                "','" .addslashes(substr(str_replace('\\','',$key),0,2)) ."')", 
+            api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX .
+                "keywords (keyword,twoletters) VALUES ('" . addslashes($key) .
+                "','" .addslashes(substr(str_replace('\\','',$key),0,2)) ."')",
             __FILE__, __LINE__);
             $key_id = mysql_insert_id(); $new++;
         }
@@ -159,14 +159,14 @@ function index_words($site_id, $path, $file, $first_words, $keywords)
         {
             $keyid = mysql_fetch_row($result); $key_id = $keyid[0];
         }
-        
-        api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX . 
-            "engine (spider_id,key_id,weight) VALUES ($spider_id,$key_id,$w)", 
+
+        api_sql_query("INSERT INTO " . PHPDIG_DB_PREFIX .
+            "engine (spider_id,key_id,weight) VALUES ($spider_id,$key_id,$w)",
             __FILE__, __LINE__);
     }
-        
-    echo '<tr><td>', htmlspecialchars($file, ENT_QUOTES, $charset), '</td><td>(spider_id ', 
-        $spider_id, '):</td><td align="right">', count($keywords), ' kwds, ', 
+
+    echo '<tr><td>', htmlspecialchars($file, ENT_QUOTES, $charset), '</td><td>(spider_id ',
+        $spider_id, '):</td><td align="right">', count($keywords), ' kwds, ',
         $new , ' new</td></tr>', "\n";
 }
 
@@ -176,34 +176,34 @@ function get_first_words($text, $path, $file)
     if (strlen($db_some_text) > SUMMARY_DISPLAY_LENGTH) {
       $db_some_text = substr($db_some_text, 0, SUMMARY_DISPLAY_LENGTH) . "...";
     }
-    
+
     $titre_resume = $path . $file;
     if (($psc = strpos($titre_resume, 'scorm/')) !== FALSE)
         $titre_resume = substr($titre_resume, $psc + 6);
     if (($pth = strpos($titre_resume, '&thumb')) !== FALSE)
         $titre_resume = substr($titre_resume, 0, $pth);
-    
+
     return $titre_resume."\n".$db_some_text;
 }
 
 function get_keywords($text)
 {
     if (($token = strtok(phpdigEpureText($text), ' '))) $nbre_mots[$token] = 1;
-    
+
     while (($token = strtok(' ')))
         $nbre_mots[$token] = ($nm = $nbre_mots[$token]) ? $nm + 1 : 1;
-     
+
     return $nbre_mots;
 }
 
 function phpdigEpureText($text)
 {
-    $text = strtr(phpdigStripAccents(strtolower($text)), 'ÐÞ', 'ðþ');
-    
+    $text = strtr(phpdigStripAccents(strtolower($text)), '��', '��');
+
     $text = ereg_replace('[^'.WORDS_CHARS_LATIN1.' \'._~@#$&%/=-]+',' ',$text);  // RH: was ' \'._~@#$:&%/;,=-]+', also below
-    
+
     $text = ereg_replace('(['.WORDS_CHARS_LATIN1.'])[\'._~@#$&%/=-]+($|[[:space:]]$|[[:space:]]['.WORDS_CHARS_LATIN1.'])','\1\2',$text);
-    
+
     // the next two repeated lines needed
     if (SMALL_WORDS_SIZE >= 1) {
       $text = ereg_replace('[[:space:]][^ ]{1,'.SMALL_WORDS_SIZE.'}[[:space:]]',' ',' '.$text.' ');
@@ -212,13 +212,13 @@ function phpdigEpureText($text)
     //$text = ereg_replace('\.+[[:space:]]|\.+$|\.{2,}',' ',$text);
     $text = ereg_replace('\.{2,}',' ',$text);
     $text = ereg_replace('^[[:space:]]*\.+',' ',$text);
-    
+
     return trim(ereg_replace("[[:space:]]+"," ",$text));
 }
 
 function phpdigStripAccents($chaine)
 {
-    $chaine = str_replace('Æ','ae',str_replace('æ','ae',$chaine));
+    $chaine = str_replace('�','ae',str_replace('�','ae',$chaine));
     return strtr($chaine, LETTERS_WITH_ACCENTS, SAME_WITHOUT_ACCENTS);
 }
 ?>

+ 4 - 4
main/metadata/openobject.php

@@ -6,21 +6,21 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: general script for opening an object
 *
 *   URL parameters:
 *   - eid=  entry-id = object-id = type.identifier, e.g. 'Document.12';
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
 require("md_funcs.php");
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 /*
-$language_file = 'Whatever'; 
+$language_file = 'Whatever';
 */
 require("../inc/global.inc.php");
 $this_section=SECTION_COURSES;

+ 6 - 6
main/metadata/phpdig/config.php

@@ -23,12 +23,12 @@ If you modify code and redistribute, you may ADD your copyright to this notice.
 //-------------CONFIGURATION FILE-------
 //-------------PHP DIG------------------
 
-// NOTE: If you want a different path, you need to add that path (relative path up to the 
-// admin directory: ../dir or full path up to the admin directory: /full/path/to/dir) in 
+// NOTE: If you want a different path, you need to add that path (relative path up to the
+// admin directory: ../dir or full path up to the admin directory: /full/path/to/dir) in
 // the first if statement in this config.php file - for example:
 // && ($relative_script_path != "../dir") // relative path
 // && ($relative_script_path != "/full/path/to/dir") // full path
-// You may also need to set $relative_script_path to this path in search.php, clickstats.php, 
+// You may also need to set $relative_script_path to this path in search.php, clickstats.php,
 // and function_phpdig_form.php depending on what files you are calling from where
 // NOTE: double dot means go back one and single dot means stay in same directory
 // NOTE: the path should be UP TO but NOT INCLUDING the admin directory - NO ending slash
@@ -43,14 +43,14 @@ If you modify code and redistribute, you may ADD your copyright to this notice.
 
 define('ABSOLUTE_SCRIPT_PATH','/full/path/to/dir'); // full path up to but not including admin dir, no end slash
 
-if ((!isset($relative_script_path)) || (($relative_script_path != ".") && 
+if ((!isset($relative_script_path)) || (($relative_script_path != ".") &&
 ($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH))) {
   // echo "\n\nPath $relative_script_path not recognized!\n\n";
   exit();
 }
 
-// NOTE: If you receive an "undefined index" message that means that your server is not recognizing 
-// one or some of the $_SERVER variables so check your PHP info and set the $_SERVER variables to 
+// NOTE: If you receive an "undefined index" message that means that your server is not recognizing
+// one or some of the $_SERVER variables so check your PHP info and set the $_SERVER variables to
 // those recognized by your server: See http://www.php.net/reserved.variables for a list
 // If using RSS (config vars below) there are $_SERVER variables in the custom_search_page.php file too
 

+ 32 - 32
main/metadata/phpdig/search.php

@@ -18,20 +18,20 @@ If you modify code and redistribute, you may ADD your copyright to this notice.
 */
 
 /**
-============================================================================== 
+==============================================================================
 *   Dokeos Metadata: search Dokeos course objects via PhpDig 1.8.6
 *
 *   customized search.php 1.8.6 for Dokeos 1.6 assumes $template == "array"
 *
 *   @package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "md_mix";
 include('../../../main/inc/global.inc.php');
 if (! $is_allowed_in_course) api_not_allowed();
-    
+
 // start of part copied (with some changes) from standard PhpDig search.php
 $relative_script_path = '.';
 $no_connect = 0;
@@ -75,11 +75,11 @@ extract(phpdigHttpVars(
 $_course = api_get_course_info(); $ckw = $_course['path'] . '/CourseKwds.js';
 define('KEYWORDS_CACHE', api_get_path('SYS_COURSE_PATH') . $ckw);
 
-if (file_exists(KEYWORDS_CACHE)) $kcdt = 
+if (file_exists(KEYWORDS_CACHE)) $kcdt =
     htmlspecialchars(date('Y/m/d H:i:s', filemtime(KEYWORDS_CACHE)));
 
 $keywordscache = $kcdt ?
-    '<script type="text/javascript" src="' . api_get_path('WEB_COURSE_PATH') . $ckw . '"></script>' . 
+    '<script type="text/javascript" src="' . api_get_path('WEB_COURSE_PATH') . $ckw . '"></script>' .
     '<br /><small><i>(CourseKwds cache: ' . $kcdt . ')</i></small>' : '';
 
 
@@ -95,19 +95,19 @@ $htmlHeadXtra[] = '
     {
         var mdsc = getObj("mdsc");
         if (!mdsc) { alert("? Form does not contain mdsc"); return false; }
-        
+
         mdsc.value = s; return true;
     }
     function checkEnter(ev)
     {
         if (!ev) ev = window.event;
-        
+
         if (ev.altKey) {alert(document.getElementById("kwds_string").value); return;}
-        
+
         if (ev.keyCode == 13)
         {
-            document.getElementById("kwdswere_string").value = 
-                document.getElementById("kwds_string").value; 
+            document.getElementById("kwdswere_string").value =
+                document.getElementById("kwds_string").value;
             if (prepSearch(ev)) getObj("form_submit").form.submit();
         }
     }
@@ -116,16 +116,16 @@ $htmlHeadXtra[] = '
 
 Display::display_header($nameTools); echo "\n";
 
-echo '<table width="100%"><tr><td><h3>', get_lang('Search'), '</h3></td>', 
+echo '<table width="100%"><tr><td><h3>', get_lang('Search'), '</h3></td>',
     '<td align="right"><a href="http://www.phpdig.net"><img src="phpdig_powered_2.gif"/></a></td></tr></table>';
 
 
-// Store new extra criteria (course manager only, see below), or execute 
+// Store new extra criteria (course manager only, see below), or execute
 // PhpDig Search and echo result message + table with results + pages bar
 
 if (!$query_string) $query_string = trim($mdsc);
 
-$ckwcdt = file_exists($ckwc = KEYWORDS_CACHE . 'c') ? 
+$ckwcdt = file_exists($ckwc = KEYWORDS_CACHE . 'c') ?
     date('Y/m/d H:i:s', filemtime($ckwc)) : '?'; $pkwc = '';
 
 if (substr($query_string, 0, 2) == '<>' && api_is_allowed_to_edit())
@@ -135,22 +135,22 @@ if (substr($query_string, 0, 2) == '<>' && api_is_allowed_to_edit())
         $fckwc = fopen($ckwc, 'rb'); $pkwc = fread($fckwc, filesize($ckwc));
         fclose($fckwc); unset($fckwc);
     }
-    
+
     if(($fckwc = fopen($ckwc, 'wb')))
     {
         fwrite($fckwc, $query_string); fclose($fckwc); unset($fckwc);
-        $ckwcdt = file_exists($ckwc) ? 
+        $ckwcdt = file_exists($ckwc) ?
             date('Y/m/d H:i:s', filemtime($ckwc)) : '? Write Error';
     }
     else $ckwcdt = '? Open Error';
-    
-    $phpdigSearchResults = array('result_message' => $ckw . 'c: ' . $ckwcdt, 
+
+    $phpdigSearchResults = array('result_message' => $ckw . 'c: ' . $ckwcdt,
         'pages_bar' => '', 'results' => array());
 }
 else
 {
-    $phpdigSearchResults = phpdigSearch($id_connect, $query_string, $option, 
-        $refine, $refine_url, $lim_start, $limite, $browse, $site, $path, 
+    $phpdigSearchResults = phpdigSearch($id_connect, $query_string, $option,
+        $refine, $refine_url, $lim_start, $limite, $browse, $site, $path,
         $relative_script_path, $template, $adlog_flag, $rssdf, $template_demo);
 }
 
@@ -171,7 +171,7 @@ echo $result_message, '<br><br><table border="1">', "\n";
 if ($phpdigSearchResults['results']) foreach ($phpdigSearchResults['results'] as $searchResult)
 {
     $url = $searchResult['complete_path'];
-    
+
     if (ereg("/[^?/]*\\?.*thumb=", $url))
     {
         // direct URL: $thumburl = ereg_replace("/[^?/]*\\?.*thumb=", "/", $url);
@@ -182,22 +182,22 @@ if ($phpdigSearchResults['results']) foreach ($phpdigSearchResults['results'] as
         $thumburl = "tpl_img/link.gif";
     }
 
-    echo '<tr><td align="center"><a target="_blank" href="', $url, '"><img src="', $thumburl, 
-        '"/></a></td><td><a target="_blank" href="', $url, '">', $searchResult['link_title'], 
+    echo '<tr><td align="center"><a target="_blank" href="', $url, '"><img src="', $thumburl,
+        '"/></a></td><td><a target="_blank" href="', $url, '">', $searchResult['link_title'],
         '</a><br>', $searchResult['text'], '</td></tr>', "\n";
 }
 
 echo '</table><br>';
 
 if ($result_message && ($hits > 10))
-    echo "Results page ", str_replace('?template_demo=', 
+    echo "Results page ", str_replace('?template_demo=',
         '?kwdswere_string=' . urlencode($kwdswere_string), $pages_bar), '<br><br>';
 
 /*  Extra criteria: A course manager can define and edit them in the TEXTAREA.
-    If he types in something as in the example below, and clicks 'Go', the new 
-    criteria are stored and the old ones are displayed. So it is easy to 
+    If he types in something as in the example below, and clicks 'Go', the new
+    criteria are stored and the old ones are displayed. So it is easy to
     restore the old ones. To confirm the new ones, empty the TEXTAREA.
-    
+
 <>This selection empties extra criteria
 <searchword>Label
 <keyword-kw>Descriptive text
@@ -209,21 +209,21 @@ $tdhtm = '';
 function tdhtm($xc)
 {
     $eol = '<br/>'; if ($xc{0} == '<') $xc = substr($xc, 1);
-    
+
     if (($eov = strpos($xc, '>')) === FALSE)
             $value = $label = $xc;
     else
     {
         $value = substr($xc, 0, $eov); $label = substr($xc, $eov+1);
-        
+
         if (($eot = strpos($label, '<')) !== FALSE)
         {
             $eol = substr($label, $eot); $label = substr($label, 0, $eot);
         }
     }
-    
-    return '<input type="radio" name="xc" onclick="mdscSet(' . "'" . 
-        htmlspecialchars($value) . "'" . ')">' . 
+
+    return '<input type="radio" name="xc" onclick="mdscSet(' . "'" .
+        htmlspecialchars($value) . "'" . ')">' .
         htmlspecialchars($label) . '</input>' . $eol;
 }
 

+ 20 - 20
main/metadata/playscormmdset.inc.php

@@ -6,20 +6,20 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: include file for accessing Scorm metadata
 *
-*   This script is to be included from /coursedir/scorm/dir.../index.php, 
+*   This script is to be included from /coursedir/scorm/dir.../index.php,
 *   after setting $scormid (Dokeos document root).
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
 // PRELIMS -------------------------------------------------------------------->
 
-if (!isset($scormid)) exit(); 
+if (!isset($scormid)) exit();
 
 define('EID_TYPE', 'Scorm');
 define('BID', EID_TYPE . '.' . $scormid);
@@ -46,7 +46,7 @@ if (HTT != 'mdp_' . strtolower(EID_TYPE))   $urlp .= '&lfn=' . urlencode(HTT);
 if (WHF != '0')                             $urlp .= '&whf=' . urlencode(WHF);
 if (RNG != '*')                             $urlp .= '&rng=' . urlencode(RNG);
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = LFN;
 require('../inc/global.inc.php');
 $nameTools = get_lang('Tool');
@@ -74,14 +74,14 @@ if (!file_exists(DIRECTORY)) give_up('No such directory: ' . DIRECTORY);
 
 $topdir = strtolower(realpath(DR));  // to stop search for .htt file
 
-if (strpos(strtolower(realpath(DIRECTORY)), $topdir) !== 0) 
+if (strpos(strtolower(realpath(DIRECTORY)), $topdir) !== 0)
     give_up('Invalid directory: ' . DIRECTORY);
 
 chdir(DIRECTORY);
 
 for ($i = 0; $i < 10; $i++)
     if(!file_exists(HTT . '.htt'))
-        if (strtolower(realpath(getcwd())) == $topdir) {break;} 
+        if (strtolower(realpath(getcwd())) == $topdir) {break;}
         else chdir('..');
 
 
@@ -94,16 +94,16 @@ $mdStore = new mdstore($is_allowed_to_edit);
 if (($mdt_rec = $mdStore->mds_get(EID)) === FALSE)  // no record, default XML
      $mdt = $mdObj->mdo_generate_default_xml_metadata();
 else $mdt = $mdt_rec;
-    
+
 $xhtxmldoc = new xmddoc(explode("\n", $mdt));
 
 (!$xhtxmldoc->error) or give_up($xhtxmldoc->error);
 
-if (SID == $id_range_first && 
+if (SID == $id_range_first &&
         ($prv = $xhtxmldoc->xmd_select_single_element('previous')) != -1)
     $xhtxmldoc->xmd_remove_element($prv);
 
-if (SID == $id_range_last && 
+if (SID == $id_range_last &&
         ($nxt = $xhtxmldoc->xmd_select_single_element('next')) != -1)
     $xhtxmldoc->xmd_remove_element($nxt);
 
@@ -112,27 +112,27 @@ $before_first = $id_range_first ? TRUE : FALSE; $after_last = FALSE;
 foreach ($xhtxmldoc->xmd_select_elements('child') as $chEl)
 {
     $chId = $xhtxmldoc->attributes[$chEl]['identifier'];  // no get_att yet...
-    
+
     if ($after_last ||
         ($before_first = $before_first && $chId != $id_range_first))
     {
         $xhtxmldoc->xmd_remove_element($chEl); continue;
     }
-    
+
     if (($mdt_rec = $mdStore->mds_get(BID . '.' . $chId)) === FALSE)
          $mdt = $mdObj->mdo_generate_default_xml_metadata();
     else $mdt = $mdt_rec;
-        
+
     $xhtxmldocchild = new xmddoc(explode("\n", $mdt));
-    
+
     (!$xhtxmldocchild->error) or give_up($chId . ': ' . $xhtxmldocchild->error);
-    
+
     // make stuff below a parameter? copy some already in importmanifest?
-    $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild, 
+    $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild,
         $xhtxmldocchild->xmd_select_single_element('title'), $chEl);
-    $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild, 
+    $xhtxmldoc->xmd_copy_foreign_child($xhtxmldocchild,
         $xhtxmldocchild->xmd_select_single_element('resource'), $chEl);
-    
+
     $after_last = $after_last || $chId == $id_range_last;
 }
 
@@ -169,7 +169,7 @@ else
     	}
     }
     ?>
-    <!DOCTYPE html 
+    <!DOCTYPE html
          PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $document_language; ?>" lang="<?php echo $document_language; ?>">
@@ -202,7 +202,7 @@ else
 echo "\n";
 
 $xhtDoc->xht_dbgn = DBG;  // for template debug info, set to e.g. 10000
-if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] = 
+if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] =
     '<h5>Trace information</h5>' . htmlspecialchars($ti, ENT_QUOTES, $charset);
 
 echo $xhtDoc->xht_fill_template('METADATA'), "\n";

+ 21 - 21
main/metadata/search.php

@@ -6,7 +6,7 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: search Dokeos course objects via their metadata
 *
 *   URL parameters:
@@ -15,7 +15,7 @@
 *   - htt=  HTML template file (same dir as script), default= 'mds_' + type.
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -36,7 +36,7 @@ if (LFN != 'md_' . strtolower(TYPE))     $urlp .= '&lfn=' . urlencode(LFN);
 if (HTT != 'mds_' . strtolower(TYPE))    $urlp .= '&htt=' . urlencode(HTT);
 if (DBG)                     $urlp .= '&dbg=' . urlencode(DBG);
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = LFN; require("../inc/global.inc.php");
 $this_section=SECTION_COURSES;
 
@@ -54,7 +54,7 @@ $xhtDoc = define_htt(HTT . '.htt', $urlp, $_course['path']);
 
 $xhtDoc->xht_param['type'] = TYPE;
 
-$xhtDoc->xht_param['index'] = 
+$xhtDoc->xht_param['index'] =
     str_replace('/search.php', '/index.php', api_get_self());
 
 
@@ -75,45 +75,45 @@ $xmlDoc = new xmddoc(''); if ($xmlDoc->error) give_up($xmlDoc->error);
 
 if (isset($_POST['mdsc']))  // Search criteria
 {
-    $mdsc = str_replace("\r", "\n", str_replace("\r\n", "\n", 
+    $mdsc = str_replace("\r", "\n", str_replace("\r\n", "\n",
         get_magic_quotes_gpc() ? stripslashes($_POST['mdsc']) : $_POST['mdsc']));
-        
+
     foreach (explode("\n", $mdsc) as $word) if (($word = trim($word)))
     {
         $words .= ", " . $word;
-        
+
         $where .= " AND indexabletext " . ($word{0} != '-' ?
              ("LIKE '%".addslashes($word)."%'") :
              ("NOT LIKE '%".addslashes(substr($word, 1))."%'"));
     }
-    
+
     if ($where)
     {
         $whereclause = substr($where, 5);  // remove first " AND "
-        
+
         $xhtDoc->xht_xmldoc->xmd_add_text_element('query', $whereclause);
         $xhtDoc->xht_param['traceinfo'] = substr($words, 2);
-        
+
         $result = $mdStore->mds_get_many('eid,mdxmltext', $whereclause);
-        
+
         while (($myrow = @mysql_fetch_array($result)))
         {
             // not quite a real manifest, but very much like one...
-            
+
             $eid = $myrow['eid']; $xmlDoc = new xmddoc($myrow['mdxmltext']);
             if ($xmlDoc->error) give_up('Entry '.$eid . ': ' . $xmlDoc->error);
-            
+
             $mdObj = new mdobject($_course, $eid);  // md_mix.php
-            
+
             $xhtDoc->xht_xmldoc->xmd_copy_foreign_child($xmlDoc);
             $newItem = $xhtDoc->xht_xmldoc->
                 xmd_select_single_element('item[-1]');
             $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'eid', $eid);
-            $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'url', 
+            $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'url',
                 $mdObj->mdo_url);
-            
+
             if ($mdObj->mdo_type == 'Scorm')
-                $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'brl', 
+                $xhtDoc->xht_xmldoc->xmd_set_attribute($newItem, 'brl',
                     $mdObj->mdo_base_url);
         }
     }
@@ -123,14 +123,14 @@ if (isset($_POST['mdsc']))  // Search criteria
 function check_is_thumb($p)  // escape function, see mds_mix.htt
 {
     global $xhtDoc; if ($p !== FALSE) return '';  // should not happen
-    
+
     if (!ereg('^pptsl[0-9]+_t\.jpg$', $xhtDoc->xht_param['thumb']))
         $xhtDoc->xht_param['thumb'] = '';
-    
+
     return '';
 }
 
-    
+
 // GENERATE OUTPUT ------------------------------------------------------------>
 
 foreach (explode("\n", $xhtDoc->htt_array['HTTP']) as $httpXtra)
@@ -149,7 +149,7 @@ $htmlHeadXtra[] = $xhtDoc->xht_fill_template('HEAD');
 Display::display_header($nameTools);
 
 $xhtDoc->xht_dbgn = DBG;  // for template debug info, set to e.g. 10000
-if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] = 
+if (($ti = $xhtDoc->xht_param['traceinfo'])) $xhtDoc->xht_param['traceinfo'] =
     '<b>' . get_lang('Search') . '</b>: ' . htmlspecialchars($ti, ENT_QUOTES, $charset);
 
 echo $xhtDoc->xht_fill_template('MDSEARCH'), "\n";

+ 11 - 11
main/metadata/statistics.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: statistics about metadata
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -21,14 +21,14 @@ require('md_funcs.php');
 define('EID_TYPE', 'Mix');
 require('md_' . strtolower(EID_TYPE) . '.php');
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = 'md_mix';
 include('../inc/global.inc.php');
 $this_section=SECTION_COURSES;
 
 $nameTools = get_lang('Tool');
 
-($nameTools && get_lang('Sorry')) or give_up( 
+($nameTools && get_lang('Sorry')) or give_up(
     'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'");
 
 $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
@@ -72,7 +72,7 @@ $kwds = array(); $kwcnt = array(); $kwrefs = array();
 
 while (($kwline = fgets($myFile)))
 {
-    if (ereg('°>(.+)<°', $kwline, $regs) || ereg('">(.+)<°', $kwline, $regs))
+    if (ereg('�>(.+)<�', $kwline, $regs) || ereg('">(.+)<�', $kwline, $regs))
         foreach (explode(',', $regs[1]) as $kw)
             if (!in_array($kw = strtr(trim($kw), $htmldecode), $kwds))
                 $kwds []= $kw;
@@ -87,11 +87,11 @@ echo count($kwds), ' ', get_lang('CourseKwds'), '<br>', "\n";
 while ($row = mysql_fetch_array($result))
 {
     $eid = $row['eid']; $curr = ''; $xmltext = $row['mdxmltext']; $offset = 0;
-    
+
     if (substr($eid, 0, 6) == 'Scorm.')
         if (($dotpos = strpos($eid, '.', 6)) && $dotpos + 1 < strlen($eid))
             $curr = substr($eid, 0, $dotpos);
-                
+
     while (($start = strpos($xmltext, '<keyword>', $offset)))
         if (($start = strpos($xmltext, '">', $start + 9)))
         {
@@ -101,8 +101,8 @@ while ($row = mysql_fetch_array($result))
                 if (!in_array($kw, $kwds))
                 {
                     if (!in_array($kw = '!' . $kw, $kwds)) $kwds []= $kw;
-                    $kwrefs[$kw] .= ' ' . ($curr ? 
-                        (strpos($kwrefs[$kw], $curr) ? 
+                    $kwrefs[$kw] .= ' ' . ($curr ?
+                        (strpos($kwrefs[$kw], $curr) ?
                             substr($eid, $dotpos+1) : $eid) : $eid);
                 }
                 $kwcnt[$kw] ++;  // = $kwcnt[$kw] ? $kwcnt[$kw] + 1 : 1;
@@ -112,7 +112,7 @@ while ($row = mysql_fetch_array($result))
             // <keyword><string language="en">lecture</string></keyword>
         }
         else $offset = $start + 9;
-    
+
     // xmd would be nicer but this is faster...
 }
 
@@ -125,7 +125,7 @@ echo '<h4>', get_lang('NonCourseKwds'), '</h4>', "\n";
 
 foreach ($kwds as $kw)
     if ($kw{0} == '!')
-        echo '<b>', htmlspecialchars(api_substr($kw, 1), ENT_QUOTES, $charset), '</b>: ', $kwcnt[$kw], 
+        echo '<b>', htmlspecialchars(api_substr($kw, 1), ENT_QUOTES, $charset), '</b>: ', $kwcnt[$kw],
             ': <i>', htmlspecialchars($kwrefs[$kw], ENT_QUOTES, $charset), ";</i> \n";
     else break;
 

+ 7 - 7
main/metadata/update_indexabletext.php

@@ -6,11 +6,11 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 *	Dokeos Metadata: update indexabletext for all eid_type records
 *
 *	@package dokeos.metadata
-============================================================================== 
+==============================================================================
 */
 
 
@@ -23,14 +23,14 @@ define('TPLEN', strlen(EID_TYPE) + 1);
 
 require('md_' . strtolower(EID_TYPE) . '.php');
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = 'md_' . strtolower(EID_TYPE);
 include('../inc/global.inc.php');
 $this_section=SECTION_COURSES;
 
 $nameTools = get_lang('Tool');
 
-($nameTools && get_lang('Sorry')) or give_up( 
+($nameTools && get_lang('Sorry')) or give_up(
     'Language file ' . $language_file . " doesn't define 'Tool' and 'Sorry'");
 
 $_course = api_get_course_info(); isset($_course) or give_up(get_lang('Sorry'));
@@ -62,10 +62,10 @@ while ($row = mysql_fetch_array($result))
 {
     $eid = $row['eid']; $xmltext = $row['mdxmltext'];
     $xhtDoc->xht_xmldoc = new xmddoc(explode("\n", $xmltext));
-    
-    $mdStore->mds_put($eid, 
+
+    $mdStore->mds_put($eid,
         $xhtDoc->xht_fill_template('INDEXABLETEXT'), 'indexabletext');
-    
+
     echo htmlspecialchars($eid, ENT_QUOTES, $charset), ' ';
 }
 

+ 65 - 65
main/newscorm/aicc.class.php

@@ -36,7 +36,7 @@ class aicc extends learnpath {
 	var $deslist = array();
 	var $cstlist = array();
 	var $orelist = array();
-	
+
 	var $subdir = ''; //path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package
 	var $zipname = ''; //keeps the zipfile safe for the object's life so that we can use it if no title avail
 	var $lastzipnameindex = 0; //keeps an index of the number of uses of the zipname so far
@@ -69,7 +69,7 @@ class aicc extends learnpath {
     /**
      * Parses a set of AICC config files and puts everything into the $config array
      * @param	string	Path to the config files dir on the system. If not defined, uses the base path of the course's scorm dir
-	 * @return	array	Structured array representing the config files' contents 
+	 * @return	array	Structured array representing the config files' contents
      */
      function parse_config_files($dir='')
      {
@@ -82,7 +82,7 @@ class aicc extends learnpath {
      	{
      		// Now go through all the config files one by one and parse everything into
      		// AICC objects.
-     		
+
      		// The basename for the config files is stored in $this->config_basename
 
      		// Parse the Course Description File (.crs) - ini-type
@@ -90,7 +90,7 @@ class aicc extends learnpath {
      		$crs_params = $this->parse_ini_file_quotes_safe($crs_file);
      		//echo '<pre>crs:'.print_r($crs_params,true).'</pre>';
 	    	if($this->debug>1){error_log('New LP - In aicc::parse_config_files() - '.$crs_file.' has been parsed',0);}
-			
+
 			//CRS distribute crs params into the aicc object
 			if(!empty($crs_params['course']['course_creator'])){
 				$this->course_creator = mysql_real_escape_string($crs_params['course']['course_creator']);
@@ -131,7 +131,7 @@ class aicc extends learnpath {
 			if(!empty($crs_params['course_description'])){
 				$this->course_description = mysql_real_escape_string($crs_params['course_description']);
 			}
-     		
+
      		// Parse the Descriptor File (.des) - csv-type
      		$des_file = $dir.'/'.$this->config_files['des'];
     		$des_params = $this->parse_csv_file($des_file);
@@ -141,9 +141,9 @@ class aicc extends learnpath {
 			foreach($des_params as $des){
 				//one AU in AICC is equivalent to one SCO in SCORM (scormItem class)
 				$oDes = new aiccResource('config',$des);
-				$this->deslist[$oDes->identifier] = $oDes;				
+				$this->deslist[$oDes->identifier] = $oDes;
 			}
-			
+
      		// Parse the Assignable Unit File (.au) - csv-type
      		$au_file = $dir.'/'.$this->config_files['au'];
      		$au_params = $this->parse_csv_file($au_file);
@@ -155,7 +155,7 @@ class aicc extends learnpath {
 				$this->aulist[$oAu->identifier] = $oAu;
 				$this->au_order_list[] = $oAu->identifier;
 			}
-     	
+
      		// Parse the Course Structure File (.cst) - csv-type
      		$cst_file = $dir.'/'.$this->config_files['cst'];
      		$cst_params = $this->parse_csv_file($cst_file,',','"',true);
@@ -166,7 +166,7 @@ class aicc extends learnpath {
 				$oCst = new aiccBlock('config',$cst);
 				$this->cstlist[$oCst->identifier] = $oCst;
 			}
-			
+
      		// Parse the Objectives Relationships File (.ore) - csv-type - if exists
      		//TODO @TODO implement these objectives. For now they're just parsed
      		if(!empty($this->config_files['ore'])){
@@ -199,7 +199,7 @@ class aicc extends learnpath {
 						$this->aulist[strtolower($pre['structure_element'])]->prereq_string = strtolower($pre['prerequisite']);
 					}
 				}
-     		}     	
+     		}
 
      		// Parse the Completion Requirements File (.cmp) - csv-type - if exists
      		//TODO @TODO implement this set of requirements (needs database changes)
@@ -213,13 +213,13 @@ class aicc extends learnpath {
 					//$oCmp = new aiccCompletionRequirements('config',$cmp);
 					//$this->cmplist[$oCmp->identifier] =& $oCmp;
 				}
-     		}     	
+     		}
      	}
      	return $this->config;
      }
      /**
       * Import the aicc object (as a result from the parse_config_files function) into the database structure
-      * @param	string	Unique course code 
+      * @param	string	Unique course code
       * @return	bool	Returns -1 on error
       */
      function import_aicc($course_code){
@@ -227,14 +227,14 @@ class aicc extends learnpath {
      	//get table names
      	$new_lp = 'lp';
      	$new_lp_item = 'lp_item';
-     	
+
      	//The previous method wasn't safe to get the database name, so do it manually with the course_code
      	$sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." WHERE code='$course_code'";
         $res = api_sql_query($sql,__FILE__,__LINE__);
         if(Database::num_rows($res)<1){ error_log('New LP - Database for '.$course_code.' not found '.__FILE__.' '.__LINE__,0);return -1;}
         $row = Database::fetch_array($res);
         $dbname = Database::get_course_table_prefix().$row['db_name'].Database::get_database_glue();
-		
+
 		$new_lp = Database::get_course_table(TABLE_LP_MAIN);
 		$new_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     	$get_max = "SELECT MAX(display_order) FROM $new_lp";
@@ -247,7 +247,7 @@ class aicc extends learnpath {
     	}
 
 		$this->config_encoding = "ISO-8859-1";
-		
+
 		$sql = "INSERT INTO $new_lp " .
 				"(lp_type, name, ref, description, " .
 				"path, force_commit, default_view_mod, default_encoding, " .
@@ -262,7 +262,7 @@ class aicc extends learnpath {
 		$this->lp_id = $lp_id;
 		api_item_property_update(api_get_course_info($course_code),TOOL_LEARNPATH,$this->lp_id,'LearnpathAdded',api_get_user_id());
 		api_item_property_update(api_get_course_info($course_code),TOOL_LEARNPATH,$this->lp_id,'visible',api_get_user_id());
-		
+
 		$previous = 0;
 		foreach($this->aulist as $identifier => $dummy)
 		{
@@ -310,7 +310,7 @@ class aicc extends learnpath {
      }
  	 /**
 	  * Intermediate to import_package only to allow import from local zip files
-	  * @param	string	Path to the zip file, from the dokeos sys root 
+	  * @param	string	Path to the zip file, from the dokeos sys root
 	  * @param	string	Current path (optional)
 	  * @return string	Absolute path to the AICC description files or empty string on error
 	  */
@@ -321,7 +321,7 @@ class aicc extends learnpath {
 	 	$file_info['tmp_name'] = $file_path;
 	 	$file_info['name'] = basename($file_path);
 	 	//call the normal import_package function
-	 	return $this->import_package($file_info,$current_dir); 
+	 	return $this->import_package($file_info,$current_dir);
 	 }
      /**
       * Imports a zip file (presumably AICC) into the Dokeos structure
@@ -335,13 +335,13 @@ class aicc extends learnpath {
      	$maxFilledSpace = 1000000000;
      	$zip_file_path = $zip_file_info['tmp_name'];
      	$zip_file_name = $zip_file_info['name'];
-     	
+
      	if($this->debug>0){error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name,0);}
      	$course_rel_dir  = api_get_course_path().'/scorm'; //scorm dir web path starting from /courses
 		$course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; //absolute system path for this course
 		$current_dir = replace_dangerous_char(trim($current_dir),'strict'); //current dir we are in, inside scorm/
      	if($this->debug>0){error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir,0);}
-     	
+
  		//$uploaded_filename = $_FILES['userFile']['name'];
 		//get name of the zip file without the extension
 		if($this->debug>0){error_log('New LP - aicc::import_package() - Received zip file name: '.$zip_file_path,0);}
@@ -350,13 +350,13 @@ class aicc extends learnpath {
 		$extension = $file_info['extension'];
 		$file_base_name = str_replace('.'.$extension,'',$filename); //filename without its extension
 		$this->zipname = $file_base_name; //save for later in case we don't have a title
-		
+
 		if($this->debug>0){error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name,0);}
 		$new_dir = replace_dangerous_char(trim($file_base_name),'strict');
 		$this->subdir = $new_dir;
 		if($this->debug>0){error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir,0);}
-	
-/*		
+
+/*
 		if( check_name_exist($course_sys_dir.$current_dir."/".$new_dir) )
 		{
 			$dialogBox = get_lang('FileExists');
@@ -364,7 +364,7 @@ class aicc extends learnpath {
 		}
 */
 		$zipFile = new pclZip($zip_file_path);
-	
+
 		// Check the zip content (real size and file extension)
 
 		$zipContentArray = $zipFile->listContent();
@@ -381,12 +381,12 @@ class aicc extends learnpath {
 			if ( preg_match('~.(php.*|phtml)$~i', $thisContent['filename']) )
 			{
 				//if a php file is found, do not authorize (security risk)
-				if($this->debug>1){error_log('New LP - aicc::import_package() - Found unauthorized file: '.$thisContent['filename'],0);}		
+				if($this->debug>1){error_log('New LP - aicc::import_package() - Found unauthorized file: '.$thisContent['filename'],0);}
 				return api_failure::set_failure('php_file_in_zip_file');
 			}elseif(preg_match('?.*/aicc/$?',$thisContent['filename'])){
 				//if a directory named 'aicc' is found, package type = aicc, but continue
-				//because we need to find the right AICC files 
-				if($this->debug>1){error_log('New LP - aicc::import_package() - Found aicc directory: '.$thisContent['filename'],0);}		
+				//because we need to find the right AICC files
+				if($this->debug>1){error_log('New LP - aicc::import_package() - Found aicc directory: '.$thisContent['filename'],0);}
 				$package_type = 'aicc';
 			}else{
 				//else, look for one of the files we're searching for (something.crs case insensitive)
@@ -406,7 +406,7 @@ class aicc extends learnpath {
 						if(!$subdir_isset){
 							if(preg_match('?^.*/aicc$?i',dirname($thisContent['filename']))){
 								//echo "Cutting subdir<br/>";
-								$this->subdir .= '/'.substr(dirname($thisContent['filename']),0,-5);							
+								$this->subdir .= '/'.substr(dirname($thisContent['filename']),0,-5);
 							}else{
 								//echo "Not cutting subdir<br/>";
 								$this->subdir .= '/'.dirname($thisContent['filename']);
@@ -422,7 +422,7 @@ class aicc extends learnpath {
 					}
 					$package_type = 'aicc';
 				}else{
-					if($this->debug>3){error_log('New LP - aicc::import_package() - File '.$thisContent['filename'].' didnt match any check',0);}		
+					if($this->debug>3){error_log('New LP - aicc::import_package() - File '.$thisContent['filename'].' didnt match any check',0);}
 				}
 			}
 			$realFileSize += $thisContent['size'];
@@ -433,7 +433,7 @@ class aicc extends learnpath {
 		foreach($files_found as $file_name => $file_exts){
 			$temp = (
 				!empty($files_found[$file_name]['crs'])
-				AND !empty($files_found[$file_name]['au']) 
+				AND !empty($files_found[$file_name]['au'])
 				AND !empty($files_found[$file_name]['des'])
 				AND !empty($files_found[$file_name]['cst'])
 			);
@@ -449,18 +449,18 @@ class aicc extends learnpath {
 				break;
 			}
 		}
-		
+
 		if($package_type== '' OR $mandatory!=true)
 		 // && defined('CHECK_FOR_AICC') && CHECK_FOR_AICC)
 		{
 			return api_failure::set_failure('not_aicc_content');
 		}
-	
+
 		if (! enough_size($realFileSize, $course_sys_dir, $maxFilledSpace) )
 		{
 			return api_failure::set_failure('not_enough_space');
 		}
-	
+
 		// it happens on Linux that $new_dir sometimes doesn't start with '/'
 		if($new_dir[0] != '/')
 		{
@@ -471,7 +471,7 @@ class aicc extends learnpath {
 		{
 			$new_dir=substr($new_dir,0,-1);
 		}
-	
+
 		/*
 		--------------------------------------
 			Uncompressing phase
@@ -493,13 +493,13 @@ class aicc extends learnpath {
 			for($j=0;$j<count($unzippingState);$j++)
 			{
 				$state=$unzippingState[$j];
-	
+
 				//TODO fix relative links in html files (?)
 				$extension = strrchr($state["stored_filename"], ".");
 				//if($this->debug>1){error_log('New LP - found extension '.$extension.' in '.$state['stored_filename'],0);}
-				
+
 			}
-	
+
 			if(!empty($new_dir))
 			{
 				$new_dir = $new_dir.'/';
@@ -513,15 +513,15 @@ class aicc extends learnpath {
 					if($file != '.' && $file != '..')
 					{
 						$filetype="file";
-	
+
 						if(is_dir($course_sys_dir.$new_dir.$file)) $filetype="folder";
-						
+
 						//TODO RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
 						//$safe_file=replace_dangerous_char($file,'strict');
 						$find_str = array('\\','.php','.phtml');
 						$repl_str = array('/', '.txt','.txt');
 						$safe_file = str_replace($find_str,$repl_str,$file);
-	
+
 						if($safe_file != $file){
 							//@rename($course_sys_dir.$new_dir,$course_sys_dir.'/'.$safe_file);
 							$mydir = dirname($course_sys_dir.$new_dir.$safe_file);
@@ -540,11 +540,11 @@ class aicc extends learnpath {
 							}
 							@rename($course_sys_dir.$new_dir.$file,$course_sys_dir.$new_dir.$safe_file);
 							if($this->debug==1){error_log('New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file,0);}
-						}	
+						}
 						//set_default_settings($course_sys_dir,$safe_file,$filetype);
 					}
 				}
-	
+
 				closedir($dir);
 				chdir($saved_dir);
 			}
@@ -569,7 +569,7 @@ class aicc extends learnpath {
 	 		return false;
 	 	}
 	 }
-	 
+
 	 /**
 	 * Sets the theme setting in the database
 	 * @param	string	Theme setting
@@ -586,7 +586,7 @@ class aicc extends learnpath {
 	 		return false;
 	 	}
 	 }
-	 
+
 	 /**
 	 * Sets the image LP in the database
 	 * @param	string	Theme setting
@@ -603,7 +603,7 @@ class aicc extends learnpath {
 	 		return false;
 	 	}
 	 }
-	 
+
 		/**
 	 * Sets the Author LP in the database
 	 * @param	string	Theme setting
@@ -620,9 +620,9 @@ class aicc extends learnpath {
 	 		return false;
 	 	}
 	 }
-	 
-	 
-	 
+
+
+
 	/**
 	 * Sets the content maker setting in the database
 	 * @param	string	Proximity setting
@@ -682,18 +682,18 @@ class aicc extends learnpath {
 		$zipfoldername = api_get_path('SYS_COURSE_PATH').$_course['directory']."/temp/".$LPnamesafe;
 		$scormfoldername = api_get_path('SYS_COURSE_PATH').$_course['directory']."/scorm/".$LPnamesafe;
 		$zipfilename = $zipfoldername."/".$LPnamesafe.".zip";
-	
-		//Get a temporary dir for creating the zip file	
-		
+
+		//Get a temporary dir for creating the zip file
+
 		//error_log('New LP - cleaning dir '.$zipfoldername,0);
 		deldir($zipfoldername); //make sure the temp dir is cleared
 		$res = mkdir($zipfoldername);
 		//error_log('New LP - made dir '.$zipfoldername,0);
-		
+
 		//create zipfile of given directory
 		$zip_folder = new PclZip($zipfilename);
 		$zip_folder->create($scormfoldername.'/', PCLZIP_OPT_REMOVE_PATH, $scormfoldername.'/');
-		
+
 		//$zipfilename = '/var/www/dokeos-comp/courses/TEST2/scorm/example_document.html';
 		//this file sending implies removing the default mime-type from php.ini
 		//DocumentManager :: file_send_for_download($zipfilename, true, $LPnamesafe.".zip");
@@ -702,7 +702,7 @@ class aicc extends learnpath {
 		// Delete the temporary zip file and directory in fileManage.lib.php
 		my_delete($zipfilename);
 		my_delete($zipfoldername);
-	
+
 		return true;
 	}
 	/**
@@ -788,7 +788,7 @@ class aicc extends learnpath {
 				{
 					if ((!$r) or ($sec))
 					{
-						if ((@substr($w,0,1)=="[") and (@substr($w,-1,1))=="]") 
+						if ((@substr($w,0,1)=="[") and (@substr($w,-1,1))=="]")
 						{
 							$sec=@substr($w,1,@strlen($w)-2);
 							$newsec=1;
@@ -798,20 +798,20 @@ class aicc extends learnpath {
 					{
 						$w=@explode("=",$w);
 						$k=@trim($w[0]);
-						unset($w[0]); 
+						unset($w[0]);
 						$v=@trim(@implode("=",$w));
-						if ((@substr($v,0,1)=="\"") and (@substr($v,-1,1)=="\"")) 
+						if ((@substr($v,0,1)=="\"") and (@substr($v,-1,1)=="\""))
 						{
 							$v=@substr($v,1,@strlen($v)-2);
 						}
-						if ($sec) 
+						if ($sec)
 						{
 							if(strtolower($sec)=='course_description'){//special case
 								$r[strtolower($sec)]=$k;
 							}else{
 								$r[strtolower($sec)][strtolower($k)]=$v;
 							}
-						} else 
+						} else
 						{
 							$r[strtolower($k)]=$v;
 						}
@@ -841,7 +841,7 @@ class aicc extends learnpath {
 				{
 					if ((!$r) or ($sec))
 					{
-						if ((@substr($w,0,1)=="[") and (@substr($w,-1,1))=="]") 
+						if ((@substr($w,0,1)=="[") and (@substr($w,-1,1))=="]")
 						{
 							$sec=@substr($w,1,@strlen($w)-2);
 							$pure_data = 0;
@@ -857,13 +857,13 @@ class aicc extends learnpath {
 					{
 						$w=@explode("=",$w);
 						$k=@trim($w[0]);
-						unset($w[0]); 
+						unset($w[0]);
 						$v=@trim(@implode("=",$w));
-						if ((@substr($v,0,1)=="\"") and (@substr($v,-1,1)=="\"")) 
+						if ((@substr($v,0,1)=="\"") and (@substr($v,-1,1)=="\""))
 						{
 							$v=@substr($v,1,@strlen($v)-2);
 						}
-						if ($sec) 
+						if ($sec)
 						{
 							if($pure_data){
 								$r[strtolower($sec)] .= $f[$i];
@@ -874,7 +874,7 @@ class aicc extends learnpath {
 									$r[strtolower($sec)][strtolower($k)]=$v;
 								}
 							}
-						} else 
+						} else
 						{
 							$r[strtolower($k)]=$v;
 						}
@@ -975,6 +975,6 @@ class aicc extends learnpath {
 			}
 			return $ret_ret_array;
 		}
-		
+
 }
 ?>

+ 4 - 4
main/newscorm/aiccBlock.class.php

@@ -1,19 +1,19 @@
 <?php //$id:$
 /**
- * Container for the aiccResource class that deals with elemens from AICC Course Structure file 
+ * Container for the aiccResource class that deals with elemens from AICC Course Structure file
  * @package	dokeos.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
  * @license	GNU/GPL - See Dokeos license directory for details
  */
 /**
  * Class defining the Block elements in an AICC Course Structure file
- * 
+ *
  */
 require_once('learnpathItem.class.php');
 class aiccBlock extends learnpathItem{
 	var $identifier = '';
 	var $members = array();
-		    
+
     /**
      * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
      * object from database records or from the array given as second param
@@ -50,7 +50,7 @@ class aiccBlock extends learnpathItem{
 			     		}
 			     	}
 					return true;
-			     	
+
     		}
     	}
     	return false;

+ 2 - 2
main/newscorm/aiccItem.class.php

@@ -17,7 +17,7 @@ class aiccItem extends learnpathItem{
 	var $sub_items = array(); //AICC elements (des)
 	//var $prerequisites = ''; - defined in learnpathItem.class.php
 	//var $max_score = ''; //defined in learnpathItem
-	//var $path = ''; //defined in learnpathItem	
+	//var $path = ''; //defined in learnpathItem
 	var $maxtimeallowed = '00:00:00'; //AICC AU's max_time_allowed
 	var $timelimitaction = ''; //AICC AU's time_limit_action
 	var $masteryscore = ''; //AICC AU's mastery_score
@@ -130,7 +130,7 @@ class aiccItem extends learnpathItem{
     	//under certain conditions, the scorm_contact should not be set, because no scorm signal was sent
     	$this->aicc_contact = true;
     	if(!$this->aicc_contact){
-    		//error_log('New LP - was expecting SCORM message but none received',0);	
+    		//error_log('New LP - was expecting SCORM message but none received',0);
     	}
     }
 }

+ 4 - 4
main/newscorm/aiccObjective.class.php

@@ -1,19 +1,19 @@
 <?php //$id:$
 /**
- * Container for the aiccResource class that deals with elemens from AICC Objectives file 
+ * Container for the aiccResource class that deals with elemens from AICC Objectives file
  * @package	dokeos.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
  * @license	GNU/GPL - See Dokeos license directory for details
  */
 /**
  * Class defining the Block elements in an AICC Course Structure file
- * 
+ *
  */
 require_once('learnpathItem.class.php');
 class aiccObjective extends learnpathItem{
 	var $identifier = '';
 	var $members = array();
-		    
+
     /**
      * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
      * object from database records or from the array given as second param
@@ -50,7 +50,7 @@ class aiccObjective extends learnpathItem{
 			     		}
 			     	}
 					return true;
-			     	
+
     		}
     	}
     	return false;

+ 5 - 5
main/newscorm/aiccResource.class.php

@@ -1,19 +1,19 @@
 <?php //$id:$
 /**
- * Container for the aiccResource class that deals with elemens from AICC Descriptor file 
+ * Container for the aiccResource class that deals with elemens from AICC Descriptor file
  * @package	dokeos.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
  * @license	GNU/GPL - See Dokeos license directory for details
  */
 /**
- * Class defining the elements from an AICC Descriptor file 
+ * Class defining the elements from an AICC Descriptor file
  */
 class aiccResource {
 	var $identifier = '';
 	var $title = '';
-	var $description = '';	
+	var $description = '';
 	var $developer_id = '';
-		    
+
     /**
      * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
      * object from database records or from the array given as second param
@@ -48,7 +48,7 @@ class aiccResource {
 			     		}
 			     	}
 					return true;
-			     	
+
     		}
     	}
     	return false;

+ 53 - 53
main/newscorm/aicc_api.php

@@ -1,6 +1,6 @@
-<?php // $Id: $ 
+<?php // $Id: $
 /**
-============================================================================== 
+==============================================================================
 *	API event handler functions for AICC / CMIv4 in API communication mode
 *
 *	@author   Denes Nagy <darkden@freemail.hu>
@@ -9,29 +9,29 @@
 *	@access   public
 *	@package  dokeos.learnpath
 * 	@license	GNU/GPL - See Dokeos license directory for details
-============================================================================== 
+==============================================================================
 */
 /**
- * This script is divided into three sections. 
+ * This script is divided into three sections.
  * The first section (below) is the initialisation part.
  * The second section is the AICC object part
  * The third section defines the event handlers for Dokeos' internal messaging
  * and frames refresh
- * 
+ *
  * This script implements the API messaging for AICC. The HACP messaging is
  * made by another set of scripts.
  */
 /*
-============================================================================== 
+==============================================================================
 	   INIT SECTION
-============================================================================== 
-*/ 
+==============================================================================
+*/
 
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
 
 //Load common libraries using a compatibility script to bridge between 1.6 and 1.8
-require_once('back_compat.inc.php');  
+require_once('back_compat.inc.php');
 //Load learning path libraries so we can use the objects to define the initial values
 //of the API
 require_once('learnpath.class.php');
@@ -50,10 +50,10 @@ if(!is_object($oItem)){
 $autocomplete_when_80pct = 0;
 
 /*
-============================================================================== 
+==============================================================================
 		JavaScript Functions
-============================================================================== 
-*/ 
+==============================================================================
+*/
 ?>var scorm_logs=<?php echo (empty($oLP->scorm_debug)?'0':'3');?>; //debug log level for SCORM. 0 = none, 1=light, 2=a lot, 3=all - displays logs in log frame
 var lms_logs=0; //debug log level for LMS actions. 0=none, 1=light, 2=a lot, 3=all
 //logit_lms('scormfunctions.php included',0);
@@ -154,7 +154,7 @@ function LMSGetValue(param) {
 	}else if(param == 'cmi.core.student_name'){
 		  <?php
 			$who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
-		    echo "result='$who';"; 
+		    echo "result='$who';";
 		  ?>
 	}else if(param == 'cmi.core.lesson_location'){
 		result=lesson_location;
@@ -193,10 +193,10 @@ function LMSGetValue(param) {
 		case 'cmi.core.entry'			:
 			result='';
 			break;
-		case 'cmi.core.exit'			: 
+		case 'cmi.core.exit'			:
 			result='';
 			break;
-		case 'cmi.core.lesson_status'	: 
+		case 'cmi.core.lesson_status'	:
 		    if(lesson_status != '') {
 		    	result=lesson_status;
 		    }
@@ -204,51 +204,51 @@ function LMSGetValue(param) {
 		    	result='not attempted';
 		    }
 		    break;
-		case 'cmi.core.student_id'	   : 
+		case 'cmi.core.student_id'	   :
 			result='<?php echo $_user['user_id']; ?>';
 			break;
-		case 'cmi.core.student_name'	: 
+		case 'cmi.core.student_name'	:
 		  <?php
 		    $who=addslashes(api_get_person_name($_user['firstName'], $_user['lastName']));
-		    echo "result='$who';"; 
+		    echo "result='$who';";
 		  ?>	break;
 		case 'cmi.core.lesson_location'	:
 			result='';
 			break;
-		case 'cmi.core.total_time'	:	
+		case 'cmi.core.total_time'	:
 			result=total_time;
 			break;
-		case 'cmi.core.score._children'	: 
+		case 'cmi.core.score._children'	:
 			result='raw,min,max';
 			break;
-		case 'cmi.core.score.raw'	: 
+		case 'cmi.core.score.raw'	:
 			result=score;
 			break;
 		case 'cmi.core.score.max'	:
 			result=max;
 			break;
-		case 'cmi.core.score.min'	: 
+		case 'cmi.core.score.min'	:
 			result=min;
 			break;
-		case 'cmi.core.score'		: 
+		case 'cmi.core.score'		:
 			result=score;
 			break;
-		case 'cmi.core.credit'		: 
+		case 'cmi.core.credit'		:
 			result='no-credit';
 			break;
-		case 'cmi.core.lesson_mode'	: 
+		case 'cmi.core.lesson_mode'	:
 			result='normal';
 			break;
-		case 'cmi.suspend_data'		: 
+		case 'cmi.suspend_data'		:
 			result='<?php echo $oItem->get_suspend_data();?>';
 			break;
-		case 'cmi.launch_data'		: 
+		case 'cmi.launch_data'		:
 			result='';
 			break;
-		case 'cmi.objectives._count': 
+		case 'cmi.objectives._count':
 			result='<?php echo $oItem->get_view_count();?>';
 			break;
-		default 					: 
+		default 					:
 			result='';
 			break;
 	}
@@ -263,7 +263,7 @@ function LMSSetValue(param, val) {
 	case 'cmi.core.score.max'		: max = val;			break;
 	case 'cmi.core.score.min'		: min = val;			break;
 	case 'cmi.core.lesson_location' : lesson_location = val;break;
-	case 'cmi.core.lesson_status'	: 
+	case 'cmi.core.lesson_status'	:
 		saved_lesson_status = lesson_status;
 		lesson_status = val;
 		<?php if($oLP->mode != 'fullscreen'){ ?>
@@ -278,7 +278,7 @@ function LMSSetValue(param, val) {
 	}
     //var update = update_toc();
 	//var update_progress = update_progress_bar();
-	<?php 
+	<?php
 	if ($oLP->force_commit == 1){
 		echo "    var mycommit = LMSCommit('force');";
 	}
@@ -292,7 +292,7 @@ function savedata(origin) { //origin can be 'commit', 'finish' or 'terminate'
     }
     <?php }?>
     param = 'id='+lms_item_id+'&origin='+origin+'&score='+score+'&max='+max+'&min='+min+'&lesson_status='+lesson_status+'&time='+session_time+'&suspend_data='+suspend_data;
-	
+
     url="http://<?php
     $self=api_get_self();
     $url=$_SERVER['HTTP_HOST'].$self;
@@ -312,11 +312,11 @@ function LMSCommit(val) {
 	return('true');
 }
 function LMSFinish(val) {
-	if (( commit == false )) { 	
-		logit_scorm('LMSFinish() (no LMSCommit())',1); 
+	if (( commit == false )) {
+		logit_scorm('LMSFinish() (no LMSCommit())',1);
 	}
 	if ( commit == true ) {
-		logit_scorm('LMSFinish() called',1);		
+		logit_scorm('LMSFinish() called',1);
 		savedata('finish');
 	}
 	return('true');
@@ -376,7 +376,7 @@ function addEvent(elm, evType, fn, useCapture){
 /**
  * Add listeners to the page objects. This has to be defined for
  * the current context as it acts on objects that should exist
- * on the page 
+ * on the page
  */
 function addListeners(){
 	//exit if the browser doesn't support ID or tag retrieval
@@ -404,7 +404,7 @@ function addListeners(){
 /**
  * Load an item into the content frame:
  * - making sure the previous item status have been saved
- * - first updating the current item ID (to save the right item) 
+ * - first updating the current item ID (to save the right item)
  * - updating the frame src
  */
 function load_item(item_id,url){
@@ -550,7 +550,7 @@ function update_progress_bar(nbr_complete, nbr_total, mode)
 		percentage = Math.round(percentage);
 		var pr_text  = myframe.document.getElementById('progress_text');
 		var pr_full  = myframe.document.getElementById('progress_img_full');
-		
+
 		var pr_empty = myframe.document.getElementById('progress_img_empty');
 		pr_full.width = percentage;
 		pr_empty.width = 100-percentage;
@@ -561,7 +561,7 @@ function update_progress_bar(nbr_complete, nbr_total, mode)
 				break;
 			case '%':
 			default:
-				mytext = percentage + '%'; 
+				mytext = percentage + '%';
 				break;
 		}
 		pr_text.innerHTML = mytext;
@@ -598,12 +598,12 @@ function update_message_frame(msg_msg)
 /**
  * Function that handles the saving of an item and switching from an item to another.
  * Once called, this function should be able to do the whole process of (1) saving the
- * current item, (2) refresh all the values inside the SCORM API object, (3) open the 
- * new item into the content_id frame, (4) refresh the table of contents, (5) refresh 
+ * current item, (2) refresh all the values inside the SCORM API object, (3) open the
+ * new item into the content_id frame, (4) refresh the table of contents, (5) refresh
  * the progress bar (completion), (6) refresh the message frame
  * @param	integer		Dokeos ID for the current item
- * @param	string		This parameter can be a string specifying the next 
- *						item (like 'next', 'previous', 'first' or 'last') or the id to the next item  
+ * @param	string		This parameter can be a string specifying the next
+ *						item (like 'next', 'previous', 'first' or 'last') or the id to the next item
  */
 function switch_item(current_item, next_item){
 	/*
@@ -620,10 +620,10 @@ function switch_item(current_item, next_item){
 	//(1) save the current item
 	logit_lms('Called switch_item with params '+lms_item_id+' and '+next_item+'',0);
 	xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location);
-	
+
 	//(2) Refresh all the values inside this SCORM API object - use AJAX
 	xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,next_item);
-	
+
 	//(3) open the new item in the content_id frame
 	var cont_f = document.getElementById('content_id');
 	if(!cont_f){logit_lms('In switch - content frame not found',0);return false;}
@@ -638,7 +638,7 @@ function switch_item(current_item, next_item){
 			break;
 	}
 	cont_f.src = 'lp_controller.php?action=content&lp_id='+lms_lp_id+'&item_id='+next_item;
-	
+
 	//(4) refresh table of contents
 	/*
 	var toc_f = document.getElementById('toc_id');
@@ -646,7 +646,7 @@ function switch_item(current_item, next_item){
 	var myrefresh = toc_f.src;
 	toc_f.src = myrefresh;
 	*/
-	
+
 	//(5) refresh the progress bar
 	/*
 	var prg_f = document.getElementById('nav_id');
@@ -654,7 +654,7 @@ function switch_item(current_item, next_item){
 	var myrefresh = prg_f.src;
 	prg_f.src = myrefresh;
 	*/
-	
+
 	//(6) refresh the message box (included in switch_item_details)
 	return true;
 }
@@ -691,18 +691,18 @@ function xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score
             's': score,
             'max': max,
             'min': min,
-            'status': lesson_status, 
-            't': session_time, 
+            'status': lesson_status,
+            't': session_time,
             'suspend': suspend_data,
             'loc': lesson_location,
-            'interact': interac_string, 
+            'interact': interac_string,
             'core_exit': lms_item_core_exit
         }
         */
         $.ajax({
             type:"GET",
             data: params,
-            url: "lp_ajax_save_item.php", 
+            url: "lp_ajax_save_item.php",
             dataType: "script",
             async: false
             }
@@ -718,7 +718,7 @@ function xajax_start_timer() {
         url: "lp_ajax_start_timer.php",
         dataType: "script",
         async: false
-    }); 
+    });
 }
 /**
  * Save a specific item's objectives into the LMS through

+ 14 - 14
main/newscorm/aicc_hacp.php

@@ -1,6 +1,6 @@
-<?php // $Id: $ 
+<?php // $Id: $
 /**
-============================================================================== 
+==============================================================================
 *	API event handler functions for AICC / CMIv4 in HACP communication mode
 *
 *	@author   Denes Nagy <darkden@freemail.hu>
@@ -9,32 +9,32 @@
 *	@access   public
 *	@package  dokeos.learnpath
 * 	@license	GNU/GPL - See Dokeos license directory for details
-============================================================================== 
+==============================================================================
 */
 /**
- * This script is divided into three sections. 
+ * This script is divided into three sections.
  * The first section (below) is the initialisation part.
  * The second section is the AICC object part
  * The third section defines the event handlers for Dokeos' internal messaging
  * and frames refresh
- * 
+ *
  * This script implements the HACP messaging for AICC. The API messaging is
  * made by another set of scripts.
- * 
+ *
  * Rules for HACP processing of one AU
  * Rule #1 The first HACP message issued must be a GetParam
  * Rule #2 The last HACP message issued must be an ExitAU
  * Rule #3 At least one PutParam message must be issued prior to an ExitAU message
  * Rule #4 No HACP messages can be issued after a successfully issued ExitAU message
- * 
+ *
  * Only suspend_data and core.lesson_location should be sent updated to a late GetParam
  * request. All other params should be as when the AU was launched.
  */
 /*
-============================================================================== 
+==============================================================================
 	   INIT SECTION
-============================================================================== 
-*/ 
+==============================================================================
+*/
 $debug = 0;
 
 //flag to allow for anonymous user - needs to be set before global.inc.php
@@ -47,7 +47,7 @@ if(!empty($_REQUEST['aicc_sid']))
 	if($debug>1){error_log('New LP - '.__FILE__.','.__LINE__.' - reusing session ID '.$_REQUEST['aicc_sid'],0);}
 }
 //Load common libraries using a compatibility script to bridge between 1.6 and 1.8
-require_once('back_compat.inc.php');  
+require_once('back_compat.inc.php');
 if($debug>2){error_log('New LP - '.__FILE__.','.__LINE__.' - Current session ID: '.session_id(),0);}
 //Load learning path libraries so we can use the objects to define the initial values
 //of the API
@@ -126,7 +126,7 @@ if(!empty($_REQUEST['command']))
 			$result .= $tab.'Mastery_Score='.$oItem->masteryscore.$crlf;
 			//$result .= '[Student_Demographics]'.$crlf;
 			//$result .= '[Student_Preferences]'.$crlf;
-						
+
 			//error_log('Returning message: '.$result,0);
 			$result = str_replace($convert_dec,$convert_enc,$result);
 			//error_log('Returning message (encoded): '.$result,0);
@@ -150,7 +150,7 @@ if(!empty($_REQUEST['command']))
 						//error_log('In '.__FILE__.', '.__LINE__.' - aicc data before translation is '.$value,0);
 						$value = str_replace('+',' ',$value);
 						$value = str_replace($convert_enc,$convert_dec,$value);
-						$hacp_aicc_data = $value;						
+						$hacp_aicc_data = $value;
 						break;
 				}
 			}
@@ -196,7 +196,7 @@ if(!empty($_REQUEST['command']))
 						break;
 				}
 			}
-			
+
 			$error_code = 0;
 			$error_text = $errors[$error_code];
 			$result = $s_ec.$error_code.$crlf.$s_et.$error_text.$crlf.$s_ad.$crlf;

+ 7 - 7
main/newscorm/audiorecorder.inc.php

@@ -2,7 +2,7 @@
 // This file is part of the Dokeos software - See license and credits in the documentation/ directory
 /**
  * Created on 27.09.2006
- * Include the lazlo file necessary to use the audiorecorder  
+ * Include the lazlo file necessary to use the audiorecorder
  * @author Sebastian Wagner <seba.wagner@gmail.com>
  * @author Eric Marguin <e.marguin@elixir-interactive.com>
  * @author Arnaud Ligot <arnaud@cblue.be>
@@ -20,9 +20,9 @@ function getFLVDuration($flv_path) {
 	try {
 		$getid3->Analyze($flv_path);
 		return $getid3->info['playtime_seconds'];
-	} catch (Exception $e) { 
+	} catch (Exception $e) {
 		return 0;
-	} 
+	}
 }
 
 
@@ -48,13 +48,13 @@ else
 			" ORDER BY path DESC";
 	$res = api_sql_query($select);
 	if(Database::num_rows($res)>0)
-	{  
+	{
 		$row = Database::fetch_array($res);
 		//$filepath = api_get_path(WEB_COURSE_PATH).$cp.'/document'.$row['path'];
 		$duration = getFLVDuration(api_get_path(SYS_COURSE_PATH).$cp.'/document'.$row['path']);
 		$filepath = api_get_path(WEB_CODE_PATH).'document/download.php?'.api_get_cidreq().'&doc_url='.$row['path'];
 		$path_to_lzx = $web_path.'conference/'.$player.'?uri='.urlencode($filepath).'&autostart=true&duration='.$duration;
-	}	
+	}
 }
 
 if(!empty($path_to_lzx)){
@@ -68,13 +68,13 @@ if(!empty($path_to_lzx)){
 	if($audio_recorder_studentview=='false')
 	{
 		echo '<script type="text/javascript">
-	
+
 		function show_audiorecorder()
 		{
 			document.getElementById("audiorecorder_frame").innerHTML = "'.addslashes($recorder_content).'";
 			document.getElementById("show_audiorecorder_div").style.display="none";
 		}
-	
+
 		</script>
 		';
 		//Commented the audio for the version stable

+ 1 - 1
main/newscorm/back_compat.inc.php

@@ -1,6 +1,6 @@
 <?php //$id: $
 /**
- * This script used to allow compatibility between the New SCORM tool and both 
+ * This script used to allow compatibility between the New SCORM tool and both
  * version 1.6.3 and 1.8 of Dokeos by loading libraries in a different way.
  * The switch is now deprecated and this file will be renamed later on to
  * something like lp_includes.inc.php

+ 3 - 3
main/newscorm/blank.php

@@ -7,7 +7,7 @@
 /**
  * Script
  */
- 
+
 
 $language_file[] = "learnpath";
 
@@ -29,8 +29,8 @@ if (isset($_GET['error'])) {
 			echo '<br /><br />';
 			Display::display_error_message(get_lang('DocumentHasBeenDeleted'));
 			break;
-		case 'prerequisites':	
-			echo '<br /><br />';	
+		case 'prerequisites':
+			echo '<br /><br />';
 			Display::display_normal_message(get_lang('_prereq_not_complete'));
 			break;
 		default:

+ 3 - 3
main/newscorm/display_audiorecorder.php

@@ -7,7 +7,7 @@
  * @license	GNU/GPL - See Dokeos license directory for details
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
-$use_anonymous = true;	
+$use_anonymous = true;
 require_once('back_compat.inc.php');
 require_once('learnpath.class.php');
 require_once('scorm.class.php');
@@ -28,8 +28,8 @@ $lp_theme_css=$_SESSION['oLP']->get_theme();
 $scorm_css_header=true;
 include_once('../inc/reduced_header.inc.php');
 echo '<html>
-		<body>';	
-	
+		<body>';
+
 		echo '<div id="audiorecorder">	';
 		$audio_recorder_studentview = 'true';
 		$audio_recorder_item_id = $_SESSION['oLP']->current;

+ 1 - 1
main/newscorm/document.php

@@ -68,7 +68,7 @@ function confirmation(name)
 	if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." ?\"))
 		{return true;}
 	else
-		{return false;} 
+		{return false;}
 }
 </script>";
 

Diff do ficheiro suprimidas por serem muito extensas
+ 169 - 169
main/newscorm/learnpath.class.php


+ 133 - 133
main/newscorm/learnpathItem.class.php

@@ -55,11 +55,11 @@ class learnpathItem{
 	var $title;
 	var $type; // this attribute can contain chapter|link|student_publication|module|quiz|document|forum|thread
 	var $view_id;
-	
+
 	var $debug = 0; //logging param
     /**
      * Class constructor. Prepares the learnpath_item for later launch
-     * 
+     *
      * Don't forget to use set_lp_view() if applicable after creating the item.
      * Setting an lp_view will finalise the item_view data collection
      * @param	integer	Learnpath item ID
@@ -116,7 +116,7 @@ class learnpathItem{
             }
         }
         $this->audio = $row['audio'];
-		
+
 		//error_log('New LP - End of learnpathItem constructor for item '.$id,0);
     	return true;
     }
@@ -174,7 +174,7 @@ class learnpathItem{
 			$this->objectives_count = (count($this->objectives)+1);
 		}
     }
-    
+
     /**
      * Closes/stops the item viewing. Finalises runtime values. If required, save to DB.
      * @return	boolean	True on success, false otherwise
@@ -187,7 +187,7 @@ class learnpathItem{
     	if($type != 'sco'){
     		if($type == TOOL_QUIZ or $type == TOOL_HOTPOTATOES)
     		{
-    			$this->get_status(true,true);//update status (second option forces the update)		
+    			$this->get_status(true,true);//update status (second option forces the update)
     		}
     		else
     		{
@@ -197,7 +197,7 @@ class learnpathItem{
     	if($this->save_on_close)
     	{
     		$this->save();
-    	}	
+    	}
     	return true;
     }
     /**
@@ -303,7 +303,7 @@ class learnpathItem{
     		//check the status in the database rather than in the object, as checking in the object
 			//would always return "no-credit" when we want to set it to completed
 			$status = $this->get_status(true);
-			if(!empty($this->debug) && $this->debug>2){error_log('New LP - In learnpathItem::get_credit() - get_prevent_reinit!=0 and status is '.$status,0);}			
+			if(!empty($this->debug) && $this->debug>2){error_log('New LP - In learnpathItem::get_credit() - get_prevent_reinit!=0 and status is '.$status,0);}
 			if($status != $this->possible_status[0] AND $status != $this->possible_status[1]){
 				$credit = 'no-credit';
 			}
@@ -508,7 +508,7 @@ class learnpathItem{
 	}
 	/**
 	 * Gets the lesson_mode (scorm feature, but might be used by aicc as well as dokeos paths)
-	 * 
+	 *
 	 * The "browse" mode is not supported yet (because there is no such way of seeing a sco in Dokeos)
 	 * @return	string	'browse','normal' or 'review'. Defaults to 'normal'
 	 */
@@ -516,7 +516,7 @@ class learnpathItem{
 		$mode = 'normal';
 		if($this->get_prevent_reinit() != 0){ //if prevent_reinit == 0
 			$my_status = $this->get_status();
-			if($my_status != $this->possible_status[0] AND $my_status != $this->possible_status[1]){	
+			if($my_status != $this->possible_status[0] AND $my_status != $this->possible_status[1]){
 				$mode = 'review';
 			}
 		}
@@ -537,7 +537,7 @@ class learnpathItem{
     function get_mastery_score()
     {
     	if($this->debug>0){error_log('New LP - In learnpathItem::get_mastery_score()',0);}
-    	if(isset($this->mastery_score)){return $this->mastery_score;}else{return -1;}    	    	
+    	if(isset($this->mastery_score)){return $this->mastery_score;}else{return -1;}
     }
     /**
      * Gets the maximum (score)
@@ -572,7 +572,7 @@ class learnpathItem{
     function get_max_time_allowed()
     {
     	if($this->debug>0){error_log('New LP - In learnpathItem::get_max_time_allowed()',0);}
-    	if(!empty($this->max_time_allowed)){return $this->max_time_allowed;}else{return '';}    	
+    	if(!empty($this->max_time_allowed)){return $this->max_time_allowed;}else{return '';}
     }
     /**
      * Gets the minimum (score)
@@ -606,7 +606,7 @@ class learnpathItem{
     }
     /**
      * Gets the prerequisites string
-     * @return	string	Empty string or prerequisites string if defined. Defaults to 
+     * @return	string	Empty string or prerequisites string if defined. Defaults to
      */
     function get_prereq_string()
     {
@@ -636,7 +636,7 @@ class learnpathItem{
 		    		return false;
 		    	}else{
 		    		$row = Database::fetch_array($res);
-		    		$this->prevent_reinit = $row['prevent_reinit']; 
+		    		$this->prevent_reinit = $row['prevent_reinit'];
 		    	}
 	    	}else{
 	    		$this->prevent_reinit = 1;//prevent reinit is always 1 by default - see learnpath.class.php
@@ -692,11 +692,11 @@ class learnpathItem{
     	$type = $this->get_type();
     	switch($type)
     	{
-    		case TOOL_DOCUMENT : 
+    		case TOOL_DOCUMENT :
     		case TOOL_QUIZ:
     		case 'sco':
     			//get the document and, if HTML, open it
-    			
+
     			if(is_file($abs_path))
     			{
 	    			//for now, read the whole file in one go (that's gonna be a problem when the file is too big)
@@ -720,7 +720,7 @@ class learnpathItem{
 								{
 									//find which kind of path these are (local or remote)
 									$sources = $attributes[$attr];
-									
+
 									foreach($sources as $source)
 									{
 										//skip what is obviously not a resource
@@ -728,7 +728,7 @@ class learnpathItem{
 										if(strpos($source,'.')=== false) continue; //no dot, should not be an external file anyway
 										if(strpos($source,'mailto:')) continue; //mailto link
 										if(strpos($source,';') && !strpos($source,'&amp;')) continue; //avoid code - that should help
-										
+
 										if($attr == 'value')
 										{
 											if(strpos($source , 'mp3file'))
@@ -769,7 +769,7 @@ class learnpathItem{
 										}
 										if(strpos($source,'://') > 0)
 										{
-											
+
 											//cut at '?' in a URL with params
 											if(strpos($source,'?')>0)
 											{
@@ -801,22 +801,22 @@ class learnpathItem{
 													if(substr($second_part,0,1) === '/')
 													{	//link starts with a /, making it absolute (relative to DocumentRoot)
 														$files_list[] = array($second_part,'local','abs');
-														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$second_part,$recursivity+1); 
+														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$second_part,$recursivity+1);
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
 													elseif(strstr($second_part,'..') === 0)
 													{	//link is relative but going back in the hierarchy
 														$files_list[] = array($second_part,'local','rel');
 														$dir = dirname($abs_path);
 														$new_abs_path = realpath($dir.'/'.$second_part);
-														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1); 
+														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1);
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
 													else
 													{	//no starting '/', making it relative to current document's path
@@ -827,13 +827,13 @@ class learnpathItem{
 														$files_list[] = array($second_part,'local','rel');
 														$dir = dirname($abs_path);
 														$new_abs_path = realpath($dir.'/'.$second_part);
-														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1); 
+														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1);
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
-													
+
 												}
 												//leave that second part behind now
 												$source = substr($source,0,strpos($source,'?'));
@@ -847,7 +847,7 @@ class learnpathItem{
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
 													else
 													{
@@ -861,22 +861,22 @@ class learnpathItem{
 													if(substr($source,0,1) === '/')
 													{	//link starts with a /, making it absolute (relative to DocumentRoot)
 														$files_list[] = array($source,'local','abs');
-														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$source,$recursivity+1); 
+														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$source,$recursivity+1);
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
 													elseif(strstr($source,'..') === 0)
 													{	//link is relative but going back in the hierarchy
 														$files_list[] = array($source,'local','rel');
 														$dir = dirname($abs_path);
 														$new_abs_path = realpath($dir.'/'.$source);
-														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1); 
+														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1);
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
 													else
 													{	//no starting '/', making it relative to current document's path
@@ -887,11 +887,11 @@ class learnpathItem{
 														$files_list[] = array($source,'local','rel');
 														$dir = dirname($abs_path);
 														$new_abs_path = realpath($dir.'/'.$source);
-														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1); 
+														$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1);
 														if(count($in_files_list)>0)
 														{
 															$files_list = array_merge($files_list,$in_files_list);
-														} 
+														}
 													}
 												}
 											}
@@ -904,7 +904,7 @@ class learnpathItem{
 												if(count($in_files_list)>0)
 												{
 													$files_list = array_merge($files_list,$in_files_list);
-												} 
+												}
 											}
 											else
 											{
@@ -918,22 +918,22 @@ class learnpathItem{
 											if(substr($source,0,1) === '/')
 											{	//link starts with a /, making it absolute (relative to DocumentRoot)
 												$files_list[] = array($source,'local','abs');
-												$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$source,$recursivity+1); 
+												$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$source,$recursivity+1);
 												if(count($in_files_list)>0)
 												{
 													$files_list = array_merge($files_list,$in_files_list);
-												} 
+												}
 											}
 											elseif(strstr($source,'..') === 0)
 											{	//link is relative but going back in the hierarchy
 												$files_list[] = array($source,'local','rel');
 												$dir = dirname($abs_path);
 												$new_abs_path = realpath($dir.'/'.$source);
-												$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1); 
+												$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1);
 												if(count($in_files_list)>0)
 												{
 													$files_list = array_merge($files_list,$in_files_list);
-												} 
+												}
 											}
 											else
 											{	//no starting '/', making it relative to current document's path
@@ -944,11 +944,11 @@ class learnpathItem{
 												$files_list[] = array($source,'local','rel');
 												$dir = dirname($abs_path);
 												$new_abs_path = realpath($dir.'/'.$source);
-												$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1); 
+												$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT,$new_abs_path,$recursivity+1);
 												if(count($in_files_list)>0)
 												{
 													$files_list = array_merge($files_list,$in_files_list);
-												} 
+												}
 											}
 										}
 									}
@@ -958,7 +958,7 @@ class learnpathItem{
 						default:
 							break;
 					}
-					
+
     			}
     			else
     			{
@@ -1020,17 +1020,17 @@ class learnpathItem{
     			if($update_local==true){
     				$this->set_status($row['status']);
     			}
-	    		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'],0);}	    		
+	    		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'],0);}
     			return $row['status'];
     		}
     	} else {
     		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - in get_status: using attrib',0);}
 	    	if(!empty($this->status)) {
-	    		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Returning attrib: '.$this->status,0);}	    		
+	    		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Returning attrib: '.$this->status,0);}
 	    		return $this->status;
 	    	}
     	}
-   		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Returning default '.$this->possible_status[0],0);}    	
+   		if($this->debug>2){error_log('New LP - In learnpathItem::get_status() - Returning default '.$this->possible_status[0],0);}
     	return $this->possible_status[0];
     }
     /**
@@ -1077,7 +1077,7 @@ class learnpathItem{
   		}
 		return $scorm_time;
     }
-    
+
 function get_terms()
           {
                 $lp_item = Database::get_course_table(TABLE_LP_ITEM);
@@ -1127,7 +1127,7 @@ function get_terms()
     		$res = $this->type;
     	}
     	if($this->debug>2){error_log('New LP - In learnpathItem::get_type() - Returning '.$res.' for item '.$this->db_id,0);}
-    	return $res;    	
+    	return $res;
     }
     /**
      * Gets the view count for this item
@@ -1156,7 +1156,7 @@ function get_terms()
 	/**
 	 * Tells if a restart is allowed (take it from $this->prevent_reinit and $this->status)
 	 * @return	integer	-1 if retaking the sco another time for credit is not allowed,
-	 * 					 0 if it is not allowed but the item has to be finished 
+	 * 					 0 if it is not allowed but the item has to be finished
 	 * 					 1 if it is allowed. Defaults to 1
 	 */
 	function is_restart_allowed()
@@ -1243,12 +1243,12 @@ function get_terms()
 		$this->prereq_alert = '';
 		// First parse all parenthesis by using a sequential loop (looking for less-inclusives first)
 		if($prereqs_string == '_true_'){return true;}
-		if($prereqs_string == '_false_'){    	
+		if($prereqs_string == '_false_'){
 			if(empty($this->prereq_alert)){
     			$this->prereq_alert = get_lang('_prereq_not_complete');
     		}
 			return false;
-		}		
+		}
 		while(strpos($prereqs_string,'(')!==false){
 			//remove any () set and replace with its value
 			$matches = array();
@@ -1264,7 +1264,7 @@ function get_terms()
 				}
 			}
 		}
-		
+
 		//parenthesis removed, now look for ORs as it is the lesser-priority binary operator (= always uses one text operand)
 		if(strpos($prereqs_string,"|")===false){
     		if($this->debug>1){error_log('New LP - Didnt find any OR, looking for AND',0);}
@@ -1276,7 +1276,7 @@ function get_terms()
 	    				$andstatus = $andstatus && $this->parse_prereq($condition,$items,$refs_list,$user_id);
 	    				if($andstatus==false){
 							if($this->debug>1){error_log('New LP - One condition in AND was false, short-circuit',0);}
-							break;	    					
+							break;
 	    				}
 					}
 					if(empty($this->prereq_alert) && !$andstatus){
@@ -1296,10 +1296,10 @@ function get_terms()
 					return false;
 	    		}
 	    	}else{
-	    		
+
 	    		//no ORs found, now look for ANDs
-	    		
-    			if($this->debug>1){error_log('New LP - Didnt find any AND, looking for =',0);}	    		
+
+    			if($this->debug>1){error_log('New LP - Didnt find any AND, looking for =',0);}
 	    		if(strpos($prereqs_string,"=")!==false){
 		    		if($this->debug>1){error_log('New LP - Found =, looking into it',0);}
 		    		//we assume '=' signs only appear when there's nothing else around
@@ -1318,10 +1318,10 @@ function get_terms()
 						return false;
 		    		}
 	    		}else{
-	    		
+
 	    			//No ANDs found, look for <>
-	    		
-	    			if($this->debug>1){error_log('New LP - Didnt find any =, looking for <>',0);}	    		
+
+	    			if($this->debug>1){error_log('New LP - Didnt find any =, looking for <>',0);}
 		    		if(strpos($prereqs_string,"<>")!==false){
 			    		if($this->debug>1){error_log('New LP - Found <>, looking into it',0);}
 			    		//we assume '<>' signs only appear when there's nothing else around
@@ -1340,9 +1340,9 @@ function get_terms()
 			    			return false;
 			    		}
 		    		}else{
-		    			
+
 		    			//No <> found, look for ~ (unary)
-		    			
+
 		    			if($this->debug>1){error_log('New LP - Didnt find any =, looking for ~',0);}
 		    			//only remains: ~ and X*{}
 		    			if(strpos($prereqs_string,"~")!==false){
@@ -1361,10 +1361,10 @@ function get_terms()
 					    		if($this->debug>1){error_log('New LP - Found ~ but strange string: '.$prereqs_string,0);}
 		    				}
 		    			}else{
-		    				
+
 		    				//Finally, look for sets/groups
-		    				
-			    			if($this->debug>1){error_log('New LP - Didnt find any ~, looking for groups',0);}	    		
+
+			    			if($this->debug>1){error_log('New LP - Didnt find any ~, looking for groups',0);}
 		    				//only groups here
 					    	$groups = array();
 					    	$groups_there = preg_match_all('/((\d+\*)?\{([^\}]+)\}+)/',$prereqs_string,$groups);
@@ -1406,15 +1406,15 @@ function get_terms()
 							    				$status = $items[$refs_list[$cond]]->get_status(true);
 								    			if (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3])){
 						    						$mycond = true;
-							    					if($this->debug>1){error_log('New LP - Found true item',0);}						    					
+							    					if($this->debug>1){error_log('New LP - Found true item',0);}
 								    			}else{
-							    					if($this->debug>1){error_log('New LP - Found false item, the set is not true, return false',0);}						    					
+							    					if($this->debug>1){error_log('New LP - Found false item, the set is not true, return false',0);}
 								    				$mycond = false;
 								    				break;
 								    			}
 						    				}else{
 							    				if($this->debug>1){error_log('New LP - item '.$cond.' does not exist in items list',0);}
-						    					if($this->debug>1){error_log('New LP - Found false item, the set is not true, return false',0);}			    					
+						    					if($this->debug>1){error_log('New LP - Found false item, the set is not true, return false',0);}
 							    				$mycond = false;
 							    				break;
 							    			}
@@ -1426,18 +1426,18 @@ function get_terms()
 						    		return $mycond;
 						    	}
 					    	}else{
-					    		
+
 					    		//Nothing found there either. Now return the value of the corresponding resource completion status
-					    		
+
 				    			if($this->debug>1){error_log('New LP - Didnt find any group, returning value for '.$prereqs_string,0);}
-				    			if(isset($items[$refs_list[$prereqs_string]])){				    				
+				    			if(isset($items[$refs_list[$prereqs_string]])){
 				    				if($items[$refs_list[$prereqs_string]]->type == 'quiz')
 				    				{
 				    					$sql = 'SELECT exe_result, exe_weighting
 												FROM '.Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES).'
-												WHERE exe_exo_id = '.$items[$refs_list[$prereqs_string]]->path.' 
+												WHERE exe_exo_id = '.$items[$refs_list[$prereqs_string]]->path.'
 												AND exe_user_id = '.$user_id.'
-												AND status <> "incomplete"		
+												AND status <> "incomplete"
 												ORDER BY exe_date DESC
 												LIMIT 0, 1';
 										$rs_quiz = api_sql_query($sql, __FILE__, __LINE__);
@@ -1520,7 +1520,7 @@ function get_terms()
     }
     /**
 	 * Parses the HTML attributes given as string.
-	 * 
+	 *
 	 * @param    string  HTML attribute string
 	 * @param	 array	 List of attributes that we want to get back
 	 * @return   array   An associative array of attributes
@@ -1538,16 +1538,16 @@ function get_terms()
 	    try {
 	       //Find all occurences of something that looks like a URL
            // The structure of this regexp is:
-           // (find protocol) then 
+           // (find protocol) then
            // (optionally find some kind of space 1 or more times) then
            // find (either an equal sign or a bracket) followed by an optional space
            // followed by some text without quotes (between quotes itself or not)
            // then possible closing brackets if we were in the opening bracket case
-           // OR something like @import() 
+           // OR something like @import()
 	    	$res = preg_match_all(
                 '/(((([A-Za-z_:])([A-Za-z0-9_:\.-]*))' .
 //	            '/(((([A-Za-z_:])([A-Za-z0-9_:\.-]|[^\x00-\x7F])*)' . -> seems to be taking too much
-//                '/(((([A-Za-z_:])([^\x00-\x7F])*)' . -> takes only last letter of parameter name 
+//                '/(((([A-Za-z_:])([^\x00-\x7F])*)' . -> takes only last letter of parameter name
 	            '([ \n\t\r]+)?(' .
 //	              '(=([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+))' . -> doesn't restrict close enough to the url itself
                   '(=([ \n\t\r]+)?("[^"\)]+"|\'[^\'\)]+\'|[^ \n\t\r\)]+))' .
@@ -1556,9 +1556,9 @@ function get_terms()
                   '(\(([ \n\t\r]+)?("[^"\)]+"|\'[^\'\)]+\'|[^ \n\t\r\)]+)\))' .
 	            '))' .
 	            '|' .
-//	            '(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))?/', -> takes a lot (like 100's of thousands of empty possibilities) 
-                '(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))/', 
-	            $attrString, 
+//	            '(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))?/', -> takes a lot (like 100's of thousands of empty possibilities)
+                '(@import([ \n\t\r]+)?("[^"]+"|\'[^\']+\'|[^ \n\t\r]+)))/',
+	            $attrString,
 	            $regs
 	       );
 
@@ -1579,18 +1579,18 @@ function get_terms()
 	            	$value = trim($regs[16][$i]);
 	            }
 	            if(!empty($name))
-	            {     
+	            {
 					if(!$reduced OR in_array(strtolower($name),$wanted))
 		            {
-			            if ($name == $check) {		                	
-		            		$attributes[strtolower($name)][] = strtolower($name);				            	
-			            } else {			            	
-			                if (!empty($value) && ($value[0] == '\'' || $value[0] == '"')) {			                	
-			                    $value = substr($value, 1, -1);			                    
+			            if ($name == $check) {
+		            		$attributes[strtolower($name)][] = strtolower($name);
+			            } else {
+			                if (!empty($value) && ($value[0] == '\'' || $value[0] == '"')) {
+			                    $value = substr($value, 1, -1);
 			                }
 						    if ($value=='API.LMSGetValue(name') {
 						    	$value='API.LMSGetValue(name)';
-						    }		                			                
+						    }
 			                $attributes[strtolower($name)][] = $value;
 			            }
 		            }
@@ -1603,7 +1603,7 @@ function get_terms()
 	}
     /**
      * Reinits all local values as the learnpath is restarted
-     * @return	boolean	True on success, false otherwise	
+     * @return	boolean	True on success, false otherwise
      */
     function restart()
     {
@@ -1629,7 +1629,7 @@ function get_terms()
 				$this->write_to_db();
 			}
 		}else{
-			//restart current element is allowed (because it's not finished yet), 
+			//restart current element is allowed (because it's not finished yet),
 			// reinit current
 			$this->current_score = 0;
 			$this->current_start_time = 0;
@@ -1684,7 +1684,7 @@ function get_terms()
 		     				break;
 		     			case 'lesson_status':
 		     				if(!empty($value)){
-			     				$this->set_status($value); 
+			     				$this->set_status($value);
 			   					if($this->debug>2){error_log('New LP - In learnpathItem::save() - setting status to '.$value,0);}
 		     				}
 		     				break;
@@ -1747,7 +1747,7 @@ function get_terms()
 		 			if($prereqs_complete)
 		 			{
 		 				$this->set_status($this->possible_status[2]);
-		 			}	 			
+		 			}
 				break;
 	 		}
 		}
@@ -1844,14 +1844,14 @@ function get_terms()
 		    	//$this->view_min_score 	= $row['min_score'];
 				$this->status			= $row['status'];
 				$this->current_start_time	= $row['start_time'];
-				$this->current_stop_time 	= $this->current_start_time + $row['total_time']; 
+				$this->current_stop_time 	= $this->current_start_time + $row['total_time'];
 				$this->lesson_location  = $row['lesson_location'];
 				$this->core_exit		= $row['core_exit'];
 		     	if($this->debug>2){error_log('New LP - In learnpathItem::set_lp_view() - Updated item object with database values',0);}
 
 		     	//now get the number of interactions for this little guy
 		     	$item_view_interaction_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
-		     	$sql = "SELECT * FROM $item_view_interaction_table WHERE lp_iv_id = '".$this->db_item_view_id."'"; 
+		     	$sql = "SELECT * FROM $item_view_interaction_table WHERE lp_iv_id = '".$this->db_item_view_id."'";
 				$res = api_sql_query($sql,__FILE__,__LINE__);
 				if($res !== false){
 					$this->interactions_count = Database::num_rows($res);
@@ -1860,7 +1860,7 @@ function get_terms()
 				}
 		     	//now get the number of objectives for this little guy
 		     	$item_view_objective_table = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
-		     	$sql = "SELECT * FROM $item_view_objective_table WHERE lp_iv_id = '".$this->db_item_view_id."'"; 
+		     	$sql = "SELECT * FROM $item_view_objective_table WHERE lp_iv_id = '".$this->db_item_view_id."'";
 				$res = api_sql_query($sql,__FILE__,__LINE__);
 				if($res !== false){
 					$this->objectives_count = Database::num_rows($res);
@@ -1996,7 +1996,7 @@ function get_terms()
     {
         return $this->search_did;
     }
-           
+
     /**
      * Sets the item viewing time in a usable form, given that SCORM packages often give it as 00:00:00.0000
      * @param	string	Time as given by SCORM
@@ -2046,7 +2046,7 @@ function get_terms()
 	/**
 	 * Checks if the current status is part of the list of status given
 	 * @param	strings_array	An array of status to check for. If the current status is one of the strings, return true
-	 * @return	boolean			True if the status was one of the given strings, false otherwise	
+	 * @return	boolean			True if the status was one of the given strings, false otherwise
 	 */
 	function status_is($list=array())
 	{
@@ -2172,17 +2172,17 @@ function get_terms()
      */
      function write_to_db()
      {
-	
+
    		if($this->debug>0){error_log('New LP - In learnpathItem::write_to_db()',0);}
    		$mode = $this->get_lesson_mode();
    		$credit = $this->get_credit();
    		$my_verified_status=$this->get_status(false);
-   		
+
    		$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 		$sql_verified='SELECT status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
 		$rs_verified=api_sql_query($sql_verified,__FILE__,__LINE__);
 		$row_verified=Database::fetch_array($rs_verified);
-					
+
    		$my_case_completed=array('completed','passed','browsed','failed');//added by isaac flores
    		if (in_array($sql_verified['status'],$my_case_completed)) {
    			$save=false;
@@ -2197,12 +2197,12 @@ function get_terms()
    		} else {
       		//check the row exists
       		$inserted = false;
-      		
+
       		// this a special case for multiple attempts and Dokeos exercises
-      		if ($this->type == 'quiz' && $this->get_prevent_reinit()==0 && $this->get_status()=='completed') {     			
-      			// we force the item to be restarted    		
+      		if ($this->type == 'quiz' && $this->get_prevent_reinit()==0 && $this->get_status()=='completed') {
+      			// we force the item to be restarted
       			$this->restart();
-      			      		
+
       			$sql = "INSERT INTO $item_view_table " .
 		     			"(total_time, " .
 		     			"start_time, " .
@@ -2227,13 +2227,13 @@ function get_terms()
 		     			"'".Database::escape_string($this->current_data)."'," .
 		     			//"'".$this->get_max_time_allowed()."'," .
 		     			"'".$this->lesson_location."')";
-		     			
+
       			if($this->debug>2){error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view forced: '.$sql,0);}
 		     	$res = api_sql_query($sql,__FILE__,__LINE__);
-		     	$this->db_item_view_id = Database::get_last_insert_id();	     	
-		     	$inserted = true;	
-		   }     		
-      		
+		     	$this->db_item_view_id = Database::get_last_insert_id();
+		     	$inserted = true;
+		   }
+
 	     	$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 	     	$check = "SELECT * FROM $item_view_table " .
 	     			"WHERE lp_item_id = ".$this->db_id. " " .
@@ -2294,72 +2294,72 @@ function get_terms()
 			     			"AND lp_view_id = ".$this->view_id." " .
 			     			"AND view_count = ".$this->attempt_id;
 	     		} else {
-	     			//for all other content types...	
+	     			//for all other content types...
 	     			if ($this->type=='quiz') {
-	     				$my_status = ' ';	
-	     				$total_time = ' ';	     				 
+	     				$my_status = ' ';
+	     				$total_time = ' ';
 	     				if (!empty($_REQUEST['exeId'])) {
 							$TBL_TRACK_EXERCICES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-							
+
 							$safe_exe_id = Database::escape_string($_REQUEST['exeId']);
 		     				$sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.(int)$safe_exe_id;
 							$res = api_sql_query($sql,__FILE__,__LINE__);
-							$row_dates = Database::fetch_array($res);		
-	
+							$row_dates = Database::fetch_array($res);
+
 							$time_start_date = convert_mysql_date($row_dates['start_date']);
 							$time_exe_date 	 = convert_mysql_date($row_dates['exe_date']);
 							$mytime = ((int)$time_exe_date-(int)$time_start_date);
 							$total_time =" total_time = ".$mytime.", ";
-	     				}																							     				    					     			
+	     				}
 	     			} else {
 	     				$my_type_lp=learnpath::get_type_static($this->lp_id);
 	     				// this is a array containing values finished
 	     				$case_completed=array('completed','passed','browsed');
 
 	     				//is not multiple attempts
-	     				if ($this->get_prevent_reinit()==1) {				
+	     				if ($this->get_prevent_reinit()==1) {
 			  		     	// process of status verified into data base
-		     				
+
 		     				$sql_verified='SELECT status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
 		     				$rs_verified=api_sql_query($sql_verified,__FILE__,__LINE__);
 		     				$row_verified=Database::fetch_array($rs_verified);
-		     				
-		     				//get type lp: 1=lp dokeos and  2=scorm 	
-			    			// if not is completed or passed or browsed and learning path is scorm			     			
+
+		     				//get type lp: 1=lp dokeos and  2=scorm
+			    			// if not is completed or passed or browsed and learning path is scorm
 		     				if(!in_array($this->get_status(false),$case_completed) && $my_type_lp==2 ) {//&& $this->type!='dir'
-		     					$total_time =" total_time = total_time +".$this->get_total_time().", "; 
-		     					$my_status = " status = '".$this->get_status(false)."' ,"; 
+		     					$total_time =" total_time = total_time +".$this->get_total_time().", ";
+		     					$my_status = " status = '".$this->get_status(false)."' ,";
 		     				} else {
 		     					//verified into data base
 		     					if (!in_array($row_verified['status'],$case_completed) && $my_type_lp==2 ) { //&& $this->type!='dir'
 		     						$total_time =" total_time = total_time +".$this->get_total_time().", ";
-		     						$my_status = " status = '".$this->get_status(false)."' ,"; 
+		     						$my_status = " status = '".$this->get_status(false)."' ,";
 		     	 				} elseif (in_array($row_verified['status'],$case_completed) && $my_type_lp==2 && $this->type!='sco' ) {//&& $this->type!='dir'
 		     	 					$total_time =" total_time = total_time +".$this->get_total_time().", ";
-		     	 					$my_status = " status = '".$this->get_status(false)."' ,"; 
+		     	 					$my_status = " status = '".$this->get_status(false)."' ,";
 		     					}else {
-		     	 				//&& !in_array($row_verified['status'],$case_completed)			     	 				
+		     	 				//&& !in_array($row_verified['status'],$case_completed)
 		     	 				//is lp dokeos
 		     	 					if ($my_type_lp==1 && $this->type!='chapter') {
 	     								$total_time =" total_time = total_time + ".$this->get_total_time().", ";
-	     								$my_status = " status = '".$this->get_status(false)."' ,"; 
-	     							}	
-		     	 				}		     					
+	     								$my_status = " status = '".$this->get_status(false)."' ,";
+	     							}
+		     	 				}
 		     				}
 	     				} else {
 	     					// is multiple attempts
 	     					if (in_array($this->get_status(false),$case_completed) &&  $my_type_lp==2) {
-	     						//reset zero new attempt ?	     						
+	     						//reset zero new attempt ?
 	     						$my_status = " status = '".$this->get_status(false)."' ,";
 	     					}  elseif (!in_array($this->get_status(false),$case_completed) &&  $my_type_lp==2){
 	     						$total_time =" total_time = ".$this->get_total_time().", ";
-	     						$my_status = " status = '".$this->get_status(false)."' ,";	     						
+	     						$my_status = " status = '".$this->get_status(false)."' ,";
 	     					} else {
 	     						//is dokeos LP
 	     						$total_time =" total_time = total_time +".$this->get_total_time().", ";
-	     						$my_status = " status = '".$this->get_status(false)."' ,"; 
-	     					}	
-	     					
+	     						$my_status = " status = '".$this->get_status(false)."' ,";
+	     					}
+
 	     					//code added by isaac flores
 	     					//this code line fix the problem of wrong status
 	     					if ( $my_type_lp==2) {
@@ -2373,12 +2373,12 @@ function get_terms()
 						     	} else {
 						     		$total_time =" total_time = total_time +".$this->get_total_time().", ";
 						     	}
-	     					}     					
-	     				}	     						
+	     					}
+	     				}
 	     				/*if ($my_type_lp==1 && !in_array($row_verified['status'],$case_completed)) {
 	     					$total_time =" total_time = total_time + ".$this->get_total_time().", ";
 	     				}*/
-	     				
+
 	     			}
 
 			     	$sql = "UPDATE $item_view_table " .
@@ -2393,7 +2393,7 @@ function get_terms()
 			     			"WHERE lp_item_id = ".$this->db_id." " .
 			     			"AND lp_view_id = ".$this->view_id." " .
 			     			"AND view_count = ".$this->attempt_id;
-			     			
+
 			     			$this->current_start_time = time();
 	     		}
 	    	 	if($this->debug>2){error_log('New LP - In learnpathItem::write_to_db() - Updating item_view: '.$sql,0);}

+ 5 - 5
main/newscorm/learnpathList.class.php

@@ -17,10 +17,10 @@ class learnpathList {
 	var $course_code;
 	var $user_id;
 	var $refs_active = false;
-	
+
 	/**
 	 * This method is the constructor for the learnpathList. It gets a list of available learning paths from
-	 * the database and creates the learnpath objects. This list depends on the user that is connected 
+	 * the database and creates the learnpath objects. This list depends on the user that is connected
 	 * (only displays) items if he has enough permissions to view them.
 	 * @param	integer		User ID
 	 * @param	string		Optional course code (otherwise we use api_get_course_id())
@@ -59,7 +59,7 @@ class learnpathList {
 			}
 			//check if visible
 			$vis = api_get_item_visibility(api_get_course_info($course_code),'learnpath',$row['id']);
-			
+
     		$this->list[$row['id']] = array(
     			'lp_type' => $row['lp_type'],
     			'lp_name' => stripslashes($row['name']),
@@ -76,7 +76,7 @@ class learnpathList {
     			'lp_scorm_debug' => $row['debug'],
     			'lp_display_order' => $row['display_order'],
     			'lp_preview_image' => stripslashes($row['preview_image'])
-    			); 
+    			);
     		$names[$row['name']]=$row['id'];
        	}
        	$this->alpha_list = asort($names);
@@ -84,7 +84,7 @@ class learnpathList {
     /**
      * Gets references to learnpaths for all learnpaths IDs kept in the local list.
      * This applies a transformation internally on list and ref_list and returns a copy of the refs list
-     * @return	array	List of references to learnpath objects	
+     * @return	array	List of references to learnpath objects
      */
     function get_refs(){
     	foreach($this->list as $id => $dummy)

+ 63 - 63
main/newscorm/learnpath_functions.inc.php

@@ -42,13 +42,13 @@
 * @todo rename functions to coding conventions: not deleteitem but delete_item, etc
 * @todo rewrite functions to comply with phpDocumentor
 * @todo remove code duplication
-============================================================================== 
+==============================================================================
 */
 
 /**
  * This function deletes an item
  * @param integer 	$id: the item we want to delete
- * @return boolean	True if item was deleted, false if not found or error 
+ * @return boolean	True if item was deleted, false if not found or error
  **/
 function deleteitem($id)
 {
@@ -139,7 +139,7 @@ function deletemodule($parent_item_id)
  * This function deletes an entire path.
  *
  * @param integer 	$id: the path we want to delete
- * @return	void 
+ * @return	void
  **/
 function deletepath($path_id)
 {
@@ -166,7 +166,7 @@ function deletepath($path_id)
  * @param string    $direction: move the given chapter up or down
  * @param integer   Item ID
  * @param integer   $moduleid: the id of the chapter the element resides in
- * @return	boolean	Returns false on error 
+ * @return	boolean	Returns false on error
  * @note    With this new version, the moveitem deals with items AND directories (not the base-level modules). This is a lot more complicated but is a temporary step towards new database structure as 'everything is an item'
  **/
 function moveitem($direction, $id, $moduleid, $type = 'item')
@@ -257,7 +257,7 @@ function moveitem($direction, $id, $moduleid, $type = 'item')
  *
  * @param   string $direction: move the given chapter up or down
  * @param   integer $id: the id of the chapter we want to move
- * @return	void 
+ * @return	void
  **/
 function movemodule($direction, $id)
 {
@@ -315,9 +315,9 @@ function movemodule($direction, $id)
  * @param		string	Chapter name
  * @param		string	Chapter description (optional)
  * @param		integer	Parent chapter ID (default: 0)
- * @param		integer Learnpath ID 
+ * @param		integer Learnpath ID
  * @param		mixed		If type 'item', then array(prereq_id=>value, prereq_..)
- * @return	integer	The new chapter ID, or false on failure 
+ * @return	integer	The new chapter ID, or false on failure
  * @TODO	Finish this function before it is used. Currently only chapters can be added using it.
  * @note This function is currently never used!
  */
@@ -327,8 +327,8 @@ function insert_item($type = 'item', $name, $chapter_description = '', $parent_i
 	$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
 
 	// getting the last order number from the chapters table, in this learnpath, for the parent chapter given
-	$sql = "SELECT * FROM $tbl_learnpath_chapter 
-			WHERE lp_id=$learnpath_id 
+	$sql = "SELECT * FROM $tbl_learnpath_chapter
+			WHERE lp_id=$learnpath_id
 			AND parent_item_id = $parent_id
 			ORDER BY display_order DESC";
 	$result = api_sql_query($sql, __FILE__, __LINE__);
@@ -336,7 +336,7 @@ function insert_item($type = 'item', $name, $chapter_description = '', $parent_i
 	$last_chapter_order = $row["display_order"];
 
 	// getting the last order number of the items
-	$sql = "SELECT * FROM $tbl_learnpath_item 
+	$sql = "SELECT * FROM $tbl_learnpath_item
 			AND parent_item_id = $parent_id
 			ORDER BY display_order DESC";
 	$result = api_sql_query($sql, __FILE__, __LINE__);
@@ -346,11 +346,11 @@ function insert_item($type = 'item', $name, $chapter_description = '', $parent_i
 
 	if ($type === 'chapter')
 	{
-		$sql = "INSERT INTO $tbl_learnpath_chapter 
-						(lp_id, chapter_name, chapter_description, display_order) 
-						VALUES ('".domesticate($learnpath_id)."', 
+		$sql = "INSERT INTO $tbl_learnpath_chapter
+						(lp_id, chapter_name, chapter_description, display_order)
+						VALUES ('".domesticate($learnpath_id)."',
 						'".domesticate(htmlspecialchars($chapter_name))."',
-						'".domesticate(htmlspecialchars($chapter_description))."', 
+						'".domesticate(htmlspecialchars($chapter_description))."',
 						$new_order )";
 		$result = api_sql_query($sql, __FILE__, __LINE__);
 		if ($result === false)
@@ -361,11 +361,11 @@ function insert_item($type = 'item', $name, $chapter_description = '', $parent_i
 	}
 	elseif ($type === 'item')
 	{
-		$sql = "INSERT INTO $tbl_learnpath_item 
-						(parent_item_id, item_type, item_id, display_order) 
-						VALUES ('".domesticate($parent_id)."', 
+		$sql = "INSERT INTO $tbl_learnpath_item
+						(parent_item_id, item_type, item_id, display_order)
+						VALUES ('".domesticate($parent_id)."',
 						'".domesticate(htmlspecialchars($item_type))."',
-						'".domesticate(htmlspecialchars($item_id))."', 
+						'".domesticate(htmlspecialchars($item_id))."',
 						$new_order )";
 		$result = api_sql_query($sql, __FILE__, __LINE__);
 		if ($result === false)
@@ -383,7 +383,7 @@ function insert_item($type = 'item', $name, $chapter_description = '', $parent_i
  **/
 function array_learnpath_categories()
 {
-	#global $tbl_learnpath_chapter; 
+	#global $tbl_learnpath_chapter;
 	global $learnpath_id;
 	$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
 
@@ -415,8 +415,8 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array (), $leve
 	global $xml_output;
 	global $learnpath_id;
 	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
-	
-	
+
+
 	// @todo: coding standards: Language variables are CaMMelCaSe, all other variables should use the underscoring method.
 	$lang_move_down = get_lang('_move_down');
 	$lang_move_up = get_lang('lang_move_up');
@@ -522,7 +522,7 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array (), $leve
 					echo "  <td align='center'>&nbsp;</td>\n";
 					//echo "  <td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&amp;action=editmodule&amp;id=".$row["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9>"."<img src=\"../img/edit.gif\" border=\"0\" title=\"$lang_edit_learnpath_module\">"."</a>"."</td>\n";
 					echo "  <td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=edititem&id=".$row["id"]."'>"."<img src=\"../img/edit.gif\" border=\"0\" title=\"$lang_edit_learnpath_module\">"."</a>"."</td>\n";
-					
+
 					//echo "  <td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&amp;action=deletemodule&amp;id=".$row["id"]."'&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 onclick=\"return confirmation('".$row['chapter_name']."');\">"."<img src=\"../img/delete.gif\" border=\"0\" title=\"$lang_delete_learnpath_module\">"."</a>"."</td>\n";
 					echo "  <td align='center'>"."<a href='".api_get_self()."?lp_id=$learnpath_id&action=delete_item&id=".$row["id"]."' onclick=\"return confirmation('".$row['title']."');\">"."<img src=\"../img/delete.gif\" border=\"0\" title=\"$lang_delete_learnpath_module\">"."</a>"."</td>\n";
 				}
@@ -845,7 +845,7 @@ function learnpath_chapters($learnpath_id)
 	global $xml_output, $learnpath_id;
 	//$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
 	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
-	
+
 
 	$sql_items = "SELECT * FROM $tbl_lp_item WHERE lp_id='$learnpath_id' AND item_type='dokeos_chapter' ORDER BY display_order ASC";
 	//$sql_items = "SELECT * FROM $tbl_learnpath_chapter WHERE lp_id='$learnpath_id' ORDER BY display_order ASC";
@@ -869,7 +869,7 @@ function is_prereq($learnpath_id)
 {
 	global $xml_output;
 	$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
-	
+
 	$prereq = false;
 
 	$sql_items = "SELECT * FROM $tbl_lp_item WHERE lp_id='$learnpath_id' AND parent_item_id=0 ORDER BY display_order ASC";
@@ -1045,7 +1045,7 @@ function get_learnpath_tree($learnpath_id)
 {
 	//error_log('New LP - In learnpath_functions::get_learnpath_tree',0);
 	//init elems
-	#global $tbl_learnpath_item, $tbl_learnpath_chapter; 
+	#global $tbl_learnpath_item, $tbl_learnpath_chapter;
 	/*
 	$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
 	$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
@@ -1137,15 +1137,15 @@ function get_ordered_items_list($tree, $chapter = 0, $include_chapters = false)
 }
 
 /**
- * Displays the structure of a chapter recursively. Takes the result of get_learnpath_tree as argument 
+ * Displays the structure of a chapter recursively. Takes the result of get_learnpath_tree as argument
  * @param	array		Chapter structure
  * @param	integer	Chapter ID (start point in the tree)
- * @param	integer	Learnpath ID 
+ * @param	integer	Learnpath ID
  * @param	integer	User ID
- * @param	boolean	Indicates if the style is wrapped (true) or extended (false) 
+ * @param	boolean	Indicates if the style is wrapped (true) or extended (false)
  * @param	integer	Level reached so far in the tree depth (enables recursive behaviour)
  * @return	array		Number of items, Number of items completed
- * @author	Many changes by Yannick Warnier <yannick.warnier@dokeos.com> 
+ * @author	Many changes by Yannick Warnier <yannick.warnier@dokeos.com>
  **/
 function display_toc_chapter_contents($tree, $parent_item_id = 0, $learnpath_id, $uid, $wrap, $level = 0)
 {
@@ -1327,7 +1327,7 @@ function get_tracking_table($learnpath_id, $user_id, $parent_item_id = 0, $tree
 /**
  * This function returns false if there is at least one item in the path
  * @param	Learnpath ID
- * @return	boolean	True if nothing was found, false otherwise 
+ * @return	boolean	True if nothing was found, false otherwise
  */
 function is_empty($id)
 {
@@ -1362,12 +1362,12 @@ function is_empty($id)
 }
 
 /**
- * This function writes $content to $filename   
+ * This function writes $content to $filename
  * @param	string	Destination filename
  * @param	string	Learnpath name
  * @param	integer	Learnpath ID
  * @param	string	Content to write
- * @return	void 
+ * @return	void
  */
 function exporttofile($filename, $LPname, $LPid, $content)
 {
@@ -1597,9 +1597,9 @@ function export_exercise($item_id)
  * @param	integer	Id from learnpath_items table
  * @param	integer	Item id
  * @param	string	Itm type
- * @param	boolean	Shall the SCORM communications features be added? (true). Default: false. 
+ * @param	boolean	Shall the SCORM communications features be added? (true). Default: false.
  * @return	void (outputs a zip file)
- * @todo	Try using the SCORM communications addition (adding a button and several javascript calls to the SCORM API) elsewhere than just in the export feature, so it doesn't look like an incoherent feature 
+ * @todo	Try using the SCORM communications addition (adding a button and several javascript calls to the SCORM API) elsewhere than just in the export feature, so it doesn't look like an incoherent feature
  */
 
 function exportitem($id, $item_id, $item_type, $add_scorm_communications = false)
@@ -1629,18 +1629,18 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 	include_once ("../lang/".$language_interface."/exercice.inc.php");
 
 	include_once (api_get_path(LIBRARY_PATH).'text.lib.php');
-	include_once ("../resourcelinker/resourcelinker.inc.php");	
+	include_once ("../resourcelinker/resourcelinker.inc.php");
 
 	$LPname = display_addedresource_link_in_learnpath($item_type, $item_id, '', $id, 'builder', 'nolink');
 
-	$expcontent = "<!-- 
+	$expcontent = "<!--
 		This is an exported file from Dokeos Learning Path belonging to a Scorm compliant content package.
 		Do not modify or replace individually.
-			
+
 		Export module author : Denes Nagy <darkden@evk.bke.hu>
-	
+
 		-->
-			
+
 		";
 	//files needed for communicating with the scos
 	$scocomfiles = "<script type='text/javascript' src='../js/APIWrapper.js'></script>"."<script type='text/javascript' src='../js/SCOFunctions.js'></script>";
@@ -1666,7 +1666,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 				</table>
 			</form>";
 
-	/** 
+	/**
 	 * switch between the different element types, namely:
 	 * - Agenda
 	 * - Ad_Valvas
@@ -1682,7 +1682,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 	 * - Assignments	]  Theses elements are all replaced by a simple message in the exported document
 	 * - Groups					]
 	 * - Users						]
-	 * - Link _self  
+	 * - Link _self
 	 * - Link _blank
 	 */
 	switch ($item_type)
@@ -1854,10 +1854,10 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 			$filename = 'data/'.$filename.$pathname[$last];
 			$copyneeded = true;
 
-			//htm files do not need to be copied as the ok button is inserted into them, 
+			//htm files do not need to be copied as the ok button is inserted into them,
 			//so don't copy directly
 			$extension = explode(".", $pathname[$last]);
-			//This old condition was WRONG for names like design.html.old. Instead, we now get the extension 
+			//This old condition was WRONG for names like design.html.old. Instead, we now get the extension
 			// by using preg_match to match case-insensitive (probably faster than 4 conditions)
 			//if (($extension[1]=='htm') or ($extension[1]=='html') or ($extension[1]=='HTM') or ($extension[1]=='HTML')) {
 			//4 Check the file extension
@@ -1874,7 +1874,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 				$file = file_get_contents($orig);
 
 				//4.a.2 Get all the src links in this file
-				//preg_match_all("|((?i)src=\".*\" )|U",$file,$match);				
+				//preg_match_all("|((?i)src=\".*\" )|U",$file,$match);
 				$match = GetSRCTags($orig);
 
 				//4.a.3 For each src tag found, do the following:
@@ -1899,7 +1899,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 						//the previous lines are used when creating docs with Dokeos Document tool's htmlarea
 						//rows marked by 'mp3' are needed because the mp3 plugin inserts the swf-mp3 links in a very strange way
 						//and we can decode them with those 3 lines, hoping this will not cause errors in case of other htmls,
-						//created by any other software												
+						//created by any other software
 						//4.a.3.2.a.4 Prepare source and destination paths
 						$source = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.dirname($myrow['path']).'/'.$src;
 						$dest = $expdir.'/data/'.$src;
@@ -1927,7 +1927,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 					{
 						$file .= $scocomfiles.$donebutton;
 					}
-				} //sco communication insertion end	
+				} //sco communication insertion end
 
 				//4.a.5 Replace the file's name by adding the element's ID before htm
 				// This will not work with uppercase HTML though. Maybe use the preg_replace syntax proposed...
@@ -1999,7 +1999,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 					//The previous lines are used when creating docs with Dokeos Document tool's htmlarea
 					//rows marked by 'mp3' are needed because the mp3 plugin inserts the swf-mp3 links in a very strange way
 					//and we can decode them with those 3 lines, hoping this will not cause errors in case of other htmls,
-					//created by any other software												
+					//created by any other software
 					//Prepare source and destination paths
 					$source = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.dirname($myrow['path']).'/'.$src;
 					$dest = $expdir.'/data/'.$src;
@@ -2029,7 +2029,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 			//8 Finally, add the API loading calls (although that might have been done first)
 			$content = str_replace("</script>", "</script>".$scocomfiles.$start, $content);
 
-			//9 Change the filename to add the database ID and export to a new file, 
+			//9 Change the filename to add the database ID and export to a new file,
 			//  setting the circle1_files array for later reuse
 			$filename = str_replace('.htm', $id.'.htm', $filename);
 			exporttofile($filename, $LPname, $id, $content);
@@ -2188,7 +2188,7 @@ function exportpath($learnpath_id)
 {
 	//1 Initialise variables
 	global $_course, $circle1_files, $LPnamesafe, $LPname, $expdir;
-	//$tbl_learnpath_main, $tbl_learnpath_chapter, $tbl_learnpath_item, 
+	//$tbl_learnpath_main, $tbl_learnpath_chapter, $tbl_learnpath_item,
 	$tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
 	$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
 	$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
@@ -2204,7 +2204,7 @@ function exportpath($learnpath_id)
 	$LPname = $row['learnpath_name'];
 	$LPnamesafe = replace_dangerous_char($LPname, 'strict');
 
-	//3 Get a temporary dir for creating the zip file	
+	//3 Get a temporary dir for creating the zip file
 	$expdir = api_get_path('SYS_COURSE_PATH').$_course['path']."/temp/".$LPnamesafe;
 	$fromdir = '../scorm/export/'; //this dir contains some standard files
 
@@ -2222,11 +2222,11 @@ function exportpath($learnpath_id)
 	//$circle2=array('');
 
 	//4 Get the first level chapters - YW added parent_item_id condition for multi-level paths
-	$sql = "SELECT * FROM $tbl_learnpath_chapter 
-			WHERE (lp_id=$learnpath_id and parent_item_id=0) 
+	$sql = "SELECT * FROM $tbl_learnpath_chapter
+			WHERE (lp_id=$learnpath_id and parent_item_id=0)
 			ORDER BY display_order ASC";
 	//to get all the elements, we should use the function that builds the table of content get_learnpath_tree
-	//WHERE (lp_id=$learnpath_id) 
+	//WHERE (lp_id=$learnpath_id)
 	//ORDER BY parent_item_id, display_order ASC";
 	$result = api_sql_query($sql, __FILE__, __LINE__);
 
@@ -2236,7 +2236,7 @@ function exportpath($learnpath_id)
 		//5.1 Get items data from the database for this chapter
 		$parent_item_id = $row['id'];
 		//$sql2a="SELECT * FROM $tbl_learnpath_chapter WHERE (lp_id=$learnpath_id and parent_item_id=$parent_item_id) ORDER BY display_order ASC";
-		//$result2a=api_sql_query($sql,__FILE__,__LINE__); 		
+		//$result2a=api_sql_query($sql,__FILE__,__LINE__);
 		$sql2b = "SELECT * FROM $tbl_learnpath_item WHERE (parent_item_id=$parent_item_id) ORDER BY display_order ASC";
 		$result2b = api_sql_query($sql2b, __FILE__, __LINE__);
 
@@ -2316,11 +2316,11 @@ function exportpath($learnpath_id)
  * Export SCORM content into a zip file
  *
  * Basically, all this function does is put the scorm directory back into a zip file (like the one
- * that was most probably used to import the course at first) 
+ * that was most probably used to import the course at first)
  * @param	string	Name of the SCORM path (or the directory under which it resides)
  * @param	array		Not used right now. Should replace the use of global $_course
- * @return	void 
- * @author	imandak80 
+ * @return	void
+ * @author	imandak80
  */
 function exportSCORM($scormname, $course)
 {
@@ -2342,7 +2342,7 @@ function exportSCORM($scormname, $course)
 		//  echo "Error  : ".$zip_folder->errorInfo(true);
 	}
 
-	//send to client	
+	//send to client
 	DocumentManager :: file_send_for_download($zipfilename, false, basename($scormname.".zip"));
 
 	//clear
@@ -2352,7 +2352,7 @@ function exportSCORM($scormname, $course)
 
 /**
  * This function returns an xml tag
- * $data behaves as the content in case of full tags 
+ * $data behaves as the content in case of full tags
  * $data is an array of attributes in case of returning an opening tag
  * @param	string
  * @param	string
@@ -2405,13 +2405,13 @@ function xmltagwrite($tagname, $which, $data, $linebreak = "yes")
  * This function writes the imsmanifest.xml and exports the chapter names
  * @param	array		Array containing filenames
  * @param	integer	Learnpath_id
- * @return	void 
+ * @return	void
  */
 function createimsmanifest($circle1_files, $learnpath_id)
 {
 	global $charset;
 	global $_course, $LPname, $expdir, $LPnamesafe;
-	//$tbl_learnpath_main, $tbl_learnpath_chapter, $tbl_learnpath_item, 
+	//$tbl_learnpath_main, $tbl_learnpath_chapter, $tbl_learnpath_item,
 	$tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
 	$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
 	$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
@@ -2596,7 +2596,7 @@ function createimsmanifest($circle1_files, $learnpath_id)
 	* @param	string	file path
 	* @return	mixed		array of strings on success, false on failure
 	* @author unknown
-	* @author included by imandak80 
+	* @author included by imandak80
 	*/
 function GetSRCTags($fileName)
 {
@@ -2632,7 +2632,7 @@ function GetSRCTags($fileName)
  * Copy file and create directories in the path if needed.
  *
  * @param	string	$source Source path
- * @param	string	$dest Destination path 
+ * @param	string	$dest Destination path
  * @return boolean 	true on success, false on failure
  */
 function CopyNCreate($source, $dest)

+ 11 - 11
main/newscorm/lp_add.php

@@ -21,7 +21,7 @@
 */
 
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -29,14 +29,14 @@
 * @author Roan Embrechts, refactoring and code cleaning
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $this_section=SECTION_COURSES;
 
 api_protect_course_script();
@@ -45,7 +45,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -53,14 +53,14 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = 'learnpath';
 
 /*
 -----------------------------------------------------------
 	Header and action code
 -----------------------------------------------------------
-*/ 
+*/
 $currentstyle = api_get_setting('stylesheets');
 //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'css/'.$currentstyle.'/learnpath.css"/>';
 //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="learnpath.css" />'; //will be a merged with original learnpath.css
@@ -69,7 +69,7 @@ $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="dtree.css" />';
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -97,21 +97,21 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 /*
 -----------------------------------------------------------
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')

+ 104 - 104
main/newscorm/lp_add_item.php

@@ -22,8 +22,8 @@
 
 
 /**
-============================================================================== 
-* This is a learning path creation and player tool in Dokeos - previously 
+==============================================================================
+* This is a learning path creation and player tool in Dokeos - previously
 * learnpath_handler.php
 *
 * @author Patrick Cool
@@ -32,14 +32,14 @@
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update
 * @author Julio Montoya  - Improving the list of templates
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $this_section=SECTION_COURSES;
 
 api_protect_course_script();
@@ -48,7 +48,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -56,49 +56,49 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 
 /*
 -----------------------------------------------------------
 	Header and action code
 -----------------------------------------------------------
-*/ 
+*/
 $htmlHeadXtra[] = '
 <script type="text/javascript">
 
 var temp=false;
 var temp2=false;
 var use_document_title='.api_get_setting('use_document_title').';
-var load_default_template = '. ((isset($_POST['submit']) || empty($_SERVER['QUERY_STRING'])) ? 'false' : 'true' ) .';	
-				
+var load_default_template = '. ((isset($_POST['submit']) || empty($_SERVER['QUERY_STRING'])) ? 'false' : 'true' ) .';
+
 function FCKeditor_OnComplete( editorInstance )
-{	
-	editorInstance.Events.AttachEvent( \'OnSelectionChange\', check_for_title ) ;	
-	document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";	
-}	
-		
+{
+	editorInstance.Events.AttachEvent( \'OnSelectionChange\', check_for_title ) ;
+	document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
+}
+
 function check_for_title()
 	{
 		if(temp==true){
 			// This functions shows that you can interact directly with the editor area
 			// DOM. In this way you have the freedom to do anything you want with it.
-	
+
 			// Get the editor instance that we want to interact with.
 			var oEditor = FCKeditorAPI.GetInstance(\'content_lp\') ;
-	
+
 			// Get the Editor Area DOM (Document object).
 			var oDOM = oEditor.EditorDocument ;
-	
+
 			var iLength ;
 			var contentText ;
 			var contentTextArray;
 			var bestandsnaamNieuw = "";
 			var bestandsnaamOud = "";
-	
+
 			// The are two diffent ways to get the text (without HTML markups).
 			// It is browser specific.
-	
+
 			if( document.all )		// If Internet Explorer.
 			{
 				contentText = oDOM.body.innerText ;
@@ -111,7 +111,7 @@ function check_for_title()
 			}
 
 			var index=contentText.indexOf("/*<![CDATA");
-			contentText=contentText.substr(0,index);			
+			contentText=contentText.substr(0,index);
 
 			// Compose title if there is none
 			contentTextArray = contentText.split(\' \') ;
@@ -127,27 +127,27 @@ function check_for_title()
 					bestandsnaamNieuw += contentTextArray[x];
 				}
 			}
-			
-		
+
+
 		}
 		temp=true;
-	}		
-		
+	}
+
 function InnerDialogLoaded()
-{	 	
+{
 	if (document.all)
-	{			
-		// if is iexplorer	
-		var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);		
+	{
+		// if is iexplorer
+		var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);
 	}
 	else
-	{		
-		var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);	
-	}				
-	
-	return 	B.ClickFrame();	
-};		 
-		
+	{
+		var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
+	}
+
+	return 	B.ClickFrame();
+};
+
 </script>';
 
 $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
@@ -155,7 +155,7 @@ $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -195,9 +195,9 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -205,7 +205,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -213,7 +213,7 @@ if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -253,7 +253,7 @@ function stripslashes(str) {
 }
 function confirmation(name)
 {
-	name=stripslashes(name);	
+	name=stripslashes(name);
 	if (confirm("<?php echo $suredel; ?> " + name + " ?"))
 	{
 		return true;
@@ -261,7 +261,7 @@ function confirmation(name)
 	else
 	{
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -277,83 +277,83 @@ echo $_SESSION['oLP']->build_action_menu();
 echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
 
 	echo '<tr>';
-			
-		echo '<td class="tree">';								
-			// show the template list 			
+
+		echo '<td class="tree">';
+			// show the template list
 			if (isset($_GET['type']) && $_GET['type']=='document' && !isset($_GET['file']))
 			{
 				$count_items = count($_SESSION['oLP']->ordered_items);
 				$style = ($count_items > 12)?' style="height:250px;width:230px;overflow-x : auto; overflow-y : scroll;" ':' class="lp_tree" ';
-				echo '<div  '.$style.'>';					
+				echo '<div  '.$style.'>';
 				//build the tree with the menu items in it
-				echo $_SESSION['oLP']->build_tree();			
+				echo $_SESSION['oLP']->build_tree();
 				echo '</div>';
 				// show the template list
 				echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'; //line
-				echo '<br />';			
+				echo '<br />';
 				echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
 			} else {
-				echo '<div class="lp_tree">';					
+				echo '<div class="lp_tree">';
 				//build the tree with the menu items in it
-				echo $_SESSION['oLP']->build_tree();			
+				echo $_SESSION['oLP']->build_tree();
 				echo '</div>';
 			}
-							
-			
+
+
 		echo '</td>';
 		echo '<td class="workspace">';
-		
+
 			if(isset($new_item_id) && is_numeric($new_item_id))
 			{
 				switch($_GET['type'])
 				{
-					
+
 					case 'chapter':
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
-						Display::display_confirmation_message(get_lang('NewChapterCreated'));					
+						Display::display_confirmation_message(get_lang('NewChapterCreated'));
 						break;
-						
+
 					case TOOL_LINK:
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
-						Display::display_confirmation_message(get_lang('NewLinksCreated'));	
+						Display::display_confirmation_message(get_lang('NewLinksCreated'));
 						break;
-					
+
 					case TOOL_STUDENTPUBLICATION:
-						
+
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
 						Display::display_confirmation_message(get_lang('NewStudentPublicationCreated'));
 						break;
-						
+
 					case 'module':
-						
+
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
 						Display::display_confirmation_message(get_lang('NewModuleCreated'));
 						break;
-						
+
 					case TOOL_QUIZ:
-					
+
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
 						Display::display_confirmation_message(get_lang('NewExerciseCreated'));
 						break;
-					
-					
+
+
 					case TOOL_DOCUMENT:
 						Display::display_confirmation_message(get_lang('NewDocumentCreated'));
 						echo $_SESSION['oLP']->display_item($new_item_id, true, $msg);
 						break;
-						
-						
+
+
 					case TOOL_FORUM:
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
 						Display::display_confirmation_message(get_lang('NewForumCreated'));
 						break;
-					
-					
+
+
 					case 'thread':
 						echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
 						Display::display_confirmation_message(get_lang('NewThreadCreated'));
 						break;
-					
+
 				}
 			}
 			else
@@ -361,19 +361,19 @@ echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
 				switch($_GET['type'])
 				{
 					case 'chapter':
-						
+
 						echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter"));
-						
+
 						break;
-						
+
 					case 'module':
-					
+
 						echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule"));
-						
+
 						break;
-						
-					case 'document': 
-						
+
+					case 'document':
+
 						if(isset($_GET['file']) && is_numeric($_GET['file']))
 						{
 							echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
@@ -382,63 +382,63 @@ echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
 						{
 							echo $_SESSION['oLP']->display_document_form('add', 0);
 						}
-						
+
 						break;
-					
+
 					case 'hotpotatoes':
-					
+
 						echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']);
 
 						break;
-					
+
 					case 'quiz':
-						
+
 						echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']);
-						
+
 						break;
-						
+
 					case 'forum':
-						
+
 						echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']);
-						
+
 						break;
-						
+
 					case 'thread':
-						
+
 						echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']);
-						
+
 						break;
-					
+
 					case 'link':
-						
+
 						echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']);
-						
+
 						break;
-						
+
 					case 'student_publication':
-						
+
 						echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']);
-						
+
 						break;
-						
+
 					case 'step':
-						
+
 						echo $_SESSION['oLP']->display_resources();
-						
+
 						break;
 				}
 			}
-		
+
 		echo '</td>';
-			
+
 	echo '</tr>';
-		
+
 echo '</table>';
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 39 - 39
main/newscorm/lp_admin_view.php

@@ -22,7 +22,7 @@
 
 
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -30,14 +30,14 @@
 * @author Roan Embrechts, refactoring and code cleaning
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $this_section=SECTION_COURSES;
 
 api_protect_course_script();
@@ -46,7 +46,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -60,7 +60,7 @@ $language_file = "learnpath";
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -100,9 +100,9 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -110,7 +110,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -119,12 +119,12 @@ $therow=Database::fetch_array($result);
 
 /*==================================================
 	prerequisites setting end
- ==================================================*/		  
+ ==================================================*/
 if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -137,7 +137,7 @@ $interbreadcrumb[]= array ("url"=>api_get_self()."?action=admin_view&lp_id=$lear
 
 //Theme calls
 $show_learn_path=true;
-$lp_theme_css=$_SESSION['oLP']->get_theme(); 
+$lp_theme_css=$_SESSION['oLP']->get_theme();
 Display::display_header(null,'Path');
 //api_display_tool_title($therow['name']);
 
@@ -155,7 +155,7 @@ function stripslashes(str) {
 }
 function confirmation(name)
 {
-	name=stripslashes(name);	
+	name=stripslashes(name);
 	if (confirm("<?php echo $suredel; ?> " + name + " ?"))
 	{
 		return true;
@@ -163,7 +163,7 @@ function confirmation(name)
 	else
 	{
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -177,7 +177,7 @@ function confirmation(name)
 switch($_GET['action'])
 {
 	case 'edit_item':
-		
+
 		if(isset($is_success) && $is_success === true)
 		{
 			Display::display_confirmation_message(get_lang("_learnpath_item_edited"));
@@ -186,16 +186,16 @@ switch($_GET['action'])
 		{
 			echo $_SESSION['oLP']->display_edit_item($_GET['id']);
 		}
-		
+
 		break;
-	
+
 	case 'delete_item':
-		
+
 		if(isset($is_success) && $is_success === true)
 		{
 			Display::display_confirmation_message(get_lang("_learnpath_item_deleted"));
 		}
-		
+
 		break;
 }
 
@@ -205,7 +205,7 @@ if (isset($_POST['save_audio']))
 	// deleting the audio fragments
 	foreach ($_POST as $key=>$value) {
 		if (substr($key,0,9) == 'removemp3') {
-			$lp_items_to_remove_audio[] = str_ireplace('removemp3','',$key);			
+			$lp_items_to_remove_audio[] = str_ireplace('removemp3','',$key);
 			// removing the audio from the learning path item
 			$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 			$in = implode(',',$lp_items_to_remove_audio);
@@ -214,8 +214,8 @@ if (isset($_POST['save_audio']))
 	if (count($lp_items_to_remove_audio)>0) {
 		$sql 	= "UPDATE $tbl_lp_item SET audio = '' WHERE id IN (".$in.")";
 		$result = api_sql_query($sql, __FILE__, __LINE__);
-	}		
-	
+	}
+
 	// uploading the audio files
 	foreach ($_FILES as $key=>$value)
 	{
@@ -223,7 +223,7 @@ if (isset($_POST['save_audio']))
 		{
 			// the id of the learning path item
 			$lp_item_id = str_ireplace('mp3file','',$key);
-			
+
 			// create the audio folder if it does not exist yet
 			global $_course;
 			$filepath = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document/';
@@ -233,23 +233,23 @@ if (isset($_POST['save_audio']))
 				$perm = octdec(!empty($perm)?$perm:'0770');
 				mkdir($filepath.'audio',$perm);
 				$audio_id=add_document($_course,'/audio','folder',0,'audio');
-				api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id());				
+				api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id());
 			}
-		
-			// check if file already exits into document/audio/			
+
+			// check if file already exits into document/audio/
 			$file_name = $_FILES[$key]['name'];
 			$file_name=stripslashes($file_name);
 			//add extension to files without one (if possible)
 			$file_name=add_ext_on_mime($file_name,$_FILES[$key]['type']);
-						
+
 			$clean_name = replace_dangerous_char($file_name);
 			$clean_name = replace_accents($clean_name);
 			//no "dangerous" files
-			$clean_name = disable_dangerous_file($clean_name);			
+			$clean_name = disable_dangerous_file($clean_name);
 
 			$check_file_path = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document/audio/'.$clean_name;
-						
-			// if the file exists we generate a new name	
+
+			// if the file exists we generate a new name
 			if (file_exists($check_file_path)) {
 				$filename_components = explode('.',$clean_name);
 				// gettting the extension of the file
@@ -260,25 +260,25 @@ if (isset($_POST['save_audio']))
 				$clean_name = implode($filename_components) .'.'.$file_extension;
 				// using the new name in the $_FILES superglobal
 				$_FILES[$key]['name'] = $clean_name;
-				
+
 			}
-			
+
 			// upload the file in the documents tool
 			include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
-			$file_path = handle_uploaded_document($_course, $_FILES[$key],api_get_path('SYS_COURSE_PATH').$_course['path'].'/document','/audio',api_get_user_id(),'','','','','',false);									
-								
+			$file_path = handle_uploaded_document($_course, $_FILES[$key],api_get_path('SYS_COURSE_PATH').$_course['path'].'/document','/audio',api_get_user_id(),'','','','','',false);
+
 			// getting the filename only
 			$file_components = explode('/',$file_path);
-			$file = $file_components[count($file_components)-1];	
+			$file = $file_components[count($file_components)-1];
 
 			// store the mp3 file in the lp_item table
 			$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 			$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file)."' WHERE id = '".Database::escape_string($lp_item_id)."'";
-			api_sql_query($sql_insert_audio, __FILE__, __LINE__);			
-			
+			api_sql_query($sql_insert_audio, __FILE__, __LINE__);
+
 		}
 	}
-	
+
 	Display::display_confirmation_message(get_lang('ChangesStored'));
 }
 
@@ -286,8 +286,8 @@ echo $_SESSION['oLP']->overview();
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 11 - 11
main/newscorm/lp_ajax_last_update_status.php

@@ -1,17 +1,17 @@
 <?php //$id$
 /**
- * This script contains the server part of the xajax interaction process. The 
+ * This script contains the server part of the xajax interaction process. The
  * client part is located in lp_api.php or other api's.
- * This script exists exclusively to comply with the SCORM 1.2 rules notes that 
+ * This script exists exclusively to comply with the SCORM 1.2 rules notes that
  * say that if the SCO doesn't give a status throughout its execution, then the
- * status should be automatically set to 'completed', then the score should be 
- * evaluated against mastery_score and, if a raw score and mastery_score value 
+ * status should be automatically set to 'completed', then the score should be
+ * evaluated against mastery_score and, if a raw score and mastery_score value
  * are set, assign the final status based on that.
  * As such, this script will:
- * 1 - check the current status for the given element is still 'not attempted' 
+ * 1 - check the current status for the given element is still 'not attempted'
  * 2 - check if there is a mastery score
  * 3 - check if there is a raw score
- * 4 - if 2 or 3 are false, change the status to 'completed', else compare 
+ * 4 - if 2 or 3 are false, change the status to 'completed', else compare
  * whether the raw score is higher than the mastery score. If not, the status
  * will be set to 'failed', if yes, the status will be set to 'passed'
  * 5 - update the status in the table of contents
@@ -20,7 +20,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = 'learnpath';
 require_once('back_compat.inc.php');
 /**
@@ -59,7 +59,7 @@ function last_update_status($lp_id,$user_id,$view_id,$item_id)
         }
     }
     error_log(__LINE__);
-    
+
     // this function should only be used for SCORM paths
     if ($mylp->get_type()!=2) {
         return;
@@ -70,7 +70,7 @@ function last_update_status($lp_id,$user_id,$view_id,$item_id)
         error_log(__LINE__);
     //launch the prerequisites check and set error if needed
         $mylpi =& $mylp->items[$item_id];
-        
+
         $mystatus_in_db = $mylpi->get_status(true);
         error_log($mystatus_in_db);
         if ($mystatus_in_db == 'not attempted' or $mystatus_in_db == '') {
@@ -93,7 +93,7 @@ function last_update_status($lp_id,$user_id,$view_id,$item_id)
             $mylp->save_item($item_id,false);
         } else {
             error_log(__LINE__);
-            return $return;        	
+            return $return;
         }
     } else {
         error_log(__LINE__);
@@ -110,7 +110,7 @@ function last_update_status($lp_id,$user_id,$view_id,$item_id)
     foreach ($update_list as $my_upd_id => $my_upd_status) {
         if ($my_upd_id != $item_id) { //only update the status from other items (i.e. parents and brothers), do not update current as we just did it already
             $return .= "update_toc('".$my_upd_status."','".$my_upd_id."','no');";
-        } 
+        }
     }
     $return .= "update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');";
     $return .="update_stats();";

+ 15 - 15
main/newscorm/lp_ajax_save_item.php

@@ -11,7 +11,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = 'learnpath';
 require_once('back_compat.inc.php');
 /**
@@ -60,12 +60,12 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
         }
     }
     //$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
-    
-    
+
+
     $prereq_check = $mylp->prerequisites_match($item_id);
     if($prereq_check === true) //launch the prerequisites check and set error if needed
     {
-    
+
         $mylpi =& $mylp->items[$item_id];
         //$mylpi->set_lp_view($view_id);
         if($max!=-1)
@@ -110,9 +110,9 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
         if(is_array($interactions) && count($interactions)>0){
             foreach($interactions as $index=>$interaction){
                 //$mylpi->add_interaction($index,$interactions[$index]);
-                //fix DT#4444  
+                //fix DT#4444
                 $clean_interaction = str_replace('@.|@',',',$interactions[$index]);
-                $mylpi->add_interaction($index,$clean_interaction);          
+                $mylpi->add_interaction($index,$clean_interaction);
             }
         }
         $mylpi->set_core_exit($core_exit);
@@ -139,7 +139,7 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
     //$mylpi->write_to_db();
     $_SESSION['lpobject'] = serialize($mylp);
     if($mylpi->get_type()!='sco')
-    { //if this object's JS status has not been updated by the SCORM API, update now 
+    { //if this object's JS status has not been updated by the SCORM API, update now
         //$objResponse->addScript("lesson_status='".$mystatus."';");
         $return .= "lesson_status='".$mystatus."';";
     }
@@ -151,7 +151,7 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
         if($my_upd_id != $item_id){ //only update the status from other items (i.e. parents and brothers), do not update current as we just did it already
             //$objResponse->addScript("update_toc('".$my_upd_status."','".$my_upd_id."');");
             $return .= "update_toc('".$my_upd_status."','".$my_upd_id."');";
-        }       
+        }
     }
     //$objResponse->addScript("update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');");
     $return .= "update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');";
@@ -161,14 +161,14 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
         $return .= "logit_lms('Saved data for item ".$item_id.", user ".$user_id." (status=".$mystatus.")',2);";
         if($debug>1){error_log('End of xajax_save_item()',0);}
     }
-    
+
     if($_configuration['tracking_enabled'] && !isset($_SESSION['login_as']))
     { // if $_SESSION['login_as'] is set, then the user is an admin logged as the user
-    
+
         $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
-        
+
         $sql_last_connection="SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='".api_get_user_id()."' ORDER BY login_date DESC LIMIT 0,1";
-        
+
         $q_last_connection=api_sql_query($sql_last_connection);
         if(Database::num_rows($q_last_connection) > 0) {
         	$current_time=date('Y-m-d H:i:s');
@@ -176,12 +176,12 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
             $i_id_last_connection=$row['login_id'];
             $s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date='".$current_time."' WHERE login_id='$i_id_last_connection'";
             api_sql_query($s_sql_update_logout_date);
-        }        
+        }
     }
-    
+
    if ($mylp->get_type()==2) {
    	    $return .="update_stats();";
-   }   
+   }
     return $return;
     //return $objResponse;
 }

+ 1 - 1
main/newscorm/lp_ajax_save_objectives.php

@@ -11,7 +11,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = 'learnpath';
 require_once('back_compat.inc.php');
 /**

+ 3 - 3
main/newscorm/lp_ajax_switch_item.php

@@ -11,7 +11,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = 'learnpath';
 require_once('back_compat.inc.php');
 /**
@@ -68,7 +68,7 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
         case 'previous':
             $mylp->set_current_item($current_item);
             $mylp->previous();
-            $new_item_id = $mylp->get_current_item_id();            
+            $new_item_id = $mylp->get_current_item_id();
             if($debug>1){error_log('In {previous} - next item is '.$new_item_id.'(current: '.$current_item.')',0);}
             break;
         case 'first':
@@ -186,7 +186,7 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
     $myinteractions_count = $mylpi->get_interactions_count();
     $myobjectives_count = $mylpi->get_objectives_count();
     $mycore_exit = $mylpi->get_core_exit();
-    
+
     //$objResponse->addScript(
     $return .=
             "saved_lesson_status='not attempted';" .

+ 7 - 7
main/newscorm/lp_author_image.php

@@ -5,7 +5,7 @@
  * @author Julio Montoya Armas <gugli100@gmail.com>
  */
 
-$use_anonymous = true;	
+$use_anonymous = true;
 require_once('back_compat.inc.php');
 require_once('learnpath.class.php');
 require_once('scorm.class.php');
@@ -32,17 +32,17 @@ echo '<html>
 		$image = '../img/lp_author_background.gif';
 		echo '<div id="image_preview">';
 		echo '<table STYLE="width:250px;height:110px;background-image: url('.$image.');">';
-			echo '<tr><td align="center">';		
+			echo '<tr><td align="center">';
 			if ($_SESSION['oLP']->get_preview_image()!='')
 				echo '<img alt="" src="'.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image().'">';
 			else
-				echo Display::display_icon('unknown_250_100.jpg',' ');	
-			echo '</td></tr>';	
+				echo Display::display_icon('unknown_250_100.jpg',' ');
+			echo '</td></tr>';
 			echo '</table>';
-			echo '<div id="author_name">';			
+			echo '<div id="author_name">';
 			echo $_SESSION['oLP']->get_author();
-			echo '</div>';	
-		echo '</div>';		
+			echo '</div>';
+		echo '</div>';
 ?>
 </body>
 </html>

+ 28 - 28
main/newscorm/lp_build.php

@@ -22,7 +22,7 @@
 
 
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -30,14 +30,14 @@
 * @author Roan Embrechts, refactoring and code cleaning
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $_SESSION['whereami'] = 'lp/build';
 $this_section=SECTION_COURSES;
 
@@ -48,7 +48,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -56,14 +56,14 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 
 /*
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -109,7 +109,7 @@ $is_new = false;
 if($learnpath_id == 0)
 {
 	$is_new = true;
-	
+
 	$sql = "
 		SELECT id
 		FROM " . $tbl_lp . "
@@ -117,7 +117,7 @@ if($learnpath_id == 0)
 		LIMIT 0, 1";
 	$result = api_sql_query($sql);
 	$row = Database::fetch_array($result);
-	
+
 	$learnpath_id = $row['id'];
 }
 
@@ -125,7 +125,7 @@ $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 
 
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -133,7 +133,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -142,16 +142,16 @@ $therow=Database::fetch_array($result);
 
 /*==================================================
 	prerequisites setting end
- ==================================================*/	
+ ==================================================*/
 if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) {
 	$_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']);
 	$gradebook=	$_SESSION['gradebook'];
 } elseif (empty($_GET['gradebook'])) {
 	unset($_SESSION['gradebook']);
 	$gradebook=	'';
-} 
+}
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[] = array (
 		'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
 		'name' => get_lang('Gradebook')
@@ -181,7 +181,7 @@ function stripslashes(str) {
 }
 function confirmation(name)
 {
-	name=stripslashes(name);	
+	name=stripslashes(name);
 	if (confirm("<?php echo $suredel; ?> " + name + " ?"))
 	{
 		return true;
@@ -189,7 +189,7 @@ function confirmation(name)
 	else
 	{
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -202,20 +202,20 @@ function confirmation(name)
 */
 echo $_SESSION['oLP']->build_action_menu();
 echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
-	echo '<tr>';			
-		echo '<td class="tree">';		
-			echo '<div class="lp_tree">';					
+	echo '<tr>';
+		echo '<td class="tree">';
+			echo '<div class="lp_tree">';
 				//build the tree with the menu items in it
-				echo $_SESSION['oLP']->build_tree();			
-			echo '</div>';					
+				echo $_SESSION['oLP']->build_tree();
+			echo '</div>';
 		echo '</td>';
-		echo '<td class="workspace">';		
+		echo '<td class="workspace">';
 			if(isset($is_success) && $is_success === true) {
 				Display::display_confirmation_message(get_lang('ItemRemoved'));
 			} else {
 				if($is_new) {
 					Display::display_normal_message(get_lang('LearnpathAdded'), false);
-				}				
+				}
 					// Display::display_normal_message(get_lang('LPCreatedAddChapterStep'), false);
 					$gradebook = Security::remove_XSS($_GET['gradebook']);
 					$learnpathadded = Display::return_icon('gallery/creative.gif','',array('align'=>'right'));
@@ -225,17 +225,17 @@ echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
 					$learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&action=view&lp_id='.$_SESSION['oLP']->lp_id.'">'.Display::return_icon('learnpath_view.gif', get_lang('Display'),array('style'=> 'vertical-align: middle;')).' '.get_lang('Display').'</a>: '.get_lang('DisplayComment').'<br />';
 					$learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=chapter&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang("NewChapter").'">'.Display::return_icon('lp_dokeos_chapter_add.gif', get_lang('NewChapter'),array('style'=> 'vertical-align: middle;')).' '.get_lang('NewChapter').'</a>: '.get_lang('NewChapterComment').'<br />';
 					$learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=step&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang("NewStep").'">'.Display::return_icon('new_test.gif', get_lang('NewStep'),array('style'=> 'vertical-align: middle;')).' '.get_lang('NewStep').'</a>: '.get_lang('NewStepComment').'<br />';
-					$learnpathadded .= '<br /><br /><br /><br /></p>';										
+					$learnpathadded .= '<br /><br /><br /><br /></p>';
 					Display::display_normal_message($learnpathadded, false);
-			}		
-		echo '</td>';			
-	echo '</tr>';		
+			}
+		echo '</td>';
+	echo '</tr>';
 echo '</table>';
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 14 - 14
main/newscorm/lp_comm.server.php

@@ -11,7 +11,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = 'learnpath';
 require_once('back_compat.inc.php');
 /**
@@ -87,12 +87,12 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
 		}
 	}
 	//$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
-	
-	
+
+
 	$prereq_check = $mylp->prerequisites_match($item_id);
 	if($prereq_check === true) //launch the prerequisites check and set error if needed
 	{
-	
+
 		$mylpi =& $mylp->items[$item_id];
 		//$mylpi->set_lp_view($view_id);
 		if($max!=-1)
@@ -144,7 +144,7 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
 	}else{
 		return $objResponse;
 	}
-	
+
 	$mystatus = $mylpi->get_status(false);
 	$mytotal = $mylp->get_total_items_count_without_chapters();
 	$mycomplete = $mylp->get_complete_items_count();
@@ -153,7 +153,7 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
 	//$mylpi->write_to_db();
 	$_SESSION['lpobject'] = serialize($mylp);
 	if($mylpi->get_type()!='sco')
-	{ //if this object's JS status has not been updated by the SCORM API, update now 
+	{ //if this object's JS status has not been updated by the SCORM API, update now
 		$objResponse->addScript("lesson_status='".$mystatus."';");
 	}
 	$objResponse->addScript("update_toc('".$mystatus."','".$item_id."');");
@@ -162,7 +162,7 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
 	{
 		if($my_upd_id != $item_id){ //only update the status from other items (i.e. parents and brothers), do not update current as we just did it already
 			$objResponse->addScript("update_toc('".$my_upd_status."','".$my_upd_id."');");
-		}		
+		}
 	}
 	$objResponse->addScript("update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');");
 
@@ -170,14 +170,14 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
 		$objResponse->addScript("logit_lms('Saved data for item ".$item_id.", user ".$user_id." (status=".$mystatus.")',2)");
 		if($debug>1){error_log('End of xajax_save_item()',0);}
 	}
-	
+
 	if($_configuration['tracking_enabled'] && !isset($_SESSION['login_as']))
 	{ // if $_SESSION['login_as'] is set, then the user is an admin logged as the user
-	
+
 		$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
-		
+
 		$sql_last_connection="SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='".api_get_user_id()."' ORDER BY login_date DESC LIMIT 0,1";
-		
+
 		$q_last_connection=api_sql_query($sql_last_connection);
 		if(Database::num_rows($q_last_connection) > 0)
 		{
@@ -186,9 +186,9 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
 			$s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date=NOW() WHERE login_id='$i_id_last_connection'";
 			api_sql_query($s_sql_update_logout_date);
 		}
-		
+
 	}
-	
+
 	return $objResponse;
 }
 /**
@@ -293,7 +293,7 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
 		case 'previous':
 			$mylp->set_current_item($current_item);
 			$mylp->previous();
-			$new_item_id = $mylp->get_current_item_id();			
+			$new_item_id = $mylp->get_current_item_id();
 			if($debug>1){error_log('In {previous} - next item is '.$new_item_id.'(current: '.$current_item.')',0);}
 			break;
 		case 'first':

+ 10 - 10
main/newscorm/lp_content.php

@@ -1,7 +1,7 @@
 <?php //$id: $
 /**
  * Script that displays an error message when no content could be loaded
- * @package dokeos.learnpath 
+ * @package dokeos.learnpath
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
 /**
@@ -29,11 +29,11 @@ $dokeos_chapter = false;
 
 foreach($list as $toc) {
 	if ($toc['id']==$lp_item_id && ($toc['type']=='dokeos_chapter' || $toc['type']=='dokeos_module' || $toc['type']=='dir')) {
-		$dokeos_chapter = true;		
-	}	
+		$dokeos_chapter = true;
+	}
 }
 
-if ($dokeos_chapter) { 
+if ($dokeos_chapter) {
 	$src='blank.php';
 } else {
 	switch($lp_type){
@@ -45,9 +45,9 @@ if ($dokeos_chapter) {
 				$_SESSION['oLP']->start_current_item(); //starts time counter manually if asset
 			}else{
 				$src = 'blank.php?error=prerequisites';
-			}		
+			}
 			break;
-		case 2:  
+		case 2:
 				$_SESSION['oLP']->stop_previous_item();
 				$prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
 				if($prereq_check === true){
@@ -55,9 +55,9 @@ if ($dokeos_chapter) {
 					$_SESSION['oLP']->start_current_item(); //starts time counter manually if asset
 				}else{
 					$src = 'blank.php?error=prerequisites';
-				}		
+				}
 				break;
-		case 3:			
+		case 3:
 			//save old if asset
 			$_SESSION['oLP']->stop_previous_item(); //save status manually if asset
 			$prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
@@ -69,7 +69,7 @@ if ($dokeos_chapter) {
 			}
 			break;
 		case 4:
-			break;	
+			break;
 	}
 }
 if($debug>0){error_log('New lp - In lp_content.php - File url is '.$src,0);}
@@ -79,7 +79,7 @@ if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')

+ 138 - 138
main/newscorm/lp_controller.php

@@ -12,7 +12,7 @@ $debug = 0;
 if($debug>0) error_log('New LP -+- Entered lp_controller.php -+-',0);
 // name of the language file that needs to be included
 if (isset($_GET['action']))
-{ 
+{
 	if($_GET['action'] == 'export')
 	{ //only needed on export
 		$language_file[] = 'hotspot';
@@ -86,7 +86,7 @@ if(isset($_SESSION['lpobject']))
 			api_session_unregister('lpobject');
 		}else{
 			$_SESSION['oLP'] = $oLP;
-			$lp_found = true;			
+			$lp_found = true;
 		}
 	}
 }
@@ -94,7 +94,7 @@ if(isset($_SESSION['lpobject']))
 if($debug>0) error_log('New LP - Passed data remains check',0);
 
 if($lp_found == false || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
-	if($debug>0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new',0);		
+	if($debug>0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new',0);
 	//regenerate a new lp object? Not always as some pages don't need the object (like upload?)
 	if(!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)){
 		if($debug>0) error_log('New LP - lp_id is defined',0);
@@ -105,35 +105,35 @@ if($lp_found == false || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id
 			$lp_id = $_REQUEST['lp_id'];
 		} else {
 			$lp_id = $myrefresh_id;
-		}		
+		}
 		if (is_numeric($lp_id)) {
 			$lp_id = Database::escape_string($lp_id);
-			$sel = "SELECT * FROM $lp_table WHERE id = $lp_id";			
-				
+			$sel = "SELECT * FROM $lp_table WHERE id = $lp_id";
+
 			if($debug>0) error_log('New LP - querying '.$sel,0);
 			$res = api_sql_query($sel);
 			if(Database::num_rows($res)) {
 				$row = Database::fetch_array($res);
 				$type = $row['lp_type'];
-				if($debug>0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);			
+				if($debug>0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
 				switch($type){
 					case 1:
-				if($debug>0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);			
+				if($debug>0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
 						$oLP = new learnpath(api_get_course_id(),$lp_id,api_get_user_id());
 						if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
 						break;
 					case 2:
-				if($debug>0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);			
+				if($debug>0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
 						$oLP = new scorm(api_get_course_id(),$lp_id,api_get_user_id());
 						if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
 						break;
 					case 3:
-				if($debug>0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);			
+				if($debug>0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
 						$oLP = new aicc(api_get_course_id(),$lp_id,api_get_user_id());
 						if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
-						break;					
+						break;
 					default:
-				if($debug>0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);			
+				if($debug>0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
 						$oLP = new learnpath(api_get_course_id(),$lp_id,api_get_user_id());
 						if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
 						break;
@@ -142,8 +142,8 @@ if($lp_found == false || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id
 		} else {
 			if($debug>0) error_log('New LP - Request[lp_id] is not numeric',0);
 		}
-		
-		
+
+
 	} else {
 		if($debug>0) error_log('New LP - Request[lp_id] and refresh_id were empty',0);
 	}
@@ -179,67 +179,67 @@ $action = (!empty($_REQUEST['action'])?$_REQUEST['action']:'');
 switch($action)
 {
 	case 'add_item':
-		
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug > 0) error_log('New LP - add item action triggered', 0);
-		
-		if(!$lp_found){	
+
+		if(!$lp_found){
 			//check if the learnpath ID was defined, otherwise send back to list
-			error_log('New LP - No learnpath given for add item', 0); 
-			require('lp_list.php'); 
+			error_log('New LP - No learnpath given for add item', 0);
+			require('lp_list.php');
 		} else {
 			$_SESSION['refresh'] = 1;
-			
+
 			if(isset($_POST['submit_button']) && !empty($_POST['title'])) {
 				//if a title was sumbitted
-				 				
+
 				if(isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) {
-					//check post_time to ensure ??? (counter-hacking measure?)										
-					require('lp_add_item.php');					
-				} else { 
-					
+					//check post_time to ensure ??? (counter-hacking measure?)
+					require('lp_add_item.php');
+				} else {
+
 					$_SESSION['post_time'] = $_POST['post_time'];
-					
-					if($_POST['type'] == TOOL_DOCUMENT) {						
+
+					if($_POST['type'] == TOOL_DOCUMENT) {
 						if(isset($_POST['path']) && $_GET['edit'] != 'true') {
-							$document_id = $_POST['path'];							
-						} else {													
+							$document_id = $_POST['path'];
+						} else {
 							$document_id = $_SESSION['oLP']->create_document($_course);
-							
-						}								
+
+						}
 						$new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $document_id, $_POST['title'], $_POST['description'], $_POST['prerequisites']);
-					} else {	
+					} else {
 						//for all other item types than documents, load the item using the item type and path rather than its ID
 						$new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $_POST['path'], $_POST['title'], $_POST['description'], $_POST['prerequisites'],$_POST['maxTimeAllowed']);
 					}
-					
-					//display 					
+
+					//display
 					require('lp_add_item.php');
 				}
-			} else {				
+			} else {
 				require('lp_add_item.php');
 			}
 		}
-		
+
 		break;
-	
+
 	case 'add_lp':
-	
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug > 0) error_log('New LP - add_lp action triggered', 0);
-		
+
 		$_REQUEST['learnpath_name'] = trim($_REQUEST['learnpath_name']);
-						
+
 		if(!empty($_REQUEST['learnpath_name']))
 		{
 			$_SESSION['refresh'] = 1;
-			
+
 			if(isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time'])
 			{
 				require('lp_add.php');
@@ -247,7 +247,7 @@ switch($action)
 			else
 			{
 				$_SESSION['post_time'] = $_REQUEST['post_time'];
-							
+
 				//Kevin Van Den Haute: changed $_REQUEST['learnpath_description'] by '' because it's not used
 				//old->$new_lp_id = learnpath::add_lp(api_get_course_id(), $_REQUEST['learnpath_name'], $_REQUEST['learnpath_description'], 'dokeos', 'manual', '');
 				$new_lp_id = learnpath::add_lp(api_get_course_id(), Security::remove_XSS($_REQUEST['learnpath_name']), '', 'dokeos', 'manual', '');
@@ -257,74 +257,74 @@ switch($action)
 				{
 					//TODO maybe create a first module directly to avoid bugging the user with useless queries
 					$_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
-							
+
 					//$_SESSION['oLP']->add_item(0,-1,'dokeos_chapter',$_REQUEST['path'],'Default');
-				
+
 					require('lp_build.php');
 				}
 			}
 		}
 		else
 			require('lp_add.php');
-		
+
 		break;
-		
+
 	case 'admin_view':
-	
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug>0) error_log('New LP - admin_view action triggered',0);
-		
+
 		if(!$lp_found){ error_log('New LP - No learnpath given for admin_view', 0); require('lp_list.php'); }
 		else
 		{
 			$_SESSION['refresh'] = 1;
-			
+
 			require('lp_admin_view.php');
 		}
-		
+
 		break;
-	
+
 	case 'build':
-	
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-	
+
 		if($debug > 0) error_log('New LP - build action triggered', 0);
-		
+
 		if(!$lp_found){ error_log('New LP - No learnpath given for build', 0); require('lp_list.php'); }
 		else
 		{
 			$_SESSION['refresh'] = 1;
-			
+
 			require('lp_build.php');
 		}
-		
+
 		break;
-		
+
 	case 'delete_item':
-	
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug > 0) error_log('New LP - delete item action triggered', 0);
-		
+
 		if(!$lp_found){ error_log('New LP - No learnpath given for delete item', 0); require('lp_list.php'); }
 		else
 		{
 			$_SESSION['refresh'] = 1;
-			
+
 			if(is_numeric($_GET['id']))
 			{
 				$_SESSION['oLP']->delete_item($_GET['id']);
-				
+
 				$is_success = true;
 			}
-			
+
 			if(isset($_GET['view']) && $_GET['view'] == 'build')
 			{
 				require('lp_build.php');
@@ -334,90 +334,90 @@ switch($action)
 				require('lp_admin_view.php');
 			}
 		}
-		
+
 		break;
-		
+
 	case 'edit_item':
-	
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug > 0) error_log('New LP - edit item action triggered', 0);
-		
+
 		if(!$lp_found){ error_log('New LP - No learnpath given for edit item', 0); require('lp_list.php'); }
 		else
 		{
 			$_SESSION['refresh'] = 1;
-			
-			if(isset($_POST['submit_button']) && !empty($_POST['title'])) { 
+
+			if(isset($_POST['submit_button']) && !empty($_POST['title'])) {
 				//$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites']);
 				//todo mp3 edit
 				$audio = array();
 				if (isset($_FILES['mp3'])) $audio = $_FILES['mp3'];
 				$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites'],$audio, $_POST['maxTimeAllowed']);
-				
+
 				if(isset($_POST['content_lp'])) {
 					$_SESSION['oLP']->edit_document($_course);
-				}				
+				}
 				$is_success = true;
 			}
-			
+
 			if(isset($_GET['view']) && $_GET['view'] == 'build')
 			{
 				require('lp_edit_item.php');
 			}
 			else
-			{ 
+			{
 				require('lp_admin_view.php');
 			}
 		}
-		
+
 		break;
-	
+
 	case 'edit_item_prereq':
-	
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
-		
+
 		if(!$lp_found){ error_log('New LP - No learnpath given for edit item prereq', 0); require('lp_list.php'); }
 		else
 		{
 			if(isset($_POST['submit_button']))
 			{
 				$_SESSION['refresh'] = 1;
-				
+
 				$_SESSION['oLP']->edit_item_prereq($_GET['id'], $_POST['prerequisites'], $_POST['min_' . $_POST['prerequisites']], $_POST['max_' . $_POST['prerequisites']]);
 			}
-			
+
 			require('lp_edit_item_prereq.php');
 		}
-		
+
 		break;
-		
+
 	case 'move_item':
-		
+
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
 		}
-		
+
 		if($debug > 0) error_log('New LP - move item action triggered', 0);
-		
+
 		if(!$lp_found){ error_log('New LP - No learnpath given for move item', 0); require('lp_list.php'); }
 		else
 		{
 			$_SESSION['refresh'] = 1;
-			
+
 			if(isset($_POST['submit_button']))
 			{
 				$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], Security::remove_XSS($_POST['title']), $_POST['description']);
-				
+
 				$is_success = true;
 			}
-			
+
 			if(isset($_GET['view']) && $_GET['view'] == 'build')
 			{
 				require('lp_move_item.php');
@@ -425,27 +425,27 @@ switch($action)
 			else
 			{
 				$_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
-				
+
 				require('lp_admin_view.php');
 			}
 		}
-		
+
 		break;
-		
-	case 'view_item':	
+
+	case 'view_item':
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
-		}			
-		if($debug>0) error_log('New LP - view_item action triggered', 0);		
-		if(!$lp_found){ 
-			error_log('New LP - No learnpath given for view item', 0); require('lp_list.php'); 
+		}
+		if($debug>0) error_log('New LP - view_item action triggered', 0);
+		if(!$lp_found){
+			error_log('New LP - No learnpath given for view item', 0); require('lp_list.php');
 		} else	{
-			$_SESSION['refresh'] = 1;			
+			$_SESSION['refresh'] = 1;
 			require('lp_view_item.php');
 		}
-		
-		break;	
-		
+
+		break;
+
 	case 'upload':
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
@@ -466,7 +466,7 @@ switch($action)
 		else{
 			$_SESSION['oLP']->scorm_export();
 			exit();
-			//require('lp_list.php'); 
+			//require('lp_list.php');
 		}
 		break;
 	case 'delete':
@@ -512,9 +512,9 @@ switch($action)
 		}
 		if($debug>0) error_log('New LP - publish action triggered',0);
 		if(!$lp_found)
-		{ 
-			error_log('New LP - No learnpath given for publish',0); 
-			require('lp_list.php'); 
+		{
+			error_log('New LP - No learnpath given for publish',0);
+			require('lp_list.php');
 		}
 		else
 		{
@@ -527,9 +527,9 @@ switch($action)
 			api_not_allowed(true);
 		}
 		if($debug>0) error_log('New LP - publish action triggered',0);
-		if(!$lp_found){ 
-			error_log('New LP - No learnpath given for publish',0); 
-			require('lp_list.php'); 
+		if(!$lp_found){
+			error_log('New LP - No learnpath given for publish',0);
+			require('lp_list.php');
 		}
 		else
 		{
@@ -541,7 +541,7 @@ switch($action)
 		if(!api_is_allowed_to_edit())
 		{
 			api_not_allowed(true);
-		}		
+		}
 		if($debug>0) error_log('New LP - edit action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for edit',0); require('lp_list.php'); }
 		else{
@@ -552,15 +552,15 @@ switch($action)
 	case 'update_lp':
 		if(!api_is_allowed_to_edit()){
 			api_not_allowed(true);
-		}  
+		}
 		if($debug>0) error_log('New LP - update_lp action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for edit',0); require('lp_list.php'); }
 		else{
 			$_SESSION['refresh'] = 1;
 			$lp_name=Security::remove_XSS($_REQUEST['lp_name']);
 			$_SESSION['oLP']->set_name($lp_name);
-			$author=$_REQUEST['lp_author'];					
-			//fixing the author name (no body or html tags)		
+			$author=$_REQUEST['lp_author'];
+			//fixing the author name (no body or html tags)
 		$auth_init = stripos($author,'<p>');
 		if ( $auth_init === false ) {
 		    $auth_init = stripos($author,'<body>');
@@ -570,23 +570,23 @@ switch($action)
 		    $auth_end  =  strripos($author,'</p>');
 		    $len = $auth_end - $auth_init + 4;
             }
-						
+
 			$author_fixed=substr($author,$auth_init, $len);
-			//$author_fixed = $author; 
-					
+			//$author_fixed = $author;
+
 			$_SESSION['oLP']->set_author($author_fixed);
 			$_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
 			$_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
-			$_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);			
+			$_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
 			$_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
 			if ($_REQUEST['remove_picture'])
-			{	
-				$_SESSION['oLP']->delete_lp_image();		
-			}			
-			
+			{
+				$_SESSION['oLP']->delete_lp_image();
+			}
+
 			if ($_FILES['lp_preview_image']['size']>0)
 				$_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
-			
+
 			if (api_get_setting('search_enabled') === 'true')
 			{
 				require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
@@ -609,7 +609,7 @@ switch($action)
 			}
 
 			require('lp_list.php');
-		}	
+		}
 		break;
 	case 'add_sub_item': //add an item inside a chapter
 		if(!api_is_allowed_to_edit()){
@@ -705,11 +705,11 @@ switch($action)
 		if(!$lp_found){ error_log('New LP - No learnpath given for content',0); require('lp_list.php'); }
 		else{
 			$_SESSION['oLP']->save_last();
-			$_SESSION['oLP']->set_current_item($_GET['item_id']); 
+			$_SESSION['oLP']->set_current_item($_GET['item_id']);
 			$_SESSION['oLP']->start_current_item();
-			require('lp_content.php'); 
+			require('lp_content.php');
 		}
-		break;	
+		break;
 	case 'view':
 		if($debug > 0)
 			error_log('New LP - view action triggered', 0);
@@ -719,15 +719,15 @@ switch($action)
 			require('lp_list.php');
 		}
 		else
-		{			
+		{
 			if($debug > 0){error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0);}
 			if ( !empty($_REQUEST['item_id']) )
             {
                 $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
-            }            
+            }
 			require('lp_view.php');
 		}
-		break;		
+		break;
 	case 'save':
 		if($debug>0) error_log('New LP - save action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for save',0); require('lp_list.php'); }
@@ -735,7 +735,7 @@ switch($action)
 			$_SESSION['oLP']->save_item();
 			require('lp_save.php');
 		}
-		break;		
+		break;
 	case 'stats':
 		if($debug>0) error_log('New LP - stats action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for stats',0); require('lp_list.php'); }
@@ -765,7 +765,7 @@ switch($action)
 		if($mode == 'fullscreen'){
 			$_SESSION['oLP']->mode = 'fullscreen';
 		}else{
-			$_SESSION['oLP']->mode = 'embedded';		
+			$_SESSION['oLP']->mode = 'embedded';
 		}
 		require('lp_view.php');
 		break;
@@ -773,7 +773,7 @@ switch($action)
 		if($debug>0) error_log('New LP - switch_view_mode action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); }
 		$_SESSION['refresh'] = 1;
-		$_SESSION['oLP']->update_default_view_mode();		
+		$_SESSION['oLP']->update_default_view_mode();
 		require('lp_list.php');
 		break;
 	case 'switch_force_commit':
@@ -789,14 +789,14 @@ switch($action)
 		$_SESSION['refresh'] = 1;
 		$_SESSION['oLP']->update_reinit();
 		require('lp_list.php');
-		break;		
+		break;
 	case 'switch_scorm_debug':
 		if($debug>0) error_log('New LP - switch_scorm_debug action triggered',0);
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); }
 		$_SESSION['refresh'] = 1;
 		$_SESSION['oLP']->update_scorm_debug();
 		require('lp_list.php');
-		break;		
+		break;
 	case 'intro_cmdAdd':
 		if($debug>0) error_log('New LP - intro_cmdAdd action triggered',0);
 		//add introduction section page
@@ -808,7 +808,7 @@ switch($action)
 			$htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
 		}
 		require('lp_message.php');
-		break;	
+		break;
 	case 'return_to_course_homepage':
         if(!$lp_found){ error_log('New LP - No learnpath given for stats',0); require('lp_list.php'); }
         else{
@@ -822,7 +822,7 @@ switch($action)
             //header('location: ../course_home/course_home.php?'.api_get_cidreq()); // This is not the preferable way to go to the homepage.
             header('location: '.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php');
         }
-        break;        
+        break;
     case 'search':
         /* Include the search script, it's smart enough to know when we are
          * searching or not

+ 15 - 15
main/newscorm/lp_edit.php

@@ -19,7 +19,7 @@ if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -39,7 +39,7 @@ echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']
 echo '<a href="../newscorm/lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('scorm.gif',get_lang('ReturnToLearningPaths')).' '.get_lang('ReturnToLearningPaths').'</a>';
 echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action='.Security::remove_XSS($_GET['action']).'&amp;lp_id='.Security::remove_XSS($_GET['lp_id']).'&amp;updateaudio=true">'.Display::return_icon('audio.gif', get_lang('UpdateAllAudioFragments')).' '.get_lang('UpdateAllAudioFragments').'</a>';
 echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=chapter&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang("NewChapter").'"><img alt="'.get_lang("NewChapter").'" src="../img/lp_dokeos_chapter_add.gif" title="'.get_lang("NewChapter").'" />'.get_lang("NewChapter").'</a>';
-echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=step&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang("NewStep").'"><img alt="'.get_lang("NewStep").'" src="../img/new_test.gif" title="'.get_lang("NewStep").'" />'.get_lang("NewStep").'</a>';			
+echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=step&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang("NewStep").'"><img alt="'.get_lang("NewStep").'" src="../img/new_test.gif" title="'.get_lang("NewStep").'" />'.get_lang("NewStep").'</a>';
 
 echo '</div>';
 
@@ -91,36 +91,36 @@ $content_proximity_select->addOption(get_lang('Remote'), 'remote');
 
 
 if (api_get_setting('allow_course_theme') == 'true')
-{		
+{
 	$mycourselptheme=api_get_course_setting('allow_learning_path_theme');
-	if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1) 
-	{			
-		//LP theme picker				
+	if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1)
+	{
+		//LP theme picker
 		$theme_select = &$form->addElement('select_theme', 'lp_theme', get_lang('Theme'));
 		$form->applyFilter('lp_theme', 'trim');
-		
+
 		$s_theme = $_SESSION['oLP']->get_theme();
-		$theme_select ->setSelected($s_theme); //default	
-	}	
+		$theme_select ->setSelected($s_theme); //default
+	}
 }
 
 //Author
-$form->addElement('html_editor', 'lp_author', get_lang('Author'), array('size'=>80), array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px') ); 
+$form->addElement('html_editor', 'lp_author', get_lang('Author'), array('size'=>80), array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px') );
 $form->applyFilter('lp_author', 'html_filter');
 
-// LP image	
+// LP image
 $form->add_progress_bar();
 if( strlen($_SESSION['oLP']->get_preview_image() ) > 0)
 {
 	$show_preview_image='<img src='.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image().'>';
 	$div = '<div class="row">
 	<div class="label">'.get_lang('ImagePreview').'</div>
-	<div class="formw">	
+	<div class="formw">
 	'.$show_preview_image.'
 	</div>
-	</div>';	
-	$form->addElement('html', $div .'<br/>');	
-	$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));	
+	</div>';
+	$form->addElement('html', $div .'<br/>');
+	$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
 }
 
 $form->addElement('file', 'lp_preview_image', ($_SESSION['oLP']->get_preview_image() != '' ? get_lang('UpdateImage') : get_lang('AddImage')));

+ 57 - 57
main/newscorm/lp_edit_item.php

@@ -1,31 +1,31 @@
 <?php
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004-2008 Dokeos SPRL
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Patrick Cool
 	Copyright (c) Denes Nagy
 	Copyright (c) Yannick Warnier
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -34,14 +34,14 @@
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @author Julio Montoya  - Improving the list of templates
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $this_section=SECTION_COURSES;
 
 api_protect_course_script();
@@ -50,7 +50,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -58,35 +58,35 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 
 /*
 -----------------------------------------------------------
 	Header and action code
 -----------------------------------------------------------
-*/ 
+*/
 $htmlHeadXtra[] = '
 <script type="text/javascript">
-	
+
 function FCKeditor_OnComplete( editorInstance )
-{	
-	document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px; width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";	
-}	
-	
+{
+	document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px; width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
+}
+
 function InnerDialogLoaded()
-{	
+{
 	if (document.all)
-	{			
+	{
 		// if is iexplorer
-		var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);		
+		var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);
 	}
 	else
-	{		
-		var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);	
-	}			
+	{
+		var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
+	}
 	return B.ClickFrame();
-};	
+};
 
 </script>';
 $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
@@ -94,7 +94,7 @@ $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -134,9 +134,9 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -144,7 +144,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -153,12 +153,12 @@ $therow=Database::fetch_array($result);
 
 /*==================================================
 	prerequisites setting end
- ==================================================*/		  
+ ==================================================*/
 if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -187,7 +187,7 @@ function stripslashes(str) {
 }
 function confirmation(name)
 {
-	name=stripslashes(name);	
+	name=stripslashes(name);
 	if (confirm("<?php echo $suredel; ?> " + name + " ?"))
 	{
 		return true;
@@ -195,7 +195,7 @@ function confirmation(name)
 	else
 	{
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -209,53 +209,53 @@ function confirmation(name)
 
 echo $_SESSION['oLP']->build_action_menu();
 echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
-		echo '<tr>';			
+		echo '<tr>';
 		echo '<td class="tree">';
-		
-		$path_item = isset($_GET['path_item'])?$_GET['path_item']:0;		
+
+		$path_item = isset($_GET['path_item'])?$_GET['path_item']:0;
 		$path_item = Database::escape_string($path_item);
 		$tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
 		$sql_doc = "SELECT path FROM " . $tbl_doc . " WHERE id = '". $path_item."' ";
 		$res_doc=api_sql_query($sql_doc, __FILE__, __LINE__);
-		$path_file=Database::result($res_doc,0,0);					
+		$path_file=Database::result($res_doc,0,0);
 		$path_parts = pathinfo($path_file);
-						
+
 		if (Database::num_rows($res_doc) > 0 && $path_parts['extension']=='html'){
 			$count_items = count($_SESSION['oLP']->ordered_items);
 			$style = ($count_items > 12)?' style="height:250px;width:230px;overflow-x : auto; overflow : scroll;" ':' class="lp_tree" ';
-			echo '<div '.$style.'>';					
+			echo '<div '.$style.'>';
 			//build the tree with the menu items in it
-			echo $_SESSION['oLP']->build_tree();			
+			echo $_SESSION['oLP']->build_tree();
 			echo '</div>';
-			// show the template list 
-			echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'; //line				
-			echo '<br>';		
+			// show the template list
+			echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'; //line
+			echo '<br>';
 			echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
 		} else {
-			echo '<div class="lp_tree" style="height:90%" >';					
+			echo '<div class="lp_tree" style="height:90%" >';
 			//build the tree with the menu items in it
-			echo $_SESSION['oLP']->build_tree();			
+			echo $_SESSION['oLP']->build_tree();
 			echo '</div>';
-		}		
-		
-		echo '</td>';		
-		echo '<td class="workspace">';			
+		}
+
+		echo '</td>';
+		echo '<td class="workspace">';
 			if(isset($is_success) && $is_success === true) {
-				$msg = '<div class="lp_message" style="margin-bottom:10px;">';			
-					$msg .= 'The item has been edited.';			
-				$msg .= '</div>';				
+				$msg = '<div class="lp_message" style="margin-bottom:10px;">';
+					$msg .= 'The item has been edited.';
+				$msg .= '</div>';
 				echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
 			} else {
 				echo $_SESSION['oLP']->display_edit_item($_GET['id']);
-			}		
-		echo '</td>';			
-	echo '</tr>';		
+			}
+		echo '</td>';
+	echo '</tr>';
 echo '</table>';
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 33 - 33
main/newscorm/lp_edit_item_prereq.php

@@ -1,30 +1,30 @@
 <?php
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Patrick Cool
 	Copyright (c) Denes Nagy
 	Copyright (c) Yannick Warnier
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -32,14 +32,14 @@
 * @author Roan Embrechts, refactoring and code cleaning
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $this_section=SECTION_COURSES;
 
 api_protect_course_script();
@@ -48,7 +48,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -56,14 +56,14 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 
 /*
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -103,9 +103,9 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -113,7 +113,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -122,12 +122,12 @@ $therow=Database::fetch_array($result);
 
 /*==================================================
 	prerequisites setting end
- ==================================================*/		  
+ ==================================================*/
 if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -159,7 +159,7 @@ function stripslashes(str) {
 }
 function confirmation(name)
 {
-	name=stripslashes(name);	
+	name=stripslashes(name);
 	if (confirm("<?php echo $suredel; ?> " + name + " ?"))
 	{
 		return true;
@@ -167,7 +167,7 @@ function confirmation(name)
 	else
 	{
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -181,31 +181,31 @@ function confirmation(name)
 echo $_SESSION['oLP']->build_action_menu();
 echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
 	echo '<tr>';
-			
-		echo '<td class="tree">';		
-			echo '<div class="lp_tree">';					
+
+		echo '<td class="tree">';
+			echo '<div class="lp_tree">';
 				//build the tree with the menu items in it
 				echo $_SESSION['oLP']->build_tree();
-			
-			echo '</div>';					
+
+			echo '</div>';
 		echo '</td>';
 		echo '<td class="workspace">';
-		
+
 			if(isset($is_success) && $is_success === true) {
-				echo '<div class="lp_message" style="margin:3px 10px;">';			
-				echo get_lang("PrerequisitesAdded");			
+				echo '<div class="lp_message" style="margin:3px 10px;">';
+				echo get_lang("PrerequisitesAdded");
 				echo '</div>';
 			} else {
 				echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']);
-			}		
-		echo '</td>';			
-	echo '</tr>';		
+			}
+		echo '</td>';
+	echo '</tr>';
 echo '</table>';
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 2 - 2
main/newscorm/lp_export.php

@@ -1,7 +1,7 @@
 <?php //$id: $
 /**
  * Script to export the current path as a SCORM zip package.
- * This script cannot use the common controller lp_controller.php because we need to keep 
+ * This script cannot use the common controller lp_controller.php because we need to keep
  * the headers clean of any session prior to output-ing the resulting file.
  * As we still need to check the user's credentials (because he might not have access to this file),
  * we need to get some ID proof.
@@ -9,7 +9,7 @@
  * to force the download and let the user do the rest. This script should not change the screen
  * at all, so the user will still be able to continue what he was doing.
  * @todo get some ID proof
- * @package dokeos.learnpath 
+ * @package dokeos.learnpath
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
 /**

+ 2 - 2
main/newscorm/lp_header.php

@@ -9,7 +9,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = "scormdocument";
 require_once('back_compat.inc.php');
 require_once('learnpath.class.php');
@@ -52,7 +52,7 @@ if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')

+ 21 - 21
main/newscorm/lp_list.php

@@ -117,7 +117,7 @@ if(api_is_allowed_to_edit())
 			echo  str_repeat('&nbsp;',3).'<a href="../upload/upload_ppt.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/powerpoint.gif" border="0" alt="'.get_lang("PowerPointConvert").'" align="absmiddle">&nbsp;'.get_lang("PowerPointConvert").'</a>';
        		//echo  str_repeat('&nbsp;',3).'<a href="../upload/upload_word.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/word.gif" border="0" alt="'.get_lang("WordConvert").'" align="absmiddle">&nbsp;'.get_lang("WordConvert").'</a>';
         }
-	echo '</div>';       
+	echo '</div>';
 }
 
 echo '<table width="100%" border="0" cellspacing="2" class="data_table">';
@@ -186,7 +186,7 @@ if (is_array($flat_list))
 	    if(!$is_allowed_to_edit && $details['lp_visibility'] == 0)
 	    {
 	    	// This is a student and this path is invisible, skip
-	    	continue;		
+	    	continue;
 	    }
 		$counter++;
 	    if (($counter % 2)==0) { $oddclass="row_odd"; } else { $oddclass="row_even"; }
@@ -210,26 +210,26 @@ if (is_array($flat_list))
 	    $dsp_default_view = '';
 	    $dsp_debug = '';
 	    $dsp_order = '';
-	    
-	    // Select course theme	
+
+	    // Select course theme
 		if (!empty($platform_theme))
-		{	
+		{
 			$mystyle=$platform_theme;
 		}
-		
-		if (!empty($user_theme)) 
-		{	 
+
+		if (!empty($user_theme))
+		{
 			$mystyle=$user_theme;
-		}		
-				
-		if (!empty($mycoursetheme)) 
-		{	 
+		}
+
+		if (!empty($mycoursetheme))
+		{
 			$mystyle=$mycoursetheme;
 		}
-		
+
 		$lp_theme_css=$mystyle;
-		
-	    
+
+
 	    if($display_progress_bar)
 	    {
 	    	$dsp_progress = '<td>'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id,api_get_user_id()),'').'</td>';
@@ -268,7 +268,7 @@ if (is_array($flat_list))
 
 			$dsp_edit = '<td align="center">';
 	    	$dsp_edit_close = '</td>';
-			
+
 			/* DELETE COMMAND */
 			$dsp_delete = "<a href=\"lp_controller.php?".api_get_cidreq()."&action=delete&lp_id=$id\" " .
 			"onClick=\"return confirmation('".addslashes($name)."');\">" .
@@ -357,28 +357,28 @@ if (is_array($flat_list))
 		 	}
 		 	/*   Export  */
 	    	if($details['lp_type']==1){
-				$dsp_disk = 
+				$dsp_disk =
 					"<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
 					"<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
 					"</a>" .
 					"";
 			}elseif($details['lp_type']==2){
-				$dsp_disk = 
+				$dsp_disk =
 					"<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".replace_dangerous_char($name,'strict').".zip'>" .
 					"<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
 					"</a>" .
 					"";
 			}else{
-				$dsp_disk = 
+				$dsp_disk =
 					//"<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
 					"<img src=\"../img/cd_gray.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
 					//"</a>" .
 					"";
 			}
-			
+
 			//hide icon export scorm
 			//$dsp_disk='';
-			
+
 			if($details['lp_display_order'] == 1 && $max != 1)
 	    	{
 	    		$dsp_order .= '<td><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_down&lp_id='.$id.'">' .

+ 1 - 1
main/newscorm/lp_list_search.php

@@ -19,7 +19,7 @@ if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')

+ 1 - 1
main/newscorm/lp_log.php

@@ -4,7 +4,7 @@
  * a separate file but rather some text included in lp_view.php, but SCORM involves loading a script that
  * saves the data asynchronously while the SCORM learning path carries on. Having an informational iframe
  * helps not popping up an additional window when saving data.
- * 
+ *
  * This script is also used to refresh the TOC as sometimes the SCORM JS messages are taken into account
  * only after the TOC is drawn. As such, you might complete an item, browse to the next page, have the
  * TOC drawn with your 'incomplete' status, while the SCORM messages generally arrives just after the TOC

+ 2 - 2
main/newscorm/lp_message.php

@@ -4,7 +4,7 @@
  * a separate file but rather some text included in lp_view.php, but SCORM involves loading a script that
  * saves the data asynchronously while the SCORM learning path carries on. Having an informational iframe
  * helps not popping up an additional window when saving data.
- * 
+ *
  * This script is also used to refresh the TOC as sometimes the SCORM JS messages are taken into account
  * only after the TOC is drawn. As such, you might complete an item, browse to the next page, have the
  * TOC drawn with your 'incomplete' status, while the SCORM messages generally arrives just after the TOC
@@ -18,7 +18,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 require_once('back_compat.inc.php');
 require_once('learnpath.class.php');

+ 33 - 33
main/newscorm/lp_move_item.php

@@ -1,30 +1,30 @@
 <?php
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Patrick Cool
 	Copyright (c) Denes Nagy
 	Copyright (c) Yannick Warnier
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -32,14 +32,14 @@
 * @author Roan Embrechts, refactoring and code cleaning
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $this_section=SECTION_COURSES;
 
 api_protect_course_script();
@@ -48,7 +48,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -56,20 +56,20 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 
 /*
 -----------------------------------------------------------
 	Header and action code
 -----------------------------------------------------------
-*/ 
+*/
 $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 /*
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -109,9 +109,9 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -119,7 +119,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -128,12 +128,12 @@ $therow=Database::fetch_array($result);
 
 /*==================================================
 	prerequisites setting end
- ==================================================*/		  
+ ==================================================*/
 if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -165,7 +165,7 @@ function stripslashes(str) {
 }
 function confirmation(name)
 {
-	name=stripslashes(name);	
+	name=stripslashes(name);
 	if (confirm("<?php echo $suredel; ?> " + name + " ?"))
 	{
 		return true;
@@ -173,7 +173,7 @@ function confirmation(name)
 	else
 	{
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -187,30 +187,30 @@ function confirmation(name)
 */
 echo $_SESSION['oLP']->build_action_menu();
 echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
-	echo '<tr>';			
+	echo '<tr>';
 		echo '<td class="tree">';
-			echo '<div class="lp_tree">';					
+			echo '<div class="lp_tree">';
 				//build the tree with the menu items in it
-				echo $_SESSION['oLP']->build_tree();			
-			echo '</div>';					
+				echo $_SESSION['oLP']->build_tree();
+			echo '</div>';
 		echo '</td>';
 		echo '<td class="workspace">';
 			if(isset($is_success) && $is_success === true) {
-				$msg = '<div class="lp_message" style="margin-bottom:10px;">';			
-					$msg .= 'The item has been moved.';			
-				$msg .= '</div>';				
+				$msg = '<div class="lp_message" style="margin-bottom:10px;">';
+					$msg .= 'The item has been moved.';
+				$msg .= '</div>';
 				echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
 			} else {
 				echo $_SESSION['oLP']->display_move_item($_GET['id']);
-			}		
-		echo '</td>';			
-	echo '</tr>';		
+			}
+		echo '</td>';
+	echo '</tr>';
 echo '</table>';
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 8 - 8
main/newscorm/lp_nav.php

@@ -10,7 +10,7 @@
  */
 //flag to allow for anonymous user - needs to be set before global.inc.php
 $use_anonymous = true;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file[] = "scormdocument";
 $language_file[] = "scorm";
 $language_file[] = "learnpath";
@@ -35,21 +35,21 @@ if(isset($_SESSION['lpobject'])) {
 	} else {
 		//error_log('New LP - in lp_nav.php - SESSION[lpobject] is not object - dying',0);
 		die('Could not instanciate lp object');
-	}	
-	$display_mode = $_SESSION['oLP']->mode;	
+	}
+	$display_mode = $_SESSION['oLP']->mode;
 	$scorm_css_header = true;
 	$lp_theme_css = $_SESSION['oLP']->get_theme();
 	//Setting up the CSS theme if exists
 	include_once('../inc/reduced_header.inc.php');
-	
+
 	if (!empty($lp_theme_css) && !empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1 ) {
-		global $lp_theme_css;			
+		global $lp_theme_css;
 	} else {
 		$lp_theme_css=$my_style;
 	}
-	//$progress_bar = $_SESSION['oLP']->get_progress_bar(); 
-	$progress_bar = $_SESSION['oLP']->get_progress_bar('',-1,'',true);	
-	$navigation_bar = $_SESSION['oLP']->get_navigation_bar();	
+	//$progress_bar = $_SESSION['oLP']->get_progress_bar();
+	$progress_bar = $_SESSION['oLP']->get_progress_bar('',-1,'',true);
+	$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
 	$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);
 }
 session_write_close();

+ 1 - 1
main/newscorm/lp_save.php

@@ -15,7 +15,7 @@ $msg = $_SESSION['oLP']->get_message();
 $charset = 'ISO-8859-15'; //not taken into account here as we don't include a header
 error_log('New LP - Loaded lp_save : '.$_SERVER['REQUEST_URI'].' from '.$_SERVER['HTTP_REFERER'],0);
 ?>
-<!DOCTYPE html 
+<!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

+ 132 - 132
main/newscorm/lp_stats.php

@@ -2,7 +2,7 @@
 /* For licensing terms, see /dokeos_license.txt */
 /**
  * This script displays statistics on the current learning path (scorm)
- * 
+ *
  * This script must be included by lp_controller.php to get basic initialisation
  * @package dokeos.learnpath
  * @author Yannick Warnier <ywarnier@beeznest.org>
@@ -23,9 +23,9 @@ if(empty($_SESSION['_course']['id']) && isset($_GET['course'])) {
 
 if (isset($_GET['student_id'])) {
 	$student_id = intval($_GET['student_id']);
-} 
+}
 
-//The two following variables have to be declared by the includer script 
+//The two following variables have to be declared by the includer script
 //$lp_id = $_SESSION['oLP']->get_id();
 //$list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
 //$user_id = $_user['user_id'];
@@ -130,17 +130,17 @@ if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) {
 	$clean_lp_id = Database::escape_string($_GET['lp_id']);
 	$clean_course_code = Database :: escape_string($course_code);
 	$sql_path = "SELECT path FROM $TBL_LP_ITEM WHERE id = '$clean_lp_item_id' AND lp_id = '$clean_lp_id'";
-	$res_path = api_sql_query($sql_path,__FILE__,__LINE__); 
+	$res_path = api_sql_query($sql_path,__FILE__,__LINE__);
 	$row_path = Database::fetch_array($res_path);
-	
-	if (Database::num_rows($res_path) > 0 ){		
-		if ($origin != 'tracking') {		    
+
+	if (Database::num_rows($res_path) > 0 ){
+		if ($origin != 'tracking') {
 			$sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND exe_user_id="' . (int)api_get_user_id() . '" AND orig_lp_id = "'.(int)$clean_lp_id.'" AND orig_lp_item_id = "'.(int)$clean_lp_item_id.'" AND exe_cours_id="' . $clean_course_code. '" AND status <> "incomplete" ORDER BY exe_date';
-		} else {										
+		} else {
 			$sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.(int)$clean_lp_id.'" AND orig_lp_item_id = "'.(int)$clean_lp_item_id.'" AND exe_cours_id="' . $clean_course_code. '" AND status <> "incomplete" ORDER BY exe_date';
-		}		
-	}					
-						
+		}
+	}
+
 }
 
 $TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
@@ -154,7 +154,7 @@ if (is_array($list) && count($list) > 0){
 			$qry_order = 'ASC';
 		}
 		//prepare statement to go through each attempt
-	
+
 		if (!empty ($view)) {
 			$sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
 			"iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
@@ -185,27 +185,27 @@ if (is_array($list) && count($list) > 0){
 			" AND v.user_id = " . $user_id . " " .
 			" ORDER BY iv.view_count $qry_order ";
 		}
-		
+
 		$result = api_sql_query($sql, __FILE__, __LINE__);
-		$num = Database :: num_rows($result);	
+		$num = Database :: num_rows($result);
 		$time_for_total = 'NaN';
-		
+
 		if (($extend_this || $extend_all) && $num > 0) {
 			$row = Database :: fetch_array($result);
 			$result_disabled_ext_all = false;
 			if($row['item_type'] == 'quiz') {
 				//check results_disabled in quiz table
-				$my_path = Database::escape_string($row['path']);  
-								
+				$my_path = Database::escape_string($row['path']);
+
 				$sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE id ='".(int)$my_path."'";
 				$res_result_disabled = api_sql_query($sql,__FILE__,__LINE__);
 				$row_result_disabled = Database::fetch_row($res_result_disabled);
-				
+
 				if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0]===1) {
 					$result_disabled_ext_all = true;
 				}
 			}
-					
+
 			//echo '<br><pre>'; print_r($row); echo '</pre><br>';
 			//if there are several attempts, and the link to extend has been clicked, show each attempt...
 			if (($counter % 2) == 0) {
@@ -218,18 +218,18 @@ if (is_array($list) && count($list) > 0){
 				$extend_link = '<a href="' . api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix . '"><img src="../img/visible.gif" alt="'.api_convert_encoding(get_lang('HideAttemptView'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('HideAttemptView'), $lp_charset, $dokeos_charset).'"  border="0"></a>' . "\n";
 			}
 			$title = $row['mytitle'];
-			
+
 			if (empty ($title)) {
 				$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
 			}
-			
-			if ($row['item_type'] != 'dokeos_chapter') {			
+
+			if ($row['item_type'] != 'dokeos_chapter') {
 				$correct_test_link = '-';
 				//api_convert_encoding($title, $lp_charset, $lp_charset)
 				$title = Security::remove_XSS($title);
 				$output .= "<tr class='$oddclass'>\n" . "<td>$extend_link</td>\n" . '<td colspan="4" class="content"><div class="mystatus">' . $title . "</div></td>\n" . '<td colspan="2" class="content"></td>' . "\n" . '<td colspan="2" class="content"></td>' . "\n" . '<td colspan="2" class="content"></td><td class="content"></td>' . "\n" . "</tr>\n";
 			}
-	
+
 			$counter++;
 			do {
 				//check if there are interactions below
@@ -245,7 +245,7 @@ if (is_array($list) && count($list) > 0){
 						$extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="'.api_convert_encoding(get_lang('ExtendAttemptView'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ExtendAttemptView'), $lp_charset, $dokeos_charset).'"  border="0"></a>' . "\n";
 					}
 				}
-	
+
 				if (($counter % 2) == 0) {
 					$oddclass = "row_odd";
 				} else {
@@ -261,7 +261,7 @@ if (is_array($list) && count($list) > 0){
 					$maxscore = $row['mymaxscore'];
 				} else {
 					if ($row['item_type'] == 'sco') {
-	
+
 						if (!empty ($row['myviewmaxscore']) && $row['myviewmaxscore'] > 0) {
 							$maxscore = $row['myviewmaxscore'];
 						}
@@ -271,7 +271,7 @@ if (is_array($list) && count($list) > 0){
 							$maxscore = $row['mymaxscore'];
 						}
 					}
-					else 
+					else
 					{
 						$maxscore = $row['mymaxscore'];
 					}
@@ -290,11 +290,11 @@ if (is_array($list) && count($list) > 0){
 					'passed' => 'ScormPassed',
 					'browsed' => 'ScormBrowsed',
 					'not attempted' => 'ScormNotAttempted',
-					
+
 				);
-				
-				$my_lesson_status = api_convert_encoding(get_lang($mylanglist[$lesson_status]), $lp_charset, $dokeos_charset);			
-				
+
+				$my_lesson_status = api_convert_encoding(get_lang($mylanglist[$lesson_status]), $lp_charset, $dokeos_charset);
+
 				if ($row['item_type'] != 'dokeos_chapter') {
 					if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 						$view_score = '/';
@@ -304,31 +304,31 @@ if (is_array($list) && count($list) > 0){
 					$output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . "<td>$extend_attempt_link</td>\n" . '<td colspan="3">' . api_convert_encoding(get_lang('Attempt'), $lp_charset, $dokeos_charset) . ' ' . $row['iv_view_count'] . "</td>\n"
 					//."<td><font color='$color'><div class='mystatus'>".api_htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
 					 . '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">' . $view_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">'.$time.'</div></td><td></td></tr>';
-					
+
 					if (!empty($export_csv)) {
-						$temp = array ();						
-						$temp[] = $title = Security::remove_XSS($title); 
+						$temp = array ();
+						$temp[] = $title = Security::remove_XSS($title);
 						$temp[] = Security::remove_XSS($my_lesson_status);
-						
+
 						if ($row['item_type'] == 'quiz') {
-							
+
 							if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 								$temp[] =  '/';
 							} else {
 								$temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
 							}
-							
+
 						} else {
 							$temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
 						}
-						
+
 						$temp[] = $time;
 						$csv_content[] = $temp;
-					}				
+					}
 				}
-				
+
 				$counter++;
-				
+
 				if ($extend_this_attempt OR $extend_all) {
 					$list1 = learnpath :: get_iv_interactions_array($row['iv_id']);
 					foreach ($list1 as $id => $interaction) {
@@ -367,30 +367,30 @@ if (is_array($list) && count($list) > 0){
 						$counter++;
 					}
 				}
-			} while ($row = Database :: fetch_array($result));	
+			} while ($row = Database :: fetch_array($result));
 		}
 		elseif ($num > 0) {
 			$row = Database :: fetch_array($result);
 			$my_id = $row['myid'];
 			$my_lp_id = $row['mylpid'];
 			$my_lp_view_id = $row['mylpviewid'];
-			$my_path = $row['path'];			
-			
+			$my_path = $row['path'];
+
 			$result_disabled_ext_all = false;
-			
+
 			if($row['item_type'] == 'quiz') {
 				//check results_disabled in quiz table
-				$my_path = Database::escape_string($my_path);  
-								
+				$my_path = Database::escape_string($my_path);
+
 				$sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE id ='".(int)$my_path."'";
 				$res_result_disabled = api_sql_query($sql,__FILE__,__LINE__);
 				$row_result_disabled = Database::fetch_row($res_result_disabled);
-				
+
 				if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0]===1) {
 					$result_disabled_ext_all = true;
 				}
-			}				
-						
+			}
+
 			//check if there are interactions below
 			$extend_attempt_link = '';
 			$extend_this_attempt = 0;
@@ -406,7 +406,7 @@ if (is_array($list) && count($list) > 0){
 					$extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="'.api_convert_encoding(get_lang('ExtendAttemptView'),$lp_charset,$charset).'" title="'.api_convert_encoding(get_lang('ExtendAttemptView'),$lp_charset,$charset).'" border="0"></a>' . "\n";
 				}
 			}
-	
+
 			if (($counter % 2) == 0) {
 				$oddclass = "row_odd";
 			} else {
@@ -434,14 +434,14 @@ if (is_array($list) && count($list) > 0){
 			//$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
 			$scoIdentifier = $row['myid'];
 			$title = $row['mytitle'];
-			
+
 			// selecting the exe_id from stats attempts tables in order to look the max score value
 			if ($origin != 'tracking') {
 				$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1';
 			} else {
 				$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1';
 			}
-			
+
 			$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);
 			$num = Database :: num_rows($resultLastAttempt);
 			if ($num > 0) {
@@ -449,14 +449,14 @@ if (is_array($list) && count($list) > 0){
 					$id_last_attempt = $rowLA['exe_id'];
 				}
 			}
-	
+
 			if ($score == 0)
 			{
 				$maxscore = $row['mymaxscore'];
 			}
-			else 
+			else
 			{
-				if ($row['item_type'] == 'sco') 
+				if ($row['item_type'] == 'sco')
 				{
 					if (!empty ($row['myviewmaxscore']) and $row['myviewmaxscore'] > 0) {
 						$maxscore = $row['myviewmaxscore'];
@@ -466,36 +466,36 @@ if (is_array($list) && count($list) > 0){
 					} else {
 						$maxscore = $row['mymaxscore'];
 					}
-				} 
+				}
 				else
 				{
-					if ($row['item_type'] == 'quiz') 
+					if ($row['item_type'] == 'quiz')
 					{
-						// get score and total time from last attempt of a exercise en lp					
+						// get score and total time from last attempt of a exercise en lp
 						$sql = "SELECT score FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."'
 								ORDER BY view_count DESC limit 1";
 						$res_score = api_sql_query($sql,__FILE__,__LINE__);
 						$row_score = Database::fetch_array($res_score);
-						
+
 						$sql = "SELECT SUM(total_time) as total_time FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '".(int)$my_id."' and lp_view_id = '".(int)$my_lp_view_id."'";
 						$res_time = api_sql_query($sql,__FILE__,__LINE__);
 						$row_time = Database::fetch_array($res_time);
-						
-						if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0) { 
+
+						if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0) {
 							$score = (float)$row_score['score'];
-							$subtotal_time = (int)$row_time['total_time'];																
+							$subtotal_time = (int)$row_time['total_time'];
 						} else {
 							$score = 0;
 							$subtotal_time =  0;
 						}
-							
-						//$time = learnpathItem :: get_scorm_time('js', $subtotal_time);																				
+
+						//$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
 						// selecting the max score from an attempt
 						$sql = "SELECT SUM(t.ponderation) as maxscore from ( SELECT distinct question_id, marks,ponderation FROM $tbl_stats_attempts as at " .
 							  "INNER JOIN  $tbl_quiz_questions as q  on(q.id = at.question_id) where exe_id ='$id_last_attempt' ) as t";
-																	
+
 						$result = api_sql_query($sql, __FILE__, __LINE__);
-						$row_max_score = Database :: fetch_array($result);							
+						$row_max_score = Database :: fetch_array($result);
 						$maxscore = $row_max_score['maxscore'];
 					}
 					else
@@ -505,13 +505,13 @@ if (is_array($list) && count($list) > 0){
 				}
 			}
 			$time_for_total = $subtotal_time;
-			$time = learnpathItem :: get_scorm_time('js', $subtotal_time);			
+			$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
 			if (empty ($title)) {
 				$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
 			}
 			//Remove "NaN" if any (@todo: locate the source of these NaN)
 			//$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
-	
+
 			if (($lesson_status == 'completed') or ($lesson_status == 'passed')) {
 				$color = 'green';
 			} else {
@@ -524,10 +524,10 @@ if (is_array($list) && count($list) > 0){
 				'passed' => 'ScormPassed',
 				'browsed' => 'ScormBrowsed',
 				'not attempted' => 'ScormNotAttempted',
-	
+
 			);
 			$my_lesson_status = api_convert_encoding(get_lang($mylanglist[$lesson_status]), $lp_charset, $dokeos_charset);
-			
+
 			if ($row['item_type'] != 'dokeos_chapter') {
 				if ($row['item_type'] == 'quiz') {
 					$correct_test_link = '';
@@ -539,14 +539,14 @@ if (is_array($list) && count($list) > 0){
 						$my_url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($row['mylpid']).'&origin=' . Security::remove_XSS($_GET['origin'].$from_link);
 						$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" AND status <> "incomplete"  ORDER BY exe_date DESC ';
 					}
-	
+
 					$resultLastAttempt = api_sql_query($sql_last_attempt, __FILE__, __LINE__);
 					$num = Database :: num_rows($resultLastAttempt);
-					if ($num > 0) {																																							
-						if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)  ) {						
+					if ($num > 0) {
+						if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)  ) {
 							$correct_test_link = '<a href="' . api_get_self() . '?action=stats' . $my_url_suffix . '&my_ext_lp_id='.$my_id.'"><img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="'.api_convert_encoding(get_lang('HideAllAttempts'),$lp_charset,$charset).'"></a>';
 							$extend_attempt = 1;
-						} else {						
+						} else {
 							$correct_test_link = '<a href="' . api_get_self() . '?action=stats&extend_attempt=1'.$my_url_suffix.'&my_lp_id='.$my_id.'"><img src="../img/view_more_stats.gif" alt="extend_view" border="0" title="'.api_convert_encoding(get_lang('ShowAllAttemptsByExercise'),$lp_charset,$charset).'"></a>';
 						}
 					} else {
@@ -555,61 +555,61 @@ if (is_array($list) && count($list) > 0){
 				} else {
 					$correct_test_link = '-';
 				}
-				
+
 				//."<td><font color='$color'><div class='mystatus'>".api_htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
 				$title = Security::remove_XSS($title);
-				if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) {					
-					$output .= "<tr class='$oddclass' >\n" . "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";				
+				if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) {
+					$output .= "<tr class='$oddclass' >\n" . "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";
 					$output .= '<td colspan="2">&nbsp;</td><td colspan="2">&nbsp;</td><td colspan="2">&nbsp;</td><td>'.$correct_test_link.'</td></tr>';
-					$output .= "</tr>\n";						 
+					$output .= "</tr>\n";
 				} else {
 					if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_ext_lp_id']) && $_GET['my_ext_lp_id'] == $my_id)) {
-						$output .= "<tr class='$oddclass' >\n"; 
+						$output .= "<tr class='$oddclass' >\n";
 					} else {
-						$output .= "<tr class='$oddclass'>\n";	
+						$output .= "<tr class='$oddclass'>\n";
 					}
-					$output .= "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";							
-					$output .= '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">';			  
+					$output .= "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";
+					$output .= '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">';
 					 if ($row['item_type'] == 'quiz') {
-					 	
+
 					 	if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 							$output .=  '/';
-						} else {						
-							$output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1)));	
+						} else {
+							$output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1)));
 						}
-						
+
 					 } else {
-					    $output .= ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore));	
-					 }			 			  
+					    $output .= ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore));
+					 }
 					 $output .= "</div></td>\n" . '<td colspan="2"><div class="mystatus">' . $time . "</div></td><td>$correct_test_link</td>\n";
-					 $output .= "</tr>\n";	
+					 $output .= "</tr>\n";
 				}
-				
+
 				if (!empty($export_csv)) {
 					$temp = array ();
 					$temp[] = api_html_entity_decode($title, ENT_QUOTES, $lp_charset);
 					$temp[] = api_html_entity_decode($my_lesson_status, ENT_QUOTES, $lp_charset);
-					
+
 					if ($row['item_type'] == 'quiz') {
-						
+
 						if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 							$temp[] =  '/';
 						} else {
 							$temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
 						}
-						
+
 					} else {
 						$temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
 					}
-					
+
 					$temp[] = $time;
 					$csv_content[] = $temp;
 				}
-				
+
 			}
-			
+
 			$counter++;
-			
+
 			if ($extend_this_attempt OR $extend_all) {
 				$list1 = learnpath :: get_iv_interactions_array($row['iv_id']);
 				foreach ($list1 as $id => $interaction) {
@@ -638,75 +638,75 @@ if (is_array($list) && count($list) > 0){
 					$counter++;
 				}
 			}
-																																									
-			// attempts list by exercise 
+
+			// attempts list by exercise
 			if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) {
-	
+
 					$res_attempts = api_sql_query($sql_attempts,__FILE__,__LINE__);
-					$num_attempts = Database :: num_rows($res_attempts);																	
-					if ($row['item_type'] === 'quiz') {									
-						if ($num_attempts > 0) {					
-							$n=1;										
+					$num_attempts = Database :: num_rows($res_attempts);
+					if ($row['item_type'] === 'quiz') {
+						if ($num_attempts > 0) {
+							$n=1;
 							while ($row_attempts = Database :: fetch_array($res_attempts)) {
 								$my_score = $row_attempts['exe_result'];
 								$my_maxscore = $row_attempts['exe_weighting'];
 								$my_exe_id	= $row_attempts['exe_id'];
 								$my_orig_lp = $row_attempts['orig_lp_id'];
 								$my_orig_lp_item = $row_attempts['orig_lp_item_id'];
-								$my_exo_exe_id=$row_attempts['exe_exo_id'];												
+								$my_exo_exe_id=$row_attempts['exe_exo_id'];
 								$mktime_start_date = convert_mysql_date($row_attempts['start_date']);
 								$mktime_exe_date = convert_mysql_date($row_attempts['exe_date']);
-								$mytime = ((int)$mktime_exe_date-(int)$mktime_start_date);					 
+								$mytime = ((int)$mktime_exe_date-(int)$mktime_start_date);
 								$time_attemp = learnpathItem :: get_scorm_time('js', $mytime);
 								$time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
-								
+
 								if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 									$view_score =  '-';
 								} else {
 									//show only float when need it
-									$my_score  = float_format( $my_score, 1); 
-									$my_maxscore =float_format($my_maxscore, 1);								 
+									$my_score  = float_format( $my_score, 1);
+									$my_maxscore =float_format($my_maxscore, 1);
 									if ($my_score == 0 ){
 										$view_score = 	'0/'.$my_maxscore;
 									} else {
-										if ($my_maxscore==0) 
+										if ($my_maxscore==0)
 											$view_score = $my_score;
-										else 
-											$view_score = $my_score . '/' . $my_maxscore;									
+										else
+											$view_score = $my_score . '/' . $my_maxscore;
 									}
-									//$view_score = ($my_score == 0 ? '0.00/'.$my_maxscore : ($my_maxscore == 0 ? $my_score : $my_score . '/' . $my_maxscore));	
+									//$view_score = ($my_score == 0 ? '0.00/'.$my_maxscore : ($my_maxscore == 0 ? $my_score : $my_score . '/' . $my_maxscore));
 								}
-																				
-								$output .= '<tr class="'.$oddclass.'" ><td>&nbsp;</td><td>'.$extend_attempt_link.'</td><td colspan="3">' . api_convert_encoding(get_lang('Attempt'), $lp_charset, $dokeos_charset) . ' ' . $n . '</td>'				
+
+								$output .= '<tr class="'.$oddclass.'" ><td>&nbsp;</td><td>'.$extend_attempt_link.'</td><td colspan="3">' . api_convert_encoding(get_lang('Attempt'), $lp_charset, $dokeos_charset) . ' ' . $n . '</td>'
 							 			. '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . '</div></font></td><td colspan="2"><div class="mystatus" align="center">' . $view_score  . '</div></td><td colspan="2"><div class="mystatus">' . $time_attemp . '</div></td>';
 							 	if ($origin != 'tracking') {
 							 		if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 										$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></td>';
 									} else {
-										$output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id .$from_link. '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';	
-									}							 								
-								} else {	
+										$output .= '<td><a href="../exercice/exercise_show.php?origin=student_progress&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id .$from_link. '" target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
+									}
+								} else {
 									if (!api_is_allowed_to_edit() && $result_disabled_ext_all) {
 										$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></td>';
 									} else {
-										$output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '&total_time='.$mytime.'&my_exe_exo_id='.$my_exo_exe_id.$from_link.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';	
-									}		
-													
-								}		 				 	        
+										$output .= '<td><a href="../exercice/exercise_show.php?origin=tracking_course&myid='.$my_orig_lp.'&my_lp_id='.$my_orig_lp_item.'&id=' . $my_exe_id . '&cidReq=' . $course_code . '&student=' . $student_id . '&total_time='.$mytime.'&my_exe_exo_id='.$my_exo_exe_id.$from_link.' " target="_parent"><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'" title="'.api_convert_encoding(get_lang('ShowAndQualifyAttempt'), $lp_charset, $dokeos_charset).'"></a></td>';
+									}
+
+								}
 							 	$output .= '</tr>';
-								$n++;												
-							}																								
+								$n++;
+							}
 						}
-						$output .= '<tr><td colspan="12">&nbsp;</td></tr>';							
-					}								
+						$output .= '<tr><td colspan="12">&nbsp;</td></tr>';
+					}
 				}
 		}
-		
+
 		$total_time += $time_for_total;
 		//QUIZZ IN LP
-		$a_my_id = array();	
+		$a_my_id = array();
 		if (!empty($my_lp_id)) {
-			$a_my_id[] = $my_lp_id;	
+			$a_my_id[] = $my_lp_id;
 		}
 	}
 }
@@ -720,8 +720,8 @@ if (!empty($a_my_id)) {
 	} else {
 		$my_studen_id = intval(api_get_user_id());
 		$my_course_id = Database::escape_string(api_get_course_id());
-	}		
-	$total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, $a_my_id);			
+	}
+	$total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, $a_my_id);
 } else {
 	$total_score = 0;
 }
@@ -741,7 +741,7 @@ if (($counter % 2) == 0) {
 
 if (empty($extend_all)) {
 	$output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . '<td colspan="4"><div class="mystatus"><i>' . api_convert_encoding(get_lang('AccomplishedStepsTotal') , $lp_charset, $dokeos_charset) . "</i></div></td>\n"
- 			. '<td colspan="2"></td>' . "\n" . '<td colspan="2"><div class="mystatus" align="center">' . $final_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">' . $total_time . '</div></td><td></td>' . "\n" . "</tr>\n";		
+ 			. '<td colspan="2"></td>' . "\n" . '<td colspan="2"><div class="mystatus" align="center">' . $final_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">' . $total_time . '</div></td><td></td>' . "\n" . "</tr>\n";
 }
 
 $output .= "</table></td></tr></table>";

+ 9 - 9
main/newscorm/lp_upload.php

@@ -26,7 +26,7 @@ $uncompress  = 1;
  * size set in php.ini, all variables from POST are cleared !
  */
 
-if ($_SERVER['REQUEST_METHOD'] == 'POST' 
+if ($_SERVER['REQUEST_METHOD'] == 'POST'
 	&& count($_FILES)>0
 	&& !empty($_FILES['user_file']['name'])
 	)
@@ -43,8 +43,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST'
 	$filename = $info['basename'];
 	$extension = $info['extension'];
 	$file_base_name = str_replace('.'.$extension,'',$filename);
-	
-	
+
+
 	$new_dir = replace_dangerous_char(trim($file_base_name),'strict');
 
 	require_once('learnpath.class.php');
@@ -60,7 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST'
 			}else{
 				//show error message stored in $oScrom->error_msg
 			}
-		
+
 			$proximity = '';
 			if(!empty($_REQUEST['content_proximity'])){$proximity = Database::escape_string($_REQUEST['content_proximity']);}
 			$maker = '';
@@ -89,13 +89,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST'
 			require_once('openoffice_presentation.class.php');
 			$take_slide_name = empty($_POST['take_slide_name']) ? false : true;
 			$o_ppt = new OpenofficePresentation($take_slide_name);
-			$first_item_id = $o_ppt -> convert_document($_FILES['user_file']);		
+			$first_item_id = $o_ppt -> convert_document($_FILES['user_file']);
 			break;
 		case 'woogie':
 			require_once('openoffice_text.class.php');
 			$split_steps = $_POST['split_steps'];
 			$o_doc = new OpenofficeText($split_steps);
-			$first_item_id = $o_doc -> convert_document($_FILES['user_file']);				
+			$first_item_id = $o_doc -> convert_document($_FILES['user_file']);
 			break;
 		case '':
 		default:
@@ -105,7 +105,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST'
 elseif($_SERVER['REQUEST_METHOD'] == 'POST')
 {
 	//if file name given to get in claroline/upload/, try importing this way
-	
+
 	// A file upload has been detected, now deal with the file...
 	//directory creation
 
@@ -132,7 +132,7 @@ elseif($_SERVER['REQUEST_METHOD'] == 'POST')
 				$oScorm->parse_manifest($manifest);
 				$oScorm->import_manifest(api_get_course_id());
 			}
-		
+
 			$proximity = '';
 			if(!empty($_REQUEST['content_proximity'])){$proximity = mysql_real_escape_string($_REQUEST['content_proximity']);}
 			$maker = '';
@@ -160,6 +160,6 @@ elseif($_SERVER['REQUEST_METHOD'] == 'POST')
 		case '':
 		default:
 			return api_failure::set_failure('not_a_learning_path');
-	}	
+	}
 }
 ?>

+ 96 - 96
main/newscorm/lp_view.php

@@ -53,13 +53,13 @@ if ($is_allowed_in_course == false) api_not_allowed();
 // we set the encoding of the lp
 if (!empty($_SESSION['oLP']->encoding)) {
 	$charset = $_SESSION['oLP']->encoding;
-} else { 
+} else {
 	$charset = api_get_system_encoding();
 }
 if (empty($charset)) {
-	$charset = 'ISO-8859-1';	
+	$charset = 'ISO-8859-1';
 }
-	
+
 $oLearnpath = false;
 $course_code = api_get_course_id();
 $user_id = api_get_user_id();
@@ -160,15 +160,15 @@ $type_quiz = false;
 
 foreach($list as $toc) {
 	if ($toc['id'] == $lp_item_id && ($toc['type']=='quiz') ) {
-		$type_quiz = true;		
-	}	
+		$type_quiz = true;
+	}
 }
 
 $autostart = 'true';
 // update status,total_time from lp_item_view table when you finish the exercises in learning path
 if ($type_quiz && !empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
 	global $src;
-	$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();	
+	$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
 	$TBL_TRACK_EXERCICES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 	$TBL_LP_ITEM_VIEW		= Database::get_course_table(TABLE_LP_ITEM_VIEW);
 	$TBL_LP_VIEW			= Database::get_course_table(TABLE_LP_VIEW);
@@ -204,10 +204,10 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($
 			$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = $score,total_time = $mytime WHERE id='".$row_last_attempt[0]."'";
 			api_sql_query($sql_upd_score,__FILE__,__LINE__);
 		}
-	}			
-		
+	}
+
 	if(intval($_GET['fb_type']) > 0) {
-		$src = 'blank.php?msg=exerciseFinished';		
+		$src = 'blank.php?msg=exerciseFinished';
 	} else {
 		$src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.Security::remove_XSS($_REQUEST['exeId']).'&origin=learnpath&learnpath_id='.Security::remove_XSS($_GET['lp_id']).'&learnpath_item_id='.Security::remove_XSS($_GET['lp_id']).'&fb_type='.Security::remove_XSS($_GET['fb_type']);
 	}
@@ -220,19 +220,19 @@ $nameTools = Security :: remove_XSS(api_convert_encoding($_SESSION['oLP']->get_n
 $save_setting = api_get_setting("show_navigation_menu");
 global $_setting;
 $_setting['show_navigation_menu'] = 'false';
-$scorm_css_header=true; 	
+$scorm_css_header=true;
 $lp_theme_css=$_SESSION['oLP']->get_theme(); //sets the css theme of the LP this call is also use at the frames (toc, nav, message)
- 
+
 if($_SESSION['oLP']->mode == 'fullscreen') {
-	$htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";	
+	$htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";
 	include_once('../inc/reduced_header.inc.php');
-	
+
 	//set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php)
 	$_SESSION['loaded_lp_view'] = true;
 	?>
 <input type="hidden" id="old_item" name ="old_item" value="0"/>
 <input type="hidden" id="current_item_id" name ="current_item_id" value="0" />
-	
+
 <div id="learningPathMain"  style="width:100%;height:100%;" >
 	<div id="learningPathLeftZone" style="float:left;width:280px;height:100%">
 		<!-- header -->
@@ -253,102 +253,102 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
 		            </table>
 		        </div>
 		</div>
-		<!-- end header --> 
+		<!-- end header -->
 
 <!-- Image preview Layout -->
-	<div id="author_image" name="author_image" class="lp_author_image" style="height:23%; width:100%;margin-left:5px">	
+	<div id="author_image" name="author_image" class="lp_author_image" style="height:23%; width:100%;margin-left:5px">
 		<?php $image = '../img/lp_author_background.gif'; ?>
-			<div id="preview_image" style="padding:5px;background-image: url('../img/lp_author_background.gif');background-repeat:no-repeat;height:110px">						       	   		       	
+			<div id="preview_image" style="padding:5px;background-image: url('../img/lp_author_background.gif');background-repeat:no-repeat;height:110px">
 		       	<div style="width:100; float:left;height:105;margin:5px">
 		       		<span>
 			        <?php if ($_SESSION['oLP']->get_preview_image()!=''): ?>
 			        <img width="115" height="100" src="<?php echo api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image(); ?>">
-			        <?php 
+			        <?php
 						else
 						: echo Display :: display_icon('unknown_250_100.jpg', ' ');
 						endif;
 						?>
 					</span>
 		       	</div>
-		       		       		       
+
 				<div id="nav_id" name="nav_name" class="lp_nav" style="margin-left:105;height:90">
-			        <?php										
+			        <?php
 						$display_mode = $_SESSION['oLP']->mode;
 						$scorm_css_header = true;
 						$lp_theme_css = $_SESSION['oLP']->get_theme();
-					
-						//Setting up the CSS theme if exists						
-					
+
+						//Setting up the CSS theme if exists
+
 						if (!empty ($lp_theme_css) && !empty ($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
 							global $lp_theme_css;
 						} else {
 							$lp_theme_css = $my_style;
 						}
-					
+
 						$progress_bar = $_SESSION['oLP']->get_progress_bar('', -1, '', true);
 						$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
-						$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);	
-						
+						$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);
+
 						$tbl_lp_item	= Database::get_course_table(TABLE_LP_ITEM);
 						$show_audioplayer = false;
 						// getting all the information about the item
 						$sql = "SELECT audio FROM " . $tbl_lp_item . " WHERE lp_id = '" . $_SESSION['oLP']->lp_id."'";
-						$res_media= api_sql_query($sql, __FILE__, __LINE__);					
-						
+						$res_media= api_sql_query($sql, __FILE__, __LINE__);
+
 						if(Database::num_rows($res_media) > 0){
 							while($row_media= Database::fetch_array($res_media)) {
-							     if(!empty($row_media['audio'])) {$show_audioplayer = true; break;}	
+							     if(!empty($row_media['audio'])) {$show_audioplayer = true; break;}
 							}
 						}
 					?>
-					
+
 					<div id="lp_navigation_elem" class="lp_navigation_elem" style="padding-left:130px;margin-top:9px;">
-						<div style="padding-top:20px;padding-bottom:50px;" ><?php echo $navigation_bar; ?></div> 
+						<div style="padding-top:20px;padding-bottom:50px;" ><?php echo $navigation_bar; ?></div>
 						<div style="height:20px"><?php echo $progress_bar; ?></div>
-					</div>									
-				</div>		  	 				
-		</div>	
-			   					
-	</div>   				   			
+					</div>
+				</div>
+		</div>
+
+	</div>
 	<!-- end image preview Layout -->
 				<div id="author_name" style="position:relative;top:2px;left:0px;margin:0;padding:0;text-align:center;width:100%">
 					<?php echo $_SESSION['oLP']->get_author() ?>
 				</div>
-	
-	<!-- media player layaout -->		
+
+	<!-- media player layaout -->
 	<?php $style_media = (($show_audioplayer)?' style= "position:relative;top:10px;left:10px;margin:8px;font-size:32pt;height:20px;"':'style="height:15px"'); ?>
 	<div id="media"  <?php echo $style_media ?>>
 		<?php echo (!empty($mediaplayer))?$mediaplayer:'&nbsp;' ?>
 	</div>
 	<!-- end media player layaout -->
-	
-	<!-- toc layout -->     
+
+	<!-- toc layout -->
 	<div id="toc_id" name="toc_name"  style="padding:0;margin-top:20px;height:60%;width:100%">
 		<div id="learningPathToc" style="font-size:9pt;margin:0;"><?php echo $_SESSION['oLP']->get_html_toc(); ?>
 		<!-- log message layout -->
-		
+
 		<div id="lp_log_name" name="lp_log_name" class="lp_log" style="height:50px;overflow:auto;margin:15px">
 			<div id="log_content"></div>
 			<div style="color: white;" onClick="cleanlog();">.</div>
 		</div>
 	<!-- end log message layout -->
 		</div>
-		
+
 	</div>
 	<!-- end toc layout -->
 
-	
+
 	</div>
-<!-- end left Zone --> 			
+<!-- end left Zone -->
 
-<!-- right Zone -->    				
+<!-- right Zone -->
 	<div id="learningPathRightZone" style="margin-left:282px;border : 0pt solid blue;height:100%">
 		<iframe id="content_id_blank" name="content_name_blank" src="blank.php" border="0" frameborder="0"  style="width:100%;height:600px" ></iframe>
 	</div>
 <!-- end right Zone -->
 
 </div>
-   
+
 	<script language="JavaScript" type="text/javascript">
 	// Need to be called after the <head> to be sure window.oxajax is defined
   	var dokeos_xajax_handler = window.oxajax;
@@ -383,21 +383,21 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
 	};
 
 	window.onload = function() {
-	
+
 		screen_height = screen.height;
 		screen_width = screen.height;
-	
-		document.getElementById('learningPathLeftZone').style.height = "100%"; 
+
+		document.getElementById('learningPathLeftZone').style.height = "100%";
 		document.getElementById('learningPathToc').style.height = "60%";
 		document.getElementById('learningPathToc').style.width = "100%";
-		document.getElementById('learningPathRightZone').style.height = "100%" 
-		document.getElementById('content_id').style.height = "100%" ; 
-		
+		document.getElementById('learningPathRightZone').style.height = "100%"
+		document.getElementById('content_id').style.height = "100%" ;
+
 		if (screen_height <= 600) {
 			document.getElementById('inner_lp_toc').style.height = "100px" ;
-			document.getElementById('learningPathLeftZone').style.height = "415px";	
-		}	
-			
+			document.getElementById('learningPathLeftZone').style.height = "415px";
+		}
+
 		initialLeftZoneHeight = document.getElementById('learningPathToc').offsetHeight;
 		initialRightZoneHeight = document.getElementById('learningPathRightZone').offsetHeight;
 		docHeight = document.body.clientHeight;
@@ -414,7 +414,7 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
 <?php
 }
 else
-{	
+{
 	include_once('../inc/reduced_header.inc.php');
 	//$displayAudioRecorder = (api_get_setting('service_visio','active')=='true') ? true : false;
 	//check if audio recorder needs to be in studentview
@@ -428,7 +428,7 @@ else
 		$audio_recorder_studentview = false;
 	}
 	//set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php)
-	$_SESSION['loaded_lp_view'] = true;	
+	$_SESSION['loaded_lp_view'] = true;
 	?>
 
 	<input type="hidden" id="old_item" name ="old_item" value="0"/>
@@ -454,14 +454,14 @@ else
 		            </table>
 		        </div>
 		</div>
-		<!-- end header --> 
+		<!-- end header -->
 
 <!-- Image preview Layout -->
-	<div id="author_image" name="author_image" class="lp_author_image" style="height:23%; width:100%;margin-left:5px;">	
+	<div id="author_image" name="author_image" class="lp_author_image" style="height:23%; width:100%;margin-left:5px;">
 		<?php $image = '../img/lp_author_background.gif'; ?>
 
 			<div id="preview_image" style="padding:5px;background-image: url('../img/lp_author_background.gif');background-repeat:no-repeat;height:110px">
-						       	   		       	
+
 		       	<div style="width:100; float:left;height:105;margin:5px">
 		       		<span style="width:104px; height:96px; float:left; vertical-align:bottom;">
 			        <center><?php if ($_SESSION['oLP']->get_preview_image()!=''): ?>
@@ -469,87 +469,87 @@ else
 			        	$picture = getimagesize(api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image());
 			        	if($picture['1'] < 96) $style = ' style="padding-top:'.((94 -$picture['1'])/2).'px;" ';
 			        	$size = ($picture['0'] > 104 && $picture['1'] > 96 )? ' width="104" height="96" ': $style;
-			        	$flie = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image(); 
-			        	echo '<img '.$size.' src="'.$flie.'">'; 
+			        	$flie = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image();
+			        	echo '<img '.$size.' src="'.$flie.'">';
 			        ?>
-			        <?php 
+			        <?php
 						else
 						: echo Display :: display_icon('unknown_250_100.jpg', ' ');
 						endif;
 						?></center>
 					</span>
 		       	</div>
-		       		       		       
+
 				<div id="nav_id" name="nav_name" class="lp_nav" style="margin-left:105;height:90">
-			        <?php										
+			        <?php
 						$display_mode = $_SESSION['oLP']->mode;
 						$scorm_css_header = true;
 						$lp_theme_css = $_SESSION['oLP']->get_theme();
-					
+
 						//Setting up the CSS theme if exists
 						if (!empty ($lp_theme_css) && !empty ($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
 							global $lp_theme_css;
 						} else {
 							$lp_theme_css = $my_style;
 						}
-					
+
 						$progress_bar = $_SESSION['oLP']->get_progress_bar('', -1, '', true);
 						$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
 						$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);
-						
+
 						$tbl_lp_item	= Database::get_course_table(TABLE_LP_ITEM);
 						$show_audioplayer = false;
 						// getting all the information about the item
 						$sql = "SELECT audio FROM " . $tbl_lp_item . " WHERE lp_id = '" . $_SESSION['oLP']->lp_id."'";
-						$res_media= api_sql_query($sql, __FILE__, __LINE__);					
-						
+						$res_media= api_sql_query($sql, __FILE__, __LINE__);
+
 						if(Database::num_rows($res_media) > 0){
 							while($row_media= Database::fetch_array($res_media)) {
-							     if(!empty($row_media['audio'])) {$show_audioplayer = true; break;}	
+							     if(!empty($row_media['audio'])) {$show_audioplayer = true; break;}
 							}
 						}
 					?>
-					
+
 					<div id="lp_navigation_elem" class="lp_navigation_elem" style="padding-left:130px;margin-top:9px;">
-						<div style="padding-top:15px;padding-bottom:50px;" ><?php echo $navigation_bar; ?></div> 
+						<div style="padding-top:15px;padding-bottom:50px;" ><?php echo $navigation_bar; ?></div>
 						<div style="height:20px"><?php echo $progress_bar; ?></div>
-					</div>									
-				</div>		  	 				
-		</div>	
-			   					
-	</div>   				   			
+					</div>
+				</div>
+		</div>
+
+	</div>
 	<!-- end image preview Layout -->
 				<div id="author_name" style="position:relative;top:2px;left:0px;margin:0;padding:0;text-align:center;width:100%">
 					<?php echo $_SESSION['oLP']->get_author() ?>
 				</div>
-	
-	<!-- media player layaout -->		
+
+	<!-- media player layaout -->
 	<?php $style_media = (($show_audioplayer)?' style= "position:relative;top:10px;left:10px;margin:8px;font-size:32pt;height:20px;"':'style="height:15px"'); ?>
 	<div id="media"  <?php echo $style_media ?>>
 		<?php echo (!empty($mediaplayer))?$mediaplayer:'&nbsp;' ?>
 	</div>
 	<!-- end media player layaout -->
-	
-	<!-- toc layout -->     
+
+	<!-- toc layout -->
 	<div id="toc_id" name="toc_name"  style="padding:0;margin-top:20px;height:60%;width:100%">
 		<div id="learningPathToc" style="font-size:9pt;margin:0;"><?php echo $_SESSION['oLP']->get_html_toc(); ?>
 		<!-- log message layout -->
-		
+
 		<div id="lp_log_name" name="lp_log_name" class="lp_log" style="height:50px;overflow:auto;margin:15px">
 			<div id="log_content"></div>
 			<div style="color: white;" onClick="cleanlog();">.</div>
 		</div>
 	<!-- end log message layout -->
 		</div>
-		
+
 	</div>
 	<!-- end toc layout -->
 
-	
+
 	</div>
-<!-- end left Zone --> 					
+<!-- end left Zone -->
 
-<!-- right Zone -->    				
+<!-- right Zone -->
 	<div id="learningPathRightZone" style="margin-left:282px;height:100%">
 		<iframe id="content_id" name="content_name" src="<?php echo $src; ?>" border="0" frameborder="0"  style="width:100%;height:600px" ></iframe>
 	</div>
@@ -591,21 +591,21 @@ else
 	};
 
 	window.onload = function() {
-	
+
 		screen_height = screen.height;
 		screen_width = screen.height;
-	
-		document.getElementById('learningPathLeftZone').style.height = "100%"; 
+
+		document.getElementById('learningPathLeftZone').style.height = "100%";
 		document.getElementById('learningPathToc').style.height = "60%";
 		document.getElementById('learningPathToc').style.width = "100%";
-		document.getElementById('learningPathRightZone').style.height = "100%" 
-		document.getElementById('content_id').style.height = "100%" ; 
-		
+		document.getElementById('learningPathRightZone').style.height = "100%"
+		document.getElementById('content_id').style.height = "100%" ;
+
 		if (screen_height <= 600) {
 			document.getElementById('inner_lp_toc').style.height = "100px" ;
-			document.getElementById('learningPathLeftZone').style.height = "415px";	
-		}	
-			
+			document.getElementById('learningPathLeftZone').style.height = "415px";
+		}
+
 		initialLeftZoneHeight = document.getElementById('learningPathToc').offsetHeight;
 		initialRightZoneHeight = document.getElementById('learningPathRightZone').offsetHeight;
 		docHeight = document.body.clientHeight;

+ 35 - 34
main/newscorm/lp_view_item.php

@@ -1,30 +1,30 @@
 <?php
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004-2009 Dokeos SPRL
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Patrick Cool
 	Copyright (c) Denes Nagy
 	Copyright (c) Yannick Warnier
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
 *
 * @author Patrick Cool
@@ -32,14 +32,14 @@
 * @author Roan Embrechts, refactoring and code cleaning
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
 * @package dokeos.learnpath
-============================================================================== 
+==============================================================================
 */
 
 /*
 ==============================================================================
 		INIT SECTION
 ==============================================================================
-*/ 
+*/
 $_SESSION['whereami'] = 'lp/build';
 if(isset($_SESSION['oLP']) && isset($_GET['id']))
 {
@@ -53,7 +53,7 @@ api_protect_course_script();
 -----------------------------------------------------------
 	Libraries
 -----------------------------------------------------------
-*/ 
+*/
 //the main_api.lib.php, database.lib.php and display.lib.php
 //libraries are included by default
 
@@ -61,19 +61,19 @@ include('learnpath_functions.inc.php');
 //include('../resourcelinker/resourcelinker.inc.php');
 include('resourcelinker.inc.php');
 //rewrite the language file, sadly overwritten by resourcelinker.inc.php
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = "learnpath";
 
 /*
 -----------------------------------------------------------
 	Header and action code
 -----------------------------------------------------------
-*/ 
+*/
 /*
 -----------------------------------------------------------
 	Constants and variables
 -----------------------------------------------------------
-*/ 
+*/
 $is_allowed_to_edit = api_is_allowed_to_edit();
 
 $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@@ -112,9 +112,9 @@ if ( (! $is_allowed_to_edit) or ($isStudentView) )
 }
 //from here on, we are admin because of the previous condition, so don't check anymore
 
-$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; 
+$sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
 $result=api_sql_query($sql_query);
-$therow=Database::fetch_array($result); 
+$therow=Database::fetch_array($result);
 
 //$admin_output = '';
 /*
@@ -122,7 +122,7 @@ $therow=Database::fetch_array($result);
 	Course admin section
 	- all the functions not available for students - always available in this case (page only shown to admin)
 -----------------------------------------------------------
-*/ 
+*/
 /*==================================================
 			SHOWING THE ADMIN TOOLS
  ==================================================*/
@@ -131,12 +131,12 @@ $therow=Database::fetch_array($result);
 
 /*==================================================
 	prerequisites setting end
- ==================================================*/		  
+ ==================================================*/
 if (isset($_SESSION['gradebook'])){
 	$gradebook=	$_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {	
+if (!empty($gradebook) && $gradebook=='view') {
 	$interbreadcrumb[]= array (
 			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
 			'name' => get_lang('Gradebook')
@@ -149,7 +149,7 @@ $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath
 //Theme calls
 $show_learn_path=true;
 $lp_theme_css=$_SESSION['oLP']->get_theme();
- 
+
 Display::display_header(null,'Path');
 //api_display_tool_title($therow['name']);
 
@@ -167,11 +167,12 @@ function stripslashes(str) {
 	return str;
 }
 function confirmation(name) {
-	name=stripslashes(name);	
	if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
+	name=stripslashes(name);
+	if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
 		return true;
 	} else {
 		return false;
-	}	
+	}
 }
 </script>
 <?php
@@ -184,25 +185,25 @@ function confirmation(name) {
 -----------------------------------------------------------
 */
 
-echo $_SESSION['oLP']->build_action_menu();	
+echo $_SESSION['oLP']->build_action_menu();
 echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
-	echo '<tr>';			
-		echo '<td class="tree">';	
-			echo '<div class="lp_tree">';					
+	echo '<tr>';
+		echo '<td class="tree">';
+			echo '<div class="lp_tree">';
 				//build the tree with the menu items in it
-				echo $_SESSION['oLP']->build_tree();			
-			echo '</div>';					
+				echo $_SESSION['oLP']->build_tree();
+			echo '</div>';
 		echo '</td>';
-		echo '<td class="workspace">';				
-			echo $_SESSION['oLP']->display_item((isset($new_item_id)) ? $new_item_id : $_GET['id']);			
-		echo '</td>';			
-	echo '</tr>';		
+		echo '<td class="workspace">';
+			echo $_SESSION['oLP']->display_item((isset($new_item_id)) ? $new_item_id : $_GET['id']);
+		echo '</td>';
+	echo '</tr>';
 echo '</table>';
 
 /*
 ==============================================================================
-		FOOTER 
+		FOOTER
 ==============================================================================
-*/ 
+*/
 Display::display_footer();
 ?>

+ 36 - 36
main/newscorm/openoffice_document.class.php

@@ -12,7 +12,7 @@
  */
 
 abstract class OpenofficeDocument extends learnpath {
-	
+
 
 	public $first_item = 0;
     public $original_charset = 'utf-8';
@@ -33,34 +33,34 @@ abstract class OpenofficeDocument extends learnpath {
     		//do nothing but still build the presentation object
     	}
     }
-    
+
     function convert_document($file, $action_after_conversion='make_lp'){
-    	
+
     	global $_course, $_user, $_configuration;
-    
+
     	$this->file_name = (strrpos($file['name'],'.')>0 ? substr($file['name'], 0, strrpos($file['name'],'.')) : $file['name']);
     	$this->file_name = remove_accents($this->file_name);
-		$this->file_name = replace_dangerous_char($this->file_name,'strict');	
+		$this->file_name = replace_dangerous_char($this->file_name,'strict');
 		$this->file_name = strtolower($this->file_name);
 
 		$visio_dir = ($action_after_conversion=='add_docs_to_visio')?VIDEOCONF_UPLOAD_PATH:'';
-		
+
 		$this->file_path = $visio_dir.'/'.$this->file_name.'.'.pathinfo($file['name'],PATHINFO_EXTENSION);
 
 		$dir_name = $visio_dir.'/'.$this->file_name;
-		
-	
-		//create the directory		
+
+
+		//create the directory
 		$this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-		
-		
+
+
 		$this->created_dir = create_unexisting_directory($_course,$_user['user_id'],0,0,$this->base_work_dir,$dir_name);
 
 		move_uploaded_file($file['tmp_name'],$this->base_work_dir.'/'.$this->file_path);
 
 
 		$perm = api_get_setting('permissions_for_new_files');
-		
+
 		/*
 		$classpath = '-cp .:jodconverter-2.2.1.jar:jodconverter-cli-2.2.1.jar';
 		if(isset($_ENV['OS']) && strpos($_ENV['OS'],'Windows') !== false)
@@ -79,8 +79,8 @@ abstract class OpenofficeDocument extends learnpath {
 		*/
 		if (IS_WINDOWS_OS) // IS_WINDOWS_OS has been defined in main_api.lib.php
 		{
-			$converter_path = str_replace('/','\\',api_get_path(SYS_PATH).'main/inc/lib/ppt2png'); 
-			$class_path = $converter_path.';'.$converter_path.'/jodconverter-2.2.1.jar;'.$converter_path.'/jodconverter-cli-2.2.1.jar'; 
+			$converter_path = str_replace('/','\\',api_get_path(SYS_PATH).'main/inc/lib/ppt2png');
+			$class_path = $converter_path.';'.$converter_path.'/jodconverter-2.2.1.jar;'.$converter_path.'/jodconverter-cli-2.2.1.jar';
 
 			//$cmd = 'java -cp "'.$class_path.'" DokeosConverter';
 			$cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$class_path.'" DokeosConverter';
@@ -94,15 +94,15 @@ abstract class OpenofficeDocument extends learnpath {
 
 			$cmd = 'cd '.$converter_path.' && java '.$class_path.' DokeosConverter';
 		}
-		$cmd .=  ' -p '.api_get_setting('service_ppt2lp','port');		
-		
+		$cmd .=  ' -p '.api_get_setting('service_ppt2lp','port');
+
 		// call to the function implemented by child
-		$cmd .= $this -> add_command_parameters();	
+		$cmd .= $this -> add_command_parameters();
 
 		// to allow openoffice to manipulate docs.
 		@chmod ($this->base_work_dir.$this->created_dir,0777);
 		@chmod ($this->base_work_dir.$this->file_path,0777);
-		
+
 		$locale = $this->original_locale; // TODO : improve it because we're not sure this locale is present everywhere
 		putenv('LC_ALL='.$locale);
 		$files = array(); $return = 0;
@@ -112,43 +112,43 @@ abstract class OpenofficeDocument extends learnpath {
 			{
 				// can't connect to openoffice
 				case 1 : $this->error = get_lang('CannotConnectToOpenOffice');break;
-				
+
 				// conversion failed in openoffice
 				case 2 : $this->error = get_lang('OogieConversionFailed');break;
-				
+
 				// conversion can't be launch because command failed
 				case 255 : $this->error = get_lang('OogieUnknownError');break;
 			}
-			
-			DocumentManager::delete_document($_course, $dir_name, $this->base_work_dir);	
-			return false;   
-				
+
+			DocumentManager::delete_document($_course, $dir_name, $this->base_work_dir);
+			return false;
+
 	    }
-	    
+
 		// create lp
 		$this->lp_id = learnpath::add_lp($_course['id'], ucfirst(pathinfo($file['name'], PATHINFO_FILENAME)),'','guess','manual');
-		
+
 		// call to the function implemented by child following action_after_conversion parameter
 		switch ($action_after_conversion)
 		{
-			case 'make_lp':$this -> make_lp($files);	
-			break;		
-			case 'add_docs_to_visio':$this -> add_docs_to_visio($files);	
-			break;	
+			case 'make_lp':$this -> make_lp($files);
+			break;
+			case 'add_docs_to_visio':$this -> add_docs_to_visio($files);
+			break;
 		}
-				
+
 	    $perm = api_get_setting('permissions_for_new_directories');
 		$perm = octdec(!empty($perm)?$perm:0770);
 		chmod ($this->base_work_dir.$this->created_dir,$perm);
-	    return $this->first_item;   	
-	    
+	    return $this->first_item;
+
     }
 
-    
+
     abstract function make_lp();
     abstract function add_docs_to_visio();
     abstract function add_command_parameters();
-   
-		
+
+
 }
 ?>

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff