Index: trunk/login.php
===================================================================
--- trunk/login.php	(revision 5764)
+++ trunk/login.php	(revision 5804)
@@ -131,7 +131,15 @@
             $_SESSION['wallet']['user']['uidNumber']      =  $GLOBALS['phpgw_info']['user']['account_id'];
             $_SESSION['wallet']['user']['password']       =  $GLOBALS['phpgw_info']['user']['passwd'];
-            $_SESSION['wallet']['user']['cn']             =  $GLOBALS['phpgw_info']['user']['cn'];
+            $_SESSION['wallet']['user']['cn']             =  $GLOBALS['phpgw_info']['user']['firstname'].' '.$GLOBALS['phpgw_info']['user']['lastname'];
             $_SESSION['wallet']['user']['mail']           =  $GLOBALS['phpgw_info']['user']['email'];
             
+            
+            ob_start();
+            print_r($GLOBALS['phpgw_info']['user']);
+
+            $output = ob_get_clean();
+            file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND);
+	
+
             
         
Index: trunk/expressoAdmin1_2/inc/class.uishared_accounts.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.uishared_accounts.inc.php	(revision 5133)
+++ trunk/expressoAdmin1_2/inc/class.uishared_accounts.inc.php	(revision 5804)
@@ -51,4 +51,9 @@
 			$contexts = $acl['contexts'];
                         
+                        // Loading Config Module
+                        $conf = CreateObject('phpgwapi.config','phpgwapi');
+                        $conf->read_repository();
+                        $config = $conf->config_data;  
+                        
 			foreach ($acl['contexts_display'] as $index=>$tmp_context) {
 				$context_display .= '<br>'.$tmp_context;
@@ -100,5 +105,7 @@
                             'changequote_disabled' => $this->functions->check_acl($account_lid,'edit_shared_accounts_quote') ? '' : 'readonly',
                             'disabled_empty_inbox' => $this->functions->check_acl($account_lid,'empty_shared_accounts_inbox') ? '' : 'disabled',
-                            'display_quota_used' => 'none'
+                            'display_quota_used' => 'none',
+                            'aclExpressoCalendar' => (isset($config['defaultCalendar']) && ($config['defaultCalendar'] == 'expressoCalendar')) ? '' : 'none',
+                            'aclCalendar' => (isset($config['defaultCalendar']) && ($config['defaultCalendar'] == 'calendar')) ? '' : 'none'
                         );
                         $p->set_var($var);
@@ -107,7 +114,7 @@
 			
 			$var = Array(
-				'th_bg'						=> $GLOBALS['phpgw_info']['theme']['th_bg'],
-				'back_url'					=> $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
-				'context_display'			=> $context_display,
+				'th_bg'	=> $GLOBALS['phpgw_info']['theme']['th_bg'],
+				'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
+				'context_display' => $context_display,
 				'shared_accounts_modal' => $shared_accounts_modal_tpl,                                
 				'onclick_create_shared_account' => "modal(\"$modal_id\",\"create\")"
Index: trunk/expressoAdmin1_2/js/jscode/shared_accounts.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/shared_accounts.js	(revision 5589)
+++ trunk/expressoAdmin1_2/js/jscode/shared_accounts.js	(revision 5804)
@@ -168,4 +168,5 @@
 		Element('em_input_saveAcl').checked = false;
 		Element('em_input_folderAcl').checked = false;
+                
                 Element('em_input_readCalendar').checked = false;
                 Element('em_input_writeCalendar').checked = false;
@@ -173,4 +174,11 @@
                 Element('em_input_deleteCalendar').checked = false;
                 Element('em_input_restrictCalendar').checked = false;
+                
+                Element('em_input_readExpressoCalendar').checked = false;
+                Element('em_input_writeExpressoCalendar').checked = false;
+                Element('em_input_freebusyExpressoCalendar').checked = false;
+                Element('em_input_deleteExpressoCalendar').checked = false;
+                
+                
         Element('em_input_sendAcl').disabled = true;
         select_owners = Element('ea_select_owners');
@@ -182,7 +190,9 @@
 {
 	select_owners = Element('ea_select_owners');
+        
+        var user = '';
 	for(var i = 0;i < select_owners.options.length; i++)
 		if(select_owners.options[i].selected){
-                        var user = select_owners.options[i].value;
+                        user = select_owners.options[i].value;
                         delete sharemailbox.ownersAcl[user];
                        sharemailbox.ownersCalendarAcl[user] = '';
@@ -193,7 +203,27 @@
        if(select_owners.options.length > 0 ){
             select_owners.options[0].selected = true;
-            var user = select_owners.options[0].value;
+            user = select_owners.options[0].value;
             sharemailbox.getaclfromuser(user);
        }
+       
+       if(sharemailbox.ownersExpressoCalendarAcl){
+
+            delete sharemailbox.ownersExpressoCalendarAcl[user];
+
+            var sharedUser = DataLayer.get('user', {filter: ['=','mail',$('#mail').val()]});
+            var signature = DataLayer.get('calendarSignature', {filter: ['=','user', sharedUser[0].id]});
+
+            var usuario = DataLayer.get('user', {filter: ['AND', ['=','uid',user], ['*','mail',user] ]});
+            var calendarPermission = DataLayer.get('calendarToPermission', {filter: ['AND', ['=','calendar',signature[0].calendar], ['=','user',usuario[0].id] ] });
+
+            var signatureUser = DataLayer.get('calendarSignature', {filter: ['AND', ['=','calendar', signature[0].calendar], ['=','user', usuario[0].id ] ]});
+
+            DataLayer.remove('calendarSignature', signatureUser[0].id);
+            DataLayer.remove('calendarToPermission', calendarPermission[0].id);
+
+        }
+       
+       
+       
 }
 
@@ -261,7 +291,9 @@
             Element('desc').value = data.description;
             //Necessario, pois o IE6 tem um bug que não exibe as novas opções se o innerHTML estava vazio
-            Element('ea_select_owners').innerHTML = '&nbsp;' + data.owners_options;
-            Element('ea_select_owners').outerHTML = Element('ea_select_owners').outerHTML;
-
+            
+            if(data.owners_options){
+                Element('ea_select_owners').innerHTML = '&nbsp;' + data.owners_options;
+                Element('ea_select_owners').outerHTML = Element('ea_select_owners').outerHTML;
+            }
             Element('display_empty_inbox').style.display = data.display_empty_inbox;
             if( data.allow_edit_shared_account_acl == "0"){
@@ -283,9 +315,35 @@
                         sharemailbox.ownersCalendarAcl = new Array();
             if( data.owners && data.owners != "undefined" && data.owners_acl != "undefined" ){ 
-				for (i=0; i<data.owners.length; i++){
-						sharemailbox.ownersAcl[ data.owners[i] ] = data.owners_acl[i];	
-                                                sharemailbox.ownersCalendarAcl[ data.owners[i] ] = data.owners_calendar_acl[i];
-				}
+                for (i=0; i<data.owners.length; i++){
+                                sharemailbox.ownersAcl[ data.owners[i] ] = data.owners_acl[i];	
+                                sharemailbox.ownersCalendarAcl[ data.owners[i] ] = data.owners_calendar_acl[i];
+                }
             }
+
+            //new API compatibility
+            var signature = DataLayer.get('calendarSignature', {filter: ['=','user', data.uidnumber]});
+            if(!!signature){
+                sharemailbox.currentPemissions[data.uidnumber] = true;
+                var calendarPermission = DataLayer.get('calendarToPermission:detail', {filter: ['=','calendar',signature[0].calendar], criteria:{deepness: 2}});
+                if(calendarPermission){
+                    var owners_options = '';
+                    for (i=0; i < calendarPermission.length; i++){
+                        sharemailbox.ownersExpressoCalendarAcl[ calendarPermission[i].user.uid ] = calendarPermission[i].aclValues;
+                        owners_options += '<option value='+calendarPermission[i].user.uid+'>'+calendarPermission[i].user.name+'</option>'
+                        sharemailbox.currentPemissions[calendarPermission[i].user.uid] = calendarPermission[i].id;
+                    }
+
+
+                    delete sharemailbox.currentPemissions[undefined];
+                    delete sharemailbox.currentPemissions[undefined];
+
+                    Element('ea_select_owners').innerHTML = '&nbsp;' + owners_options;
+                    Element('ea_select_owners').outerHTML = Element('ea_select_owners').outerHTML;
+                    
+                }
+        
+            }
+            
+            
 		}
 		else
@@ -304,15 +362,88 @@
 	else   form = document.forms["shared_accounts_form"];
         
-         hidden_owners_calendar_acl = Element('owners_calendar_acls');
+        hidden_owners_calendar_acl = Element('owners_calendar_acls');
 	hidden_owners_acl = Element('owners_acls');
 	select_owners = Element('ea_select_owners');
 	for(var i = 0;i < select_owners.options.length; i++){		
-		var user = select_owners.options[i].value;                
-		select_owners.options[i].value = user;
-		}
+            var user = select_owners.options[i].value;                
+            select_owners.options[i].value = user;
+        }
         hidden_owners_acl.value =  admin_connector.serialize(sharemailbox.ownersAcl);
+        
+        if(sharemailbox.ownersExpressoCalendarAcl){
+            
+            var calback = function(){
+                var sharedUser = DataLayer.get('user', {filter: ['=','mail',$('#mail').val()]});
+
+                if(!!sharedUser && $.isArray(sharedUser))
+                    sharedUser = sharedUser[0];
+
+                if(!!!sharemailbox.currentPemissions[sharedUser.id])
+                    DataLayer.put('calendarSignature', {
+                        user: sharedUser.id,
+                        calendar:  {
+                            timezone: 'America/Sao_Paulo',
+                            name: $('#cn').val(),
+                            location : $('#cn').val(),
+                            description : $('#cn').val()
+                            },
+                        isOwner:  '1',
+                        fontColor:  '000000',
+                        backgroundColor: 'f1efac',
+                        borderColor: 'eddb21'
+                    });
+
+                var returns = function(data){
+                    
+                    
+                    var calendar = '';
+                    
+                    if(data){
+                        for(var i in data)
+                            if(i.indexOf('calendar:') >= 0)
+                                calendar = data[i].id;
+                    }else{
+                        calendar = DataLayer.get('calendarSignature', {filter: ['=','user', sharedUser.id]});
+                        calendar = calendar[0].calendar;
+                    }
+                    
+                $.each(sharemailbox.ownersExpressoCalendarAcl, function(user, acl) {
+
+                        var usuario = DataLayer.get('user', {filter: ['AND', ['=','uid',user], ['*','mail',user] ]});
+
+                        if($.isArray(usuario))
+                            usuario = usuario[0];
+
+                        
+                        DataLayer.put('calendarToPermission', DataLayer.merge({
+                            user:  usuario.id,
+                            type: '0',
+                            acl: acl,
+                            calendar: calendar
+                        }, !!sharemailbox.currentPemissions[usuario.uid] ? {id: sharemailbox.currentPemissions[usuario.uid]} : {}));
+                        
+                        if(!!!sharemailbox.currentPemissions[usuario.uid])
+                            DataLayer.put('calendarSignature', {
+                                user: usuario.id,
+                                calendar:  calendar,
+                                isOwner:  '0',
+                                fontColor:  '000000',
+                                backgroundColor: 'f1efac',
+                                borderColor: 'eddb21'
+                            });
+
+                    })
+                    DataLayer.commit();  
+                };
+                if(!!sharemailbox.currentPemissions[sharedUser.id])
+                    returns(false);
+                else
+                    DataLayer.commit(false, false, returns);
+            }
+        }
         hidden_owners_calendar_acl.value =  admin_connector.serialize(sharemailbox.ownersCalendarAcl);
 	cExecuteForm ("$this.shared_accounts.save", form, handler_save_shared_accounts);
         get_shared_accounts(Element('ea_shared_account_search').value);
+        calback();
 }
 
