Index: /sandbox/2.4.2-expresso1/expressoCalendar/setup/default_records.inc.php
===================================================================
--- /sandbox/2.4.2-expresso1/expressoCalendar/setup/default_records.inc.php	(revision 5804)
+++ /sandbox/2.4.2-expresso1/expressoCalendar/setup/default_records.inc.php	(revision 6832)
@@ -38,5 +38,6 @@
 		$oProc->query("ALTER TABLE calendar ALTER COLUMN dtstamp SET DEFAULT (date_part('epoch'::text, ('now'::text)::timestamp(3) with time zone) * (1000)::double precision);");
 	
-		$oProc->query("INSERT INTO calendar_object_type( \"id\", \"name\") VALUES ('1','VEVENT');");
+        $oProc->query("INSERT INTO calendar_object_type( \"id\", \"name\") VALUES ('1','VEVENT');");
+		$oProc->query("INSERT INTO calendar_object_type( \"id\", \"name\") VALUES ('2','TODO');");
                 $oProc->query("INSERT INTO calendar_class( \"id\", \"name\") VALUES ('1','Public'),('2','Private'),('3','Confidential');");
                 $oProc->query("INSERT INTO calendar_participant_status( \"id\", \"name\") VALUES ('1','CONFIRMED'),('2','TENTATIVE'),('3','CANCELLED'),('4','UNANSWERED'),('5', 'DELEGATED');");
Index: /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_current.inc.php
===================================================================
--- /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_current.inc.php	(revision 6114)
+++ /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_current.inc.php	(revision 6832)
@@ -48,4 +48,5 @@
                 'duration' => array('type' => 'int', 'precision' => '8' ,'nullable' => True),
                 'tzid' => array('type' => 'varchar', 'precision' => '50' ,'nullable' => True),
+                'type' => array('type' => 'int', 'precision' => '2' ,'nullable' => false, 'default' => 0),
                 'dtstamp' => array('type' => 'int', 'precision' => '8' ,'nullable' => True)
             ),
@@ -277,7 +278,7 @@
 				'msg_alarms' => array( 'type' => 'text', 'nullable' => True),
 				'font_color' => array(  'type' => 'varchar','precision' => '6', 'nullable' => True),
-                                'background_color' => array(  'type' => 'varchar','precision' => '6', 'nullable' => True),
-                                'border_color' => array(  'type' => 'varchar','precision' => '6', 'nullable' => True)
-                                
+                'background_color' => array(  'type' => 'varchar','precision' => '6', 'nullable' => True),
+                'border_color' => array(  'type' => 'varchar','precision' => '6', 'nullable' => True),
+                'type' => array('type' => 'int', 'precision' => '2' ,'nullable' => false, 'default' => 0)
             ),
             'pk' => array('id'),
Index: /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_update.inc.php
===================================================================
--- /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_update.inc.php	(revision 6797)
+++ /sandbox/2.4.2-expresso1/expressoCalendar/setup/tables_update.inc.php	(revision 6832)
@@ -57,15 +57,15 @@
 
 		$oProc->CreateTable('calendar_repeat_ranges', array(
-				'fd' => array(
-				    'id' => array( 'type' => 'auto', 'nullable' => False),
-				    'range_start' => array(  'type' => 'bigint','precision' => '16', 'nullable' => False),
-				    'range_end' => array(  'type' => 'bigint', 'precision' => '16', 'nullable' => False),
-				    'user_info_id' => array(  'type' => 'bigint', 'precision' => '16', 'nullable' => False)
-				),
-				'pk' => array('id'),
-				'fk' => array(),
-				'ix' => array(),
-				'uc' => array()
-				    )
+			'fd' => array(
+			    'id' => array( 'type' => 'auto', 'nullable' => False),
+			    'range_start' => array(  'type' => 'bigint','precision' => '16', 'nullable' => False),
+			    'range_end' => array(  'type' => 'bigint', 'precision' => '16', 'nullable' => False),
+			    'user_info_id' => array(  'type' => 'bigint', 'precision' => '16', 'nullable' => False)
+			),
+			'pk' => array('id'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+			    )
 		);
 
