Index: /trunk/phpgwapi/inc/class.common.inc.php
===================================================================
--- /trunk/phpgwapi/inc/class.common.inc.php	(revision 62)
+++ /trunk/phpgwapi/inc/class.common.inc.php	(revision 63)
@@ -1459,12 +1459,9 @@
 			if (!$t || (int)$t <= 0)
 			{
-				$t."GMT";
 				$t = $GLOBALS['phpgw']->datetime->gmtnow;
 			}
-			else
-				$t."Não GMT";
 			//  + (date('I') == 1?3600:0)
 			$t += $GLOBALS['phpgw']->datetime->tz_offset;
-
+			
 			if (! $format)
 			{
@@ -1479,4 +1476,5 @@
 				}
 			}
+			
 			if((PHP_OS == 'Windows' || PHP_OS == 'WINNT') && (int)$t < 21600)
 			/*if(PHP_OS == 'Windows' && (int)$t < 21600)*/
Index: /trunk/expressoAdmin1_2/docs/change_log.txt
===================================================================
--- /trunk/expressoAdmin1_2/docs/change_log.txt	(revision 62)
+++ /trunk/expressoAdmin1_2/docs/change_log.txt	(revision 63)
@@ -87,2 +87,6 @@
 - Corrigido bug ao adicionar email em grupos
 - Corrigido bug ao adicionar atributos samba a um usuários já existente.
+
+14/08/2007
+- Criado aba Informações Corporativas, com os campo employeeNumber, cpf, rg, rgUf
+- Melhorado classe user.inc.php.
Index: /trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 63)
@@ -242,4 +242,5 @@
 				'display_spam_uid'				=> 'display:none',
 				'lang_general_information'		=> lang('General Information'),
+				'lang_corporative_information'	=> lang('Corporative Information'),
 				'lang_email_config'				=> lang('Email Config'),
 				'lang_groups_permission'		=> lang('Groups Permission'),
@@ -274,4 +275,11 @@
 				'ldap_context'					=> ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
 				
+				// Corporative Information
+				'display_corporative_information' => $this->functions->check_acl($manager_lid,'manipulate_corporative_information') ? '' : 'none',
+				'lang_employeenumber'			=> lang('Employee number'),
+				'lang_cpf'						=> lang('cpf'),
+				'lang_rg'						=> lang('rg'),
+				'lang_rguf'						=> lang('rguf'),
+				
 				//MAIL
 				'lang_activeemailaccount'		=> lang('Active email account'),
@@ -305,4 +313,5 @@
 				
 				//SAMBA ABA
+				'display_samba_suport'				=> $this->functions->check_acl($manager_lid,'edit_sambausers_attributes') ? '' : 'none',
 				'lang_samba_config'					=> lang('Samba Config'),
 				'lang_use_attrs_samba'				=> lang('Use samba attributes'),
@@ -536,4 +545,5 @@
 				'display_input_account_lid'		=> 'display:none',
 				'lang_general_information'		=> lang('General Information'),
+				'lang_corporative_information'	=> lang('Corporative Information'),
 				'lang_email_config'				=> lang('Email Config'),
 				'lang_groups_permission'		=> lang('Groups Permission'),
@@ -572,5 +582,16 @@
 				'phpgwaccountvisible_checked'	=> $user_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
 
-				//MAIL BORD
+				// Corporative Information
+				'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes') ? '' : 'none',
+				'lang_employeenumber'			=> lang('Employee number'),
+				'lang_cpf'						=> lang('cpf'),
+				'lang_rg'						=> lang('rg'),
+				'lang_rguf'						=> lang('rguf'),
+				'corporative_information_employeenumber' => $user_info['corporative_information_employeenumber'],
+				'corporative_information_cpf'			=> $user_info['corporative_information_cpf'],
+				'corporative_information_rg'			=> $user_info['corporative_information_rg'],
+				'corporative_information_rguf'			=> $user_info['corporative_information_rguf'],
+				
+				//MAIL
 				'disabled_quota_used'			=> 'disabled',
 				'lang_activeemailaccount'		=> lang('Active email account'),
Index: /trunk/expressoAdmin1_2/inc/class.user.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.user.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.user.inc.php	(revision 63)
@@ -117,32 +117,54 @@
 				if (($this->current_config['expressoAdmin_samba_support'] == 'true') && ($params['use_attrs_samba'] == 'on'))
 				{
-					//Verifica se o binario para criar as senhas do samba exite.
-					if (!is_file('/home/expressolivre/mkntpwd'))
-					{
-						$return['status'] = false;
-						$return['msg'] .= "O arquivo  binário /home/expressolivre/mkntpwd não exite.\\nEle é necessário para a criação das senhas usadas pelo SAMBA.\\nInforme o administrador ExpressoLivre sobre isto.";
-					}
-					else
-					{
-						$user_info['objectClass'][] 		= 'sambaSamAccount';
-						$user_info['loginShell']			= '/bin/bash';
-
-						$user_info['sambaSID']				= $params['sambadomain'] . '-' . ((2 * $id)+1000);
-						$user_info['sambaPrimaryGroupSID']	= $params['sambadomain'] . '-' . ((2 * $user_info['gidNumber'])+1001);
-
-						$user_info['sambaAcctFlags']		= $params['sambaacctflags'];
-			
-						$user_info['sambaLogonScript']		= $params['sambalogonscript'];
-						$user_info['homeDirectory']			= $params['sambahomedirectory'];
-			
-						$user_info['sambaLMPassword']		= exec('/home/expressolivre/mkntpwd -L '.$params['password1']);
-						$user_info['sambaNTPassword']		= exec('/home/expressolivre/mkntpwd -N '.$params['password1']);
-						$user_info['sambaPasswordHistory']	= '0000000000000000000000000000000000000000000000000000000000000000';
-			
-						$user_info['sambaPwdCanChange']		= strtotime("now");
-						$user_info['sambaPwdLastSet']		= strtotime("now");
-						$user_info['sambaPwdMustChange']	= '2147483647';
-					}
-				}
+					// Verifica o acesso do gerente aos atributos samba
+					if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_sambausers_attributes'))
+					{
+						//Verifica se o binario para criar as senhas do samba exite.
+						if (!is_file('/home/expressolivre/mkntpwd'))
+						{
+							$return['status'] = false;
+							$return['msg'] .= "O arquivo  binário /home/expressolivre/mkntpwd não exite.\\nEle é necessário para a criação das senhas usadas pelo SAMBA.\\nInforme o administrador ExpressoLivre sobre isto.";
+						}
+						else
+						{
+							$user_info['objectClass'][] 		= 'sambaSamAccount';
+							$user_info['loginShell']			= '/bin/bash';
+	
+							$user_info['sambaSID']				= $params['sambadomain'] . '-' . ((2 * $id)+1000);
+							$user_info['sambaPrimaryGroupSID']	= $params['sambadomain'] . '-' . ((2 * $user_info['gidNumber'])+1001);
+
+							$user_info['sambaAcctFlags']		= $params['sambaacctflags'];
+			
+							$user_info['sambaLogonScript']		= $params['sambalogonscript'];
+							$user_info['homeDirectory']			= $params['sambahomedirectory'];
+			
+							$user_info['sambaLMPassword']		= exec('/home/expressolivre/mkntpwd -L '.$params['password1']);
+							$user_info['sambaNTPassword']		= exec('/home/expressolivre/mkntpwd -N '.$params['password1']);
+							$user_info['sambaPasswordHistory']	= '0000000000000000000000000000000000000000000000000000000000000000';
+			
+							$user_info['sambaPwdCanChange']		= strtotime("now");
+							$user_info['sambaPwdLastSet']		= strtotime("now");
+							$user_info['sambaPwdMustChange']	= '2147483647';
+						}
+					}
+				}
+				
+				// Verifica o acesso do gerente aos atributos corporativos
+				if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information'))
+				{
+					foreach ($params as $atribute=>$value)
+					{
+						$pos = strrpos($atribute, 'corporative_information_');
+						if ($pos !== false)
+						{
+							if ($params[$atribute])
+							{
+								$ldap_atribute = str_replace("corporative_information_", "", $atribute);
+								$user_info[$ldap_atribute] = $params[$atribute];
+							}
+						}
+					}
+				}
+				
 				$result = $this->ldap_functions->ldap_add_entry($dn, $user_info);
 				if (!$result['status'])