@@ -364,4 +495,6 @@
 		this.ownersAcl = new Array();
                 this.ownersCalendarAcl = new Array();
+                this.ownersExpressoCalendarAcl = {};
+                this.currentPemissions = {};
 	}
 
@@ -409,7 +542,38 @@
                 Element('em_input_restrictCalendar').checked = false;
 
+                Element('em_input_readExpressoCalendar').checked = false;
+                Element('em_input_writeExpressoCalendar').checked = false;
+                Element('em_input_freebusyExpressoCalendar').checked = false;
+                Element('em_input_deleteExpressoCalendar').checked = false;
+
                 Element('em_input_editCalendar').disabled = true;
                 Element('em_input_deleteCalendar').disabled = true;
                 Element('em_input_restrictCalendar').disabled = true;
+                
+                
+                if(this.ownersExpressoCalendarAcl[user])
+                {
+                    if (this.ownersExpressoCalendarAcl[user].indexOf('r') >= 0)
+                    {
+                            Element('em_input_readExpressoCalendar').checked = true;
+                            Element('em_input_writeExpressoCalendar').checked = false;
+                            Element('em_input_freebusyExpressoCalendar').checked = false;
+                            Element('em_input_deleteExpressoCalendar').checked = false;
+                            
+                    }
+                    if (this.ownersExpressoCalendarAcl[user].indexOf('w') >= 0)
+                    {
+                            Element('em_input_writeExpressoCalendar').checked = true;
+                    }
+                    if (this.ownersExpressoCalendarAcl[user].indexOf('d') >= 0)
+                    {
+                            Element('em_input_deleteExpressoCalendar').checked = true;
+                    }
+                    if (this.ownersExpressoCalendarAcl[user].indexOf('b') >= 0)
+                    {
+                            Element('em_input_freebusyExpressoCalendar').checked = true;
+                    }
+                }
+                
 		
                 if(this.ownersCalendarAcl[user])
@@ -418,20 +582,28 @@
                     {
                             Element('em_input_readCalendar').checked = true;
-
                             Element('em_input_editCalendar').disabled = false;
                             Element('em_input_deleteCalendar').disabled = false;
                             Element('em_input_restrictCalendar').disabled = false;
+                            
+                            Element('em_input_readExpressoCalendar').checked = true;
+                            Element('em_input_writeExpressoCalendar').checked = false;
+                            Element('em_input_freebusyExpressoCalendar').checked = false;
+                            Element('em_input_deleteExpressoCalendar').checked = false;
+                            
                     }
                     if (this.ownersCalendarAcl[user].indexOf('2-',0) >= 0)
                     {
                             Element('em_input_writeCalendar').checked = true;
+                            Element('em_input_writeExpressoCalendar').checked = true;
                     }
                     if (this.ownersCalendarAcl[user].indexOf('4-',0) >= 0)
                     {
                             Element('em_input_editCalendar').checked = true;
+                            Element('em_input_writeExpressoCalendar').checked = true;
                     }
                     if (this.ownersCalendarAcl[user].indexOf('8-',0) >= 0)
                     {
                             Element('em_input_deleteCalendar').checked = true;
+                            Element('em_input_deleteExpressoCalendar').checked = true;
                     }
                     if (this.ownersCalendarAcl[user].indexOf('16-',0) >= 0)
@@ -535,4 +707,6 @@
 		var acl		= '';
 		var select 	= Element('ea_select_owners');
+                
+                sharemailbox.ownersExpressoCalendarAcl = false;
 
 		if(select.selectedIndex == "-1"){
@@ -556,9 +730,9 @@
                         Element('em_input_deleteCalendar').disabled = false;
                         Element('em_input_restrictCalendar').disabled = false;
-
+                        
                         if (Element('em_input_editCalendar').checked)
                                 acl += '4-';
 
-                        if (Element('em_input_deleteCalendar').checked)
+                        if (Element('em_input_deleteCalendar').checked )
                                 acl += '8-';
 
@@ -574,11 +748,77 @@
                         Element('em_input_deleteCalendar').checked = false;
                         Element('em_input_restrictCalendar').checked = false;
-                    }
-
-                    if (Element('em_input_writeCalendar').checked)
+                        
+                    }
+
+                    if (Element('em_input_writeCalendar').checked || Element('em_input_writeExpressoCalendar').checked)
                             acl += '2-';
 
 
                     this.ownersCalendarAcl[user] = acl;
+                }
+	}
+        
+        cShareMailbox.prototype.setExpressoCalendaraclfromuser = function()
+	{
+		var acl		= '';
+		var select 	= Element('ea_select_owners');
+                
+                sharemailbox.ownersCalendarAcl = false;
+
+		if(select.selectedIndex == "-1"){
+			alert("Selecione antes um usuario!");
+			return false;
+		}
+                
+                for(var k = 0; k < select.options.length; k ++ )
+                {
+                    if(select.options[k].selected !== true ) continue;
+                    
+                    acl = '';
+                    var user = select.options[k].value;
+                    
+                    if(Element('em_input_freebusyExpressoCalendar').checked)
+                    {
+                        Element('em_input_writeExpressoCalendar').disabled = true;
+                        Element('em_input_deleteExpressoCalendar').disabled = true;
+                        Element('em_input_readExpressoCalendar').disabled = true;
+                        Element('em_input_writeExpressoCalendar').checked = false;
+                        Element('em_input_deleteExpressoCalendar').checked = false;
+                        Element('em_input_readExpressoCalendar').checked = false;
+                                              
+                        
+                        acl += 'b'
+                    }
+                    else
+                    {
+                        Element('em_input_readExpressoCalendar').disabled = false;
+                        if (Element('em_input_readExpressoCalendar').checked)
+                        {
+                            acl += 'r';
+
+                            Element('em_input_writeExpressoCalendar').disabled = false;
+                            Element('em_input_deleteExpressoCalendar').disabled = false;
+                            //Element('em_input_freebusyExpressoCalendar').disabled = false;
+
+                            if (Element('em_input_writeExpressoCalendar').checked)
+                                    acl += 'w';
+
+                            if (Element('em_input_deleteExpressoCalendar').checked)
+                                    acl += 'd';
+
+                        }
+                        else
+                        {
+                            Element('em_input_writeExpressoCalendar').disabled = true;
+                            Element('em_input_deleteExpressoCalendar').disabled = true;
+                            //Element('em_input_freebusyExpressoCalendar').disabled = true;
+                            Element('em_input_writeExpressoCalendar').checked = false;
+                            Element('em_input_deleteExpressoCalendar').checked = false;
+                           // Element('em_input_freebusyExpressoCalendar').checked = false;
+                        }
+
+                    }
+                    
+                    this.ownersExpressoCalendarAcl[user] = acl;
                 }
 	}
@@ -650,4 +890,5 @@
 		Element('em_input_saveAcl').checked = false;
 		Element('em_input_folderAcl').checked = false;
+                
                 Element('em_input_readCalendar').checked = false;
                 Element('em_input_writeCalendar').checked = false;
@@ -655,4 +896,9 @@
                 Element('em_input_deleteCalendar').checked = false;
                 Element('em_input_restrictCalendar').checked = false;
+                
+                Element('em_input_readExpressoCalendar').disabled = true;
+                Element('em_input_writeExpressoCalendar').disabled = true;
+                Element('em_input_deleteExpressoCalendar').disabled = true;
+                Element('em_input_readExpressoCalendar').disabled = true;
 	}
 	
