Browse Source

Feature #1744 - Cleaning logical conditions (4).

Ivan Tcholakov 14 years ago
parent
commit
dfcfaf5d8d
39 changed files with 381 additions and 382 deletions
  1. 1 1
      index.php
  2. 1 1
      main/install/install.lib.php
  3. 4 4
      main/install/update-db-scorm-1.6.x-1.8.0.inc.php
  4. 1 1
      main/link/linkfunctions.php
  5. 3 3
      main/metadata/phpdig/search_function.php
  6. 51 51
      main/mySpace/myspace.lib.php
  7. 1 1
      main/newscorm/aicc.class.php
  8. 2 2
      main/newscorm/aicc_api.php
  9. 17 17
      main/newscorm/js/api_wrapper.js
  10. 45 45
      main/newscorm/learnpath.class.php
  11. 43 43
      main/newscorm/learnpathItem.class.php
  12. 2 2
      main/newscorm/lp_add_item.php
  13. 5 5
      main/newscorm/lp_controller.php
  14. 1 1
      main/newscorm/lp_header.php
  15. 1 1
      main/newscorm/lp_upload.php
  16. 7 7
      main/newscorm/lp_view.php
  17. 1 1
      main/newscorm/resourcelinker.inc.php
  18. 6 7
      main/newscorm/scorm_api.php
  19. 1 1
      main/notebook/index.php
  20. 1 1
      main/online/online_message.php
  21. 2 2
      main/permissions/permissions_functions.inc.php
  22. 1 1
      main/reservation/m_item.php
  23. 1 1
      main/reservation/m_item_origineel.php
  24. 7 7
      main/social/profile.php
  25. 1 1
      main/survey/create_new_survey.php
  26. 1 1
      main/upload/index.php
  27. 1 1
      main/user/userInfoLib.php
  28. 1 1
      main/webservices/registration.soap.php
  29. 41 41
      main/webservices/webservice_course.php
  30. 27 27
      main/webservices/webservice_session.php
  31. 34 34
      main/webservices/webservice_user.php
  32. 1 1
      main/wiki/diff.inc.php
  33. 6 6
      main/wiki/index.php
  34. 4 4
      main/wiki/wiki.inc.php
  35. 31 31
      main/work/work.lib.php
  36. 19 19
      main/work/work.php
  37. 1 1
      tests/simpletest/unit_tester.php
  38. 7 7
      user.php
  39. 1 1
      user_portal.php

+ 1 - 1
index.php