@@ -79,36 +79,36 @@
 	function expressoCalendar_upgrade1_002() {
 
-            $oProc = $GLOBALS['phpgw_setup']->oProc;
+        $oProc = $GLOBALS['phpgw_setup']->oProc;
 
-            $oProc->query("ALTER TABLE calendar_repeat_occurrence ADD COLUMN exception smallint DEFAULT 0");
+        $oProc->query("ALTER TABLE calendar_repeat_occurrence ADD COLUMN exception smallint DEFAULT 0");
 
-            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.003';
-            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
+        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.003';
+        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
 	};
         
         $test[] = '1.003';
 	function expressoCalendar_upgrade1_003() {
-            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.004';
-            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
+        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.004';
+        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
 	};
 
 	$test[] = '1.004';
 	function expressoCalendar_upgrade1_004() {
-            $oProc = $GLOBALS['phpgw_setup']->oProc;
-            $oProc->query("ALTER TABLE calendar_repeat_occurrence  ALTER COLUMN exception SET default 0");
+        $oProc = $GLOBALS['phpgw_setup']->oProc;
+        $oProc->query("ALTER TABLE calendar_repeat_occurrence  ALTER COLUMN exception SET default 0");
 
-            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.005';
-            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
+        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.005';
+        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
 	};
         
         $test[] = '1.005';
 	function expressoCalendar_upgrade1_005() {
-            $oProc = $GLOBALS['phpgw_setup']->oProc;
-            $oProc->query("ALTER TABLE calendar_alarm ADD COLUMN alarm_offset bigint;");
+        $oProc = $GLOBALS['phpgw_setup']->oProc;
+        $oProc->query("ALTER TABLE calendar_alarm ADD COLUMN alarm_offset bigint;");
 	    $oProc->query("UPDATE calendar_alarm SET alarm_offset = obj.range_start - calendar_alarm.range_start FROM calendar_object as obj WHERE obj.id = object_id;");
 	    $oProc->query("ALTER TABLE calendar_alarm DROP COLUMN range_start;");
 	    $oProc->query("ALTER TABLE calendar_alarm DROP COLUMN range_end;");
-            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.006';
-            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
+        $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.006';
+        return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
 	};
 	
@@ -129,6 +129,7 @@
 
 	 	$oProc->query("ALTER TABLE calendar ADD COLUMN type smallint DEFAULT 0;");
-	 	
 	 	$oProc->query("ALTER TABLE calendar_signature ADD COLUMN type smallint DEFAULT 0;");
+
+        $oProc->query("INSERT INTO calendar_object_type(id, name) VALUES ('2', 'TODO');");
 
         $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.008';
Index: /sandbox/2.4.2-expresso1/prototype/config/calendarSignature.ini
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/config/calendarSignature.ini	(revision 6797)
+++ /sandbox/2.4.2-expresso1/prototype/config/calendarSignature.ini	(revision 6832)
@@ -13,4 +13,5 @@
 createDefaultSignature = modules/calendar/interceptors/DBMapping.php
 deepnessFindCalendarSignature = modules/calendar/interceptors/DBMapping.php
+createDefaultGroup = modules/calendar/interceptors/DBMapping.php
 
 [after.read]
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6797)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6832)
@@ -925,5 +925,50 @@
     }
 
