Index: sandbox/2.5.1-expresso2/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- sandbox/2.5.1-expresso2/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7795)
+++ sandbox/2.5.1-expresso2/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7869)
@@ -599,12 +599,14 @@
                     $isAllDay = 1;
 
+                    $taskToActivity = Controller::find(array('concept' => 'taskToActivity'), false, array('filter' => array('AND', array('=', 'activity', $taskToActivity[0]['activity']), array('=', 'owner', Config::me('uidNumber'))), 'deepness' => 2));
+
                     if(!empty($activity)){
                         $start = $params['startTime'];
                         $end = $params['endTime'];
                         foreach($taskToActivity as $t){
-                         if($t['task']['id'] != $params['id']){
-                            $start = $t['task']['startTime'] < $start ? $t['task']['startTime'] : $start;
-                            $end = $t['task']['endTime'] > $end ? $t['task']['endTime'] : $end;
-                            $isAllDay = (($isAllDay == 1) && ($t['task']['allDay'] == '1')) ? 1 : 0;
+                         if($t['task']['id'] != $params['id']){ 
+                             $start = $t['task']['startTime'] < $start ? $t['task']['startTime'] : $start; 
+                             $end = $t['task']['endTime'] > $end ? $t['task']['endTime'] : $end; 
+                             $isAllDay = (($isAllDay == 1) && ($t['task']['allDay'] == '1')) ? 1 : 0; 
                          }
                         }
@@ -841,17 +843,34 @@
     }
 
+    //Função que traz o 'calendar'(grupo) das tarefas.
+    public function getCalendarTask( $task ){
+
+        $sql = 'select co.calendar_id as "calendar" from calendar_to_calendar_object as "co", calendar_signature as "cs" where cs.user_uidnumber = '. Config::me('uidNumber') 
+        .' AND cs.is_owner = 1 AND cs.calendar_id = co.calendar_id AND co.calendar_object_id = '. $task;
+
+
+        $returns = Controller::service('PostgreSQL')->execResultSql($sql);
+
+        return $returns[0]['calendar'];
+
+    }
+
     //TODO: Remover apos suporte a deepness na api 
     public function deepnessFindTask(&$uri, &$result, &$criteria, $original) {
-        if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) 
-           foreach($result as &$value)
+
+        if (isset($criteria['deepness']) && $criteria['deepness'] != 0){ 
+              foreach($result as &$value){
                 $value['task'] = Controller::read(array('concept' => 'schedulable', 'id' => $value['task']));
-           
+                $value['task']['calendar'] = self::getCalendarTask( $value['task']['id'] );    
+
+            }
         
         return $result;
     }
+    }
 
     //TODO: Remover apos suporte a deepness na api 
     public function deepnessFindHistoric(&$uri, &$result, &$criteria, $original) {
-        if (isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) {
+        if (isset($criteria['deepness']) && $criteria['deepness'] != 0) {
             foreach($result as &$v){
                 $v['user'] = Controller::read(array('concept' => 'user', 'id' => $v['user']));
@@ -883,9 +902,24 @@
                 .'calendar_object.range_end as "rangeEnd", calendar_object.last_update as "lastUpdate", '
                 .'calendar_object.dtstamp as "dtstamp", calendar_object.sequence as "sequence", '
-                .'calendar_object.tzid as "timezone" '
-                .'FROM calendar_object '
-                .'WHERE ( calendar_object.id = '. $criteria['schedulable'] .')';
+                .'calendar_object.tzid as "timezone", calendar_to_calendar_object.calendar_id as "calendar" ' 
+                .'FROM calendar_object, calendar_to_calendar_object ' 
+                .'WHERE ( calendar_object.id = '. $criteria['schedulable'] .' AND calendar_to_calendar_object.calendar_object_id = calendar_object.id)';
+
 
             $params = Controller::service('PostgreSQL')->execResultSql($sql);
+
+            foreach( $params as &$event ){ 
+                if(isset( $event['repeat'] ) && isset( $event['repeat']['id'] ) ){ 
+                    $occurrences = Controller::service('PostgreSQL')->execResultSql('SELECT DISTINCT occurrence FROM calendar_object as "c", calendar_repeat_occurrence as "o", calendar_repeat as "r" WHERE r.object_id = '. $event['id'] .' AND o.repeat_id = r.id ' ); 
+   
+                    if($occurrences){ 
+                        $event['occurrences'] = array(); 
+
+                        foreach($occurrences as $o) 
+                            $event['occurrences'][] = $o['occurrence']; 
+                    }else 
+                        unset( $event['occurrences'] ); 
+                } 
+            }
 
             $params = self::deepnessFindEvent($uri, $params, $criteria, $original);
@@ -899,5 +933,5 @@
     //TODO: Remover apos suporte a deepness na api 
     public function deepnessFindEvent(&$uri, &$result, &$criteria, $original) {
-        if ((isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0) ) {
+        if ((isset($criteria['deepness']) && $criteria['deepness'] != 0) ) {
 
             $date = new DateTime('now', new DateTimeZone('UTC'));
@@ -988,5 +1022,5 @@
     public static function deepnessReadParticipant( &$uri , &$result , &$criteria , $original ){
 	
-       if(isset($original['criteria']['deepness']) && $original['criteria']['deepness'] != 0)
+       if(isset($criteria['deepness']) && $criteria['deepness'] != 0)
        {
             if(isset($result['id']) && isset($result['user']))
Index: sandbox/2.5.1-expresso2/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- sandbox/2.5.1-expresso2/prototype/modules/calendar/js/calendar.codecs.js	(revision 7790)
+++ sandbox/2.5.1-expresso2/prototype/modules/calendar/js/calendar.codecs.js	(revision 7869)
@@ -1171,5 +1171,6 @@
 					percentage: task.percentage,
 					priority: task.priority,
-					summary: task.summary
+					summary: task.summary,
+					group: task.calendar
                 }
 
Index: sandbox/2.5.1-expresso2/prototype/modules/calendar/js/activity.helpers.js
===================================================================
--- sandbox/2.5.1-expresso2/prototype/modules/calendar/js/activity.helpers.js	(revision 7680)
+++ sandbox/2.5.1-expresso2/prototype/modules/calendar/js/activity.helpers.js	(revision 7869)
@@ -222,9 +222,54 @@
     }
     */
-	UI.dialogs.addActivity.find('select[name="activityStatus"], input[name="allDay"]').removeAttr('disabled');
-    canDiscardActivityDialog = true;
-	
-	UI.dialogs.addActivity.children().find('form.form-addactivity').submit();
-	UI.dialogs.addActivity.dialog("close");
+
+    //Código o qual será chamado para o salvamento da Atividade.
+    var handler_save = function (objsToSave){
+        UI.dialogs.addActivity.find('select[name="activityStatus"], input[name="allDay"]').removeAttr('disabled');
+        canDiscardActivityDialog = true;
+
+        var activity_tst = DataLayer.form( UI.dialogs.addActivity.children().find('form') );
+        if(objsToSave)
+            objsToSave[objsToSave.length] = activity_tst;
+       
+        else 
+            objsToSave = activity_tst;
+        DataLayer.put('schedulable', objsToSave);
+        
+        UI.dialogs.addActivity.dialog("close");
+    }
+
+    //Verifica se o grupo da atividade mudou
+    if (group.id != UI.dialogs.addActivity.children().find('form select[name="group"] :selected').val() && typeof group.id != 'undefined') {
+        //Janela de dialogo
+        $.Zebra_Dialog('Você alterou o grupo da atividade, deseja alterar também o grupo das tarefas pertencentes à essa atividade?', {
+            'type':     'question',
+            'overlay_opacity': '0.5',
+            'modal': true,
+            'buttons':  ['Não Alterar', 'Alterar'],
+            'onClose':  function(clicked) {
+                if(clicked == 'Não Alterar') {
+                  
+                    handler_save();
+                }else{
+                    var objsToSave = [];
+                    //percorre as tarefas da atividade para verificar se o grupo mudou
+                    for(var t in objActivity.tasks){
+                        if(typeof objActivity.tasks[t].group != 'undefined')
+                            if (objActivity.tasks[t].group != UI.dialogs.addActivity.children().find('form select[name="group"] :selected').val()){
+                                objActivity.tasks[t].group = UI.dialogs.addActivity.children().find('form select[name="group"] :selected').val();
+                                objsToSave[objsToSave.length] = {'calendar' : objActivity.tasks[t].group, 'id': t};
+                            }
+                    }
+                    handler_save(objsToSave);
+                    
+                }
+                
+            }
+        });
+                        
+    
+    } else {
+        handler_save();
+    }
 
 }).end()
@@ -259,7 +304,5 @@
                     ['=', 'type', '2'], 
                     ['>=','startTime', $.now()], 
-                    ['in', 'calendar', 
-                        [$('div.new-activity-win.active select[name="groupFilter"]').val()]
-                    ]
+                    ['in', 'calendar', [$('div.new-activity-win.active select[name="groupFilter"]').val()]]
                 ], criteria: {filterTasks: true, deepness: 2}
         };
@@ -412,5 +455,9 @@
     updateActivity = false;
 
-    var objActivity = DataLayer.get('schedulable:activity', UI.dialogs.addActivity.find('input[name="idActivity"]').val());
+    var idTask = UI.dialogs.addActivity.find('input[name="idActivity"]').val(); 
+      
+    getSchedulable( idTask ); 
+      
+    var objActivity = DataLayer.get('schedulable:activity', idTask ); 
     var blkAddTask = UI.dialogs.addActivity.find('#group_addactivity_details8');
     var blkAuto = UI.dialogs.addActivity.find('#group_addactivity_details1');
@@ -671,6 +718,8 @@
             text: false
         }).click(function () {
-	    var task = DataLayer.get('schedulable:task', $(this).parents('li').find('input[name="idtask[]"]').val());
-	    taskDetails(task, true, '',true, null, true);           
+	    var idTask = $(this).parents('li').find('input[name="idtask[]"]').val() 
+        getSchedulable(idTask); 
+        var task = DataLayer.get('schedulable:task', idTask); 
+        taskDetails(task, true, '',true, null, true);     
         })
         .addClass('tiny disable ui-button-disabled ui-state-disabled')
Index: sandbox/2.5.1-expresso2/prototype/modules/calendar/js/init.js
===================================================================
--- sandbox/2.5.1-expresso2/prototype/modules/calendar/js/init.js	(revision 7787)
+++ sandbox/2.5.1-expresso2/prototype/modules/calendar/js/init.js	(revision 7869)
@@ -503,4 +503,5 @@
                     break;
                 case 3:
+                    DataLayer.remove('taskToActivity', false);//Limpa o cache
                     var activity = getSchedulable(evt.id, '');
                     activity.group = evt.calendar;