@@ -239,7 +261,7 @@
 			$old_values = $this->get_user_info($new_values['uidnumber'], $new_values['manager_context']);
 			$dn = 'uid=' . $old_values['uid'] . ',' . strtolower($old_values['context']);
-			
+
 			$diff = array_diff($new_values, $old_values);
-			
+
 			$manager_account_lid = $_SESSION['phpgw_session']['session_lid'];
 			if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) &&
@@ -254,10 +276,4 @@
 
 			// Verifica o acesso do gerente
-			if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users'))
-			{
-				
-			}
-			
-			// Verifica o acesso do gerente
 			if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users'))
 			{
@@ -293,5 +309,5 @@
 					$ldap_mod_replace['sn'] = $new_values['sn'];
 					$ldap_mod_replace['cn'] = $new_values['givenname'] . ' ' . $new_values['sn'];
-					$this->db_functions->write_log("alterado sn do usuario",'',$dn,'','');
+					$this->db_functions->write_log("altera$ldap_mod_do sn do usuario",'',$dn,'','');
 				}
 				if ($diff['mail'])
@@ -349,5 +365,38 @@
 				}
 			}
-
+			
+			// REPLACE, ADD & REMOVE COPORATIVEs ATRIBUTES
+			// Verifica o acesso do gerente aos atributos corporativos
+			if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information'))
+			{
+				foreach ($new_values as $atribute=>$value)
+				{
+					$pos = strrpos($atribute, 'corporative_information_');
+					if ($pos !== false)
+					{
+						$ldap_atribute = str_replace("corporative_information_", "", $atribute);
+						// REPLACE ATTRS OF CORPORATIVE
+						if (($diff[$atribute]) && ($old_values[$atribute] != ''))
+						{
+							$ldap_atribute = str_replace("corporative_information_", "", $atribute);
+							$ldap_mod_replace[$ldap_atribute] = $new_values[$atribute];
+							$this->db_functions->write_log("alterado $ldap_atribute do usuario",'',$dn,'','');
+						}
+						//ADD ATTRS OF CORPORATIVE
+						elseif (($old_values[$atribute] == '') && ($new_values[$atribute] != ''))
+						{
+							$ldap_add[$ldap_atribute] = $new_values[$atribute];
+							$this->db_functions->write_log("adicionado $ldap_atribute ao usuario",'',$dn,'','');
+						}
+						//REMOVE ATTRS OF CORPORATIVE
+						elseif (($old_values[$atribute] != '') && ($new_values[$atribute] == ''))
+						{
+							$ldap_remove[$ldap_atribute] = array();
+							$this->db_functions->write_log("removido $ldap_atribute do usuario",'',$dn,'','');	
+						}
+					}
+				}
+			}
+			
 			//Suporte ao SAMBA
 			if ( ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users')) || 
@@ -512,5 +561,5 @@
 				}
 			}
-			
+
 			if ( ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users')) || 
 			     ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_sambausers_attributes')) )
@@ -640,5 +689,4 @@
 			if (count($ldap_remove))
 			{
-				
 				$result = $this->ldap_functions->remove_user_attributes($dn, $ldap_remove);
 				if (!$result['status'])
@@ -727,5 +775,4 @@
 			return $return;
 		}		
-		
 		
 		function get_user_info($uidnumber, $context)
@@ -1076,4 +1123,10 @@
 			}
 		}
+		
+		function write_log_from_ajax($params)
+		{
+			$this->db_functions->write_log($params['_action'],'',$params['userinfo'],'','');
+			return true;
+		}
 	}
 ?>
Index: /trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php	(revision 63)
@@ -30,4 +30,5 @@
 			'lid'						=> $_POST['manager_lid'],
 			'context'					=> $_POST['context'],
+			
 			'add_users'					=> $_POST['add_users'],
 			'edit_users'				=> $_POST['edit_users'],
@@ -35,4 +36,5 @@
 			'rename_users'				=> $_POST['rename_users'],
 			'view_users'				=> $_POST['view_users'],
+			'manipulate_corporative_information' => $_POST['manipulate_corporative_information'],
 			'add_groups'				=> $_POST['add_groups'],
 			'edit_groups'				=> $_POST['edit_groups'],
@@ -42,4 +44,5 @@
 			'change_users_quote'		=> $_POST['change_users_quote'],
 			'set_user_default_password'	=> $_POST['set_user_default_password'],
+			'empty_user_inbox'			=> $_POST['empty_user_inbox'],
 			'edit_sambausers_attributes'=> $_POST['edit_sambausers_attributes'],
 			'edit_sambadomains'			=> $_POST['edit_sambadomains'],
@@ -54,5 +57,6 @@
 			'create_computers'			=> $_POST['create_computers'],
 			'edit_computers'			=> $_POST['edit_computers'],
-			'delete_computers'			=> $_POST['delete_computers'],			
+			'delete_computers'			=> $_POST['delete_computers'],
+					
 			'apps'						=> $_POST['applications_list']
 			);
@@ -60,7 +64,7 @@
 			// Soma os niveis de acesso criando uma ACL
 			$acl = 0;
-			$acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'];
+			$acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'] + $manager['manipulate_corporative_information'];
 			$acl = $acl + $manager['add_groups'] + $manager['edit_groups'] + $manager['delete_groups'] + $manager['edit_email_groups'];
-			$acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'];
+			$acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'] + $manager['empty_user_inbox'];
 			$acl = $acl + $manager['edit_sambausers_attributes'] + $manager['edit_sambadomains'];
 			$acl = $acl + $manager['add_email_lists'] + $manager['edit_email_lists'] + $manager['delete_email_lists'];
@@ -102,4 +106,5 @@
 			'lid'						=> $_POST['manager_lid'],
 			'context'					=> $_POST['context'],
+			
 			'add_users'					=> $_POST['add_users'],
 			'edit_users'				=> $_POST['edit_users'],
@@ -107,4 +112,5 @@
 			'rename_users'				=> $_POST['rename_users'],
 			'view_users'				=> $_POST['view_users'],
+			'manipulate_corporative_information' => $_POST['manipulate_corporative_information'],
 			'add_groups'				=> $_POST['add_groups'],
 			'edit_groups'				=> $_POST['edit_groups'],
@@ -114,4 +120,5 @@
 			'change_users_quote'		=> $_POST['change_users_quote'],
 			'set_user_default_password'	=> $_POST['set_user_default_password'],
+			'empty_user_inbox'			=> $_POST['empty_user_inbox'],
 			'edit_sambausers_attributes'=> $_POST['edit_sambausers_attributes'],
 			'edit_sambadomains'			=> $_POST['edit_sambadomains'],
@@ -127,4 +134,5 @@
 			'edit_computers'			=> $_POST['edit_computers'],
 			'delete_computers'			=> $_POST['delete_computers'],
+			
 			'apps'						=> $_POST['applications_list']
 			);
@@ -132,7 +140,7 @@
 			// Soma os niveis de acesso criando uma ACL
 			$acl = 0;
-			$acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'];
+			$acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'] + $manager['manipulate_corporative_information'];
 			$acl = $acl + $manager['add_groups'] + $manager['edit_groups'] + $manager['delete_groups'] + $manager['edit_email_groups'];
-			$acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'];
+			$acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'] + $manager['empty_user_inbox'];
 			$acl = $acl + $manager['edit_sambausers_attributes'] + $manager['edit_sambadomains'];
 			$acl = $acl + $manager['add_email_lists'] + $manager['edit_email_lists'] + $manager['delete_email_lists'];
Index: /trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.imap_functions.inc.php	(revision 63)
@@ -1,6 +1,9 @@
 <?php
+
+include_once('class.functions.inc.php');
 
 class imap_functions
 {
+	var $functions;
 	var $imap;
 	var $imapDelimiter;
@@ -17,4 +20,5 @@
 		$this->imapDelimiter= $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'];
 		$this->imap 		= imap_open('{'.$this->imap_server.':'.$this->imap_port.'/novalidate-cert}', $this->imap_admin, $this->imap_passwd, OP_HALFOPEN);
+		$this->functions	= new functions;
 	}
 	
@@ -72,6 +76,6 @@
 		else
 		{
-			$quota['mailquota'] = ($get_quota['limit'] / 1024);
-			$quota['mailquota_used'] = ($get_quota['usage'] / 1024);
+			$quota['mailquota'] = round (($get_quota['limit'] / 1024), 2);
+			$quota['mailquota_used'] = round (($get_quota['usage'] / 1024), 2);
 		}
 			
