Yannick Warnier 13 years ago
parent
commit
f82807b31d
66 changed files with 1920 additions and 1582 deletions
  1. 2 2
      custompages/style-ie6.css
  2. 2 2
      custompages/style.css
  3. 8 8
      main/admin/add_courses_to_usergroup.php
  4. 0 1
      main/admin/add_sessions_to_usergroup.php
  5. 97 63
      main/admin/add_users_to_session.php
  6. 60 16
      main/admin/add_users_to_usergroup.php
  7. 9 12
      main/admin/resume_session.php
  8. 1 1
      main/admin/session_course_edit.php
  9. 21 16
      main/admin/session_course_list.php
  10. 115 79
      main/admin/session_course_user_list.php
  11. 1 1
      main/attendance/attendance_calendar.php
  12. 4 6
      main/attendance/attendance_controller.php
  13. 21 10
      main/calendar/agenda.inc.php
  14. 7 2
      main/calendar/agenda.lib.php
  15. 13 5
      main/course_description/listing.php
  16. 0 3
      main/course_progress/index.php
  17. 1 1
      main/coursecopy/classes/Attendance.class.php
  18. 26 4
      main/coursecopy/classes/CourseBuilder.class.php
  19. 6 18
      main/coursecopy/classes/CourseRestorer.class.php
  20. 1 2
      main/coursecopy/classes/Survey.class.php
  21. 1 2
      main/coursecopy/classes/SurveyQuestion.class.php
  22. 1 1
      main/coursecopy/classes/Thematic.class.php
  23. 20 21
      main/coursecopy/copy_course_session.php
  24. 3 3
      main/document/save_pixlr.php
  25. 12 8
      main/exercice/exercice.php
  26. 39 36
      main/exercice/exercise.class.php
  27. 19 8
      main/exercice/exercise.lib.php
  28. 13 6
      main/exercice/exercise_submit.php
  29. 6 7
      main/exercice/overview.php
  30. 43 43
      main/forum/forumfunction.inc.php
  31. 2 2
      main/forum/iframe_thread.php
  32. 3 3
      main/forum/index.php
  33. 9 9
      main/forum/viewforum.php
  34. 5 4
      main/forum/viewforumcategory.php
  35. 3 3
      main/forum/viewthread_flat.inc.php
  36. 2 2
      main/forum/viewthread_nested.inc.php
  37. 2 2
      main/forum/viewthread_threaded.inc.php
  38. 2 2
      main/gradebook/lib/gradebook_data_generator.class.php
  39. 7 8
      main/inc/ajax/course_home.ajax.php
  40. 1 1
      main/inc/footer.inc.php
  41. 5 23
      main/inc/lib/attendance.lib.php
  42. 25 19
      main/inc/lib/blog.lib.php
  43. 2 2
      main/inc/lib/chat.lib.php
  44. 1 1
      main/inc/lib/course.lib.php
  45. 3 3
      main/inc/lib/database.lib.php
  46. 3 3
      main/inc/lib/database.mysqli.lib.php
  47. 9 10
      main/inc/lib/glossary.lib.php
  48. BIN
      main/inc/lib/javascript/chosen/chosen-sprite.png
  49. 85 62
      main/inc/lib/javascript/chosen/chosen.css
  50. 217 170
      main/inc/lib/javascript/chosen/chosen.jquery.js
  51. 1 1
      main/inc/lib/javascript/chosen/chosen.jquery.min.js
  52. 1 1
      main/inc/lib/link.lib.php
  53. 2 3
      main/inc/lib/loginredirection.lib.php
  54. 14 10
      main/inc/lib/main_api.lib.php
  55. 603 603
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  56. 39 3
      main/inc/lib/sessionmanager.lib.php
  57. 5 7
      main/inc/lib/thematic.lib.php
  58. 50 59
      main/inc/lib/tracking.lib.php
  59. 7 2
      main/inc/lib/usergroup.lib.php
  60. 6 2
      main/inc/lib/usermanager.lib.php
  61. 1 1
      main/inc/lib/userportal.lib.php
  62. 9 8
      main/lang/english/trad4all.inc.php
  63. 15 3
      main/newscorm/learnpathList.class.php
  64. 124 57
      main/session/index.php
  65. 39 44
      main/work/work.lib.php
  66. 66 62
      main/work/work.php

+ 2 - 2
custompages/style-ie6.css