+
+     public function createDefaultGroup(&$uri, &$result, &$criteria, $original) {
+        $existDefaultGroup = false;
+
+        foreach($result as $v){
+            if($v['type'] == 1 && $v['calendar']['type'] == 1)
+                $existDefaultGroup = true;
+        }
+
+        if(!$existDefaultGroup){
+
+            $cal = array('name' => 'Sem grupo',
+                'description' => 'Sem grupo',
+                'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo',
+                'dtstamp' => time() . '000',
+                'type' => '1'
+            );
+
+            $calCreated = Controller::create(array('concept' => 'calendar'), $cal);
+
+            $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'],
+                'calendar' => $calCreated['id'],
+                'isOwner' => '1',
+                'dtstamp' => time() . '000',
+                'fontColor' => 'FFFFFF',
+                'backgroundColor' => '3366CC',
+                'borderColor' => '3366CC',
+                'type' => '1'
+            );
+
+            $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
+            $sigCreated = Controller::read(array('concept' => 'calendarSignature', 'id' => $sigCreated['id']), false, array('deepness' => 2 ));
+
+            array_push($result, $sigCreated);
+
+
+        }
+
+     }
+
     public function createDefaultSignature(&$uri, &$result, &$criteria, $original) {
+
+    if(count($result) == 0 && isset($criteria['filter'][3]) && isset($criteria['filter'][3]['isRecursion'])){
+        throw new Exception('It was not possible to find to calendar!');
+        return false;
+    }
 
 	//Caso uma busca não retorne nenhum resultado e foi buscado pelas assinaturas do usuario logado apenas
@@ -933,6 +978,7 @@
 	if (count($result) > 0) {
 	    foreach ($result as $value) {
-		if (isset($value['isOwner']) && $value['isOwner'] != 0)
-		    $isValidSignature = true;
+    		if (isset($value['isOwner']) && $value['isOwner'] != 0)
+    		    $isValidSignature = true;
+
 	    }
 	}
@@ -945,64 +991,71 @@
 
 	    if (Config::module('useCaldav', 'expressoCalendar')) {
-		require_once ROOTPATH . '/modules/calendar/interceptors/DAViCalAdapter.php';
-
-		$calendario = DAViCalAdapter::findCalendars();
+    		require_once ROOTPATH . '/modules/calendar/interceptors/DAViCalAdapter.php';
+    		$calendario = DAViCalAdapter::findCalendars();
 	    }
 
 	    if (Config::module('useCaldav', 'expressoCalendar') && is_array($calendario) && count($calendario) > 0) {
-		foreach ($calendario as $i => $v) {
-
-		    $urlA = explode('/', $v->url);
-		    $name = isset($v->displayname) ? $v->displayname : $urlA[(count($urlA) - 2)];
-		    $cal = array('name' => $name,
-			'description' => isset($v->description) ? $v->description : $name,
-			'timezone' => isset($v->timezone) ? $v->timezone : (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo',
-			'dtstamp' => time() . '000',
-			'location' => $urlA[(count($urlA) - 3)] . '/' . $urlA[(count($urlA) - 2)]
-		    );
-
-		    $calCreated = Controller::create(array('concept' => 'calendar'), $cal);
-
-
-
-		    $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'],
-			'calendar' => $calCreated['id'],
-			'isOwner' => '1',
-			'dtstamp' => time() . '000',
-			'fontColor' => 'FFFFFF',
-			'backgroundColor' => '3366CC',
-			'borderColor' => '3366CC',
-		    );
-
-		    $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
-
-
-		    DAViCalAdapter::importCollection($v->url, $calCreated['id']);
-		}
+    		foreach ($calendario as $i => $v) {
+
+    		    $urlA = explode('/', $v->url);
+    		    $name = isset($v->displayname) ? $v->displayname : $urlA[(count($urlA) - 2)];
+    		    $cal = array('name' => $name,
+    			'description' => isset($v->description) ? $v->description : $name,
+    			'timezone' => isset($v->timezone) ? $v->timezone : (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo',
+    			'dtstamp' => time() . '000',
+    			'location' => $urlA[(count($urlA) - 3)] . '/' . $urlA[(count($urlA) - 2)]
+    		    );
+
+    		    $calCreated = Controller::create(array('concept' => 'calendar'), $cal);
+
+                if(!$calCreated){
+                    throw new Exception('Error to create calendar');
+                    return false;
+                }
+
+    		    $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'],
+    			'calendar' => $calCreated['id'],
+    			'isOwner' => '1',
+    			'dtstamp' => time() . '000',
+    			'fontColor' => 'FFFFFF',
+    			'backgroundColor' => '3366CC',
+    			'borderColor' => '3366CC',
+    		    );
+
+    		    $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
+
+                if(!$sigCreated){
+                    throw new Exception('Error to create signature');
+                    return false;
+                }
+
+    		    DAViCalAdapter::importCollection($v->url, $calCreated['id']);
+    		}
 	    } else {
-		//Criaremos uma agenda padrão
-		$cal = array('name' => 'Calendario',
-		    'description' => 'Calendario Padrão',
-		    'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo',
-		    'dtstamp' => time() . '000'
-		);
-
-		$calCreated = Controller::create(array('concept' => 'calendar'), $cal);
-
-		$sig = array('user' => $_SESSION['wallet']['user']['uidNumber'],
-		    'calendar' => $calCreated['id'],
-		    'isOwner' => '1',
-		    'dtstamp' => time() . '000',
-		    'fontColor' => 'FFFFFF',
-		    'backgroundColor' => '3366CC',
-		    'borderColor' => '3366CC',
-		);
-
-		$sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
-	    }
-
-	    $result = Controller::find($original['URI'], $original['properties'] ? $original['properties'] : null, $original['criteria']);
+    		//Criaremos uma agenda padrão
+    		$cal = array('name' => 'Calendario',
+    		    'description' => 'Calendario Padrão',
+    		    'timezone' => (date_default_timezone_get()) ? date_default_timezone_get() : 'America/Sao_Paulo',
+    		    'dtstamp' => time() . '000'
+    		);
+
+    		$calCreated = Controller::create(array('concept' => 'calendar'), $cal);
+
+    		$sig = array('user' => $_SESSION['wallet']['user']['uidNumber'],
+    		    'calendar' => $calCreated['id'],
+    		    'isOwner' => '1',
+    		    'dtstamp' => time() . '000',
+    		    'fontColor' => 'FFFFFF',
+    		    'backgroundColor' => '3366CC',
+    		    'borderColor' => '3366CC',
+    		);
+
+    		$sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
+        }
+    
+        $original['criteria']['filter'][] = array('isRecursion' => true);
+        $result = Controller::find($original['URI'], $original['properties'] ? $original['properties'] : null, $original['criteria']);
 	    return false;
-	}
+    	}
     }
 
Index: /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js
===================================================================
--- /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js	(revision 6820)
+++ /sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js	(revision 6832)
@@ -241,5 +241,6 @@
     		    			allDay: '1'
     		    		});
-    			    	//DataLayer.commit();
+    			    	
+                        $(componente).qtip('destroy');
 
                     });
@@ -267,5 +268,5 @@
     			    });
     							
-    			    $('.button').button();
+    			    $('.qtip-active .button').button();
     			
     			$('div.qtip.qtip-blue.qtip-active').addClass('new-task');