@@ -116,3 +120,62 @@
 		return $result;
 	}
+	
+	function empty_inbox($params)
+	{
+		// Verifica o acesso do gerente
+		if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'empty_user_inbox'))
+		{
+			$result['status'] = false;
+			$result['msg'] = 'Você não tem acesso para executar esta operação.';
+			return $result;
+		}
+		
+		if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
+		{
+			$imap_options = '/tls/novalidate-cert';
+		}
+		else
+		{
+			$imap_options = '/notls/novalidate-cert';
+		}
+
+		
+		$result['status'] = true;
+		$uid = $params['uid'];
+		
+		$return_setacl = imap_setacl($this->imap, "user" . $this->imapDelimiter . $uid, $this->imap_admin, 'lrswipcda');
+		
+		if ($return_setacl)
+		{
+			//$mbox_stream = imap_open('{'.$this->imap_server.':'.$this->imap_port.$imap_options.'/user="'.$uid.'"}', $this->imap_admin, $this->imap_passwd);
+			$mbox_stream = imap_open('{'.$this->imap_server.':'.$this->imap_port.$imap_options .'}user'. $this->imapDelimiter . $uid, $this->imap_admin, $this->imap_passwd);
+			
+			$check = imap_mailboxmsginfo($mbox_stream);
+			$inbox_size = (string)(round ((($check->Size)/(1024*1024)), 2));
+			
+			$return_imap_delete = imap_delete($mbox_stream,'1:*');
+			imap_close($mbox_stream, CL_EXPUNGE);
+			
+			imap_setacl ($this->imap, "user" . $this->imapDelimiter . $uid, $this->imap_admin, '');
+			
+			if ($return_imap_delete)
+			{
+				$result['inbox_size'] = $inbox_size;
+				
+				$get_user_quota = @imap_get_quotaroot($this->imap,"user" . $this->imapDelimiter . $uid);
+				$result['mailquota_used'] = (string)(round(($get_user_quota['usage']/1024), 2));
+			}
+			else
+			{
+				$result['status'] = false;
+				$result['msg'] = "Nao foi possivel esvaziar a caixa postal do usuario:\n" . imap_last_error();
+			}
+		}
+		else
+		{
+			$result['status'] = false;
+			$result['msg'] = "Nao foi possivel modificar a acl do usuario:\n" . imap_last_error();
+		}
+		return $result;
+	}
 }
Index: /trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php	(revision 63)
@@ -207,4 +207,5 @@
 				'lang_rename_user'				=> lang('Rename users'),
 				'lang_view_user'				=> lang('View users'),
+				'lang_manipulate_corporative_information' => lang('Manipulate corporative information'),
 				'lang_add_groups'				=> lang('Add groups'),
 				'lang_edit_groups'				=> lang('Edit groups'),
@@ -214,4 +215,5 @@
 				'lang_change_users_quote'		=> lang('Change users quote'),
 				'lang_set_user_default_password'=> lang('Set default users password'),
+				'lang_empty_user_inbox'			=> lang('Empty user inbox'),
 				'lang_edit_sambausers_attributes'=> lang('Edit SAMBA users attributes'),
 				'lang_edit_sambadomains'		=> lang('Edit SAMBA domains'),
@@ -233,4 +235,6 @@
 				'add_users' 					=> $_POST['add_users'] != '' ? 'checked' : '',
 				'edit_users'					=> $_POST['edit_users'] != '' ? 'checked' : '',
+				'view_users' 					=> $_POST['view_users'] != '' ? 'checked' : '',
+				'manipulate_corporative_information' => $_POST['manipulate_corporative_information'] != '' ? 'checked' : '',
 				'delete_users' 					=> $_POST['delete_users'] != '' ? 'checked' : '',
 				'add_groups' 					=> $_POST['add_groups'] != '' ? 'checked' : '',
@@ -335,4 +339,5 @@
 				$_POST['rename_users'] 			= $acl['rename_users'];
 				$_POST['view_users'] 			= $acl['view_users'];
+				$_POST['manipulate_corporative_information'] = $acl['manipulate_corporative_information'];
 				$_POST['add_groups']			= $acl['add_groups'];
 				$_POST['edit_groups']			= $acl['edit_groups'];
@@ -342,4 +347,5 @@
 				$_POST['change_users_quote']	= $acl['change_users_quote'];
 				$_POST['set_user_default_password']	= $acl['set_user_default_password'];
+				$_POST['empty_user_inbox']		= $acl['empty_user_inbox'];
 				$_POST['edit_sambausers_attributes'] = $acl['edit_sambausers_attributes'];
 				$_POST['edit_sambadomains'] 	= $acl['edit_sambadomains'];
@@ -453,4 +459,5 @@
 				'lang_rename_user'				=> lang('Rename users'),
 				'lang_view_user'				=> lang('View users'),
+				'lang_manipulate_corporative_information' => lang('Manipulate corporative information'),
 				'lang_add_groups'				=> lang('Add groups'),
 				'lang_edit_groups'				=> lang('Edit groups'),
@@ -460,4 +467,5 @@
 				'lang_change_users_quote'		=> lang('Change users quote'),
 				'lang_set_user_default_password'=> lang('Set default user password'),
+				'lang_empty_user_inbox'			=> lang('Empty user inbox'),
 				'lang_edit_sambausers_attributes'=> lang('Edit SAMBA users attributes'),
 				'lang_edit_sambadomains'		=> lang('Edit SAMBA domains'),
@@ -483,4 +491,5 @@
 				'rename_users' 					=> $_POST['rename_users'] != '' ? 'checked' : '',
 				'view_users' 					=> $_POST['view_users'] != '' ? 'checked' : '',
+				'manipulate_corporative_information' => $_POST['manipulate_corporative_information'] != '' ? 'checked' : '',
 				'add_groups' 					=> $_POST['add_groups'] != '' ? 'checked' : '',
 				'edit_groups'					=> $_POST['edit_groups'] != '' ? 'checked' : '',
@@ -490,4 +499,5 @@
 				'change_users_quote'			=> $_POST['change_users_quote'] != '' ? 'checked' : '',
 				'set_user_default_password'		=> $_POST['set_user_default_password'] != '' ? 'checked' : '',
+				'empty_user_inbox'				=> $_POST['empty_user_inbox'] != '' ? 'checked' : '',
 				'edit_sambausers_attributes'	=> $_POST['edit_sambausers_attributes'] != '' ? 'checked' : '',
 				'edit_sambadomains'				=> $_POST['edit_sambadomains'] != '' ? 'checked' : '',
Index: /trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 63)
@@ -3,4 +3,5 @@
 define('PHPGW_API_INC','../phpgwapi/inc');	
 include_once(PHPGW_API_INC.'/class.common.inc.php');
+include_once('class.functions.inc.php');
 
 class ldap_functions
@@ -8,4 +9,5 @@
 	var $ldap;
 	var $current_config;
+	var $functions;
 	
 	function ldap_functions(){
@@ -14,8 +16,10 @@
 		$common = new common();
 		$this->ldap = $common->ldapConnect();
+		$this->functions = new functions;
 	}
 	
 	function validate_fields($params)
 	{
+		$result['status'] = true;
 		$params = unserialize($params['attributes']);
 		$type = $params['type'];
@@ -24,7 +28,5 @@
 		$mail = $params['mail'];
 		$mailalternateaddress = $params['mailalternateaddress'];
-
-		$result['status'] = true;
-		
+				
 		if ($_SESSION['phpgw_info']['expresso']['global_denied_users'][$uid])
 		{
@@ -657,4 +659,13 @@
 			array_pop($a_tmp);
 			$result['sambasid'] = implode("-", $a_tmp);
+		}
+
+		// Verifica o acesso do gerente aos atributos corporativos
+		if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information'))
+		{
+			$result['corporative_information_employeenumber']= $entry[0]['employeenumber'][0];
+			$result['corporative_information_cpf']			= $entry[0]['cpf'][0];
+			$result['corporative_information_rg']			= $entry[0]['rg'][0];
+			$result['corporative_information_rguf']			= $entry[0]['rguf'][0];
 		}
 		
Index: /trunk/expressoAdmin1_2/inc/class.functions.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 62)
+++ /trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 63)
@@ -66,4 +66,8 @@
 						return true;
 					break;
