Index: /branches/2.5/phpgwapi/setup/phpgw_pt-br.lang
===================================================================
--- /branches/2.5/phpgwapi/setup/phpgw_pt-br.lang	(revision 5870)
+++ /branches/2.5/phpgwapi/setup/phpgw_pt-br.lang	(revision 7982)
@@ -54,4 +54,5 @@
 austria	common	pt-br	AUSTRIA
 author	common	pt-br	Autor
+Auto import calendars to receive an internal event	common	pt-br	Auto importar calendarios ao receber um evento interno
 autohide sidebox menus	common	pt-br	Ocultar Caixa do Menu
 automacally hide the sidebox menus?	common	pt-br	Esconder automáticamente os menus laterais
@@ -208,4 +209,6 @@
 exact	common	pt-br	exato(a)
 exit	common	pt-br	Sair
+ExpressoCalendar migration	common	pt-br	ExpressoCalendar migração
+expressoCalendar Setup	common	pt-br	Configuração do ExpressoCalendar
 ExpressoLivre is unavailable at this moment. Code %1<br>Please, try later.	common	pt-br	ExpressoLivre indisponível no momento. Código %1<br>Tente mais tarde.
 Catalog is out of service, you will not able to do some operations	common	pt-br	O serviço de catálogo está em manutenção, você não poderá realizar algumas operações
@@ -244,4 +247,5 @@
 gibraltar	common	pt-br	GIBRALTAR
 Global Catalogues Configuration	common	pt-br	Configuração Global do Catálogo
+Global Settings	common	pt-br	Configurações globais
 global	common	pt-br	Global
 global public	common	pt-br	Público a todos
Index: /branches/2.5/admin/inc/class.uiconfig.inc.php
===================================================================
--- /branches/2.5/admin/inc/class.uiconfig.inc.php	(revision 7655)
+++ /branches/2.5/admin/inc/class.uiconfig.inc.php	(revision 7982)
@@ -53,5 +53,5 @@
 				default:
 					$appname = $_GET['appname'];
-					$config_appname = $appname;
+					$config_appname = (isset($_GET['config']) && $_GET['config']) ? $_GET['config'] : $appname ;
 					break;
 			}
@@ -72,5 +72,28 @@
 			}
 	
-		if($appname === "expressoCalendar"){						
+                if($appname === "expressoCalendar"){ 
+ 
+            if($config_appname == 'expressoCalendar' ) 
+            { 
+                $t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)); 
+ 
+            }; 
+ 
+            if($_POST['newsettings']['expressoCalendar_autoImportCalendars'] == 'true') 
+            { 
+                $db = $GLOBALS['phpgw']->db; 
+                $calendars = array(); 
+                $db->query('SELECT calendar_signature.user_uidnumber as "user",calendar.id as "calendar" FROM calendar,calendar_signature WHERE calendar.id = calendar_signature.calendar_id AND calendar.type = 0 AND calendar_signature.is_owner = 1 AND (SELECT id from module_preference WHERE user_uidnumber = calendar_signature.user_uidnumber AND module_preference.module = \'expressoCalendar\' AND module_preference.name = \'dafaultImportCalendar\'  ) IS NULL'); 
+                while( $db->next_record() ) 
+                { 
+                    $calendars[] = $db->row(); 
+                } 
+ 
+                foreach($calendars as $v) 
+                { 
+                    $db->query('INSERT INTO module_preference ("user_uidnumber","value","name","module") VALUES ( \''.$v['user'].'\' , \''.$v['calendar'].'\',\'dafaultImportCalendar\' , \'expressoCalendar\')'); 
+                } 
+            } 
+ 
 			if (isset($_POST['migration']) && ($_POST['migration']  == "true")){
 			
@@ -80,4 +103,5 @@
 				$migratrion->calendar();
 			}
+ 
 		}
 
@@ -105,5 +129,5 @@
 							if(function_exists(substr($key,0,strrpos($key,'_'))))
                         	{
-                                call_user_func(substr($key,0,strrpos($key,'_')),&$config);
+                                call_user_func(substr($key,0,strrpos($key,'_')), $config);
                         	} 
                         	else 
@@ -114,5 +138,5 @@
                         	if($GLOBALS['config_error'])
 							{
-								$errors .= lang($GLOBALS['config_error']) . '&nbsp;';
+								$errors = lang($GLOBALS['config_error']) . '&nbsp;';
 								$GLOBALS['config_error'] = False;
 							}
