Index: /trunk/prototype/services/iCal.php
===================================================================
--- /trunk/prototype/services/iCal.php	(revision 5592)
+++ /trunk/prototype/services/iCal.php	(revision 5615)
@@ -747,6 +747,6 @@
         static private function _getSchedulable( $uid )
         {
-           $schedulable =  Controller::find( array( 'concept' => 'schedulable' ) , null , array ( 'deepness' => '2' , 'filter' => array( '=' , 'uid' , $uid )));
-           return (isset($schedulable[0])) ? $schedulable[0] : false;
+           $schedulable =  Controller::find( array( 'concept' => 'schedulable' ) , false , array ( 'filter' => array( '=' , 'uid' , $uid ), 'criteria' => array('deepness' => 2) ));		   
+		   return (isset($schedulable[0])) ? $schedulable[0] : false;
         }
         
Index: /trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- /trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5592)
+++ /trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5615)
@@ -10,11 +10,14 @@
         $params['type_id'] = EVENT_ID;
 	
-		$params['startTime'] =  strtotime( $params['startTime'] . ' ' .$params['timezone']).'000';
-	
-		$params['endTime'] =   strtotime( $params['endTime'] . ' ' .$params['timezone']).'000';
+	
+		if(!is_numeric($params['startTime']) )
+			$params['startTime'] =  strtotime( $params['startTime'] . ' ' .$params['timezone']).'000';
 		
-		if($params['allDay'])
-			$params['endTime'] =  $params['endTime']  + 86400000;
-
+		if (!is_numeric($params['endTime'])){
+			$params['endTime'] =   strtotime( $params['endTime'] . ' ' .$params['timezone']).'000';
+			
+			if($params['allDay'])
+				$params['endTime'] =  $params['endTime']  + 86400000;
+		}
     //        if( !isset( $new['repeat'] ))
     //            $new['range_end'] = '7287926400'; // 12/12/2200
Index: /trunk/prototype/modules/calendar/interceptors/Helpers.php
===================================================================
--- /trunk/prototype/modules/calendar/interceptors/Helpers.php	(revision 5437)
+++ /trunk/prototype/modules/calendar/interceptors/Helpers.php	(revision 5615)
@@ -5,6 +5,7 @@
     public static function futureEvent( $startTime , $rangeEnd )
     {
-        //Verifica data   
-        list( $y1  , $m1 , $d1) = explode( '-' , $rangeEnd ); 
+        //Verifica data  
+		$range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') );
+        list( $y1  , $m1 , $d1) = explode( '-' , $range->format('y-m-d')); 
                 
         $rangeEndMicrotime = gmmktime(0, 0, 0, $m1 , $d1, $y1); 
Index: /trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- /trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5608)
+++ /trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5615)
@@ -294,4 +294,6 @@
 });
 
+//TODO - Voltar quando tratado put de varios items de um mesmo conceito,
+/*
 DataLayer.listen( "calendarSignature", function( status ){
 
@@ -307,4 +309,5 @@
     }
 });
+*/
 
 DataLayer.listen( "modulePreference", function( status ){
@@ -360,5 +363,5 @@
 					location: form.location
 				},
-				isOwner: 1,
+			//	isOwner: 1,
 				fontColor: Encoder.htmlEncode(form.fontColor.substring(1)),
 				backgroundColor: Encoder.htmlEncode(form.backgroundColor.substring(1)),
Index: /trunk/prototype/modules/calendar/js/calendar.shared.js
===================================================================
--- /trunk/prototype/modules/calendar/js/calendar.shared.js	(revision 5592)
+++ /trunk/prototype/modules/calendar/js/calendar.shared.js	(revision 5615)
@@ -317,5 +317,11 @@
 					DataLayer.put('calendarSignature', DataLayer.merge({calendar: calendarId, isOwner: 0, user: User.me.id, fontColor: '120d0d', backgroundColor: (!!type ? 'fbec88' : '8c8c8c'), borderColor: (!!type ? 'fad24e' : '120d0d')}, !!idPermission ? {id: idPermission} : {} ));
 				});
-				
+
+			DataLayer.commit( false, false, function( received ){
+					delete Calendar.currentViewKey;
+					Calendar.load();
+					refresh_calendars();
+			});
+	
 			UI.dialogs.sharedCalendar.dialog("close");
 		