+				case manipulate_corporative_information:
+					if ($array_acl[manipulate_corporative_information])
+						return true;
+					break;
 				case change_users_password:
 					if ($array_acl[change_users_password])
@@ -76,4 +80,8 @@
 				case set_user_default_password:
 					if ($array_acl[set_user_default_password])
+						return true;
+					break;
+				case empty_user_inbox:
+					if (($array_acl[empty_user_inbox]) && ($array_acl[edit_users]))
 						return true;
 					break;
@@ -186,5 +194,5 @@
 		
 		// Make a array read humam
-		// Last acl:	33.554.432, 67.108.864
+		// Last acl:	33.554.432, 67.108.864, 134.217.728, 134.217.728, 268.435.456
 		function make_array_acl($acl)
 		{
@@ -194,4 +202,5 @@
 			$array_acl['rename_users'] = $acl & 8388608;
 			$array_acl['view_users'] = $acl & 33554432;
+			$array_acl['manipulate_corporative_information'] = $acl & 268435456;
 			$array_acl['add_groups'] = $acl & 16;
 			$array_acl['edit_groups'] = $acl & 32;
@@ -201,4 +210,5 @@
 			$array_acl['change_users_quote'] = $acl & 262144;
 			$array_acl['set_user_default_password'] = $acl & 524288;
+			$array_acl['empty_user_inbox'] = $acl & 134217728;
 			$array_acl['edit_sambausers_attributes'] = $acl & 32768;
 			$array_acl['edit_sambadomains'] = $acl & 16777216;
Index: /trunk/expressoAdmin1_2/js/jscode/users.js
===================================================================
--- /trunk/expressoAdmin1_2/js/jscode/users.js	(revision 62)
+++ /trunk/expressoAdmin1_2/js/jscode/users.js	(revision 63)
@@ -41,5 +41,37 @@
 		return;
 	}
-
+	
+	// Corporative Information
+	if (document.forms[0].corporative_information_employeenumber.value != "")
+	{
+		var re_employeenumber = /^([0-9])+$/;
+		
+		if(!re_employeenumber.test(document.forms[0].corporative_information_employeenumber.value))
+		{
+			alert('Campo matrícula contém caracteres não permitidos. Somente números são permitidos.');
+			document.forms[0].corporative_information_employeenumber.focus();
+			return;
+		}
+	}
+
+	if (document.forms[0].corporative_information_cpf.value != "")
+	{
+		var re_cpf = /^([0-9])+$/;
+
+		if(!re_cpf.test(document.forms[0].corporative_information_cpf.value))
+		{
+			alert('Campo cpf contém caracteres não permitidos. Somente números são permitidos');
+			document.forms[0].corporative_information_employeenumber.focus();
+			return;
+		}
+	
+		if (! validarCPF(document.forms[0].corporative_information_cpf.value) )
+		{
+			alert("Campo CPF invalido.");
+			document.forms[0].corporative_information_cpf.focus();
+			return;
+		}
+	}
+	
 	//MAIL
 	document.forms[0].mail.value = document.forms[0].mail.value.toLowerCase();
@@ -606,2 +638,51 @@
 	}
 }
+
+function empty_inbox(uid)
+{
+	var action = "Limpado INBOX do usuario";
+	var handler_write_log = function(){}
+	var handler_empty_inbox = function(data)
+	{
+		if (!data.status)
+			alert(data.msg);
+		else{
+			cExecute ('$this.user.write_log_from_ajax&_action='+action+'&userinfo='+uid, handler_write_log);
+			alert("Esvaziados '" + data.inbox_size + "' MB da caixa postal do usuário");
+			document.getElementById('mailquota_used').value = data.mailquota_used;
+		}
+	}
+	cExecute ('$this.imap_functions.empty_inbox&uid='+uid, handler_empty_inbox);
+}
+
+function validarCPF(cpf)
+{
+	if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
+		cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
+		cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
+		cpf == "88888888888" || cpf == "99999999999"){
+	  return false;
+   }
+
+	soma = 0;
+	for(i = 0; i < 9; i++)
+		soma += parseInt(cpf.charAt(i)) * (10 - i);
+	resto = 11 - (soma % 11);
+	if(resto == 10 || resto == 11)
+		resto = 0;
+	if(resto != parseInt(cpf.charAt(9)))
+	{
+		return false;
+	}
+	
+	soma = 0;
+	for(i = 0; i < 10; i ++)
+		soma += parseInt(cpf.charAt(i)) * (11 - i);
+	resto = 11 - (soma % 11);
+	if(resto == 10 || resto == 11)
+		resto = 0;
+	if(resto != parseInt(cpf.charAt(10))){
+		return false;
+	}
+	return true;
+}
Index: /trunk/expressoAdmin1_2/templates/default/accounts_form.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/accounts_form.tpl	(revision 62)
+++ /trunk/expressoAdmin1_2/templates/default/accounts_form.tpl	(revision 63)
@@ -2,5 +2,5 @@
 
 <script type="text/javascript">