Index: /branches/2.5/expressoCalendar/inc/hook_admin.inc.php
===================================================================
--- /branches/2.5/expressoCalendar/inc/hook_admin.inc.php	(revision 5804)
+++ /branches/2.5/expressoCalendar/inc/hook_admin.inc.php	(revision 7982)
@@ -13,5 +13,6 @@
 	$title = $appname;
 	$file = Array(
-		'ExpressoCalendar migração' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
+                'ExpressoCalendar migration' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname. '&config=migra'), 
+        'Global Settings' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname) 
 	);
 	//Do not modify below this line
Index: /branches/2.5/expressoCalendar/templates/default/config.tpl
===================================================================
--- /branches/2.5/expressoCalendar/templates/default/config.tpl	(revision 5804)
+++ /branches/2.5/expressoCalendar/templates/default/config.tpl	(revision 7982)
@@ -1,41 +1,34 @@
 <!-- BEGIN header -->
-<form  method="POST" action="{action_url}">
-<input type="hidden" name="migration" value="true">
-<table border="0" align="center">
-	<tr class="th">
-		<td colspan="2"><font color="{th_text}">&nbsp;<b>{title}</b></font></td>
-	</tr>
-	<tr>
-   		<td></td>
-	</tr>
-	<tr>
-		<td colspan="2"><b>{error}</b></td>
-	</tr>
-   <tr>
-   	<td></td>
-   </tr>
-<!-- END header -->
-<!-- BEGIN body -->
-	<tr class="th">
-		<td colspan="2" align="center"><b>{lang_expressoCalendar_migration}</b></td>
-	</tr>
-	<tr>
-   		<td></td>
-	</tr>
-	<tr class="row_on">
-		<td>{lang_Migrate_all_calendar_events_for_expressoCalendar}:</td>
-	</tr>	
-<!-- END body -->
-<!-- BEGIN footer -->
-	<tr class="th">
-		<td colspan="2">&nbsp;</td>
-	</tr>
-	<tr>
-		<td colspan="2" align="center">
-			<input type="submit" name="submit" value="{lang_submit}">
-			<input type="submit" name="cancel" value="{lang_cancel}">
-		</td>
-	</tr>
-</table>
+<form method="POST" action="{action_url}"> 
+    <table border="0" align="center"> 
+        <!-- END header --> 
+        <!-- BEGIN body --> 
+        <tr class="th"> 
+            <td colspan="2" align="center"><b>{lang_expressoCalendar_Setup}</b></td> 
+        </tr> 
+ 
+        <tr><td></td></tr> 
+ 
+        <tr class="row_off"> 
+            <td>{lang_Auto_import_calendars_to_receive_an_internal_event}:</td> 
+            <td> 
+                <select name="newsettings[expressoCalendar_autoImportCalendars]"> 
+                    <option value="false" {selected_expressoCalendar_autoImportCalendars_false}>{lang_no}</option> 
+                    <option value="true"  {selected_expressoCalendar_autoImportCalendars_true}>{lang_yes}</option> 
+                </select> 
+            </td> 
+        </tr> 
+        <!-- END body --> 
+        <!-- BEGIN footer --> 
+        <tr class="th"> 
+            <td colspan="2">&nbsp;</td> 
+        </tr> 
+        <tr> 
+            <td colspan="2" align="center"> 
+                <input type="submit" name="submit" value="{lang_submit}"> 
+                <input type="submit" name="cancel" value="{lang_cancel}"> 
+            </td> 
+        </tr> 
+    </table> 
 </form>
 <!-- END footer -->