@@ -17,8 +17,8 @@ body {
 
 #backgroundimage {
 	background-attachment:fixed;
-	width: 100%
-	height: 100%
+	width: 100%;
+	height: 100%;
 	position: absolute;
 	left: 0;
 	top: 30px;

+ 2 - 2
custompages/style.css

@@ -16,8 +16,8 @@ body {
 
 #backgroundimage {
 	background-attachment:fixed;
-	width: 100%
-	height: 100%
+	width: 100%;
+	height: 100%;
 	position: absolute;
 	left: 0;
 	top: 30px;

+ 8 - 8
main/admin/add_courses_to_usergroup.php

@@ -5,10 +5,10 @@
 */
 
 // name of the language file that needs to be included
-$language_file=array('admin','registration');
+$language_file = array('admin','registration');
 
 // resetting the course id
-$cidReset=true;
+$cidReset = true;
 
 // including some necessary files
 require_once '../inc/global.inc.php';
@@ -96,7 +96,7 @@ if($_POST['form_sent']) {
 }
 $data               = $usergroup->get($id);
 $course_list_in     = $usergroup->get_courses_by_usergroup($id);
-$course_list        = CourseManager::get_courses_list();
+$course_list        = CourseManager::get_courses_list(0,0,'title');
 
 //api_display_tool_title($tool_name.' ('.$session_info['name'].')');
 $elements_not_in = $elements_in= array();
@@ -104,9 +104,9 @@ $elements_not_in = $elements_in= array();
 if (!empty($course_list)) {
     foreach($course_list as $item) {        
         if (in_array($item['id'], $course_list_in)) {            
-            $elements_in[$item['id']] = $item['title'];             
+            $elements_in[$item['id']] = $item['title']." (".$item['code'].")";
         } else {
-            $elements_not_in[$item['id']] = $item['title'];
+            $elements_not_in[$item['id']] = $item['title']." (".$item['code'].")";
         }
     }
 }
@@ -134,7 +134,7 @@ function search($needle,$type) {
                 $order_clause.
                 ' LIMIT 11';*/
         } else {
-            $list = CourseManager::get_courses_list(0, 0, 1, 'ASC', -1, $needle);
+            $list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle);
         }     
         $i=0;        
         if ($type=='single') {
@@ -154,7 +154,7 @@ function search($needle,$type) {
             
             foreach ($list as $row ) {         
                 if (!in_array($row['id'], array_keys($elements_in))) {       
-                    $return .= '<option value="'.$row['id'].'">'.$row['title'].'</option>';
+                    $return .= '<option value="'.$row['id'].'">'.$row['title'].' ('.$row['code'].')</option>';
                 }
             }
             $return .= '</select>';
@@ -229,7 +229,7 @@ if(!empty($errorMsg)) {
 <?php if ($add_type=='multiple') { ?>
 <tr>
 <td align="center">
-<?php echo get_lang('FirstLetterSessions'); ?> :
+<?php echo get_lang('FirstLetterCourseTitle'); ?> :
      <select name="firstLetterUser" onchange = "xajax_search(this.value,'multiple')" >
       <option value = "%">--</option>
       <?php

+ 0 - 1
main/admin/add_sessions_to_usergroup.php

@@ -14,7 +14,6 @@ $cidReset=true;
 require_once '../inc/global.inc.php';
 require_once '../inc/lib/xajax/xajax.inc.php';
 require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
-require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
 
 $xajax = new xajax();
 

+ 97 - 63
main/admin/add_users_to_session.php

@@ -76,8 +76,14 @@ function search_users($needle, $type) {
 	global $tbl_user,$tbl_session_rel_user,$id_session;
 	$xajax_response = new XajaxResponse();
 	$return = '';
-
+    
 	if (!empty($needle) && !empty($type)) {
+        
+        //normal behaviour
+        if ($type == 'any_session' && $needle == 'false')  {
+            $type = 'multiple';
+            $needle = '';            
+        }
 
 		// xajax send utf8 datas... datas in db can be non-utf8 datas
 		$charset = api_get_system_encoding();
@@ -87,6 +93,9 @@ function search_users($needle, $type) {
 
 		$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
 		$cond_user_id = '';
+        
+        //Only for single & multiple
+        if (in_array($type, array('single','multiple')))
 		if (!empty($id_session)) {
 		    $id_session = intval($id_session);
 			// check id_user from session_rel_user table
@@ -98,46 +107,65 @@ function search_users($needle, $type) {
 					$user_ids[] = (int)$row[0];
 				}
 			}
-			if (count($user_ids) > 0){
+			if (count($user_ids) > 0) {
 				$cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
 			}
 		}
 
-		if ($type == 'single') {
-			// search users where username or firstname or lastname begins likes $needle
-			$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
-					WHERE (username LIKE "'.$needle.'%"
-					OR firstname LIKE "'.$needle.'%"
-				OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'"   AND user.status<>'.DRH.''.
-				$order_clause.
-				' LIMIT 11';
-		} else {
-			$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
-					WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
-					$order_clause;
-		}
-
+		switch($type) {
+            case 'single':
+                // search users where username or firstname or lastname begins likes $needle
+                $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                        WHERE (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%"
+                            OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.''.
+                            $order_clause.
+                            ' LIMIT 11';
+                break;
+            case 'multiple':
+                $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                        WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
+                        $order_clause;
+                break;
+            case 'any_session':
+                $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id)
+                        WHERE   s.id_user IS null AND user.status<>'.DRH.' AND 
+                                user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
+                        $order_clause;
+                break;
+		}   
+    
 		global $_configuration;
 		if ($_configuration['multiple_access_urls']) {
 			$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
 			$access_url_id = api_get_current_access_url_id();
-			if ($access_url_id != -1){
-				if ($type == 'single') {
-					$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
-					INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
-					WHERE access_url_id = '.$access_url_id.'  AND (username LIKE "'.$needle.'%"
-					OR firstname LIKE "'.$needle.'%"
-					OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.' '.
-					$order_clause.
-					' LIMIT 11';
-				} else {
-					$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
-					INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
-					WHERE access_url_id = '.$access_url_id.'
-					AND '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
-					$order_clause;
+			if ($access_url_id != -1) {              
+                switch($type) {
+                    case 'single':
+                        $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                        INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
+                        WHERE access_url_id = '.$access_url_id.'  AND (username LIKE "'.$needle.'%"
+                        OR firstname LIKE "'.$needle.'%"
+                        OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.' '.
+                        $order_clause.
+                        ' LIMIT 11';
+                        break;
+                    case 'multiple':
+                        $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
+                        INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
+                        WHERE access_url_id = '.$access_url_id.' AND 
+                                '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
+                        $order_clause;
+                        break;
+                    case 'any_session' :
+                        $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id)
+                        INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
+                        WHERE   access_url_id = '.$access_url_id.' AND 
+                                s.id_user IS null AND
+                                user.status<>'.DRH.' AND 
+                                user.user_id<>"'.$user_anonymous.'"'.$cond_user_id.
+                        $order_clause;
+                        break;
 				}
-
 			}
 		}
 
@@ -155,7 +183,6 @@ function search_users($needle, $type) {
 			}
 
 			$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
-
 		} else {
 			global $nosessionUsersList;
 			$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
@@ -167,7 +194,6 @@ function search_users($needle, $type) {
 			$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
 		}
 	}
-
 	return $xajax_response;
 }
 
@@ -177,7 +203,6 @@ $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
 $htmlHeadXtra[] = '
 <script type="text/javascript">
 function add_user_to_session (code, content) {
-
 	document.getElementById("user_to_add").value = "";
 	document.getElementById("ajax_list_users_single").innerHTML = "";
 
@@ -188,12 +213,11 @@ function add_user_to_session (code, content) {
 				return false;
 		}
 	}
-
 	destination.options[destination.length] = new Option(content,code);
 	destination.selectedIndex = -1;
 	sortOptions(destination.options);
-
 }
+
 function remove_item(origin) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 		if(origin.options[i].selected) {
@@ -208,13 +232,26 @@ function validate_filter() {
 		document.formulaire.form_sent.value=0;
 		document.formulaire.submit();
 }
+
+function checked_in_no_session(checked) {    
+    $("#first_letter_user")
+    .find("option")
+    .attr("selected", false);
+    xajax_search_users(checked, "any_session");
+}
+
+function change_select(val) {
+    $("#user_with_any_session_id").attr("checked", false);
+    xajax_search_users(val,"multiple");
+}
+
 </script>';
 
 
 $form_sent=0;
 $errorMsg=$firstLetterUser=$firstLetterSession='';
 $UserList=$SessionList=array();
-$users=$sessions=array();
+$sessions=array();
 $noPHP_SELF=true;
 
 if($_POST['form_sent']) {
@@ -222,7 +259,6 @@ if($_POST['form_sent']) {
 	$firstLetterUser       = $_POST['firstLetterUser'];
 	$firstLetterSession    = $_POST['firstLetterSession'];
 	$UserList              = $_POST['sessionUsersList'];
-	$ClassList             = $_POST['sessionClassesList'];
     
 	if (!is_array($UserList)) {
 		$UserList=array();
@@ -238,8 +274,6 @@ if($_POST['form_sent']) {
 
 $session_info = SessionManager::fetch($id_session);
 Display::display_header($tool_name);
-//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
-
 
 $nosessionUsersList = $sessionUsersList = array();
 
@@ -357,15 +391,17 @@ if ($ajax_search) {
 		$Users    = Database::store_result($result);
 
 		foreach ($Users as $user) {
-			if($user['id_session'] != $id_session)
-				$nosessionUsersList[$user['user_id']] = $user ;
+			if ($user['id_session'] != $id_session)
+				$nosessionUsersList[$user['user_id']] = $user ;            
 		}
+        
 		$user_anonymous=api_get_anonymous_id();
 		foreach($nosessionUsersList as $key_user_list =>$value_user_list) {
 			if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) {
 				unset($nosessionUsersList[$key_user_list]);
 			}
 		}
+        
 		//filling the correct users in list
 		$sql="SELECT  user_id, lastname, firstname, username, id_session
 			FROM $tbl_user u
@@ -392,16 +428,16 @@ if ($ajax_search) {
 	foreach($Users as $key_user_list =>$value_user_list) {
 		if ($Users[$key_user_list]['user_id']==$user_anonymous) {
 			unset($Users[$key_user_list]);
-			}
-		}
+        }
+    }
 
 	foreach ($Users as $user) {
 		if($user['id_session'] == $id_session){
 			$sessionUsersList[$user['user_id']] = $user;
-			if (array_key_exists($user['user_id'],$nosessionUsersList))
+			if (array_key_exists($user['user_id'],$nosessionUsersList)) {
                 unset($nosessionUsersList[$user['user_id']]);
+            }
 		}
-
 	}
 }
 
@@ -413,10 +449,7 @@ if ($add_type == 'multiple') {
 	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.Security::remove_XSS($_GET['add']).'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
 }
 	$link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>';
-
-
 ?>
-
 <div class="actions">
 	<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>&nbsp;|&nbsp;<?php echo $link_add_group; ?>
 </div>
@@ -473,21 +506,19 @@ if(!empty($errorMsg)) {
 
 <?php if ($add_type=='multiple') { ?>
 <tr>
-<td align="center">
-
-<?php echo get_lang('FirstLetterUser'); ?> :
-     <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')" >
-      <option value = "%">--</option>
-      <?php
-        echo Display :: get_alphabet_options();
-      ?>
-     </select>
-</td>
-<td align="center">&nbsp;</td>
+    <td align="center">
+
+    <?php echo get_lang('FirstLetterUser'); ?> :
+        <select id="first_letter_user" name="firstLetterUser" onchange = "change_select(this.value);" >
+        <option value = "%">--</option>
+        <?php
+            echo Display :: get_alphabet_options();
+        ?>
+        </select>
+    </td>
+    <td align="center">&nbsp;</td>
 </tr>
 <?php } ?>
-
-
 <tr>
   <td align="center">
   <div id="content_source">
@@ -510,10 +541,13 @@ if(!empty($errorMsg)) {
 		?>
 	  </select>
 	  </div>
+        <input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id"> 
+        <label for="user_with_any_session_id"><?php echo get_lang('UsersRegisteredInNoSession'); ?></label>
 	<?php
   	  }
   	  unset($nosessionUsersList);
   	 ?>
+  
   </div>
   </td>
   <td width="10%" valign="middle" align="center">

+ 60 - 16
main/admin/add_users_to_usergroup.php

@@ -5,16 +5,15 @@
 */
 
 // name of the language file that needs to be included
-$language_file=array('admin','registration');
+$language_file = array('admin','registration');
 
 // resetting the course id
-$cidReset=true;
+$cidReset = true;
 
 // including some necessary files
 require_once '../inc/global.inc.php';
 require_once '../inc/lib/xajax/xajax.inc.php';
 require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
-require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -69,12 +68,26 @@ function validate_filter() {
         document.formulaire.form_sent.value=0;
         document.formulaire.submit();
 }
+
+function checked_in_no_group(checked) {    
+    $("#first_letter_user")
+    .find("option")
+    .attr("selected", false);    
+        document.formulaire.form_sent.value="2"; 
+    document.formulaire.submit();
+}
+
+function change_select(val) {
+    $("#user_with_any_group_id").attr("checked", false);
+    document.formulaire.form_sent.value="2"; 
+    document.formulaire.submit();
+}
+
 </script>';
 
 
 $form_sent  = 0;
 $errorMsg   = '';
-$sessions   = array();
 
 $extra_field_list= UserManager::get_extra_fields();
 $new_field_list = array();
@@ -90,6 +103,7 @@ if (is_array($extra_field_list)) {
 $usergroup = new UserGroup();
 $id = intval($_GET['id']);
 $first_letter_user = '';
+
 if ($_POST['form_sent']) {
     $form_sent              = $_POST['form_sent'];    
     $elements_posted        = $_POST['elements_in_name'];
@@ -110,8 +124,7 @@ if ($_POST['form_sent']) {
 //Filter by Extra Fields
 $use_extra_fields = false;
 if (is_array($extra_field_list)) {
-    if (is_array($new_field_list) && count($new_field_list)>0 ) {
-        $result_list=array();
+    if (is_array($new_field_list) && count($new_field_list)>0 ) {        
         foreach ($new_field_list as $new_field) {
             $varname = 'field_'.$new_field['variable'];
             if (Usermanager::is_extra_field_available($new_field['variable'])) {
@@ -140,19 +153,46 @@ if ($use_extra_fields) {
 $data       = $usergroup->get($id);
 $list_in    = $usergroup->get_users_by_usergroup($id);
 
+$list_all    = $usergroup->get_users_by_usergroup();
+
 $order = array('lastname');
 if (api_is_western_name_order()) {
     $order = array('firstname');	
 }
 
-if (!empty($first_letter_user)) {    
-    $user_list = UserManager::get_user_list_like(array('firstname'=>$first_letter_user), $order);
-} else {
-    $user_list  = UserManager::get_user_list(array(),$order);
+$elements_not_in = $elements_in = array();
+$complete_user_list = UserManager::get_user_list(array(), $order);
+
+if (!empty($complete_user_list)) {
+    foreach($complete_user_list as $item) {
+        if ($use_extra_fields) {
+            if (!in_array($item['user_id'], $final_result)) {
+                continue;
+            }
+        }
+        if ($item['status'] == 6 ) continue; //avoid anonymous users
+        
+        if (in_array($item['user_id'], $list_in)) {       
+            $person_name = api_get_person_name($item['firstname'], $item['lastname']).' ('.$item['username'].')';
+            $elements_in[$item['user_id']] = $person_name;             
+        }        
+    }
 }
+  
+$user_with_any_group = isset($_REQUEST['user_with_any_group']) && !empty($_REQUEST['user_with_any_group']) ? true : false;
 
-//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
-$elements_not_in = $elements_in = array();
+if ($user_with_any_group) {
+    $user_list = UserManager::get_user_list_like(array('lastname' => $first_letter_user), $order, true);
+    $new_user_list = array();
+    foreach($user_list as $item) {
+        if (!in_array($item['user_id'], $list_all)) {
+            $new_user_list[] = $item;
+        }        
+    }
+    $user_list = $new_user_list;        
+} else {    
+    $user_list = UserManager::get_user_list_like(array('lastname' => $first_letter_user), $order, true);
+}
 
 if (!empty($user_list)) {
     foreach($user_list as $item) {
@@ -162,9 +202,9 @@ if (!empty($user_list)) {
             }
         }
         if ($item['status'] == 6 ) continue; //avoid anonymous users
-        $person_name = api_get_person_name($item['firstname'], $item['lastname']);        
+        $person_name = api_get_person_name($item['firstname'], $item['lastname']).' ('.$item['username'].')';
         if (in_array($item['user_id'], $list_in)) {                        
-            $elements_in[$item['user_id']] = $person_name;             
+            //$elements_in[$item['user_id']] = $person_name;             
         } else {
             $elements_not_in[$item['user_id']] = $person_name;
         }
@@ -235,8 +275,8 @@ if(!empty($errorMsg)) {
 <?php if ($add_type=='multiple') { ?>
 <tr>
 <td align="center">
-<?php echo get_lang('FirstLetterSessions'); ?> :
-     <select name="firstLetterUser" onchange="javascript:document.formulaire.form_sent.value='2'; document.formulaire.submit();">
+<?php echo get_lang('FirstLetterUser'); ?> :
+     <select id="first_letter_user" name="firstLetterUser" onchange="change_select();">
       <option value = "%">--</option>
       <?php
         echo Display :: get_alphabet_options($first_letter_user);
@@ -250,6 +290,10 @@ if(!empty($errorMsg)) {
   <td align="center">
   <div id="content_source">      
         <?php echo Display::select('elements_not_in_name', $elements_not_in, '',array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?>
+      <br />
+        <input type="checkbox" <?php if ($user_with_any_group) echo 'checked="checked"';?> onchange="checked_in_no_group(this.checked);" name="user_with_any_group" id="user_with_any_group_id"> 
+        <label for="user_with_any_group_id"><?php echo get_lang('UsersRegisteredInNoGroup'); ?></label>
+        
   </div>
   </td>
   <td width="10%" valign="middle" align="center">

+ 9 - 12
main/admin/resume_session.php

@@ -11,8 +11,10 @@ $language_file = 'admin';
 $cidReset = true;
 require_once '../inc/global.inc.php';
 
+require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
+
 // setting the section (for the tabs)
-$this_section=SECTION_PLATFORM_ADMIN;
+$this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script(true);
 
@@ -69,11 +71,9 @@ if($_GET['action'] == 'delete') {
 		$idChecked="'".implode("','",$idChecked)."'";
 
 		Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)");
-
 		$nbr_affected_rows=Database::affected_rows();
 
 		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)");
-
 		Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
 	}
 
@@ -86,6 +86,7 @@ if($_GET['action'] == 'delete') {
 	if (!empty($_GET['user'])) {
 		Database::query("DELETE FROM $tbl_session_rel_user WHERE relation_type<>".SESSION_RELATION_TYPE_RRHH." AND id_session='$id_session' AND id_user=".intval($_GET['user']));
 		$nbr_affected_rows=Database::affected_rows();
+        
 		Database::query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'");
 
 		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".intval($_GET['user']));
@@ -161,7 +162,6 @@ echo Display::tag('h1', Display::return_icon('session.png', get_lang('Session'))
 		<?php echo intval($session['nb_days_access_after_end']) ?>
 	</td>
 </tr>
-
 <tr>
 	<td>
 		<?php echo api_ucfirst(get_lang('SessionVisibility')) ?> :
@@ -172,7 +172,6 @@ echo Display::tag('h1', Display::return_icon('session.png', get_lang('Session'))
 </tr>
 
 <?php 
-require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
 
 if (api_get_multiple_access_url()) {
     echo '<tr><td>';   
@@ -204,13 +203,12 @@ if (api_get_multiple_access_url()) {
 </tr>
 </tr>
 <?php
-if($session['nbr_courses']==0){
+if ($session['nbr_courses']==0){
 	echo '
 		<tr>
 			<td colspan="4">'.get_lang('NoCoursesForThisSession').'</td>
 		</tr>';
-}
-else {
+} else {
 	// select the courses
 	$sql = "SELECT code,title,visual_code, nbr_users
 			FROM $tbl_course,$tbl_session_rel_course
@@ -261,6 +259,7 @@ else {
 			<td>'.$course['nbr_users'].'</td>
 			<td>
                 <a href="'.api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session.'">'.Display::return_icon('course_home.gif', get_lang('Course')).'</a>   
+                <a href="session_course_user_list.php?id_session='.$id_session.'&course_code='.$course['code'].'">'.Display::return_icon('user.png', get_lang('Edit'), '', 22).'</a>
 				<a href="../tracking/courseLog.php?id_session='.$id_session.'&cidReq='.$course['code'].$orig_param.'&hide_course_breadcrumb=1">'.Display::return_icon('statistics.gif', get_lang('Tracking')).'</a>&nbsp;                
 				<a href="session_course_edit.php?id_session='.$id_session.'&page=resume_session.php&course_code='.$course['code'].''.$orig_param.'">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>
 				<a href="'.api_get_self().'?id_session='.$id_session.'&action=delete&idChecked[]='.$course['code'].'" onclick="javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>
@@ -270,9 +269,7 @@ else {
 }
 ?>
 </table>
-
 <br />
-
 <!--List of courses -->
 <table class="data_table" width="100%">
 <tr>
@@ -287,9 +284,9 @@ if($session['nbr_users']==0){
 		<tr>
 			<td colspan="2">'.get_lang('NoUsersForThisSession').'</td>
 		</tr>';
-}
-else {
+} else {
 	$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
+    
 	$sql = 'SELECT '.$tbl_user.'.user_id, lastname, firstname, username '.
 			' FROM '.$tbl_user.
 			' INNER JOIN '.$tbl_session_rel_user.

+ 1 - 1
main/admin/session_course_edit.php

@@ -33,7 +33,7 @@ $tool_name=$course_info['name'];
 
 $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
 $interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang("SessionList"));
-$interbreadcrumb[]=array('url' => "../admin/resume_session.php?id_session=".Security::remove_XSS($_REQUEST['id_session']),"name" => get_lang('SessionOverview'));
+$interbreadcrumb[]=array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
 $interbreadcrumb[]=array('url' => "session_course_list.php?id_session=$id_session","name" =>api_htmlentities($session_name,ENT_QUOTES,$charset));
 
 $result = Database::query("SELECT s.name, c.title FROM $tbl_session_course sc,$tbl_session s,$tbl_course c WHERE sc.id_session=s.id AND sc.course_code=c.code AND sc.id_session='$id_session' AND sc.course_code='".addslashes($course_code)."'");

+ 21 - 16
main/admin/session_course_list.php

@@ -6,8 +6,9 @@
 
 
 // name of the language file that needs to be included
-$language_file='admin';
-$cidReset=true;
+$language_file = 'admin';
+$cidReset = true;
+
 require_once '../inc/global.inc.php';
 
 // setting the section (for the tabs)
@@ -21,19 +22,24 @@ $tbl_session						= Database::get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_rel_course				= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session_rel_course_rel_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
-$id_session=intval($_GET['id_session']);
-$page=intval($_GET['page']);
-$action=$_REQUEST['action'];
-$sort=in_array($_GET['sort'],array('title','nbr_users'))?$_GET['sort']:'title';
+$id_session = intval($_GET['id_session']);
+
+if (empty($id_session)) {
+    api_not_allowed();
+}
 
-$result=Database::query("SELECT name FROM $tbl_session WHERE id='$id_session'");
+$page   = intval($_GET['page']);
+$action = $_REQUEST['action'];
+$sort   = in_array($_GET['sort'],array('title','nbr_users'))?$_GET['sort']:'title';
 
-if(!list($session_name)=Database::fetch_row($result)) {
+$result = Database::query("SELECT name FROM $tbl_session WHERE id='$id_session'");
+
+if (!list($session_name)=Database::fetch_row($result)) {
 	header('Location: session_list.php');
-	exit();
+	exit;
 }
 
-if($action == 'delete') {
+if ($action == 'delete') {
 	$idChecked = $_REQUEST['idChecked'];
 	if(is_array($idChecked) && count($idChecked)>0) {
 		$my_temp = array();
@@ -53,16 +59,16 @@ if($action == 'delete') {
 	exit();
 }
 
-$limit=20;
-$from=$page * $limit;
+$limit  = 20;
+$from   = $page * $limit;
 
-$result=Database::query("SELECT code,title,nbr_users FROM $tbl_session_rel_course,$tbl_course WHERE course_code=code AND id_session='$id_session' ORDER BY $sort LIMIT $from,".($limit+1));
+$result=Database::query("SELECT code,title,nbr_users FROM $tbl_session_rel_course, $tbl_course WHERE course_code=code AND id_session='$id_session' ORDER BY $sort LIMIT $from,".($limit+1));
 $Courses=Database::store_result($result);
-$nbr_results=sizeof($Sessions);
 $tool_name = api_htmlentities($session_name,ENT_QUOTES,$charset).' : '.get_lang('CourseListInSession');
 
 $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
 $interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang('SessionList'));
+$interbreadcrumb[]=array('url' => "resume_session.php?id_session=".Security::remove_XSS($_REQUEST['id_session']),"name" => get_lang('SessionOverview'));
 
 Display::display_header($tool_name);
 api_display_tool_title($tool_name);
@@ -95,5 +101,4 @@ echo '<select name="action">
 	</select>
 	<button class="save" type="submit">'.get_lang('Ok').'</button>
 	</form>';
-Display::display_footer();
-?>
+Display::display_footer();

+ 115 - 79
main/admin/session_course_user_list.php

@@ -6,23 +6,30 @@
 /**
  * Code
  */
-$language_file='admin';
-$cidReset=true;
+$language_file = array('admin', 'registration');
+$cidReset = true;
 require_once '../inc/global.inc.php';
 
 api_protect_admin_script(true);
-$tbl_user=Database::get_main_table(TABLE_MAIN_USER);
-$tbl_course=Database::get_main_table(TABLE_MAIN_COURSE);
-$tbl_session=Database::get_main_table(TABLE_MAIN_SESSION);
-$tbl_session_rel_course=Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-$tbl_session_rel_course_rel_user=Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-
-$id_session=intval($_GET['id_session']);
-$course_code=trim(stripslashes($_GET['course_code']));
-$page=intval($_GET['page']);
-$action=$_REQUEST['action'];
-$sort=in_array($_GET['sort'],array('lastname','firstname','username'))?$_GET['sort']:api_sort_by_first_name()?'firstname':'lastname';
-$idChecked = (is_array($_GET['idChecked']) ? $_GET['idChecked'] : (is_array($_POST['idChecked']) ? $_POST['idChecked'] : null));
+
+$tbl_user                           = Database::get_main_table(TABLE_MAIN_USER);
+$tbl_course                         = Database::get_main_table(TABLE_MAIN_COURSE);
+$tbl_session                        = Database::get_main_table(TABLE_MAIN_SESSION);
+$tbl_session_rel_course             = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
+$tbl_session_rel_user               = Database::get_main_table(TABLE_MAIN_SESSION_USER);
+$tbl_session_rel_course_rel_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+
+$id_session = intval($_GET['id_session']);
+if (empty($id_session )) {
+    api_not_allowed();
+}
+
+$course_code    = Database::escape_string(trim($_GET['course_code']));
+$page           = intval($_GET['page']);
+$action         = $_REQUEST['action'];
+$sort           = in_array($_GET['sort'],array('lastname','firstname','username'))?$_GET['sort']:api_sort_by_first_name()?'firstname':'lastname';
+$idChecked      = (is_array($_GET['idChecked']) ? $_GET['idChecked'] : (is_array($_POST['idChecked']) ? $_POST['idChecked'] : null));
+
 if (is_array($idChecked)) {
 	$my_temp = array();
 	foreach ($idChecked as $id){
@@ -36,42 +43,64 @@ $sql = "SELECT s.name, c.title  FROM $tbl_session_rel_course src
 		INNER JOIN $tbl_course c ON c.code = src.course_code
 		WHERE src.id_session='$id_session' AND src.course_code='".Database::escape_string($course_code)."' "; 
 
-$result=Database::query($sql);
-if(!list($session_name,$course_title)=Database::fetch_row($result))
-{
+$result = Database::query($sql);
+
+if (!list($session_name,$course_title)=Database::fetch_row($result)) {
 	header('Location: session_course_list.php?id_session='.$id_session);
 	exit();
 }
 
-if($action == 'delete') {
-	if(is_array($idChecked) && count($idChecked)>0 ) {
-		$idChecked=implode(',',$idChecked);
-		Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='".addslashes($course_code)."' AND id_user IN($idChecked)");
-		$nbr_affected_rows=Database::affected_rows();
-		Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session' AND course_code='".addslashes($course_code)."'");
-	}
-	header('Location: '.api_get_self().'?id_session='.$id_session.'&course_code='.urlencode($course_code).'&sort='.$sort);
-	exit();
-}
 
-$limit=20;
-$from=$page * $limit;
+   
+    switch($action) {
+        case 'delete':     
+            if (is_array($idChecked) && count($idChecked)>0 ) {
+                array_map('intval', $idChecked);
+                $idChecked = implode(',',$idChecked);
+            }
+            if (!empty($idChecked)) { 
+                Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='".$course_code."' AND id_user IN($idChecked)");
+                $nbr_affected_rows = Database::affected_rows();
+                Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session' AND course_code='".$course_code."'");
+            }
+            header('Location: '.api_get_self().'?id_session='.$id_session.'&course_code='.urlencode($course_code).'&sort='.$sort);
+            exit();
+            break;
+        case 'add':          
+            SessionManager::subscribe_users_to_session_course($idChecked, $id_session, $course_code);          
+            header('Location: '.api_get_self().'?id_session='.$id_session.'&course_code='.urlencode($course_code).'&sort='.$sort);
+            exit;
+            break;
+    }
+
+
+$limit  = 20;
+$from   = $page * $limit;
 $is_western_name_order = api_is_western_name_order();
+        
+//scru.status<>2  scru.course_code='".$course_code."' 
+$sql = "SELECT u.user_id,".($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname').", u.username, scru.id_user as is_subscribed
+             FROM $tbl_session_rel_user s INNER JOIN $tbl_user u ON (u.user_id=s.id_user) LEFT JOIN $tbl_session_rel_course_rel_user scru ON (u.user_id=scru.id_user AND  scru.course_code = '".$course_code."' )      
+             WHERE s.id_session='$id_session' 
+             ORDER BY $sort LIMIT $from,".($limit+1);
 
-$result=Database::query("SELECT u.user_id,".($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname').", u.username FROM $tbl_session_rel_course_rel_user scru, $tbl_user u WHERE u.user_id=scru.id_user AND scru.id_session='$id_session' AND scru.status<>2 AND scru.course_code='".addslashes($course_code)."' ORDER BY $sort LIMIT $from,".($limit+1));
-$Users=Database::store_result($result);
+$result = Database::query($sql);
+$Users  = Database::store_result($result);
 
-$nbr_results=sizeof($Users);
+$nbr_results = sizeof($Users);
 
-$tool_name = get_lang('ListOfUsersSubscribedToCourse').' &quot;'.api_htmlentities($course_title,ENT_QUOTES,$charset).'&quot; '.get_lang('ForTheSession').' &quot;'.api_htmlentities($session_name,ENT_QUOTES,$charset).'&quot;';
+$tool_name = get_lang('Session').': &quot;'.$session_name.'&quot; - '.get_lang('Course').': &quot;'.$course_title.'&quot;';
 
-$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('AdministrationTools'));
-$interbreadcrumb[]=array("url" => "session_list.php","name" => get_lang('SessionList'));
-$interbreadcrumb[]=array("url" => "session_course_list.php?id_session=$id_session","name" => get_lang('ListOfCoursesOfSession')." &quot;".api_htmlentities($session_name,ENT_QUOTES,$charset)."&quot;");
+$interbreadcrumb[] = array("url" => "index.php","name" => get_lang('PlatformAdmin'));
+$interbreadcrumb[] = array("url" => "session_list.php","name" => get_lang('SessionList'));
+$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
+//$interbreadcrumb[]=array("url" => "session_course_list.php?id_session=$id_session","name" => get_lang('ListOfCoursesOfSession')." &quot;".api_htmlentities($session_name,ENT_QUOTES,$charset)."&quot;");
 
 Display::display_header($tool_name);
-api_display_tool_title($tool_name);
+
+//api_display_tool_title($tool_name);
 ?>
+<h3><?php echo $tool_name; ?> </h3>
 <form method="post" action="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&sort=<?php echo $sort; ?>" onsubmit="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
 <div align="right">
 <?php
@@ -93,7 +122,6 @@ if($nbr_results > $limit) {
 	echo get_lang('Next');
 }
 ?>
-
 </div>
 <br />
 
@@ -114,60 +142,68 @@ if($nbr_results > $limit) {
 <?php
 $i=0;
 
-foreach($Users as $key=>$enreg) {
-	if($key == $limit) {
+foreach ($Users as $key=>$enreg) {
+	if ($key == $limit) {
 		break;
 	}
-?>
-
-<tr class="<?php echo $i?'row_odd':'row_even'; ?>">
-  <td><input type="checkbox" name="idChecked[]" value="<?php echo $enreg['user_id']; ?>"></td>
-  <?php if ($is_western_name_order) { ?>
-  <td><?php echo api_htmlentities($enreg['firstname'],ENT_QUOTES,$charset); ?></td>
-  <td><?php echo api_htmlentities($enreg['lastname'],ENT_QUOTES,$charset); ?></td>
-  <?php } else { ?>
-  <td><?php echo api_htmlentities($enreg['lastname'],ENT_QUOTES,$charset); ?></td>
-  <td><?php echo api_htmlentities($enreg['firstname'],ENT_QUOTES,$charset); ?></td>
-  <?php } ?>
-  <td><?php echo api_htmlentities($enreg['username'],ENT_QUOTES,$charset); ?></td>
-  <td>
-	<a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&sort=<?php echo $sort; ?>&action=delete&idChecked[]=<?php echo $enreg['user_id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;"><?php Display::display_icon('delete.gif', get_lang('Delete')); ?></a>
-  </td>
-</tr>
-
-<?php
-	$i=$i ? 0 : 1;
+    ?>
+
+    <tr class="<?php echo $i?'row_odd':'row_even'; ?>">
+        <td><input type="checkbox" name="idChecked[]" value="<?php echo $enreg['user_id']; ?>"></td>
+        <?php if ($is_western_name_order) { ?>
+        <td><?php echo api_htmlentities($enreg['firstname'],ENT_QUOTES,$charset); ?></td>
+        <td><?php echo api_htmlentities($enreg['lastname'],ENT_QUOTES,$charset); ?></td>
+        <?php } else { ?>
+        <td><?php echo api_htmlentities($enreg['lastname'],ENT_QUOTES,$charset); ?></td>
+        <td><?php echo api_htmlentities($enreg['firstname'],ENT_QUOTES,$charset); ?></td>
+        <?php } ?>
+        <td><?php echo api_htmlentities($enreg['username'],ENT_QUOTES,$charset); ?></td>
+        <td>
+        <?php if ($enreg['is_subscribed']) { ?> 
+            <a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&sort=<?php echo $sort; ?>&action=delete&idChecked[]=<?php echo $enreg['user_id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
+                <?php Display::display_icon('delete.png', get_lang('Delete')); ?>
+            </a>
+        <?php } else  { ?>
+            <a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&sort=<?php echo $sort; ?>&action=add&idChecked[]=<?php echo $enreg['user_id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
+                <?php Display::display_icon('add.png', get_lang('Add'), array(), 22); ?>
+            </a>
+        <?php }  ?>
+            
+        </td>
+    </tr>
+    <?php
+        $i=$i ? 0 : 1;
 }
-
 unset($Users);
 ?>
 
 </table>
 <br />
 <div align="left">
-<?php
-if($page) {
-?>
-<a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>"><?php echo get_lang('Previous'); ?></a>
-<?php
-} else {
-	echo get_lang('Previous');
-}
-?>
-|
-<?php
-if($nbr_results > $limit) {
-?>
-<a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>"><?php echo get_lang('Next'); ?></a>
-<?php
-} else {
-	echo get_lang('Next');
-}
-?>
+    <?php
+    if($page) {
+    ?>
+    <a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>"><?php echo get_lang('Previous'); ?></a>
+    <?php
+    } else {
+        echo get_lang('Previous');
+    }
+    ?>
+    |
+    <?php
+    if($nbr_results > $limit) {
+    ?>
+    <a href="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>"><?php echo get_lang('Next'); ?></a>
+    <?php
+    } else {
+        echo get_lang('Next');
+    }
+    ?>
 </div>
 <br />
 <select name="action">
 <option value="delete"><?php echo get_lang('UnsubscribeSelectedUsersFromSession');?></option>
+<option value="add"><?php echo get_lang('AddUsers');?></option>
 </select>
 <button class="save" type="submit"> <?php echo get_lang('Ok'); ?></button>
 </form>

+ 1 - 1
main/attendance/attendance_calendar.php

@@ -52,7 +52,7 @@ if (isset($action) && $action == 'calendar_add') {
 	echo '<h4>'.get_lang('AddADateTime').'</h4>';
 		$form = new FormValidator('attendance_calendar_add','POST','index.php?action=calendar_add&attendance_id='.$attendance_id.$param_gradebook.'&'.api_get_cidreq(),'');
 		$form->addElement('datepicker', 'date_time', '', array('form_name'=>'attendance_calendar_add'), 5);
-		$defaults['date_time'] = date('Y-m-d H:i',api_strtotime(api_get_local_time()));
+		$defaults['date_time'] = date('Y-m-d H:i', api_strtotime(api_get_local_time()));
 
         $form->addElement('html','<br /><br />');
 		

+ 4 - 6
main/attendance/attendance_controller.php

@@ -299,18 +299,16 @@
 			if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {	
 				if (!isset($_POST['cancel'])) {
                     if (isset($_POST['repeat'])) {
-                       error_log($attendance->build_datetime_from_array($_POST['date_time']));
-                       //$start_datetime = api_strtotime($attendance->build_datetime_from_array($_POST['date_time']));
-                       
+                        //@todo  check this error_logs
                         $start_datetime = api_strtotime(api_get_utc_datetime($attendance->build_datetime_from_array($_POST['date_time'])),'UTC');
-                        error_log('$start_datetime '.$start_datetime);
+                        //error_log('$start_datetime '.$start_datetime);
                         
                         $_POST['end_date_time']['H'] = $_POST['date_time']['H'];
                         $_POST['end_date_time']['i'] = $_POST['date_time']['i'];
-                        error_log($attendance->build_datetime_from_array($_POST['end_date_time']));
+                        //error_log($attendance->build_datetime_from_array($_POST['end_date_time']));
                         
                         $end_datetime = api_strtotime(api_get_utc_datetime($attendance->build_datetime_from_array($_POST['end_date_time'])),'UTC');
-                        error_log('$end_datetime '.$end_datetime);
+                        //error_log('$end_datetime '.$end_datetime);
                         $checkdate = checkdate($_POST['end_date_time']['F'], $_POST['end_date_time']['d'], $_POST['end_date_time']['Y']);
 
                         $repeat_type = $_POST['repeat_type'];

+ 21 - 10
main/calendar/agenda.inc.php

@@ -589,14 +589,18 @@ $(function() {
 
 function move(fbox,	tbox)
 {
+    // @todo : change associative arrays arrLookup and arrLookupTitle that use firstname/lastnam as key
+    // so, pb with homonyms
 	var	arrFbox	= new Array();
 	var	arrTbox	= new Array();
 	var	arrLookup =	new	Array();
+	var	arrLookupTitle =	new	Array();
 
 	var	i;
 	for	(i = 0;	i <	tbox.options.length; i++)
 	{
 		arrLookup[tbox.options[i].text]	= tbox.options[i].value;
+		arrLookupTitle[tbox.options[i].text] = tbox.options[i].title;
 		arrTbox[i] = tbox.options[i].text;
 	}
 
@@ -606,6 +610,7 @@ function move(fbox,	tbox)
 	for(i =	0; i < fbox.options.length;	i++)
 	{
 		arrLookup[fbox.options[i].text]	= fbox.options[i].value;
+		arrLookupTitle[fbox.options[i].text] = fbox.options[i].title;
 
 		if (fbox.options[i].selected &&	fbox.options[i].value != \"\")
 		{
@@ -665,7 +670,7 @@ function move(fbox,	tbox)
 		var	no = new Option();
 		no.value = arrLookup[arrFbox[c]];
 		no.text	= arrFbox[c];
-		no.title = no.text;
+		no.title = arrLookupTitle[arrFbox[c]];
 		fbox[c]	= no;
 	}
 	for(c =	0; c < arrTbox.length; c++)
@@ -673,7 +678,7 @@ function move(fbox,	tbox)
 		var	no = new Option();
 		no.value = arrLookup[arrTbox[c]];
 		no.text	= arrTbox[c];
-		no.title = no.text;
+		no.title = arrLookupTitle[arrTbox[c]];
 		tbox[c]	= no;
 	}
 }
@@ -1003,8 +1008,9 @@ function construct_not_selected_select_form($group_list=null, $user_list=null,$t
 		foreach($user_list as $this_user) {
 		    // $to_already_selected is the array containing the users (and groups) that are already selected
 			if (!is_array($to_already_selected) || !in_array("USER:".$this_user['uid'],$to_already_selected)) {
-    		    $user_info = api_get_person_name($this_user['firstName'], $this_user['lastName'])." (".$this_user['username'].") ";
-				echo	"<option title='$user_info' value='USER:".$this_user['uid']."'>$user_info</option>";
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $this_user['username']), ENT_QUOTES);
+    		    $user_info = api_get_person_name($this_user['firstName'], $this_user['lastName']);
+				echo	"<option title='$username' value='USER:".$this_user['uid']."'>$user_info</option>";
 			}
 		}
 	}
@@ -1048,8 +1054,9 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al
 			}
 			else
 			{
-			    $user_info = api_get_person_name($ref_array_users[$id]['firstName'], $ref_array_users[$id]['lastName'])." (".$ref_array_users[$id]['username'].")";
-				$select_options_user[] = "<option title='$user_info' value='".$groupuser."'>$user_info</option>";
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $ref_array_users[$id]['username']), ENT_QUOTES);
+			    $user_info = api_get_person_name($ref_array_users[$id]['firstName'], $ref_array_users[$id]['lastName']);
+				$select_options_user[] = "<option title='$username' value='".$groupuser."'>$user_info</option>";
 				//echo "<option value=\"".$groupuser."\">".api_get_person_name($ref_array_users[$id]['firstName'], $ref_array_users[$id]['lastName'])."</option>";
 			}
 		}
@@ -1357,16 +1364,20 @@ function sent_to_form($sent_to_array) {
     	if (isset($sent_to_array['users'])) {
     		if (is_array($sent_to_array['users'])) {
     			foreach ($sent_to_array['users'] as $user_id) {
-    				$user_info= api_get_user_info($user_id);
-    				$output[] = api_get_person_name($user_info['firstName'], $user_info['lastName'])." (".$user_info['username'].")";
+    			    // @todo add username as tooltip - is this fucntion still used ?
+    				// $user_info= api_get_user_info($user_id);
+                    // $username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);
+    				$output[] = api_get_person_name($user_info['firstName'], $user_info['lastName']);
                 }
             }
     	}    
 	} else {
 	    // there is only one user/group
 		if (is_array($sent_to_array['users'])) {
-			$user_info = api_get_user_info($sent_to_array['users'][0]);
-			$output[]= api_get_person_name($user_info['firstName'], $user_info['lastName'])." (".$user_info['username'].")";
+		    // @todo add username as tooltip - is this fucntion still used ?
+			// $user_info = api_get_user_info($sent_to_array['users'][0]);
+            // $username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);
+			$output[]= api_get_person_name($user_info['firstName'], $user_info['lastName']);
 		}
 		if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0) {
 			$group_id = $sent_to_array['groups'][0];

+ 7 - 2
main/calendar/agenda.lib.php

@@ -548,7 +548,9 @@ class Agenda {
                         $sent_to = array();
                         foreach($user_to_array as $item) {
                             $user_info = api_get_user_info($item);   
-                            $sent_to[] = $user_info['complete_name'];        
+                            // add username as tooltip for $event['sent_to'] - ref #4226
+                            $username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES);                            
+                            $sent_to[] = "<span title='".$username."'>".$user_info['complete_name']."</span>";        
                         }
                     }
                     $event['sent_to'] = implode(', ', $sent_to);
@@ -662,7 +664,10 @@ class Agenda {
         foreach($user_list as $this_user) {
             // $to_already_selected is the array containing the users (and groups) that are already selected
             if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'],$to_already_selected)) {
-                $html .= "<option value=\"USER:".$this_user['user_id']."\">".api_get_person_name($this_user['firstname'], $this_user['lastname'])." (".$this_user['username'].")</option>";
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $this_user['username']), ENT_QUOTES);
+                // @todo : add title attribute $username in the jqdialog window. wait for a chosen version to inherit title attribute
+                // from <option> to <li>
+                $html .= "<option title='".$username."' value=\"USER:".$this_user['user_id']."\">".api_get_person_name($this_user['firstname'], $this_user['lastname'])."</option>";
             }
         }
         if (is_array($group_list)) {

+ 13 - 5
main/course_description/listing.php

@@ -44,21 +44,29 @@ if (api_is_allowed_to_edit(null,true)) {
 if ($history) {
 	echo '<div><table width="100%"><tr><td><h3>'.get_lang('ThematicAdvanceHistory').'</h3></td><td align="right"><a href="index.php?action=listing">'.Display::return_icon('info.png',get_lang('BackToCourseDesriptionList'),array('style'=>'vertical-align:middle;'),22).' '.get_lang('BackToCourseDesriptionList').'</a></td></tr></table></div>';
 }
+$user_info = api_get_user_info();
+
 if (isset($descriptions) && count($descriptions) > 0) {
 	foreach ($descriptions as $id => $description) {
 		echo '<div class="sectiontitle">';
 		
 		if (api_is_allowed_to_edit(null,true) && !$history) {
 			if (api_get_session_id() == $description['session_id']) {
+                $description['title'] = $description['title'].' '.api_get_session_image(api_get_session_id(), $user_info['status']);
+                
 				//delete
 				echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
 				echo Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'),22);
 				echo '</a> ';
-			}			
-			//edit
-			echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=edit&description_type='.$description['description_type'].'">';
-			echo Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),22);
-			echo '</a> ';	
+                
+                //edit
+                echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=edit&description_type='.$description['description_type'].'">';
+                echo Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),22);                	
+                echo '</a> ';
+			} else {                
+                echo Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'),22);
+                
+            }
 		}
 		
 		echo $description['title'];

+ 0 - 3
main/course_progress/index.php

@@ -18,8 +18,6 @@ require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
 require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
 require_once api_get_path(LIBRARY_PATH).'app_view.php';
 require_once 'thematic_controller.php';
-require_once api_get_path(LIBRARY_PATH).'course.lib.php';
-require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 //require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
 
 // current section
@@ -77,7 +75,6 @@ if (!empty($thematic_id)) {
 // get default thematic plan title
 $default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
 
-
 $htmlHeadXtra[] = api_get_jquery_ui_js();
 
 // Only when I see the 3 columns. Avoids double or triple click binding for onclick event 

+ 1 - 1
main/coursecopy/classes/Attendance.class.php

@@ -2,7 +2,7 @@
 /* For licensing terms, see /license.txt */
 require_once 'Resource.class.php';
 /**
- * Surveys backup script
+ * Attendance backup script
  * @package chamilo.backup
  */
 

+ 26 - 4
main/coursecopy/classes/CourseBuilder.class.php

@@ -847,11 +847,17 @@ class CourseBuilder {
 		$table_thematic			= Database :: get_course_table(TABLE_THEMATIC);
 		$table_thematic_advance = Database :: get_course_table(TABLE_THEMATIC_ADVANCE);
 		$table_thematic_plan    = Database :: get_course_table(TABLE_THEMATIC_PLAN);
+        
+        $session_id = intval($session_id);
+        if ($with_base_content) {
+            $session_condition = api_get_session_condition($session_id, true, true);                
+        } else {
+            $session_condition = api_get_session_condition($session_id, true);
+        }
 		
 		$course_id = api_get_course_int_id();
 		
-		
-		$sql = 'SELECT * FROM '.$table_thematic.' WHERE c_id = '.$course_id.' AND session_id = 0 ';
+		$sql = "SELECT * FROM $table_thematic WHERE c_id = $course_id $session_condition ";
 		$db_result = Database::query($sql);
 		while ($row = Database::fetch_array($db_result,'ASSOC')) {
 			$thematic = new Thematic($row);
@@ -860,8 +866,24 @@ class CourseBuilder {
 			$result = Database::query($sql);
 			while ($sub_row = Database::fetch_array($result,'ASSOC')) {				
 				$thematic->add_thematic_advance($sub_row);
-			}			
-			$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id'];
+			}
+            
+            $items  = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), $session_id);		
+            //$items_from_session = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), api_get_session_id());
+            
+            $thematic_plan_id_list = array();
+            if (!empty($items)) {
+                foreach($items as $item) {				
+                    $thematic_plan_id_list[] = $item['ref'];
+                    //$thematic_plan_complete_list[$item['ref']] = $item;
+                }
+            }
+            //$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id'];
+            
+            $sql = "SELECT tp.*
+                FROM $table_thematic_plan tp INNER JOIN $table_thematic t ON (t.id=tp.thematic_id) 			        
+                WHERE  t.c_id = $course_id AND tp.c_id = $course_id  AND thematic_id = {$row['id']}  AND tp.id IN (".implode(', ', $thematic_plan_id_list).") ";
+
 				
 			$result = Database::query($sql);
 			while ($sub_row = Database::fetch_array($result,'ASSOC')) {

+ 6 - 18
main/coursecopy/classes/CourseRestorer.class.php

@@ -1342,16 +1342,11 @@ class CourseRestorer
 					Database::query($sql);
 					$new_id = Database::insert_id();
 					$this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
-					foreach ($survey->question_ids as $index => $question_id)
-					{
+					foreach ($survey->question_ids as $index => $question_id) {
 						$qid = $this->restore_survey_question($question_id, $new_id);
-						$sql = "UPDATE ".$table_que." " .
-								"SET survey_id = ".$new_id." WHERE " .
-								"question_id = ".$qid."";
+						$sql = "UPDATE $table_que SET survey_id = $new_id WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
 						Database::query($sql);
-						$sql = "UPDATE ".$table_ans." ".
-								"SET survey_id = ".$new_id." WHERE " .
-								"question_id = ".$qid."";
+						$sql = "UPDATE $table_ans SET survey_id = $new_id WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
 						Database::query($sql);
 					}
 				}
@@ -1363,8 +1358,7 @@ class CourseRestorer
 	/**
 	 * Check availability of a survey code
 	 */
-	function is_survey_code_available($survey_code)
-	{
+	function is_survey_code_available($survey_code)	{
 		$table_sur = Database :: get_course_table(TABLE_SURVEY);
 		$sql = "SELECT * FROM $table_sur WHERE c_id = ".$this->destination_course_id." AND code='".self::DBUTF8escapestring($survey_code)."'";
 		$result = Database::query($sql);
@@ -1375,8 +1369,7 @@ class CourseRestorer
 	/**
 	 * Restore survey-questions
 	 */
-	function restore_survey_question($id, $survey_id)
-	{
+	function restore_survey_question($id, $survey_id) {
 		$resources = $this->course->resources;
 		$question = $resources[RESOURCE_SURVEYQUESTION][$id];
 
@@ -1738,11 +1731,6 @@ class CourseRestorer
 		$destination='../../courses/'.$this->course->destination_path.'/work/';		
 		$origin='../../courses/'.$this->course->info['path'].'/work/';
 		self::allow_create_all_directory($origin,$destination,false);
-
-	
-	
-	
-
 	}
 
 /**
@@ -1888,7 +1876,7 @@ class CourseRestorer
 				$last_id = Database::insert($table_thematic, $thematic->params, false);
 				
 				if (is_numeric($last_id)) {
-					api_item_property_update($this->destination_course_info, 'thematic', $last_id,"ThematicAdded", api_get_user_id());
+					api_item_property_update($this->destination_course_info, 'thematic', $last_id, "ThematicAdded", api_get_user_id());
 					
 					foreach($thematic->thematic_advance_list as $thematic_advance) {						
 						unset($thematic_advance['id']);						

+ 1 - 2
main/coursecopy/classes/Survey.class.php

@@ -139,5 +139,4 @@ class Survey extends Resource
 		parent::show();
 		echo $this->code.' - '.$this->title;
 	}
-}
-?>
+}

+ 1 - 2
main/coursecopy/classes/SurveyQuestion.class.php

@@ -94,5 +94,4 @@ class SurveyQuestion extends Resource
 		parent::show();
 		echo $this->survey_question;
 	}
-}
-?>
+}

+ 1 - 1
main/coursecopy/classes/Thematic.class.php

@@ -2,7 +2,7 @@
 /* For licensing terms, see /license.txt */
 require_once 'Resource.class.php';
 /**
- * Surveys backup script
+ * Thematic backup script
  * @package chamilo.backup
  */
 

+ 20 - 21
main/coursecopy/copy_course_session.php

@@ -94,22 +94,23 @@ function display_form() {
     $html .= Display::return_message(get_lang('CopyCourseFromSessionToSessionExplanation'));
     
 	$html .= '<form name="formulaire" method="post" action="'.api_get_self().'" >';    
-	$html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">';
+	$html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
     
-	//left
-	$html .= '<tr><td width="50%" align="center"><b>'.get_lang('OriginCoursesFromSession').':</b></td>';
-	$html .= '<td align="center" width="30%"><b>'.get_lang('DestinationCoursesFromSession').':</b></td></tr>';
-	$html .= '<tr><td width="50%" align="center">'.make_select_session_list('sessions_list_origin', $sessions, array('onchange' => 'javascript: xajax_search_courses(this.value,\'origin\');')).'</td>';
-	$html .= '<td width="50%" align="center"><div id="ajax_sessions_list_destination">';
+	// origin
+	$html .= '<tr><td width="15%"><b>'.get_lang('OriginCoursesFromSession').':</b></td>';
+	$html .= '<td width="10%" align="left">'.make_select_session_list('sessions_list_origin', $sessions, array('onchange' => 'javascript: xajax_search_courses(this.value,\'origin\');')).'</td>';	
+	$html .= '<td width="50%"><div id="ajax_list_courses_origin">';
+	$html .= '<select id="origin" name="SessionCoursesListOrigin[]"  style="width:380px;"></select></div></td></tr>';
+    
+    //destination    
+    $html .= '<tr><td width="15%"><b>'.get_lang('DestinationCoursesFromSession').':</b></td>';    
+    $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">';
 	$html .= '<select name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">';
-	$html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div></td></tr>';
-	$html .= '<tr><td width="50%" align="center"><div id="ajax_list_courses_origin">';
-	$html .= '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:380px;"></select></div></td>';
+	$html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div></td>';    
 	
-    //Right
-	$html .= '<td width="50%" align="center">';
+	$html .= '<td width="50%">';
 	$html .= '<div id="ajax_list_courses_destination">';
-	$html .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:380px;" ></select></div></td>';
+	$html .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" ></select></div></td>';
 	$html .= '</tr></table>';
 	
 	$html .= '<h3>'.get_lang('TypeOfCopy').'</h3>';
@@ -118,7 +119,7 @@ function display_form() {
     $html .= '<input type="radio" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
     $html .= '<label for="copy_option_2"><span id="title_option2" style="color:#aaa"> '.get_lang('LetMeSelectItems').'</span></label><br/>';
     
-    $html .= '<input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" checked="checked" /><label for="copy_base_content_id">'.get_lang('CopyOnlySessionItems').'</label><br /><br/>';
+    $html .= '<input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" /><label for="copy_base_content_id">'.get_lang('CopyOnlySessionItems').'</label><br /><br/>';
 	
 	$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;">'.get_lang('CopyCourse').'</button>';
     $html .= '</form>';
@@ -138,7 +139,7 @@ function search_courses($id_session, $type) {
             $course_list = SessionManager::get_course_list_by_session_id($id_session);
      
 			$temp_course_list = array();
-			$return .= '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:380px;" onclick="javascript: checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\');">';
+			$return .= '<select id="origin" name="SessionCoursesListOrigin[]" style="width:380px;" onclick="javascript: checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\');">';
 			
 			foreach ($course_list as $course) {			    
 				$temp_course_list[] = "'{$course['code']}'";
@@ -174,7 +175,7 @@ function search_courses($id_session, $type) {
 			}
 
 			// Select multiple destination empty
-			$select_multiple_empty = '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:380px;"></select>';
+			$select_multiple_empty = '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;"></select>';
 
 			// Send response by ajax
 			$xajax_response -> addAssign('ajax_list_courses_origin', 'innerHTML', api_utf8_encode($return));
@@ -195,7 +196,7 @@ function search_courses($id_session, $type) {
 
 			$course_list_destination = array();
 			//onmouseover="javascript: this.disabled=true;" onmouseout="javascript: this.disabled=false;"
-			$return .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:380px;" >';
+			$return .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" >';
 			while ($course = Database :: fetch_array($rs)) {
 				$course_list_destination[] = $course['code'];
 				$course_title = str_replace("'", "\'", $course_title);
@@ -334,8 +335,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
 		if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
 			//We need only one value			
 			if (count($arr_course_origin) > 1 || count($arr_course_destination) > 1) {
-				Display::display_error_message(get_lang('YouMustSelectACourseFromOriginalSession'));
-				display_form();	
+				Display::display_error_message(get_lang('YouMustSelectACourseFromOriginalSession'));				
 			} else {
 				//foreach ($arr_course_origin as $course_origin) {
 				//first element of the array
@@ -345,10 +345,9 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is
 				$course_origin = api_get_course_info($course_code);				
 				$cb = new CourseBuilder('', $course_origin);
 				$course = $cb->build($origin_session, $course_code, $with_base_content);
-				$cr = new CourseRestorer($course);
-				//$cr->set_file_option($_POST['same_file_name_option']);
+				$cr = new CourseRestorer($course);				
 				$cr->restore($course_destinatination, $destination_session);
-				//}
+				
 			}
 			Display::display_confirmation_message(get_lang('CopyFinished'));
 			display_form();

+ 3 - 3
main/document/save_pixlr.php

@@ -5,7 +5,7 @@
  *
  *	@package chamilo.document
  *
- * @author Juan Carlos Raa Trabado
+ * @author Juan Carlos Raña Trabado
  * @since 30/january/2011
 */
 /**
@@ -44,8 +44,8 @@ $dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 $saveDir=$dirBaseDocuments.$_SESSION['paint_dir'];
 $contents = file_get_contents($urlcontents);
 
-//Verify that the URL is pointing to a file @ pixlr.com
-if (strpos($urlcontents, "pixlr.com") == 0){
+//Verify that the URL is pointing to a file @ pixlr.com domain or ip
+if (strpos($urlcontents, "pixlr.com") == 0 && strpos($urlcontents, "69.164.195.250") == 0){
   echo "Invalid referrer";
   exit;
 }

+ 12 - 8
main/exercice/exercice.php

@@ -409,10 +409,11 @@ if ($total > $limit) {
  
     $i =1;
     $lis = '';
-$exercise_list = array();
+
 $online_icon  = Display::return_icon('online.png', get_lang('Visible'),array('width'=>'12px'));
 $offline_icon = Display::return_icon('offline.png',get_lang('Invisible'),array('width'=>'12px'));
 
+$exercise_list = array();
 while ($row = Database :: fetch_array($result,'ASSOC')) {
     $exercise_list[] = $row;
 } 
@@ -459,7 +460,8 @@ if (!empty($exercise_list)) {
             $time_limits = false;                            
             if ($row['start_time'] != '0000-00-00 00:00:00' || $row['end_time'] != '0000-00-00 00:00:00') {
                 $time_limits = true;    
-            }                        
+            }
+            
             if ($time_limits) {
                 // check if start time
                 $start_time = false;
@@ -470,12 +472,12 @@ if (!empty($exercise_list)) {
                 if ($row['end_time'] != '0000-00-00 00:00:00') {
                     $end_time   = api_strtotime($row['end_time'],'UTC');  
                 }                                    
-                $now        = time();
+                $now             = time();
                 $is_actived_time = false;
                 
                 //If both "clocks" are enable
                 if ($start_time && $end_time) {                  
-                    if ($now > $start_time && $end_time > $now ) {
+                    if ($now > $start_time && $end_time > $now ) {                        
                         $is_actived_time = true;
                     }
                 } else {
@@ -492,8 +494,7 @@ if (!empty($exercise_list)) {
                     }
                 }                    
             }
-             
-			
+             			
 			//Blocking empty start times see BT#2800
         	global $_custom; 
 			if (isset($_custom['exercises_hidden_when_no_start_date']) && $_custom['exercises_hidden_when_no_start_date']) { 
@@ -549,9 +550,9 @@ if (!empty($exercise_list)) {
                     $class_tip = 'link_tooltip';
                 }
                 
-                $url = '<a '.$alt_title.' class="'.$class_tip.'" id="tooltip_'.$row['id'].'" href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'"><img src="../img/quiz.gif" /> '.$title.' </a>'.$lp_blocked;
+                $url = '<a '.$alt_title.' class="'.$class_tip.'" id="tooltip_'.$row['id'].'" href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'"><img src="../img/quiz.gif" /> '.$title.' </a>';
                            
-                $item =  Display::tag('td', $url.' '.$session_img);  
+                $item =  Display::tag('td', $url.' '.$session_img.$lp_blocked);  
                 
 
                 //count number exercice - teacher
@@ -628,6 +629,7 @@ if (!empty($exercise_list)) {
                 // --- Student only                 
                 
                 // if time is actived show link to exercise
+                
                 if ($time_limits) {                 
                     if ($is_actived_time) {
                         $url =  '<a '.$alt_title.'  href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'">'.$cut_title.'</a>';
@@ -690,6 +692,8 @@ if (!empty($exercise_list)) {
                         }
                     } else {
                         //Quiz not ready due to time limits
+                        
+                        //@todo use the is_visible function                        
                         if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
                             $attempt_text =  sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
                         } else {

+ 39 - 36
main/exercice/exercise.class.php

@@ -130,10 +130,10 @@ class Exercise {
 			$this->review_answers   = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;  
 			
 			if ($object->end_time != '0000-00-00 00:00:00') {
-				$this->end_time 	= api_get_local_time($object->end_time);
+				$this->end_time 	= $object->end_time;
 			}
 			if ($object->start_time != '0000-00-00 00:00:00') {
-				$this->start_time 	= api_get_local_time($object->start_time);
+				$this->start_time 	= $object->start_time;
 			}
 			$this->expired_time 	= $object->expired_time; //control time
 
@@ -1121,12 +1121,12 @@ class Exercise {
                 $defaults['display_category_name'] = $this->selectDisplayCategoryName(); // 
                 
 				if (($this->start_time!='0000-00-00 00:00:00'))
-				$defaults['activate_start_date_check'] = 1;
+                    $defaults['activate_start_date_check'] = 1;
 				if ($this->end_time!='0000-00-00 00:00:00')
-				$defaults['activate_end_date_check'] = 1;
+                    $defaults['activate_end_date_check'] = 1;
 
-				$defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00')? $this->start_time : date('Y-m-d 12:00:00');
-				$defaults['end_time']   = ($this->end_time!='0000-00-00 00:00:00')?$this->end_time : date('Y-m-d 12:00:00',time()+84600);
+				$defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? $this->start_time : date('Y-m-d 12:00:00');
+				$defaults['end_time']   = ($this->end_time!='0000-00-00 00:00:00') ? $this->end_time : date('Y-m-d 12:00:00',time()+84600);
 
 				//Get expired time
 				if($this->expired_time != '0') {					
@@ -3290,57 +3290,60 @@ class Exercise {
 		
 	 public function is_visible($lp_id = 0, $lp_item_id = 0 , $lp_item_view_id = 0) {
 		//1. By default the exercise is visible
-		$is_visible = true;
-		
+		$is_visible = true;		
 		
 		//1.1 Admins and teachers can access to the exercise
 		
 		if (api_is_platform_admin() || api_is_course_admin()) {
-			$is_visible = true;
+			return array('value' => true, 'message' => '');            
 		}
 		
-		
 		//2. If the exercise is not active 
 		if ($this->active == 0) {
-			return false;
-		}
+			return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotAvailable'), 'warning', false));            
+		}        
 		
 		//3. We check if the time limits are on
 		$limit_time_exists = ((!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') || (!empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00')) ? true : false;
-		
+        
 		if ($limit_time_exists) {
-			$time_now 				= time();
-		
+			$time_now = time();            
+                       
 			if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {				
-				$permission_to_start = (($time_now - api_strtotime($this->start_time, 'UTC')) > 0) ? true : false;
-			} else {
-				$permission_to_start = true;
-			}
-			
-			if ($this->end_time != '0000-00-00 00:00:00') {
-				$exercise_timeover = (($time_now - api_strtotime($this->end_time, 'UTC')) > 0) ? true : false;
-			} else {
-				$exercise_timeover = false;
-			}
-		
-			if (!$permission_to_start || $exercise_timeover) {
-				$is_visible = false;
-			}
+				$is_visible = (($time_now - api_strtotime($this->start_time, 'UTC')) > 0) ? true : false;
+			}            
+            
+            if ($is_visible == false) {
+                $message = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($this->start_time));
+            }
+            
+            if ($is_visible == true) {		
+                if ($this->end_time != '0000-00-00 00:00:00') {
+                    $is_visible = ((api_strtotime($this->end_time, 'UTC') > $time_now) > 0) ? true : false;
+                    if ($is_visible == false) {
+                        $message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));     
+                    }
+                }
+            }
+            if ($is_visible == false && $this->start_time != '0000-00-00 00:00:00' && $this->end_time != '0000-00-00 00:00:00') {
+                $message =  sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($this->start_time), api_convert_and_format_date($this->end_time));
+            } 
 		}
 		
 		// 4. We check if the student have attempts
 		if ($is_visible) {
-			if ($this->selectAttempts()) {
+			if ($this->selectAttempts() > 0) {
 				$attempt_count = get_attempt_count_not_finished(api_get_user_id(), $this->id, $lp_id, $lp_item_id, $lp_item_view_id);
-				if ($attempt_count >= $this->selectAttempts()) {
-					//Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
+				if ($attempt_count >= $this->selectAttempts()) {					
+                    $message = sprintf(get_lang('ReachedMaxAttempts'), $this->name, $this->selectAttempts());
 					$is_visible = false;
 				}
 			}
 		}
-		
-	
-		return $is_visible;
+        if (!empty($message)){
+            $message = Display :: return_message($message, 'warning', false);
+        }
+		return array('value' => $is_visible, 'message' => $message);
 	}
 	
 	function save_attempt() {
@@ -3498,6 +3501,6 @@ class Exercise {
 			}
 		}		
 		return $result;
-	}	
+    }
 }
 endif;

+ 19 - 8
main/exercice/exercise.lib.php

@@ -1023,8 +1023,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
                     }
                     
                     if ($start_date != "0000-00-00 00:00:00") {
-                        $start_date_timestamp   = api_strtotime($start_date);
-                        $exe_date_timestamp     = api_strtotime($results[$i]['exe_date']);                                                
+                        $start_date_timestamp   = api_strtotime($start_date, 'UTC');
+                        $exe_date_timestamp     = api_strtotime($results[$i]['exe_date'], 'UTC');                                                
     
                         $my_duration = ceil((($exe_date_timestamp - $start_date_timestamp) / 60));
                         //var_dump($start_date .' - '.$results[$i]['exdate'].' - '.$my_duration);
@@ -1218,8 +1218,8 @@ function convert_score($score, $weight) {
  * @param   int     session id
  * @return  array   array with exercise data
  */
-function get_all_exercises($course_info = null, $session_id = 0, $check_dates = false) {
-	$TBL_EXERCICES              = Database :: get_course_table(TABLE_QUIZ_TEST);
+function get_all_exercises($course_info = null, $session_id = 0, $check_publication_dates = false) {
+	$TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
 	$course_id = api_get_course_int_id();
 	
     if (!empty($course_info) && !empty($course_info['real_id'])) {
@@ -1229,11 +1229,22 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_dates =
     if ($session_id == -1) {
     	$session_id  = 0;
     }
-    if ($session_id == 0) {
-    	$conditions = array('where'=>array('active = ? AND session_id = ? AND c_id = ? '=>array('1', $session_id, $course_id)), 'order'=>'title');
+    
+    $now = api_get_utc_datetime();
+    $time_conditions = '';
+    
+    if ($check_publication_dates) {        
+        $time_conditions = " AND ((start_time <> '0000-00-00 00:00:00' AND start_time < '$now'  AND end_time <> '0000-00-00 00:00:00' AND end_time > '$now' )  OR "; //start and end are set
+        $time_conditions .= " (start_time <> '0000-00-00 00:00:00' AND start_time < '$now'  AND end_time = '0000-00-00 00:00:00') OR "; // only start is set
+        $time_conditions .= " (start_time = '0000-00-00 00:00:00'   AND end_time <> '0000-00-00 00:00:00'  AND end_time > '$now') OR   "; // only end is set
+        $time_conditions .= " (start_time = '0000-00-00 00:00:00'   AND end_time =  '0000-00-00 00:00:00'))  "; // nothing is set                           
+    }
+    
+    if ($session_id == 0) {       
+    	$conditions = array('where'=>array('active = ? AND session_id = ? AND c_id = ? '.$time_conditions => array('1', $session_id, $course_id)), 'order'=>'title');        
     } else {
         //All exercises
-    	$conditions = array('where'=>array('active = ? AND  (session_id = 0 OR session_id = ? ) AND c_id = ? ' => array('1', $session_id, $course_id)), 'order'=>'title');
+    	$conditions = array('where'=>array('active = ? AND  (session_id = 0 OR session_id = ? ) AND c_id = ? '.$time_conditions => array('1', $session_id, $course_id)), 'order'=>'title');        
     }    
     return Database::select('*',$TBL_EXERCICES, $conditions);
 }
@@ -1541,7 +1552,7 @@ function get_exercises_to_be_taken($course_code, $session_id) {
 	$result = array();
 	$now = time() + 15*24*60*60;
 	foreach($exercises as $exercise_item) {
-		if (isset($exercise_item['end_time'])  && !empty($exercise_item['end_time']) && $exercise_item['end_time'] != '0000-00-00 00:00:00' && api_strtotime($exercise_item['end_time']) < $now) {
+		if (isset($exercise_item['end_time'])  && !empty($exercise_item['end_time']) && $exercise_item['end_time'] != '0000-00-00 00:00:00' && api_strtotime($exercise_item['end_time'], 'UTC') < $now) {
 			$result[] = $exercise_item;
 		}
 	}

+ 13 - 6
main/exercice/exercise_submit.php

@@ -230,7 +230,6 @@ if ($debug) { error_log("4. Setting the exe_id $exe_id");} ;
 //var_dump($safe_lp_id.' - '.$safe_lp_item_id.' - '.$safe_lp_item_view_id);
 $exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
 
-
 if (empty($exercise_stat_info)) {
 	$total_weight = 0;
 	$questionList = $objExercise->get_validated_question_list();	
@@ -638,19 +637,27 @@ if (!empty($exercise_description)) {
 }
 echo Display::div($exercise_header, array('class'=>'exercise_header'));*/
 
+$is_visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
+if ($is_visible_return['value'] == false) {
+    echo $is_visible_return['message'];    
+    if ($origin != 'learnpath') {
+        Display :: display_footer();
+    }
+    exit;
+}
 
 $limit_time_exists = (($objExercise->start_time != '0000-00-00 00:00:00') || ($objExercise->end_time != '0000-00-00 00:00:00')) ? true : false;
 
-if ($limit_time_exists) {	
-    $exercise_start_time 	= api_strtotime($objExercise->start_time,'UTC');
-    $exercise_end_time 		= api_strtotime($objExercise->end_time,'UTC');
+if ($limit_time_exists) {	    
+    $exercise_start_time 	= api_strtotime($objExercise->start_time, 'UTC');
+    $exercise_end_time 		= api_strtotime($objExercise->end_time, 'UTC');
     $time_now 				= time();
     
     if ($objExercise->start_time != '0000-00-00 00:00:00') {
         $permission_to_start = (($time_now - $exercise_start_time) > 0) ? true : false;
     } else {
         $permission_to_start = true;
-    }         
+    }
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         if ($objExercise->end_time != '0000-00-00 00:00:00') {
             $exercise_timeover = (($time_now - $exercise_end_time) > 0) ? true : false;
@@ -1043,4 +1050,4 @@ if ($origin != 'learnpath') {
     Display :: display_footer();
 } else {
     echo '</body></html>';
-}
+}

+ 6 - 7
main/exercice/overview.php

@@ -90,17 +90,16 @@ if (!empty($attempt_list)) {
 $html .= $message;
 $exercise_url_button = Display::url($label, $exercise_url, array('class'=>'a_button blue bigger round'));
 
-if (!$objExercise->is_visible($learnpath_id, $learnpath_item_id)) {
+$visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id);
+        
+if ($visible_return['value'] == false) {
 	$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id;	
-	//$exercise_url_button = Display::url(get_lang('SeeResults'), $exercise_url, array('class'=>'a_button white bigger round no_link'));
-	if ($origin == 'learnpath') {
-		$exercise_url_button = Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $objExercise->title, $objExercise->selectAttempts()), 'warning');
-	}
-	$exercise_url_button = sprintf(get_lang('ReachedMaxAttempts'), $objExercise->title, $objExercise->selectAttempts());
+	$exercise_url_button = $visible_return['message'];    
 }
+
 $options  = Display::div('', array('class'=>'left_option'));
 if (!empty($exercise_url_button)) {
-	$options .= Display::div($exercise_url_button, array('class'=>'center_option'));
+	$options .= $exercise_url_button;
 }
 
 $attempts = get_exercise_results_by_user(api_get_user_id(), $objExercise->id, api_get_course_id(), api_get_session_id(), $learnpath_id, $learnpath_item_id, 'desc');

+ 43 - 43
main/forum/forumfunction.inc.php

@@ -1200,9 +1200,8 @@ function get_forums($id='', $course_code = '') {
     $condition_session = api_get_session_condition($session_id);
     $course_id = $course_info['real_id'];
     
-    $condition_course = " AND forum.c_id = $course_id";
-
     $forum_list = array();
+    
     if ($id == '') {
         // Student 
         // Select all the forum information of all forums (that are visible to students).
@@ -1210,14 +1209,14 @@ function get_forums($id='', $course_code = '') {
                         WHERE forum.forum_id=item_properties.ref
                         AND item_properties.visibility=1
                         AND item_properties.tool='".TOOL_FORUM."'
-                        $condition_session AND forum.c_id = $course_id
+                        $condition_session AND forum.c_id = $course_id AND item_properties.c_id = $course_id
                         ORDER BY forum.forum_order ASC";
 
         // Select the number of threads of the forums (only the threads that are visible).
         $sql2 = "SELECT count(*) AS number_of_threads, threads.forum_id FROM $table_threads threads, ".$table_item_property." item_properties
                         WHERE threads.thread_id=item_properties.ref
                         AND item_properties.visibility=1
-                        AND item_properties.tool='".TOOL_FORUM_THREAD."' AND threads.c_id = $course_id
+                        AND item_properties.tool='".TOOL_FORUM_THREAD."' AND threads.c_id = $course_id AND item_properties.c_id = $course_id
                         GROUP BY threads.forum_id";
 
         // Select the number of posts of the forum (post that are visible and that are in a thread that is visible).
@@ -1226,7 +1225,7 @@ function get_forums($id='', $course_code = '') {
                         AND posts.thread_id=threads.thread_id
                         AND threads.thread_id=item_properties.ref
                         AND item_properties.visibility=1
-                        AND item_properties.tool='".TOOL_FORUM_THREAD."' AND posts.c_id = $course_id
+                        AND item_properties.tool='".TOOL_FORUM_THREAD."' AND threads.c_id = $course_id AND posts.c_id = $course_id AND item_properties.c_id = $course_id
                         GROUP BY threads.forum_id";
 
         //-------------- Course Admin  -----------------//
@@ -1236,14 +1235,14 @@ function get_forums($id='', $course_code = '') {
                             WHERE forum.forum_id=item_properties.ref
                             AND item_properties.visibility<>2
                             AND item_properties.tool='".TOOL_FORUM."'
-                            $condition_session AND forum.c_id = $course_id
+                            $condition_session AND forum.c_id = $course_id AND item_properties.c_id = $course_id
                             ORDER BY forum_order ASC";
             //echo $sql.'<hr />';
             // Select the number of threads of the forums (only the threads that are not deleted).
             $sql2 = "SELECT count(*) AS number_of_threads, threads.forum_id FROM $table_threads threads, ".$table_item_property." item_properties
                             WHERE threads.thread_id=item_properties.ref
                             AND item_properties.visibility<>2
-                            AND item_properties.tool='".TOOL_FORUM_THREAD."' AND threads.c_id = $course_id
+                            AND item_properties.tool='".TOOL_FORUM_THREAD."' AND threads.c_id = $course_id AND item_properties.c_id = $course_id
                             GROUP BY threads.forum_id";
             //echo $sql2.'<hr />';
             // Select the number of posts of the forum.
@@ -1251,47 +1250,47 @@ function get_forums($id='', $course_code = '') {
                             WHERE posts.thread_id=threads.thread_id
                             AND threads.thread_id=item_properties.ref
                             AND item_properties.visibility=1
-                            AND item_properties.tool='".TOOL_FORUM_THREAD."' AND posts.c_id = $course_id
+                            AND item_properties.tool='".TOOL_FORUM_THREAD."' AND posts.c_id = $course_id AND threads.c_id = $course_id AND item_properties.c_id = $course_id
                             GROUP BY threads.forum_id";
             //echo $sql3.'<hr />';
         }
-    }
-    
-    // GETTING ONE SPECIFIC FORUM 
+    } else {
+        // GETTING ONE SPECIFIC FORUM 
     
-    // We could do the splitup into student and course admin also but we want to have as much as information about a certain forum as possible
-    // so we do not take too much information into account. This function (or this section of the function) is namely used to fill the forms
-    // when editing a forum (and for the moment it is the only place where we use this part of the function)
-        else {
-            // Select all the forum information of the given forum (that is not deleted).
-            $sql = "SELECT * FROM $table_forums forum , ".$table_item_property." item_properties
-                                WHERE forum.forum_id=item_properties.ref
-                                AND forum_id='".Database::escape_string($id)."'
-                                AND item_properties.visibility<>2
-                                AND item_properties.tool='".TOOL_FORUM."'
-                                $condition_session  AND forum.c_id = $course_id
-                                ORDER BY forum_order ASC";
-
-            // Select the number of threads of the forum.
-            $sql2 = "SELECT count(*) AS number_of_threads, forum_id FROM $table_threads
-						WHERE forum_id=".Database::escape_string($id)." AND c_id = $course_id
-                    	GROUP BY forum_id";
+        // We could do the splitup into student and course admin also but we want to have as much as information about a certain forum as possible
+        // so we do not take too much information into account. This function (or this section of the function) is namely used to fill the forms
+        // when editing a forum (and for the moment it is the only place where we use this part of the function)
+        // 
+        // Select all the forum information of the given forum (that is not deleted).
+        $sql = "SELECT * FROM $table_forums forum , ".$table_item_property." item_properties
+                            WHERE forum.forum_id=item_properties.ref
+                            AND forum_id='".Database::escape_string($id)."'
+                            AND item_properties.visibility<>2
+                            AND item_properties.tool='".TOOL_FORUM."'
+                            $condition_session  AND forum.c_id = $course_id AND item_properties.c_id = $course_id
+                            ORDER BY forum_order ASC";
 
-            // Select the number of posts of the forum.
-            $sql3 = "SELECT count(*) AS number_of_posts, forum_id FROM $table_posts
-                                WHERE forum_id=".Database::escape_string($id)."  AND c_id = $course_id
-                                GROUP BY forum_id";
-
-            // Select the last post and the poster (note: this is probably no longer needed).
-            $sql4 = "SELECT  post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname
-                                FROM $table_posts post, $table_users users
-                                WHERE forum_id=".Database::escape_string($id)."
-                                AND post.poster_id=users.user_id  AND post.c_id = $course_id
-                                GROUP BY post.forum_id
-                                ORDER BY post.post_id ASC";
-        }
+        // Select the number of threads of the forum.
+        $sql2 = "SELECT count(*) AS number_of_threads, forum_id FROM $table_threads
+                    WHERE forum_id=".Database::escape_string($id)." AND c_id = $course_id
+                    GROUP BY forum_id";
+
+        // Select the number of posts of the forum.
+        $sql3 = "SELECT count(*) AS number_of_posts, forum_id FROM $table_posts
+                            WHERE forum_id=".Database::escape_string($id)."  AND c_id = $course_id
+                            GROUP BY forum_id";
+
+        // Select the last post and the poster (note: this is probably no longer needed).
+        $sql4 = "SELECT  post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname
+                            FROM $table_posts post, $table_users users
+                            WHERE forum_id=".Database::escape_string($id)."
+                            AND post.poster_id=users.user_id  AND post.c_id = $course_id 
+                            GROUP BY post.forum_id
+                            ORDER BY post.post_id ASC";
+    }
 
     // Handling all the forum information.
+    
     $result = Database::query($sql);
     while ($row = Database::fetch_array($result)) {
         if ($id == '') {
@@ -2679,14 +2678,15 @@ function store_edit_post($values) {
  * This function displays the firstname and lastname of the user as a link to the user tool.
  *
  * @param string names
+ * @ in_title : title tootip
  * @return string HTML
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @version february 2006, dokeos 1.8
  */
-function display_user_link($user_id, $name, $origin = '') {
+function display_user_link($user_id, $name, $origin = '', $in_title = '') {
     if ($user_id != 0) {
-        return '<a href="../user/userInfo.php?uInfo='.$user_id.'" '. (!empty($origin)? 'target="_self"': '') .'>'.$name.'</a>';
+        return '<a title="'.api_htmlentities($in_title, ENT_QUOTES).'" href="../user/userInfo.php?uInfo='.$user_id.'" '. (!empty($origin)? 'target="_self"': '') .'>'.$name.'</a>';
     } else {
         return $name.' ('.get_lang('Anonymous').')';
     }

+ 2 - 2
main/forum/iframe_thread.php

@@ -105,13 +105,13 @@ echo "<table width=\"100%\" cellspacing=\"5\" border=\"0\">";
 while ($row = Database::fetch_array($result)) {
     echo "<tr>";
     echo "<td rowspan=\"2\" class=\"forum_message_left\">";
-    $username = $row['username'];
+    $username = api_htmlentities(sprintf(get_lang('LoginX'), $row['username']), ENT_QUOTES);
     if ($row['user_id']=='0') {
         $name = $row['poster_name'];
     } else {
         $name = api_get_person_name($row['firstname'], $row['lastname']);
     }
-    echo $name." ($username)<br />";
+    echo Display::tag('span', $name, array('title'=>$username)).'<br />";
     echo api_convert_and_format_date($row['post_date']).'<br /><br />';
 
     echo "</td>";

+ 3 - 3
main/forum/index.php

@@ -401,13 +401,13 @@ if (is_array($forum_categories_list)) {
                         } else {
                             $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
                             $poster_id = $forum['last_poster_id'];
-                            $userinfo = api_get_user_info($poster_id);  // 
-                            $username = " (".$userinfo['username'].")";  // 
+                            $userinfo = api_get_user_info($poster_id);
+                            $username = sprintf(get_lang('LoginX'), $userinfo['username']);
                         }
                         echo '<td nowrap="nowrap">';
 
                         if (!empty($forum['last_post_id'])) {
-                            echo api_convert_and_format_date($forum['last_post_date']).'<br /> '.get_lang('By').' '.display_user_link($poster_id, $name.$username); // 
+                            echo api_convert_and_format_date($forum['last_post_date']).'<br /> '.get_lang('By').' '.display_user_link($poster_id, $name, '', $username);
                         }
                         echo '</td>';
                         echo '<td nowrap="nowrap" align="center">';

+ 9 - 9
main/forum/viewforum.php

@@ -377,11 +377,11 @@ if (is_array($threads)) {
             echo '<td>'.$row['thread_views'].'</td>';
             // display the author name
             $tab_poster_info = api_get_user_info($row['user_id']);
-            $poster_username = " (".$tab_poster_info['username'].")";
+            $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
             if ($origin != 'learnpath') {
-                echo '<td>'.display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']).$poster_username).'</td>';
+                echo '<td>'.display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']), '', $poster_username).'</td>';
             } else {
-                echo '<td>'.api_get_person_name($row['firstname'], $row['lastname']).'$poster_username</td>';
+                echo '<td>'.Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title"=>api_htmlentities($poster_username, ENT_QUOTES))).'</td>';
             }            
             // display the last post name
 //            if ($row['user_id'] == '0') {
@@ -396,25 +396,25 @@ if (is_array($threads)) {
             } else {
                 $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']);
                 $tab_last_poster_info = api_get_user_info($row['last_poster_user_id']);
-                $last_poster_username = " (".$tab_last_poster_info['username'].")";
+                $last_poster_username = sprintf(get_lang('LoginX'), $tab_last_poster_info['username']);
             }
             // If the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread.
             if (($row['visible'] == '1' OR api_is_allowed_to_edit(false, true)) && $origin != 'learnpath') {
-                $last_post = api_convert_and_format_date($row['thread_date']).' '.get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name.$last_poster_username);
+                $last_post = api_convert_and_format_date($row['thread_date']).' '.get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name, '', $last_poster_username);
             } elseif ($origin != 'learnpath') {
                 $last_post_sql = "SELECT post.*, user.firstname, user.lastname, user.username FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' AND post.c_id=".api_get_course_int_id()." ORDER BY post_id DESC";
                 $last_post_result = Database::query($last_post_sql);
                 $last_post_row = Database::fetch_array($last_post_result);
                 $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']);
-                $last_post_info_username = " (".$last_post_row['username'].")";
-                $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name.$last_post_info_username);
+                $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']);
+                $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name, '', $last_post_info_username);
             } else {
                 $last_post_sql = "SELECT post.*, user.firstname, user.lastname, user.username FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' AND post.c_id=".api_get_course_int_id()." ORDER BY post_id DESC";
                 $last_post_result = Database::query($last_post_sql);
                 $last_post_row = Database::fetch_array($last_post_result);
-                $last_post_info_username = " (".$last_post_row['username'].")";
+                $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']);
                 $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']);
-                $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.$name.$last_post_info_username;
+                $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.Display::tag('span', $name, array("title"=>api_htmlentities($last_post_info_username, ENT_QUOTES)));
             }
 
             echo '<td>'.$last_post.'</td>';

+ 5 - 4
main/forum/viewforumcategory.php

@@ -26,7 +26,7 @@
 $language_file = 'forum';
 
 // Including the global initialization file.
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
 
 $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
     $(document).ready(function(){ $(\'.hide-me\').slideUp() });
@@ -54,7 +54,7 @@ api_protect_course_script(true);
 // Including additional library scripts.
 require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
 require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
-$nameTools=get_lang('ToolForum');
+$nameTools = get_lang('ToolForum');
 
 // Including necessary files
 require 'forumconfig.inc.php';
@@ -203,7 +203,7 @@ if ($action_forums != 'add') {
     // Step 3: The interim headers (for the forum).
     echo '<tr class="forum_header">';
     echo '<td colspan="2">'.get_lang('Forum').'</td>';
-    echo '<td>'.get_lang('Topics').'</td>';
+    echo '<td>'.get_lang('Threads').'</td>';
     echo '<td>'.get_lang('Posts').'</td>';
     echo '<td>'.get_lang('LastPosts').'</td>';
     echo '<td>'.get_lang('Actions').'</td>';
@@ -302,6 +302,7 @@ if ($action_forums != 'add') {
                 //$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
                 // the number of topics and posts
                 $my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : '';
+                
                 $my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : '';
                 echo '<td>'.$my_number_threads.'</td>';
                 echo '<td>'.$my_number_posts.'</td>';
@@ -350,4 +351,4 @@ if ($action_forums != 'add') {
 /* FOOTER */
 if ($origin != 'learnpath') {
     Display :: display_footer();
-}
+}

+ 3 - 3
main/forum/viewthread_flat.inc.php

@@ -38,15 +38,15 @@ if (isset($current_thread['thread_id'])){
         } else {
             $name = api_get_person_name($row['firstname'], $row['lastname']);
         }
-        $username = $row['username'];   // 
+        $username = sprintf(get_lang('LoginX'), $row['username']);
         
         if ($origin!='learnpath') {
             if (api_get_course_setting('allow_user_image_forum')) {
                 echo '<br />'.display_user_image($row['user_id'],$name).'<br />';
             }
-            echo display_user_link($row['user_id'], $name." ($username)").'<br />';
+            echo display_user_link($row['user_id'], $name, '', $username).'<br />';
         } else {
-            echo $name. ' ('.$username.')<br />';
+            echo Display::tag('span', $name, array('title'=>api_htmlentities($username, ENT_QUOTES))).'<br />';
         }
 
         $group_id = api_get_group_id();

+ 2 - 2
main/forum/viewthread_nested.inc.php

@@ -48,7 +48,7 @@ foreach ($rows as $post) {
     echo "<tr>";
     echo "<td rowspan=\"3\" class=\"$leftclass\">";
 
-    $username = $post['username']; // 
+    $username = sprintf(get_lang('LoginX'), $post['username']);
     if ($post['user_id']=='0') {
         $name=$post['poster_name'];
     } else {
@@ -57,7 +57,7 @@ foreach ($rows as $post) {
     if (api_get_course_setting('allow_user_image_forum')) {
         echo '<br />'.display_user_image($post['user_id'],$name,$origin).'<br />';
     }
-    echo display_user_link($post['user_id'], $name." ($username)", $origin)."<br />";
+    echo display_user_link($post['user_id'], $name, $origin, $username)."<br />";
     echo api_convert_and_format_date($post['post_date']).'<br /><br />';
     // get attach id
     $attachment_list=get_attachment($post['post_id']);

+ 2 - 2
main/forum/viewthread_threaded.inc.php

@@ -158,7 +158,7 @@ unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id
 echo "<table width=\"100%\"  class=\"forum_table\"  cellspacing=\"5\" border=\"0\">";
 echo "<tr>";
 echo "<td rowspan=\"3\" class=\"$leftclass\">";
-$username = $rows[$display_post_id]['username'];
+$username = sprintf(get_lang('LoginX'), $rows[$display_post_id]['username']);
 if ($rows[$display_post_id]['user_id']=='0') {
     $name=prepare4display($rows[$display_post_id]['poster_name']);
 } else {
@@ -166,7 +166,7 @@ if ($rows[$display_post_id]['user_id']=='0') {
 }
 
 if (api_get_course_setting('allow_user_image_forum')) {echo '<br />'.display_user_image($rows[$display_post_id]['user_id'],$name, $origin).'<br />';	}
-echo display_user_link($rows[$display_post_id]['user_id'], $name." ($username)", $origin)."<br />";
+echo display_user_link($rows[$display_post_id]['user_id'], $name, $origin, $username)."<br />";
 echo api_convert_and_format_date($rows[$display_post_id]['post_date']).'<br /><br />';
 // get attach id
 $attachment_list=get_attachment($display_post_id);

+ 2 - 2
main/gradebook/lib/gradebook_data_generator.class.php

@@ -164,7 +164,7 @@ class GradebookDataGenerator
 		} else {
 		    $date = $item1->get_date();
             if (!empty($date)) {
-			 $timestamp1 = api_strtotime($date);
+			 $timestamp1 = api_strtotime($date, 'UTC');
             } else {
                 $timestamp1 = null;
             }
@@ -173,7 +173,7 @@ class GradebookDataGenerator
 		if(is_int($item2->get_date())) {
 			$timestamp2 = $item2->get_date();
 		} else {
-			$timestamp2 = api_strtotime($item2->get_date());
+			$timestamp2 = api_strtotime($item2->get_date(), 'UTC');
 		}
 		
 		if ($timestamp1 == $timestamp2) {

+ 7 - 8
main/inc/ajax/course_home.ajax.php

@@ -7,7 +7,6 @@
 $action = $_GET['a'];
 $now    = time();
 
-
 switch ($action) {
 	case 'set_visibility':
 		require_once '../global.inc.php';
@@ -174,13 +173,13 @@ switch ($action) {
                 
                 //Checking LP publicated and expired_on dates
                 if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {                        
-                    if ($now < api_strtotime($lp_item['publicated_on'])) {                        
+                    if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {                        
                         continue;
                     }
                 }
                 
                 if (!empty($lp_item['expired_on']) && $lp_item['expired_on'] != '0000-00-00 00:00:00') {
-                    if ($now > api_strtotime($lp_item['expired_on'])) {
+                    if ($now > api_strtotime($lp_item['expired_on'], 'UTC')) {
                         continue;
                     }
                 }
@@ -297,8 +296,8 @@ switch ($action) {
                  //Checking LP publicated and expired_on dates
                 
                 if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {
-                    $week_data = date('Y', api_strtotime($lp_item['publicated_on'])).' - '.get_week_from_day($lp_item['publicated_on']);                   
-                    if ($now < api_strtotime($lp_item['publicated_on'])) {                        
+                    $week_data = date('Y', api_strtotime($lp_item['publicated_on'], 'UTC')).' - '.get_week_from_day($lp_item['publicated_on']);                   
+                    if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {                        
                         continue;
                     }
                 } else {
@@ -306,7 +305,7 @@ switch ($action) {
                 }
                 
                 if (!empty($lp_item['expired_on']) && $lp_item['expired_on'] != '0000-00-00 00:00:00') {
-                    if ($now > api_strtotime($lp_item['expired_on'])) {
+                    if ($now > api_strtotime($lp_item['expired_on'], 'UTC')) {
                         continue;
                     }
                 }
@@ -420,12 +419,12 @@ switch ($action) {
                 
                  //Checking LP publicated and expired_on dates
                 if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') {                        
-                    if ($now < api_strtotime($lp_item['publicated_on'])) {                        
+                    if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) {                        
                         continue;
                     }
                 }                
                 if (!empty($lp_item['expired_on']) && $lp_item['expired_on'] != '0000-00-00 00:00:00') {
-                    if ($now > api_strtotime($lp_item['expired_on'])) {
+                    if ($now > api_strtotime($lp_item['expired_on'], 'UTC')) {
                         continue;
                     }
                 }                

+ 1 - 1
main/inc/footer.inc.php

@@ -53,7 +53,7 @@ echo '<div class="copyright">';
 		echo '<div align="right">', get_lang('Manager'), ' : ', Display::encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))).'</div>';
 	}
 	echo '<div align="right">'.get_lang('Platform').' <a href="', $_configuration['software_url'], '" target="_blank">', $_configuration['software_name'], ' ', $_configuration['system_version'], '</a>';
-	echo '&copy; ', date('Y');
+	echo ' &copy; ', date('Y');
 	echo '</div>';
 	
 echo '</div>'; //copyright div

+ 5 - 23
main/inc/lib/attendance.lib.php

@@ -941,8 +941,7 @@ class Attendance
 		$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
 		$attendance_id = intval($attendance_id);		
         $course_id = api_get_course_int_id();
-		$sql = "SELECT * FROM $tbl_attendance_calendar WHERE c_id = $course_id AND attendance_id = '$attendance_id' ";		
-		$filter_where = '';
+		$sql = "SELECT * FROM $tbl_attendance_calendar WHERE c_id = $course_id AND attendance_id = '$attendance_id' ";				
 		if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) {
 			$type = 'all';
 		}		
@@ -976,10 +975,10 @@ class Attendance
                 $row['date_time']       = api_get_local_time($row['date_time']);
                 $row['date']            = api_format_date($row['date_time'], DATE_FORMAT_SHORT);
                 $row['time']            = api_format_date($row['date_time'], TIME_NO_SEC_FORMAT);              
-                if ($type == 'today') {
-                    if (date('d-m-Y', api_strtotime($row['date_time'])) == date('d-m-Y', api_strtotime(api_get_local_time()))) {
+                if ($type == 'today') {                    
+                    if (date('d-m-Y', api_strtotime($row['date_time'], 'UTC')) == date('d-m-Y', time())) {
                         $data[] = $row;                        
-                    }                
+                    }
                 } else {
                 	$data[] = $row;
                 }
@@ -1147,24 +1146,7 @@ class Attendance
                         $this->set_date_time($datetimezone);
                         $res = $this->attendance_calendar_add($attendance_id);
                         $j++;
-                    }
-                
-                    //$next_start = $this->add_month($start_date);
-                    /*
-                    $next_start = api_strtotime(api_get_utc_date_add(api_get_utc_datetime($start_date), 0 , 1),'UTC');
-                    error_log('22-->$start_date '.$start_date);
-                    error_log('$next_start '.$next_start);
-                    error_log('$end_date '.$end_date);
-                    while($next_start <= $end_date) {
-                        //$datetime = date('Y-m-d H:i:s', $next_start);
-                        $datetimezone = api_get_utc_datetime($next_start);
-                        error_log('$datetimezone n loop '.$datetimezone);
-                        $this->set_date_time($datetimezone);
-                        $res = $this->attendance_calendar_add($attendance_id);
-                        //$next_start = $this->add_month($next_start);
-                        $next_start = api_strtotime(api_get_utc_date_add(api_get_utc_datetime($next_start), 0 , 1),'UTC');
-                        error_log('$next_start in loop '.$next_start);
-                    }*/
+                    }                
                     break;
             }
         }

+ 25 - 19
main/inc/lib/blog.lib.php

@@ -758,7 +758,8 @@ class Blog {
 					echo ' "> '.$file_name_array['filename'].' </a><br />';
 					echo '</span>';
 				}
-				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . api_get_person_name($blog_post['firstname'], $blog_post['lastname']) . ' ('.$blog_post['username'].') - <a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'."\n";
+				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
+				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'."\n";
 				echo '</div>';
 			}
 		} else {
@@ -883,8 +884,8 @@ class Blog {
 			echo '</span>';
 			echo '<br />';
 		}
-
-		echo '<span class="blogpost_info">'.get_lang('Author').': ' .api_get_person_name($blog_post['firstname'], $blog_post['lastname']).' ('.$blog_post['username'].') - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
+        $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
+		echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
 		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
 		echo '</div>';
 
@@ -1095,7 +1096,8 @@ class Blog {
 					echo $file_name_array['comment'];
 					echo '</span><br />';
 				}
-				echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.api_get_person_name($comment['firstname'], $comment['lastname']).' ('.$comment['username'].') - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);				
+				echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
 				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
 			echo '</div>';
 
@@ -1425,7 +1427,7 @@ class Blog {
 		
 		$course_id = api_get_course_int_id();
 
-		$sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, task.description, task.system_task, task.blog_id, task.task_id 
+		$sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id 
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
 				INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
@@ -1442,9 +1444,11 @@ class Blog {
 			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
 			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&amp;blog_id=' . $assignment['blog_id'] . '&amp;do=delete&amp;task_id=' . $assignment['task_id'];
 			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
-
+			
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
+            
 			echo	'<tr class="' . $css_class . '" valign="top">',
-						 '<td width="240">' . api_get_person_name($assignment['firstname'], $assignment['lastname']) . '</td>',
+						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
 						 '<td>'.stripslashes($assignment['title']) . '</td>',
 						 '<td>'.stripslashes($assignment['description']) . '</td>',
 						 '<td>' . $assignment['target_date'] . '</td>',
@@ -1668,9 +1672,11 @@ class Blog {
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
 		$result = Database::query($sql);
 		$select_user_list = '<select name="task_user_id">';
+		
 		while($user = Database::fetch_array($result))
 		{
-			$select_user_list .= '<option value="' . $user['user_id'] . '">' . api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') </option>';
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $user['username']), ENT_QUOTES);		    
+			$select_user_list .= '<option title="'.$username.'" value="' . $user['user_id'] . '">' . api_get_person_name($user['firstname'], $user['lastname']).'</option>';
 		}
 		$select_user_list .= '</select>';
 
@@ -1818,7 +1824,7 @@ class Blog {
 
 		// Get users in this blog / make select list of it
 		$sql = "
-			SELECT user.user_id, user.firstname, user.lastname
+			SELECT user.user_id, user.firstname, user.lastname, user.username
 			FROM $tbl_users user
 			INNER JOIN $tbl_blogs_rel_user blogs_rel_user ON user.user_id = blogs_rel_user.user_id
 			WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
@@ -1826,7 +1832,8 @@ class Blog {
 
 		$select_user_list = '<select name="task_user_id">';
 		while($user = Database::fetch_array($result)) {
-			$select_user_list .= '<option ' . (($user_id == $user['user_id']) ? 'selected="selected "' : ' ') . 'value="' . $user['user_id'] . '">' . api_get_person_name($user['firstname'], $user['lastname']) . '</option>';
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $user['username']), ENT_QUOTES);
+			$select_user_list .= '<option title="'.$username.'"' . (($user_id == $user['user_id']) ? 'selected="selected "' : ' ') . 'value="' . $user['user_id'] . '">' . api_get_person_name($user['firstname'], $user['lastname']) . '</option>';
 		}
 		
 		$select_user_list .= '</select>';
@@ -2040,7 +2047,8 @@ class Blog {
 
 		if(Database::num_rows($result) > 0) {
 			while($blog_post = Database::fetch_array($result)) {
-				echo '<a href="blog.php?action=execute_task&amp;blog_id=' . $blog_id . '&amp;task_id=' . $task_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(api_get_person_name($blog_post['firstname'], $blog_post['lastname']).' ('.$blog_post['username'].')') . '<br />';
+			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
+				echo '<a href="blog.php?action=execute_task&amp;blog_id=' . $blog_id . '&amp;task_id=' . $task_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
 			}
 		} else 
 			echo get_lang('NoArticles');
@@ -2136,7 +2144,6 @@ class Blog {
 			$column_header[] = array (get_lang('LastName'), true, '');
 			$column_header[] = array (get_lang('FirstName'), true, '');
 		}
-		$column_header[] = array (get_lang('LoginName'), true, '');
 		$column_header[] = array (get_lang('Email'), false, '');
 		$column_header[] = array (get_lang('Register'), false, '');
 		
@@ -2159,14 +2166,14 @@ class Blog {
 				$a_infosUser = UserManager :: get_user_info_by_id($user['user_id']);
 				$row = array ();
 				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.(($_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
+				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
 				if ($is_western_name_order) {
 					$row[] = $a_infosUser["firstname"];
-					$row[] = $a_infosUser["lastname"];
+					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
 				} else {
-					$row[] = $a_infosUser["lastname"];
+					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
 					$row[] = $a_infosUser["firstname"];
 				}
-				$row[] = $a_infosUser["username"];
 				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
 				
 				//Link to register users
@@ -2232,7 +2239,6 @@ class Blog {
 			$column_header[] = array (get_lang('LastName'), true, '');
 			$column_header[] = array (get_lang('FirstName'), true, '');
 		}
-		$column_header[] = array (get_lang('LoginName'), true, '');
 		$column_header[] = array (get_lang('Email'), false, '');
 		$column_header[] = array (get_lang('TaskManager'), true, '');
 		$column_header[] = array (get_lang('UnRegister'), false, '');
@@ -2253,14 +2259,14 @@ class Blog {
 		while($myrow = Database::fetch_array($sql_result)) {
 			$row = array ();
 			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.(($_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
+			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
 			if ($is_western_name_order) {
 				$row[] = $myrow["firstname"];
-				$row[] = $myrow["lastname"];
+				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
 			} else {
-				$row[] = $myrow["lastname"];
+				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
 				$row[] = $myrow["firstname"];
 			}
-			$row[] = $myrow["username"];
 			$row[] = Display::icon_mailto_link($myrow["email"]);
 
 			$sql = "SELECT bt.title task

+ 2 - 2
main/inc/lib/chat.lib.php

@@ -93,7 +93,7 @@ class Chat extends Model {
 								'id'		=> $chat['id']								
 							);
 				$items[$from_user_id][] = $item;				
-				$_SESSION['openChatBoxes'][$from_user_id] = api_strtotime($chat['sent']);				
+				$_SESSION['openChatBoxes'][$from_user_id] = api_strtotime($chat['sent'],'UTC');				
 			}
 			$_SESSION['chatHistory'][$from_user_id][] = $item;					
 			
@@ -106,7 +106,7 @@ class Chat extends Model {
 					$time = api_convert_and_format_date($time, DATE_TIME_FORMAT_SHORT_TIME_FIRST);
 					$message = sprintf(get_lang('SentAtX'), $time);
 					
-					if ($now > 180) {						
+					if ($now > 180) {		
 						$item = array('s' => '2', 'f' => $user_id, 'm' => $message);			
 						
 						if (isset($_SESSION['chatHistory'][$user_id])) {

+ 1 - 1
main/inc/lib/course.lib.php

@@ -3505,7 +3505,7 @@ class CourseManager {
      * @param id    url id
      * 
      **/    
-    public function update_course_ranking($course_id = null, $session_id = null, $url_id = null, $points_to_add = null, $add_access = true, $add_user = true) {        
+    public static function update_course_ranking($course_id = null, $session_id = null, $url_id = null, $points_to_add = null, $add_access = true, $add_user = true) {        
         //Course catalog stats modifications see #4191        
         $table_course_ranking       = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
                 

+ 3 - 3
main/inc/lib/database.lib.php

@@ -1170,7 +1170,7 @@ class Database {
         }
 
         $sql    = "SELECT $clean_columns FROM $table_name $conditions";
-	//echo $sql.'<br />';
+        //echo $sql.'<br />';
         $result = self::query($sql);
         $array = array();
         //if (self::num_rows($result) > 0 ) {
@@ -1194,7 +1194,7 @@ class Database {
      * @param   array
      * @todo lot of stuff to do here
     */
-    public function parse_conditions($conditions) {        
+    static function parse_conditions($conditions) {        
         if (empty($conditions)) {
             return '';
         }
@@ -1286,7 +1286,7 @@ class Database {
         return $return_value;
     }
 
-    private function parse_where_conditions($coditions) {
+    public static function parse_where_conditions($coditions) {
         return self::parse_conditions(array('where'=>$coditions));
     }
 

+ 3 - 3
main/inc/lib/database.mysqli.lib.php

@@ -1076,7 +1076,7 @@ class Database {
      * @todo lot of stuff to do here
     */
 
-    public static function select($columns = '*' , $table_name,  $conditions = array(), $type_result = 'all', $option = 'ASSOC') {
+    public static function select($columns, $table_name,  $conditions = array(), $type_result = 'all', $option = 'ASSOC') {
         $conditions = self::parse_conditions($conditions);
 
         //@todo we could do a describe here to check the columns ...
@@ -1116,7 +1116,7 @@ class Database {
      * @param   array
      * @todo lot of stuff to do here
     */
-    private function parse_conditions($conditions) {
+    static function parse_conditions($conditions) {
         if (empty($conditions)) {
             return '';
         }
@@ -1205,7 +1205,7 @@ class Database {
         return $return_value;
     }
 
-    private function parse_where_conditions($coditions){
+    public static function parse_where_conditions($coditions){
         return self::parse_conditions(array('where'=>$coditions));
     }
 

+ 9 - 10
main/inc/lib/glossary.lib.php

@@ -307,10 +307,7 @@ class GlossaryManager {
 			//$table->set_header(0, '', false);
 			$table->set_header(0, get_lang('TermName'), true);
 			$table->set_header(1, get_lang('TermDefinition'), true);			
-			if (api_is_allowed_to_edit(null,true)) {
-			    
-			    /*$table->set_header(2, get_lang('CreationDate'), false);
-                $table->set_header(3, get_lang('UpdateDate'), false);*/            
+			if (api_is_allowed_to_edit(null,true)) {			         
 				$table->set_header(2, get_lang('Actions'), false, 'width=90px');
 				$table->set_column_filter(2, array('GlossaryManager','actions_filter'));
 			}
@@ -448,19 +445,21 @@ class GlossaryManager {
 	 * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
 	 * @version januari 2009, dokeos 1.8.6
 	 */
-	function actions_filter($glossary_id, $url_params, $row) {   
+	function actions_filter($glossary_id, $url_params, $row) {           
 		$glossary_id = $row[2];
 		$return = '<a href="'.api_get_self().'?action=edit_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
 		$glossary_data = GlossaryManager::get_glossary_information($glossary_id);		
+        
 		$glossary_term = $glossary_data['glossary_title'];
 
-		$return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>';
-		
 		if (api_is_allowed_to_edit(null, true)) {
-		    if ($glossary_data['session_id'] != api_get_session_id()) {
-		        $return  = get_lang('EditionNotAvailableFromSession');
-		    }
+		    if ($glossary_data['session_id'] == api_get_session_id()) {
+                $return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>';
+		    } else {
+                $return  = get_lang('EditionNotAvailableFromSession');
+            }
 		}
+        
 		return $return;
 	}
 

BIN
main/inc/lib/javascript/chosen/chosen-sprite.png


+ 85 - 62
main/inc/lib/javascript/chosen/chosen.css

@@ -23,29 +23,32 @@
 
 /* @group Single Chosen */
 .chzn-container-single .chzn-single {
-  background-color: #fff;
-  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white));
-  background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%);
-  background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%);
-  background-image: -o-linear-gradient(top, #eeeeee 0%,#ffffff 50%);
-  background-image: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 50%);
+  background-color: #ffffff;
+  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #f4f4f4), color-stop(0.48, #eeeeee), color-stop(0.5, #f6f6f6), color-stop(0.8, #ffffff));
+  background-image: -webkit-linear-gradient(center bottom, #f4f4f4 0%, #eeeeee 48%, #f6f6f6 50%, #ffffff 80%);
+  background-image: -moz-linear-gradient(center bottom, #f4f4f4 0%, #eeeeee 48%, #f6f6f6 50%, #ffffff 80%);
+  background-image: -o-linear-gradient(top, #f4f4f4 0%, #eeeeee 48%, #f6f6f6 50%, #ffffff 80%);
+  background-image: -ms-linear-gradient(top, #f4f4f4 0%, #eeeeee 48%, #f6f6f6 50%, #ffffff 80%);
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 );
-  background-image: linear-gradient(top, #eeeeee 0%,#ffffff 50%);
-  -webkit-border-radius: 4px;
-  -moz-border-radius   : 4px;
-  border-radius        : 4px;
+  background-image: linear-gradient(top, #f4f4f4 0%, #eeeeee 48%, #f6f6f6 50%, #ffffff 80%);
+  -webkit-border-radius: 5px;
+  -moz-border-radius   : 5px;
+  border-radius        : 5px;
   -moz-background-clip   : padding;
   -webkit-background-clip: padding-box;
   background-clip        : padding-box;
-  border: 1px solid #aaa;
+  border: 1px solid #aaaaaa;
+  -webkit-box-shadow: 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
+  -moz-box-shadow   : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
+  box-shadow        : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
   display: block;
   overflow: hidden;
   white-space: nowrap;
   position: relative;
-  height: 26px;
-  line-height: 26px;
+  height: 23px;
+  line-height: 24px;
   padding: 0 0 0 8px;
-  color: #444;
+  color: #444444;
   text-decoration: none;
 }
 .chzn-container-single .chzn-single span {
@@ -61,7 +64,7 @@
   display: block;
   position: absolute;
   right: 26px;
-  top: 8px;
+  top: 6px;
   width: 12px;
   height: 13px;
   font-size: 1px;
@@ -71,21 +74,6 @@
   background-position: right -11px;
 }
 .chzn-container-single .chzn-single div {
-  -webkit-border-radius: 0 4px 4px 0;
-  -moz-border-radius   : 0 4px 4px 0;
-  border-radius        : 0 4px 4px 0;
-  -moz-background-clip   : padding;
-  -webkit-background-clip: padding-box;
-  background-clip        : padding-box;
-  background: #ccc;
-  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
-  background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
-  background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
-  background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
-  background-image: -ms-linear-gradient(top, #cccccc 0%,#eeeeee 60%);
-  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 );
-  background-image: linear-gradient(top, #cccccc 0%,#eeeeee 60%);
-  border-left: 1px solid #aaa;
   position: absolute;
   right: 0;
   top: 0;
@@ -94,7 +82,7 @@
   width: 18px;
 }
 .chzn-container-single .chzn-single div b {
-  background: url('chosen-sprite.png') no-repeat 0 1px;
+  background: url('chosen-sprite.png') no-repeat 0 0;
   display: block;
   width: 100%;
   height: 100%;
@@ -143,9 +131,9 @@
   background-image: -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
   background-image: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
   background-image: -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
-  background-image: -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+  background-image: -ms-linear-gradient(top, #ffffff 85%, #eeeeee 99%);
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
-  background-image: linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+  background-image: linear-gradient(top, #ffffff 85%, #eeeeee 99%);
   border: 1px solid #aaa;
   margin: 0;
   padding: 0;
@@ -168,6 +156,9 @@
   color: #666;
   background: transparent !important;
   border: 0 !important;
+  font-family: sans-serif;
+  font-size: 100%;
+  height: 15px;
   padding: 5px;
   margin: 1px 0;
   outline: 0;
@@ -187,17 +178,20 @@
   -webkit-background-clip: padding-box;
   background-clip        : padding-box;
   background-color: #e4e4e4;
-  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #e4e4e4), color-stop(0.7, #eeeeee));
-  background-image: -webkit-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
-  background-image: -moz-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
-  background-image: -o-linear-gradient(bottom, #e4e4e4 0%, #eeeeee 70%);
-  background-image: -ms-linear-gradient(top, #e4e4e4 0%,#eeeeee 70%);
-  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e4e4e4', endColorstr='#eeeeee',GradientType=0 );
-  background-image: linear-gradient(top, #e4e4e4 0%,#eeeeee 70%);
+  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.48, #e8e8e8), color-stop(0.5, #f0f0f0), color-stop(0.8, #f4f4f4));
+  background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, #e8e8e8 48%, #f0f0f0 50%, #f4f4f4 80%);
+  background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, #e8e8e8 48%, #f0f0f0 50%, #f4f4f4 80%);
+  background-image: -o-linear-gradient(top, #eeeeee 0%, #e8e8e8 48%, #f0f0f0 50%, #f4f4f4 80%);
+  background-image: -ms-linear-gradient(top, #eeeeee 0%, #e8e8e8 48%, #f0f0f0 50%, #f4f4f4 80%);
+  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#f4f4f4',GradientType=0 );
+  background-image: linear-gradient(top, #eeeeee 0%, #e8e8e8 48%, #f0f0f0 50%, #f4f4f4 80%);
+  -webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
+  -moz-box-shadow   : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
+  box-shadow        : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
   color: #333;
-  border: 1px solid #b4b4b4;
+  border: 1px solid #aaaaaa;
   line-height: 13px;
-  padding: 3px 19px 3px 6px;
+  padding: 3px 20px 3px 5px;
   margin: 3px 0 3px 5px;
   position: relative;
 }
@@ -228,7 +222,7 @@
 /* @group Results */
 .chzn-container .chzn-results {
   margin: 0 4px 4px 0;
-  max-height: 190px;
+  max-height: 240px;
   padding: 0 0 0 4px;
   position: relative;
   overflow-x: hidden;
@@ -240,8 +234,8 @@
 }
 .chzn-container .chzn-results li {
   display: none;
-  line-height: 80%;
-  padding: 7px 7px 8px;
+  line-height: 15px;
+  padding: 5px 6px;
   margin: 0;
   list-style: none;
 }
@@ -250,7 +244,14 @@
   display: list-item;
 }
 .chzn-container .chzn-results .highlighted {
-  background: #3875d7;
+  background-color: #3875d7;
+  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.1, #2a62bc), color-stop(0.8, #3875d7));
+  background-image: -webkit-linear-gradient(center bottom, #2a62bc 10%, #3875d7 80%);
+  background-image: -moz-linear-gradient(center bottom, #2a62bc 10%, #3875d7 80%);
+  background-image: -o-linear-gradient(bottom, #2a62bc 10%, #3875d7 80%);
+  background-image: -ms-linear-gradient(top, #2a62bc 10%, #3875d7 80%);
+  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2a62bc', endColorstr='#3875d7',GradientType=0 );
+  background-image: linear-gradient(top, #2a62bc 10%, #3875d7 80%);
   color: #fff;
 }
 .chzn-container .chzn-results li em {
@@ -270,11 +271,34 @@
   font-weight: bold;
 }
 .chzn-container .chzn-results .group-option {
-  padding-left: 20px;
+  padding-left: 15px;
 }
 .chzn-container-multi .chzn-drop .result-selected {
   display: none;
 }
+.chzn-container .chzn-results-scroll {
+  background: white;
+  margin: 0px 4px;
+  position: absolute;
+  text-align: center;
+  width: 321px; /* This should by dynamic with js */
+  z-index: 1;
+}
+.chzn-container .chzn-results-scroll span {
+  display: inline-block;
+  height: 17px;
+  text-indent: -5000px;
+  width: 9px;
+}
+.chzn-container .chzn-results-scroll-down {
+  bottom: 0;
+}
+.chzn-container .chzn-results-scroll-down span {
+  background: url('chosen-sprite.png') no-repeat -4px -3px;
+}
+.chzn-container .chzn-results-scroll-up span {
+  background: url('chosen-sprite.png') no-repeat -22px -3px;
+}
 /* @end */
 
 /* @group Active  */
@@ -292,13 +316,13 @@
   -o-box-shadow     : 0 1px 0 #fff inset;
   box-shadow        : 0 1px 0 #fff inset;
   background-color: #eee;
-  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee));
-  background-image: -webkit-linear-gradient(center bottom, white 0%, #eeeeee 50%);
-  background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%);
-  background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%);
-  background-image: -ms-linear-gradient(top, #ffffff 0%,#eeeeee 50%);
+  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.2, white), color-stop(0.8, #eeeeee));
+  background-image: -webkit-linear-gradient(center bottom, white 20%, #eeeeee 80%);
+  background-image: -moz-linear-gradient(center bottom, white 20%, #eeeeee 80%);
+  background-image: -o-linear-gradient(bottom, white 20%, #eeeeee 80%);
+  background-image: -ms-linear-gradient(top, #ffffff 20%,#eeeeee 80%);
   filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
-  background-image: linear-gradient(top, #ffffff 0%,#eeeeee 50%);
+  background-image: linear-gradient(top, #ffffff 20%,#eeeeee 80%);
   -webkit-border-bottom-left-radius : 0;
   -webkit-border-bottom-right-radius: 0;
   -moz-border-radius-bottomleft : 0;
@@ -341,16 +365,15 @@
 .chzn-rtl { direction:rtl;text-align: right; }
 .chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; }
 .chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; }
-.chzn-rtl .chzn-single div { 
-  left: 0; right: auto; 
-  border-left: none; border-right: 1px solid #aaaaaa;
-  -webkit-border-radius: 4px 0 0 4px;
-  -moz-border-radius   : 4px 0 0 4px;
-  border-radius        : 4px 0 0 4px; 
+
+.chzn-rtl .chzn-single div { left: 3px; right: auto; }
+.chzn-rtl .chzn-single abbr {
+  left: 26px;
+  right: auto;
 }
 .chzn-rtl .chzn-choices li { float: right; }
-.chzn-rtl .chzn-choices .search-choice { padding: 3px 6px 3px 19px; margin: 3px 5px 3px 0; }
-.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 5px; right: auto; background-position: right top;}
+.chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
+.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;}
 .chzn-rtl.chzn-container-single .chzn-results { margin-left: 4px; margin-right: 0; padding-left: 0; padding-right: 4px; }
 .chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; }
 .chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
@@ -364,4 +387,4 @@
   background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
   padding: 4px 5px 4px 20px;
 }
-/* @end */
+/* @end */

+ 217 - 170
main/inc/lib/javascript/chosen/chosen.jquery.js

@@ -1,7 +1,7 @@
 // Chosen, a Select Box Enhancer for jQuery and Protoype
 // by Patrick Filler for Harvest, http://getharvest.com
 // 
-// Version 0.9.5
+// Version 0.9.7
 // Full source at https://github.com/harvesthq/chosen
 // Copyright (c) 2011 Harvest http://getharvest.com
 
@@ -9,11 +9,14 @@
 // This file is generated by `cake build`, do not edit it by hand.
 (function() {
   var SelectParser;
+
   SelectParser = (function() {
+
     function SelectParser() {
       this.options_index = 0;
       this.parsed = [];
     }
+
     SelectParser.prototype.add_node = function(child) {
       if (child.nodeName === "OPTGROUP") {
         return this.add_group(child);
@@ -21,6 +24,7 @@
         return this.add_option(child);
       }
     };
+
     SelectParser.prototype.add_group = function(group) {
       var group_position, option, _i, _len, _ref, _results;
       group_position = this.parsed.length;
@@ -39,12 +43,11 @@
       }
       return _results;
     };
+
     SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
       if (option.nodeName === "OPTION") {
         if (option.text !== "") {
-          if (group_position != null) {
-            this.parsed[group_position].children += 1;
-          }
+          if (group_position != null) this.parsed[group_position].children += 1;
           this.parsed.push({
             array_index: this.parsed.length,
             options_index: this.options_index,
@@ -67,8 +70,11 @@
         return this.options_index += 1;
       }
     };
+
     return SelectParser;
+
   })();
+
   SelectParser.select_to_array = function(select) {
     var child, parser, _i, _len, _ref;
     parser = new SelectParser();
@@ -79,17 +85,23 @@
     }
     return parser.parsed;
   };
+
   this.SelectParser = SelectParser;
+
 }).call(this);
+
+/*
+Chosen source: generate output using 'cake build'
+Copyright (c) 2011 by Harvest
+*/
+
 (function() {
-  /*
-  Chosen source: generate output using 'cake build'
-  Copyright (c) 2011 by Harvest
-  */
   var AbstractChosen, root;
-  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
   root = this;
+
   AbstractChosen = (function() {
+
     function AbstractChosen(form_field, options) {
       this.form_field = form_field;
       this.options = options != null ? options : {};
@@ -101,69 +113,74 @@
       this.register_observers();
       this.finish_setup();
     }
+
     AbstractChosen.prototype.set_default_values = function() {
-      this.click_test_action = __bind(function(evt) {
-        return this.test_active_click(evt);
-      }, this);
-      this.activate_action = __bind(function(evt) {
-        return this.activate_field(evt);
-      }, this);
+      var _this = this;
+      this.click_test_action = function(evt) {
+        return _this.test_active_click(evt);
+      };
+      this.activate_action = function(evt) {
+        return _this.activate_field(evt);
+      };
       this.active_field = false;
       this.mouse_on_container = false;
       this.results_showing = false;
       this.result_highlighted = null;
       this.result_single_selected = null;
-      this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
+      this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
       this.disable_search_threshold = this.options.disable_search_threshold || 0;
       this.choices = 0;
       return this.results_none_found = this.options.no_results_text || "No results match";
     };
+
     AbstractChosen.prototype.mouse_enter = function() {
       return this.mouse_on_container = true;
     };
+
     AbstractChosen.prototype.mouse_leave = function() {
       return this.mouse_on_container = false;
     };
+
     AbstractChosen.prototype.input_focus = function(evt) {
+      var _this = this;
       if (!this.active_field) {
-        return setTimeout((__bind(function() {
-          return this.container_mousedown();
-        }, this)), 50);
+        return setTimeout((function() {
+          return _this.container_mousedown();
+        }), 50);
       }
     };
+
     AbstractChosen.prototype.input_blur = function(evt) {
+      var _this = this;
       if (!this.mouse_on_container) {
         this.active_field = false;
-        return setTimeout((__bind(function() {
-          return this.blur_test();
-        }, this)), 100);
+        return setTimeout((function() {
+          return _this.blur_test();
+        }), 100);
       }
     };
+
     AbstractChosen.prototype.result_add_option = function(option) {
       var classes, style;
       if (!option.disabled) {
         option.dom_id = this.container_id + "_o_" + option.array_index;
         classes = option.selected && this.is_multiple ? [] : ["active-result"];
-        if (option.selected) {
-          classes.push("result-selected");
-        }
-        if (option.group_array_index != null) {
-          classes.push("group-option");
-        }
-        if (option.classes !== "") {
-          classes.push(option.classes);
-        }
+        if (option.selected) classes.push("result-selected");
+        if (option.group_array_index != null) classes.push("group-option");
+        if (option.classes !== "") classes.push(option.classes);
         style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
         return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
       } else {
         return "";
       }
     };
+
     AbstractChosen.prototype.results_update_field = function() {
       this.result_clear_highlight();
       this.result_single_selected = null;
       return this.results_build();
     };
+
     AbstractChosen.prototype.results_toggle = function() {
       if (this.results_showing) {
         return this.results_hide();
@@ -171,6 +188,7 @@
         return this.results_show();
       }
     };
+
     AbstractChosen.prototype.results_search = function(evt) {
       if (this.results_showing) {
         return this.winnow_results();
@@ -178,6 +196,7 @@
         return this.results_show();
       }
     };
+
     AbstractChosen.prototype.keyup_checker = function(evt) {
       var stroke, _ref;
       stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
@@ -193,15 +212,11 @@
           break;
         case 13:
           evt.preventDefault();
-          if (this.results_showing) {
-            return this.result_select(evt);
-          }
+          if (this.results_showing) return this.result_select(evt);
           break;
         case 27:
-          if (this.results_showing) {
-            return this.results_hide();
-          }
-          break;
+          if (this.results_showing) this.results_hide();
+          return true;
         case 9:
         case 38:
         case 40:
@@ -213,62 +228,71 @@
           return this.results_search();
       }
     };
+
     AbstractChosen.prototype.generate_field_id = function() {
       var new_id;
       new_id = this.generate_random_id();
       this.form_field.id = new_id;
       return new_id;
     };
+
     AbstractChosen.prototype.generate_random_char = function() {
       var chars, newchar, rand;
       chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
       rand = Math.floor(Math.random() * chars.length);
       return newchar = chars.substring(rand, rand + 1);
     };
+
     return AbstractChosen;
+
   })();
+
   root.AbstractChosen = AbstractChosen;
+
 }).call(this);
+
+/*
+Chosen source: generate output using 'cake build'
+Copyright (c) 2011 by Harvest
+*/
+
 (function() {
-  /*
-  Chosen source: generate output using 'cake build'
-  Copyright (c) 2011 by Harvest
-  */
-  var $, Chosen, get_side_border_padding, root;
-  var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
-    for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
-    function ctor() { this.constructor = child; }
-    ctor.prototype = parent.prototype;
-    child.prototype = new ctor;
-    child.__super__ = parent.prototype;
-    return child;
-  }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+  var $, Chosen, get_side_border_padding, root,
+    __hasProp = Object.prototype.hasOwnProperty,
+    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+
   root = this;
+
   $ = jQuery;
+
   $.fn.extend({
     chosen: function(options) {
       if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
         return this;
       }
       return $(this).each(function(input_field) {
-        if (!($(this)).hasClass("chzn-done")) {
-          return new Chosen(this, options);
-        }
+        if (!($(this)).hasClass("chzn-done")) return new Chosen(this, options);
       });
     }
   });
-  Chosen = (function() {
-    __extends(Chosen, AbstractChosen);
+
+  Chosen = (function(_super) {
+
+    __extends(Chosen, _super);
+
     function Chosen() {
       Chosen.__super__.constructor.apply(this, arguments);
     }
+
     Chosen.prototype.setup = function() {
       this.form_field_jq = $(this.form_field);
       return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
     };
+
     Chosen.prototype.finish_setup = function() {
       return this.form_field_jq.addClass("chzn-done");
     };
+
     Chosen.prototype.set_up_html = function() {
       var container_div, dd_top, dd_width, sf_width;
       this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
@@ -288,9 +312,6 @@
       this.form_field_jq.hide().after(container_div);
       this.container = $('#' + this.container_id);
       this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
-      if (!this.is_multiple && this.form_field.options.length <= this.disable_search_threshold) {
-        this.container.addClass("chzn-container-single-nosearch");
-      }
       this.dropdown = this.container.find('div.chzn-drop').first();
       dd_top = this.container.height();
       dd_width = this.f_width - get_side_border_padding(this.dropdown);
@@ -319,81 +340,85 @@
         chosen: this
       });
     };
+
     Chosen.prototype.register_observers = function() {
-      this.container.mousedown(__bind(function(evt) {
-        return this.container_mousedown(evt);
-      }, this));
-      this.container.mouseup(__bind(function(evt) {
-        return this.container_mouseup(evt);
-      }, this));
-      this.container.mouseenter(__bind(function(evt) {
-        return this.mouse_enter(evt);
-      }, this));
-      this.container.mouseleave(__bind(function(evt) {
-        return this.mouse_leave(evt);
-      }, this));
-      this.search_results.mouseup(__bind(function(evt) {
-        return this.search_results_mouseup(evt);
-      }, this));
-      this.search_results.mouseover(__bind(function(evt) {
-        return this.search_results_mouseover(evt);
-      }, this));
-      this.search_results.mouseout(__bind(function(evt) {
-        return this.search_results_mouseout(evt);
-      }, this));
-      this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
-        return this.results_update_field(evt);
-      }, this));
-      this.search_field.blur(__bind(function(evt) {
-        return this.input_blur(evt);
-      }, this));
-      this.search_field.keyup(__bind(function(evt) {
-        return this.keyup_checker(evt);
-      }, this));
-      this.search_field.keydown(__bind(function(evt) {
-        return this.keydown_checker(evt);
-      }, this));
+      var _this = this;
+      this.container.mousedown(function(evt) {
+        return _this.container_mousedown(evt);
+      });
+      this.container.mouseup(function(evt) {
+        return _this.container_mouseup(evt);
+      });
+      this.container.mouseenter(function(evt) {
+        return _this.mouse_enter(evt);
+      });
+      this.container.mouseleave(function(evt) {
+        return _this.mouse_leave(evt);
+      });
+      this.search_results.mouseup(function(evt) {
+        return _this.search_results_mouseup(evt);
+      });
+      this.search_results.mouseover(function(evt) {
+        return _this.search_results_mouseover(evt);
+      });
+      this.search_results.mouseout(function(evt) {
+        return _this.search_results_mouseout(evt);
+      });
+      this.form_field_jq.bind("liszt:updated", function(evt) {
+        return _this.results_update_field(evt);
+      });
+      this.search_field.blur(function(evt) {
+        return _this.input_blur(evt);
+      });
+      this.search_field.keyup(function(evt) {
+        return _this.keyup_checker(evt);
+      });
+      this.search_field.keydown(function(evt) {
+        return _this.keydown_checker(evt);
+      });
       if (this.is_multiple) {
-        this.search_choices.click(__bind(function(evt) {
-          return this.choices_click(evt);
-        }, this));
-        return this.search_field.focus(__bind(function(evt) {
-          return this.input_focus(evt);
-        }, this));
+        this.search_choices.click(function(evt) {
+          return _this.choices_click(evt);
+        });
+        return this.search_field.focus(function(evt) {
+          return _this.input_focus(evt);
+        });
+      } else {
+        return this.container.click(function(evt) {
+          return evt.preventDefault();
+        });
       }
     };
+
     Chosen.prototype.search_field_disabled = function() {
-      this.is_disabled = this.form_field_jq.attr('disabled');
+      this.is_disabled = this.form_field_jq[0].disabled;
       if (this.is_disabled) {
         this.container.addClass('chzn-disabled');
-        this.search_field.attr('disabled', true);
+        this.search_field[0].disabled = true;
         if (!this.is_multiple) {
           this.selected_item.unbind("focus", this.activate_action);
         }
         return this.close_field();
       } else {
         this.container.removeClass('chzn-disabled');
-        this.search_field.attr('disabled', false);
+        this.search_field[0].disabled = false;
         if (!this.is_multiple) {
           return this.selected_item.bind("focus", this.activate_action);
         }
       }
     };
+
     Chosen.prototype.container_mousedown = function(evt) {
       var target_closelink;
       if (!this.is_disabled) {
         target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
-        if (evt && evt.type === "mousedown") {
-          evt.stopPropagation();
-        }
+        if (evt && evt.type === "mousedown") evt.stopPropagation();
         if (!this.pending_destroy_click && !target_closelink) {
           if (!this.active_field) {
-            if (this.is_multiple) {
-              this.search_field.val("");
-            }
+            if (this.is_multiple) this.search_field.val("");
             $(document).click(this.click_test_action);
             this.results_show();
-          } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
+          } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
             evt.preventDefault();
             this.results_toggle();
           }
@@ -403,16 +428,17 @@
         }
       }
     };
+
     Chosen.prototype.container_mouseup = function(evt) {
-      if (evt.target.nodeName === "ABBR") {
-        return this.results_reset(evt);
-      }
+      if (evt.target.nodeName === "ABBR") return this.results_reset(evt);
     };
+
     Chosen.prototype.blur_test = function(evt) {
       if (!this.active_field && this.container.hasClass("chzn-container-active")) {
         return this.close_field();
       }
     };
+
     Chosen.prototype.close_field = function() {
       $(document).unbind("click", this.click_test_action);
       if (!this.is_multiple) {
@@ -427,6 +453,7 @@
       this.show_search_field_default();
       return this.search_field_scale();
     };
+
     Chosen.prototype.activate_field = function() {
       if (!this.is_multiple && !this.active_field) {
         this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
@@ -437,6 +464,7 @@
       this.search_field.val(this.search_field.val());
       return this.search_field.focus();
     };
+
     Chosen.prototype.test_active_click = function(evt) {
       if ($(evt.target).parents('#' + this.container_id).length) {
         return this.active_field = true;
@@ -444,9 +472,9 @@
         return this.close_field();
       }
     };
+
     Chosen.prototype.results_build = function() {
-      var content, data, startTime, _i, _len, _ref;
-      startTime = new Date();
+      var content, data, _i, _len, _ref;
       this.parsing = true;
       this.results_data = root.SelectParser.select_to_array(this.form_field);
       if (this.is_multiple && this.choices > 0) {
@@ -454,6 +482,11 @@
         this.choices = 0;
       } else if (!this.is_multiple) {
         this.selected_item.find("span").text(this.default_text);
+        if (this.form_field.options.length <= this.disable_search_threshold) {
+          this.container.addClass("chzn-container-single-nosearch");
+        } else {
+          this.container.removeClass("chzn-container-single-nosearch");
+        }
       }
       content = '';
       _ref = this.results_data;
@@ -467,9 +500,7 @@
             this.choice_build(data);
           } else if (data.selected && !this.is_multiple) {
             this.selected_item.find("span").text(data.text);
-            if (this.allow_single_deselect) {
-              this.single_deselect_control_build();
-            }
+            if (this.allow_single_deselect) this.single_deselect_control_build();
           }
         }
       }
@@ -479,6 +510,7 @@
       this.search_results.html(content);
       return this.parsing = false;
     };
+
     Chosen.prototype.result_add_group = function(group) {
       if (!group.disabled) {
         group.dom_id = this.container_id + "_g_" + group.array_index;
@@ -487,6 +519,7 @@
         return "";
       }
     };
+
     Chosen.prototype.result_do_highlight = function(el) {
       var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
       if (el.length) {
@@ -505,12 +538,12 @@
         }
       }
     };
+
     Chosen.prototype.result_clear_highlight = function() {
-      if (this.result_highlight) {
-        this.result_highlight.removeClass("highlighted");
-      }
+      if (this.result_highlight) this.result_highlight.removeClass("highlighted");
       return this.result_highlight = null;
     };
+
     Chosen.prototype.results_show = function() {
       var dd_top;
       if (!this.is_multiple) {
@@ -529,6 +562,7 @@
       this.search_field.val(this.search_field.val());
       return this.winnow_results();
     };
+
     Chosen.prototype.results_hide = function() {
       if (!this.is_multiple) {
         this.selected_item.removeClass("chzn-single-with-drop");
@@ -539,6 +573,7 @@
       });
       return this.results_showing = false;
     };
+
     Chosen.prototype.set_tab_index = function(el) {
       var ti;
       if (this.form_field_jq.attr("tabindex")) {
@@ -552,6 +587,7 @@
         }
       }
     };
+
     Chosen.prototype.show_search_field_default = function() {
       if (this.is_multiple && this.choices < 1 && !this.active_field) {
         this.search_field.val(this.default_text);
@@ -561,6 +597,7 @@
         return this.search_field.removeClass("default");
       }
     };
+
     Chosen.prototype.search_results_mouseup = function(evt) {
       var target;
       target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
@@ -569,34 +606,38 @@
         return this.result_select(evt);
       }
     };
+
     Chosen.prototype.search_results_mouseover = function(evt) {
       var target;
       target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
-      if (target) {
-        return this.result_do_highlight(target);
-      }
+      if (target) return this.result_do_highlight(target);
     };
+
     Chosen.prototype.search_results_mouseout = function(evt) {
       if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
         return this.result_clear_highlight();
       }
     };
+
     Chosen.prototype.choices_click = function(evt) {
       evt.preventDefault();
       if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
         return this.results_show();
       }
     };
+
     Chosen.prototype.choice_build = function(item) {
-      var choice_id, link;
+      var choice_id, link,
+        _this = this;
       choice_id = this.container_id + "_c_" + item.array_index;
       this.choices += 1;
       this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
       link = $('#' + choice_id).find("a").first();
-      return link.click(__bind(function(evt) {
-        return this.choice_destroy_link_click(evt);
-      }, this));
+      return link.click(function(evt) {
+        return _this.choice_destroy_link_click(evt);
+      });
     };
+
     Chosen.prototype.choice_destroy_link_click = function(evt) {
       evt.preventDefault();
       if (!this.is_disabled) {
@@ -606,6 +647,7 @@
         return evt.stopPropagation;
       }
     };
+
     Chosen.prototype.choice_destroy = function(link) {
       this.choices -= 1;
       this.show_search_field_default();
@@ -615,16 +657,16 @@
       this.result_deselect(link.attr("rel"));
       return link.parents('li').first().remove();
     };
+
     Chosen.prototype.results_reset = function(evt) {
       this.form_field.options[0].selected = true;
       this.selected_item.find("span").text(this.default_text);
       this.show_search_field_default();
       $(evt.target).remove();
       this.form_field_jq.trigger("change");
-      if (this.active_field) {
-        return this.results_hide();
-      }
+      if (this.active_field) return this.results_hide();
     };
+
     Chosen.prototype.result_select = function(evt) {
       var high, high_id, item, position;
       if (this.result_highlight) {
@@ -646,24 +688,23 @@
           this.choice_build(item);
         } else {
           this.selected_item.find("span").first().text(item.text);
-          if (this.allow_single_deselect) {
-            this.single_deselect_control_build();
-          }
-        }
-        if (!(evt.metaKey && this.is_multiple)) {
-          this.results_hide();
+          if (this.allow_single_deselect) this.single_deselect_control_build();
         }
+        if (!(evt.metaKey && this.is_multiple)) this.results_hide();
         this.search_field.val("");
         this.form_field_jq.trigger("change");
         return this.search_field_scale();
       }
     };
+
     Chosen.prototype.result_activate = function(el) {
       return el.addClass("active-result");
     };
+
     Chosen.prototype.result_deactivate = function(el) {
       return el.removeClass("active-result");
     };
+
     Chosen.prototype.result_deselect = function(pos) {
       var result, result_data;
       result_data = this.results_data[pos];
@@ -676,14 +717,15 @@
       this.form_field_jq.trigger("change");
       return this.search_field_scale();
     };
+
     Chosen.prototype.single_deselect_control_build = function() {
       if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
         return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
       }
     };
+
     Chosen.prototype.winnow_results = function() {
-      var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
-      startTime = new Date();
+      var found, option, part, parts, regex, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
       this.no_results_clear();
       results = 0;
       searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
@@ -694,10 +736,11 @@
         option = _ref[_i];
         if (!option.disabled && !option.empty) {
           if (option.group) {
-            $('#' + option.dom_id).hide();
+            $('#' + option.dom_id).css('display', 'none');
           } else if (!(this.is_multiple && option.selected)) {
             found = false;
             result_id = option.dom_id;
+            result = $("#" + result_id);
             if (regex.test(option.html)) {
               found = true;
               results += 1;
@@ -721,18 +764,16 @@
               } else {
                 text = option.html;
               }
-              if ($("#" + result_id).html !== text) {
-                $("#" + result_id).html(text);
-              }
-              this.result_activate($("#" + result_id));
+              result.html(text);
+              this.result_activate(result);
               if (option.group_array_index != null) {
-                $("#" + this.results_data[option.group_array_index].dom_id).show();
+                $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
               }
             } else {
               if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
                 this.result_clear_highlight();
               }
-              this.result_deactivate($("#" + result_id));
+              this.result_deactivate(result);
             }
           }
         }
@@ -743,6 +784,7 @@
         return this.winnow_results_set_highlight();
       }
     };
+
     Chosen.prototype.winnow_results_clear = function() {
       var li, lis, _i, _len, _results;
       this.search_field.val("");
@@ -751,46 +793,49 @@
       for (_i = 0, _len = lis.length; _i < _len; _i++) {
         li = lis[_i];
         li = $(li);
-        _results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
+        if (li.hasClass("group-result")) {
+          _results.push(li.css('display', 'auto'));
+        } else if (!this.is_multiple || !li.hasClass("result-selected")) {
+          _results.push(this.result_activate(li));
+        } else {
+          _results.push(void 0);
+        }
       }
       return _results;
     };
+
     Chosen.prototype.winnow_results_set_highlight = function() {
       var do_high, selected_results;
       if (!this.result_highlight) {
         selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
         do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
-        if (do_high != null) {
-          return this.result_do_highlight(do_high);
-        }
+        if (do_high != null) return this.result_do_highlight(do_high);
       }
     };
+
     Chosen.prototype.no_results = function(terms) {
       var no_results_html;
       no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
       no_results_html.find("span").first().html(terms);
       return this.search_results.append(no_results_html);
     };
+
     Chosen.prototype.no_results_clear = function() {
       return this.search_results.find(".no-results").remove();
     };
+
     Chosen.prototype.keydown_arrow = function() {
       var first_active, next_sib;
       if (!this.result_highlight) {
         first_active = this.search_results.find("li.active-result").first();
-        if (first_active) {
-          this.result_do_highlight($(first_active));
-        }
+        if (first_active) this.result_do_highlight($(first_active));
       } else if (this.results_showing) {
         next_sib = this.result_highlight.nextAll("li.active-result").first();
-        if (next_sib) {
-          this.result_do_highlight(next_sib);
-        }
-      }
-      if (!this.results_showing) {
-        return this.results_show();
+        if (next_sib) this.result_do_highlight(next_sib);
       }
+      if (!this.results_showing) return this.results_show();
     };
+
     Chosen.prototype.keyup_arrow = function() {
       var prev_sibs;
       if (!this.results_showing && !this.is_multiple) {
@@ -800,13 +845,12 @@
         if (prev_sibs.length) {
           return this.result_do_highlight(prev_sibs.first());
         } else {
-          if (this.choices > 0) {
-            this.results_hide();
-          }
+          if (this.choices > 0) this.results_hide();
           return this.result_clear_highlight();
         }
       }
     };
+
     Chosen.prototype.keydown_backstroke = function() {
       if (this.pending_backstroke) {
         this.choice_destroy(this.pending_backstroke.find("a").first());
@@ -816,27 +860,25 @@
         return this.pending_backstroke.addClass("search-choice-focus");
       }
     };
+
     Chosen.prototype.clear_backstroke = function() {
       if (this.pending_backstroke) {
         this.pending_backstroke.removeClass("search-choice-focus");
       }
       return this.pending_backstroke = null;
     };
+
     Chosen.prototype.keydown_checker = function(evt) {
       var stroke, _ref;
       stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
       this.search_field_scale();
-      if (stroke !== 8 && this.pending_backstroke) {
-        this.clear_backstroke();
-      }
+      if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
       switch (stroke) {
         case 8:
           this.backstroke_length = this.search_field.val().length;
           break;
         case 9:
-          if (this.results_showing && !this.is_multiple) {
-            this.result_select(evt);
-          }
+          if (this.results_showing && !this.is_multiple) this.result_select(evt);
           this.mouse_on_container = false;
           break;
         case 13:
@@ -851,6 +893,7 @@
           break;
       }
     };
+
     Chosen.prototype.search_field_scale = function() {
       var dd_top, div, h, style, style_block, styles, w, _i, _len;
       if (this.is_multiple) {
@@ -869,9 +912,7 @@
         $('body').append(div);
         w = div.width() + 25;
         div.remove();
-        if (w > this.f_width - 10) {
-          w = this.f_width - 10;
-        }
+        if (w > this.f_width - 10) w = this.f_width - 10;
         this.search_field.css({
           'width': w + 'px'
         });
@@ -881,6 +922,7 @@
         });
       }
     };
+
     Chosen.prototype.generate_random_id = function() {
       var string;
       string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
@@ -889,11 +931,16 @@
       }
       return string;
     };
+
     return Chosen;
-  })();
+
+  })(AbstractChosen);
+
   get_side_border_padding = function(elmt) {
     var side_border_padding;
     return side_border_padding = elmt.outerWidth() - elmt.width();
   };
+
   root.get_side_border_padding = get_side_border_padding;
+
 }).call(this);

File diff suppressed because it is too large
+ 1 - 1
main/inc/lib/javascript/chosen/chosen.jquery.min.js


+ 1 - 1
main/inc/lib/link.lib.php

@@ -649,7 +649,7 @@ function showlinksofcategory($catid) {
     				    Display :: return_icon('delete.png', get_lang('Delete'), array (), 22) . '</a>';
     
     			} else {
-    				echo get_lang('EditionNotAvailableFromSession');
+    				echo Display :: return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array (), 22); //get_lang('EditionNotAvailableFromSession');
     			}
     		}
     		echo '</td></tr>';

+ 2 - 3
main/inc/lib/loginredirection.lib.php

@@ -6,7 +6,7 @@
 Class LoginRedirection {
 
   //checks user status and redirect him through custom page if setting is enabled
-  public function redirect(){
+  public static function redirect(){
 
     global $param;
     $param = isset($param) ? $param : '';
@@ -58,5 +58,4 @@ Class LoginRedirection {
     header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param);
     exit();
   }
-}
-?>
+}

+ 14 - 10
main/inc/lib/main_api.lib.php

@@ -1731,12 +1731,13 @@ function api_get_session_visibility($session_id) {
                 $visibility = SESSION_AVAILABLE;    
             } else {
                 $time = time();
-                
+                     
                 //If datestart is set
                 if (!empty($row['date_start']) && $row['date_start'] != '0000-00-00') {
                     $row['date_start'] = $row['date_start'].' 00:00:00';   
-                    if ($time > api_strtotime($row['date_start'])) {
-                        $visibility = SESSION_AVAILABLE;
+                  
+                    if ($time > api_strtotime($row['date_start'], 'UTC')) {                          
+                        $visibility = SESSION_AVAILABLE;                        
                     } else {
                         $visibility = SESSION_INVISIBLE;
                     }
@@ -1746,14 +1747,17 @@ function api_get_session_visibility($session_id) {
                 if (!empty($row['date_end']) && $row['date_end'] != '0000-00-00') {                    
                     $row['date_end'] = $row['date_end'].' 00:00:00';
                     //only if date_start said that it was ok
+                    
                     if ($visibility == SESSION_AVAILABLE) {
                         $visibility = $row['visibility'];
-                        /*
-                        if ($time < api_strtotime($row['date_end'])) {
-                            $visibility = $row['visibility'];
+                        
+                        if ($time < api_strtotime($row['date_end'], 'UTC')) {
+                            //date still available
+                            $visibility = SESSION_AVAILABLE;
                         } else {
+                            //session ends
                             $visibility = $row['visibility'];
-                        }*/                 
+                        }
                     }
                 }                
             }
@@ -2374,9 +2378,9 @@ function api_is_allowed_to_session_edit($tutor = false, $coach = false) {
             // Get the session visibility
             $session_visibility = api_get_session_visibility($session_id);  // if 5 the session is still available.
             
-                //@todo We could load the session_rel_course_rel_user permission to increase the level of detail.
-                //echo api_get_user_id();
-                //echo api_get_course_id();
+            //@todo We could load the session_rel_course_rel_user permission to increase the level of detail.
+            //echo api_get_user_id();
+            //echo api_get_course_id();
 
             switch ($session_visibility) {
                 case SESSION_VISIBLE_READ_ONLY: // 1

File diff suppressed because it is too large
+ 603 - 603
main/inc/lib/pear/HTML/QuickForm/advmultiselect.php


+ 39 - 3
main/inc/lib/sessionmanager.lib.php

@@ -220,7 +220,7 @@ class SessionManager {
 		}        
 
 		$today = api_get_utc_datetime();
-		$today = api_strtotime($today);
+		$today = api_strtotime($today, 'UTC');
 		$today = date('Y-m-d', $today);
 
 		$select = "SELECT * FROM (SELECT 
@@ -635,7 +635,9 @@ class SessionManager {
 					}
 				}
 			}
-			
+            
+			//Replace with this new function
+            //
 			// insert new users into session_rel_course_rel_user and ignore if they already exist
 			foreach ($user_list as $enreg_user) {
 				if(!in_array($enreg_user, $existingUsers)) {
@@ -677,10 +679,43 @@ class SessionManager {
             $update_sql = "UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ";
             Database::query($update_sql);
         } else {
-            echo $update_sql = "UPDATE $tbl_session SET nbr_users= nbr_users + $nbr_users WHERE id='$id_session' ";
+            $update_sql = "UPDATE $tbl_session SET nbr_users= nbr_users + $nbr_users WHERE id='$id_session' ";
             Database::query($update_sql);           
         }
 	}
+    
+    function subscribe_users_to_session_course($user_list, $session_id, $course_code, $session_visibility = SESSION_VISIBLE_READ_ONLY ) {
+           	$tbl_session_rel_course				= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
+            $tbl_session_rel_course_rel_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+            
+            if (empty($user_list) || empty($session_id) || empty($course_code)) {
+                return false;                
+            }
+            
+            $session_id = intval($session_id);
+            $course_code = Database::escape_string($course_code);
+            $session_visibility = intval($session_visibility);                      
+    
+            $nbr_users = 0;
+			foreach ($user_list as $enreg_user) {
+				//if (!in_array($enreg_user, $existingUsers)) {
+	                $enreg_user = intval($enreg_user);
+					$insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user,visibility) 
+                                   VALUES ('$session_id','$course_code','$enreg_user','$session_visibility')";
+					Database::query($insert_sql);
+					if (Database::affected_rows()) {
+						$nbr_users++;
+					}
+				//}
+			}
+			// count users in this session-course relation
+			$sql = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course' AND status<>2";
+			$rs = Database::query($sql);
+			list($nbr_users) = Database::fetch_array($rs);
+			// update the session-course relation to add the users total
+			$update_sql = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";
+			Database::query($update_sql);
+    }
 
 	/**
 	 * Unsubscribe user from session
@@ -1564,6 +1599,7 @@ class SessionManager {
     
     function suscribe_sessions_to_promotion($promotion_id, $list) {
         $t = Database::get_main_table(TABLE_MAIN_SESSION);
+        $params = array();
         $params['promotion_id'] = 0;             
         Database::update($t, $params, array('promotion_id = ?'=>$promotion_id));
         

+ 5 - 7
main/inc/lib/thematic.lib.php

@@ -31,8 +31,7 @@ class Thematic
 
 	public function __construct() {
 		$this->course_int_id = api_get_course_int_id();
-	}
-	
+	}	
 	
 	/**
 	 * Get the total number of thematic inside current course and current session
@@ -291,7 +290,7 @@ class Thematic
 			}
 		} else {
 			// update
-			$sql = "UPDATE $tbl_thematic SET title = '$title', content = '$content', session_id = $session_id WHERE id = $id ";
+			$sql = "UPDATE $tbl_thematic SET title = '$title', content = '$content', session_id = $session_id WHERE id = $id AND c_id = {$this->course_int_id}";
 			Database::query($sql);
 			$last_id = $id;
 			if (Database::affected_rows()) {
@@ -645,7 +644,8 @@ class Thematic
             }
 		} else {
 			// update
-			$sql = "UPDATE $tbl_thematic_advance SET thematic_id = '$tematic_id', attendance_id = '$attendance_id', content = '$content', start_date = '".api_get_utc_datetime($start_date)."', duration = '$duration' WHERE id = $id ";
+			$sql = "UPDATE $tbl_thematic_advance SET thematic_id = '$tematic_id', attendance_id = '$attendance_id', content = '$content', start_date = '".api_get_utc_datetime($start_date)."', duration = '$duration' 
+                    WHERE c_id = {$this->course_int_id} AND id = $id ";
 			Database::query($sql);			
             if (Database::affected_rows()) {
                 api_item_property_update($_course, 'thematic_advance', $id, "ThematicAdvanceUpdated", $user_id);
@@ -941,9 +941,7 @@ class Thematic
 					foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
 						
 						$item_info = api_get_item_property_info(api_get_course_int_id(), 'thematic_advance', $thematic_advance['id']);
-						//var_dump($item_info );
-						
-												
+							
 						if ($item_info['id_session'] == api_get_session_id()) {
     						
     						$a_thematic_advance_ids[] = $thematic_advance['id'];

+ 50 - 59
main/inc/lib/tracking.lib.php

@@ -2179,7 +2179,8 @@ class Tracking {
 				}
 				$course_in_session[$my_session_id]['course_list'] = $final_course_data;
 				$course_in_session[$my_session_id]['name'] = $session_name;
-			}			
+			}		
+            
 			 
 			$html = '';
 
@@ -2187,7 +2188,7 @@ class Tracking {
 			
 			if ($show_courses) {
 				if (!empty($courses)) {
-					$html .= Display::tag('h1', Display::return_icon('course.png', get_lang('MyCourses'), array(), 22).' '.get_lang('MyCourses'));
+					$html .= Display::tag('h2', Display::return_icon('course.png', get_lang('MyCourses'), array(), 22).' '.get_lang('MyCourses'));
 					$html .= '<table class="data_table" width="100%">';
 					$html .= '<tr>
                               '.Display::tag('th', get_lang('Course'),          		array('width'=>'300px')).'
@@ -2275,7 +2276,8 @@ class Tracking {
 							foreach($exercise_list as $exercise_data) {							    
 								$exercise_obj = new Exercise($course_data['id']);
 								$exercise_obj->read($exercise_data['id']);
-								if ($exercise_obj->is_visible()) {
+                                $visible_return = $exercise_obj->is_visible();
+								if ($visible_return['value'] == true) {
 									$best_average = intval(get_best_average_score_by_exercise($exercise_data['id'], $course_data['code'], $my_session_id, $user_count));
 									$exercise_graph_list[] 		= $best_average;
 									$all_exercise_graph_list[] 	= $best_average;
@@ -2287,7 +2289,7 @@ class Tracking {
 									}
 									//$user_results[] = 100;
 									$user_results[] = $score;
-									$time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time']) : 0;
+									$time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
 									$all_exercise_start_time[] = $time ;
 									$all_user_results[] = $score;
 									if (count($exercise_list)<=10) {
@@ -2335,7 +2337,7 @@ class Tracking {
 				}
 				
 				
-				$html .= Display::tag('h1',Display::return_icon('session.png', get_lang('Sessions'), array(), 22).' '.get_lang('Sessions'));
+				$html .= Display::tag('h2',Display::return_icon('session.png', get_lang('Sessions'), array(), 22).' '.get_lang('Sessions'));
 				
 				$html .= '<table class="data_table" width="100%">';
 				//'.Display::tag('th', get_lang('DoneExercises'),            array('class'=>'head')).'
@@ -2432,7 +2434,7 @@ class Tracking {
 					$session_data 	= $course_in_session[$session_id_from_get];
 					$course_list 	= $session_data['course_list'];
 					
-					$html .= Display::tag('h2',$session_data['name'].' - '.get_lang('CourseList'));
+					$html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
 
 					$html .= '<table class="data_table" width="100%">';
 					//'.Display::tag('th', get_lang('DoneExercises'),         array('class'=>'head')).'
@@ -2563,34 +2565,22 @@ class Tracking {
 			$html = '';
 			if (isset($course_code)) {
 				require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
+                require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.class.php';
+                require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
+                
 
 				$user_id                    = intval($user_id);
 				$session_id                 = intval($session_id);
 				$course                     = Database::escape_string($course_code);
 				$course_info                = CourseManager::get_course_information($course);
                 
-                $course_id                  = $course_info['real_id'];
-
-				$tbl_user                   = Database :: get_main_table(TABLE_MAIN_USER);
-				$tbl_session                = Database :: get_main_table(TABLE_MAIN_SESSION);
-				$tbl_session_course         = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
-				$tbl_session_course_user    = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+                $course_id                  = $course_info['real_id'];              				
+				$session_name               = api_get_session_name($session_id);
                 
-				$tbl_course_lp              = Database :: get_course_table(TABLE_LP_MAIN);				
-				$tbl_course_quiz            = Database :: get_course_table(TABLE_QUIZ_TEST);
-				
-				$session_name = api_get_session_name($session_id);
 				$html .= Display::tag('h2', $course_info['title']);
 				
 				$html .= '<table class="data_table" width="100%">';
-				
-				// This code was commented on purpose see BT#924
-				
-				/*$sql = 'SELECT visibility FROM '.$course_info['db_name'].'.'.TABLE_TOOL_LIST.' WHERE name="quiz"';
-				 $result_visibility_tests = Database::query($sql);
-				
-				if (Database::result($result_visibility_tests, 0, 'visibility') == 1) {*/
-				
+						
 				//Course details
 				$html .= '<tr>
 				                <th class="head" style="color:#000">'.get_lang('Exercices').'</th>
@@ -2600,27 +2590,32 @@ class Tracking {
 				                <th class="head" style="color:#000">'.get_lang('BestResultInCourse').'</th>
 				                <th class="head" style="color:#000">'.get_lang('Statistics').' '.Display :: return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>                                        
 				                </tr>';
-				
-				if (empty($session_id)) {
-					$sql_exercices = "SELECT quiz.title,id, results_disabled FROM ".$tbl_course_quiz." AS quiz WHERE c_id = $course_id AND active='1' AND session_id = 0";
-				} else {
-					$sql_exercices = "SELECT quiz.title,id, results_disabled FROM ".$tbl_course_quiz." AS quiz WHERE c_id = $course_id AND active='1'";
-				}
-				$result_exercices = Database::query($sql_exercices);
-				$to_graph_exercise_result = array();
-                
                 
                 if (empty($session_id)) {
                     $user_list  = UserManager::get_user_list();
                 } else {        
                     $user_list  = SessionManager::get_users_by_session($session_id);        
-                }                                
+                }
+                
+                $exercise_list = get_all_exercises($course_info, $session_id, true);
+                
+                $to_graph_exercise_result = array();                
                                 
-				if (Database::num_rows($result_exercices) > 0) {
+				if (!empty($exercise_list)) {
 					$score = $weighting = $exe_id = 0;
-					while ($exercices = Database::fetch_array($result_exercices)) {
-						//if ($exercices['id'] != 3) continue;
+					foreach ($exercise_list as $exercices) {
+                        
+                        $exercise_obj = new Exercise($course_info['real_id']);
+                        $exercise_obj->read($exercices['id']);
+                        $visible_return = $exercise_obj->is_visible();
+                        
+                        //just in case
+                        if ($visible_return['value'] == false) {
+                            continue;
+                        }
+                        						
 						$score = $weighting = $attempts = 0;
+                        
 						//Getting count of attempts by user
 						$attempts      = count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['code'], $session_id);
 						//For graphics
@@ -2696,29 +2691,25 @@ class Tracking {
 				$html .= '</table>';
 				
 				
-				//LP table results
-				
+				//LP table results				
 				$html .='<table class="data_table" width="100%">';
-				$html .= Display::tag('th', get_lang('Learnpaths'),    array('class'=>'head', 'style'=>'color:#000'));
-				$html .= Display::tag('th', get_lang('LatencyTimeSpent'),          array('class'=>'head', 'style'=>'color:#000'));
-				$html .= Display::tag('th', get_lang('Progress'),      array('class'=>'head', 'style'=>'color:#000'));
-				$html .= Display::tag('th', get_lang('Score'),         array('class'=>'head', 'style'=>'color:#000'));
-				$html .= Display::tag('th', get_lang('LastConnexion'), array('class'=>'head', 'style'=>'color:#000'));
+				$html .= Display::tag('th', get_lang('Learnpaths'),         array('class'=>'head', 'style'=>'color:#000'));
+				$html .= Display::tag('th', get_lang('LatencyTimeSpent'),   array('class'=>'head', 'style'=>'color:#000'));
+				$html .= Display::tag('th', get_lang('Progress'),           array('class'=>'head', 'style'=>'color:#000'));
+				$html .= Display::tag('th', get_lang('Score'),              array('class'=>'head', 'style'=>'color:#000'));
+				$html .= Display::tag('th', get_lang('LastConnexion'),      array('class'=>'head', 'style'=>'color:#000'));
 				$html .= '</tr>';
 
-				if (empty($session_id)) {
-					$sql_learnpath = "SELECT lp.name,lp.id FROM ".$tbl_course_lp." AS lp  WHERE c_id = $course_id AND session_id = 0 ORDER BY lp.display_order";
-				} else {
-					$sql_learnpath = "SELECT lp.name,lp.id FROM ".$tbl_course_lp." AS lp WHERE c_id = $course_id ORDER BY lp.display_order";
-				}
-
-				$result_learnpath = Database::query($sql_learnpath);
-				if (Database::num_rows($result_learnpath) > 0) {
-					while($learnpath = Database::fetch_array($result_learnpath)) {
-						$progress               = Tracking::get_avg_student_progress($user_id, $course, array($learnpath['id']), $session_id);
-						$last_connection_in_lp  = Tracking::get_last_connection_time_in_lp($user_id, $course, $learnpath['id'], $session_id);
-						$time_spent_in_lp       = Tracking::get_time_spent_in_lp($user_id, $course, array($learnpath['id']), $session_id);
-						$percentage_score 		= Tracking::get_avg_student_score($user_id, $course, array($learnpath['id']), $session_id);
+                $list = new LearnpathList(api_get_user_id(), $course_info['code'], $session_id, 'publicated_on ASC', true);  
+                $lp_list        = $list->get_flat_list();
+                
+				if (!empty($lp_list) > 0) {
+					foreach($lp_list as $lp_id => $learnpath) {
+                        
+						$progress               = Tracking::get_avg_student_progress($user_id, $course, array($lp_id), $session_id);
+						$last_connection_in_lp  = Tracking::get_last_connection_time_in_lp($user_id, $course, $lp_id, $session_id);
+						$time_spent_in_lp       = Tracking::get_time_spent_in_lp($user_id, $course, array($lp_id), $session_id);
+						$percentage_score 		= Tracking::get_avg_student_score($user_id, $course, array($lp_id), $session_id);
 						if (is_numeric($percentage_score)) {
 							$percentage_score = $percentage_score.'%';
 						} else {
@@ -2728,8 +2719,8 @@ class Tracking {
 						$time_spent_in_lp       = api_time_to_hms($time_spent_in_lp);
 
 						$html .= '<tr class="row_even">';
-						$url = api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id={$learnpath['id']}&action=view";						
-						$html .= Display::tag('td', Display::url($learnpath['name'], $url, array('target'=>SESSION_LINK_TARGET)));
+						$url = api_get_path(WEB_CODE_PATH)."newscorm/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";						
+						$html .= Display::tag('td', Display::url($learnpath['lp_name'], $url, array('target'=>SESSION_LINK_TARGET)));
 						$html .= Display::tag('td', $time_spent_in_lp, array('align'=>'center'));
 						if (is_numeric($progress)) {
 							$progress = $progress.'%';

+ 7 - 2
main/inc/lib/usergroup.lib.php

@@ -74,8 +74,13 @@ class UserGroup extends Model {
      * @param   int     user group id
      * @return  array   with a list of user ids
      */
-    public function get_users_by_usergroup($id) {
-        $results = Database::select('user_id',$this->usergroup_rel_user_table, array('where'=>array('usergroup_id = ?'=>$id)));
+    public function get_users_by_usergroup($id = null) {
+        if (empty($id)) {
+            $conditions = array();
+        } else {
+            $conditions = array('where'=>array('usergroup_id = ?'=>$id));
+        }
+        $results = Database::select('user_id', $this->usergroup_rel_user_table, $conditions, true);
         $array = array();
         if (!empty($results)) {    
             foreach($results as $row) {

+ 6 - 2
main/inc/lib/usermanager.lib.php

@@ -650,7 +650,7 @@ class UserManager {
     * @return array An array with all users of the platform.
     * @todo optional course code parameter, optional sorting parameters...
     */
-    public static function get_user_list_like($conditions = array(), $order_by = array()) {
+    public static function get_user_list_like($conditions = array(), $order_by = array(), $simple_like = false) {
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
         $return_array = array();
         $sql_query = "SELECT * FROM $user_table";
@@ -659,7 +659,11 @@ class UserManager {
             foreach ($conditions as $field => $value) {
                 $field = Database::escape_string($field);
                 $value = Database::escape_string($value);
-                $sql_query .= $field.' LIKE \'%'.$value.'%\'';
+                if ($simple_like) {
+                    $sql_query .= $field." LIKE '$value%'";
+                } else {
+                    $sql_query .= $field.' LIKE \'%'.$value.'%\'';
+                }
             }
         }
         if (count($order_by) > 0) {

+ 1 - 1
main/inc/lib/userportal.lib.php

@@ -80,7 +80,7 @@ class IndexManager {
 				foreach($exercises as $exercise_item) {
 					$exercise_item['course_code'] 	= $course_code;
 					$exercise_item['session_id'] 	= $session_id;
-					$exercise_item['tms'] 	= api_strtotime($exercise_item['end_time']);
+					$exercise_item['tms'] 	= api_strtotime($exercise_item['end_time'], 'UTC');
 						
 					$exercise_list[] = $exercise_item;
 				}

+ 9 - 8
main/lang/english/trad4all.inc.php

@@ -927,13 +927,13 @@ $SendInformation = "Send information";
 $YouMustAcceptLicence = "You must accept the licence";
 $SelectOne = "Select one";
 $ContactInformationHasBeenSent = "Contact information has been sent";
-$ContactInformationDescription = "Dear user,<br />
-<br />You are about to start using one of the best open-source e-learning platform on the market. Like many other open-source project, this project is backed up by a large community of students, teachers, developers and content creators who would like to promote the project better.<br />
-<br />
-By knowing a little bit more about you, one of our most important users, who will manage this e-learning system, we will be able to let people know that our software is used and let you know when we organize events that might be relevant to you.<br />
-<br />
-By filling this form, you accept that the Chamilo association or its members might send you information by e-mail about important events or updates in the Chamilo software or community. This will help the community grow as an organized entity where information flow, with a permanent respect of your time and your privacy.<br />
-<br />
+$ContactInformationDescription = "Dear user,<br />
+<br />You are about to start using one of the best open-source e-learning platform on the market. Like many other open-source project, this project is backed up by a large community of students, teachers, developers and content creators who would like to promote the project better.<br />
+<br />
+By knowing a little bit more about you, one of our most important users, who will manage this e-learning system, we will be able to let people know that our software is used and let you know when we organize events that might be relevant to you.<br />
+<br />
+By filling this form, you accept that the Chamilo association or its members might send you information by e-mail about important events or updates in the Chamilo software or community. This will help the community grow as an organized entity where information flow, with a permanent respect of your time and your privacy.<br />
+<br />
 Please note that you are <b>not required</b> to fill this form. If you want to remain anonymous, we will loose the opportunity to offer you all the privileges of being a registered portal administrator, but we will respect your decision. Simply leave this form empty and click \"Next\".<br /><br />";
 $CompanyActivity = "Your company's activity";
 $DateUnLock = "Unlock date";
@@ -1139,7 +1139,7 @@ $SaveForNow = "Save and continue later";
 $NoQuicktime = "Your browser does not have the QuickTime plugin installed. You can still use the platform, but to run a larger number of media file types, we suggest you might want to install it.";
 $NoJavaSun = "Your browser doesn't seem to have the Sun Java plugin installed. You can still use the platform, but you will lose a few of its capabilities.";
 $NoJava = "Your browser does not support Java";
-$JavaSun24 = "Your browser has a Java version not supported by this tool.
+$JavaSun24 = "Your browser has a Java version not supported by this tool.
 To use it you have to install a Java Sun version higher than 24";
 $NoMessageAnywere = "If you do not want to see this message again during this session, click here";
 $Attempts = "Attempts";
@@ -1203,6 +1203,7 @@ $HottestCourses = "Hottest courses";
 $SentAtX = "Sent at: %s";
 $dateTimeFormatShort = "%b %d, %Y at %I:%M %p";
 $dateTimeFormatShortTimeFirst = "%I:%M %p, %b %d %Y";
+$LoginX = "Login: %s";
 $LoginToVote = "Login to vote";
 $DoNotShow = "Do not show";
 $ShowToAdminsOnly = "Show to admins only";

+ 15 - 3
main/newscorm/learnpathList.class.php

@@ -30,7 +30,7 @@ class learnpathList {
      * @param	int			Optional session id (otherwise we use api_get_session_id())
      * @return	void
      */
-    function __construct($user_id, $course_code = '', $session_id = null, $order_by = null) {
+    function __construct($user_id, $course_code = '', $session_id = null, $order_by = null, $check_publication_dates = false) {
         $course_info = api_get_course_info($course_code);
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
@@ -49,9 +49,21 @@ class learnpathList {
         $condition_session = api_get_session_condition($session_id, true, true);
         $order = "ORDER BY display_order ASC, name ASC";
         if (isset($order_by)) {
-           $order =  Database::parse_conditions(array('order'=>$order_by));           
+           $order = Database::parse_conditions(array('order'=>$order_by));           
         }
-        $sql = "SELECT * FROM $lp_table WHERE c_id = $course_id $condition_session $order";
+        $now = api_get_utc_datetime();
+        $time_conditions = '';
+        
+        if ($check_publication_dates) {
+            $time_conditions = " AND ( (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now'  AND expired_on <> '0000-00-00 00:00:00'  AND expired_on > '$now' )  OR 
+                        (publicated_on <> '0000-00-00 00:00:00'  AND publicated_on < '$now'  AND expired_on = '0000-00-00 00:00:00') OR
+                        (publicated_on = '0000-00-00 00:00:00'   AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now') OR                        
+                        (publicated_on = '0000-00-00 00:00:00'   AND expired_on = '0000-00-00 00:00:00' )) 
+            ";
+        }
+        
+        $sql = "SELECT * FROM $lp_table WHERE c_id = $course_id $time_conditions $condition_session $order";
+        
         $res = Database::query($sql);
         $names = array();
         while ($row = Database::fetch_array($res,'ASSOC')) {

+ 124 - 57
main/session/index.php

@@ -9,7 +9,7 @@
  * Code
  */
 // Language files that should be included.
-$language_file = array('courses', 'index','tracking','exercice', 'admin');
+$language_file = array('learnpath', 'courses', 'index','tracking','exercice', 'admin');
 $cidReset = true;
 require_once '../inc/global.inc.php';
 require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
@@ -46,53 +46,104 @@ $my_session_list = array();
 $final_array     = array();
 
 if (!empty($new_session_list)) {
-	foreach($new_session_list as $item) {
-		$my_session_id = isset($item['id_session']) ? $item['id_session'] : null;
-		if (isset($my_session_id) && !in_array($my_session_id, $my_session_list) && $session_id == $my_session_id) {
-			$final_array[$my_session_id]['name'] = $item['session_name'];
-
-			//Get all courses by session where I'm subscribed
-			$my_course_list = UserManager::get_courses_list_by_session(api_get_user_id(), $my_session_id);            
-			 
-			foreach ($my_course_list as $my_course) {
-				$course = array();
-
-				$course_info   = api_get_course_info($my_course['code']);
-				//Getting all exercises from the current course
-				$exercise_list = get_all_exercises($course_info, $my_session_id);
-				 
-				//Exercises we skip
-				/*if (empty($exercise_list)) {
-				continue;
-				} */
-				//$exercise_course_list = array();
-				$course['name'] = $course_info['name'];
-				$course['id']   = $course_info['real_id'];
-				if (!empty($exercise_list)) {
-					foreach($exercise_list as $exercise_item) { 
-						//Loading the exercise
-						$exercise = new Exercise($course_info['real_id']);
-						$exercise->read($exercise_item['id']);
-                        if ($exercise->is_visible()) {
+    foreach($new_session_list as $item) {
+        $my_session_id = isset($item['id_session']) ? $item['id_session'] : null;    
+        if (isset($my_session_id) && !in_array($my_session_id, $my_session_list) && $session_id == $my_session_id) {
+        	$final_array[$my_session_id]['name'] = $item['session_name'];
+            
+            //Get all courses by session where I'm subscribed
+            $my_course_list = UserManager::get_courses_list_by_session(api_get_user_id(), $my_session_id);            
+                   
+            foreach ($my_course_list as $my_course) {
+                $course = array();
+            
+                $course_info   = api_get_course_info($my_course['code']);
+                //Getting all exercises from the current course            
+                $exercise_list = get_all_exercises($course_info, $my_session_id, true);
+                           
+                //Exercises we skip
+                /*if (empty($exercise_list)) {
+                    continue;
+                } */   
+                //$exercise_course_list = array();
+                $course['name'] = $course_info['name'];
+                $course['id']   = $course_info['real_id'];
+                if (!empty($exercise_list)) {        
+                    foreach($exercise_list as $exercise_item) {
+                        //Loading the exercise                
+                        $exercise = new Exercise($course_info['real_id']);
+                        $exercise->read($exercise_item['id']);  
+                        $visible_return = $exercise->is_visible();
+                        if ($visible_return['value'] == false) {                             
                             //$exercise_course_list[$exercise_item['id']] = $exercise;
                             //Reading all Exercise results by user, exercise_id, code, and session
                             $user_results = get_exercise_results_by_user(api_get_user_id(), $exercise_item['id'], $my_course['code'], $my_session_id);
-                            $course['exercises'][$exercise_item['id']]['data']['exercise_data'] =  $exercise;
+                            $course['exercises'][$exercise_item['id']]['data']['exercise_data'] =  $exercise;                            
                             $course['exercises'][$exercise_item['id']]['data']['results']       =  $user_results;
                         }
-					}
-					$final_array[$my_session_id]['data'][$my_course['code']] = $course;
-				}
-			}
-		}
-		$my_session_list[] =  $my_session_id;
-	}
+                    }
+                    $final_array[$my_session_id]['data'][$my_course['code']] = $course;        
+                }   
+            }            
+        }
+        $my_session_list[] =  $my_session_id;      
+    }
+}
+
+if (!empty($course_list)) {
+    foreach($course_list as $course_data) {
+        if (in_array($course_data['code'], $user_course_list)) {
+            $course_data['title'] = Display::url($course_data['title'], api_get_course_url($course_data['code'], $session_id));            
+        } else {
+            continue;
+        }
+        
+        $list           = new LearnpathList(api_get_user_id(),$course_data['code'], $session_id, 'publicated_on ASC', true);  
+        $lp_list        = $list->get_flat_list();
+        $lp_count       = count($lp_list); 
+        $course_info    = api_get_course_info($course_data['code']);
+        $exercise_count = count(get_all_exercises($course_info, $session_id, true));
+        
+        $max_mutation_date = '';
+        
+        $last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(), $course_data['code'], $session_id, false);
+        $icons = '';
+        foreach($lp_list as $item) {
+        
+            if ($item['modified_on'] == '0000-00-00 00:00:00' || empty($item['modified_on'])) {        
+                $lp_date_original = $item['created_on'];
+                $image = 'new.gif';
+                $label      = get_lang('LearnpathAdded');
+            } else {
+                $lp_date_original = $item['modified_on'];
+                $image      = 'moderator_star.png';
+                $label      = get_lang('LearnpathUpdated');
+            }
+            
+            $mutation_date = api_strtotime($item['publicated_on']) > api_strtotime($lp_date_original) ? $item['publicated_on'] : $lp_date_original;
+            
+            if (api_strtotime($mutation_date) > api_strtotime($max_mutation_date)) {
+                $max_mutation_date = $mutation_date;
+            }
+            
+
+            if (strtotime($last_date) < strtotime($lp_date_original)) {
+                if (empty($icons)) {
+                    $icons .= ' '.Display::return_icon($image, get_lang('_title_notification').': '.$label.' - '.$lp_date_original).' ';                    
+                }
+            }           
+        }        
+        $new_course_list[] = array( 'title'=> $course_data['title'].$icons,
+      //                                 'recent_lps' => $icons,
+                                       //'max_mutation_date' => substr(api_get_local_time($max_mutation_date),0,10),
+                                       'exercise_count' => $exercise_count,
+                                       'lp_count'       => $lp_count); 
+    }
 }
 
-//echo '<pre>';print_r($final_array);
 //If the requested session does not exist in my list we stop the script
 if (!api_is_platform_admin()) {
-	if (!in_array($session_id, $my_session_list)) {
+	if (!in_array($session_id, $my_session_list)) {       
 		api_not_allowed();
 	}
 }
@@ -185,7 +236,7 @@ foreach($final_array as $session_data) {
                     } else {
                         //We check the date validation of the exercise if the user can make it
                         if ($exercise_info->start_time != '0000-00-00 00:00:00') {
-                            $allowed_time = api_strtotime($exercise_info->start_time);                                     
+                            $allowed_time = api_strtotime($exercise_info->start_time, 'UTC');                                     
                             if ($now < $allowed_time) {
                                   continue;
                             }
@@ -238,29 +289,45 @@ if (!empty($start) && !empty($end)) {
 echo Display::tag('h1', $back_url.' '.$session_info['name']);
 echo $dates.'<br />';
 
-//echo '<pre>';print_r($course_list);
-$new_course_list = array();
-if (!empty($course_list)) {
-    foreach($course_list as $course_data) {
-        if (in_array($course_data['code'], $user_course_list)) {
-            $course_data['title'] = Display::url($course_data['title'], api_get_course_url($course_data['code'], $session_id));
-            $new_course_list[] = array('title'=> $course_data['title']); 
-        }        
-    }
-}
-
 //All Learnpaths grid settings (First tab, first subtab)
-$columns_courses        = array(get_lang('Title'));
-$column_model_courses   = array(array('name'=>'title',  'index'=>'title',   'width'=>'880px',  'align'=>'left',  'sortable'=>'false'));
-$extra_params_courses   = array();
+
+$columns_courses        = array(get_lang('Title'), get_lang('NumberOfPublishedExercises'), get_lang('NumberOfPublishedLps'));
+$column_model_courses   = array(
+    array('name'=>'title',              'index'=>'title',               'width'=>'400px',  'align'=>'left',  'sortable'=>'true'),
+    //array('name'=>'recent_lps',         'index'=>'recent_lps',          'width'=>'10px',  'align'=>'left',  'sortable'=>'false'),
+//    array('name'=>'max_mutation_date',  'index'=>'max_mutation_date',   'width'=>'120px',  'align'=>'left',  'sortable'=>'true'),
+    array('name'=>'exercise_count',     'index'=>'exercise_count',      'width'=>'180px',  'align'=>'left',  'sortable'=>'true'),
+    array('name'=>'lp_count',           'index'=>'lp_count',            'width'=>'180px',  'align'=>'left',  'sortable'=>'true')
+);
+
+//$extra_params_courses['gridview'] = "false";
+/*$extra_params_courses['rowNum'] = 9000;
+
+$extra_params_courses['height'] = "100%";
 $extra_params_courses['autowidth'] = 'false'; //use the width of the parent                             
+$extra_params_courses['recordtext'] = '';
+$extra_params_courses['pgtext'] = '';
+$extra_params_courses['pgbuttons'] = false;*/
+//$extra_params_courses['width'] = '50%';
+//$extra_params_courses['autowidth'] = 'true'; 
                         
 $url            = api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=session_courses_lp_default&session_id='.$session_id.'&course_id='.$course_id;
 $columns        = array(get_lang('PublicationDate'),get_lang('Course'), get_lang('LearningPaths'));
 $column_model   = array(array('name'=>'date',   'index'=>'date',   'width'=>'120', 'align'=>'left', 'sortable'=>'true'),
                         array('name'=>'course', 'index'=>'course', 'width'=>'300', 'align'=>'left', 'sortable'=>'true'),
                         array('name'=>'lp',     'index'=>'lp',     'width'=>'440', 'align'=>'left', 'sortable'=>'true'));
-$extra_params = array();                        
+$extra_params = array();   
+/*
+$extra_params['sortname'] = 'date';
+$extra_params['sortorder'] = 'asc';
+$extra_params['pgbuttons'] = false;
+$extra_params['recordtext'] = '';
+$extra_params['pgtext'] = '';
+$extra_params['height'] = "100%";
+*/
+//$extra_params['autowidth'] = 'true'; //use the width of the parent
+//$extra_params['width'] = '90%';    
+
 //$extra_params['autowidth'] = 'true'; //use the width of the parent
 //$extra_params['forceFit'] = 'true'; //use the width of the parent
 //$extra_params['altRows'] = 'true'; //zebra style
@@ -363,9 +430,9 @@ $(function() {
 </script>
 
 <?php 
-$my_reporting   = Tracking::show_user_progress(api_get_user_id(), $session_id, '&session_id='.$session_id.'#tabs-4', false);
+$my_reporting   = Tracking::show_user_progress(api_get_user_id(), $session_id, '#tabs-4', false);
 if (!empty($my_reporting))  {
-    $my_reporting  .= '<br />'.Tracking::show_course_detail(api_get_user_id(), $_GET['course'], $_GET['session_id']);
+    $my_reporting  .= '<br />'.Tracking::show_course_detail(api_get_user_id(), $_GET['course'], $session_id);
 }
 if (empty($my_reporting)) {
     $my_reporting  = Display::return_message(get_lang('NoDataAvailable'), 'warning');

+ 39 - 44
main/work/work.lib.php

@@ -25,19 +25,23 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.
  * @param	integer	Whether to show upload form option
  * @return	void
  */
-function display_action_links($id, $cur_dir_path, $always_show_tool_options, $always_show_upload_form) {
+function display_action_links($id, $cur_dir_path, $show_tool_options, $display_upload_link, $action) {
 	global $gradebook;
-
+    
+    $id = $my_back_id = intval($id);
+    if ($action == 'list') {
+        $my_back_id = 0;
+    }
+    
 	$display_output = '';
 	$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
-	if ($always_show_upload_form) {
-		$parent_id = $id;
-	}	
+    
+	
 	if (!empty($cur_dir_path)) {		
-		$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'&id='.$parent_id.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').'</a>';
+		$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'&id='.$my_back_id.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').'</a>';
 	}
 
-	if (!$always_show_tool_options && api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
+	if ($show_tool_options && api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
 		// Create dir
 		if (empty($cur_dir_path)) {
 			$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=create_dir&origin='.$origin.'&gradebook='.$gradebook.'">';
@@ -50,10 +54,12 @@ function display_action_links($id, $cur_dir_path, $always_show_tool_options, $al
 		}
 	}
 
-	if (!$always_show_upload_form && api_is_allowed_to_session_edit(false, true) && (isset($cur_dir_path) && (!empty($cur_dir_path) && $cur_dir_path != '/') )) {
-		$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$id.'&curdirpath='.$cur_dir_path.'&action=upload_form&origin='.$origin.'&gradebook='.$gradebook.'">';
-		$display_output .= Display::return_icon('upload_file.png', get_lang('UploadADocument'),'','32').'</a>';
-	}
+
+    if ($display_upload_link && api_is_allowed_to_session_edit(false, true) && (isset($cur_dir_path) && (!empty($cur_dir_path) && $cur_dir_path != '/') )) {
+        $display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$id.'&curdirpath='.$cur_dir_path.'&action=upload_form&origin='.$origin.'&gradebook='.$gradebook.'">';
+        $display_output .= Display::return_icon('upload_file.png', get_lang('UploadADocument'),'','32').'</a>';
+    }
+
 
 	if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath' && api_is_allowed_to_session_edit(false, true)) {
 		// Delete all files
@@ -62,14 +68,6 @@ function display_action_links($id, $cur_dir_path, $always_show_tool_options, $al
 		} else {
 			$message = get_lang('ConfirmYourChoice');
 		}
-
-		if (empty($curdirpath) or $curdirpath != '.') {
-			//$display_output .= '<a href="#">'.Display::return_icon('delete_na.png', get_lang('Delete'),'','32').'</a>';
-		} else {
-			/*$display_output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.$cur_dir_path.'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;delete=all" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities($message, ENT_QUOTES)).'\')) return false;">'.
-				Display::return_icon('delete.png', get_lang('Delete'),'','32').'</a>';*/
-		}
-		// make all files visible or invisible
 	}
 
 	if (api_is_allowed_to_edit(null, true)) {
@@ -357,6 +355,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 
 	// Getting the work data	
 	$my_folder_data = get_work_data_by_id($id);
+   
     
     $qualification_exists = false;
     if (!empty($my_folder_data['qualification']) && intval($my_folder_data['qualification']) > 0) {
@@ -375,12 +374,9 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
     			if (intval($my_folder_data['qualification']) == 0) {
     				Display::display_warning_message(get_lang('MaxWeightNeedToBeProvided'));
     			}
-    	}        
-    	
+    	}    	
     	$contains_file_query = '';    	
         
-        
-    	
     	//Get list from database
     	if ($is_allowed_to_edit) {
     		$active_condition = ' active IN (0, 1)';		
@@ -402,7 +398,8 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
     		$sql_get_publications_list = "SELECT * FROM  $work_table $group_query $subdirs_query $add_in_where_query  $active_condition $condition_session ORDER BY title";    		
     	}
         
-        $work_parents = array();        
+        $work_parents = array();       
+       
         $sql_result = Database::query($sql_get_publications_list);
         if (Database::num_rows($sql_result)) {  
             while ($work = Database::fetch_object($sql_result)) {
@@ -410,7 +407,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
                     $work_parents[] = $work;
                 }
             }
-        }
+        }        
     } else {
         $parent_id = isset($my_folder_data['id']) ? $my_folder_data['id'] : 0;
         
@@ -485,7 +482,6 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
             
 			$result = Database::query($sql_select_directory);
 			$row    = Database::fetch_array($result, 'ASSOC');
-            
 			
 			if (!$row) {
 				// the folder belongs to another session
@@ -506,17 +502,14 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 						$sql = Database::query('SELECT * FROM '.$work_assigment.' WHERE c_id = '.$course_id.' AND id = "'.$row['has_properties'].'" LIMIT 1');
 						$homework = Database::fetch_array($sql);
 					}
-					$form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?origin='.$origin.'&gradebook='.$gradebook.'&edit_dir='.$id2);
-
-					$group_name[] = FormValidator :: createElement('text', 'dir_name');
-					$form_folder -> addGroup($group_name, 'my_group', get_lang('Title'));
-                    
+					$form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?origin='.$origin.'&gradebook='.$gradebook.'&edit_dir='.$id2);                  
+                    $form_folder->addElement('text', 'dir_name', get_lang('Title'));                    
                     $form_folder->addElement('hidden', 'work_id', $id2);
-                    $form_folder -> addGroupRule('my_group', get_lang('ThisFieldIsRequired'), 'required');
+                    $form_folder -> addRule('dir_name', get_lang('ThisFieldIsRequired'), 'required');
                     
                     $my_title = !empty($row['title']) ? $row['title'] : basename($row['url']);
                     
-					$defaults = array('my_group[dir_name]' => Security::remove_XSS($my_title), 'description' => Security::remove_XSS($row['description']));
+					$defaults = array('dir_name' => Security::remove_XSS($my_title), 'description' => Security::remove_XSS($row['description']));
 					$form_folder->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'work', 'Width' => '80%', 'Height' => '200'));
 
 					$there_is_a_end_date = false;						
@@ -650,7 +643,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 						
 						$values = $form_folder->exportValues();
                         $work_id = $values['work_id'];
-						$values = $values['my_group'];
+						//$values = $values['my_group'];
                         
 						$dir_name = replace_dangerous_char($values['dir_name']);
 						$dir_name = disable_dangerous_file($dir_name);
@@ -685,7 +678,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
                                                  description = '."'".Database::escape_string($_POST['description'])."'".', 
                                                  qualification = '."'".Database::escape_string($_POST['qualification']['qualification'])."'".',
                                                  weight = '."'".Database::escape_string($_POST['weight']['weight'])."'".' 
-                                             WHERE c_id = '.$course_id.' AND id = '.$row['id'];
+                                             WHERE c_id = '.$course_id.' AND id = '.$row['id'];                            
 							Database::query($sql);
 								
 							require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
@@ -869,21 +862,23 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
 					$class = '';
 				}
 
-				$qualification_string = '';
-				$add_string = '';
-
+				$qualification_string = '';                
 				if ($qualification_exists) {
 					if ($work->qualification == '') {
 						$qualification_string = '<b style="color:orange"> - </b>';
 					} else {
 						$qualification_string = '<b style="color:blue">'.$work->qualification.'</b>';
 					}
-						
-					$time_expires 	= api_strtotime($my_assignment['expires_on']);
-					if (!empty($my_assignment['expires_on']) && $my_assignment['expires_on'] != '0000-00-00 00:00:00' && $time_expires < api_strtotime($work->sent_date)) {
-						$add_string = ' <b style="color:red">'.get_lang('Expired').'</b>';
-					}
-				}
+                }
+                
+                $add_string = '';		
+                $time_expires = api_strtotime($my_assignment['expires_on'], 'UTC');
+                if (!empty($my_assignment['expires_on']) && $my_assignment['expires_on'] != '0000-00-00 00:00:00' && $time_expires < api_strtotime($work->sent_date, 'UTC')) {
+                    $add_string = ' <b style="color:red">'.get_lang('Expired').'</b>';
+                }
+                
+//				}
+                
 				$row[] = '<a href="download.php?id='.$work->id.'">'.build_document_icon_tag('file', substr(basename($work->url), 13)).'</a>';
 				if ($work->contains_file) {
 					$row[] = '<a href="download.php?id='.$work->id.'"'.$class.'>'.Display::return_icon('save.png', get_lang('Save'),array('style' => 'float:right;'), 22).' '.$work->title.'</a><br />'.$work->description;

+ 66 - 62
main/work/work.php

@@ -58,6 +58,7 @@ require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
 $course_id      = api_get_course_int_id();
 $course_info    = api_get_course_info();
 $user_id 	    = api_get_user_id();
+$id_session     = api_get_session_id();
 
 // Section (for the tabs)
 $this_section = SECTION_COURSES;
@@ -94,7 +95,6 @@ $TSTDPUBASG			= Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMEN
 $table_course_user	= Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_user			= Database :: get_main_table(TABLE_MAIN_USER);
 $table_session		= Database :: get_main_table(TABLE_MAIN_SESSION);
-$table_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 $table_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
 /*	Constants and variables */
@@ -127,39 +127,28 @@ $uploadvisibledisabled  = isset($_REQUEST['uploadvisibledisabled']) ? Database::
 
 // get data for publication assignment
 $has_expired = false;
-$has_ended = false;
+$has_ended   = false;
 
 //directories management
 $sys_course_path 	= api_get_path(SYS_COURSE_PATH);
 $course_dir 		= $sys_course_path . $_course['path'];
 $base_work_dir 		= $course_dir . '/work';
 
-$cur_dir_path = '';
-if (isset($curdirpath) && $curdirpath != '') {
-	//now using common security approach with security lib
-	$in_course = Security :: check_abs_path($base_work_dir.$curdirpath, $base_work_dir);	
-	if (!$in_course) {
-		$curdirpath = "/";
-	}	
-}
-if ($curdirpath == '.') {
-	$curdirpath = '/';
-}
-
 /*	Configuration settings */
 
-$link_target_parameter = ""; //or e.g. "target=\"_blank\"";
+api_protect_course_script(true);
+
+$link_target_parameter = ""; // e.g. "target=\"_blank\"";
 
 $display_list_users_without_publication = isset($_GET['list']) && Security::remove_XSS($_GET['list']) == 'without';
 
 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
 
+//Download folder
 if ($action == 'downloadfolder') {
 	require 'downloadfolder.inc.php';
 }
 
-api_protect_course_script(true);
-
 /*	More init stuff */
 
 if (isset ($_POST['cancelForm']) && !empty ($_POST['cancelForm'])) {
@@ -212,16 +201,15 @@ if (!empty($group_id)) {
 	$url_dir = 'work.php?&id=' . $work_id;
 	$interbreadcrumb[] = array ('url' => $url_dir,'name' =>  $my_folder_data['title']);	
 
-	if ($display_upload_form) {
+	if ($action == 'upload_form') {
 		$interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('UploadADocument'));
 	}
-
+    
+    //???
 	if ($display_tool_options) {
-		$interbreadcrumb[] = array (
-			'url' => 'work.php',
-			'name' => get_lang('EditToolOptions'));
+		$interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('EditToolOptions'));
 	}
-
+    
 	if ($action == 'create_dir') {
 		$interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('CreateAssignment'));
 	}
@@ -238,10 +226,9 @@ if (!empty($group_id)) {
         $url_dir = 'work.php?id=' . $work_id;
 		$interbreadcrumb[] = array ('url' => $url_dir,'name' =>  $my_folder_data['title']);	
 		
-		if ($display_upload_form) {
+		if ($action == 'upload_form') {
 			$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UploadADocument'));
 		}
-
 		if ($action == 'settings') {
 			$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditToolOptions'));
 		}
@@ -278,58 +265,72 @@ if (!in_array($action, array('send_mail','add', 'upload'))) {
     $token = Security::get_token();
 }
 
-if ($is_special) {
-	$homework = get_work_assignment_by_id($my_folder_data['id']);
-	$has_expired = $has_ended = false;
-	$has_expiry_date = false;
+$show_tool_options = $action == 'list' ? true : false;
 
+$display_upload_link = $action == 'upload_form' ? false : true;
+if ($is_special) {    
+	$homework = get_work_assignment_by_id($my_folder_data['id']);    
+	
 	if ($homework['expires_on'] != '0000-00-00 00:00:00' || $homework['ends_on'] != '0000-00-00 00:00:00') {
 		$time_now		= time();
 
-		if (!empty($homework['expires_on']) && $homework['expires_on'] != '0000-00-00 00:00:00') {
-			$time_expires 	= api_strtotime($homework['expires_on']);
+		if (!empty($homework['expires_on']) && $homework['expires_on'] != '0000-00-00 00:00:00') {            
+			$time_expires 	= api_strtotime($homework['expires_on'], 'UTC');
 			$difference 	= $time_expires - $time_now;
 			if ($difference < 0) {
-				$has_expired = true;
-				$has_expiry_date = true;
+				$has_expired = true;				
 			}
 		}
+        
+        if (empty($homework['expires_on']) || $homework['expires_on'] == '0000-00-00 00:00:00') {
+			$has_expired = false;
+		}
+        
 		if (!empty($homework['ends_on']) && $homework['ends_on'] != '0000-00-00 00:00:00') {
-			$time_ends 		= api_strtotime($homework['ends_on']);
+			$time_ends 		= api_strtotime($homework['ends_on'], 'UTC');
 			$difference2 	= $time_ends - $time_now;
 			if ($difference2 < 0) {
 				$has_ended = true;
 			}
 		}
-		if (empty($homework['expires_on']) || $homework['expires_on'] == '0000-00-00 00:00:00') {
-			$has_expiry_date = false;
-		}
+		
 		$ends_on 	= api_convert_and_format_date($homework['ends_on']);
 		$expires_on = api_convert_and_format_date($homework['expires_on']);
 
 		if ($has_ended) {
-			display_action_links($work_id, $curdirpath, $always_show_tool_options, $display_upload_form);
-			Display :: display_error_message(get_lang('EndDateAlreadyPassed').' '.$ends_on);
-		} elseif ($has_expired) {
-			display_action_links($work_id,$curdirpath, $always_show_tool_options, $display_upload_form);
-			Display :: display_warning_message(get_lang('ExpiryDateAlreadyPassed').' '.$expires_on);
-		} else {
-			display_action_links($work_id,$curdirpath, $always_show_tool_options, $display_upload_form);
-			if ($has_expiry_date) {
-				Display :: display_normal_message(get_lang('ExpiryDateToSendWorkIs').' '.$expires_on);
+            
+            //if (!api_is_allowed_to_edit()) {                
+                $display_upload_link = false;
+            //}
+			$message = Display::return_message(get_lang('EndDateAlreadyPassed').' '.$ends_on, 'error');
+		} elseif ($has_expired) {            
+            $display_upload_link = true;                       	
+			$message = Display::return_message(get_lang('ExpiryDateAlreadyPassed').' '.$expires_on, 'warning');
+		} else {	
+			if ($has_expired) {
+				$message = Display::return_message(get_lang('ExpiryDateToSendWorkIs').' '.$expires_on);
 			}
-		}
-	} else {
-		display_action_links($work_id,$curdirpath, $always_show_tool_options, $display_upload_form);
+		}        
 	}
-} else {
-	display_action_links($work_id, $curdirpath, $always_show_tool_options, $display_upload_form);
 }
 
+display_action_links($work_id, $curdirpath, $show_tool_options, $display_upload_link, $action);
+echo $message;
+
+//for teachers
+
 switch ($action) {
 	case 'mark_work':
+        if (!api_is_allowed_to_edit()) {
+            echo Display::return_message(get_lang('ActionNotAllowed'), 'error');
+            Display::display_footer();
+					
+        }
 	case 'upload_form': //can be add or edit work
+        $is_author = false;
+        
 		if (empty($item_id)) {
+            
 			$parent_data = get_work_data_by_id($work_id);
 			$parent_data['qualification'] = intval($parent_data['qualification']);
 			
@@ -345,10 +346,7 @@ switch ($action) {
 					exit;
 				}
 			}
-		}
-		
-		$is_author = false;
-		if ($item_id) {
+		} else {
 			//we found the current user is the author
 			$sql = "SELECT * FROM  $work_table WHERE c_id = $course_id AND id = $item_id";
 			$result = Database::query($sql);
@@ -457,13 +455,19 @@ switch ($action) {
 			$form->add_real_progress_bar('uploadWork', 'file');
 		}
 		$form->setDefaults($defaults);
-		//fixes bug when showing modification form
-		
-		if ($student_can_edit_in_session && (empty($item_id) || (!empty($item_id) && ($is_allowed_to_edit or $is_author)))) {
-			$form->display();
-		} else {
-		    Display::display_error_message(get_lang('ActionNotAllowed'));
-		}
+		//fixes bug when showing modification form		
+        if (!empty($work_id)) {
+            if ( $is_allowed_to_edit or $is_author) {
+                $form->display();
+            } elseif ($student_can_edit_in_session && $has_ended == false) {          
+                $form->display();
+            } else {
+                Display::display_error_message(get_lang('ActionNotAllowed'));
+            }
+        } else {
+            Display::display_error_message(get_lang('ActionNotAllowed'));
+        }
+        
 		break;		
 	case 'send_mail':        
 		if (Security::check_token('get')) {

Some files were not shown because too many files changed in this diff