-var tab = new Tabs(6,'activetab','inactivetab','tab','tabcontent','','','tabpage');
+var tab = new Tabs(7,'activetab','inactivetab','tab','tabcontent','','','tabpage');
 function initAll()
 {
@@ -28,9 +28,10 @@
 	<tr>
 		<th id="tab1" class="activetab" onclick="javascript:tab.display(1);"><a href="#" tabindex="0" accesskey="1" onfocus="tab.display(1);" onclick="tab.display(1); return(false);">{lang_general_information}</a></th>
-		<th id="tab2" class="activetab" onclick="javascript:tab.display(2);"><a href="#" tabindex="0" accesskey="2" onfocus="tab.display(2);" onclick="tab.display(2); return(false);">{lang_email_config}</a></th>
-		<th id="tab3" class="activetab" onclick="javascript:tab.display(3);"><a href="#" tabindex="0" accesskey="3" onfocus="tab.display(3);" onclick="tab.display(3); return(false);">{lang_groups_permission}</a></th>
-		<th id="tab4" class="activetab" onclick="javascript:tab.display(4);"><a href="#" tabindex="0" accesskey="4" onfocus="tab.display(4);" onclick="tab.display(4); return(false);">{lang_lists_permission}</a></th>
-		<th id="tab5" class="activetab" onclick="javascript:tab.display(5);"><a href="#" tabindex="0" accesskey="5" onfocus="tab.display(5);" onclick="tab.display(5); return(false);">{lang_aplication_permission}</a></th>
-		<th style="{display_samba_suport}" id="tab6" class="activetab" onclick="javascript:tab.display(6);"><a href="#" tabindex="0" accesskey="6" onfocus="tab.display(6);" onclick="tab.display(6); return(false);">{lang_samba_config}</a></th>
+		<th id="tab2" class="activetab" style="display:{display_corporative_information}"onclick="javascript:tab.display(2);"><a href="#" tabindex="0" accesskey="2" onfocus="tab.display(2);" onclick="tab.display(2); return(false);">{lang_corporative_information}</a></th>
+		<th id="tab3" class="activetab" onclick="javascript:tab.display(3);"><a href="#" tabindex="0" accesskey="3" onfocus="tab.display(3);" onclick="tab.display(3); return(false);">{lang_email_config}</a></th>
+		<th id="tab4" class="activetab" onclick="javascript:tab.display(4);"><a href="#" tabindex="0" accesskey="4" onfocus="tab.display(4);" onclick="tab.display(4); return(false);">{lang_groups_permission}</a></th>
+		<th id="tab5" class="activetab" onclick="javascript:tab.display(5);"><a href="#" tabindex="0" accesskey="5" onfocus="tab.display(5);" onclick="tab.display(5); return(false);">{lang_lists_permission}</a></th>
+		<th id="tab6" class="activetab" onclick="javascript:tab.display(6);"><a href="#" tabindex="0" accesskey="6" onfocus="tab.display(6);" onclick="tab.display(6); return(false);">{lang_aplication_permission}</a></th>
+		<th id="tab7" class="activetab" style="display:{display_samba_suport}" onclick="javascript:tab.display(7);"><a href="#" tabindex="0" accesskey="7" onfocus="tab.display(7);" onclick="tab.display(7); return(false);">{lang_samba_config}</a></th>
 	</tr>
 </table>
@@ -111,6 +112,28 @@
 </div>
 
+<!-- The code for Corporative Information -->
+<div id="tabcontent2" class="inactivetab">
+	<table width="60%" border="0" cellspacing="4" cellpading="0">
+		<tr bgcolor={row_on}>
+			<td>{lang_employeenumber}:</td>
+			<td><input type="text" name="corporative_information_employeenumber" autocomplete="off" value="{corporative_information_employeenumber}" size="30"></td>
+		</tr>
+		<tr bgcolor={row_off}>
+			<td>{lang_cpf}:</td>
+			<td><input type="text" name="corporative_information_cpf" autocomplete="off" value="{corporative_information_cpf}" size="30"></td>
+		</tr>
+		<tr bgcolor={row_on}>
+			<td>{lang_rg}:</td>
+			<td><input type="text" name="corporative_information_rg" autocomplete="off" value="{corporative_information_rg}" size="30"></td>
+		</tr>
+		<tr bgcolor={row_off}>
+			<td>{lang_rguf}:</td>
+			<td><input type="text" name="corporative_information_rguf" autocomplete="off" value="{corporative_information_rguf}" size="30"></td>
+		</tr>
+	</table>
+</div>
+
 <!-- The code for Email Config -->
-<div id="tabcontent2" class="inactivetab">
+<div id="tabcontent3" class="inactivetab">
 	<table width="60%" border="0" cellspacing="4" cellpading="0">
 		<tr bgcolor={row_off}>
@@ -146,12 +169,16 @@
 		<tr bgcolor={row_off}>
 			<td>{lang_email_quota_used}:</td>
-			<td><input type="text" name="mailquota_used" value="{mailquota_used}" disabled size=10></td>
-		</tr>
-				
+			<td><input type="text" name="mailquota_used" id="mailquota_used" value="{mailquota_used}" disabled size=10></td>
+		</tr>
+
+		<tr bgcolor={row_on}>
+			<td><input type='button' {disabled} {disabled_empty_inbox} value='Limpar INBOX do usuário' onclick="javascript:empty_inbox(uid.value);"></td>
+		</tr>
+
 	</table>
 </div>
 
 <!-- The code for Group -->
-<div id="tabcontent3" class="inactivetab">
+<div id="tabcontent4" class="inactivetab">
 	<table width="60%" border="0" cellspacing="4" cellpading="0">
 		<tr bgcolor={row_on}>
@@ -213,5 +240,5 @@
 
 <!-- The code for lists Email -->
-<div id="tabcontent4" class="inactivetab">
+<div id="tabcontent5" class="inactivetab">
 	<table width="60%" border="0" cellspacing="4" cellpading="0">
 		<tr bgcolor={row_on}>
@@ -265,5 +292,5 @@
 
 <!-- The code for Apps Tab -->
-<div id="tabcontent5" class="inactivetab">
+<div id="tabcontent6" class="inactivetab">
 	<table id="ea_table_apps" width="80%" border="0" cellspacing="2" cellpading="0">
 		{apps}
@@ -272,5 +299,6 @@
 
 <!-- The code for SAMBA -->
-<div id="tabcontent6" class="inactivetab" style="{display_samba_suport}">
+<!--<div id="tabcontent7" class="inactivetab" style="{display_samba_suport}">-->
+<div id="tabcontent7" class="inactivetab">
 	<table width="60%" border="0" cellspacing="4" cellpading="0">
 		<tr bgcolor={row_on}>
Index: /trunk/expressoAdmin1_2/templates/default/managers_form.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/managers_form.tpl	(revision 62)
+++ /trunk/expressoAdmin1_2/templates/default/managers_form.tpl	(revision 63)
@@ -76,4 +76,8 @@
 						</tr>
 						<tr bgcolor="{color_font1}" align='right'>
+							<td>{lang_manipulate_corporative_information}:</td>
+							<td><input type="checkbox" name="manipulate_corporative_information" value="268435456" {manipulate_corporative_information}></td>
+						</tr>
+						<tr bgcolor="{color_font1}" align='right'>
 							<td>{lang_view_user}:</td>
 							<td><input type="checkbox" name="view_users" value="33554432" {view_users}></td>
@@ -90,4 +94,8 @@
 							<td>{lang_set_user_default_password}:</td>
 							<td><input type="checkbox" name="set_user_default_password" value="524288" {set_user_default_password}></td>
+						</tr>
+						<tr bgcolor="{color_font1}" align='right'>
+							<td>{lang_empty_user_inbox}:</td>
+							<td><input type="checkbox" name="empty_user_inbox" value="134217728" {empty_user_inbox}></td>
 						</tr>
 						
Index: /trunk/instant_messenger/IMManager.php
===================================================================
--- /trunk/instant_messenger/IMManager.php	(revision 55)
+++ /trunk/instant_messenger/IMManager.php	(revision 63)
@@ -1,16 +1,5 @@
 #!/usr/bin/php -Cq
 <?php
-   //error_reporting(0);
-   //ini_set( 'track_errors', '1' );
-   ###
-   # This file is prepared for receive dependable connections but
-   # exists a BUG in the PHP related with the library OpenSSL that
-   # doesn't permit the enable crypto in connection created.
-   #
-   # See [Bug #40993 stream_socket_accept() : accept failed] in
-   # http://bugs.php.net/bug.php?id=40993&edit=1
-   #
-   #
-   ###
+
    require_once('inc/IMConfigure.php');
 
@@ -18,47 +7,15 @@
    # definitions of socket - BEGIN
    #
-      /***
-       * This file is prepared for receive dependable connections but
-       * exists a BUG in the PHP related with the library OpenSSL that
-       * doesn't permit the enable crypto in connection created.
-       *
-       * See [Bug #40993 stream_socket_accept() : accept failed] in
-       * http://bugs.php.net/bug.php?id=40993&edit=1
-       *
-       *
-       * It's necessary to remove all the comments made with '//'
-       * for safe connection
-       *
-       *
-       * WARNING - DANGER:
-       *
-       * Before remove all the comments made with '//' for safe
-       * connection, it's necessary to remove all the comments
-       * made with '//' in the file IMConfigure.php
-       * If this will not be made will happen many ERRORS
-       ***/
-
-      //define("CONTEXT", stream_context_create());
-
       define('URI', '0.0.0.0');
-
       define('TARGET_NON_SECURITY', TRANSPORT_NON_SECURITY . '://' . URI  . ':' . PORT_NON_SECURITY);
-      //define('TARGET_SECURITY', TRANSPORT_SECURITY . '://' . URI  . ':' . PORT_SECURITY);
-
-      //stream_context_set_option(CONTEXT, 'ssl', 'local_cert', './apache.pem'); # local_cert must be in PEM format
-      //stream_context_set_option(CONTEXT, 'ssl', 'allow_self_signed', true);
-      //stream_context_set_option(CONTEXT, 'ssl', 'verify_peer', false);
-
       define('SOCKET_NON_SECURITY', stream_socket_server(TARGET_NON_SECURITY, $errno_non_security, $errstr_non_security, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN));
-      //define('SOCKET_SECURITY', stream_socket_server(TARGET_SECURITY, $errno_security, $errstr_security, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, CONTEXT));
    #
    # definitions of socket - END
    ###
 
-   //if ( !SOCKET_NON_SECURITY || !SOCKET_SECURITY ) # It's necessary to remove the next line for safe connection
+
    if ( !SOCKET_NON_SECURITY )
    {
       printf("NON SECURITY:\n(%d) %s", $errno_non_security, $errstr_non_security);
-      //printf("SECURITY:\n(%d) %s", $errno_security, $errstr_security);
       exit(0);
    }
@@ -66,5 +23,4 @@
    include 'inc/Jabberd2.abstract.php';
 
-   //$master = array(SOCKET_NON_SECURITY, SOCKET_SECURITY); # It's necessary to remove the next line for safe connection
    $master = array(SOCKET_NON_SECURITY);
 
@@ -79,5 +35,5 @@
       $_e = NULL;
        
-      $mod_fd = @stream_select($read, $_w , $_e , READ_SOCKET_AFTER_OF);
+      $mod_fd = @stream_select($read, $_w , $_e , READ_SOCKET_AFTER_OF );
 
       if ( $mod_fd === FALSE )
@@ -85,16 +41,10 @@
 
       for ( $i = 0; $i < $mod_fd; ++$i )
+      {
          if ( $read[$i] === SOCKET_NON_SECURITY )
          {
             $conn_non_security = stream_socket_accept(SOCKET_NON_SECURITY);
-            # fwrite($conn_non_security, "Hello! The time is " . date("n/j/Y g:i:s a"));
             $master[] = &$conn_non_security;
          }
-         //else if ( $read[$i] === SOCKET_SECURITY )
-         //{
-         //   $conn_security = stream_socket_accept(SOCKET_SECURITY);
-         //   fwrite($conn_security, "Hello! The time is " . date("n/j/Y g:i:s a")."\n");
-         //   $master[] = &$conn_security;
-         //}
          else
          {
@@ -102,5 +52,4 @@
             if ( strlen($sock_data) === 0 )
             {
-               printf("Connection closed");
                $key_to_del = array_search($read[$i], $master, TRUE);
                fclose($read[$i]);
@@ -109,5 +58,4 @@
             else if ( $sock_data === FALSE )
             {
-               printf("Something bad happened");
                $key_to_del = array_search($read[$i], $master, TRUE);
                unset($master[$key_to_del]);
@@ -115,5 +63,4 @@
             else
             {
-               # printf("\n\n%s\n\n", $sock_data);
                $headers = (split("\n", $sock_data));
 
@@ -121,16 +68,17 @@
                preg_match('/^Host: \w*:(.+)/', $headers[1], $host);
 
-               //if ( (int)$host[1] == PORT_NON_SECURITY ) 
-                  $conn = &$conn_non_security;
-               //else
-               //   $conn = &$conn_security;
+               $conn = &$conn_non_security;
 
                $request = explode(';', $request[2]);
 
                if ( $request[0] == CONNECT && isset($request[1]) && !isset($users[$request[1]]) )
+               {
                   connect($users, $request[1]);
+               }
 
                if ( $request[0] == CLOSE && isset($request[1]) && isset($users[$request[1]]) )
-                  close($request[1]);
+               {   
+               	close($request[1]);
+               }
 
                fclose($read[$i]);
@@ -138,30 +86,39 @@
             }
          }
-
+      }	
+      
       foreach ( $users as $key => $val )
       {
-         if ( (time() - $users[$key]['time'] > DISCONNECT_AFTERWARDS_OF) )
-            if ( $users[$key]['attempt'] > 2 )
-            {
-               $users[$key]['attempt'] = 0;
-               close($key);
-            }
-            else
-            {
-               $users[$key]['attempt']++;
-               readSocket($users, $key);
-            }
+         if($users[$key]['time0'] != $users[$key]['time1']  )
+         {
+         	$users[$key]['time1'] = $users[$key]['time0'];
+         	$users[$key]['attempt'] = 0;
+         	readSocket($key);
+         	//readSocket($users, $key);
+         }
          else
          {
-            $users[$key]['attempt'] = 0;
-            readSocket($users, $key);
-         }
+				$users[$key]['attempt']++;
+				if( $users[$key]['attempt'] > 5 )
+				{
+     				$users[$key]['jabber']->disconnect();
+     				unset($users[$key]);     				
+				}
+				else
+				{
+					readSocket($key);
+					//readSocket($users, $key);
+				}         	
+         }
+
+         //print_r("Session : " . $key . " | Count : " . count($users) . " | time 0 : " . $users[$key]['time0'] . " | time 1 : " . $users[$key]['time1'] . " | tentativas : " . $users[$key]['attempt'] . " \n");
       }
 
-      //print_r($users);
-   }
-
+   }
+	
+	
    exit(0);
 