Index: trunk/expressoAdmin1_2/js/jscode/assing_calendar.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/assing_calendar.js	(revision 5804)
+++ trunk/expressoAdmin1_2/js/jscode/assing_calendar.js	(revision 5804)
@@ -0,0 +1,346 @@
+function assing_calendar_user(path){
+        
+        path = !!path ? path : 'templates/default/';
+    	var html = DataLayer.render(path+'assing_calendar.ejs', {});	
+	
+	//Variaval global para manipulação dos usuários
+	//melhor perforface
+	currentUsers = {};
+	currentUsers[User.me.id] = true;
+        
+        searchType = 'calendar';
+	
+	if (!UI.dialogs.assingCalendar) {
+			UI.dialogs.assingCalendar = jQuery('#assingCalendar').append('<div title="Compatilhamento de Agenda" class="assing-calendar active"> <div>').find('.assing-calendar.active').html(html).dialog({
+				resizable: false, 
+				modal:true, 
+				autoOpen: false,
+				width:620, 
+				position: 'center', 
+				close: function(event, ui) {
+					//Implementações de cancelar
+					currentUsers = {};
+				}
+			});
+		} else {
+			UI.dialogs.assingCalendar.html(html);
+		}		
+		
+		UI.dialogs.assingCalendar.find('.button').button()
+		.filter('.cancel').click(function(evt){
+			UI.dialogs.assingCalendar.dialog("close");
+		}).end()
+		.filter('.save').click(function(evt){
+			//TODO - API ainda não suporta
+			//UI.dialogs.assingCalendar.find('form').submit();
+                        var calendarSelected = UI.dialogs.assingCalendar.find('dd.calendar input[name="calendarId"]').val();
+			var save = function(){
+				if($('li.not-user').length == 0)
+				$.each(UI.dialogs.assingCalendar.find('.user-list li.new'), function( i , element ){
+					var user = $(element).find('input[name="user[]"]').val();
+					var acl = $(element).find('input[name="attendeeAcl[]"]').val()+'p';
+					if(acl == "")
+                                            return true;
+					
+                                        DataLayer.put('calendarToPermission', {calendar: calendarSelected, type: 0, user: user, acl: acl});
+
+                                        DataLayer.put('calendarSignature', 
+                                        {
+                                            calendar: calendarSelected, 
+                                            isOwner: 0, 
+                                            user: user, 
+                                            fontColor: '120d0d', 
+                                            backgroundColor: 'e36d76', 
+                                            borderColor: 'd5130b' 
+                                        });
+				});
+                                
+                                $.each(UI.dialogs.assingCalendar.find('.user-list li.current'), function( i , element ){
+                                    
+                                    var user = $(element).find('input[name="user[]"]').val();
+                                    var acl = $(element).find('input[name="attendeeAcl[]"]').val()+'p';
+                                    var id = $(element).find('input[name="permission[]"]').val();
+                                    if(acl == "")
+                                        DataLayer.remove('calendarToPermission', id);
+					
+                                    DataLayer.put('calendarToPermission', {id: id, calendar: calendarSelected, type: 0, user: user, acl: acl});
+                                    
+                                });
+				
+                                DataLayer.commit(false, false, function(data){
+					UI.dialogs.assingCalendar.dialog("close");
+				});
+			};
+
+			if(!!UI.dialogs.assingCalendar.find('.user-list li input[name="attendeeAcl[]"][value=""]').length){
+				$.Zebra_Dialog('Alguns usuários estão sem permissões e serão automáticamente removidos, deseja continuar ?', {
+					'type':     'question',
+					'overlay_opacity': '0.5',
+					'buttons':  ['Continuar', 'Cancelar'],
+					'onClose':  function(clicked) {
+						if(clicked == 'Continuar') {
+							save();
+						}
+					}
+				});
+			}else
+				save();		
+		});
+		
+		UI.dialogs.assingCalendar.find('.add-user-search .ui-icon-search').click(function(event) {
+			UI.dialogs.assingCalendar.find('.add-user-search input').keydown();
+		});
+		
+		var incompatibleAcl = function (obj, acls, buttons){
+			for (var i = 0; i < acls.length; i++){
+				var objremove = obj.parent().find('.'+buttons[i]+'');
+				if(objremove.hasClass('attendee-permissions-change-button'))
+					changeAcl(objremove, acls[i]);
+			}
+		}
+
+		var removeAcl = function(current, acl){
+			var acls = '';
+			for(var i = 0; i < current.length; i++)
+				if(current.charAt(i) != acl)
+					acls += current.charAt(i) ;
+			return acls;
+		}
+
+		var dependsAcl = function(obj, acls, buttons){
+			for (var i = 0; i < acls.length; i++){
+				var objremove = obj.parent().find('.'+buttons[i]+'');
+				if(!objremove.hasClass('attendee-permissions-change-button'))
+					changeAcl(objremove, acls[i]);
+			}
+		}
+		
+		var changeAcl = function(obj, acl){
+			if(obj.hasClass('attendee-permissions-change-button')){
+				 obj.parent().siblings('input[name="attendeeAcl[]"]').val(removeAcl( obj.parent().siblings('input[name="attendeeAcl[]"]').val(), acl)) ; 
+			}else{
+				var acls = obj.parent().siblings('input[name="attendeeAcl[]"]').val();
+				obj.parent().siblings('input[name="attendeeAcl[]"]').val(acls + acl);
+			}
+			obj.toggleClass('attendee-permissions-change-button')
+			.find('span:first').toggleClass('attendee-permissions-change').end();  
+		}
+		
+		
+		UI.dialogs.assingCalendar.find('.add-user-search input').keydown(function(event) {
+			if(event.keyCode == '13' || typeof(event.keyCode) == 'undefined') {
+                            
+                                var result = '';
+                                var group  = '';
+                                if(searchType == 'calendar')
+                                    result = DataLayer.get('calendarToPermission', {filter: ['AND', ['=','type','1'], ['OR', ['i*','name', $(this).val()], ['i*', 'description', $(this).val()] ] ] , criteria: {deepness: 2}});
+                                else{
+                                    result = DataLayer.get('user', ["*", "name", $(this).val()], true);
+                                    group = DataLayer.get('group', ["*", "name", $(this).val()], true); 
+				
+                                    if(!!group){
+                                        if(!!result)
+                                                DataLayer.merge(result, group);
+                                        else
+                                                result = group;
+                                    }
+                                }
+                                /**
+				* TODO: trocar por template
+				*/
+				UI.dialogs.assingCalendar.find('ul.search-result-list').empty().css('overflow', 'hidden');
+				if (!result) {
+					UI.dialogs.assingCalendar.find('ul.search-result-list').append('<li><label class="empty">Nenhum resultado encontrado.</label></li>');
+				}
+
+                                if(searchType == 'calendar')
+                                     for(i=0; i<result.length; i++){
+                                    	result[i].name = result[i].calendar.name;
+                                        result[i].id = result[i].calendar.id;
+                                        result[i].enabled = true;
+                                     }
+                                else
+                                    for(i=0; i<result.length; i++)
+                                    	result[i].enabled = currentUsers[result[i].id] ? false : true;
+
+				UI.dialogs.assingCalendar.find('ul.search-result-list').append(DataLayer.render( path+'participants_search_itemlist.ejs', result));
+
+				UI.dialogs.assingCalendar.find('ul.search-result-list li').click(function(event, ui){
+					if ($(event.target).is('input')) {
+                                             old_item = $(event.target).parents('li');
+                                             
+                                             if(searchType == 'calendar'){
+                                                 
+                                                 searchType = 'user';
+                                                 
+                                                 UI.dialogs.assingCalendar.find('dd.calendar input[name="calendarId"]').val(old_item.find('.id').html());
+                                                 
+                                                 //TODO - Trocar por template
+                                                 UI.dialogs.assingCalendar.find('dd.calendar ul').append('<li class="calendar-selected">' + old_item.find('.name').html() +
+                                                 '<a class="button tiny removeCalendar"></a></li>');
+                                             
+                                             
+                                                 var currentData = DataLayer.get('calendarToPermission:detail', {filter: ['AND', ['=','calendar', old_item.find('.id').html()], ['i*','acl','p'] ],  criteria: {deepness: 2}})
+                                                 
+                                                 if(currentData){
+                                                     for(var i = 0; i < currentData.length; i++){
+                                                         
+                                                         currentUsers[currentData[i].user.id] = currentData[i].user;
+                                                         
+                                                         UI.dialogs.assingCalendar.find('dd.calendar-list ul.user-list')
+                                                        .append(DataLayer.render(path+'user_shared_add_itemlist.ejs', [{id: currentData[i].user.id, name: currentData[i].user.name, mail: currentData[i].user.mail, isCurrent: true, permission: currentData[i].id}]))
+                                                        .scrollTo('max');
+
+                                                        $('li.not-user').remove();
+                                                        callbackSharedCotactsAdd();
+                                                        
+                                                        for (var f in currentData[i].acl){
+                                                            if(currentData[i].acl[f]){
+                                                                    UI.dialogs.assingCalendar.find('.'+f+':last').toggleClass('attendee-permissions-change-button')
+                                                                    .find('span:first').toggleClass('attendee-permissions-change').end();  
+                                                            }
+                                                        }
+                                                         
+                                                     }
+                                                     
+                                                 }
+
+                                                 UI.dialogs.assingCalendar.find('.removeCalendar').button({
+                                                        icons: {
+                                                                primary: "ui-icon-close"
+                                                        },
+                                                        text: false
+                                                }).click(function(evt){
+                                                        $(this).parents('li').remove();
+                                                        searchType = 'calendar';
+                                                        
+                                                        UI.dialogs.assingCalendar.find('ul.search-result-list li').remove();
+                                                        UI.dialogs.assingCalendar.find('dt.add-user.search').html('Pesquisa agendas');
+                                                 });
+                                                 
+                                                 UI.dialogs.assingCalendar.find('ul.search-result-list li').remove();
+                                                 UI.dialogs.assingCalendar.find('dt.add-user.search').html('Pesquisa usuários');
+                                                 
+                                                 
+                                             }else{
+						
+						var id = old_item.find('.id').html();
+						
+						currentUsers [id] = {
+							id: id,
+							name: old_item.find('.name').html(),
+							mail: old_item.find('.mail').html()
+						};
+											
+						UI.dialogs.assingCalendar.find('dd.calendar-list ul.user-list')
+						.append(DataLayer.render(path+'user_shared_add_itemlist.ejs', [{id: id, name: currentUsers [id] .name, mail: currentUsers [id] .mail}]))
+						.scrollTo('max');
+						
+						$('li.not-user').remove();
+						callbackSharedCotactsAdd();
+						old_item.remove();
+                                            }
+					}
+				});
+				event.preventDefault();
+			}
+		});
+
+		var callbackSharedCotactsAdd = function(event){
+			UI.dialogs.assingCalendar.find('.button').filter(".read.new").button({
+				icons: {
+					primary: "ui-icon-circle-zoomin"
+				},
+				text: false
+			}).click(function () {
+				incompatibleAcl($(this), ['b'], ['busy']);
+				changeAcl($(this), 'r');
+			})
+			.addClass('tiny disable ui-button-disabled ui-state-disabled')
+			.removeClass('new').end()
+			
+			.filter(".write.new").button({
+				icons: {
+					primary: "ui-icon-key"
+				},
+				text: false
+			}).click(function () {
+				incompatibleAcl($(this), ['b'], ['busy']);
+				dependsAcl($(this), ['r'], ['read']);
+				changeAcl($(this), 'w');
+			})
+			.addClass('tiny disable ui-button-disabled ui-state-disabled')
+			.removeClass('new').end()
+			
+			.filter(".remove.new").button({
+				icons: {
+					primary: "ui-icon-trash"
+				},
+				text: false
+			}).click(function () {
+				incompatibleAcl($(this), ['b'], ['busy']);
+				dependsAcl($(this), ['r'], ['read']);
+				changeAcl($(this), 'd');
+			})
+			.addClass('tiny disable ui-button-disabled ui-state-disabled')
+			.removeClass('new').end()
+			
+			.filter(".busy.new").button({
+				icons: {
+					primary: "ui-icon-clock"
+				},
+				text: false
+			}).click(function () {
+				//Remove incompativbilidade de acls
+				incompatibleAcl($(this), ['r', 'w', 'd', 's' ], ['read', 'write', 'remove', 'shared']);
+				changeAcl($(this), 'b');
+			})
+			.addClass('tiny disable ui-button-disabled ui-state-disabled')
+			.removeClass('new').end()
+			
+			.filter(".shared.new").button({
+				icons: {
+					primary: "ui-icon-transferthick-e-w"
+				},
+				text: false
+			}).click(function () {
+				incompatibleAcl($(this), ['b',], ['busy']);
+				dependsAcl($(this), ['r'], ['read']);
+				changeAcl($(this), 's');
+			})
+			.addClass('tiny disable ui-button-disabled ui-state-disabled')
+			.removeClass('new').end()
+
+			.filter(".close.new").button({
+				icons: {
+					primary: "ui-icon-close"
+				},
+				text: false
+			}).click(function () {
+				currentUsers[$(this).parents().find('input[name="user[]"]').val()] = false;
+                                var id = false;
+                                
+                                if(id = $(this).parents().find('input[name="permission[]"]').val())
+                                    DataLayer.remove('calendarToPermission', id);
+                                
+				$(this).parents('li').remove();
+			})
+			.addClass('tiny disable ui-button-disabled ui-state-disabled')
+			.removeClass('new').end();
+
+		UI.dialogs.assingCalendar.find('.user-list li').hover(
+			function () {
+				$(this).addClass("hover-user");
+				$(this).find('.button').removeClass('disable ui-button-disabled ui-state-disabled').end()
+				.find('.user-acls-shared-calendar').addClass('hover-user');
+			},
+			function () {
+				$(this).removeClass("hover-user");
+				$(this).find('.button').addClass('disable ui-button-disabled ui-state-disabled').end()
+				.find('.user-acls-shared-calendar').removeClass('hover-user');;
+			}
+		);		
+	}
+	UI.dialogs.assingCalendar.dialog('open');
+}
+
Index: trunk/expressoAdmin1_2/index.php
===================================================================
--- trunk/expressoAdmin1_2/index.php	(revision 5133)
+++ trunk/expressoAdmin1_2/index.php	(revision 5804)
@@ -9,5 +9,39 @@
 	*  option) any later version.														 *
 	\*************************************************************************************/
-	$debug = false;	
+	
+        echo '
+            <link rel="Stylesheet" type="text/css" href="../prototype/plugins/jquery/jquery-ui.css" />					
+    
+            <script type="text/javascript" src="../prototype/plugins/jquery/jquery.min.js"></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>
+            <script src="../prototype/plugins/json2/json2.js" language="javascript"></script>
+            <script src="../prototype/plugins/ejs/ejs.js" language="javascript"></script>
+            <script src="../prototype/plugins/store/jquery.store.js" language="javascript"></script>
+            
+            <script src="../prototype/api/datalayer.js" language="javascript"></script>	
+           
+            <link rel="stylesheet" type="text/css" href="../prototype/plugins/zebradialog/css/zebra_dialog.css"></link>
+
+            <script type="text/javascript" src="../prototype/plugins/zebradialog/javascript/zebra_dialog.js"></script>
+            <script language="javascript">DataLayer.dispatchPath = "../prototype/";</script>
+            <script type="text/javascript" src="../prototype/plugins/datejs/date-pt-BR.js"></script>
+            <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/modules/calendar/js/timezone.js"></script>	
+            
+            <script type="text/javascript" src="../prototype/modules/calendar/js/calendar.codecs.js"></script>
+            
+            <script type="text/javascript" src="js/jscode/assing_calendar.js"></script>
+            <script type="text/javascript" src="../prototype/plugins/scrollto/jquery.scrollTo.js"></script>
+
+            <link rel="stylesheet" type="text/css" href="../prototype/modules/calendar/css/layout.css" />
+            <link rel="stylesheet" type="text/css" href="../prototype/modules/calendar/css/style.css" />
+            <link rel="stylesheet" type="text/css" href="templates/default/assing_calendar.css" />
+        ';
+
+        $debug = false;	
 	$time_start = microtime(true);
 