Index: /branches/2.5/expressoCalendar/templates/default/migra.tpl
===================================================================
--- /branches/2.5/expressoCalendar/templates/default/migra.tpl	(revision 7982)
+++ /branches/2.5/expressoCalendar/templates/default/migra.tpl	(revision 7982)
@@ -0,0 +1,41 @@
+<!-- BEGIN header -->
+<form  method="POST" action="{action_url}">
+<input type="hidden" name="migration" value="true">
+<table border="0" align="center">
+	<tr class="th">
+		<td colspan="2"><font color="{th_text}">&nbsp;<b>{title}</b></font></td>
+	</tr>
+	<tr>
+   		<td></td>
+	</tr>
+	<tr>
+		<td colspan="2"><b>{error}</b></td>
+	</tr>
+   <tr>
+   	<td></td>
+   </tr>
+<!-- END header -->
+<!-- BEGIN body -->
+	<tr class="th">
+		<td colspan="2" align="center"><b>{lang_expressoCalendar_migration}</b></td>
+	</tr>
+	<tr>
+   		<td></td>
+	</tr>
+	<tr class="row_on">
+		<td>{lang_Migrate_all_calendar_events_for_expressoCalendar}:</td>
+	</tr>	
+<!-- END body -->
+<!-- BEGIN footer -->
+	<tr class="th">
+		<td colspan="2">&nbsp;</td>
+	</tr>
+	<tr>
+		<td colspan="2" align="center">
+			<input type="submit" name="submit" value="{lang_submit}">
+			<input type="submit" name="cancel" value="{lang_cancel}">
+		</td>
+	</tr>
+</table>
+</form>
+<!-- END footer -->
Index: /branches/2.5/prototype/config/participant.ini
===================================================================
--- /branches/2.5/prototype/config/participant.ini	(revision 7377)
+++ /branches/2.5/prototype/config/participant.ini	(revision 7982)
@@ -21,4 +21,5 @@
 [after.create]
 createParticipantHistoric = modules/calendar/interceptors/DBMapping.php
+autoImportCalendar = modules/calendar/interceptors/DBMapping.php
 
 [before.create]
Index: /branches/2.5/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- /branches/2.5/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7978)
+++ /branches/2.5/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7982)
@@ -169,4 +169,5 @@
     public function schedulableSecurity(&$uri, &$params, &$criteria, $original) 
     {
+ 
         if( !isset($criteria['filter'][1]) || !$criteria['filter'][1] == 'uid') 
         { 
@@ -763,4 +764,25 @@
 	    }
 	}
+    } 
+ 
+    static function autoImportCalendar(&$uri, &$params, &$criteria, $original){ 
+        $autoCommit = Controller::service('PostgreSQL')->execResultSql('Select config_value FROM phpgw_config WHERE config_app = \'expressoCalendar\' AND config_name = \'expressoCalendar_autoImportCalendars\''); 
+ 
+ 
+        if(isset($autoCommit[0]) && $autoCommit[0]['config_value'] == 'true') 
+        { 
+            if(isset($original['properties']) && isset($original['properties']['user'])  && isset($original['properties']['isOrganizer']) &&  $original['properties']['isOrganizer'] != '1') 
+            { 
+                $defaultCalendar = Controller::find(array('concept' => 'modulePreference'), array('value') , array('filter' => array( 'and' , array('=' , 'name' , 'dafaultImportCalendar') , array('=' , 'module' , 'expressoCalendar') , array('=' , 'user' , $original['properties']['user'])  )) ); 
+                if(isset($defaultCalendar[0]) && $defaultCalendar[0]['value'] > 0) 
+                { 
+                    Controller::create(array('concept' => 'calendarToSchedulable'), 
+                        array('schedulable' => $original['properties']['schedulable'], 
+                            'calendar' => $defaultCalendar[0]['value'] 
+                        ) 
+                    ); 
+                } 
+            } 
+        } 
     }
 