+	
    function connect(&$pUsers, $pSession)
    {
@@ -203,5 +160,6 @@
                   $pUsers[$pSession] = array();
                   $pUsers[$pSession]['jabber'] = $a;
-                  $pUsers[$pSession]['time'] = $_time;
+                  $pUsers[$pSession]['time0'] = $_time;
+						$pUsers[$pSession]['time1'] = 0;                  
                   $pUsers[$pSession]['attempt'] = 0;
                }
@@ -224,6 +182,8 @@
    }
 
-   function readSocket(&$pUsers, $pSession)
-   {
+   //function readSocket(&$pUsers, $pSession)
+   function readSocket($pSession)
+   {
+      global $users;
       global $send;
       $sessionpath = explode(';', session_save_path());
@@ -244,6 +204,6 @@
             if ( $is_user )
             {
-               $pUsers[$pSession]['time'] = $_SESSION['phpgw_info']['instant_messenger']['time'];
-					$readSocket = @$pUsers[$pSession]['jabber']->readSocket();
+               $users[$pSession]['time0'] = $_SESSION['phpgw_info']['instant_messenger']['time'];
+					$readSocket = $users[$pSession]['jabber']->readSocket();
                
                if ( $readSocket !== false )
@@ -261,5 +221,5 @@
 									if ( !is_null($value) )
 									{
-										$pUsers[$pSession]['jabber']->writeSocket($value);
+										$users[$pSession]['jabber']->writeSocket($value);
 										$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] = NULL;
 									}
@@ -271,5 +231,5 @@
 										foreach ( $value as $key => $val )
 										{
-											$pUsers[$pSession]['jabber']->getVcard($val);
+											$users[$pSession]['jabber']->getVcard($val);
 											unset($_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][$key]);
 										}
@@ -278,9 +238,9 @@
 								else
 								{
-									if ( method_exists($pUsers[$pSession]['jabber'], $action) )
+									if ( method_exists($users[$pSession]['jabber'], $action) )
 										if ( $value )
-											$pUsers[$pSession]['jabber']->$action($value);
+											$users[$pSession]['jabber']->$action($value);
 										else
-											$pUsers[$pSession]['jabber']->$action();
+											$users[$pSession]['jabber']->$action();
 									unset($_SESSION['phpgw_info']['instant_messenger']['socket']['out'][$action]);
 								}
Index: /trunk/instant_messenger/xsl/window.xsl
===================================================================
--- /trunk/instant_messenger/xsl/window.xsl	(revision 60)
+++ /trunk/instant_messenger/xsl/window.xsl	(revision 63)
@@ -19,5 +19,5 @@
       <div class="im-windowfantom-des" id="{@id}_im_window_fantom" />
       <div class="im-windowfantom-des" id="{@id}_im_window_movable" />
-      <div class="im-window-resizehandle" id="{@id}_im_window_resize" />
+      <div class="im-window-resizehandle" id="{@id}_im_window_resize" style="visibility:hidden;" />
    </body>
    </html>
Index: /trunk/instant_messenger/docs/change_log.txt
===================================================================
--- /trunk/instant_messenger/docs/change_log.txt	(revision 60)
+++ /trunk/instant_messenger/docs/change_log.txt	(revision 63)
@@ -19,2 +19,5 @@
 - Corrigido a mudança de status automática
 - Layout do adicionar contato não gera mais scrolls
+
+23/08/2007
+- Arrumado o tipo de cursor no IE na mudança de Status
Index: /trunk/instant_messenger/inc/Socket.abstract.php
===================================================================
--- /trunk/instant_messenger/inc/Socket.abstract.php	(revision 55)
+++ /trunk/instant_messenger/inc/Socket.abstract.php	(revision 63)
@@ -18,6 +18,4 @@
 abstract class Socket
 {
-	private $log_file = false;
-	
 	protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 )
 	{
@@ -54,12 +52,4 @@
       set_magic_quotes_runtime(get_magic_quotes_gpc());
 
-		if( $this->log_file )
-		{
-			if ( !empty($return) && $fp = fopen ('read.log', "a+") )
-	      {
-	         fwrite($fp, $return . "\n");
-	         fclose($fp);
-	      }
-		}
 
       if ( $php_errormsg )
@@ -77,14 +67,5 @@
          return false;
 
-		if( $this->log_file)
-		{
-			if ( $fp = fopen ('write.log', "a+") )
-	      {
-	         fwrite($fp, $pData . "\n");
-	         fclose($fp);
-	      }
-		}
-
-		$return = @fwrite($pSocket, $pData);
+	  $return = @fwrite($pSocket, $pData);
       
       if ( $php_errormsg )
Index: /trunk/instant_messenger/inc/im_acl.inc.php
===================================================================
--- /trunk/instant_messenger/inc/im_acl.inc.php	(revision 59)
+++ /trunk/instant_messenger/inc/im_acl.inc.php	(revision 63)
@@ -92,22 +92,6 @@
           */
           
-         }else{
-				$user = "niltonneto";
-				
-				if(trim($_SESSION['phpgw_info']['instant_messenger']['user']) == $user)
-				{
-					ini_set ( "session.save_path", "/php_sessions/"); 
-					$path = ini_get("session.save_path");
-					
-					$log = date('m/d/Y H:i:s'). " - Erro na conexao com: ". $SERVER . " - Erros : " . $errstr . " : " . $errno. "\n"; 
-				  
-				  	$ff = fopen ($path."conexao_jabber.log", "a+");
-				  	if ( $ff )
-				  	{ 
-					 	fwrite($ff, $log);
-					 	fclose($ff);
-				  	}
-				}
          }
+         
          break;
       }