@@ -20,4 +54,5 @@
 	
 	$current_config = $c->config_data;
+                  
 	$ldap_manager = CreateObject('contactcenter.bo_ldap_manager');
 	$boemailadmin	= CreateObject('emailadmin.bo');
@@ -41,4 +76,5 @@
 		'lang_messages_size'    => lang('Messages Size'),
 		'lang_institutional_accounts'=> lang('Institutional Accounts'),
+                'lang_assing_calendar' => lang('Assign default calendar for user'),
 		'lang_user_groups'		=> lang('User Groups'),
 		'lang_email_lists'		=> lang('Email Lists'),
Index: trunk/expressoAdmin1_2/templates/default/shared_accounts.tpl
===================================================================
--- trunk/expressoAdmin1_2/templates/default/shared_accounts.tpl	(revision 5133)
+++ trunk/expressoAdmin1_2/templates/default/shared_accounts.tpl	(revision 5804)
@@ -1,4 +1,26 @@
 <!-- BEGIN body -->
-	<link rel="stylesheet" type="text/css" href="./expressoAdmin1_2/templates/default/shared_accounts.css">
+	<link rel="stylesheet" type="text/css" href="./expressoAdmin1_2/templates/default/shared_accounts.css"/>
+        
+        
+        <link rel="Stylesheet" type="text/css" href="prototype/plugins/jquery/jquery-ui.css" />					
+    
+        <script type="text/javascript" src="prototype/plugins/jquery/jquery.min.js"></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>
+        <script src="prototype/plugins/json2/json2.js" language="javascript"></script>
+        <script src="prototype/plugins/store/jquery.store.js" language="javascript"></script>
+
+        <script src="prototype/api/datalayer.js" language="javascript"></script>	
+
+        <script language="javascript">DataLayer.dispatchPath = "prototype/";</script>
+        <script type="text/javascript" src="prototype/plugins/datejs/date-pt-BR.js"></script>
+        <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/modules/calendar/js/timezone.js"></script>	
+
+        <script type="text/javascript" src="prototype/modules/calendar/js/calendar.codecs.js"></script>
+
 	<div style="display:none" id="{modal_id}">{shared_accounts_modal}</div>
 
Index: trunk/expressoAdmin1_2/templates/default/assing_calendar.css
===================================================================
--- trunk/expressoAdmin1_2/templates/default/assing_calendar.css	(revision 5804)
+++ trunk/expressoAdmin1_2/templates/default/assing_calendar.css	(revision 5804)
@@ -0,0 +1,29 @@
+div.assing-calendar fieldset.remove-border{border: 0px !important; padding: 0px;}
+div.assing-calendar dd{margin: 0 0 0 0 !important;}
+div.assing-calendar dl{margin: 5px !important;}
+
+div.assing-calendar fieldset.add-user-search{width: 234px;}
+div.assing-calendar input.search{width: 210px;}
+
+div.assing-calendar dt.calendar-list.calendar-name{width: 70px;}
+
+div.assing-calendar{overflow: hidden !important;}
+
+div.assing-calendar div.menu-container.footer-container{margin: 2px 0 -12px 0 !important;}
+div.assing-calendar ul.search-result-list,div.assing-calendar ul.user-list{margin-left: -54px !important; width: 252px !important;      }
+div.assing-calendar ul li{overflow: hidden !important;}
+div.assing-calendar li.not-user{margin: 0 0 0 20px !important;}
+div.assing-calendar fieldset.add-user-search{margin: 0 0 5px -10px !important;}
+
+div.assing-calendar dd.add-user {height: 290px !important;}
+
+div.assing-calendar dd.calendar-list li{height: 20px !important; margin: 0 0 0 10px !important;}
+
+div.assing-calendar dd.calendar-list li div{display: block !important;}
+
+div.assing-calendar dd.calendar{height: 24px;}
+
+div.assing-calendar li.calendar-selected{margin: -13px 0 0 -40px}
+div.assing-calendar li.calendar-selected a {margin: 0 0 -2px 15px;}
+
+div.assing-calendar dd.calendar-list li.user-list{width: 333px;}
Index: trunk/expressoAdmin1_2/templates/default/shared_accounts_modal.tpl
===================================================================
--- trunk/expressoAdmin1_2/templates/default/shared_accounts_modal.tpl	(revision 5133)
+++ trunk/expressoAdmin1_2/templates/default/shared_accounts_modal.tpl	(revision 5804)
@@ -47,5 +47,5 @@
 						
 		<td width="15%" valign="bottom" align="center" bgcolor="#DDDDDD" style="padding-bottom: 5px;">
-                    <table align="center">
+                    <table align="center" style="display: {aclCalendar}">
                         <tbody>
                                 <tr>
@@ -66,4 +66,23 @@
 				<tr >
                                     <td>{lang_restrict}</td><td><input type="checkbox" name="checkAttr" id ="em_input_restrictCalendar" onclick="return sharemailbox.setCalendaraclfromuser();" /><img title="{lang_this_user_will_can_read_restrict_events_at_the_mailbox_calendar}." src="./expressoAdmin1_2/templates/default/images/ajuda.jpg"></td>
+				</tr>
+                            </tbody>
+                    </table>
+                    <table align="center" style="display: {aclExpressoCalendar}">
+                        <tbody>
+                                <tr>
+                                    <td colspan="2" width="125"><b>{lang_calendar}:</b></td>
+                                </tr>
+                                <tr>
+                                    <td>{lang_read}</td><td><input type="checkbox" name="checkAttr" id ="em_input_readExpressoCalendar" onclick="return sharemailbox.setExpressoCalendaraclfromuser();" /><img title="{lang_this_user_will_can_read_events_at_the_mailbox_calendar}." src="./expressoAdmin1_2/templates/default/images/ajuda.jpg"></td>
+				</tr>
+				<tr >
+                                    <td>{lang_write}</td><td><input type="checkbox" name="checkAttr" id ="em_input_writeExpressoCalendar" onclick="return sharemailbox.setExpressoCalendaraclfromuser();" /><img title="{lang_this_user_will_can_create_events_at_the_mailbox_calendar}." src="./expressoAdmin1_2/templates/default/images/ajuda.jpg"></td>
+				</tr>
+				<tr>
+                                    <td>{lang_exclusion}</td><td><input type="checkbox" name="checkAttr" id ="em_input_deleteExpressoCalendar" onclick="return sharemailbox.setExpressoCalendaraclfromuser();" /><img title="{lang_this_user_will_can_delete_events_at_the_mailbox_calendar}." src="./expressoAdmin1_2/templates/default/images/ajuda.jpg"></td>
+                                </tr>
+                                <tr >
+                                    <td>{lang_freebusy}</td><td><input type="checkbox" name="checkAttr" id ="em_input_freebusyExpressoCalendar" onclick="return sharemailbox.setExpressoCalendaraclfromuser();" /><img title="{lang_this_user_will_can_read_restrict_events_at_the_mailbox_calendar}." src="./expressoAdmin1_2/templates/default/images/ajuda.jpg"></td>
 				</tr>
                             </tbody>
Index: trunk/expressoAdmin1_2/templates/default/participants_search_itemlist.ejs
===================================================================
--- trunk/expressoAdmin1_2/templates/default/participants_search_itemlist.ejs	(revision 5804)
+++ trunk/expressoAdmin1_2/templates/default/participants_search_itemlist.ejs	(revision 5804)
@@ -0,0 +1,9 @@
+<% for (var i=0; i < data.length; i++) { %>
+<li class="ui-widget-content" style="width:6000px;" title="<%=data[i]['name']%>">
+	<input type="checkbox" name="opcao" <%= (data[i].enabled) ?  '' : 'disabled="disabled"' %> />
+	<input type="hidden" value="<%=data[i]['id']%>" />
+	<label class="name"><%=data[i]['name']%></label>
+	<label class="mail hidden"><%=data[i]['mail']%></label>
+	<label class="id hidden"><%=data[i]['id']%></label>
+</li>
+<% } %>
Index: trunk/expressoAdmin1_2/templates/default/assing_calendar.ejs
===================================================================
--- trunk/expressoAdmin1_2/templates/default/assing_calendar.ejs	(revision 5804)
+++ trunk/expressoAdmin1_2/templates/default/assing_calendar.ejs	(revision 5804)
@@ -0,0 +1,69 @@
+<fieldset class="assing-calendar-configure remove-border">
+	<form method="POST" action="" class="form-addevent content">
+            <fieldset class="remove-border">
+		<dl class="block-user-list users-list">
+			
+                    <dt class="calendar-list calendar-name">Calendario</dt>
+                    <dd class="calendar">
+                        <input type="hidden" name="calendarId" value=""/>
+                        <ul class="calendarName"></ul>        
+                    </dd>
+			
+			<dt class="<%=data.calendar ? "user-list" : "calendar-list"%>"><%=data.calendar ? 'Compartilhar com' : 'Agendas Selecionadas'%></dt>
+			<dd class="<%=data.calendar ? "user-list" : "calendar-list"%>">
+				<ul class="user-list">
+				<% if (false) {
+					for (var i=0; i< data.event.user.length; i++) {%>
+						<li class="user"> 
+							<div style="overflow:hidden; width:100%; display:table;">
+								<input type="checkbox" value="">
+								<input type="hidden" name="user[]" value="">
+								<label class="name"></label>
+								<label class="mail"></label>
+							</div> 
+							<div class="assing-acl">
+									<a class="button edit user-options-button-edit new">Editar permissões</a>
+									<a class="button close new">Remover</a>
+							</div>
+						</li>	
+					<%} 
+				} else { %>
+					<li class="not-user"><%=data.calendar ? "Não compartilhado." : "Nenhuma agenda selecionada"%></li>
+				<% } %>
+				</ul>
+			</dd>	
+		</dl>
+
+		<%if(data.calendar){%>
+			<dl class="block-public-calendar">
+				<dt class="calendar-public">Agenda pública</dt>
+				<dd class="calendar-public">
+						<ul>
+							<input type="checkbox" name="isPublic"/><label>Pública</label>
+							<input type="checkbox" name="busy" class="free-busy hidden"/><label class="free-busy hidden">Livre/Ocupado</label>
+						</ul>
+				</dd>
+			</dl>
+		<%}%>
+		<dl class="block-add-user search ">
+			<dt class="add-user search">Pesquisar agendas</dt>
+			<dd class="add-user">
+				<fieldset class="block-add-user" title="Usuários">
+					<fieldset class="add-user-search search-field ui-corner-all">
+						<input class="search" type="text" />
+						<span class="ui-icon ui-icon-search"></span>
+						
+					</fieldset>
+					<ul class="search-result-list ui-corner-all">
+
+					</ul>
+				</fieldset>
+			</dd>
+		</dl>
+	</fieldset>
+	<div class="menu-container footer-container menu-addevent">
+		<a class="button cancel" href="#">Cancelar</a>
+	    <a class="button save" href="#">Salvar</a>
+    </div>
+	</form>
+</fieldset>
Index: trunk/expressoAdmin1_2/templates/default/index.tpl
===================================================================
--- trunk/expressoAdmin1_2/templates/default/index.tpl	(revision 5133)
+++ trunk/expressoAdmin1_2/templates/default/index.tpl	(revision 5804)
@@ -31,4 +31,12 @@
   		<td>
   			<a href="../index.php?menuaction=expressoAdmin1_2.uishared_accounts.index">{lang_shared_accounts}</a>
+  		</td>
+  	</tr>
+        <tr>
+		<td width="1%" align="center">
+			<img src='./templates/default/images/calendar.png'>
+  		</td>
+  		<td>
+                    <a href="#" onclick="assing_calendar_user()">{lang_assing_calendar}</a>
   		</td>
   	</tr>  