Index: /trunk/prototype/modules/calendar/js/helpers.js
===================================================================
--- /trunk/prototype/modules/calendar/js/helpers.js	(revision 5592)
+++ /trunk/prototype/modules/calendar/js/helpers.js	(revision 5615)
@@ -1327,4 +1327,10 @@
 				template_content.find('form').submit();
 				$tabs.tabs( "remove", "#configure_tab");
+				DataLayer.commit( false, false, function( received ){
+					delete Calendar.currentViewKey;
+					Calendar.load();
+					refresh_calendars();
+				});
+				
 			}).end().filter('.cancel').click(function(evt){
 				$tabs.tabs( "remove", "#configure_tab");
@@ -1422,4 +1428,11 @@
 				if(idCalendar == User.preferences.defaultCalendar)
 					DataLayer.remove( 'modulePreference', User.preferenceIds['defaultCalendar']);
+					
+					
+				DataLayer.commit( false, false, function( received ){
+					delete Calendar.currentViewKey;
+					Calendar.load();
+					refresh_calendars();
+				});
 			}
 				$('.positionHelper').css('display', 'none');
@@ -1527,4 +1540,11 @@
 					borderColor: colorsSuggestions[selected]['border'].substring(1)
 				});
+				
+				DataLayer.commit( false, false, function( received ){
+					delete Calendar.currentViewKey;
+					Calendar.load();
+					refresh_calendars();
+				});
+				
 				meu_container.find(".button.new").qtip('destroy');
 			});
@@ -1953,6 +1973,11 @@
 		delete newSchedulable.dtstamp;
 		delete schedulable.calendar;
-		
-		schedulable.calendar = calendar;	
+		delete schedulable.DayLigth;
+		delete schedulable.rangeStart
+		delete schedulable.rangeEnd;
+		delete schedulable.lastUpdate;
+		delete schedulable.repeat;
+	
+		schedulable.calendar = DataLayer.copy(calendar);	
 	
 		newSchedulable.endTime = new Date(parseInt(newSchedulable.endTime) - (newSchedulable.allDay ? 86400000 : 0)).toString('yyyy-MM-dd hh:mm:00');
@@ -1960,4 +1985,5 @@
 		
 		var participants = DataLayer.copy(schedulable.participants);
+		
 		delete schedulable.participants;
 		
@@ -1970,12 +1996,11 @@
 	
 			delete participant.id;
+			delete participant.schedulable;
+			delete participant.delegatedFrom;
 			
 			return participant ;
         });
 	
-	
-	
-		DataLayer.put('schedulable', newSchedulable);
-
+		DataLayer.put('schedulable', newSchedulable);		
 	}
 	
Index: /trunk/prototype/api/datalayer.js
===================================================================
--- /trunk/prototype/api/datalayer.js	(revision 5604)
+++ /trunk/prototype/api/datalayer.js	(revision 5615)
@@ -1073,5 +1073,5 @@
 	    result = this.check( concept, id || filter );
 	
-	if (bothSides && filter.filter && filter.criteria)
+	if (bothSides && filter.filter)
 		result = false;
 
@@ -1112,5 +1112,5 @@
       
 	for( var key in base )
-	    if( this.storage.filter( base[key], filter ) )
+	    if( this.storage.filter( base[key], this.copy( filter ) ) )
 		filtered[ filtered.length ] = key;
 
