Index: trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5381)
+++ trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5384)
@@ -111,4 +111,18 @@
 	      this.signatureOf[ this.calendarIds[i] = ( this.calendars[ this.calendars.length ] = this.signatures[i].calendar ).id ] = this.signatures[i];
 	  }
+	  this.rerenderView = function(){
+		delete Calendar.currentViewKey;
+		$('#calendar').fullCalendar( 'refetchEvents' );
+		
+		var calendarNotSelected = getNotSelectedCalendars();
+		for(var i = 0; i < calendarNotSelected.length; i++)
+			if(!!Calendar.currentView[ calendarNotSelected[i] ])
+				Calendar.currentView[ calendarNotSelected[i] ].hidden = true;
+	
+		//Necessita ser chamado novamente para atualizar os eventos na tela para o usuário
+		//de acordo com as a agendas selecionadas
+		$('#calendar').fullCalendar( 'refetchEvents' );	
+	  };
+	  
 	  delete Calendar.currentViewKey;
       }
@@ -175,4 +189,8 @@
 Calendar.load();
 
+/* Todo será implementado funcionalidades ajax no calback de importacao de eventos */
+isValidCalback = false;
+
+
 //DataLayer.poll( "schedulable" );
 
@@ -180,18 +198,31 @@
   
     if( status === 'serverclient' ){
-		DataLayer.commit( false, false, function(){
-			delete Calendar.currentViewKey;
-			$('#calendar').fullCalendar( 'refetchEvents' );
-			var calendarNotSelected = getNotSelectedCalendars();
-			for(var i = 0; i < calendarNotSelected.length; i++)
-				Calendar.currentView[ calendarNotSelected[i] ].hidden = true;
-			//Necessita ser chamado novamente para atualizar os eventos na tela para o usuário
-			//de acordo com as a agendas selecionadas
-			$('#calendar').fullCalendar( 'refetchEvents' );
+		DataLayer.commit( false, false, function(){	
+			Calendar.rerenderView();
 			//Atualiza a listagem de eventos apenas se estiver na aba de listagem
 			if($tabs.tabs('option' ,'selected') == 1)
 				pageselectCallback("", 0);
 		});
-    }	
+    }
+});
+
+DataLayer.listen( "calendarToSchedulable", function( status, updateData){
+  
+    if( status === 'client' ){
+		if(updateData && isValidCalback){
+			isValidCalback = false;
+			$.Zebra_Dialog('Evento(s) importados com sucesso!', {
+				'overlay_opacity': '0.5',
+				'onClose':  function(clicked) {				
+					Calendar.rerenderView();
+				}
+			});
+			isValidCalback = false;
+		}else if(updateData == false){
+			$.Zebra_Dialog('Erro ao importar evento(s)!', {
+				'overlay_opacity': '0.5'	
+			});
+		}
+    };	
 });
 
@@ -668,5 +699,5 @@
 			      calendars: Calendar.calendars,
 			      calendar: objEvent.calendar,
-			      summary: objEvent.summary,
+			      summary: Encoder.htmlEncode(objEvent.summary),
 			      description: objEvent.description,
 			      timezone: objEvent.timezone,
Index: trunk/prototype/modules/calendar/js/helpers.js
===================================================================
--- trunk/prototype/modules/calendar/js/helpers.js	(revision 5381)
+++ trunk/prototype/modules/calendar/js/helpers.js	(revision 5384)
@@ -597,5 +597,5 @@
 					
 					
-					var isExternal = (user) ? user.isExternal : 1;
+					var isExternal = (!!user && !!user.isExternal) ? 0 : 1;
 
 					/**
@@ -610,5 +610,5 @@
 					if (user){
 						if (!skipAddNewLine) {
-							user[0].id =  DataLayer.put('participant', {user: user[0].id, isExternal: 1});
+							user[0].id =  DataLayer.put('participant', {user: user[0].id, isExternal: isExternal});
 							blkAddAtendee.find('dd.attendee-list ul.attendee-list').append(
 								DataLayer.render('templates/participants_add_itemlist.ejs', user)
@@ -1077,4 +1077,6 @@
 				}
 				DataLayer.remove('calendarSignature', signature);
+				if(idCalendar == User.preferences.defaultCalendar)
+					DataLayer.remove( 'modulePreference', User.preferenceIds['defaultCalendar']);
 				$('.positionHelper').css('display', 'none');
 			}else{
@@ -1176,5 +1178,5 @@
 					user: User.me.id,
 					calendar: {
-						name: $('.qtip-active input').val(),
+						name: Encoder.htmlEncode($('.qtip-active input').val()),
 						timezone: User.preferences.timezone				
 					},
@@ -1239,9 +1241,11 @@
 			}
 			
-			if(Calendar.currentView){
+			 if(Calendar.currentView){
 				var checkBox = $(this);
-				Calendar.currentView[ checkBox.val() ].hidden = !checkBox.is(':checked');
-				$('#calendar').fullCalendar( 'refetchEvents' );
-			}		
+                if(!!Calendar.currentView[ checkBox.val() ]){
+					Calendar.currentView[ checkBox.val() ].hidden = !checkBox.is(':checked');
+					$('#calendar').fullCalendar( 'refetchEvents' );
+				}
+			}
 	    });
       });
@@ -1526,4 +1530,5 @@
 			$('.import-event-form', UI.dialogs.importCalendar).submit();			
 			UI.dialogs.importCalendar.dialog("close");
+			isValidCalback = true;
 			/**
 			 * TODO - implementar ação de importação