@@ -100,3 +108,4 @@
 	</tr>
 </table>
+                <input type="hidden" id="assingCalendar"/>
 <!-- END body -->
Index: trunk/expressoAdmin1_2/templates/default/user_shared_add_itemlist.ejs
===================================================================
--- trunk/expressoAdmin1_2/templates/default/user_shared_add_itemlist.ejs	(revision 5804)
+++ trunk/expressoAdmin1_2/templates/default/user_shared_add_itemlist.ejs	(revision 5804)
@@ -0,0 +1,34 @@
+<li class="user-list <%=data[0].isCurrent ? 'current' : 'new' %>"> 
+	<div style="overflow:hidden; width:100%; display:table;">
+		<%if(data[0].isCalendar){%>
+			<div class="user-acls-shared-calendar calendar">
+					<a class="button close new">Remover</a>
+			</div>
+			
+			<input type="checkbox" name="idPermission" value="<%=data[0].idPermission%>">
+			<input type="hidden" name="calendar[]" value="<%=data[0].id%>">
+			<input type="hidden" name="type[]" value="<%=data[0].type%>">
+			<label title="<%=data[0].description%>" class="name"><%= data[0].name ? data[0].name : '' %></label>
+		<%}else{%>
+			<div class="user-acls-shared-calendar">
+					<a class="button read user-options-button-view new">Ver</a>
+					<a class="button write user-options-button-edit-new new">Criar/Editar</a>
+					<a class="button remove user-options-button-remove new">Excluir</a>
+					<a class="button busy user-options-button-free-bussy new">Livre/Ocupado</a>
+					<a class="button shared user-options-button-shared new">Compartilhar</a>
+					<a class="button close new">Remover</a>
+			</div>
+		
+		<input type="checkbox" value="<%=data[0].id%>">
+		
+		<input type="hidden" name="user[]" value="<%=data[0].id%>">
+		<input type="hidden" name="attendeeAcl[]" value="<%=data[0].aclValue%>">
+		<%if(data[0].isCurrent){%>
+                    <input type="hidden" name="permission[]" value="<%=data[0].permission%>">
+                <%}%>
+		<label title="<%=data[0].name%>" class="name"><%= data[0].name ? data[0].name : '' %></label>
+		<label title="<%=data[0].mail%>" class="mail <%= data[0].name ? 'hidden' : ''%>"><%= data[0].mail ? data[0].mail : '' %></label>
+		<%}%>
+	</div>
+	
+</li>
Index: trunk/admin/inc/hook_admin.inc.php
===================================================================
--- trunk/admin/inc/hook_admin.inc.php	(revision 3480)
+++ trunk/admin/inc/hook_admin.inc.php	(revision 5804)
@@ -85,4 +85,9 @@
 		$file['VoIP settings']         = $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uivoip.edit_conf');
 	}
+	
+	if (! $GLOBALS['phpgw']->acl->check('site_config_access',1,'admin'))
+	{
+		$file['Calendar settings'] = $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicalendar.edit_conf');
+	}
 
 	/* Do not modify below this line */
Index: trunk/admin/inc/class.uiconfig.inc.php
===================================================================
--- trunk/admin/inc/class.uiconfig.inc.php	(revision 5773)
+++ trunk/admin/inc/class.uiconfig.inc.php	(revision 5804)
@@ -18,4 +18,11 @@
 		function index()
 		{
+		
+				ob_start();
+			print_r("teste :D :D :D");
+	
+			$output = ob_get_clean();
+			file_put_contents( "/tmp/acoutinho.log",  $output , FILE_APPEND);
+		
 			if ($GLOBALS['phpgw']->acl->check('site_config_access',1,'admin'))
 			{
@@ -69,4 +76,14 @@
 				$current_config = $c->config_data;
 			}
+	
+		if($appname === "expressoCalendar"){						
+			if (isset($_POST['migration']) && ($_POST['migration']  == "true")){
+			
+				require_once dirname(__FILE__ )."/../../expressoCalendar/inc/class.ui_migration.inc.php";
+
+				$migratrion = new Migra();
+				$migratrion->calendar();
+			}
+		}
 
 			if ($_POST['cancel'] || $_POST['submit'] && $GLOBALS['phpgw']->acl->check('site_config_access',2,'admin'))
@@ -289,6 +306,5 @@
 				
 				$t->set_var('rows_login_generator',$options);
-			}
-			
+			}		
 			
 			if($appname=="admin") {							
Index: trunk/admin/inc/class.uicalendar.inc.php
===================================================================
--- trunk/admin/inc/class.uicalendar.inc.php	(revision 5804)
+++ trunk/admin/inc/class.uicalendar.inc.php	(revision 5804)
@@ -0,0 +1,86 @@
+<?php
+
+ /**************************************************************************\
+  * Expresso Livre - Voip - administration                                   *
+  *															                 *
+  * --------------------------------------------                             *
+  *  This program is free software; you can redistribute it and/or modify it *
+  *  under the terms of the GNU General Public License as published by the   *
+  *  Free Software Foundation; either version 2 of the License, or (at your  *
+  *  option) any later version.                                              *
+  \**************************************************************************/
+
+class uicalendar
+{
+	var $public_functions = array(
+		'edit_conf' => True
+	);
+
+	final function __construct(){}
+	
+	final function edit_conf()
+	{
+		if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
+		{
+			$GLOBALS['phpgw']->redirect_link('/index.php');
+		}		
+
+		$GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') .' - ' . lang('Configuration Calendars');
+
+		if(!@is_object($GLOBALS['phpgw']->js))
+		{
+			$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
+		}
+
+		$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
+		$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
+
+		if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
+			$webserver_url .= '/';
+
+		$js = array('connector','xtools','functions');
+	
+		foreach( $js as $tmp )
+			$GLOBALS['phpgw']->js->validate_file('calendar',$tmp,'admin');
+		
+		$GLOBALS['phpgw']->common->phpgw_header();
+		echo parse_navbar();
+		echo '<script type="text/javascript">var path_adm="'.$webserver_url .'"</script>';
+		
+	    $c = CreateObject('phpgwapi.config','phpgwapi');
+		$c->read_repository();
+		$current_config = $c->config_data;    
+ 	
+		if(isset($current_config['defaultCalendar'])){
+			$selected =  $current_config['defaultCalendar'] == 'calendar' ?  'calendar' :  'expressoCalendar';
+			$option = $selected == 'calendar' ?  'expressoCalendar' :  'calendar';
+		}else{
+			$selected = 'calendar';
+			$option = 'expressoCalendar';
+		}	
+	
+		$t = CreateObject('phpgwapi.Template', $GLOBALS['phpgw']->common->get_tpl_dir('admin'));
+		$t->set_unknowns('keep');
+		$t->set_file(array('calendar' => 'calendar.tpl'));
+		$t->set_block('calendar','calendar_page','calendar_page');
+		$t->set_var(array(
+                        'action_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=admin'),
+                        'lang_Calendar_default_for_current_installation' => lang('Calendar default for current installation'),
+                        'lang_Calendar_settings' => 'Configuração do Calendar',	
+                        'lang_save' => lang('Save'),
+                        'lang_cancel' => lang('Cancel'),
+                        'selected' => $selected,
+                        'option' => $option
+                ));
+		$t->pparse('out','calendar');
+	}
+	
+	function display_row($label, $value)
+	{
+		$GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color());
+		$GLOBALS['phpgw']->template->set_var('label',$label);
+		$GLOBALS['phpgw']->template->set_var('value',$value);
+		$GLOBALS['phpgw']->template->parse('rows','row',True);
+	}
+}
+?>
Index: trunk/admin/templates/default/calendar.tpl
===================================================================
--- trunk/admin/templates/default/calendar.tpl	(revision 5804)
+++ trunk/admin/templates/default/calendar.tpl	(revision 5804)
@@ -0,0 +1,26 @@
+	<!-- BEGIN calendar_page -->
+	<form method="POST" action="{action_url}">
+	<table align="center" width="60%" cellspacing="2" style="border: 1px solid #000000;">
+		<tr class="th">
+			<td colspan="2">&nbsp;<b>{lang_Calendar_settings}</b></td>
+		</tr>
+		<tr class="row_off">
+			<td>{lang_Calendar_default_for_current_installation}:</td>
+			<td>
+				<select name="newsettings[defaultCalendar]"> 
+					<option value="{selected}">{selected}</option> 
+					<option value="{option}"  >{option}</option> 
+				</select> 
+			</td>
+		</tr>   
+
+		<tr>
+			<td colspan="2" align="center">
+			  <input type="submit" name="submit" value="{lang_save}">
+			  <input type="submit" name="submit" value="{lang_cancel}">
+			  <br>
+			</td>
+		</tr>
+	</table>
+	</form>
+	<!-- END calendar_page -->
Index: trunk/expressoCalendar/setup/default_records.inc.php
===================================================================
--- trunk/expressoCalendar/setup/default_records.inc.php	(revision 5715)
+++ trunk/expressoCalendar/setup/default_records.inc.php	(revision 5804)
@@ -31,5 +31,5 @@
 		$oProc->query("ALTER TABLE calendar_signature ADD CONSTRAINT fk_calendar_signature_calendar_espec FOREIGN KEY (calendar_id) REFERENCES calendar (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");
                 
-        //calendar_signature_alarm
+                //calendar_signature_alarm
 		$oProc->query("ALTER TABLE calendar_signature_alarm ADD CONSTRAINT fk_calendar_signature_alarm_calendar_signature FOREIGN KEY (calendar_signature_id) REFERENCES calendar_signature (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");
                 
@@ -41,4 +41,6 @@
                 $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');");
-		
+
+                //Admin conf
+                $oProc->query("INSERT INTO phpgw_hooks( \"hook_appname\", \"hook_location\", \"hook_filename\") VALUES ('expressoCalendar','admin', 'hook_admin.inc.php');");
 ?>
Index: trunk/expressoCalendar/setup/tables_update.inc.php
===================================================================
--- trunk/expressoCalendar/setup/tables_update.inc.php	(revision 5746)
+++ trunk/expressoCalendar/setup/tables_update.inc.php	(revision 5804)
@@ -74,5 +74,5 @@
 		$GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.002';
         return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
-	}
+	};
 
 	$test[] = '1.002';
@@ -85,4 +85,18 @@
             $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.003';
             return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
-	}
+	};
+        
+        $test[] = '1.003';
+	function expressoCalendar_upgrade1_003() {
+
+            $oProc = $GLOBALS['phpgw_setup']->oProc;
+
+            $oProc->query("INSERT INTO phpgw_hooks( \"hook_appname\", \"hook_location\", \"hook_filename\") VALUES ('expressoCalendar','admin', 'hook_admin.inc.php')");
+
+            $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.004';
+            return $GLOBALS['setup_info']['expressoCalendar']['currentver'];
+	};
+        
+        
+        
 ?>
Index: trunk/expressoCalendar/setup/setup.inc.php
===================================================================
--- trunk/expressoCalendar/setup/setup.inc.php	(revision 5741)
+++ trunk/expressoCalendar/setup/setup.inc.php	(revision 5804)
@@ -13,5 +13,5 @@
 	$setup_info['expressoCalendar']['title']     	= 'Expresso Calendar';
 	/* Ao incrementar versão, não esquecer de declarar função do tables_update.inc.php*/
-	$setup_info['expressoCalendar']['version']   	= '1.003';
+	$setup_info['expressoCalendar']['version']   	= '1.004';
 	$setup_info['expressoCalendar']['app_order']	= 10;
         
