Index: /trunk/expressoMail1_2/index.php
===================================================================
--- /trunk/expressoMail1_2/index.php	(revision 5804)
+++ /trunk/expressoMail1_2/index.php	(revision 5821)
@@ -217,4 +217,10 @@
 
 	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['quick_search_default'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['quick_search_default'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['quick_search_default'] : 1;
+	// 	ACL for block edit Personal Data.
+	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_quickadd_telephonenumber'] = $current_config['expressoMail_enable_quickadd_telephonenumber'] == 'true' ? $current_config['expressoMail_enable_quickadd_telephonenumber'] : "";
+	if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['enable_quickadd_telephonenumber']){
+		$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['blockpersonaldata'] = $GLOBALS['phpgw']->acl->check('blockpersonaldata',1,'preferences');		
+	}
+
         $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['auto_close_first_tab'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_close_first_tab'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_close_first_tab'] : "0";
 	
Index: /trunk/expressoMail1_2/templates/default/config.tpl
===================================================================
--- /trunk/expressoMail1_2/templates/default/config.tpl	(revision 5804)
+++ /trunk/expressoMail1_2/templates/default/config.tpl	(revision 5821)
@@ -212,4 +212,34 @@
     </tr>
 
+<tr bgcolor="{th_bg}"> 
+    <td colspan="2"> 
+        &nbsp; 
+    </td> 
+  </tr>
+      
+  <tr bgcolor="{row_on}"> 
+    <td colspan="2"> 
+        <label style="font-weight:bold;">{lang_Quick_add_widget_for_telephone_number}</label> 
+    </td> 
+  </tr>
+  
+    <tr bgcolor="{row_off}">
+        <td>{lang_Enable_quick_add_for_user}</td>
+        <td>
+            <select id="use_quickadd" name="newsettings[expressoMail_enable_quickadd_telephonenumber]">
+                <option value="false" {selected_expressoMail_enable_quickadd_telephonenumber_false}>{lang_No}</option>
+                <option value="true" {selected_expressoMail_enable_quickadd_telephonenumber_true}>{lang_Yes}</option>
+            </select>
+        </td>
+    </tr>
+    <tr bgcolor="{row_on}">
+        <td>{lang_Days_interval_to_show_balloon_for_user}</td>
+        <td>
+            <input size="5" name="newsettings[expressoMail_quickadd_days_expire_balloon]" value="{value_expressoMail_quickadd_days_expire_balloon}">
+            <span>{lang_day(s)}</span>
+            <input type="hidden" name="valida_alert_days_expire_balloon" value="{lang_The field should only contain numbers}" /> 
+        </td>
+    </tr>    
+
 <!-- END body -->
 <!-- BEGIN footer -->
Index: /trunk/expressoMail1_2/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/expressoMail1_2/setup/phpgw_pt-br.lang	(revision 5809)
+++ /trunk/expressoMail1_2/setup/phpgw_pt-br.lang	(revision 5821)
@@ -683,4 +683,12 @@
 Send this mail as text plain	expressoMail1_2	pt-br	Enviar este e-mail como texto simples
 The text format will be lost	expressoMail1_2	pt-br	A formatação do texto será perdida
+The format of telephone number is invalid	expressoMail1_2	pt-br	O formato do número de telefone é inválido
+Telephone number updated with success.	expressoMail1_2	pt-br	Telefone atualizado com sucesso.
+Click here to update your telephone	expressoMail1_2	pt-br	Clique aqui para atualizar seu telefone
+Update my telephone	expressoMail1_2	pt-br	Atualizar meu telefone
+You can't modify your Commercial Telephone.	expressoMail1_2	pt-br	Você não tem permissão para modificar seu Telefone Comercial.
+Warning for users	expressoMail1_2	pt-br	Aviso importante aos usuários
+text_Warning	expressoMail1_2	pt-br	Caro usuário, <br>Mantenha seu Telefone Comercial sempre atualizado no Expresso. Muitas pessoas consultam o Catálogo do Expresso como se fosse uma lista telefônica.
+Close this warning	expressoMail1_2	pt-br	Fechar este aviso
 Warning	expressoMail1_2	pt-br	Atenção
 Discard	expressoMail1_2	pt-br	Descartar
Index: /trunk/expressoMail1_2/inc/class.db_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 5819)
+++ /trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 5821)
@@ -682,4 +682,13 @@
         }
 