@@ -1378,5 +1400,5 @@
 
     public function deleteCalendarSignatureDependences(&$uri, &$params, &$criteria, $original) {
-	$signature = Controller::read($uri, array('isOwner', 'calendar'));
+	$signature = Controller::read($uri, array('isOwner', 'calendar','user'));
 
 	if ($signature['isOwner'] == '1') {
@@ -1392,9 +1414,21 @@
 
 	    Controller::delete(array('concept' => 'calendar', 'id' => $signature['calendar']));
-		
-		$permissions = Controller::find(array('concept' => 'calendarToPermission'), array('id'), array('filter' => array('=', 'calendar', $signature['calendar'])));
-
-		
-		
+ 
+        $autoCommit = Controller::service('PostgreSQL')->execResultSql('Select config_value FROM phpgw_config WHERE config_app = \'expressoCalendar\' AND config_name = \'expressoCalendar_autoImportCalendars\''); 
+ 
+        if(isset($autoCommit[0]) && $autoCommit[0]['config_value'] == 'true') 
+        { 
+            $defaultCalendar = Controller::find(array('concept' => 'modulePreference'), array('value','id') , array('filter' => array( 'and' , array('=' , 'name' , 'dafaultImportCalendar') , array('=' , 'module' , 'expressoCalendar') , array('=' , 'user' , $signature['user'])  )) ); 
+ 
+ 
+            self::lg($defaultCalendar); 
+            if(isset($defaultCalendar[0])  && $defaultCalendar[0]['value'] == $signature['calendar'] ) 
+            { 
+                Controller::delete(array('concept' => 'modulePreference', 'id' => $defaultCalendar[0]['id'])); 
+            } 
+        } 
+ 
+        $permissions = Controller::find(array('concept' => 'calendarToPermission'), array('id'), array('filter' => array('=', 'calendar', $signature['calendar']))); 
+ 
 		if($permissions && count($permissions) > 0){
 			$ids = array();
@@ -1543,5 +1577,14 @@
                 }
 
-    		    DAViCalAdapter::importCollection($v->url, $calCreated['id']);
+                if($i == 0) 
+                { 
+                    $pref = array(); 
+                    $pref['user'] = $_SESSION['wallet']['user']['uidNumber']; 
+                    $pref['value'] = $calCreated['id']; 
+                    $pref['name'] = 'dafaultImportCalendar' ; 
+                    $pref['module'] = 'expressoCalendar'; 
+                    Controller::create(array('concept' => 'modulePreference'), $pref); 
+                } 
+ 
     		}
 	    } else {
@@ -1565,4 +1608,14 @@
 
     		$sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
+ 
+ 
+            $pref = array(); 
+            $pref['user'] = $_SESSION['wallet']['user']['uidNumber']; 
+            $pref['value'] = $calCreated['id']; 
+            $pref['name'] = 'dafaultImportCalendar' ; 
+            $pref['module'] = 'expressoCalendar'; 
+            Controller::create(array('concept' => 'modulePreference'), $pref); 
+ 
+ 
         }
     
Index: /branches/2.5/prototype/modules/calendar/schedules.php
===================================================================
--- /branches/2.5/prototype/modules/calendar/schedules.php	(revision 7967)
+++ /branches/2.5/prototype/modules/calendar/schedules.php	(revision 7982)
@@ -158,10 +158,14 @@
             $attend = Controller::read(array('concept' => 'participant'), null, array('filter' => array('AND', array('=','schedulable',$v['id']), array('=','user', Config::me('uidNumber'))  )));
 
+            $result[$i]['unanswered'] = 0; 
+ 
             if(count($attend) > 0 && !empty($attend)){
-
                 if(array_key_exists(0, $attend))
                     $attend = $attend[0];
 
                 $result[$i]['editable'] = (strstr($attend['acl'],"w") || strstr($attend['acl'],"o") || $attend['isOrganizer'] == '1') ? 1 : 0;
+ 
+                if($attend['status'] == STATUS_UNANSWERED) 
+                    $result[$i]['unanswered'] = 1; 
 
             }else{
Index: /branches/2.5/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- /branches/2.5/prototype/modules/calendar/js/calendar.codecs.js	(revision 7969)
+++ /branches/2.5/prototype/modules/calendar/js/calendar.codecs.js	(revision 7982)
@@ -1856,5 +1856,6 @@
 				occurrence: occurrences[i],
 				type: typeEvent,
-				calendar: evt.calendar
+                                calendar: evt.calendar, 
+                unanswered: evt.unanswered, 
 				}, (parseInt(typeEvent) == 1 ? eventEditable(evt.id, isRepeat, i ) : (parseInt(typeEvent) == 2 ? taskEditable(evt.id) : {editable: false, disableResizing: true, disableDragging: true}))));
         }