Index: /trunk/instant_messenger/inc/class.Ujabber.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.Ujabber.inc.php	(revision 57)
+++ /trunk/instant_messenger/inc/class.Ujabber.inc.php	(revision 63)
@@ -11,6 +11,5 @@
       $return = null;
 
-      $_SESSION['phpgw_info']['instant_messenger']['time'] = time();
-
+		$_SESSION['phpgw_info']['instant_messenger']['time'] = time();
       $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = true;
       $xml = $_SESSION['phpgw_info']['instant_messenger']['socket']['in'];
Index: /trunk/instant_messenger/inc/IMConfigure.php
===================================================================
--- /trunk/instant_messenger/inc/IMConfigure.php	(revision 55)
+++ /trunk/instant_messenger/inc/IMConfigure.php	(revision 63)
@@ -15,5 +15,5 @@
    #
       define('DISCONNECT_AFTERWARDS_OF', 20);
-      define('READ_SOCKET_AFTER_OF', 1);
+      define('READ_SOCKET_AFTER_OF', 2);
    #
    # definitions of time - END
Index: /trunk/instant_messenger/js/im_functions.js
===================================================================
--- /trunk/instant_messenger/js/im_functions.js	(revision 57)
+++ /trunk/instant_messenger/js/im_functions.js	(revision 63)
@@ -749,23 +749,32 @@
 		
 		 func.confEl(option1_image, 'src', img_available.src);
-		 func.confEl(option1_image, 'style', 'width:16px;height:16px;');
+		 func.confEl(option1_image, 'style', 'width:16px;height:16px;cursor:pointer;');
 		 func.confEl(option2_image, 'src', img_xa.src);
-		 func.confEl(option2_image, 'style', 'width:16px;height:16px;');
+		 func.confEl(option2_image, 'style', 'width:16px;height:16px;cursor:pointer;');
 		 func.confEl(option3_image, 'src', img_dnd.src);
-		 func.confEl(option3_image, 'style', 'width:16px;height:16px;');
+		 func.confEl(option3_image, 'style', 'width:16px;height:16px;cursor:pointer;');
 		 func.confEl(option4_image, 'src', img_unavailable.src);
-		 func.confEl(option4_image, 'style', 'width:16px;height:16px;');
+		 func.confEl(option4_image, 'style', 'width:16px;height:16px;cursor:pointer;');
 		 func.confEl(option5_image, 'src', img_edit.src);
-		 func.confEl(option5_image, 'style', 'width:16px;height:16px;');
+		 func.confEl(option5_image, 'style', 'width:16px;height:16px;cursor:pointer;');
 		
 		 func.insEl(option1_image, IM.get_lang('online'), option1_link);
+		 func.confEl(option1_link, 'style','cursor:pointer;');
 		 func.insEl(option1_link, option1);
+
 		 func.insEl(option2_image, IM.get_lang('away'), option2_link);
+		 func.confEl(option2_link, 'style','cursor:pointer;');
 		 func.insEl(option2_link, option2);
+
 		 func.insEl(option3_image, IM.get_lang('busy'), option3_link);
+		 func.confEl(option3_link, 'style','cursor:pointer;');
 		 func.insEl(option3_link, option3);
+
 		 func.insEl(option4_image, IM.get_lang('offline'), option4_link);
+		 func.confEl(option4_link, 'style','cursor:pointer;');
 		 func.insEl(option4_link, option4);
+
 		 func.insEl(option5_image, IM.get_lang('Custom message...'), option5_link);
+		 func.confEl(option5_link, 'style','cursor:pointer;');
 		 func.insEl(option5_link, option5);
 		
Index: /trunk/instant_messenger/js/im_win.js
===================================================================
--- /trunk/instant_messenger/js/im_win.js	(revision 60)
+++ /trunk/instant_messenger/js/im_win.js	(revision 63)
@@ -102,12 +102,12 @@
 			params['body']       = main_menu_all;
 			params['close']      = true;
-			params['height']     = 260;
+			params['height']     = 270;
 			params['left']       = 10;
 			params['id']         = pId;
 			params['maximize']   = true;
 			params['style']      = 'visibility:hidden';
-			params['title']      = ".: " + IM.get_lang("instant_messenger") + " :.";
+			params['title']      = 'Expresso Messenger';
 			params['top']        = 10;
-			params['width']      = 200;
+			params['width']      = 210;
 			this.build(params);
 
Index: /trunk/instant_messenger/templates/default/css.css
===================================================================
--- /trunk/instant_messenger/templates/default/css.css	(revision 55)
+++ /trunk/instant_messenger/templates/default/css.css	(revision 63)
@@ -72,6 +72,6 @@
 .im-window-resizehandle
 {
-	position: absolute;
-	overflow: hidden;
+	position: relative;
+	overflow: auto;
 	width: 15px;
 	height: 15px;
Index: /trunk/instant_messenger/templates/default/index.tpl
===================================================================
--- /trunk/instant_messenger/templates/default/index.tpl	(revision 60)
+++ /trunk/instant_messenger/templates/default/index.tpl	(revision 63)
@@ -53,5 +53,5 @@
     <br>
 
-	Para acessar o menu "Opções" ( conforme figura 2 ), basta dar um clique com o mouse e abrirá uma menu com as opções de Adicionar Contato ( <b>veja <a href="#useradd">Adicionando um novo contato</a></b> ), Remover Contato ( <b>veja <a href="#userdel">Removendo um contato</a></b> ), 
+	Para acessar o menu "Opções" ( conforme figura 2 ), basta dar um clique com o mouse e abrirá um menu com as opções de Adicionar Contato ( <b>veja <a href="#useradd">Adicionando um novo contato</a></b> ), Remover Contato ( <b>veja <a href="#userdel">Removendo um contato</a></b> ), 
 	Informações Adicionais ( <b>veja <a href="#info_ad">Informações Adicionais</a></b> ) e Preferências ( <b>veja <a href="#info_prefe">Preferências</a></b> ).
     
@@ -114,6 +114,14 @@
 	também possui esta opção ( <b>veja <a href="#menu_right">Preferências Avançadas</a></b>, opção Ver Info).
 
+    <h2><a name="info_prefe">6. Preferências</a></h2>
+	( figura 5 )
+    <img src="templates/default/images/preferencias.png" width="356" height="270" alt="Preferências" align="left">
+    <br clear="all">
+    <br>
+
+	Personalize seu tempo para ficar ausente, se em sua lista de contato aparecerá seus contatos offline e um tipo de aviso para uma nova mensagem. 
+
     <h2><a name="troca_mens">7. Troca de Mensagens</a></h2>
-	( figura 5 )
+	( figura 6 )
     <img src="templates/default/images/troca_mensagem.png" width="332" height="272" alt="Troca de Mensagens" align="left">
     <br clear="all">
@@ -124,5 +132,5 @@
 
     <h2><a name="troca_status">8. Troca de Status</a></h2>
-	( figura 6 )
+	( figura 7 )
     <img src="templates/default/images/troca_status.png" width="449" height="313" alt="Troca de Status" align="left">
     <br clear="all">
Index: /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 53)
+++ /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 63)
@@ -657,5 +657,5 @@
 		$tag_list = Array('head','blink','object','frame',
 			'iframe','layer','ilayer','plaintext','script',
-			'applet','embed','frameset','xml','xmp');
+			'applet','embed','frameset','xml','xmp','style');
 
 		$body = $this-> replace_links($body);
@@ -1051,4 +1051,5 @@
 		$attachments = $params['FILES'];
 		$forwarding_attachments = $params['forwarding_attachments'];
+		 
 		$folder =$params['folder'];
 		$folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");		
@@ -1142,8 +1143,10 @@
 			foreach($forwarding_attachments as $forwarding_attachment)
 			{
-				$tmp_forwarding_attachment = str_replace("'", "", $forwarding_attachment);
-				$file_description = explode(",", $tmp_forwarding_attachment);
+				$file_description = unserialize(rawurldecode($forwarding_attachment));
+				foreach($file_description as $i => $descriptor){				
+					$file_description[$i]  = eregi_replace('\'*\'','',$descriptor);
+				}
 				$fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]);
