Index: trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 7041)
+++ trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 7068)
@@ -703,7 +703,9 @@
         "class": form["class"],
         startTime: Date.parseExact(form.startDate + " "+$.trim(form.startHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
-        endTime:  Date.parseExact(form.endDate + " "+$.trim(form.endHour), formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),  //+ (!!form.allDay ? 86400000 : 0) ,
-        due: (form.dueDate == '' )? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueTime) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
-        allDay: ( !!form.allDay ? 1 : 0 ),      
+        endTime: (form.dueDate == '' ) ?
+            Date.parseExact(form.startDate + " "+$.trim(form.startHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00') :
+            Date.parseExact(form.dueDate + " "+$.trim(form.dueTime) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
+        due: (form.dueDate == '' ) ? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueTime) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
+        allDay: ( form.dueDate == ''  ? 1 : 0 ),
         status: form.taskStatus,      
         id: form.idTask,
@@ -1062,5 +1064,5 @@
         "class": form["class"],
         startTime: Date.parseExact(form.startDate + " "+$.trim(form.startHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
-        endTime:  Date.parseExact(form.endDate + " "+$.trim(form.endHour), formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),  //+ (!!form.allDay ? 86400000 : 0) ,
+        endTime:  (form.dueDate == '' )? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
         due: (form.dueDate == '' )? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'),
         allDay: ( !!form.allDay ? 1 : 0 ),      
@@ -1647,90 +1649,112 @@
 		
 	    if(!(typeof(evt) == 'object') || (evt.id.indexOf('java') >= 0))
-		return (null);
+			return (null);
 
 	    evt.calendar = evt.calendar || "1";
 
 	    if( !grouped[ evt.calendar ] )
-		grouped[ evt.calendar ] = [];
+			grouped[ evt.calendar ] = [];
 			
 	    var calendar = DataLayer.get('calendar', evt.calendar);
 		
+		var taskEditable = function(idTask){
+			for(var i = 0; i < evt.participants.length; i++){
+				attendee = DataLayer.get('participant', evt.participants[i]);
+				if(attendee.user == User.me.id)
+					return attendee.isOrganizer == '1' ? 
+					{
+						editable: true, 
+						disableResizing: false, 
+						disableDragging: false,
+						className: 'fullcalendar-context-menu  event-type-2 event-id-'+idTask+' calendar-id-'+calendar.id
+					} 
+					: 
+					{
+						editable: false, 
+						disableResizing: true, 
+						disableDragging: true,
+						className: 'blocked-event-permision  fullcalendar-not-context-menu event-id-'+idTask
+					};
+			}
+		}
+		
 	    var eventEditable = function(idEvent, isRecurrence, Recurrence){
-		if(Calendar.signatureOf[calendar.id].isOwner == "1"){
-		    var attendee = {};
-		    for(var i = 0; i < evt.participants.length; i++){
-			attendee = DataLayer.get('participant', evt.participants[i]);
-			if(attendee.user == User.me.id)
-					    return (attendee.acl.indexOf('w') >= 0 || attendee.acl.indexOf('o') >= 0 ) ? 
+			if(Calendar.signatureOf[calendar.id].isOwner == "1"){
+				var attendee = {};
+				for(var i = 0; i < evt.participants.length; i++){
+					attendee = DataLayer.get('participant', evt.participants[i]);
+					if(attendee.user == User.me.id)
+						return (attendee.acl.indexOf('w') >= 0 || attendee.acl.indexOf('o') >= 0 ) ? 
 						{
-				selectable: true, 
-				className: 'fullcalendar-context-menu  event-id-'+idEvent+' calendar-id-'+calendar.id+ (isRecurrence ? ' isRecurrence Recurrence-id-'+Recurrence : '')
-				} : {
-				editable: false, 
-				selectable: true ,
-				className: 'blocked-event-permision  fullcalendar-not-context-menu event-id-'+idEvent
+							selectable: true, 
+							className: 'fullcalendar-context-menu  event-type-1 event-id-'+idEvent+' calendar-id-'+calendar.id+ (isRecurrence ? ' isRecurrence Recurrence-id-'+Recurrence : '')
+						} : {
+							editable: false, 
+							selectable: true ,
+							className: 'blocked-event-permision  fullcalendar-not-context-menu event-id-'+idEvent
+						};
+				}
+				return {
+					editable: false, 
+					className: 'blocked-event-permision  fullcalendar-not-context-menu event-id-'+idEvent+' calendar-id-'+calendar.id,  
+					selectable: true, 
+					disableDragging: isRecurrence
 				};
-		    }
-		    return {
-			editable: false, 
-			className: 'blocked-event-permision  fullcalendar-not-context-menu event-id-'+idEvent+' calendar-id-'+calendar.id,  
-			selectable: true, 
-			disableDragging: isRecurrence
-		    };
-		}
-		else{
-		    var aclSignature = Calendar.signatureOf[calendar.id].permission;
+			}
+			else{
+				var aclSignature = Calendar.signatureOf[calendar.id].permission;
+					
+				var mountClass =  function(acl){
+					var returns = ""
+					returns += acl['write'] ? "" :  'blocked-event-permision ';
+					returns += acl['busy'] ? 'fullcalendar-not-context-menu ' : (acl['read']  ?  'fullcalendar-context-menu '+ (isRecurrence ? ' isRecurrence Recurrence-id-'+Recurrence : '') : '');
+					returns += 'event-id-'+idEvent+' calendar-id-'+calendar.id;
+					return returns;
+				}
 				
-		    var mountClass =  function(acl){
-			var returns = ""
-			returns += acl['write'] ? "" :  'blocked-event-permision ';
-			returns += acl['busy'] ? 'fullcalendar-not-context-menu ' : (acl['read']  ?  'fullcalendar-context-menu '+ (isRecurrence ? ' isRecurrence Recurrence-id-'+Recurrence : '') : '');
-			returns += 'event-id-'+idEvent+' calendar-id-'+calendar.id;
-			return returns;
-		    }				
-		    return DataLayer.merge(
-			{
-			editable: aclSignature.acl['write'] && !isRecurrence,
-			disableResizing : (((aclSignature.acl['busy'] && !aclSignature.acl['write']) || (!aclSignature.acl['write'] && aclSignature.acl['read'])) ? true : false),
-			disableDragging  : (((aclSignature.acl['busy'] && !aclSignature.acl['write']) || (!aclSignature.acl['write'] && aclSignature.acl['read'])) ? true: false),
-			className: mountClass(aclSignature.acl)
-			}, aclSignature.acl['busy'] ? 
-			{
-			    title: 'Ocupado', 
-			    selectable: false
-			} : {
-			    selectable: true
-			});	
-		}
+				return DataLayer.merge({
+					editable: aclSignature.acl['write'] && !isRecurrence,
+					disableResizing : (((aclSignature.acl['busy'] && !aclSignature.acl['write']) || (!aclSignature.acl['write'] && aclSignature.acl['read'])) ? true : false),
+					disableDragging  : (((aclSignature.acl['busy'] && !aclSignature.acl['write']) || (!aclSignature.acl['write'] && aclSignature.acl['read'])) ? true: false),
+					className: mountClass(aclSignature.acl)
+					}, aclSignature.acl['busy'] ? 
+					{
+						title: 'Ocupado', 
+						selectable: false
+					} : {
+						selectable: true
+					}
+				);	
+			}
 	    }
+
+		var duration = parseInt( evt.endTime ) - parseInt( evt.startTime ), isRepeat = false;
+
+		var occurrences = [];
 		
-	    var duration = parseInt( evt.endTime ) - parseInt( evt.startTime ), isRepeat = false;
-		
-	    var occurrences = [];
-		
-	    if( evt.occurrences )
-	    {
-		isRepeat = true;
-		occurrences = evt.occurrences;
+		if( evt.occurrences )
+		{
+			isRepeat = true;
+			occurrences = evt.occurrences;
 	    }else
-		occurrences[ occurrences.length ] = evt.startTime;
+			occurrences[ occurrences.length ] = evt.startTime;
 
 	    //occurrences = DataLayer.unique( occurrences ).sort();
 		var typeEvent;  
-	    for( var i = 0; i < occurrences.length; i++ ){
-
+	    for( var i = 0; i < occurrences.length; i++ )
+		{
             typeEvent = (evt.type == 2 && evt.taskToActivity ? 3 : evt.type)
     		grouped[ evt.calendar ].push( DataLayer.merge(
     		{
-    		    id: evt.URI || evt.id+ '-' + i,
-    		    title: Encoder.htmlDecode(evt.summary),
-    		    start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone,  !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
-    		    end:   Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
-    		    allDay: parseInt( evt.allDay ),
-    		    isRepeat: isRepeat,
-    		    occurrence: i,
-    		    type: typeEvent,
-    		    calendar: evt.calendar
-    		    }, (parseInt(typeEvent) == 1 ? eventEditable(evt.id, isRepeat, i ) : (parseInt(typeEvent) == 2 ? {editable: true, disableResizing: false, disableDragging: false} : {editable: false, disableResizing: true, disableDragging: true}) )) );
+				id: evt.URI || evt.id+ '-' + i,
+				title: Encoder.htmlDecode(evt.summary),
+				start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone,  !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
+				end:   Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving),
+				allDay: parseInt( evt.allDay ),
+				isRepeat: isRepeat,
+				occurrence: i,
+				type: typeEvent,
+				calendar: evt.calendar
+				}, (parseInt(typeEvent) == 1 ? eventEditable(evt.id, isRepeat, i ) : (parseInt(typeEvent) == 2 ? taskEditable(evt.id) : {editable: false, disableResizing: true, disableDragging: true}))));
         }
 	});