Index: /branches/2.5/prototype/modules/calendar/js/helpers.js
===================================================================
--- /branches/2.5/prototype/modules/calendar/js/helpers.js	(revision 7970)
+++ /branches/2.5/prototype/modules/calendar/js/helpers.js	(revision 7982)
@@ -1559,11 +1559,14 @@
 	DataLayer.render( 'templates/preferences_calendar.ejs', {
 	    preferences:User.preferences, 
-	    calendars: Calendar.calendars
+            calendars: Calendar.calendars, 
+        signatureOf : Calendar.signatureOf 
 	    }, function( template ){
 	    var tabPrefCalendar = jQuery('#preference_tab').html( template ).find('.preferences-win');
 		
-	    tabPrefCalendar.find('option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change');
-		
-	    DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){
+            tabPrefCalendar.find('select[name="defaultCalendar"] option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); 
+        tabPrefCalendar.find('select[name="dafaultImportCalendar"] option[value="'+User.preferences.dafaultImportCalendar+'"]').attr('selected','selected').trigger('change'); 
+ 
+        DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){ 
+
 		tabPrefCalendar.find('select[name="timezone"]').html(timezones_options).find('option[value="'+User.preferences.timezone+'"]').attr('selected','selected').trigger('change');
 	    });
Index: /branches/2.5/prototype/modules/calendar/js/init.js
===================================================================
--- /branches/2.5/prototype/modules/calendar/js/init.js	(revision 7968)
+++ /branches/2.5/prototype/modules/calendar/js/init.js	(revision 7982)
@@ -358,4 +358,11 @@
 
 			var img_icon = "";
+ 
+            if( !!parseInt(event.unanswered)  ){ 
+ 
+                img_icon = "mini-attention.png"; 
+ 
+            }else{ 
+ 
 			if(event.type == 1)
 				img_icon = "mini-event.png";
@@ -365,5 +372,6 @@
 				img_icon = "mini-activity.png";
 
-			
+	}
+		
     	    element.find(".fc-event-inner.fc-event-skin").prepend($('<img style="width: 11px; height: 13px;" class="" src="../prototype/modules/calendar/img/' + img_icon + '"></img>'));
 		},
Index: /branches/2.5/prototype/modules/calendar/templates/attendee_add.ejs
===================================================================
--- /branches/2.5/prototype/modules/calendar/templates/attendee_add.ejs	(revision 7388)
+++ /branches/2.5/prototype/modules/calendar/templates/attendee_add.ejs	(revision 7982)
@@ -11,5 +11,6 @@
 						<option value="3" <%= data.event.status=='3' ? 'selected="selected"':'' %>>Eu não vou</option>
 						<option value="2" <%= data.event.status=='2' ? 'selected="selected"':'' %>>Talvez</option>
-						<option class="hidden" value="5">Delegado</option>
+                        <option value="4" <%= data.event.status=='4' ? 'selected="selected"':'' %>>Sem resposta </option> 
+                                            <option class="hidden" value="5" >Delegado</option> 
 					<%}%>
 				<%}else{%>
Index: /branches/2.5/prototype/modules/calendar/templates/preferences_calendar.ejs
===================================================================
--- /branches/2.5/prototype/modules/calendar/templates/preferences_calendar.ejs	(revision 7143)
+++ /branches/2.5/prototype/modules/calendar/templates/preferences_calendar.ejs	(revision 7982)
@@ -72,5 +72,5 @@
 
 			<p class="input-group"> 
-                <label for="defaultCalendar">Agenda padrão:</label> 
+                <label for="defaultCalendar">Agenda padrão para Criação de Eventos:</label> 
                 <select name="defaultCalendar" > 
                     <%for(var i = 0; i < data.calendars.length; i++){%> 
@@ -79,4 +79,16 @@
                 </select>
 			</p>
+ 
+            <p class="input-group"> 
+                <label for="dafaultImportCalendar">Agenda padrão para Importação de Eventos :</label> 
+                <select name="dafaultImportCalendar" > 
+                    <option value=""> </option> 
+                    <%for(var i = 0; i < data.calendars.length; i++){ 
+                     if(data.signatureOf[data.calendars[i].id].isOwner == '1'){ 
+                    %> 
+                    <option value="<%=data.calendars[i].id%>"> <%= data.calendars[i].name %></option> 
+                    <%}}%> 
+                </select> 
+            </p> 
 
 			<p class="input-group">
Index: /branches/2.5/prototype/modules/calendar/templates/event_detail_list.ejs
===================================================================
--- /branches/2.5/prototype/modules/calendar/templates/event_detail_list.ejs	(revision 7702)
+++ /branches/2.5/prototype/modules/calendar/templates/event_detail_list.ejs	(revision 7982)
@@ -3,5 +3,5 @@
     var encoder = {};
     encoder.alarm = {'1':'do evento','2':'da tarefa','3':'da atividade'};
-    encoder.status = {'1':'Eu vou', '2':'Talvez', '3':'Eu não vou'};
+    encoder.status = {'1':'Eu vou', '2':'Talvez', '3':'Eu não vou' , '4':'Sem resposta'};
     encoder.statusEvent = {1: 'Sem ações', 2: 'Em processo', 3: 'Completo', 4: 'Cancelado'};
     encoder.priority = {1: 'Alta', 2: 'Normal', 3: 'Baixa'};