-				$fileName = rawurldecode($file_description[2]);
+				$fileName = $file_description[2];
 				if(!array_search(trim($fileName),$name_cid_files)) {
 					$mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2]));
Index: /trunk/expressoMail1_2/inc/gotodownload.php
===================================================================
--- /trunk/expressoMail1_2/inc/gotodownload.php	(revision 27)
+++ /trunk/expressoMail1_2/inc/gotodownload.php	(revision 63)
@@ -32,7 +32,9 @@
 		$filename = $idx_file;
 			
+   	$filename 	 = $filename 	? $filename 	: "attachment.bin";
+   	$newfilename = $newfilename ? $newfilename 	: $filename;
    	$strFileType = strrev(substr(strrev(strtolower($filename)),0,4));
-	  	
-   	downloadFile($strFileType, $filename, $newfilename ? $newfilename : $filename, $fileContent, $encoding);
+	
+   	downloadFile($strFileType, $filename, $newfilename, $fileContent, $encoding);
    
    function downloadFile($strFileType, $strFileName, $newFileName, $fileContent, $encoding) {
Index: /trunk/expressoMail1_2/js/InfoContact.js
===================================================================
--- /trunk/expressoMail1_2/js/InfoContact.js	(revision 54)
+++ /trunk/expressoMail1_2/js/InfoContact.js	(revision 63)
@@ -1,3 +1,3 @@
-function emInfoContact()
+ function emInfoContact()
 {
 	this.email = "";
@@ -139,5 +139,5 @@
 
 	var status = IM.infoContact(uid);
-	var _return = '<br/><br/>';
+	var _return = '<br/>';
 
 	if ( status )
Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 61)
+++ /trunk/expressoMail1_2/js/main.js	(revision 63)
@@ -240,5 +240,15 @@
 
 function new_message(type, border_ID){
-	var new_border_ID = draw_new_message();
+	var new_border_ID = draw_new_message();	
+	// Salva a pasta da mensagem respondida ou encaminhada:
+	var folder_message = Element("input_folder_"+border_ID);
+	if(folder_message) {
+		var input_current_folder = document.createElement('input');	
+		input_current_folder.id = "new_input_folder_"+border_ID;
+		input_current_folder.name = "input_folder";
+		input_current_folder.type = "hidden";
+		input_current_folder.value = folder_message.value;
+		Element("content_id_" + new_border_ID).appendChild(input_current_folder);
+	}//Fim.
 	var title = '';
 	data = [];
@@ -393,5 +403,6 @@
 					tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("("));
 					a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'";
-					divFiles.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+a_tmp.join(',')+"\"/>";
+					s_tmp = escape(connector.serialize(a_tmp));
+					divFiles.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+s_tmp+"\"/>";
 					divFiles.appendChild(link_attachment);
 				}
@@ -585,21 +596,23 @@
 
 		for (var i=0; i<msgs_to_set.length; i++){
-			switch(data.flag){
-				case "unseen":
-					set_msg_class_to_unread(msgs_to_set[i]);
-					Element("check_box_message_" + msgs_to_set[i]).checked = false;
-					break;
-				case "seen":
-					set_msg_class_to_read(msgs_to_set[i], false);
-					Element("check_box_message_" + msgs_to_set[i]).checked = false;
-					break;
-				case "flagged":
-					set_msg_class_to_flagged(msgs_to_set[i]);
-					document.getElementById("check_box_message_" + msgs_to_set[i]).checked = false;
-					break;
-				case "unflagged":
-					set_msg_class_to_unflagged(msgs_to_set[i]);
-					Element("check_box_message_" + msgs_to_set[i]).checked = false;
-					break;
+			if(Element("check_box_message_" + msgs_to_set[i])){
+				switch(data.flag){
+					case "unseen":
+						set_msg_class_to_unread(msgs_to_set[i]);
+						Element("check_box_message_" + msgs_to_set[i]).checked = false;
+						break;
+					case "seen":
+						set_msg_class_to_read(msgs_to_set[i], false);
+						Element("check_box_message_" + msgs_to_set[i]).checked = false;
+						break;
+					case "flagged":
+						set_msg_class_to_flagged(msgs_to_set[i]);
+						document.getElementById("check_box_message_" + msgs_to_set[i]).checked = false;
+						break;
+					case "unflagged":
+						set_msg_class_to_unflagged(msgs_to_set[i]);
+						Element("check_box_message_" + msgs_to_set[i]).checked = false;
+						break;
+				}
 			}
 		}
@@ -607,9 +620,12 @@
 	}
 	
+	var folder = get_current_folder();
 	if (msgs_to_set == 'get_selected_messages')
 		var msgs_to_set = this.get_selected_messages();
+	else
+		folder = Element("input_folder_"+msgs_to_set+"_r").value;
 	
 	if (msgs_to_set)
-		cExecute ("$this.imap_functions.set_messages_flag&folder="+get_current_folder()+"&msgs_to_set="+msgs_to_set+"&flag="+flag, handler_set_messages_flag);
+		cExecute ("$this.imap_functions.set_messages_flag&folder="+folder+"&msgs_to_set="+msgs_to_set+"&flag="+flag, handler_set_messages_flag);
 	else
 		write_msg(get_lang('No selected message.'));		
@@ -618,8 +634,9 @@
 // By message number
 function set_message_flag(msg_number, flag){
+	var msg_number_folder = Element("new_input_folder_"+msg_number+"_r");
 	var handler_set_messages_flag = function (data){
 		if(!verify_session(data))
 			return;
-		if (data.status) {
+		if (data.status && Element("td_message_answered_"+msg_number)) {	
 			if(flag == 'answered')
 				Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/default/images/answered.gif title=Respondida>';
@@ -628,5 +645,5 @@
 		}
 	}
-	cExecute ("$this.imap_functions.set_messages_flag&folder="+get_current_folder()+"&msgs_to_set="+msg_number+"&flag="+flag, handler_set_messages_flag);
+	cExecute ("$this.imap_functions.set_messages_flag&folder="+( msg_number_folder ?  msg_number_folder.value : get_current_folder() )+"&msgs_to_set="+msg_number+"&flag="+flag, handler_set_messages_flag);
 }
 
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 61)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 63)
@@ -934,6 +934,14 @@
 	to_values.id = "to_values_"+ID;
 	to_values.type = "HIDDEN";
-	to_values.value = info_msg.toaddress2; //Veio do IMAP, sem images nem links.
-	
+	to_values.value = info_msg.toaddress2; //Veio do IMAP, sem images nem links.	
+
+	// Salva a pasta da mensagem
+	var input_current_folder = document.createElement('input');	
+	input_current_folder.id = "input_folder_"+ID;
+	input_current_folder.name = "input_folder";
+	input_current_folder.type = "hidden";
+	input_current_folder.value = info_msg.msg_folder;
+	td2.appendChild(input_current_folder);	
+	// fim
 	toaddress_array[ID] = info_msg.toaddress2.split(",");
 	if (toaddress_array[ID].length > 1){
@@ -1220,5 +1228,5 @@
 	td_from.setAttribute("noWrap","true");
 	td_from.style.width = "100%";
-	
+			
 	var sel_from = document.createElement('SELECT');	
 	sel_from.id = "from_"+ID;
@@ -1530,5 +1538,5 @@
 	input_return_receipt.name = "input_return_receipt";
 	input_return_receipt.setAttribute("tabIndex","-1");
-	td_return_receipt.appendChild(input_return_receipt);
+	td_return_receipt.appendChild(input_return_receipt);	
 	tr5.appendChild(td5);
 	tr5.appendChild(td_return_receipt);
Index: /trunk/expressoMail1_2/js/TreeShow.js
===================================================================
--- /trunk/expressoMail1_2/js/TreeShow.js	(revision 53)
+++ /trunk/expressoMail1_2/js/TreeShow.js	(revision 63)
@@ -58,7 +58,9 @@
 	Tree_Box.prototype.verify = function(exp)
  	{
- 		//var reTipo = /^[A-Z-a-z-0-9-_]+$/;
-		//if(reTipo.test(exp)){return true;}
-		//else{return false;}
+		var reTipo = /^(.*)(\/)(.*)$/;
+		
+		if(reTipo.test(exp)){
+			return false;
+		}
 		return true;
  	}