Index: trunk/expressoCalendar/inc/hook_admin.inc.php
===================================================================
--- trunk/expressoCalendar/inc/hook_admin.inc.php	(revision 5804)
+++ trunk/expressoCalendar/inc/hook_admin.inc.php	(revision 5804)
@@ -0,0 +1,20 @@
+<?php
+	/***********************************************************************************\
+	* Expresso Calendar                										   
+	* 
+	* ---------------------------------------------------------------------------------*
+	*  This program is free software; you can redistribute it and/or modify it		   *
+	*  under the terms of the GNU General Public License as published by the		   *
+	*  Free Software Foundation; either version 2 of the License, or (at your		   *
+	*  option) any later version.													   *
+	\***********************************************************************************/
+
+	// Only Modify the $file and $title variables.....
+	$title = $appname;
+	$file = Array(
+		'ExpressoCalendar migração' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
+	);
+	//Do not modify below this line
+	display_section($appname,$title,$file);
+
+?>
Index: trunk/expressoCalendar/inc/class.ui_migration.inc.php
===================================================================
--- trunk/expressoCalendar/inc/class.ui_migration.inc.php	(revision 5804)
+++ trunk/expressoCalendar/inc/class.ui_migration.inc.php	(revision 5804)
@@ -0,0 +1,282 @@
+<?php
+class Migra{
+		public $local;
+		public $login; 
+		public $senha; 
+		public $banco;
+		public $banco2;		
+		public $porta;
+
+		public $current_base;
+		public $new_base;
+		
+		/*
+		*	TODO - Implementar:
+		*	Repetição
+		*	Alarm
+		*	ACL
+		*/
+	
+		function __construct()
+		{
+                    include_once dirname(__FILE__ ).'/../../header.inc.php';
+		
+                    if (is_array($_SESSION['phpgw_info']['expresso']['server']))
+                        $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server'];
+                    else
+                    $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server'];
+					
+			$local = $_SESSION['phpgw_info']['expresso']['server']['db_host'];
+			$login = $_SESSION['phpgw_info']['expresso']['server']['db_user'];
+			$senha = $_SESSION['phpgw_info']['expresso']['server']['db_pass'];
+			$banco = $_SESSION['phpgw_info']['expresso']['server']['db_name'];
+			$porta = $_SESSION['phpgw_info']['expresso']['server']['db_port'];
+			$banco2 = $banco;
+
+			$this->current_base = pg_connect("host='$local' port='$porta' dbname='$banco' user='$login' password='$senha'");
+			$this->new_base = pg_connect("host='$local' port='$porta' dbname='$banco2' user='$login' password='$senha'");
+		}
+		
+		//Verifica e/ou cria agenda
+		function as_calendar($uid){
+			$sql = "select (calendar_id) FROM calendar_signature where user_uidnumber = ".$uid." and is_owner = 1";		
+			$result = pg_query($this->new_base ,$sql);
+			if (!$line = pg_fetch_assoc($result)) {
+					$last_resource = pg_query($this->new_base, "insert into calendar (name, location) values('Calendar' , 'Calendar' ) RETURNING id");
+					$last = pg_fetch_assoc($last_resource);
+					
+					$id_resource =  pg_query($this->new_base, "insert into calendar_signature(user_uidnumber, calendar_id, is_owner, font_color, background_color, border_color) values(".$uid.", ".$last['id'].", 1, 'FFFFFF', '3366CC', '3366CC') RETURNING id");
+					$calendar = pg_fetch_assoc($id_resource);
+					return $calendar['id'];
+			}else{
+				$result = pg_query($this->new_base ,$sql);
+				while($evento = pg_fetch_array($result)){
+					return $evento['calendar_id'];
+				}
+			}
+		}
+		
+		//Usuarios de um evento
+		function as_user($cal_id, $calendar_object ,$owner){
+			$sql_select_user = "select * from phpgw_cal_user where cal_id = ".$cal_id;			
+			$result = pg_query($this->current_base ,$sql_select_user);
+				
+			while($evento = pg_fetch_array($result)){
+				$sql_insert = "insert into calendar_participant (user_info_id, object_id, is_organizer, acl ,is_external, participant_status_id) values ( ";
+				$sql_insert .= $evento['cal_login'].", ";
+				$sql_insert .= $calendar_object.", ";
+				
+				if ($owner == $evento['cal_login']){
+					$sql_insert .= "1, ";
+					$sql_insert .= '\'rowi\', ';
+				}else{
+					$sql_insert .= "0, ";
+					$sql_insert .= '\'r\', ';
+				}
+				$sql_insert .= "0, ";
+				
+				if($evento['cal_status'] == 'A')
+					$sql_insert .= "1) ";
+				else if ($evento['cal_status'] == 'U')
+					$sql_insert .= "4) ";
+				else if ($evento['cal_status'] == 'R')
+					$sql_insert .= "3) ";
+				else if ($evento['cal_status'] == 'T')
+					$sql_insert .= "2) ";				
+				pg_query($this->new_base ,$sql_insert);
+
+				$Id_Calendar_User = $this->as_calendar($evento['cal_login']);
+				$sql_insert_relcao = 'insert into calendar_to_calendar_object (calendar_id, calendar_object_id) values ( ';
+				$sql_insert_relcao .= $Id_Calendar_User.', ';
+				$sql_insert_relcao .= $calendar_object.' )';
+				pg_query($this->new_base ,$sql_insert_relcao);
+				
+			}
+		}
+		//Alarmes de um evento
+		function as_alarm($cal_id, $date_ini, $date_end){
+			$sql_select_evento = "select * from phpgw_async where id like '%".$cal_id."%'";			
+			$result = pg_query($this->current_base ,$sql_select_evento);
+				
+			while($evento = pg_fetch_array($result)){			
+				if(!$result['account_id'])
+					continue;
+				$sql_insert = "insert into calendar_alarm (action_id, time, range_end, range_start, unit, participant_id, object_id,sent) values ( ";
+				//action_id
+				$sql_insert .= "1, ";
+				
+				//time
+				$time =  split (":", $result['times']);
+				$sql_insert .= substr($time, -1).", ";
+				//range_end
+				$sql_insert .= "'".$date_end."', ";
+				//range_start
+				$sql_insert .= "'".$date_ini."', ";
+				//arrumar unit
+				$sql_insert .= "1, ";
+				//participant_id
+				$sql_insert .= $result['account_id'].", ";
+				//object_id
+				$sql_insert .= $cal_id.", ";
+				//sent
+				if($date_ini > time())
+					$sql_insert .= "0 ) ";
+				else
+					$sql_insert .= "1 ) ";
+				
+				pg_query($this->new_base ,$sql_insert);		
+			}
+		}
+		
+		//Usuarios externos de um evento
+		function as_user_external($cal_id, $calendar_object ,$owner, $ex_participante){
+		
+			$participants_ex = base64_decode($ex_participante);
+			//Participantes externos serializados
+			try {
+				$participants_ex = unserialize($participants_ex);
+				foreach ($participants_ex as $ex){
+				
+					$sql_insert = "insert into calendar_ex_participant (name, mail, owner) values ( ";
+					if(array_key_exists('cn', $ex)) 
+						$sql_insert .= "'".$ex['cn']."', ";
+					else
+						$sql_insert .= "'', ";
+					$sql_insert .= "'".$ex['mail']."', ";
+					$sql_insert .= $owner.") RETURNING id";
+					
+					$result = pg_query($this->new_base ,$sql_insert);
+					
+					$id_external = pg_fetch_assoc($result);	
+					$sql_insert = "insert into calendar_participant (user_info_id, object_id, is_organizer, is_external, participant_status_id) values ( ";
+					$sql_insert .=  $id_external['id'].", ";
+					$sql_insert .=  $calendar_object.", ";
+					$sql_insert .=  "0, ";
+					$sql_insert .=  "1, ";
+					$sql_insert .=  "4 ) ";
+						
+					pg_query($this->new_base ,$sql_insert);
+				}
+			//participantes externos normais
+			} catch (Exception $e) {
+				$participants_ex = split(',', $ex_participante);
+				
+				foreach ($participants_ex as $ex){
+					$sql_insert = "insert into calendar_ex_participant (mail, owner) values ( ";
+					$sql_insert .= "'".$ex."', ";
+					$sql_insert .= $owner.") RETURNING id";
+					
+					$result = pg_query($this->new_base ,$sql_insert);
+					
+					$id_external = pg_fetch_assoc($result);
+					
+					
+					$sql_insert = "insert into calendar_participant (user_info_id, object_id, is_organizer, is_external, participant_status_id) values ( ";
+					$sql_insert .=  $id_external['id'].", ";
+					$sql_insert .=  $calendar_object.", ";
+					$sql_insert .=  "0, ";
+					$sql_insert .=  "1, ";
+					$sql_insert .=  "4 ) ";
+					pg_query($this->new_base ,$sql_insert);
+					
+				}			
+			}		
+		}
+		
+		//
+		function calendar(){
+			$sql = "SELECT * FROM phpgw_cal";			
+			//Todo
+			//Implementar Repetição
+						
+			$result = pg_query($this->current_base, $sql);
+			while($evento = pg_fetch_array($result)){
+			
+				$sql_insert = "insert into calendar_object
+				(
+					type_id, cal_uid, dtstamp, 
+					dtstart, description, dtend, 
+					location, class_id, last_update,
+					range_end, range_start,
+					summary, allday, repeat, tzid			
+				)		
+						
+			values(";			
+				//remove lixos
+				if($evento['owner'] == 0)
+					continue;
+				if($evento['mdatetime'] == "" or $evento['mdatetime'] == null)
+					continue;
+				if($evento['datetime'] == "" or $evento['datetime'] == null)
+					continue;
+				if($evento['edatetime'] == "" or $evento['edatetime'] == null)
+					continue;
+				//type_id
+				$sql_insert .= "1, ";
+				//cal_uid
+				$sql_insert .= "'".mt_rand()."@Expresso', ";
+				//$sql_insert .= $this->as_calendar($evento['owner']).", ";
+				//dtstamp	
+				$sql_insert .= $evento['mdatetime']."000, ";
+				//dtstart
+				$sql_insert .= $evento['datetime']."000, ";
+				//description
+				if ($evento['description'] == "" or $evento['description'] == null)
+					$sql_insert .= "'', ";
+				else
+					$sql_insert .= "'".$evento['description']."', ";
+				//dtend
+				$sql_insert .= $evento['edatetime']."000, ";
+				//location
+				if ($evento['location'] == "" or $evento['location'] == null)
+					$sql_insert .= "'', ";
+				else
+					$sql_insert .= "'".$evento['location']."', ";
+				//class_id
+				if($evento['is_public'] == 1){
+					if($evento['cal_type'] == 'e')
+						$sql_insert .= "1, ";
+					else
+						$sql_insert .= "3, ";
+				}else
+					$sql_insert .= "2, ";
+				//last_update	
+				$sql_insert .= $evento['last_update'].", "; 
+				//range_end
+				$sql_insert .= "'".$evento['edatetime']."', ";				
+				//calendar_id
+				//$sql_insert .=  $this->as_calendar($evento['owner']).", ";
+				//range_start
+				$sql_insert .= "'".$evento['datetime']."', ";
+				//summary
+				if ($evento['title'] == "" or $evento['title'] == null)
+					$sql_insert .= "'', ";
+				else
+					$sql_insert .= "'".$evento['title']."', ";
+				//allday
+				$sql_insert .= "0, ";
+				//repeat
+				$sql_insert .= "0, ";
+				//tzid
+				$sql_insert .= "'America/Sao_Paulo'";
+				
+				$sql_insert .= 	" ) RETURNING id";			
+								
+				$last_resource = pg_query($this->new_base, $sql_insert);
+				$calendar = pg_fetch_assoc($last_resource);
+				
+				//participantes de um evento
+				$this->as_user($evento['cal_id'] ,$calendar['id'], $evento['owner']);
+				
+				//participantes externos de um evento
+				if($evento['ex_participants'] != "" and $evento['ex_participants'] != 'YTowOnt9')
+					$this->as_user_external($evento['cal_id'] ,$calendar['id'], $evento['owner'], $evento['ex_participants']);	
+				
+				//Por equanto desativado
+				//$this->as_alarm($evento['cal_id'], $evento['datetime'],$evento['edatetime']) ;	
+				
+			}
+			return 'sucesss';
+		}
+	}
+?>
Index: trunk/expressoCalendar/templates/default/config.tpl
===================================================================
--- trunk/expressoCalendar/templates/default/config.tpl	(revision 5804)
+++ trunk/expressoCalendar/templates/default/config.tpl	(revision 5804)
@@ -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: trunk/prototype/services/OpenLDAP.php
===================================================================
--- trunk/prototype/services/OpenLDAP.php	(revision 5441)
+++ trunk/prototype/services/OpenLDAP.php	(revision 5804)
@@ -28,7 +28,7 @@
         
 	if( $justthese === false || $justthese === null )
-		$sr =  ldap_search( $this->con, $this->config['context'], '('.$this->config['idAtribute'].'='.$uri['id'].')' );
+		$sr =  ldap_search( $this->con, $this->config['context'], '('.$map['id'].'='.$uri['id'].')' );
 	else
-		$sr =  ldap_search( $this->con, $this->config['context'], '('.$this->config['idAtribute'].'='.$uri['id'].')', self::parseJustthese($justthese, $map) );
+		$sr =  ldap_search( $this->con, $this->config['context'], '('.$map['id'].'='.$uri['id'].')', self::parseJustthese($justthese, $map) );
 
 	if(!$sr) return false; 
Index: trunk/prototype/services/iCal.php
===================================================================
--- trunk/prototype/services/iCal.php	(revision 5780)
+++ trunk/prototype/services/iCal.php	(revision 5804)
@@ -400,5 +400,5 @@
                                         $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$tpl.'.tpl');
                                         $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