+		function write_log($action, $about)
+		{
+			$sql = "INSERT INTO phpgw_expressoadmin_log (date, manager, action, userinfo) "
+				. "VALUES('now','" . $_SESSION['phpgw_info']['expressomail']['user']['account_lid'] . "','" . strtolower($action) . "','" . strtolower($about) . "')";
+			if (!$this->db->query($sql)) {
+        		return false;
+        	}
+        return true;
+       }
 }
 ?>
Index: /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 5513)
+++ /trunk/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 5821)
@@ -87,9 +87,18 @@
 		$this->ldap_host 	= $_SESSION['phpgw_info']['expressomail']['server']['ldap_host'];
 		$this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'];
-		$this->ds 			= ldap_connect($this->ldap_host);
-		ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer);
-		ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']);
-
+
+		if($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host'] &&
+			$_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn'] &&
+			$_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']) {
+			$this->ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_master_host']);
+			ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+			ldap_set_option($this->ds, LDAP_OPT_REFERRALS,0);
+			ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_dn'], $_SESSION['phpgw_info']['expressomail']['server']['ldap_master_root_pw']);
+		}else{
+			$this->ds = ldap_connect($this->ldap_host);
+			ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+			ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer);
+			ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']);
+		}
 	}
 
@@ -1156,4 +1165,38 @@
             return $return;
         }
+
+        function save_telephoneNumber($params){
+        	$return = array();
+        	if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['blockpersonaldata']){
+        		$return['error'] = $this->functions->getLang("You can't modify your Commercial Telephone.");
+        		return $return;
+        	}
+        	$old_telephone = 0;
+        	$pattern = '/\([0-9]{2,3}\)[0-9]{4}-[0-9]{4}$/';
+        	if ((strlen($params['number']) != 0) && (!preg_match($pattern, $params['number'])))
+        		{
+        		$return['error'] = $this->functions->getLang('The format of telephone number is invalid');
+        		return $return;
+        	}
+        	if($params['number'] != $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']) {
+        		$old_telephone = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number'];
+        		$this->ldapRootConnect(false);
+        		if(strlen($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number']) == 0) {
+        			$info['telephonenumber'] = $params['number'];
+        			$result = @ldap_mod_add($this->ds, $_SESSION['phpgw_info']['expressomail']['user']['account_dn'], $info);
+        		}
+        		else {
+        			$info['telephonenumber'] = $params['number'];
+        			$result = @ldap_mod_replace($this->ds, $_SESSION['phpgw_info']['expressomail']['user']['account_dn'], $info);
+        		}
+        		$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number'] = $info['telephonenumber'];
+				// 	Log updated telephone number by user action
+				include_once('class.db_functions.inc.php');
+				$db_functions = new db_functions();
+    			$db_functions->write_log('modified user telephone',"User changed its own telephone number in preferences $old_telephone => ".$info['telephonenumber']);
+    			unset($info['telephonenumber']);
+    		}
+    		return $return['ok'] = true;
+    	}        
 }
 ?>