@@ -1125,8 +1125,8 @@
 
     
-    compare: function( operator, base, test ){
+    compare: function( operator, b, t ){
       
-	base = this.converterType(base);
-	test = this.converterType(test);
+	var base = this.converterType(b);
+	var test = this.converterType(t);
 	 
     switch( operator ){
@@ -1145,5 +1145,5 @@
 	case '<':  return ( base >  test );
 	
-	default: return true;
+	default: return false;
 	}
       
@@ -1164,12 +1164,12 @@
 
 	if( !filter || !result )
-	  return( result || false );
-
-	var keys = DataLayer.copy( filter );
-
-	if( notArray = $.type(keys) === "string" )
-	    keys = [ keys ];
-	else if( $.type(keys) !== "array" )
-		keys = this.filter( result, keys.filter, keys.criteria );
+	  return DataLayer.copy( result || false );
+
+	var keys = [];
+
+	if( notArray = $.type(filter) === "string" )
+	    keys = [ filter ];
+	else if( $.type(filter) !== "array" )
+		keys = this.filter( result, filter.filter, filter.criteria );
 
 	var res = [];
@@ -1178,5 +1178,5 @@
 	    res[ res.length ] = result[keys[i]];
 
-	return( notArray ? res[0] || false : res.length ? res : false );
+	return DataLayer.copy( notArray ? res[0] || false : res.length ? res : false );
     },
 
@@ -1192,5 +1192,5 @@
 	get: function( key ){
 
-	    return DataLayer.copy( this.cache[key] );
+	    return this.cache[key];
 
 	},
Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 5604)
+++ /trunk/expressoMail1_2/index.php	(revision 5615)
@@ -30,13 +30,5 @@
 					<link rel="Stylesheet" type="text/css" href="templates/default/expressoMail_reset.css" />
 					<script type="text/javascript" src="../prototype/plugins/jquery/jquery.min.js"></script>
-					
-					<script type="text/javascript">
-						$.ajax({
-							url: "../expressoCalendar/index.php",
-							async: false});
-					
-					</script>
-					
-					
+
 					<script type="text/javascript" src="../prototype/plugins/jquery/jquery-ui.min.js"></script>
 					<script type="text/javascript" src="../prototype/plugins/jquery/jquery-ui.custom.min.js"></script>
@@ -63,5 +55,5 @@
 					<script type="text/javascript" src="../prototype/plugins/datejs/sugarpak.js"></script>
 					<script type="text/javascript" src="../prototype/plugins/datejs/parser.js"></script>
-					<script type="text/javascript" src="../prototype/plugins/dateFormat/dateFormat.js"></script>
+
 					<script type="text/javascript" src="../prototype/plugins/watermark/jquery.watermarkinput.js"></script>
 					<script type="text/javascript" src="../prototype/plugins/mask/jquery.maskedinput.js"></script>
@@ -69,9 +61,5 @@
 					<script type="text/javascript" src="../prototype/plugins/timepicker/localization/jquery-ui-timepicker-pt-BR.js"></script>
 					<script type="text/javascript" src="../prototype/plugins/jquery-elastic/jquery.elastic.source.js"></script>
-					<script type="text/javascript" src="../prototype/modules/calendar/js/calendar.date.js"></script>
-					<script type="text/javascript" src="../prototype/modules/calendar/js/helpers.js"></script>
-					<script type="text/javascript" src="../prototype/modules/calendar/js/timezone.js"></script>
-					<script type="text/javascript" src="../prototype/modules/calendar/js/calendar.codecs.js"></script>
-					<script type="text/javascript" src="../prototype/plugins/encoder/encoder.js"></script>
+					
 					<script type="text/javascript" src="../prototype/plugins/qtip/jquery.qtip-1.0.0-rc3.min.js"></script>
 					<script type="text/javascript" src="../prototype/plugins/contextmenu/jquery.contextMenu.js"></script>
@@ -79,5 +67,5 @@
 					<script type="text/javascript" src="../prototype/plugins/fileupload/jquery.iframe-transport.js"></script>
 					<!-- <script type="text/javascript" src="../prototype/plugins/contextmenu/jquery.ui.position.js"></script> -->
-					<script language="javascript">var CalendarBkp = Calendar;</script>
+					
                 <script src="js/rich_text_editor.js" type="text/javascript"></script>
                 <script src="js/base64.js" type="text/javascript"></script>';
@@ -94,7 +82,5 @@
 	echo '<script type="text/javascript" src="../phpgwapi/js/wz_dragdrop/wz_dragdrop.js?'.$update_version.'"></script>
 		<script type="text/javascript" src="../phpgwapi/js/dJSWin/dJSWin.js?'.$update_version.'"></script>
-		<script type="text/javascript" src="../phpgwapi/js/x_tools/xtools.js?'.$update_version.'"></script>';
-	echo "<script language='javascript'>Calendar = $.extend(CalendarBkp, Calendar);</script>";
-		
+		<script type="text/javascript" src="../phpgwapi/js/x_tools/xtools.js?'.$update_version.'"></script>';		
 
 	echo '