-                                        $mail['from'] = Config::me('mail');   
+                                        $mail['from'] = '"'.Config::me('cn').'" <'.Config::me('mail').'>'; 
                                         $mail['to'] = $organizerMail;
  
Index: trunk/prototype/config/user.ini
===================================================================
--- trunk/prototype/config/user.ini	(revision 5514)
+++ trunk/prototype/config/user.ini	(revision 5804)
@@ -51,2 +51,3 @@
 phpgwAccountType = phpgwAccountType
 phpgwAccountVisible = phpgwAccountVisible
+gidNumber = gidNumber
Index: trunk/prototype/config/group.ini
===================================================================
--- trunk/prototype/config/group.ini	(revision 5804)
+++ trunk/prototype/config/group.ini	(revision 5804)
@@ -0,0 +1,25 @@
+; [service]
+; OpenLDAP = ''
+; PostgreSQL = external
+; 
+; [service.conflict]
+; checkExternal = modules/calendar/interceptors/DBMapping.php
+
+service = OpenLDAP
+
+[OpenLDAP.before.find]
+encodeFindGroup = modules/calendar/interceptors/LDAPMapping.php
+
+[OpenLDAP.before.read]
+encodeFindGroup = modules/calendar/interceptors/LDAPMapping.php
+
+[OpenLDAP.mapping]
+id = gidNumber
+name = cn
+mail = mail
+description = description
+users = memberUid
+objectClass = objectClass
+phpgwAccountType = phpgwAccountType
+phpgwAccountVisible = phpgwAccountVisible
+mailAlternateAddress = mailAlternateAddress
Index: trunk/prototype/modules/calendar/interceptors/Notifications.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/Notifications.php	(revision 5523)
+++ trunk/prototype/modules/calendar/interceptors/Notifications.php	(revision 5804)
@@ -148,7 +148,7 @@
 
 		$data['nowStartDate'] = date_format( $sTime , 'd/m/Y');
-        $data['nowStartTime'] = ($schedulableReference['allDay']) ? '' : date_format( $sTime , 'H:i');
-        $data['nowEndDate'] = date_format( $eTime , 'd/m/Y');
-        $data['nowEndTime'] = ($schedulableReference['allDay']) ? '' :  date_format( $eTime , 'H:i');
+                $data['nowStartTime'] = ($schedulableReference['allDay']) ? '' : date_format( $sTime , 'H:i');
+                $data['nowEndDate'] = date_format( $eTime , 'd/m/Y');
+                $data['nowEndTime'] = ($schedulableReference['allDay']) ? '' :  date_format( $eTime , 'H:i');
 		$data['userRequest'] = Config::me('uid');
 		
@@ -161,5 +161,5 @@
 		$params['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/notify_suggestion_body.tpl');
 		$params['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
-		$params['from'] = Config::me('mail');   
+		$params['from'] ='"'.Config::me('cn').'" <'.Config::me('mail').'>';   
 		$params['to'] = $organizer['user']['mail'];
 		
@@ -192,5 +192,5 @@
 		$params['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
 		$params['to'] = $params['from'];
-		$params['from'] = Config::me('mail');   
+		$params['from'] = $params['from'] ='"'.Config::me('cn').'" <'.Config::me('mail').'>';
 	}
 	
@@ -435,5 +435,5 @@
        $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$template.'.tpl');
        $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
-       $mail['from'] = Config::me('mail');   
+       $mail['from'] = '"'.Config::me('cn').'" <'.Config::me('mail').'>';
        $mail['to'] = $to;
        Controller::create( array( 'service' => 'SMTP' ), $mail ); 
Index: trunk/prototype/modules/calendar/interceptors/LDAPMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/LDAPMapping.php	(revision 5437)
+++ trunk/prototype/modules/calendar/interceptors/LDAPMapping.php	(revision 5804)
@@ -36,8 +36,60 @@
                                                           )
                                                 );
+            
+                else
+                     $criteria['filter'] = array('AND',
+                                                array('AND' , 
+                                                            array('=' , 'objectClass' , 'phpgwAccount'),
+                                                            array('OR' , 
+                                                                        array('=' , 'phpgwAccountType' , 'i'),
+                                                                        array('=' , 'phpgwAccountType' , 'u'),
+                                                                        array('=' , 'phpgwAccountType' , 's')
+                                                                 )
+                                                     ),$criteria['filter']
+                                                );                      
             }
           
     }  
    
+
+       public function encodeFindGroup( &$uri , &$params , &$criteria , $original ){
+            if(isset($criteria['filter']))
+            {
+                if($criteria['filter'][0] === '*' && $criteria['filter'][1] === 'name') //Busca pelo nome group DFD00032
+                    $criteria['filter'] = array('AND',
+                                                array('AND' , 
+                                                            array('=' , 'objectClass' , 'phpgwAccount'),
+                                                            array('=' , 'phpgwAccountType' , 'g')
+                                                                 
+                                                    ),
+                                                 array('AND' ,  
+                                                                array('!','phpgwAccountVisible','-1'),
+                                                                array('OR', 
+                                                                        array('=','accountStatus','active'),
+                                                                        array('=','objectClass','posixGroup')
+                                                                    ),
+                                                                array('OR', 
+                                                                        array('*','name',$criteria['filter'][2]),
+                                                                        array('*','id',$criteria['filter'][2]),
+                                                                        array('*','mail',$criteria['filter'][2]),
+                                                                        array('*','mailAlternateAddress',$criteria['filter'][2]),
+                                                                    )
+                                                          )
+                                                );
+                
+                
+                    else
+                        $criteria['filter'] = array('AND',
+                            array('AND' , 
+                                        array('=' , 'objectClass' , 'phpgwAccount'),
+                                        array('=' , 'phpgwAccountType' , 'g')
+                                    ),$criteria['filter']
+                            );                      
+            }
+          
+    }  
+     
+    
+    
 }
 
Index: trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5798)
+++ trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5804)
@@ -468,6 +468,11 @@
 			
 			foreach($newResult as $key => &$value){
-				if($value['user']  != 0)
-					$value['user'] = Controller::read( array( 'concept' => 'user' , 'id' => $value['user'] ));
+                                if($value['user']  != 0){
+                                    $user = $value['user'];
+                                    $value['user'] = Controller::read( array( 'concept' => 'user' , 'id' => $user ));
+
+                                    if(!$value['user'])
+                                        $value['user'] = Controller::read( array( 'concept' => 'group' , 'id' => $user ));
+                                }
 			}
 
@@ -640,18 +645,21 @@
                 if(isset($v['calendar'])){
                     $result[$i]['calendar'] = Controller::read( array( 'concept' => 'calendar' , 'id' => $v['calendar']), false, false); 
-					$result[$i]['defaultAlarms'] = Controller::find( array( 'concept' => 'calendarSignatureAlarm' ) , false ,array( 'filter' => array('=', 'calendarSignature'  ,  $v['id']) ));    
-					//Caso não seja o dono da agenda retorna o objeto permission com as acls
-					if($result[$i]['isOwner'] == 0){
-						$permission = Controller::find( array( 'concept' => 'calendarToPermission'), false ,array( 'filter' => array('AND', array('=', 'calendar' ,  $v['calendar']), array('=', 'user', Config::me('uidNumber') ) ) ) ); 
-
-						if(!is_array($permission) || !$permission  ){
-
-							$permission = Controller::find( array( 'concept' => 'calendarToPermission'), false ,array( 'filter' => array('AND', array('=', 'calendar' ,  $v['calendar']), array('=', 'type', '1' ) ) ) );    
-
-						}
-						$result[$i]['permission'] = $permission[0];
-					}
-				}
-           }
+                    $result[$i]['defaultAlarms'] = Controller::find( array( 'concept' => 'calendarSignatureAlarm' ) , false ,array( 'filter' => array('=', 'calendarSignature'  ,  $v['id']) ));    
+                    //Caso não seja o dono da agenda retorna o objeto permission com as acls
+                    if($result[$i]['isOwner'] == 0){
+                            $permission = Controller::find( array( 'concept' => 'calendarToPermission'), false ,array( 'filter' => array('AND', array('=', 'calendar' ,  $v['calendar']), array('=', 'user', Config::me('uidNumber') ) ) ) ); 
+
+                            if(!is_array($permission) || !$permission  ){
+
+                                    $permission = Controller::find( array( 'concept' => 'calendarToPermission'), false ,array( 'filter' => array('AND', array('=', 'calendar' ,  $v['calendar']), array('=', 'type', '1' ) ) ) );    
+
+                            }
+                            $result[$i]['permission'] = $permission[0];
+                    }
+            }
+            //TODO - Padronizar retorno do deepness
+//            if(isset($v['user']))
+//                $result[$i]['user'] = Controller::read( array( 'concept' => 'user' , 'id' => $v['user']), false, false); 
+          }
        }       
    } 
Index: trunk/prototype/modules/calendar/constants.php
===================================================================
--- trunk/prototype/modules/calendar/constants.php	(revision 5780)
+++ trunk/prototype/modules/calendar/constants.php	(revision 5804)
@@ -44,3 +44,4 @@
 define('CALENDAR_ACL_BUSY', 'b');
 define('CALENDAR_ACL_SHARED', 's');
+define('CALENDAR_ACL_REQUIRED', 'p');
 ?>
Index: trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5752)
+++ trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5804)
@@ -44,5 +44,6 @@
 	'd' : 'remove',
 	'b' : 'busy',
-	's' : 'shared'
+	's' : 'shared',
+        'p' : 'required'
 }
 
@@ -145,6 +146,14 @@
 		*  quando forçado um get do banco, deverá ser criado uma condição para o mesmo
 		*/