Index: /trunk/expressoMail1_2/js/QuickAddTelephone.js
===================================================================
--- /trunk/expressoMail1_2/js/QuickAddTelephone.js	(revision 5821)
+++ /trunk/expressoMail1_2/js/QuickAddTelephone.js	(revision 5821)
@@ -0,0 +1,114 @@
+ 	function emQuickAddTelephone ()	{
+ 		var div_user_info = Element("user_info");
+ 		// User without telephone and no permission to edit it. Abort.
+ 		if(preferences.blockpersonaldata && !preferences.telephone_number){
+ 			return;
+ 		} 		
+ 		if(div_user_info) {
+ 			
+ 			var span  = document.createElement("SPAN");
+ 			span.title = preferences.blockpersonaldata ? get_lang("You can't modify your Commercial Telephone.") : get_lang("Update my telephone");
+ 			span.style.cursor = "pointer";
+ 			span.style.marginLeft = "10px";
+ 			span.style.fontWeight = "bold";
+ 			span.style.color  = "YELLOW";
+ 			span.style.textDecoration = 'underline';
+ 			span.innerHTML = preferences.telephone_number ?  preferences.telephone_number : get_lang('Update my telephone');
+ 			span.onclick= function() { 
+ 				if(preferences.blockpersonaldata) 
+ 					alert(get_lang("You can't modify your Commercial Telephone."));
+ 				else 
+ 					QuickAddTelephone.update_telephonenumber(this.id);
+ 			}
+
+ 			span.id = "span_telephonenumber";
+ 			div_user_info.appendChild(span);
+ 		}
+	}
+
+ 	emQuickAddTelephone.prototype.FormatTelephoneNumber = function (event, campo)	{
+ 		event = is_ie ? window.event : event; 		
+ 		var code = (event.keyCode ? event.keyCode :event.which); 		
+		separador1 = '(';
+		separador2 = ')';
+		separador3 = '-';		
+		vr = campo.value;
+		tam = vr.length;
+		if ((tam == 1) && (( code != 8 ) || ( code != 46 )))
+			campo.value = '';
+		if ((tam == 3) && (( code != 8 ) || ( code != 46 )))
+			campo.value = vr.substr( 0, tam - 1 );	
+		if (( tam <= 1 ) && ( code != 8 ) && ( code != 46 ))
+			campo.value = separador1 + vr;		
+		if (( tam == 3 ) && ( code != 8 ) && ( code != 46 ))
+			campo.value = vr + separador2;			
+		if (( tam == 8 ) && (( code != 8 ) && ( code != 46 )))
+			campo.value = vr + separador3;
+		if ((( tam == 9 ) || ( tam == 8 )) && (( code == 8 ) || ( code == 46 )))
+			campo.value = vr.substr( 0, tam - 1 );
+	}
+
+ 	emQuickAddTelephone.prototype.update_telephonenumber = function (spanID){
+		var span = document.getElementById(spanID);
+		var input  = document.createElement("INPUT");
+		input.type  = "text";
+		input.value = (span.innerHTML == get_lang('Update my telephone') ? '(00)0000-0000' : span.innerHTML);
+		input.oldvalue = span.innerHTML;
+		input.autocomplete="off";
+		input.name = "telephone_number";
+		input.style.marginLeft = "10px";
+		input.size = "12";
+		input.maxLength = "13";
+		input.id = "input_telephonenumber";
+		input.onkeyup = function(event) {
+			event = is_ie ? window.event : event;
+			var code = (event.keyCode ? event.keyCode :event.which);
+			if(code == '13'){
+				if(input.oldvalue != input.value && input.value != '' && input.value !='(00)0000-0000')
+					QuickAddTelephone.save_telephonenumber(this);
+				else
+					QuickAddTelephone.load_telephonenumber(this);
+			}else if(code == '27'){
+				QuickAddTelephone.load_telephonenumber(this);					
+			}else {
+				QuickAddTelephone.FormatTelephoneNumber(event, this);
+			} 
+		}; 
+		input.onblur = function() { 
+			QuickAddTelephone.load_telephonenumber(this);
+		};
+		span.parentNode.replaceChild(input, span);
+		input.focus();
+	}
+		
+ 	emQuickAddTelephone.prototype.load_telephonenumber = function(input){
+		var span  = document.createElement("SPAN");
+		span.title= get_lang("Update my telephone");
+		span.style.cursor = "pointer";
+		span.style.fontWeight = "bold";
+		span.style.marginLeft = "10px";
+		span.style.color  = "YELLOW";
+		span.style.textDecoration = 'underline';
+		span.innerHTML = input.oldvalue;
+		span.onclick= function() { QuickAddTelephone.update_telephonenumber(this.id)};			
+		span.id = "span_telephonenumber";
+		input.parentNode.replaceChild(span, input);	
+	}
+ 	
+ 	emQuickAddTelephone.prototype.save_telephonenumber = function(input){
+		var handler_save = function(data){			
+			if(data && data['error']){
+				alert(data['error']);
+				return;
+			}
+			else
+				write_msg(get_lang("Telephone number updated with success."));
+			input.oldvalue = input.value;
+			QuickAddTelephone.load_telephonenumber(input);
+		}
+		cExecute ("$this.ldap_functions.save_telephoneNumber&number="+input.value+"&id="+input.id, handler_save);
+	}	
+
+/* Build the Object */
+	var QuickAddTelephone;
+	QuickAddTelephone = new emQuickAddTelephone();
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 5814)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 5821)
@@ -493,4 +493,7 @@
 		if(Element("table_quota"))
 			connector.loadScript("InfoQuota");
+
+		if(preferences.enable_quickadd_telephonenumber)
+			connector.loadScript("QuickAddTelephone");
 }
 