@@ -707,7 +707,7 @@ function display_anonymous_course_list() {
 		foreach ($course_list as $course) {
 			// $setting_show_also_closed_courses
 
-			if ($setting_show_also_closed_courses == false) {
+			if (!$setting_show_also_closed_courses) {
 				// If we do not show the closed courses
 				// we only show the courses that are open to the world (to everybody)
 				// and the courses that are open to the platform (if the current user is a registered user

+ 1 - 1
main/install/install.lib.php

@@ -1346,7 +1346,7 @@ function display_license_agreement() {
 				<td align="center">
 					<button type="submit" class="back" name="step1" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
 					<input type="hidden" name="is_executable" id="is_executable" value="-" />
-					<button type="submit" class="next" name="step3" onclick="javascript:if(document.getElementById('accept_licence').checked == false) { alert('<?php echo get_lang('YouMustAcceptLicence')?>');return false;}" value="<?php echo get_lang('Next'); ?> &gt;" ><?php echo get_lang('Next'); ?></button>
+					<button type="submit" class="next" name="step3" onclick="javascript: if(!document.getElementById('accept_licence').checked) { alert('<?php echo get_lang('YouMustAcceptLicence')?>');return false;}" value="<?php echo get_lang('Next'); ?> &gt;" ><?php echo get_lang('Next'); ?></button>
 				</td>
 			</tr>
                         </table>

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

@@ -137,7 +137,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
                         "'".Database::escape_string($row['learnpath_description'])."',$dsp_ord,'Dokeos')";
         $ins_lp_res = Database::query($ins_lp_sql);
         $in_id = Database::insert_id();
-        if (empty($in_id) or $in_id == false) die('Could not insert lp: '.$ins_lp_sql);
+        if (!$in_id) die('Could not insert lp: '.$ins_lp_sql);
         $lp_ids[$row['learnpath_id']] = $in_id;
         $dsp_ord++;
         $max_dsp_lp = $dsp_ord;
@@ -181,7 +181,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
         $ins_res = Database::query($ins_lp_sql);
         $in_id = Database::insert_id();
         //echo "&nbsp;&nbsp;Inserted item $in_id<br />\n";
-        if (empty($in_id) OR $in_id == false) die('Could not insert lp: '.$ins_sql);
+        if (!$in_id) die('Could not insert lp: '.$ins_sql);
         $parent_chaps[$row['id']] = $row['parent_chapter_id'];
         $lp_chap_items[$row['id']] = $in_id;
         $parent_lps[$row['id']] = $row['learnpath_id'];
@@ -330,7 +330,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
             $ins_res = Database::query($ins_lp_sql);
             $in_id = Database::insert_id();
             //echo "&nbsp;&nbsp;Inserted item $in_id (".$row['title'].")<br />\n";
-            if (empty($in_id) OR $in_id == false) die('Could not insert lp_item: '.$ins_sql);
+            if (!$in_id) 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;
         }
@@ -973,7 +973,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
         if ($loglevel > 1) { error_log("$sql_ins", 0); }
         $sql_res = Database::query($sql_ins);
         $in_id = Database::insert_id();
-        if (empty($in_id) or $in_id == false) die('Could not insert scorm lp: '.$sql_ins);
+        if (!$in_id) die('Could not insert scorm lp: '.$sql_ins);
         //echo "&nbsp;&nbsp;Inserted item $in_id<br />\n";
         $lp_ids[$my_content_id] = $in_id; //contains the old LP ID => the new LP ID
         $lp_course[$my_content_id] = $courses_id_list[$my_course_code]; // Contains the old learnpath ID => the course DB name

+ 1 - 1
main/link/linkfunctions.php

@@ -53,7 +53,7 @@ function addlinkcategory($type) {
 		$description = trim($description);
 
 		// If title is empty, an error occurs
-		if (filter_var($urllink, FILTER_VALIDATE_URL) == false) {
+		if (!filter_var($urllink, FILTER_VALIDATE_URL)) {
 			$msgErr = get_lang('GiveURL');
 			Display::display_error_message(get_lang('GiveURL'));
 			$ok = false;

+ 3 - 3
main/metadata/phpdig/search_function.php

@@ -342,7 +342,7 @@ if ($ncrit && is_array($strings)) {
         reset($final_result);
         $query_for_phrase_array = explode(" ",$query_for_phrase);
         $reg_strings = str_replace('@#@',' ',phpdigPregQuotes(str_replace('\\','',implode('@#@',$query_for_phrase_array))));
-        $stop_regs = "[][(){}[:blank:]=&?!&#%\$£*@+%:;,/\.'\"]";
+        $stop_regs = "[][(){}[:blank:]=&?!&#%\$�*@+%:;,/\.'\"]";
         $reg_strings = "($stop_regs{1}|^)($reg_strings)($stop_regs{1}|\$)";
         while (list($spider_id,$weight) = each($final_result)) {
           $content_file = $relative_script_path.'/'.TEXT_CONTENT_PATH.$spider_id.'.txt';
@@ -416,7 +416,7 @@ if ((is_array($final_result)) && (count($final_result) > 0)) {
     else {
         $reg_strings = str_replace('@#@','|',phpdigPregQuotes(str_replace('\\','',implode('@#@',$strings))));
     }
-    $stop_regs = "[][(){}[:blank:]=&?!&#%\$£*@+%:;,/\.'\"]";
+    $stop_regs = "[][(){}[:blank:]=&?!&#%\$�*@+%:;,/\.'\"]";
 
     switch($option) {
         case 'any':
@@ -641,7 +641,7 @@ else {
 }
 
 $timer->start('Logs');
-if (PHPDIG_LOGS == true && !$browse && !$refine && $adlog_flag == 0) {
+if (PHPDIG_LOGS && !$browse && !$refine && $adlog_flag == 0) {
    if (is_array($final_result)) {
        phpdigAddLog ($id_connect,$option,$strings,$exclude,count($final_result),$search_time);
    }

+ 51 - 51
main/mySpace/myspace.lib.php

@@ -180,8 +180,8 @@ class MySpace {
 			} else {
 				$$avg_score = '-';
 			}
-			
-			$return .= '	<td><div>'.$avg_score.'</div></td>';			
+
+			$return .= '	<td><div>'.$avg_score.'</div></td>';
 			// student tes score
 			//$return .= '	<td><div style="width:40px">'.round(Tracking :: get_avg_student_exercise_score ($user_id, $row[0]),2).'%</div></td>';
 			// student messages
@@ -333,7 +333,7 @@ class MySpace {
 			}
 		}
 	}
-	
+
 	/**
 	 * Display a sortable table that contains an overview of all the reporting progress of all courses
 	 */
@@ -361,17 +361,17 @@ class MySpace {
 
 		$table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1);
 		$table->additional_parameters = $addparams;
-		
+
 		$table->set_header(0, '', false, null, array('style' => 'display: none'));
 		$table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
 		$table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
 		$table->set_column_filter(2, array('MySpace','course_tracking_filter'));
 		$table->display();
 	}
-	
+
 	/**
 	 * Get the total number of courses
-	 * 
+	 *
 	 * @return integer Total number of courses
 	 */
 	public function get_total_number_courses() {
@@ -379,7 +379,7 @@ class MySpace {
 		$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 		return Database::count_rows($main_course_table);
 	}
-	
+
 	/**
 	 * Get data for the courses
 	 *
@@ -395,11 +395,11 @@ class MySpace {
 		//$access_url_id = api_get_current_access_url_id();
 	 	//$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 		$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
-		
+
 		/*if ($_configuration['multiple_access_urls']) {
 			$condition_multi_url = ", $tbl_url_rel_user as url_user WHERE user.user_id=url_user.user_id AND access_url_id='$access_url_id'";
 		}
-		
+
 		global $export_csv;
 		if ($export_csv) {
 			$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
@@ -416,7 +416,7 @@ class MySpace {
 		}
 		return $return;
 	}
-	
+
 	/**
 	 * Fills in course reporting data
 	 *
@@ -477,17 +477,17 @@ class MySpace {
 			}
 			$nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
 			$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
-			
+
 			$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $course_code, null, false);
-			if($last_login_date_tmp != false && $last_login_date == false) {
+			if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
 				$last_login_date = $last_login_date_tmp;
-			} else if($last_login_date_tmp != false && $last_login_date == false) {
+			} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
 				// Find the max and assign it to first_login_date
 				if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
 					$last_login_date = $last_login_date_tmp;
 				}
 			}
-			
+
 			$exercise_results_tmp = MySpace::exercises_results($row->user_id, $course_code);
 			$total_score_obtained += $exercise_results_tmp['score_obtained'];
 			$total_score_possible += $exercise_results_tmp['score_possible'];
@@ -503,7 +503,7 @@ class MySpace {
 		} else {
 			$avg_score = '-';
 		}
-		if($last_login_date != false) {
+		if($last_login_date) {
 			$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
 		} else {
 			$last_login_date = '-';
@@ -538,7 +538,7 @@ class MySpace {
 		$return .= '</table>';
 		return $return;
 	}
-	
+
 	/**
 	 * This function exports the table that we see in display_tracking_course_overview()
 	 *
@@ -560,7 +560,7 @@ class MySpace {
 		} else {
 			$orderby = 0;
 		}
-		
+
 		if ($_GET['tracking_course_overview_direction']) {
 			$direction = $_GET['tracking_course_overview_direction'];
 		} else {
@@ -568,7 +568,7 @@ class MySpace {
 		}
 
 		$course_data = MySpace::get_course_data_tracking_overview($from, 1000, $orderby, $direction);
-		
+
 		$csv_content = array();
 
 		// the first line of the csv file with the column headers
@@ -590,10 +590,10 @@ class MySpace {
 		foreach ($course_data as $key => $course) {
 			$course_code = $course[0];
 			$course_title = $course[1];
-			
+
 			$csv_row = array();
 			$csv_row[] = $course_title;
-			
+
 			// getting all the courses of the session
 			$sql = "SELECT * FROM $tbl_user AS u INNER JOIN $tbl_course_rel_user AS cu ON cu.user_id = u.user_id WHERE cu.course_code = '".$course_code."' AND ISNULL(cu.role);";
 			$result = Database::query($sql);
@@ -621,17 +621,17 @@ class MySpace {
 				}
 				$nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
 				$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
-				
+
 				$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row->user_id, $course_code, null, false);
-				if($last_login_date_tmp != false && $last_login_date == false) {
+				if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
 					$last_login_date = $last_login_date_tmp;
-				} else if($last_login_date_tmp != false && $last_login_date == false) {
+				} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
 					// Find the max and assign it to first_login_date
 					if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
 						$last_login_date = $last_login_date_tmp;
 					}
 				}
-				
+
 				$exercise_results_tmp = MySpace::exercises_results($row->user_id, $course_code);
 				$total_score_obtained += $exercise_results_tmp['score_obtained'];
 				$total_score_possible += $exercise_results_tmp['score_possible'];
@@ -647,7 +647,7 @@ class MySpace {
 			} else {
 				$avg_score = '-';
 			}
-			if($last_login_date != false) {
+			if($last_login_date) {
 				$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
 			} else {
 				$last_login_date = '-';
@@ -679,7 +679,7 @@ class MySpace {
 		Export :: export_table_csv($csv_content, 'reporting_course_overview');
 		exit;
 	}
-	
+
 	/**
 	 * Display a sortable table that contains an overview of all the reporting progress of all sessions and all courses the user is subscribed to
 	 * @author Guillaume Viguier <guillaume@viguierjust.com>
@@ -709,17 +709,17 @@ class MySpace {
 
 		$table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_sessions'), array('MySpace','get_session_data_tracking_overview'), 1);
 		$table->additional_parameters = $addparams;
-		
+
 		$table->set_header(0, '', false, null, array('style' => 'display: none'));
 		$table->set_header(1, get_lang('Session'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
 		$table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
 		$table->set_column_filter(2, array('MySpace','session_tracking_filter'));
 		$table->display();
 	}
-	
+
 	/**
 	 * Get the total number of sessions
-	 * 
+	 *
 	 * @return integer Total number of sessions
 	 */
 	public function get_total_number_sessions() {
@@ -727,7 +727,7 @@ class MySpace {
 		$main_session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
 		return Database::count_rows($main_session_table);
 	}
-	
+
 	/**
 	 * Get data for the sessions
 	 *
@@ -743,11 +743,11 @@ class MySpace {
 		//$access_url_id = api_get_current_access_url_id();
 	 	//$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 		$main_session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
-		
+
 		/*if ($_configuration['multiple_access_urls']) {
 			$condition_multi_url = ", $tbl_url_rel_user as url_user WHERE user.user_id=url_user.user_id AND access_url_id='$access_url_id'";
 		}
-		
+
 		global $export_csv;
 		if ($export_csv) {
 			$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
@@ -764,7 +764,7 @@ class MySpace {
 		}
 		return $return;
 	}
-	
+
 	/**
 	 * Fills in session reporting data
 	 *
@@ -833,17 +833,17 @@ class MySpace {
 				}
 				$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
 				$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
-				
+
 				$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $row->code, $session_id, false);
-				if($last_login_date_tmp != false && $last_login_date == false) {
+				if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
 					$last_login_date = $last_login_date_tmp;
-				} else if($last_login_date_tmp != false && $last_login_date == false) {
+				} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition! To be cleaned.
 					// Find the max and assign it to first_login_date
 					if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
 						$last_login_date = $last_login_date_tmp;
 					}
 				}
-				
+
 				$exercise_results_tmp = MySpace::exercises_results($row_user->user_id, $row->code, $session_id);
 				$total_score_obtained += $exercise_results_tmp['score_obtained'];
 				$total_score_possible += $exercise_results_tmp['score_possible'];
@@ -859,7 +859,7 @@ class MySpace {
 			} else {
 				$avg_score = '-';
 			}
-			if($last_login_date != false) {
+			if($last_login_date) {
 				$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
 			} else {
 				$last_login_date = '-';
@@ -894,7 +894,7 @@ class MySpace {
 		$return .= '</table>';
 		return $return;
 	}
-	
+
 	/**
 	 * This function exports the table that we see in display_tracking_session_overview()
 	 *
@@ -917,7 +917,7 @@ class MySpace {
 		} else {
 			$orderby = 0;
 		}
-		
+
 		if ($_GET['tracking_session_overview_direction']) {
 			$direction = $_GET['tracking_session_overview_direction'];
 		} else {
@@ -925,7 +925,7 @@ class MySpace {
 		}
 
 		$session_data = MySpace::get_session_data_tracking_overview($from, 1000, $orderby, $direction);
-		
+
 		$csv_content = array();
 
 		// the first line of the csv file with the column headers
@@ -948,7 +948,7 @@ class MySpace {
 		foreach ($session_data as $key => $session) {
 			$session_id = $session[0];
 			$session_title = $session[1];
-			
+
 			// getting all the courses of the session
 			$sql = "SELECT * FROM $tbl_course AS c INNER JOIN $tbl_session_rel_course AS sc ON sc.course_code = c.code WHERE sc.id_session = '".$session_id."';";
 			$result = Database::query($sql);
@@ -983,17 +983,17 @@ class MySpace {
 					}
 					$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
 					$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
-					
+
 					$last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course ($row_user->user_id, $row->code, $session_id, false);
-					if($last_login_date_tmp != false && $last_login_date == false) {
+					if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
 						$last_login_date = $last_login_date_tmp;
-					} else if($last_login_date_tmp != false && $last_login_date == false) {
+					} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
 						// Find the max and assign it to first_login_date
 						if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
 							$last_login_date = $last_login_date_tmp;
 						}
 					}
-					
+
 					$exercise_results_tmp = MySpace::exercises_results($row_user->user_id, $row->code, $session_id);
 					$total_score_obtained += $exercise_results_tmp['score_obtained'];
 					$total_score_possible += $exercise_results_tmp['score_possible'];
@@ -1009,7 +1009,7 @@ class MySpace {
 				} else {
 					$avg_score = '-';
 				}
-				if($last_login_date != false) {
+				if($last_login_date) {
 					$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
 				} else {
 					$last_login_date = '-';
@@ -1047,8 +1047,8 @@ class MySpace {
 		Export :: export_table_csv($csv_content, 'reporting_session_overview');
 		exit;
 	}
-	
-	
+
+
 	/**
 	 * Get general information about the exercise performance of the user
 	 * the total obtained score (all the score on all the questions)
@@ -1349,11 +1349,11 @@ class MySpace {
 		$access_url_id = api_get_current_access_url_id();
 	 	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 		$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
-		
+
 		if ($_configuration['multiple_access_urls']) {
 			$condition_multi_url = ", $tbl_url_rel_user as url_user WHERE user.user_id=url_user.user_id AND access_url_id='$access_url_id'";
 		}
-		
+
 		global $export_csv;
 		if ($export_csv) {
 			$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);

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

@@ -450,7 +450,7 @@ class aicc extends learnpath {
 			}
 		}
 
-		if($package_type== '' OR $mandatory!=true)
+		if ($package_type == '' || !$mandatory)
 		 // && defined('CHECK_FOR_AICC') && CHECK_FOR_AICC)
 		{
 			return api_failure::set_failure('not_aicc_content');

+ 2 - 2
main/newscorm/aicc_api.php

@@ -312,10 +312,10 @@ function LMSCommit(val) {
 	return('true');
 }
 function LMSFinish(val) {
-	if (( commit == false )) {
+	if ( !commit ) {
 		logit_scorm('LMSFinish() (no LMSCommit())',1);
 	}
-	if ( commit == true ) {
+	if ( commit ) {
 		logit_scorm('LMSFinish() called',1);
 		savedata('finish');
 	}

+ 17 - 17
main/newscorm/js/api_wrapper.js

@@ -98,7 +98,7 @@ function ErrorHandler()
 		if(errCode == _NotImplementedError)
 		{
 			var errDescription = "The LMS doesn't support this feature";
-			if(_debug == true)
+			if(_debug)
 			{
 				errDescription += "\n";
 				errDescription += api.LMSGetDiagnostic(null);
@@ -108,7 +108,7 @@ function ErrorHandler()
 		else
 		{
 			var errDescription = API.LMSGetErrorString(errCode);
-			if(_debug == true)
+			if(_debug)
 			{
 				errDescription += "\n";
 				errDescription += api.LMSGetDiagnostic(null);
@@ -278,7 +278,7 @@ var exitPageStatus;
 function loadPage()
 {
 	var result = doLMSInitialize();
-	if(result != false)
+	if(result)
 	{
 		var status = doLMSGetValue("cmi.core.lesson_status");
 		if(status == "not attempted")
@@ -407,7 +407,7 @@ function doQuit()
  */
 function unloadPage(status)
 {
-    if (exitPageStatus != true)
+    if (!exitPageStatus)
     {
            // doQuit( status );
     }
@@ -445,7 +445,7 @@ function checkAnswers(interrupted)
 				{
 					var idAnswer = questions_answers[idQuestion][j];
 					var answer = document.getElementById('question_'+(idQuestion)+'_multiple_'+(idAnswer));
-					if(answer.checked == true)
+					if(answer.checked)
 					{
 						interactionAnswers += idAnswer+'__|';// changed by isaac flores
 						myScore +=questions_answers_ponderation[idQuestion][idAnswer];
@@ -482,7 +482,7 @@ function checkAnswers(interrupted)
 				{
 					var idAnswer = questions_answers[idQuestion][j];
 					var answer = document.getElementById('question_'+(idQuestion)+'_unique_'+(idAnswer));
-					if(answer.checked == true)
+					if(answer.checked)
 					{
 						interactionAnswers += idAnswer;
 						if(questions_answers_correct[idQuestion] == idAnswer)
@@ -511,7 +511,7 @@ function checkAnswers(interrupted)
 				{
 					var idAnswer = questions_answers[idQuestion][j];
 					var answer = document.getElementById('question_'+(idQuestion)+'_tf_'+(idAnswer));
-					if(answer.checked.value == true)
+					if(answer.checked.value)
 					{
 						interactionAnswers += idAnswer;
 						for(k=0;k<questions_answers_correct[idQuestion].length;k++)
@@ -628,16 +628,16 @@ function checkAnswers(interrupted)
 			} else if(type == 'exact') {
 				var interactionType = 'exact';
 				interactionScore = 0;
-				// not yet implemented see scorm_classes.php ScormAnswerMultipleChoice::export() function 
+				// not yet implemented see scorm_classes.php ScormAnswerMultipleChoice::export() function
 				/*
-			
+
 				var myScore = 0;
 				var real_answers = new Array();
 
 				for(var j=0; j<questions_answers[idQuestion].length;j++) {
 					var idAnswer = questions_answers[idQuestion][j];
 					var answer   = document.getElementById('question_'+(idQuestion)+'_multiple_'+(idAnswer));
-					if (answer.checked == true) {
+					if (answer.checked) {
 						if(questions_answers_ponderation[idQuestion][idAnswer] != 0 ) {
 							real_answers[j] = true;
 						} else {
@@ -654,17 +654,17 @@ function checkAnswers(interrupted)
 				}
 
 				var final_answer = true;
-				for(var z=0; z<real_answers.length ;z++) {		
-		 			if (real_answers[z] == false) {
+				for(var z=0; z<real_answers.length ;z++) {
+		 			if (!real_answers[z]) {
 			 			final_answer = false;
-			 		}		 	
+			 		}
 			 	}
 
-			 	if (final_answer == true) {
-			 		//getting only the first score where we save the weight of all the question 
+			 	if (final_answer) {
+			 		//getting only the first score where we save the weight of all the question
 					myScore += questions_answers_ponderation[idQuestion][1];
 				}
-			
+
 				interactionScore = myScore;
 				//correct responses work by pattern, see SCORM Runtime Env Doc
 				//for(k=0;k<questions_answers_correct[idQuestion].length;k++)
@@ -709,7 +709,7 @@ function checkAnswers(interrupted)
 	}
 	doLMSSetValue('cmi.core.lesson_status',status);
 
-	if((interrupted==true) && (status != 'completed') && (status != 'passed'))
+	if (interrupted && (status != 'completed') && (status != 'passed'))
 	{
 		doLMSSetValue('cmi.core.exit','suspended');
 	}

+ 45 - 45
main/newscorm/learnpath.class.php

@@ -3,10 +3,10 @@
 /**
  * This (abstract?) class defines the parent attributes and methods for the dokeos learnpaths and scorm
  * learnpaths. It is used by the scorm class.
- * 
+ *
  * @package chamilo.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
- * @author	Julio Montoya   <gugli100@gmail.com> Improvements 
+ * @author	Julio Montoya   <gugli100@gmail.com> Improvements
  * @license	GNU/GPL - See license in root directory for details
  */
 /**
@@ -69,7 +69,7 @@ class learnpath {
 	var $lp_session_id =0;
 
 	var $prerequisite = 0;
-	
+
 	/**
 	 * Class constructor. Needs a database handler, a course code and a learnpath id from the database.
 	 * Also builds the list of items into $this->items.
@@ -712,7 +712,7 @@ class learnpath {
 						}
 					}
 				}
-				if ($completed == true) { //if all the children were completed
+				if ($completed) { //if all the children were completed
 					$parent->set_status('completed');
 					$parent->save(false, $this->prerequisites_match($parent->get_id()));
 					$this->update_queue[$parent->get_id()] = $parent->get_status();
@@ -1416,7 +1416,7 @@ class learnpath {
 		return $current;
 	}
 
-	/** 
+	/**
 	 * Force to get the first learnpath item id
 	 * @return	integer	The current learnpath item id
 	 */
@@ -1469,7 +1469,7 @@ class learnpath {
 		if (count($this->ordered_items) == 0) {
 			$this->index = 0;
 		}
-		if (!empty ($this->last_item_seen) && !empty ($this->items[$this->last_item_seen]) && $this->items[$this->last_item_seen]->get_type() != 'dir' && $this->items[$this->last_item_seen]->get_type() != 'dokeos_chapter' && $this->items[$this->last_item_seen]->is_done() != true) {
+		if (!empty ($this->last_item_seen) && !empty ($this->items[$this->last_item_seen]) && $this->items[$this->last_item_seen]->get_type() != 'dir' && $this->items[$this->last_item_seen]->get_type() != 'dokeos_chapter' && !$this->items[$this->last_item_seen]->is_done()) {
 			if ($this->debug > 2) {
 				error_log('New LP - In learnpath::first() - Last item seen is ' . $this->last_item_seen . ' of type ' . $this->items[$this->last_item_seen]->get_type(), 0);
 			}
@@ -1751,7 +1751,7 @@ class learnpath {
 					$package_type = 'scorm';
 					break; //exit the foreach loop
 				}
-				elseif (preg_match('/aicc\//i', $thisContent['filename']) != false) {
+				elseif (preg_match('/aicc\//i', $thisContent['filename'])) {
 					//if found an aicc directory... (!= false means it cannot be false (error) or 0 (no match))
 					$package_type = 'aicc';
 					//break;//don't exit the loop, because if we find an imsmanifest afterwards, we want it, not the AICC
@@ -1941,7 +1941,7 @@ class learnpath {
 	function is_lp_visible_for_student($lp_id, $student_id) {
 
 		$tbl_learnpath = Database :: get_course_table(TABLE_LP_MAIN);
-		
+
 		// get current prerequisite
 		$sql = "SELECT prerequisite FROM $tbl_learnpath WHERE id = $lp_id";
 		$rs  = Database::query($sql);
@@ -1949,17 +1949,17 @@ class learnpath {
 		$prerequisite = $row['prerequisite'];
 		$is_visible = true;
 		$progress = 0;
-				
+
 		if (!empty($prerequisite)) {
 			$progress = self::get_db_progress($prerequisite,$student_id,'%');
-			$progress = intval($progress);			
+			$progress = intval($progress);
 			if ($progress < 100) {
-				$is_visible = false;	
-			}			
+				$is_visible = false;
+			}
 		}
-		
+
 		return $is_visible;
-		
+
 	}
 
 	/**
@@ -2509,7 +2509,7 @@ class learnpath {
 			}
 		}
 		if ($this->debug > 2) {
-			error_log('New LP - In learnpath::get_type() - Returning ' . ($res == false ? 'false' : $res), 0);
+			error_log('New LP - In learnpath::get_type() - Returning ' . ($res ? $res : 'false'), 0);
 		}
 		return $res;
 	}
@@ -2805,15 +2805,15 @@ class learnpath {
 			} else {
 				$course_path = $sys_course_path; //system path
 			}
-			
-			
+
+
 			//Fixed issue BT#1272 - If the item type is a Chamilo Item (quiz, link, etc), then change the lp type to thread it as a normal Chamilo LP not a SCO.
 			if (in_array($lp_item_type, array('quiz', 'document', 'link', 'forum', 'thread', 'student_publication'))) {
 				$lp_type = 1;
 			}
 			//Now go through the specific cases to get the end of the path
-					
-			//@todo use constants instead of int values	
+
+			//@todo use constants instead of int values
 			switch ($lp_type) {
 				case 1 :
 					if ($lp_item_type == 'dokeos_chapter') {
@@ -3892,7 +3892,7 @@ class learnpath {
 		$res = Database::query($sql);
 		return true;
 	}
-	
+
 	/**
 	* Sets the prerequisite of a LP (and save)
 	* @param	int		integer giving the new prerequisite of this learnpath
@@ -4330,7 +4330,7 @@ class learnpath {
 
 		if ($is_allowed_to_edit) {
 			$token = Security::get_token();
-			
+
 			$gradebook = Security :: remove_XSS($_GET['gradebook']);
 			$return .= '<div class="actions">';
 			$return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']) . '&amp;gradebook=' . $gradebook . '&amp;action=build&amp;lp_id=' . $this->lp_id . '" title="' . get_lang("Build") . '">' . Display :: return_icon('learnpath_build.gif', get_lang('Build')) . ' ' . get_lang('Build') . '</a>';
@@ -4721,14 +4721,14 @@ class learnpath {
 			$sql = "SELECT lp.* FROM " . $tbl_lp_item . " as lp
 					WHERE lp.id = " . Database :: escape_string($item_id);
 			$result = Database::query($sql);
-			while ($row = Database :: fetch_array($result)) {				
+			while ($row = Database :: fetch_array($result)) {
 				$_SESSION['parent_item_id'] = ($row['item_type'] == 'dokeos_chapter' || $row['item_type'] == 'dokeos_module' || $row['item_type'] == 'dir') ? $item_id : 0;
-				
-				//Prevents wrong parent selection for document see Bug#1251 
+
+				//Prevents wrong parent selection for document see Bug#1251
 				if ($row['item_type'] != 'dokeos_chapter' || $row['item_type'] != 'dokeos_module') {
-					$_SESSION['parent_item_id'] = $row['parent_item_id'];					
+					$_SESSION['parent_item_id'] = $row['parent_item_id'];
 				}
-				
+
 				$return .= $this->display_manipulate($item_id, $row['item_type']);
 				$return .= '<div style="padding:10px;">';
 				if ($msg != '')
@@ -6058,7 +6058,7 @@ class learnpath {
 				'min_score' 		=> $row['min_score'],
 				'mastery_score' 	=> $row['mastery_score'],
 				'prerequisite' 		=> $row['prerequisite']
-			);			
+			);
 		}
 
 		$this->tree_array($arrLP);
@@ -6117,7 +6117,7 @@ class learnpath {
 				}
 			}
 		}
-		
+
 		$parent_select = & $form->addElement('select', 'parent', get_lang('Parent'), '', 'class="learnpath_item_form" style="width:40%;" onchange="load_cbo(this.value);"');
 		$my_count=0;
 		foreach ($arrHide as $key => $value) {
@@ -6131,15 +6131,15 @@ class learnpath {
 			}
 			$my_count++;
 		}
-		
+
 		if (!empty ($id)) {
 			$parent_select->setSelected($parent);
-		} else {			
+		} else {
 			$parent_item_id = $_SESSION['parent_item_id'];
 			$parent_select->setSelected($parent_item_id);
 		}
-		
-		
+
+
 
 		if (is_array($arrLP)) {
 			reset($arrLP);
@@ -7151,7 +7151,7 @@ class learnpath {
 		global $charset;
 		$lp_id = $this->lp_id;
 		$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
-	
+
 		// get current prerequisite
 		$sql = "SELECT * FROM $tbl_lp WHERE id = $lp_id ";
 		$result = Database::query($sql);
@@ -7159,18 +7159,18 @@ class learnpath {
 		$preq_id = $row['prerequisite'];
 		$session_id = api_get_session_id();
 		$session_condition = api_get_session_condition($session_id, false);
-		$sql 	= "SELECT * FROM $tbl_lp $session_condition ORDER BY display_order ";		
+		$sql 	= "SELECT * FROM $tbl_lp $session_condition ORDER BY display_order ";
 		$rs = Database::query($sql);
 		$return = '';
 		$return .= '<select name="prerequisites" >';
-		$return .= '<option value="0">'.get_lang('None').'</option>';		
-		if (Database::num_rows($rs) > 0) {					
+		$return .= '<option value="0">'.get_lang('None').'</option>';
+		if (Database::num_rows($rs) > 0) {
 			while ($row = Database::fetch_array($rs)) {
 				if ($row['id'] == $lp_id) {
-					continue;	
-				}					
-				$return .= '<option value="'.$row['id'].'" '.(($row['id']==$preq_id)?' selected ' : '').'>'.$row['name'].'</option>';							
-			}			
+					continue;
+				}
+				$return .= '<option value="'.$row['id'].'" '.(($row['id']==$preq_id)?' selected ' : '').'>'.$row['name'].'</option>';
+			}
 		}
 		$return .= '</select>';
 		return $return;
@@ -7250,21 +7250,21 @@ class learnpath {
 	 */
 	function write_resources_tree($resources_sorted, $num = 0) {
 
-		require_once (api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');		
+		require_once (api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');
 		if (count($resources_sorted) > 0) {
 			foreach ($resources_sorted as $key => $resource) {
-				if (is_int($resource['id'])) { 
+				if (is_int($resource['id'])) {
 					// it's a folder
 					$return .= '<div><div style="margin-left:' . ($num * 15) . 'px;margin-right:5px;"><img style="cursor: pointer;" src="../img/nolines_plus.gif" align="absmiddle" id="img_' . $resource["id"] . '" onclick="testResources(\'' . $resource["id"] . '\',\'img_' . $resource["id"] . '\')"><img alt="" src="../img/lp_folder.gif" title="" align="absmiddle" />&nbsp;<span onclick="testResources(\'' . $resource["id"] . '\',\'img_' . $resource["id"] . '\')" style="cursor: pointer;" >' . $key . '</span></div><div style="display: none;" id="' . $resource['id'] . '">';
 					$return .= $this->write_resources_tree($resource['files'], $num +1);
 					$return .= '</div></div>';
 				} else {
 					if (!is_array($resource)) {
-						// it's a file				
+						// it's a file
 						$icon		= choose_image($resource);
 						$position 	= strrpos($icon, '.');
-						$icon 		= substr($icon, 0, $position) . '_small.gif';					
-						$file_info	= explode('/', $resource);						
+						$icon 		= substr($icon, 0, $position) . '_small.gif';
+						$file_info	= explode('/', $resource);
           				$my_file_title = $file_info[0];
           				$my_file_name  = $file_info[1];
 						//$return .= '<div><div style="margin-left:' . (($num +1) * 15) . 'px;margin-right:5px;"><a href="' . api_get_self() . '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;file=' . $key . '&amp;lp_id=' . $this->lp_id . '"><img alt="" src="../img/' . $icon . '" title="" />&nbsp;' . $resource .'</a></div></div>';

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

@@ -65,7 +65,7 @@ class learnpathItem {
      * @param	integer	User ID
      * @return	boolean	True on success, false on failure
      */
-    function learnpathItem($db_id, $user_id) { 
+    function learnpathItem($db_id, $user_id) {
     	//get items table
     	if(self::debug>0){error_log('New LP - In learnpathItem constructor: '.$db_id.','.$user_id,0);}
     	$items_table = Database::get_course_table(TABLE_LP_ITEM);
@@ -1016,7 +1016,7 @@ class learnpathItem {
     		$res = Database::query($sql);
     		if (Database::num_rows($res)==1) {
     			$row = Database::fetch_array($res);
-    			if($update_local==true){
+    			if ($update_local) {
     				$this->set_status($row['status']);
     			}
 	    		if(self::debug>2){error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'],0);}
@@ -1108,7 +1108,7 @@ class learnpathItem {
     	if (empty($this->title)) {return '';}
     	return $this->title;
     }
-    
+
     /**
      * Returns the total time used to see that item
      * @return	integer	Total time
@@ -1233,7 +1233,7 @@ class learnpathItem {
     		}*/
     		// if we don't init start time here, the time is sometimes calculated from the las start time
     		$this->current_start_time = time();
-    		
+
     		//error_log('New LP - reinit blocked by setting',0);
     	}
     }
@@ -1260,7 +1260,7 @@ class learnpathItem {
 	 * @param	integer	The user ID. In some cases like Dokeos quizzes, it's necessary to have the user ID to query other tables (like the results of quizzes)
      * @return	boolean	True if the list of prerequisites given is entirely satisfied, false otherwise
      */
-    function parse_prereq($prereqs_string, $items, $refs_list,$user_id){    	
+    function parse_prereq($prereqs_string, $items, $refs_list,$user_id){
 		if(self::debug>0){error_log('New LP - In learnpathItem::parse_prereq() for learnpath '.$this->lp_id.' with string '.$prereqs_string,0);}
     	//deal with &, |, ~, =, <>, {}, ,, X*, () in reverse order
 		$this->prereq_alert = '';
@@ -1287,9 +1287,9 @@ class learnpathItem {
 				}
 			}
 		}
-	
+
 		//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 (strpos($prereqs_string,"|")===false) {
     		if(self::debug>1){error_log('New LP - Didnt find any OR, looking for AND',0);}
 	    	if(strpos($prereqs_string,"&")!==false){
 	    		$list = split("&",$prereqs_string);
@@ -1297,7 +1297,7 @@ class learnpathItem {
 					$andstatus = true;
 					foreach($list as $condition){
 	    				$andstatus = $andstatus && $this->parse_prereq($condition,$items,$refs_list,$user_id);
-	    				if($andstatus==false){
+	    				if (!$andstatus) {
 							if(self::debug>1){error_log('New LP - One condition in AND was false, short-circuit',0);}
 							break;
 	    				}
@@ -1306,7 +1306,7 @@ class learnpathItem {
     					$this->prereq_alert = get_lang('_prereq_not_complete');
     				}
 					return $andstatus;
-	    		} else {	    			
+	    		} else {
 	    			if(isset($items[$refs_list[$list[0]]])){
 	    				$status = $items[$refs_list[$list[0]]]->get_status(true);
 		    			$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
@@ -1450,38 +1450,38 @@ class learnpathItem {
 					    	} else {
 
 					    		//Nothing found there either. Now return the value of the corresponding resource completion status
-				    			if(self::debug>1){error_log('New LP - Didnt find any group, returning value for '.$prereqs_string,0);}				
-				    			
+				    			if(self::debug>1){error_log('New LP - Didnt find any group, returning value for '.$prereqs_string,0);}
+
 				    			if (isset($items[$refs_list[$prereqs_string]])) {
 				    				if ($items[$refs_list[$prereqs_string]]->type == 'quiz') {
-				    					
-				    					//1. Checking the status in current items	
+
+				    					//1. Checking the status in current items
 				    					$status = $items[$refs_list[$prereqs_string]]->get_status(true);
-				    					//error_log('hello '.$status);				    					
+				    					//error_log('hello '.$status);
 				    					$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
-				    					
+
 								    	if(!$returnstatus) {
 								    		if(self::debug>1){error_log('New LP - Prerequisite '.$prereqs_string.' not complete',0);}
 								    	} else {
 								    		if(self::debug>1){error_log('New LP - Prerequisite '.$prereqs_string.' complete',0);}
 								    	}
-								    									    	
-				    					//for one attempt LPs					    			
-				    					if ($this->prevent_reinit == 1) { 
 
-				    						//2. If is completed we check the results in the DB of the quiz							    	
-					    					if ($returnstatus) {		    					
+				    					//for one attempt LPs
+				    					if ($this->prevent_reinit == 1) {
+
+				    						//2. If is completed we check the results in the DB of the quiz
+					    					if ($returnstatus) {
 												//AND origin_lp_item_id = '.$user_id.'
 						    					$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.'
 																AND exe_user_id = '.$user_id.'
-																AND orig_lp_id = '.$this->lp_id.' AND orig_lp_item_id = '.$prereqs_string.' 
+																AND orig_lp_id = '.$this->lp_id.' AND orig_lp_item_id = '.$prereqs_string.'
 																AND status <> "incomplete"
 														ORDER BY exe_date DESC
 														LIMIT 0, 1';
 												//error_log('results :'.$items[$refs_list[$prereqs_string]]->path. ':'.$user_id);
-											
+
 												$rs_quiz = Database::query($sql);
 												if($quiz = Database :: fetch_array($rs_quiz)) {
 													if($quiz['exe_result'] >= $items[$refs_list[$prereqs_string]]->get_mastery_score()) {
@@ -1493,19 +1493,19 @@ class learnpathItem {
 												} else {
 													$this->prereq_alert = get_lang('_prereq_not_complete');
 													$returnstatus = false;
-												}																						
-					    					} 
-					    					
+												}
+					    					}
+
 				    					} else {
 				    						//2. for multiple attempts we check that there are minimun 1 item completed
-				    						
+
 			    							//checking in the database
 			    							$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.'
 															AND exe_user_id = '.$user_id.' AND orig_lp_id = '.$this->lp_id.' AND orig_lp_item_id = '.$prereqs_string.' ';
 											//error_log('results 2:'.$items[$refs_list[$prereqs_string]]->path. ':'.$user_id);
-											
+
 											$rs_quiz = Database::query($sql);
 											if (Database::num_rows($rs_quiz) > 0 ) {
 												while ($quiz = Database :: fetch_array($rs_quiz)) {
@@ -1521,11 +1521,11 @@ class learnpathItem {
 												$this->prereq_alert = get_lang('_prereq_not_complete');
 												$returnstatus = false;
 											}
-			    					
-				    					}		    					
+
+				    					}
 										return $returnstatus;
 				    				} else {
-				    					
+
 				    					$status = $items[$refs_list[$prereqs_string]]->get_status(false);
 				    					$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
 
@@ -1537,23 +1537,23 @@ class learnpathItem {
 								    	//error_log('status of document'.$status);
 								    	//var_dump($returnstatus);
 								    	//$returnstatus = true;
-				    					if ($returnstatus  && $this->prevent_reinit == 1 ) {				    						
+				    					if ($returnstatus  && $this->prevent_reinit == 1 ) {
 					    					// i would prefer check in the database
 					    					$lp_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 					    					$lp_view = Database::get_course_table(TABLE_LP_VIEW);
-					    					
+
 				    						$sql = 'SELECT id FROM '.$lp_view.'
 													WHERE user_id = '.$user_id.'  AND lp_id = '.$this->lp_id.' LIMIT 0, 1';
 											$rs_lp = Database::query($sql);
 					    					$lp_id = Database :: fetch_row($rs_lp);
 					    					$my_lp_id = $lp_id[0];
-					    					
+
 					    					$sql = 'SELECT status FROM '.$lp_item_view.'
 													WHERE lp_view_id = '.$my_lp_id.' AND lp_item_id = '.$refs_list[$prereqs_string].' LIMIT 0, 1';
 											$rs_lp = Database::query($sql);
 					    					$status_array = Database :: fetch_row($rs_lp);
 					    					$status	= $status_array[0];
-					    					 
+
 					    					//var_dump($status);
 						    				$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
 									    	if (!$returnstatus && empty($this->prereq_alert)){
@@ -1565,7 +1565,7 @@ class learnpathItem {
 									    		if(self::debug>1){error_log('New LP - Prerequisite '.$prereqs_string.' complete',0);}
 									    	}
 				    					}
-				    					
+
 										//error_log('results :'.$items[$refs_list[$prereqs_string]]->path. ':'.$user_id);
 										/*$rs_quiz = Database::query($sql);
 										if($quiz = Database :: fetch_array($rs_quiz))
@@ -1585,12 +1585,12 @@ class learnpathItem {
 											$this->prereq_alert = get_lang('_prereq_not_complete');
 											$returnstatus = false;
 										}*/
-										 
+
 				    					/*
 					    				$status = $items[$refs_list[$prereqs_string]]->get_status(true);
 					    				//error_log(print_r($items,1));
 					    				//error_log($refs_list[$prereqs_string]);
-					    				
+
 						    			$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
 								    	if(!$returnstatus && empty($this->prereq_alert)){
 								    		$this->prereq_alert = get_lang('_prereq_not_complete');
@@ -1601,7 +1601,7 @@ class learnpathItem {
 								    		if(self::debug>1){error_log('New LP - Prerequisite '.$prereqs_string.' complete',0);}
 								    	}
 								    	*/
-								    	
+
 								    	//$returnstatus =false;
 						    			return $returnstatus;
 				    				}
@@ -1621,7 +1621,7 @@ class learnpathItem {
 				foreach($list as $condition){
 					if(self::debug>1){error_log('New LP - Found OR, adding it ('.$condition.')',0);}
     				$orstatus = $orstatus || $this->parse_prereq($condition,$items,$refs_list,$user_id);
-    				if($orstatus == true){
+    				if ($orstatus) {
     					//shortcircuit OR
 						if(self::debug>1){error_log('New LP - One condition in OR was true, short-circuit',0);}
     					break;
@@ -1711,7 +1711,7 @@ class learnpathItem {
 			}else{
 			  if(self::debug>1){error_log('New LP - In learnpathItem::save() - SCORM save request received',0);}
 			  //get all new settings from the URL
-				if($from_outside==true){
+				if ($from_outside) {
 				  if(self::debug>1){error_log('New LP - In learnpathItem::save() - Getting item data from outside',0);}
 		     	  foreach($_GET as $param => $value)
 		     	  {
@@ -1778,7 +1778,7 @@ class learnpathItem {
 				}
 			}
 		}else{ //if not SCO, such messages should not be expected
-			$type = strtolower($this->type);		
+			$type = strtolower($this->type);
 			switch($type){
 				case 'asset':
 		 			if($prereqs_complete)
@@ -1877,7 +1877,7 @@ class learnpathItem {
     {
 		if(self::debug>0){error_log('New LP - In learnpathItem::set_lp_view('.$lp_view_id.')',0);}
     	if(!empty($lp_view_id) and $lp_view_id = intval(strval($lp_view_id)))
-     	{	
+     	{
      		$this->view_id = $lp_view_id;
 	     	$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
 	     	//get the lp_item_view with the highest view_count
@@ -2304,7 +2304,7 @@ class learnpathItem {
 	     	//depending on what we want (really), we'll update or insert a new row
 	     	//now save into DB
 	     	$res = 0;
-	     	if( $inserted==false && Database::num_rows($check_res)<1){
+	     	if (!$inserted && Database::num_rows($check_res) < 1) {
                 /*$my_status = '';
 	     		if ($this->type!=TOOL_QUIZ) {
 	     				$my_status = $this->get_status(false);

+ 2 - 2
main/newscorm/lp_add_item.php

@@ -50,7 +50,7 @@ function FCKeditor_OnComplete( editorInstance ) {
 }
 
 function check_for_title() {
-		if (temp==true) {
+		if (temp) {
 			// 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.
 
@@ -119,7 +119,7 @@ function InnerDialogLoaded() {
 $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
 /*
 	Constants and variables
-*/ 
+*/
 
 $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
 

+ 5 - 5
main/newscorm/lp_controller.php

@@ -71,7 +71,7 @@ if($debug>0) error_log('New LP - Included aiccItem',0);
 require_once('back_compat.inc.php');
 if($debug>0) error_log('New LP - Included back_compat',0);
 
-if ($is_allowed_in_course == false){
+if (!$is_allowed_in_course) {
 	api_not_allowed(true);
 }
 
@@ -115,9 +115,9 @@ if(isset($_SESSION['lpobject']))
 	}
 }
 
-if($debug>0) error_log('New LP - Passed data remains check',0);
+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 (!$lp_found || (!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);
 	//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)){
@@ -436,7 +436,7 @@ switch($action)
 		else {
 			$_SESSION['refresh'] = 1;
 
-			if (isset($_POST['submit_button'])) { 
+			if (isset($_POST['submit_button'])) {
 				$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'] , $_POST['description'] );
 				$is_success = true;
 			}
@@ -447,7 +447,7 @@ switch($action)
 				//avoids weird behaviours see CT#967
 				$check = Security::check_token('get');
 				if ($check) {
-					$_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);					
+					$_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
 				}
 				Security::clear_token();
 				require('lp_admin_view.php');

+ 1 - 1
main/newscorm/lp_header.php

@@ -23,7 +23,7 @@ $path_name = $_SESSION['oLP']->get_name();
 $path_id = $_SESSION['oLP']->get_id();
 // use the flag set in lp_view.php to check if this script has been loaded
 // as a frame of lp_view.php. Otherwise, redirect to lp_controller
-if(!isset($_SESSION['loaded_lp_view']) || $_SESSION['loaded_lp_view']==false)
+if (!$_SESSION['loaded_lp_view'])
 {
 	header('location: lp_controller.php?'.api_get_cidreq().'&action=view&item_id='.$path_id);
 }

+ 1 - 1
main/newscorm/lp_upload.php

@@ -55,7 +55,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST'
 			require_once('scorm.class.php');
 			$oScorm = new scorm();
 			$manifest = $oScorm->import_package($_FILES['user_file'],$current_dir);
-			if ($manifest == false ) { //if api_set_failure
+			if (!$manifest) { //if api_set_failure
 				return api_failure::set_failure(api_failure::get_last_failure());
 			}
 			if(!empty($manifest)){

+ 7 - 7
main/newscorm/lp_view.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /* For licensing terms, see /license.txt */
 /**
 * This file was originally the copy of document.php, but many modifications happened since then ;
@@ -35,7 +35,7 @@ require_once 'learnpath.class.php';
 require_once 'learnpathItem.class.php';
 //require_once('lp_comm.common.php'); //xajax functions
 
-if ($is_allowed_in_course == false) api_not_allowed();
+if (!$is_allowed_in_course) api_not_allowed();
 
 // we set the encoding of the lp
 if (!empty($_SESSION['oLP']->encoding)) {
@@ -100,12 +100,12 @@ if (!isset($src)) {
 			$htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
 			$prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
 			if($prereq_check === true){
-				$src = $_SESSION['oLP']->get_link('http',$lp_item_id);			
+				$src = $_SESSION['oLP']->get_link('http',$lp_item_id);
 				//Prevents FF 3.6 + Adobe Reader 9 bug see BT#794 when calling a pdf file in a LP
-				$file_info = pathinfo($src);					
+				$file_info = pathinfo($src);
 				if (api_strtolower(substr($file_info['extension'], 0, 3) == 'pdf')) {
 					$src = 'lp_view_item.php?src='.$src;
-				}				
+				}
 				$_SESSION['oLP']->start_current_item(); //starts time counter manually if asset
 			} else {
 				$src = 'blank.php?error=prerequisites';
@@ -327,7 +327,7 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
 		<div id="toc_id" name="toc_name"  style="overflow: auto; padding:0;margin-top:20px;width:100%">
 			<div id="learning_path_toc" style="font-size:9pt;margin:0;"><?php echo $_SESSION['oLP']->get_html_toc(); ?>
 
-    	<?php if (!empty($_SESSION['oLP']->scorm_debug)) { //only show log    			
+    	<?php if (!empty($_SESSION['oLP']->scorm_debug)) { //only show log
     	?>
 	        <!-- log message layout -->
 			<div id="lp_log_name" name="lp_log_name" class="lp_log" style="height:150px;overflow:auto;margin:4px">
@@ -342,7 +342,7 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
 	</div>
     <!-- end left Zone -->
 
-    <!-- right Zone -->    
+    <!-- right Zone -->
 	<div id="learning_path_right_zone" style="margin-left:282px;height:100%">
 	<?php
 		// hub 26-05-2010 Fullscreen or not fullscreen

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

@@ -1705,7 +1705,7 @@ function rl_get_html_resource_link($course_code, $type, $id, $style='', $new_win
 
 	// styling the link of the added resource
 	if ($style <> '') $styling = ' class="'.$style.'"';
-	if($new_window == true){ $target = ' target = "_blank" ';}else{$target = ' target = "_self" ';}
+	if ($new_window) { $target = ' target = "_blank" '; } else { $target = ' target = "_self" '; }
 
 	$output = '';
 

+ 6 - 7
main/newscorm/scorm_api.php

@@ -854,12 +854,11 @@ function LMSFinish(val) {
     olms.G_LastErrorMessage = 'No error';
     // if olms.commit == false, then the SCORM didn't ask for a commit, so we
     // should at least report that
-    if (( olms.commit == false )) {
+    if ( !olms.commit ) {
         logit_scorm('LMSFinish() (no LMSCommit())',1);
-
     }
 
-    //if ( olms.commit == true ) {
+    //if ( olms.commit ) {
     	logit_scorm('LMSFinish() called',1);
     	savedata('finish');
         olms.commit = false;
@@ -1017,7 +1016,7 @@ function addListeners(){
  */
 function lms_save_asset(){
 	// only for dokeos lps
-	if (olms.execute_stats==true) {
+	if (olms.execute_stats) {
 		olms.execute_stats=false;
 	} else {
 		olms.execute_stats=true;
@@ -1178,7 +1177,7 @@ function update_toc(update_action,update_id,change_ids)
  * Update the stats frame using a reload of the frame to avoid unsynched data
  */
 function update_stats() {
-	if (olms.execute_stats==true) {
+	if (olms.execute_stats) {
 		try {
 		cont_f = document.getElementById('content_id');
 		cont_f.src="lp_controller.php?action=stats";
@@ -1254,7 +1253,7 @@ function process_scorm_values () {
 
     for (i=0;i<olms.scorm_variables.length;i++) {
 
-        if (olms.updatable_vars_list[olms.scorm_variables[i]]==true) {
+        if (olms.updatable_vars_list[olms.scorm_variables[i]]) {
             olms.variable_to_send.push(olms.scorm_variables[i]);
         }
     }
@@ -1269,7 +1268,7 @@ function reinit_updatable_vars_list () {
 
     for (i=0;i<olms.scorm_variables.length;i++) {
 
-        if (olms.updatable_vars_list[olms.scorm_variables[i]]==true) {
+        if (olms.updatable_vars_list[olms.scorm_variables[i]]) {
             olms.updatable_vars_list[olms.scorm_variables[i]]=false;
         }
     }

+ 1 - 1
main/notebook/index.php

@@ -92,7 +92,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
 		if ($check) {
 	   		$values = $form->exportValues();
 	   		$res = NotebookManager::save_note($values);
-	   		if ($res == true){
+	   		if ($res) {
 	   			Display::display_confirmation_message(get_lang('NoteAdded'));
 	   		}
 		}

+ 1 - 1
main/online/online_message.php

@@ -118,7 +118,7 @@ include('header_frame.inc.php');
 <table border="0" cellpadding="5" cellspacing="0" width="100%">
 <tr>
   <td width="90%"><input type="text" name="message" size="50" value="" style="width: 100%;"></td>
-  <td width="9%" nowrap="nowrap"><?php echo get_lang('Question'); ?>&nbsp;<input type="checkbox" name="question" value="1" style="vertical-align: middle;" onclick="javascript:if(this.checked == true && !confirm('<?php echo addslashes(api_htmlentities(get_lang('OnlyCheckForImportantQuestion'),ENT_QUOTES,$charset)); ?>')) this.checked=false; document.formMessage.message.focus();"></td>
+  <td width="9%" nowrap="nowrap"><?php echo get_lang('Question'); ?>&nbsp;<input type="checkbox" name="question" value="1" style="vertical-align: middle;" onclick="javascript: if(this.checked && !confirm('<?php echo addslashes(api_htmlentities(get_lang('OnlyCheckForImportantQuestion'),ENT_QUOTES,$charset)); ?>')) this.checked=false; document.formMessage.message.focus();"></td>
   <td width="1%"><input type="submit" value="OK" style="width: 30px;"></td>
 </tr>
 </table>

+ 2 - 2
main/permissions/permissions_functions.inc.php

@@ -247,7 +247,7 @@ function display_checkbox_matrix($permission_array, $tool, $permission, $inherit
 */
 function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
 {
-	if($course_admin==true)
+	if ($course_admin)
 	{
 		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
 	}
@@ -331,7 +331,7 @@ function display_image_matrix($permission_array, $tool, $permission,$inherited_p
 function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
 {
 
-	if($course_admin==true)
+	if ($course_admin)
 	{
 		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
 	}

+ 1 - 1
main/reservation/m_item.php

@@ -85,7 +85,7 @@ if (isset ($_POST['action'])) {
 			if (count($ids) > 0) {
 				foreach ($ids as $id) {
 					$result = Rsys :: delete_item($id);
-					if ($result != 0 && $warning <> true)
+					if ($result != 0 && $warning <> true) // TODO: A strange looking logical condition, to be cleaned.
 						$warning = true;
 				}
 				ob_start();

+ 1 - 1
main/reservation/m_item_origineel.php

@@ -79,7 +79,7 @@ if (isset ($_POST['action'])) {
 			if (count($ids) > 0) {
 				foreach ($ids as $id) {
 					$result = Rsys :: delete_item($id);
-					if ($result != 0 && $warning <> true)
+					if ($result != 0 && $warning <> true) // TODO: A strange looking logical condition, to be cleaned.
 						$warning = true;
 				}
 				ob_start();

+ 7 - 7
main/social/profile.php

@@ -27,7 +27,7 @@ if (isset($_GET['u'])) {
 	if (api_get_user_id() != $user_id) {
 		$user_info	= UserManager::get_user_info_by_id($user_id);
 		$show_full_profile = false;
-		if ($user_info==false) {
+		if (!$user_info) {
 			// user does no exist !!
 			api_not_allowed();
 		} else {
@@ -517,7 +517,7 @@ echo '<div id="social-content-right">';
 		}
 
 		// COURSES LIST
-		
+
 		if ($show_full_profile) {
 			if ( is_array($list) ) {
 				echo '<div class="social-box-main1">';
@@ -571,7 +571,7 @@ echo '<div id="social-content-right">';
 
 	//--Productions
 	$production_list =  UserManager::build_production_list($user_id);
-	
+
 	// Images uploaded by course
 	$file_list = '';
 	if (is_array($course_list_code) && count($course_list_code)>0) {
@@ -603,11 +603,11 @@ echo '<div id="social-content-right">';
 									echo '<div style="float:left;width:60px;" >';
 										echo '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
 									echo '</div>';
-									
+
 									echo '<div style="padding-left:70px;">';
-											$user_info = api_get_user_info($user_invitation_id);									
+											$user_info = api_get_user_info($user_invitation_id);
 											echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</a>';
-											echo '<br />';											
+											echo '<br />';
 											echo ' '.(substr($pending_invitations[$i]['content'],0,50));
 										echo '<br />';
 										echo '<a id="btn_accepted_'.$user_invitation_id.'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
@@ -631,7 +631,7 @@ echo '<div id="social-content-right">';
 							echo '</div>';
 						}
 						// Images uploaded by course
-						
+
 						if (!empty($file_list)) {
 							echo '<div><h3>'.get_lang('ImagesUploaded').'</h3></div>';
 							echo '<div class="social-content-information">';

+ 1 - 1
main/survey/create_new_survey.php

@@ -208,7 +208,7 @@ if ($survey_data['survey_type'] == 1 || $_GET['action'] == 'add') {
 if ((isset($_GET['action']) && $_GET['action'] == 'edit') && !empty($survey_id)) {
 	if ($survey_data['anonymous'] == 0) {
 
-		$form->addElement('checkbox', 'show_form_profile', get_lang('ShowFormProfile'), '', 'onclick="javascript: if(this.checked==true){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
+		$form->addElement('checkbox', 'show_form_profile', get_lang('ShowFormProfile'), '', 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
 
 		if ($survey_data['show_form_profile'] == 1) {
 			$form -> addElement('html', '<div id="options_field" style="display:block">');

+ 1 - 1
main/upload/index.php

@@ -33,7 +33,7 @@ $htmlHeadXtra[] =
 "<script type=\"text/javascript\">
 <!-- //
 function check_unzip() {
-	if(document.upload.unzip.checked==true){
+	if(document.upload.unzip.checked){
 	document.upload.if_exists[0].disabled=true;
 	document.upload.if_exists[1].checked=true;
 	document.upload.if_exists[2].disabled=true;

+ 1 - 1
main/user/userInfoLib.php

@@ -115,7 +115,7 @@ function remove_cat_def($id, $force = false)
 		return false;
 	}
 	$sqlCondition = " WHERE id = '$id'";
-	if ($force == false)
+	if (!$force)
 	{
 		$sql = "SELECT * FROM $TBL_USERINFO_CONTENT $sqlCondition";
 		$result = Database::query($sql);

+ 1 - 1
main/webservices/registration.soap.php

@@ -3491,7 +3491,7 @@ function WSSubscribeUsersToCourse($params) {
 				$result['result'] = 0;
 			} else {
 				$course_code = CourseManager::get_course_code_from_course_id($course_id);
-				if(CourseManager::add_user_to_course($user_id, $course_code, $status) == false) {
+				if (!CourseManager::add_user_to_course($user_id, $course_code, $status)) {
 					$result['result'] = 0;
 				}
 			}

+ 41 - 41
main/webservices/webservice_course.php

@@ -13,7 +13,7 @@ require_once(dirname(__FILE__).'/webservice.php');
 class WSCourse extends WS {
 	/**
 	 * Deletes a course (helper method)
-	 * 
+	 *
 	 * @param string Course id field name
 	 * @param string Course id value
 	 * @return mixed True if the course was successfully deleted, WSError otherwise
@@ -28,10 +28,10 @@ class WSCourse extends WS {
 			return true;
 		}
 	}
-	
+
 	/**
 	 * Deletes a course
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name
 	 * @param string Course id value
@@ -47,10 +47,10 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Deletes multiple courses
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value')
 	 * @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
@@ -77,10 +77,10 @@ class WSCourse extends WS {
 			return $results;
 		}
 	}
-	
+
 	/**
 	 * Creates a course (helper method)
-	 * 
+	 *
 	 * @param string Title
 	 * @param string Category code
 	 * @param string Wanted code. If it's not defined, it will be generated automatically
@@ -110,7 +110,7 @@ class WSCourse extends WS {
 			$wanted_code = generate_course_code($title);
 		}
 		$result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0);
-		if($result == false) {
+		if (!$result) {
 			return new WSError(202, 'There was an error creating the course');
 		} else {
 			// Update extra fields
@@ -122,10 +122,10 @@ class WSCourse extends WS {
 			return $course_info['id'];
 		}
 	}
-	
+
 	/**
 	 * Creates a course
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Title
 	 * @param string Category code
@@ -153,10 +153,10 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Create multiple courses
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Courses to be created, with elements following the structure presented in CreateCourse
 	 * @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
@@ -186,10 +186,10 @@ class WSCourse extends WS {
 			return $results;
 		}
 	}
-	
+
 	/**
 	 * Edits a course (helper method)
-	 * 
+	 *
 	 * @param string Course id field name
 	 * @param string Course id value
 	 * @param string Title
@@ -253,10 +253,10 @@ class WSCourse extends WS {
 			return true;
 		}
 	}
-	
+
 	/**
 	 * Edits a course
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name
 	 * @param string Course id value
@@ -282,10 +282,10 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * List courses
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
 	 * @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility',
@@ -298,7 +298,7 @@ class WSCourse extends WS {
 		} else {
 			$courses_result = array();
 			$category_names = array();
-			
+
 			$courses = CourseManager::get_courses_list();
 			foreach($courses as $course) {
 				$course_tmp = array();
@@ -307,7 +307,7 @@ class WSCourse extends WS {
 				$course_tmp['title'] = $course['title'];
 				$course_tmp['language'] = $course['course_language'];
 				$course_tmp['visibility'] = $course['visibility'];
-				
+
 				// Determining category name
 				if($category_names[$course['category_code']]) {
 					$course_tmp['category_name'] = $category_names[$course['category_code']];
@@ -316,25 +316,25 @@ class WSCourse extends WS {
 					$category_names[$course['category_code']] = $category['name'];
 					$course_tmp['category_name'] = $category['name'];
 				}
-				
+
 				// Determining number of students registered in course
 				$user_list = CourseManager::get_user_list_from_course_code($course['code'], false);
 				$course_tmp['number_students'] = count($user_list);
-				
+
 				// Determining external course id
 				$course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']);
-				
-				
+
+
 				$courses_result[] = $course_tmp;
 			}
-			
+
 			return $courses_result;
 		}
 	}
-	
+
 	/**
 	 * Subscribe or unsubscribe user to a course (helper method)
-	 * 
+	 *
 	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
 	 * @param string Course id value.
 	 * @param string User id field name. Use "chamilo_user_id" to use internal id
@@ -368,10 +368,10 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Subscribe user to a course
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
 	 * @param string Course id value.
@@ -390,10 +390,10 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Unsusbscribe user from course
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
 	 * @param string Course id value.
@@ -411,10 +411,10 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Returns the descriptions of a course, along with their id
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name
 	 * @param string Course id value
@@ -439,13 +439,13 @@ class WSCourse extends WS {
 				}
 				return $results;
 			}
-		}	
+		}
 	}
-	
-	
+
+
 	/**
 	 * Edit course description
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name
 	 * @param string Course id value
@@ -478,7 +478,7 @@ class WSCourse extends WS {
 						$exists = true;
 					}
 				}
-				if($exists == false) {
+				if (!$exists) {
 					$cd->set_progress(0);
 					$cd->insert($course_info['db_name']);
 				} else {
@@ -487,8 +487,8 @@ class WSCourse extends WS {
 			}
 		}
 	}
-	
-	
-	
+
+
+
 }
 

+ 27 - 27
main/webservices/webservice_session.php

@@ -13,7 +13,7 @@ class WSSession extends WS {
 
 	/**
 	 * Creates a session (helper method)
-	 * 
+	 *
 	 * @param string Name of the session
 	 * @param string Start date, use the 'YYYY-MM-DD' format
 	 * @param string End date, use the 'YYYY-MM-DD' format
@@ -64,10 +64,10 @@ class WSSession extends WS {
 			return $session_id;
 		}
 	}
-	
+
 	/**
 	 * Creates a session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Name of the session
 	 * @param string Start date, use the 'YYYY-MM-DD' format
@@ -96,10 +96,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Deletes a session (helper method)
-	 * 
+	 *
 	 * @param string Session id field name
 	 * @param string Session id value
 	 * @return mixed True in case of success, WSError otherwise
@@ -113,10 +113,10 @@ class WSSession extends WS {
 			return true;
 		}
 	}
-	
+
 	/**
 	 * Deletes a session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Session id field name
 	 * @param string Session id value
@@ -132,10 +132,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Edits a session (helper method)
-	 * 
+	 *
 	 * @param string Name of the session
 	 * @param string Start date, use the 'YYYY-MM-DD' format
 	 * @param string End date, use the 'YYYY-MM-DD' format
@@ -188,10 +188,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Edits a session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Name of the session
 	 * @param string Start date, use the 'YYYY-MM-DD' format
@@ -217,10 +217,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Change user subscription (helper method)
-	 * 
+	 *
 	 * @param string User id field name
 	 * @param string User id value
 	 * @param string Session id field name
@@ -241,18 +241,18 @@ class WSSession extends WS {
 					SessionManager::suscribe_users_to_session($session_id, array($user_id));
 				} else {
 					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
-					if($result == false) {
+					if (!$result) {
 						return new WSError(303, 'There was an error unsubscribing this user from the session');
 					}
 				}
 				return true;
 			}
-		}		
+		}
 	}
-	
+
 	/**
 	 * Subscribe user to a session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User id field name
 	 * @param string User id value
@@ -270,10 +270,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Subscribe user to a session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User id field name
 	 * @param string User id value
@@ -291,10 +291,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Change course subscription
-	 * 
+	 *
 	 * @param string Course id field name
 	 * @param string Course id value
 	 * @param string Session id field name
@@ -317,7 +317,7 @@ class WSSession extends WS {
 					return true;
 				} else {
 					$result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
-					if($result == true) {
+					if ($result) {
 						return true;
 					} else {
 						return new WSError(304, 'Error unsubscribing course from session');
@@ -327,10 +327,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Subscribe course to session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name
 	 * @param string Course id value
@@ -348,10 +348,10 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Unsubscribe course from session
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string Course id field name
 	 * @param string Course id value
@@ -369,5 +369,5 @@ class WSSession extends WS {
 			}
 		}
 	}
-	
+
 }

+ 34 - 34
main/webservices/webservice_user.php

@@ -9,10 +9,10 @@ require_once(dirname(__FILE__).'/webservice.php');
  * Web services available for the User module. This class extends the WS class
  */
 class WSUser extends WS {
-	
+
 	/**
 	 * Enables or disables a user
-	 * 
+	 *
 	 * @param string User id field name
 	 * @param string User id value
 	 * @param int Set to 1 to enable and to 0 to disable
@@ -29,10 +29,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Enables or disables multiple users
-	 * 
+	 *
 	 * @param array Users
 	 * @param int Set to 1 to enable and to 0 to disable
 	 * @return array Array of results
@@ -53,10 +53,10 @@ class WSUser extends WS {
 		}
 		return $results;
 	}
-	
+
 	/**
 	 * Disables a user
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
 	 * @param string User id value
@@ -73,10 +73,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Disables multiple users
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
 	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
@@ -91,10 +91,10 @@ class WSUser extends WS {
 			return $this->changeUsersActiveState($users, 0);
 		}
 	}
-	
+
 	/**
 	 * Enables a user
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
 	 * @param string User id value
@@ -110,10 +110,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Enables multiple users
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
 	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
@@ -128,10 +128,10 @@ class WSUser extends WS {
 			return $this->changeUsersActiveState($users, 1);
 		}
 	}
-	
+
 	/**
 	 * Deletes a user (helper method)
-	 * 
+	 *
 	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
 	 * @param string User id value
 	 * @return mixed True if user was successfully deleted, WSError otherwise
@@ -148,10 +148,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Deletes a user
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
 	 * @param string User id value
@@ -167,10 +167,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Deletes multiple users
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
 	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
@@ -197,16 +197,16 @@ class WSUser extends WS {
 			return $results;
 		}
 	}
-	
+
 	/**
 	 * Creates a user (helper method)
-	 * 
+	 *
 	 * @param string User first name
 	 * @param string User last name
 	 * @param int User status
 	 * @param string Login name
 	 * @param string Password (encrypted or not)
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember 
+	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
 	 * to include the salt in the extra fields if you are encrypting the password
 	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
 	 * @param string User id value. Leave blank if you are using the internal user_id
@@ -228,7 +228,7 @@ class WSUser extends WS {
 			$extras_associative[$extra['field_name']] = $extra['field_value'];
 		}
 		$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
-		if($result == false) {
+		if (!$result) {
 			$failure = $api_failureList[0];
 			if($failure == 'login-pass already taken') {
 				return new WSError(102, 'This username is already taken');
@@ -241,17 +241,17 @@ class WSUser extends WS {
 			return $result;
 		}
 	}
-	
+
 	/**
 	 * Creates a user
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User first name
 	 * @param string User last name
 	 * @param int User status
 	 * @param string Login name
 	 * @param string Password (encrypted or not)
-	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember 
+	 * @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
 	 * to include the salt in the extra fields if you are encrypting the password
 	 * @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
 	 * @param string User id value. Leave blank if you are using the internal user_id
@@ -277,10 +277,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Creates multiple users
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
 	 * @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
@@ -309,10 +309,10 @@ class WSUser extends WS {
 			return $results;
 		}
 	}
-	
+
 	/**
 	 * Edits user info (helper method)
-	 * 
+	 *
 	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
 	 * @param string User id value
 	 * @param string First name
@@ -341,7 +341,7 @@ class WSUser extends WS {
 				$extras = null;
 			}
 			$result = UserManager::update_user($user_id, $firstname, $lastname, $loginname, $password, PLATFORM_AUTH_SOURCE, $email, $status, '', $phone, $user_info['picture_uri'], $expiration_date, $user_info['active'], null, $user_info['hr_dept_id'], $extras, $encrypt_method);
-			if($result == false) {
+			if (!$result) {
 				$failure = $api_failureList[0];
 				if($failure == 'encrypt_method invalid') {
 					return new WSError(103, 'The encryption of the password is invalid');
@@ -353,10 +353,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Edits user info
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
 	 * @param string User id value
@@ -384,10 +384,10 @@ class WSUser extends WS {
 			}
 		}
 	}
-	
+
 	/**
 	 * Edits multiple users
-	 * 
+	 *
 	 * @param string API secret key
 	 * @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
 	 * @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different

+ 1 - 1
main/wiki/diff.inc.php

@@ -95,7 +95,7 @@
 
             }
             // line unchanged
-            elseif ( $show_equals == true )
+            elseif ( $show_equals )
             {
                 $output .= $format_line_function( $i, DIFF_EQUAL, $newArr[$i] );
 

+ 6 - 6
main/wiki/index.php

@@ -630,7 +630,7 @@ if ($_GET['action']=='usercontrib')
 
 			$row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'.api_htmlentities($obj->title).'</a>';
 			$row[] =Security::remove_XSS($obj->version);
-			$row[] =Security::remove_XSS($obj->comment);			
+			$row[] =Security::remove_XSS($obj->comment);
 			//$row[] = api_strlen($obj->comment)>30 ? Security::remove_XSS(api_substr($obj->comment,0,30)).'...' : Security::remove_XSS($obj->comment);
 			$row[] =Security::remove_XSS($obj->progress).' %';
 			$row[] =Security::remove_XSS($obj->score);
@@ -1457,7 +1457,7 @@ if ($_GET['action']=='edit')
 					echo '<div id="options" style="display:none; margin: 20px;" >';
 
 					//task
-					echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktask" onclick="if(this.checked==true){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/>&nbsp;<img src="../img/wiki/task.gif" title="'.get_lang('DefineTask').'" alt="'.get_lang('DefineTask').'"/>'.get_lang('DescriptionOfTheTask').'';
+					echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktask" onclick="javascript: if(this.checked){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/>&nbsp;<img src="../img/wiki/task.gif" title="'.get_lang('DefineTask').'" alt="'.get_lang('DefineTask').'"/>'.get_lang('DescriptionOfTheTask').'';
 					echo '&nbsp;&nbsp;&nbsp;<span id="msg_error4" style="display:none;color:red"></span>';
 					echo '<div id="option4" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 
@@ -1472,7 +1472,7 @@ if ($_GET['action']=='edit')
 					echo '</div>';
 
 					//feedback
-					echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkfeedback" onclick="if(this.checked==true){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;'.get_lang('AddFeedback').'';
+					echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkfeedback" onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;'.get_lang('AddFeedback').'';
 					echo '&nbsp;&nbsp;&nbsp;<span id="msg_error2" style="display:none;color:red"></span>';
 					echo '<div id="option2" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 
@@ -1535,7 +1535,7 @@ if ($_GET['action']=='edit')
 					echo '</div>';
 
 					//time limit
-					echo  '<div>&nbsp;</div><input type="checkbox" value="1" name="checktimelimit" onclick="if(this.checked==true){document.getElementById(\'option1\').style.display=\'block\'; $pepe=\'a\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;'.get_lang('PutATimeLimit').'';
+					echo  '<div>&nbsp;</div><input type="checkbox" value="1" name="checktimelimit" onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display=\'block\'; $pepe=\'a\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;'.get_lang('PutATimeLimit').'';
 					echo  '&nbsp;&nbsp;&nbsp;<span id="msg_error1" style="display:none;color:red"></span>';
 					echo  '<div id="option1" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 					echo '<table width="100%" border="0" style="font-weight:normal">';
@@ -1578,7 +1578,7 @@ if ($_GET['action']=='edit')
 					echo '</div>';
 
 					//other limit
-					echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkotherlimit" onclick="if(this.checked==true){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;'.get_lang('OtherSettings').'';
+					echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkotherlimit" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;'.get_lang('OtherSettings').'';
 					echo '&nbsp;&nbsp;&nbsp;<span id="msg_error3" style="display:none;color:red"></span>';
 					echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 					echo '<div style="font-weight:normal"; align="center">'.get_lang('NMaxWords').':&nbsp;<input type="text" name="max_text" size="3" value="'.$row['max_text'].'">&nbsp;&nbsp;'.get_lang('NMaxVersion').':&nbsp;<input type="text" name="max_version" size="3" value="'.$row['max_version'].'"></div>';
@@ -1872,7 +1872,7 @@ if ($_GET['action']=='recentchanges') {
 
 		//$sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND visibility=1 AND '.$tbl_wiki.'.'.$groupfilter.' ORDER BY dtime DESC'; // new version
 	}
-	
+
 	$allpages=Database::query($sql);
 
 	//show table

+ 4 - 4
main/wiki/wiki.inc.php

@@ -577,7 +577,7 @@ return true;
 		echo '<div id="options" style="display:none; margin: 20px;" >';
 
 		//task
-		echo '<input type="checkbox" value="1" name="checktask" onclick="if(this.checked==true){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/>&nbsp;<img src="../img/wiki/task.gif" title="'.get_lang('DefineTask').'" alt="'.get_lang('DefineTask').'"/>'.get_lang('DescriptionOfTheTask').'';
+		echo '<input type="checkbox" value="1" name="checktask" onclick="javascript: if(this.checked){document.getElementById(\'option4\').style.display=\'block\';}else{document.getElementById(\'option4\').style.display=\'none\';}"/>&nbsp;<img src="../img/wiki/task.gif" title="'.get_lang('DefineTask').'" alt="'.get_lang('DefineTask').'"/>'.get_lang('DescriptionOfTheTask').'';
 		echo '&nbsp;&nbsp;&nbsp;<span id="msg_error4" style="display:none;color:red"></span>';
 		echo '<div id="option4" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 
@@ -593,7 +593,7 @@ return true;
 		echo '</div>';
 
 		//feedback
-		echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkfeedback" onclick="if(this.checked==true){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;'.get_lang('AddFeedback').'';
+		echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkfeedback" onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;'.get_lang('AddFeedback').'';
 		echo '&nbsp;&nbsp;&nbsp;<span id="msg_error2" style="display:none;color:red"></span>';
 		echo '<div id="option2" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 
@@ -656,7 +656,7 @@ return true;
 		echo '</div>';
 
 		//time limit
-		echo  '<div>&nbsp;</div><input type="checkbox" value="1" name="checktimelimit" onclick="if(this.checked==true){document.getElementById(\'option1\').style.display=\'block\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;'.get_lang('PutATimeLimit').'';
+		echo  '<div>&nbsp;</div><input type="checkbox" value="1" name="checktimelimit" onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display=\'block\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;'.get_lang('PutATimeLimit').'';
 		echo  '&nbsp;&nbsp;&nbsp;<span id="msg_error1" style="display:none;color:red"></span>';
 		echo  '<div id="option1" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 		echo '<table width="100%" border="0" style="font-weight:normal">';
@@ -680,7 +680,7 @@ return true;
 		echo '</div>';
 
 		//other limit
-		echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkotherlimit" onclick="if(this.checked==true){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;'.get_lang('OtherSettings').'';
+		echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checkotherlimit" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;'.get_lang('OtherSettings').'';
 		echo '&nbsp;&nbsp;&nbsp;<span id="msg_error3" style="display:none;color:red"></span>';
 		echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
 		echo '<div style="font-weight:normal"; align="center">'.get_lang('NMaxWords').':&nbsp;<input type="text" name="max_text" size="3">&nbsp;&nbsp;'.get_lang('NMaxVersion').':&nbsp;<input type="text" name="max_version" size="3"></div>';

+ 31 - 31
main/work/work.lib.php

@@ -245,22 +245,22 @@ function two_digits($number) {
 /**
 * converts 2008-10-06 12:45:00 to -> array($data'year'=>2008,$data'month'=>10 etc...)
 */
-function convert_date_to_array($date, $group) { 
+function convert_date_to_array($date, $group) {
 	$parts = split(' ', $date);
 	$date_parts = split('-', $parts[0]);
-	$date_parts_tmp = array(); 
+	$date_parts_tmp = array();
 	foreach ($date_parts as $item) {
 		$date_parts_tmp[] = intval($item);
 	}
-	
+
 	$time_parts = split(':', $parts[1]);
-	$time_parts_tmp = array(); 
+	$time_parts_tmp = array();
 	foreach ($time_parts as $item) {
 		$time_parts_tmp[] = intval($item);
 	}
-	
-	
-	
+
+
+
 	list($data[$group.'[year]'], $data[$group.'[month]'], $data[$group.'[day]']) = $date_parts_tmp;
 	list($data[$group.'[hour]'], $data[$group.'[minute]']) = $time_parts_tmp;
 	return $data;
@@ -369,7 +369,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 
 	}
 //	echo $sql_get_publications_list;
-	
+
 	$sql_result = Database::query($sql_get_publications_list);
 	$sql_result_num = Database::query($sql_get_publications_num);
 
@@ -461,7 +461,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 
 					$group_name[] = FormValidator :: createElement('text', 'dir_name');
 					$form_folder -> addGroup($group_name, 'my_group', get_lang('Title'));
-					
+
 					$form_folder -> addGroupRule('my_group', get_lang('ThisFieldIsRequired'), 'required');
 					$defaults = array('my_group[dir_name]' => html_entity_decode($dir), 'description' => api_html_entity_decode($row['description']));
 
@@ -477,7 +477,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 					}
 
 					$there_is_a_end_date = false;
-					
+
 					if ($row['view_properties'] == '1') {
 						if ($homework['expires_on'] != '0000-00-00 00:00:00') {
 							$there_is_a_expire_date = true;
@@ -509,17 +509,17 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 						list($d_year, $d_month, $d_day) = split('-', $parts[0]);
 						list($d_hour, $d_minute) = split(':', $parts[1]);
 						if ((int)$row['weight'] == 0) {
-							$form_folder -> addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked==true){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
+							$form_folder -> addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
 							$form_folder -> addElement('html', '<div id=\'option3\' style="display:none">');
 							$weight_input2[] = FormValidator :: createElement('text', 'weight');
 							$form_folder -> addGroup($weight_input2, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
 							$form_folder -> addElement('html', '</div>');
 						}
-						
+
 						if ($homework['expires_on'] == '0000-00-00 00:00:00') {
 							$homework['expires_on'] = date('Y-m-d H:i:s');
 							$there_is_a_expire_date = true;
-							$form_folder -> addElement('checkbox', 'enableExpiryDate',null,get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked==true){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"');
+							$form_folder -> addElement('checkbox', 'enableExpiryDate',null,get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"');
 							$form_folder -> addElement('html', '<div id=\'option1\' style="display:none">');
 							$form_folder -> addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt'));
 							$form_folder -> addElement('html', '</div>');
@@ -527,7 +527,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 						if ($homework['ends_on'] == '0000-00-00 00:00:00') {
 							$homework['ends_on'] = date('Y-m-d H:i:s');
 							$there_is_a_end_date = true;
-							$form_folder -> addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked==true){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"');
+							$form_folder -> addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"');
 							$form_folder -> addElement('html', '<div id=\'option2\' style="display:none">');
 							$form_folder -> addGroup(create_group_date_select(), 'ends', get_lang('EndsAt'));
 							$form_folder -> addElement('html', '</div>');
@@ -540,13 +540,13 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 
 					$form_folder -> addElement('style_submit_button', 'submit', get_lang('ModifyDirectory'), 'class="save"');
 					if ($there_is_a_end_date) {
-						$end_date_array = convert_date_to_array($homework['ends_on'], 'ends');										
+						$end_date_array = convert_date_to_array($homework['ends_on'], 'ends');
 						$defaults = array_merge($defaults, $end_date_array);
 					}
-					if ($there_is_a_expire_date) {					
+					if ($there_is_a_expire_date) {
 						$expires_date_array = convert_date_to_array($homework['expires_on'], 'expires');
 						$defaults = array_merge($defaults, $expires_date_array);
-						
+
 					}
 					if (!empty($row['qualification'])) {
 						$defaults = array_merge($defaults, array('qualification[qualification]' => $row['qualification']));
@@ -562,8 +562,8 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 						$values = $values['my_group'];
 						$dir_name = replace_dangerous_char($values['dir_name']);
 						$dir_name = disable_dangerous_file($dir_name);
-						if (is_work_exist_by_url('/'.$dir_name) == false) {
-						
+						if (!is_work_exist_by_url('/'.$dir_name)) {
+
 							$TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
 							if ($there_is_a_end_date || $there_is_a_expire_date) {
 								if ($row['view_properties'] == '1') {
@@ -592,23 +592,23 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 							//if($_POST['qualification']['qualification']!='')
 							Database::query('UPDATE '.$work_table.' SET description = '."'".Database::escape_string($_POST['description'])."'".', qualification = '."'".Database::escape_string($_POST['qualification']['qualification'])."'".',weight = '."'".Database::escape_string($_POST['weight']['weight'])."'".' WHERE id = '."'".$row['id']."'");
 							Database::query('UPDATE '.Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK).' SET weight = '."'".Database::escape_string($_POST['weight']['weight'])."'".' WHERE course_code = '."'".api_get_course_id()."'".' AND ref_id = '."'".$row['id']."'".'');
-	
+
 						    //we are changing the current work and we want add them into gradebook
 							if (isset($_POST['make_calification']) && $_POST['make_calification'] == 1) {
 								require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
 								require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
 								require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php';
 								require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
-	
+
 								$resource_name = $_POST['dir_name'];
 								add_resource_to_course_gradebook(api_get_course_id(), 3, $row['id'], Database::escape_string($resource_name), (float)$_POST['weight']['weight'], (float)$_POST['qualification']['qualification'], Database::escape_string($_POST['description']), time(), 1, api_get_session_id());
 							}
-						
+
 							update_dir_name($mydir, $dir_name);
 							$mydir = $my_sub_dir.$dir_name;
 							$dir = $dir_name;
 							$display_edit_form = false;
-	
+
 							// gets calendar_id from student_publication_assigment
 							$sql = "SELECT add_to_calendar FROM $work_assigment WHERE publication_id ='".$row['id']."'";
 							$res = Database::query($sql);
@@ -621,9 +621,9 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
 											end_date='".get_date_from_group('ends')."'
 										WHERE id='".$calendar_id[0]."'";
 								Database::query($sql);
-							}							
+							}
 							Display::display_confirmation_message(get_lang('FolderEdited'));
-						
+
 						} else {
 							Display::display_warning_message(get_lang('FileExists'));
 						}
@@ -1372,18 +1372,18 @@ function to_javascript_work() {
 					msg_id1.innerHTML="'.get_lang('FieldRequired', '').'";
 					msg_id2.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";msg_id5.innerHTML="";
 				}
-				else if(document.form1.type1.checked==true && document.form1.type2.checked==true && expires_date > ends_date) {
+				else if(document.form1.type1.checked && document.form1.type2.checked && expires_date > ends_date) {
 						msg_id2.style.display ="block";
 						msg_id2.innerHTML="'.get_lang('EndDateCannotBeBeforeTheExpireDate', '').'";
 						msg_id1.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";msg_id5.innerHTML="";
 				}
-				else if (checkDate(expires_month,expires_day,expires_year) == false)
+				else if (!checkDate(expires_month,expires_day,expires_year))
 				{
 					msg_id3.style.display ="block";
 					msg_id3.innerHTML="'.get_lang('InvalidDate', '').'";
 					msg_id1.innerHTML="";msg_id2.innerHTML="";msg_id4.innerHTML="";msg_id5.innerHTML="";
 				}
-				else if (checkDate(ends_month,ends_day,ends_year) == false)
+				else if (!checkDate(ends_month,ends_day,ends_year))
 				{
 
 					msg_id4.style.display ="block";
@@ -1393,7 +1393,7 @@ function to_javascript_work() {
 				else
 				{
 
-					if (document.form1.make_calification.checked == true)
+					if (document.form1.make_calification.checked)
 				 	{
 					 	var weight = document.form1.weight.value;
 						 	if(weight==""){
@@ -1546,9 +1546,9 @@ function send_reminder_users_without_publication($task_id) {
 
 /**
  * Sends an email to the students of a course when a homework is created
- * 
+ *
  * @param string course_id
- * 
+ *
  * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
  */
 function send_email_on_homework_creation($course_id) {

+ 19 - 19
main/work/work.php

@@ -478,7 +478,7 @@ if (!empty($make_visible)) {
 	}
 	if (isset($make_visible) && $make_visible == 'all') {
 		$sql = "ALTER TABLE  " . $work_table . " CHANGE accepted accepted TINYINT(1) DEFAULT '1'";
-		Database::query($sql);		
+		Database::query($sql);
 		$sql = "UPDATE  " . $work_table . " SET accepted = 1";
 		Database::query($sql);
 		Display::display_confirmation_message(get_lang('AllFilesVisible'));
@@ -538,7 +538,7 @@ if (!empty($_REQUEST['new_dir'])) {
 				require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
 				$course = isset($course_info) ? $course_info : null;
 				$content = '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.substr(Security::remove_XSS($dir_name_sql), 1).'" >'.$_POST['new_dir'].'</a> - '.$_POST['description'];
-				
+
 				$agenda_id = agenda_add_item($course, $_POST['new_dir'], $content, date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), array('GROUP:'.$toolgroup), 0);
 			}
 			$sql_add_publication = "INSERT INTO " . $work_table . " SET " .
@@ -560,7 +560,7 @@ if (!empty($_REQUEST['new_dir'])) {
 									   user_id = '".$user_id."'";
 
 			Database::query($sql_add_publication);
-			
+
 			// add the directory
 			$id = Database::insert_id();
 			//Folder created
@@ -616,7 +616,7 @@ if (!empty($_REQUEST['new_dir'])) {
 			}
 
 			// end features
-			
+
 			if(api_get_course_setting('email_alert_students_on_new_homework') == 1) {
 				send_email_on_homework_creation(api_get_course_id());
 			}
@@ -678,8 +678,8 @@ if (!empty($_REQUEST['delete2'])) {
 if (!empty ($_REQUEST['move'])) {
 	$folders = array();
 	$session_id = api_get_session_id();
-	$session_id == 0 ? $withsession = " AND session_id = 0 " : $withsession = " AND session_id='".$session_id."'";	
-	
+	$session_id == 0 ? $withsession = " AND session_id = 0 " : $withsession = " AND session_id='".$session_id."'";
+
 	$sql = "SELECT id, url FROM $work_table  WHERE url LIKE '/%' AND post_group_id = '".(empty($_SESSION['toolgroup'])?0:intval($_SESSION['toolgroup']))."'".$withsession;
 	$res = Database::query($sql);
 	while($folder = Database::fetch_array($res)) {
@@ -694,7 +694,7 @@ if (isset ($_POST['move_to']) && isset ($_POST['move_file'])) {
 	require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
 	$move_to = $_POST['move_to'];
 	$move_to_path = get_work_path($move_to);
-		
+
 	if ($move_to_path==-1) {
 		$move_to_path = '/';
 	} elseif (substr($move_to_path, -1, 1) != '/') {
@@ -706,7 +706,7 @@ if (isset ($_POST['move_to']) && isset ($_POST['move_file'])) {
 		//Display::display_normal_message('We want to move '.$_POST['move_file'].' to '.$_POST['move_to']);
 		if (move($course_dir . '/' . $path, $base_work_dir . $move_to_path)) {
 			//update db
-			
+
 			update_work_url($move_file_id, 'work' . $move_to_path, $move_to);
 			//set the current path
 			$cur_dir_path = $move_to_path;
@@ -885,7 +885,7 @@ if ($ctok == $_POST['sec_token']) { //check the token inserted into the form
 				$parent_id = '';
 				$active = '';
 				$user_id = api_get_user_id();
-				
+
 				$sql = Database::query('SELECT id FROM '.Database::get_course_table(TABLE_STUDENT_PUBLICATION).' WHERE url = '."'/".Database::escape_string($_GET['curdirpath'])."' AND filetype='folder' LIMIT 1");
 				if (Database::num_rows($sql) > 0) {
 					$dir_row = Database::fetch_array($sql);
@@ -1132,8 +1132,8 @@ if ($is_special > 0) {
 		if ($homework['ends_on'] != '0000-00-00 00:00:00' && $difference2 < 0) {
 			$has_ended = true;
 		}
-		if ($homework['expires_on'] == '0000-00-00 00:00:00') { 
-			$has_expiry_date = false; 
+		if ($homework['expires_on'] == '0000-00-00 00:00:00') {
+			$has_expiry_date = false;
 		}
 		if (!$has_expiry_date) {
 			//@todo fix me
@@ -1312,15 +1312,15 @@ if ($is_course_member) {
 									'.get_lang('Description').'
 								</div>
 								<div class="formw">';
-									
+
 				$oFCKeditor = new FCKeditor('description') ;
 				$oFCKeditor->ToolbarSet = 'profile';
 				$oFCKeditor->Width		= '80%';
 				$oFCKeditor->Height		= '130';
-				$oFCKeditor->Value		= $message;				
-				$return =	$oFCKeditor->CreateHtml();	
+				$oFCKeditor->Value		= $message;
+				$return =	$oFCKeditor->CreateHtml();
 				$new_folder_text .= $return;
-									
+
 		$new_folder_text .= '</div>
 							</div>';
 
@@ -1331,7 +1331,7 @@ if ($is_course_member) {
 		$addtext .= '<table cellspacing="0" cellpading="0" border="0"><tr>';
 		$addtext .= '<td colspan="2">&nbsp;&nbsp;'.get_lang('QualificationNumeric').'&nbsp;';
 		$addtext .= '<input type="text" name="qualification_value" value="" size="5"/></td><tr><td colspan="2">';
-		$addtext .= '<input type="checkbox" value="1" name="make_calification" onclick="if(this.checked==true){document.getElementById(\'option1\').style.display=\'block\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>'.get_lang('MakeQualifiable').'</td></tr><tr>';
+		$addtext .= '<input type="checkbox" value="1" name="make_calification" onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display=\'block\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>'.get_lang('MakeQualifiable').'</td></tr><tr>';
 		$addtext .= '<td colspan="2"><div id="option1" style="display:none">';
 		$addtext .= '<div id="msg_error_weight" style="display:none;color:red"></div>';
 		$addtext .=	'&nbsp;&nbsp;'.get_lang('WeightInTheGradebook').'&nbsp;';
@@ -1339,12 +1339,12 @@ if ($is_course_member) {
 		$addtext .= '</tr></table>';
 		$addtext .= '<br />';
 		$addtext .= '<b>'.get_lang('DatesAvailables').'</b><br />';
-		$addtext .= '<input type="checkbox" value="1" name="type1" onclick="if(this.checked==true){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>'.get_lang('EnableExpiryDate').'';
+		$addtext .= '<input type="checkbox" value="1" name="type1" onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>'.get_lang('EnableExpiryDate').'';
 		$addtext .= '&nbsp;&nbsp;&nbsp;<span id="msg_error2" style="display:none;color:red"></span>';
 		$addtext .= '&nbsp;&nbsp;&nbsp;<span id="msg_error3" style="display:none;color:red"></span>';
 		$addtext .= '<div id="option2" style="padding:4px;display:none">&nbsp;&nbsp;';
 		$addtext .= draw_date_picker('expires').'</div>';
-		$addtext .= '<br /><input type="checkbox" value="1" name="type2" onclick="if(this.checked==true){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>'.get_lang('EnableEndDate').'';
+		$addtext .= '<br /><input type="checkbox" value="1" name="type2" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>'.get_lang('EnableEndDate').'';
 		$addtext .= '<div id="option3" style="padding:4px;display:none">';
 		$addtext .= '&nbsp;&nbsp;&nbsp;<div id="msg_error4" style="display:none;color:red"></div>';
 		$addtext .= draw_date_picker('ends').'<br />';
@@ -1397,7 +1397,7 @@ if ($cur_dir_path == '/') {
 	$my_cur_dir_path = $cur_dir_path;
 }
 
-//If no upload form is showed and if NO tooloptions 
+//If no upload form is showed and if NO tooloptions
 
 if (!$display_upload_form && !$display_tool_options) {
 	$add_query = '';

+ 1 - 1
tests/simpletest/unit_tester.php

@@ -400,7 +400,7 @@ class UnitTestCase extends SimpleTestCase {
      *    @access private
      */
     function _coerceExpectation($expected) {
-        if ($expected == false) {
+        if (!$expected) {
             return new TrueExpectation();
         }
         if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) {

+ 7 - 7
user.php

@@ -3,13 +3,13 @@
 
 /**
  *  Clean URls for the Social Network
- * 
+ *
  *  The idea is to access to the user info more easily:
  *  http://campus.chamilo.org/admin instead of http://campus.chamilo.org/main/social/profile.php?1
  *  To use this you should rename the htaccess to .htaccess and check your virtualhost configuration
- * 
+ *
  *  More improvements will come in the next version of Chamilo maybe in the 1.8.8
- *   
+ *
  */
 
 
@@ -26,12 +26,12 @@ api_block_anonymous_users();
 $array_keys = array_keys($_GET);
 
 if (!empty($array_keys)) {
-	$username 	= substr($array_keys[0],0,20); // max len of an username	
+	$username 	= substr($array_keys[0],0,20); // max len of an username
 	$friend_id 	= UserManager::get_user_id_from_username($username);
-			
-	if ($friend_id != false) {
+
+	if ($friend_id) {
 		SocialManager::display_individual_user($friend_id);
-		/*	
+		/*
 		if (api_get_setting('allow_social_tool') =='true') {
 			header('Location: main/social/profile.php?u='.$friend_id.'');
 			exit;

+ 1 - 1
user_portal.php

@@ -1643,7 +1643,7 @@ echo '<div id="social_widget">';
 
 echo '  <div id="social_widget_image">';
 if (api_get_setting('allow_social_tool') == 'true') {
-	if ($no_image == false) {
+	if (!$no_image) {
 	    echo '<a href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'"  '.$img_array['style'].' border="1"></a>';
 	} else {
 	    echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].' border="1"></a>';