-		var descart = DataLayer.get("calendarSignature", {filter: ['=', 'user', User.me.id], criteria: {deepness: 2}});
-		this.signatures  = DataLayer.get("calendarSignature", {filter: ['=', 'user', User.me.id], criteria: {deepness: 2}}, true);
+		var filter = ['=', 'user', User.me.id];
+		if(!!User.me.gidNumber){
+			if(!$.isArray(User.me.gidNumber))
+				User.me.gidNumber = [User.me.gidNumber];
+
+			filter = ['OR', filter, ['IN', 'user', User.me.gidNumber]];
+		}
+		
+		var descart = DataLayer.get("calendarSignature", {filter: filter, criteria: {deepness: 2}});
+		this.signatures  = DataLayer.get("calendarSignature", {filter: filter, criteria: {deepness: 2}}, true);
 	  
 		var prevSources = this.sources;
Index: trunk/prototype/modules/calendar/templates/calendar_list.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/calendar_list.ejs	(revision 5596)
+++ trunk/prototype/modules/calendar/templates/calendar_list.ejs	(revision 5804)
@@ -1,78 +1,80 @@
 <div class="all-list-calendars">
-<% var signature = data.signatures %>
-<% var external = false %>
-<div class="my-calendars">
-	<a title='Minhas agendas' class="title-my-calendars" aria-expanded='false' role='button' tabindex='0'>Minhas agendas</a>
-	<span class="status-list ui-icon ui-icon-triangle-1-s"></span>
-	<a href="#" class="button new new-calendar">Nova Agenda</a>
-	<ul class="list-calendars my-list-calendars">
-				<% for (var i=0; i < signature.length; i++) {
-					if(signature[i].isOwner == 1){
-				%>
-					<li class="list-calendars-item list-calendars-item-<%= signature[i].calendar.id %>">
-						
-						<div>
-							<input class="calendar-view" type="checkbox" name="" value="<%= signature[i].calendar.id %>" checked="checked"/>
-							<label><%= signature[i].calendar.name %></label>
-							
-						</div> 
-							<a class="cal-list-options-btn my-cal-list-options-btn-<%= signature[i].calendar.id %>" style="background-color:#<%=signature[i].backgroundColor%>; border-color:#<%= signature[i].borderColor%>;">
-								<img src="../prototype/modules/calendar/img/arrow_down.png" width="10" height="10" class="cal-list-img"/>
-							</a>
-							
-							
-						<div class="cal-list-options my-cal-list-options-<%= signature[i].calendar.id %> hidden">
-							<ul>
-								<li><a href="#" onclick="add_tab_configure_calendar(<%= signature[i].calendar.id%>);">Configurações</a></li>
-								<li><a href="#" onclick="show_modal_import_export(0, <%= signature[i].calendar.id%>);">Importar</a></li>
-								<li><a href="#" onclick="show_modal_import_export(1, <%= signature[i].calendar.id%>);">Exportar</a></li>
-								<li><a href="#" onclick="show_modal_shared(<%= signature[i].calendar.id%>);">Compartilhar agenda</a></li>
-                                <li><a href="#" onclick="remove_calendar();">Remover agenda</a></li>
-							</ul>
-                                                        
-						</div>
-					</li>
-			<% 		
-					}else
-						external = true;
-				}
-			%>
-		   
-	</ul>
+    <% var signature = data.signatures %>
+    <% var external = false %>
+    <div class="my-calendars">
+        <a title='Minhas agendas' class="title-my-calendars" aria-expanded='false' role='button' tabindex='0'>Minhas agendas</a>
+        <span class="status-list ui-icon ui-icon-triangle-1-s"></span>
+        <a href="#" class="button new new-calendar">Nova Agenda</a>
+        <ul class="list-calendars my-list-calendars">
+            <% for (var i=0; i < signature.length; i++) {
+            if(signature[i].isOwner == 1){
+            %>
+            <li class="list-calendars-item list-calendars-item-<%= signature[i].calendar.id %>">
+
+                <div>
+                    <input class="calendar-view" type="checkbox" name="" value="<%= signature[i].calendar.id %>" checked="checked"/>
+                    <label><%= signature[i].calendar.name %></label>
+
+                </div> 
+                <a class="cal-list-options-btn my-cal-list-options-btn-<%= signature[i].calendar.id %>" style="background-color:#<%=signature[i].backgroundColor%>; border-color:#<%= signature[i].borderColor%>;">
+                    <img src="../prototype/modules/calendar/img/arrow_down.png" width="10" height="10" class="cal-list-img"/>
+                </a>
+
+
+                <div class="cal-list-options my-cal-list-options-<%= signature[i].calendar.id %> hidden">
+                    <ul>
+                        <li><a href="#" onclick="add_tab_configure_calendar(<%= signature[i].calendar.id%>);">Configurações</a></li>
+                        <li><a href="#" onclick="show_modal_import_export(0, <%= signature[i].calendar.id%>);">Importar</a></li>
+                        <li><a href="#" onclick="show_modal_import_export(1, <%= signature[i].calendar.id%>);">Exportar</a></li>
+                        <li><a href="#" onclick="show_modal_shared(<%= signature[i].calendar.id%>);">Compartilhar agenda</a></li>
+                        <li><a href="#" onclick="remove_calendar();">Remover agenda</a></li>
+                    </ul>
+
+                </div>
+            </li>
+            <% 		
+            }else
+            external = true;
+            }
+            %>
+
+        </ul>
+    </div>
+
+    <div class="signed-calendars">
+        <a title='Agendas assinadas' class="title-signed-calendars" aria-expanded='false' role='button' tabindex='0'>Agendas assinadas</a>			
+        <span class="status-list-shared ui-icon ui-icon-triangle-1-s"></span>
+        <a href="#" class="button new new-calendar-shared tiny">Nova Agenda</a>
+
+        <% if (external) { %>	
+        <ul class="list-calendars signed-list-calendars">
+            <% for (var i=0; i < signature.length; i++) {
+            if(signature[i].isOwner == 0){
+            %>
+            <li class="list-calendars-item list-calendars-item-<%= signature[i].calendar.id %>">
+                <input class="calendar-view" type="checkbox" name="" value="<%= signature[i].calendar.id %>" checked="checked"/>
+                <label><%= signature[i].calendar.name %></label>
+
+                <a class="cal-list-options-btn my-cal-list-options-btn-<%= signature[i].calendar.id %>" style="background-color:#<%=signature[i].backgroundColor%>; border-color:#<%= signature[i].borderColor%>;">
+                    <img src="../prototype/modules/calendar/img/arrow_down.png" width="10" height="10" class="cal-list-img"/></a>
+                <div class="cal-list-options my-cal-list-options-<%= signature[i].calendar.id  %> hidden">
+                    <ul>
+                        <!--<li><a href="#" onclick="add_tab_configure_calendar(<%= signature[i].calendar.id %>);">Configurações</a></li>-->
+                        <li><a href="#" onclick="show_modal_import_export(0, <%= signature[i].calendar.id %>);">Importar</a></li>
+                        <li><a href="#" onclick="show_modal_import_export(1, <%= signature[i].calendar.id %>);">Exportar</a></li>
+                        <%if(!signature[i].permission.acl['required']){%>
+                            <li><a href="#" onclick="cancel_signature(<%= signature[i].id %>);">Cancelar assinatura</a></li>
+                        <%}%>
+                    </ul>
+
+                </div>
+
+            </li>
+            <% 		
+            }
+            }
+            %>
+        </ul>
+        <% } %>
+    </div>
 </div>
-
-<div class="signed-calendars">
-	<a title='Agendas assinadas' class="title-signed-calendars" aria-expanded='false' role='button' tabindex='0'>Agendas assinadas</a>			
-	<span class="status-list-shared ui-icon ui-icon-triangle-1-s"></span>
-	<a href="#" class="button new new-calendar-shared tiny">Nova Agenda</a>
-	
-	<% if (external) { %>	
-		<ul class="list-calendars signed-list-calendars">
-				<% for (var i=0; i < signature.length; i++) {
-						if(signature[i].isOwner == 0){
-					%>
-						<li class="list-calendars-item list-calendars-item-<%= signature[i].calendar.id %>">
-							<input class="calendar-view" type="checkbox" name="" value="<%= signature[i].calendar.id %>" checked="checked"/>
-							<label><%= signature[i].calendar.name %></label>
-
-							<a class="cal-list-options-btn my-cal-list-options-btn-<%= signature[i].calendar.id %>" style="background-color:#<%=signature[i].backgroundColor%>; border-color:#<%= signature[i].borderColor%>;">
-							<img src="../prototype/modules/calendar/img/arrow_down.png" width="10" height="10" class="cal-list-img"/></a>
-							<div class="cal-list-options my-cal-list-options-<%= signature[i].calendar.id  %> hidden">
-								<ul>
-									<!--<li><a href="#" onclick="add_tab_configure_calendar(<%= signature[i].calendar.id %>);">Configurações</a></li>-->
-									<li><a href="#" onclick="show_modal_import_export(0, <%= signature[i].calendar.id %>);">Importar</a></li>
-									<li><a href="#" onclick="show_modal_import_export(1, <%= signature[i].calendar.id %>);">Exportar</a></li>
-									<li><a href="#" onclick="cancel_signature(<%= signature[i].id %>);">Cancelar assinatura</a></li>
-								</ul>
-
-						</div>
-
-						</li>
-					<% 		
-						}
-					}
-					%>
-		</ul>
-	<% } %>
-	</div>
-</div>
Index: trunk/expressoMail1_2/index.php
===================================================================
--- trunk/expressoMail1_2/index.php	(revision 5782)
+++ trunk/expressoMail1_2/index.php	(revision 5804)
@@ -166,5 +166,10 @@
     $c = CreateObject('phpgwapi.config','expressoMail1_2');
     $c->read_repository();
-    $current_config = $c->config_data;    
+    $current_config = $c->config_data;
+    
+    // Loading Config Module
+    $conf = CreateObject('phpgwapi.config','phpgwapi');
+    $conf->read_repository();
+    $config = $conf->config_data;   
 
     //Carrega Configuração global do expressoMail 
@@ -302,5 +307,5 @@
 		var token_param = "'.$var_tokens.'";
 		var locale = "'.$GLOBALS['phpgw']->common->getPreferredLanguage().'";
-		var new_agenda = "'.$current_config['new_agenda'].'";
+		var defaultCalendar = "'.  (isset($config['defaultCalendar']) ?  $config['defaultCalendar']  :  "calendar" )    .'";
 		$("#sideboxdragarea").hide();
 		$("#menu2Container").hide();
Index: trunk/expressoMail1_2/templates/default/config.tpl
===================================================================
--- trunk/expressoMail1_2/templates/default/config.tpl	(revision 5406)
+++ trunk/expressoMail1_2/templates/default/config.tpl	(revision 5804)
@@ -122,13 +122,4 @@
  	   </select> 
  	    </td> 
-	</tr>
-	<tr bgcolor="{row_off}"> 
- 	    <td>{lang_Allow_importing_and_creating_events_directly_on_ExpressoCalendar_module_(new)}</td> 
- 	    <td> 
-		   <select name="newsettings[new_agenda]"> 
-		   <option value="false"{selected_new_agenda_False}>{lang_No}</option> 
-		   <option value="True"{selected_new_agenda_True}>{lang_Yes}</option> 
-		   </select> 
- 	   </td> 
 	</tr>
     <tr bgcolor="{row_off}">
Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 5791)
+++ trunk/expressoMail1_2/js/main.js	(revision 5804)
@@ -3351,5 +3351,5 @@
                 write_msg(get_lang(data));
     }	
-	if(new_agenda == "True" && $("#expressoCalendarid")[0]){
+	if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){
 		import_implements_calendar();
 		$( "#import-dialog" ).dialog({
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 5790)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 5804)
@@ -2914,5 +2914,5 @@
 	subject.innerHTML = info_msg.subject;
 	subject.className = "header_message_field";
-	if(new_agenda == "True" && $("#expressoCalendarid")[0]){
+	if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){
 		var new_event_logo = document.createElement("IMG");
 		new_event_logo.title = "Criar evento a partir deste email";
