Juan Carlos Raña 15 anos atrás
pai
commit
29e4c1ad16

+ 9 - 29
main/calendar/agenda.inc.php

@@ -642,8 +642,8 @@ function selectAll(cbList,bSelect,showwarning)
 		msg_err2 = document.getElementById(\"err_start_date\");
 		msg_err3 = document.getElementById(\"err_end_date\");
 		msg_err4 = document.getElementById(\"err_title\");
-
-		/*if (start_date > ends_date) {
+			
+		if (start_date > ends_date) {
 			msg_err1.style.display =\"block\";
 			msg_err1.innerHTML=\"".get_lang('EndDateCannotBeBeforeTheStartDate')."\";
 			msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\";
@@ -659,7 +659,7 @@ function selectAll(cbList,bSelect,showwarning)
 			msg_err4.style.display =\"block\";
 			msg_err4.innerHTML=\"".get_lang('FieldRequired')."\";
 			msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\";
-		}  else {
+		} else {
 			if (cbList.length <	1) {
 				if (!confirm(\"".get_lang('Send2All')."\")) {
 					return false;
@@ -668,38 +668,18 @@ function selectAll(cbList,bSelect,showwarning)
 			for	(var i=0; i<cbList.length; i++)
 			cbList[i].selected = cbList[i].checked = bSelect;
 			document.new_calendar_item.submit();
-		}*/ 
-			if (start_date > ends_date) {
-			msg_err1.style.display =\"block\";
-			msg_err1.innerHTML=\"".get_lang('EndDateCannotBeBeforeTheStartDate')."\";
-			msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\";
-		} else if (checkDate(start_month,start_day,start_year) == false) {
-			msg_err2.style.display =\"block\";
-			msg_err2.innerHTML=\"".get_lang('InvalidDate')."\";
-			msg_err1.innerHTML=\"\";msg_err3.innerHTML=\"\";
-		} else if (checkDate(ends_month,ends_day,ends_year) == false) {
-			msg_err3.style.display =\"block\";
-			msg_err3.innerHTML=\"".get_lang('InvalidDate')."\";
-			msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\";
-		} else if (document.new_calendar_item.title.value == '') {
-			msg_err4.style.display =\"block\";
-			msg_err4.innerHTML=\"".get_lang('FieldRequired')."\";
-			msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\";
-		} 
-				 else {
-			document.new_calendar_item.submit();
 		}
 
 }
 
-	function reverseAll(cbList)
+function reverseAll(cbList)
+{
+	for	(var i=0; i<cbList.length; i++)
 	{
-		for	(var i=0; i<cbList.length; i++)
-		{
-			cbList[i].checked  = !(cbList[i].checked)
-			cbList[i].selected = !(cbList[i].selected)
-		}
+		cbList[i].checked  = !(cbList[i].checked)
+		cbList[i].selected = !(cbList[i].selected)
 	}
+}
 
 function plus_attachment() {
 				if (document.getElementById('options').style.display == 'none') {

+ 6 - 0
main/course_description/index.php

@@ -122,6 +122,12 @@ $default_description_title_editable[5] = true;
 $default_description_title_editable[6] = true;
 $default_description_title_editable[7] = true;
 
+/*
+-----------------------------------------------------------
+	Tracking
+-----------------------------------------------------------
+*/
+event_access_tool(TOOL_COURSE_DESCRIPTION);
 
 /*
 ==============================================================================

+ 2 - 0
main/inc/lib/main_api.lib.php

@@ -2285,6 +2285,8 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
 	$time = date("Y-m-d H:i:s", $time);
 	if (!empty($session_id)) {
 		$session_id = intval($session_id);
+	} else {
+		$session_id = api_get_session_id();
 	}
 
 	// Definition of tables

+ 14 - 5
main/survey/survey.lib.php

@@ -43,7 +43,7 @@ class survey_manager
 	 * @param integer $survey_id the id of the survey
 	 * @param boolean $shared this parameter determines if we have to get the information of a survey from the central (shared) database or from the
 	 * 		  course database
-	 *
+	 * @param string course code optional
 	 * @return array
 	 *
 	 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@@ -51,12 +51,15 @@ class survey_manager
 	 *
 	 * @todo this is the same function as in create_new_survey.php
 	 */
-	function get_survey($survey_id,$shared=0)
+	function get_survey($survey_id,$shared=0,$course_code='')
 	{
 		global $_course;
 
 		// table definition
-		if (isset($_GET['course'])) {
+		
+		if (!empty($course_code)) {
+			$my_course_id = $course_code;
+		} else if (isset($_GET['course'])) {
 			$my_course_id=Security::remove_XSS($_GET['course']);
 		} else {
 			$my_course_id=api_get_course_id();
@@ -4280,6 +4283,7 @@ class SurveyUtil {
 	 * This function gets all the invited users for a given survey code.
 	 *
 	 * @param	string	Survey code
+	 * @param	string	optional - course database
 	 * @return 	array	Array containing the course users and additional users (non course users)
 	 *
 	 * @todo consider making $defaults['additional_users'] also an array
@@ -4287,10 +4291,15 @@ class SurveyUtil {
 	 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 	 * @version January 2007
 	 */
-	function get_invited_users($survey_code)
+	function get_invited_users($survey_code,$course_db='')
 	{
 		// Database table definition
-		$table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
+		if (!empty($course_db)) {
+			$table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION,$course_db);
+		} else {
+			$table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);	
+		}
+
 	 	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
 
 		// Selecting all the invitations of this survey AND the additional emailaddresses (the left join)

+ 3 - 0
main/survey/survey_list.php

@@ -46,6 +46,9 @@ require ('../inc/global.inc.php');
 require_once('survey.lib.php');
 require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
 
+//Tracking
+event_access_tool(TOOL_SURVEY);
+	
 /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
 if (!api_is_allowed_to_edit(false,true)) //coach can see this
 {

+ 16 - 10
user_portal.php

@@ -61,6 +61,7 @@ require_once $libpath.'debug.lib.inc.php';
 require_once $libpath.'system_announcements.lib.php';
 require_once $libpath.'groupmanager.lib.php';
 require_once $libpath.'usermanager.lib.php';
+require_once 'main/survey/survey.lib.php';
 
 api_block_anonymous_users(); // only users who are logged in can proceed
 
@@ -716,7 +717,7 @@ function show_notification($my_course) {
 	$sqlLastTrackInCourse = "SELECT * FROM $t_track_e_access
 									 USE INDEX (access_cours_code, access_user_id)
 									 WHERE access_cours_code = '".$my_course['k']."'
-									 AND access_user_id = '$user_id'";
+									 AND access_user_id = '$user_id' AND access_session_id ='".$my_course['id_session']."'";
 	$resLastTrackInCourse = Database::query($sqlLastTrackInCourse, __FILE__, __LINE__);
 	$oldestTrackDate = "3000-01-01 00:00:00";
 	while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
@@ -733,7 +734,7 @@ function show_notification($my_course) {
 					WHERE tet.lastedit_date > '$oldestTrackDate'
 					AND ctt.name = tet.tool
 					AND ctt.visibility = '1'
-					AND tet.lastedit_user_id != $user_id
+					AND tet.lastedit_user_id != $user_id AND tet.id_session = '".$my_course['id_session']."'
 					ORDER BY tet.lastedit_date";
 
 	$res = Database::query($sql);
@@ -742,14 +743,19 @@ function show_notification($my_course) {
 	$group_ids[] = 0; //add group 'everyone'
 	//filter all selected items
 	while ($res && ($item_property = Database::fetch_array($res))) {
-		if ((!isset ($lastTrackInCourseDate[$item_property['tool']])
-				|| $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date'])
-			&& ((in_array($item_property['to_group_id'], $group_ids) && $item_property['tool'] != TOOL_DROPBOX)
-				|| $item_property['to_user_id'] == $user_id)
-			&& ($item_property['visibility'] == '1'
-				|| ($my_course['s'] == '1' && $item_property['visibility'] == '0')
-				|| !isset ($item_property['visibility']))) {
-			$notifications[$item_property['tool']] = $item_property;
+					
+		if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date'])
+			&& ((in_array($item_property['to_group_id'], $group_ids) && ($item_property['tool'] != TOOL_DROPBOX && $item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)))
+			&& ($item_property['visibility'] == '1' || ($my_course['s'] == '1' && $item_property['visibility'] == '0') || !isset ($item_property['visibility']))) {
+
+			if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && (($item_property['to_user_id'] != $user_id ) && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'],$group_ids)) )) continue;
+						
+			if ($item_property['tool'] == TOOL_SURVEY) {				
+				$survey_info = survey_manager::get_survey($item_property['ref'],0,$my_course['k']);				
+				$invited_users = SurveyUtil::get_invited_users($survey_info['code'],$course_database);												
+				if (!in_array($user_id,$invited_users['course_users'])) continue;				
+			}					
+			$notifications[$item_property['tool']] = $item_property;						
 		}
 	}
 	//show all tool icons where there is something new