Index: trunk/jabberit_messenger/templates/default/confServersJabber.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/confServersJabber.tpl	(revision 909)
+++ trunk/jabberit_messenger/templates/default/confServersJabber.tpl	(revision 946)
@@ -11,22 +11,60 @@
 		<td colspan="2">
 			<table width="100%;">
-				<tr>
-					<td colspan="3">
-						<label>{lang_Organization}</label>&nbsp;.:&nbsp;
-						<select id="organizations_ldap_jabberit">
-				   			{options_ous_ldap}
-				   		</select>
+				<tr class="row_off">
+					<td style="width:20%">
+						<label>{lang_Organization}</label>
+					</td>
+					<td style="width:80%">
+						<input id="organizationLdapJabberit" type="text" size="30" maxlength="30"/>
+						<label style="font-size:7pt !important;color:red;">
+							{lang_Example}&nbsp;.:&nbsp;ORGANIZACAO ( ou específica )&nbsp;&nbsp;ou * ( para todas )
+						</label>
 					</td>
 				</tr>
-				<tr>
-					<td colspan="3">
-						<label>{lang_ServerJabber}</label>&nbsp;.:&nbsp;
-						<input id="HostNameJabber" type="text" size="40" maxlength="40"/>
+				<tr class="row_off">
+					<td style="width:20%">
+						<label>{lang_ServerJabber}</label>
+					</td>
+					<td style="width:80%">
+						<input id="hostNameJabberit" type="text" size="40" maxlength="40"/>
 						<label style="font-size:7pt !important;color:red;">{lang_Example}&nbsp;:&nbsp;jabber.server.com</label>
 					</td>
 				</tr>
-				<tr>
-					<td class="row_on" style="border:1px solid #00000">
-					  <input type="button" name="add" value="{lang_save}" onclick="constructScript.setConfServerJabber();">
+				<tr class="row_off">
+					<td style="width:20%">
+						<label>Servidor Ldap</label>
+					</td>
+					<td style="width:80%">
+						<input id="serverLdapJabberit" type="text" size="50" maxlength="50"/>
+					</td>
+				</tr>
+				<tr class="row_off">
+					<td style="width:20%">
+						<label>Contexto</label>
+					</td>
+					<td style="width:80%">
+						<input id="contextLdapJabberit" type="text" size="50" maxlength="50"/>
+					</td>
+				</tr>
+				<tr class="row_off">
+					<td style="width:20%">
+						<label>Usuário Ldap</label>
+					</td>
+					<td style="width:80%">
+						<input id="userLdapJabberit" type="text" size="50" maxlength="50"/>
+					</td>
+				</tr>
+				<tr class="row_off">
+					<td style="width:20%">
+						<label>Password</label>	
+					</td>
+					<td style="width:80%">
+						<input id="passwordLdapJabberit" type="password" size="40" maxlength="40"/>					
+					</td>
+				</tr>
+				<tr class="row_off">
+					<td colspan="2" style="border:1px solid #00000; width:100%;">
+					  <input type="button" name="add" value="{lang_save}" onclick="constructScript.setConfServerJabber();" />
+					  <input type="reset" name="reset" value="{lang_new}" />
 					</td>
 				</tr>
@@ -43,5 +81,6 @@
 					<td align="left" class="row_on" style="width:40%">{lang_Organization}</td>
 					<td align="left" class="row_on" style="width:40% !important">{lang_ServerJabber}</td>
-					<td align="left" class="row_on" style="width:20% !important">{lang_Delete}</td>										
+					<td align="left" class="row_on" style="width:10% !important">{lang_Edit}</td>										
+					<td align="left" class="row_on" style="width:10% !important">{lang_Delete}</td>
 				</tr>
 				{value_Organizations_Servers}
@@ -51,5 +90,5 @@
 	<tr>
 		<td colspan="2" align="center">
-		  <input type="button" name="back" value="{lang_Back}" onClick="document.location.href='{action_url}'">
+		  <input type="button" name="back" value="{lang_Back}" onClick="document.location.href='{action_url}'" />
 		  <br/>
 		</td>
Index: trunk/jabberit_messenger/templates/default/indexIM.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/indexIM.tpl	(revision 596)
+++ trunk/jabberit_messenger/templates/default/indexIM.tpl	(revision 946)
@@ -128,5 +128,5 @@
 	<br/>
 	<br/>
-    <img src="templates/default/images/troca_de_mensagem.png" width="494" height="341" alt="Troca de Mensagens" title="Troca de Mensagens" align="left" style="margin-top:5px;"/>
+    <img src="templates/default/images/troca_de_mensagem.png" width="300" height="351" alt="Troca de Mensagens" title="Troca de Mensagens" align="left" style="margin-top:5px;"/>
     <br clear="all"/>
     ( figura 8 )
Index: trunk/jabberit_messenger/templates/default/setup.js
===================================================================
--- trunk/jabberit_messenger/templates/default/setup.js	(revision 898)
+++ trunk/jabberit_messenger/templates/default/setup.js	(revision 946)
@@ -91,4 +91,35 @@
 				},
 				"organization=" + organization);
+	}
+	
+	function editHostsJabber()
+	{
+		if( arguments.length > 0 )
+		{
+			_conn.go("$this.db_im.editHostJabber",
+					 function(data)
+					 {
+							var fields = [
+											['org','organizationLdapJabberit'], 
+											['jabberName','hostNameJabberit'],
+											['serverLdap','serverLdapJabberit'], 
+											['contextLdap','contextLdapJabberit'],
+											['user','userLdapJabberit'], 
+											['password','passwordLdapJabberit']										
+										 ];						 	
+
+							data = data.split(';');
+
+							for( var i = 0 ; i < data.length ; i++ )
+							{
+								var values = data[i].split(':');
+
+								for( var j in fields )
+									if( values[0] == fields[j][0] )
+										document.getElementById(fields[j][1]).value = values[1];
+							}
+							
+					 },"item="+arguments[0]);
+		}
 	}
 	
@@ -136,5 +167,5 @@
 		{
 			values = values.substring(0,(values.length - 1 ));
-			_conn.go("$this.FileDefine.getParams","val=" + values);
+			_conn.go("$this.fileDefine.ldapInternal","val=" + values);
 			return true;
 		}
@@ -194,5 +225,5 @@
 				addLdapAttributes(doc);
 		}	
-		else
+		else // AQUI ESTÁ GERANDO O ARQUIVO //
 		{
 			if( doc )
@@ -203,34 +234,49 @@
 	function setConfServerJabber()
 	{
-		var elementSel = document.getElementById('organizations_ldap_jabberit');
-		var Organization = "";
-		var inputHostJabber = ltrim(document.getElementById('HostNameJabber').value);
-		
-		for(var i = 0; i < elementSel.options.length; i++)
-		{
-			if( elementSel.options[i].selected == true && elementSel.options[i].value != "-1" )
-				Organization = elementSel.options[i].value;
-		}
-		
-		if( Organization && inputHostJabber )
-		{
-			_conn.go("$this.db_im.setHostJabber",
-					 function(data)
-					 {
-						var _params = {
-								'lang1': jabberitGetLang('Organization'),
-								'lang2': jabberitGetLang('Servers Jabber'),
-								'lang3': jabberitGetLang('Delete')								
-						};
-
-						var Table = document.getElementById('tableConfServersJabber');
-						Table.parentNode.innerHTML = _xtools.parse( data, 'tableConfServersJabber.xsl', _params);
-
-						elementSel.options[0].selected = true;
-						document.getElementById('HostNameJabber').value = "";
-							
-					 },"organization="+Organization+"&hostJabber="+inputHostJabber);
-		}
-	
+		var orgLdap		= document.getElementById('organizationLdapJabberit');
+		var hostName	= document.getElementById('hostNameJabberit');
+		var	serverLdap	= document.getElementById('serverLdapJabberit');
+		var contextLdap = document.getElementById('contextLdapJabberit');
+		var userLdap	= document.getElementById('userLdapJabberit');
+		var pwdLdap		= document.getElementById('passwordLdapJabberit');	
+
+		var ArrayConf = [
+							['orgLdap', 'Informe uma organizacao !'],
+							['hostName', 'Informe o nome do servidor Jabber !'],
+							['serverLdap', 'Informe o nome do servidor Ldap !'],
+							['contextLdap', 'Informe um contexto Ldap !'],
+							['userLdap', ''],
+							['pwdLdap', '']
+						];
+
+		for (var i in ArrayConf)
+		{
+			if( !ltrim(eval(ArrayConf[i][0]).value) && ltrim(ArrayConf[i][1]) )
+			{
+				alert(ArrayConf[i][1]);
+				eval(ArrayConf[i][0]).focus();
+				return false;				
+			}	
+		}
+		
+		_conn.go("$this.db_im.setHostJabber",
+				 function(data)
+				 {
+					var _params = {
+							'lang1': jabberitGetLang('Organization'),
+							'lang2': jabberitGetLang('Servers Jabber'),
+							'lang3': jabberitGetLang('Delete'),								
+							'lang4': jabberitGetLang('Edit')							
+					};
+
+					var Table = document.getElementById('tableConfServersJabber');
+					Table.parentNode.innerHTML = _xtools.parse( data, 'tableConfServersJabber.xsl', _params);
+					
+					for( var i in ArrayConf )
+						eval(ArrayConf[i][0]).value = "";
+				 },
+				 "org="+orgLdap.value+"&jabberName="+hostName.value+
+				 "&serverLdap="+serverLdap.value+"&contextLdap="+contextLdap.value+
+				 "&user="+userLdap.value+"&password="+pwdLdap.value);
 	}
 
@@ -314,5 +360,5 @@
 			var idElement = arguments[0];
 			var elementTableTr = document.getElementById(idElement);
-			
+
 			_conn.go("$this.db_im.removeHostsJabber",
 				     function(data)
@@ -383,4 +429,5 @@
 	function constructScript(){}
 
+	constructScript.prototype.editHostsJ				= editHostsJabber;
 	constructScript.prototype.removeHostsJ				= removeHostsJabber;
 	constructScript.prototype.removeOrg 				= removeOrgLdapAttributes;
Index: trunk/jabberit_messenger/templates/default/content.html
===================================================================
--- trunk/jabberit_messenger/templates/default/content.html	(revision 596)
+++ trunk/jabberit_messenger/templates/default/content.html	(revision 946)
@@ -116,5 +116,5 @@
 	Clicando duas vezes com o botão esquerdo sobre o nome do contato escolhido, abrirá uma janela (figura 8), para a troca de mensagens. Nessa mesma janela existe um menu, o qual é possível
 	configurar o formato da fonte e enviar smiles.<br><br>
-    <img src="images/troca_de_mensagem.png" width="494" height="341" alt="Troca de Mensagens" title="Troca de Mensagens" align="bottom" style="margin-top:5px;"/><br>( figura 8 )
+    <img src="images/troca_de_mensagem.png" width="300" height="351" alt="Troca de Mensagens" title="Troca de Mensagens" align="bottom" style="margin-top:5px;"/><br>( figura 8 )
 	</div>	
 	<br/>
Index: trunk/jabberit_messenger/templates/default/confExternals.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/confExternals.tpl	(revision 561)
+++ 	(revision )
@@ -1,84 +1,0 @@
-<!-- BEGIN confOrg -->
-<script type="text/javascript" src="jabberit_messenger/js/connector.js"></script>
-<script type="text/javascript" src="jabberit_messenger/js/xtools.js"></script>
-<script type="text/javascript" src="jabberit_messenger/controller.php?act=j.setup"></script>
-<form method="POST" action="{action_url}">
-<table align="center" width="60%" cellspacing="2" style="border: 1px solid #000000;">
-	<input type="hidden" name="HiddenJabberitExternals" value="">
-	<tr class="th">
-		<td colspan="2">&nbsp;<b>{lang_Informe_as_Organizacoes_Externas}</b></td>
-	</tr>
-	<tr class="row_on">
-		<td colspan="2" style="padding:5 0 5 0px;">&nbsp;<b>&nbsp;{lang_Cadastrar_Organizacao}&nbsp;</b></td>
-	</tr>
-	<tr class="row_on">
-		<td colspan="2">
-			<table>
-				<tr>
-					<td colspan="3">
-						<label>{lang_Habilitar_Participantes_Externos}&nbsp;.:&nbsp;</label>
-						<select name="use_external_participants_jabberit" onchange="constructScript.setPartExternal(this,document);">
-				   			{value_use_external_participants_jabberit}
-				   		</select>
-					</td>
-				</tr>
-				<tr>
-					<td align="right" class="row_on"><label id="label_CadOrgJabberit">{lang_Organization}</label>&nbsp;.:&nbsp;</td>
-					<td class="row_on">
-						<input name="text_CadOrgJabberit" {value_flag} type="text" size="30" maxlength="30">
-					</td>
-					<td class="row_on" style="border:1px solid #00000">
-					  <input type="button" name="add" value="{lang_save}" {value_flag} onclick="return constructScript.sendf(document);">
-					</td>
-				</tr>
-			</table>
-		</td>
-	</tr>
-	<tr class="row_on">
-		<td colspan="2" style="padding:5 0 5 0px;">&nbsp;<b>{lang_Organizacoes_Cadastradas}</b></td>
-	</tr>
-	<tr>
-		<td colspan="2">
-			<table id="tableExternalParticipantsJabberit" cellspacing="2" style="width:100%">
-				<tr>
-					<td align="left" class="row_on">{lang_Organization}</td>
-					<td align="left" class="row_on" style="width:30% !important">{lang_Delete}</td>					
-				</tr>
-				{organizations_attributes}
-			</table>
-		</td>
-	</tr>
-	<tr>
-		<td colspan="2" align="center">
-		  <input type="submit" name="back" value="{lang_Back}">
-		  <br>
-		</td>
-	</tr>
-</table>
-</form>
-<script>
-	
-	var form = document.forms[0];
-
-	for(var i = 0; i < form.elements.length; i++)
-	{
-		switch(form.elements[i].type)
-		{
-			case 'text':
-			case 'button':
-							
-				if({value_flag} == 'true')
-				{
-					form.elements[i].disabled = eval('true');
-					//alert('PRIMEIRO');
-				}
-				else
-				{
-					form.elements[i].disabled = eval('false');
-					//alert('SEGUNDO');
-				}
-				break;
-		}
-	}
-</script>
-<!-- END confOrg -->
Index: trunk/jabberit_messenger/setup/phpgw_pt-br.lang
===================================================================
--- trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 910)
+++ trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 946)
@@ -1,3 +1,4 @@
 Add	jabberit_messenger	pt-br	Adicionar
+Add contact wait	jabberit_messenger	pt-br	Adicionando contato aguarde
 Add Contatct	jabberit_messenger	pt-br	Adicionar Contato
 Add Contacts	jabberit_messenger	pt-br	Adicionar Contatos
@@ -43,11 +44,14 @@
 deny	jabberit_messenger	pt-br	Negar
 Deny module's use by group	common	pt-br	Restringir o Uso do Módulo por Grupo
-Error in the message!	jabberit_messenger	pt-br	Erro na mensagem!
-Error saving your preferences!	jabberit_messenger	pt-br	Erro salvando suas preferências! 
+E-mail	jabberit_messenger	pt-br	E-mail
+Edit	jabberit_messenger	pt-br	Editar
 Enable Auto Login IM	jabberit_messenger	pt-br	Conectar Automaticamente IM 
 Enable the Expresso Messenger inside of the modules	common	pt-br	Habilitar o Expresso Messenger dentro dos módulos
 Enable the Expresso Messenger module	jabberit_messenger	pt-br	Habilitar o módulo Expresso Messenger 
+Enter a GROUP	jabberit_messenger	pt-br	Informe um GRUPO
+Enter a NAME	jabberit_messenger	pt-br	Informe um NOME
 Enter a value greater than or equal to 1!	jabberit_messenger	pt-br	Informe um valor igual ou maior que 1!
-E-mail	jabberit_messenger	pt-br	E-mail
+Error in the message!	jabberit_messenger	pt-br	Erro na mensagem!
+Error saving your preferences!	jabberit_messenger	pt-br	Erro salvando suas preferências! 
 Example	jabberit_messenger	pt-br	Exemplo
 External Participants	common	pt-br	Participantes Externos
@@ -82,4 +86,5 @@
 Name of Contacts	jabberit_messenger	pt-br	Nome do Contato
 Name Organization	jabberit_messenger	pt-br	Nome Organização
+New	jabberit_messenger	pt-br	Novo
 New Message!	jabberit_messenger	pt-br	Nova Mensagem!
 Nick	jabberit_messenger	pt-br	Apelido
Index: trunk/jabberit_messenger/setup/setup.inc.php
===================================================================
--- trunk/jabberit_messenger/setup/setup.inc.php	(revision 942)
+++ trunk/jabberit_messenger/setup/setup.inc.php	(revision 946)
@@ -8,5 +8,5 @@
 	$setup_info['jabberit_messenger']['name']      	= 'jabberit_messenger';
 	$setup_info['jabberit_messenger']['title']     	= 'Jeti Applet';
-	$setup_info['jabberit_messenger']['version']   	= '0.7.12';
+	$setup_info['jabberit_messenger']['version']   	= '0.7.13';
 	$setup_info['jabberit_messenger']['app_order'] 	= 9;
 	$setup_info['jabberit_messenger']['enable']    	= 1;
Index: trunk/jabberit_messenger/xsl/tableConfServersJabber.xsl
===================================================================
--- trunk/jabberit_messenger/xsl/tableConfServersJabber.xsl	(revision 897)
+++ trunk/jabberit_messenger/xsl/tableConfServersJabber.xsl	(revision 946)
@@ -6,4 +6,5 @@
 	<xsl:param name="lang2" />
 	<xsl:param name="lang3" />
+	<xsl:param name="lang4" />
 	
 	<xsl:template match="/">
@@ -12,5 +13,6 @@
 				<td align="left" class="row_on" style="width:40%"><xsl:value-of select="$lang1" /></td>
 				<td align="left" class="row_on" style="width:40% !important"><xsl:value-of select="$lang2" /></td>
-				<td align="left" class="row_on" style="width:20% !important"><xsl:value-of select="$lang3" /></td>					
+				<td align="left" class="row_on" style="width:10% !important"><xsl:value-of select="$lang4" /></td>					
+				<td align="left" class="row_on" style="width:10% !important"><xsl:value-of select="$lang3" /></td>				
 			</tr>
 			<xsl:for-each select="return/confServer">
@@ -18,4 +20,5 @@
 					<td><xsl:value-of select="@ou" /></td>
 					<td><xsl:value-of select="@serverName" /></td>
+					<td><a href="javascript:constructScript.editHostsJ('{.}');"><xsl:value-of select="$lang4" /></a></td>
 					<td><a href="javascript:constructScript.removeHostsJ('{.}');"><xsl:value-of select="$lang3" /></a></td>
 				</tr>
Index: trunk/jabberit_messenger/xsl/add_user.xsl
===================================================================
--- trunk/jabberit_messenger/xsl/add_user.xsl	(revision 908)
+++ trunk/jabberit_messenger/xsl/add_user.xsl	(revision 946)
@@ -19,10 +19,4 @@
 				<input type="text" size="30" onclick="this.select();" onkeypress="javascript:loadscript.keyPress(event, this);" style="margin: 0 10 0 0px;"/>
 				<input type="image" src='../jabberit_messenger/templates/default/images/users.png' value="{$lang2}" onclick="javascript:loadscript.search(this);" />
-				<div id="external_Participants_Jabberit" style="display:none;margin:3 0 0 0px;border-bottom:1px dashed #000;width:430px;">
-					<input type="checkbox" name="checkbox_external_Participants_Jabberit" style="margin:10 5 0 0px;" onclick="javascript:loadscript.cLabel(this);"/>
-					<span style="width:130px;"><xsl:value-of select="$lang8" /> .: </span> - <span onclick="javascript:loadscript.openWinParExt(this);" style="cursor:pointer;">
-					<img src='../jabberit_messenger/templates/default/images/view.png' alt='Ver Organizações' title='Ver Organizações' />
-					</span>
-				</div> 
 			</div>
 			<br/>
Index: trunk/jabberit_messenger/xsl/list_ldap_contacts.xsl
===================================================================
--- trunk/jabberit_messenger/xsl/list_ldap_contacts.xsl	(revision 907)
+++ trunk/jabberit_messenger/xsl/list_ldap_contacts.xsl	(revision 946)
@@ -23,5 +23,5 @@
 		<xsl:for-each select="data">
 			<xsl:sort select="cn"/>
-			<span value="{mail};{uid}" jid="{jid}" photo="{photo}">
+			<span value="{mail};{uid}" jid="{jid}" ou="{ou}" photo="{photo}">
 				<span id="{mail};{uid}" style="display:none;"><xsl:value-of select="cn" /></span>
 				<b><xsl:value-of select="name(..)"/></b>
Index: trunk/jabberit_messenger/inc/controller.xml
===================================================================
--- trunk/jabberit_messenger/inc/controller.xml	(revision 899)
+++ trunk/jabberit_messenger/inc/controller.xml	(revision 946)
@@ -34,10 +34,11 @@
 			<item ref="contacts_im" alias="list_contacts" class="contacts_im" method="list_contacts" prefix="class." suffix=".inc.php"/>
 			<item ref="contacts_im" alias="verifyAddNewContact" class="contacts_im" method="verifyAddNewContact" prefix="class." suffix=".inc.php"/>
+			<item ref="db_im" alias="editHostJabber" class="db_im" method="editHostJabber" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="getPreferences" class="db_im" method="getPreferences" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setAttributesLdap" class="db_im" method="setAttributesLdap" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setHostJabber" class="db_im" method="setHostJabber" prefix="class." suffix=".inc.php"/>
+			<item ref="db_im" alias="setPreferences" class="db_im" method="setPreferences" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setOuGroupsLocked" class="db_im" method="setOuGroupsLocked" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setOrganization" class="db_im" method="setOrganization" prefix="class." suffix=".inc.php"/>
-			<item ref="db_im" alias="setPreferences" class="db_im" method="setPreferences" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="setUseParticipantsExternal" class="db_im" method="setUseParticipantsExternal" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="removeAttributesLdap" class="db_im" method="removeAttributesLdap" prefix="class." suffix=".inc.php"/>
@@ -45,11 +46,7 @@
 			<item ref="db_im" alias="removeOuGroupsLocked" class="db_im" method="removeOuGroupsLocked" prefix="class." suffix=".inc.php"/>
 			<item ref="db_im" alias="removeParticipantsExternal" class="db_im" method="removeParticipantsExternal" prefix="class." suffix=".inc.php"/>
-			<item ref="ldap_im" alias="list_organizations_ldap" class="ldap_im" method="list_organizations_ldap" prefix="class." suffix=".inc.php"/>
-			<item ref="ldap_im" alias="list_participants_externals" class="ldap_im" method="list_participants_externals" prefix="class." suffix=".inc.php"/>
+			<item ref="fileDefine" alias="ldapExternal" class="fileDefine" method="ldapExternal" prefix="class." suffix=".inc.php"/>
+			<item ref="fileDefine" alias="ldapInternal" class="fileDefine" method="ldapInternal" prefix="class." suffix=".inc.php"/>			
 			<item ref="ldap_im" alias="getGroupsLdap" class="ldap_im" method="getGroupsLdap" prefix="class." suffix=".inc.php"/>
-			<item ref="ldap_im" alias="photo_ldap" class="ldap_im" method="photo_ldap" prefix="class." suffix=".inc.php"/>
-			<item ref="ujabber" alias="AddNewContact" class="ujabber" method="AddNewContact" prefix="class." suffix=".inc.php"/>
-			<item ref="ujabber" alias="getGroupsJabber" class="ujabber" method="getGroupsJabber" prefix="class." suffix=".inc.php"/>			
-			<item ref="FileDefine" alias="getParams" class="FileDefine" method="getParams" prefix="class." suffix=".inc.php"/>			
 		</php>
 		<xml></xml>
Index: trunk/jabberit_messenger/inc/webservice.php
===================================================================
--- trunk/jabberit_messenger/inc/webservice.php	(revision 946)
+++ trunk/jabberit_messenger/inc/webservice.php	(revision 946)
@@ -0,0 +1,274 @@
+<?php
+  /***************************************************************************\
+  *  Expresso - Expresso Messenger                                            *
+  *  	- Alexandre Correia / Rodrigo Souza							          *
+  *  	- JETI - http://jeti-im.org/										  *
+  * ------------------------------------------------------------------------- *
+  *  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 webService
+{
+	private $conn;
+	private $contextLdap;
+	private $userDn;	
+	private $jabberName;
+	private $passwd;
+	private $photo_user = array();
+	private $refer;
+	private $serverLdap;
+	
+	function __construct()
+	{
+		require_once('confLDAPInternal.php');
+		$handle   = unserialize(base64_decode($LDAP_INTERNAL));
+
+		$this->jabberName	= $handle['jabberName'];
+		$this->serverLdap	= $handle['serverLdap'];
+		$this->contextLdap	= $handle['contextLdap'];
+		$this->userDn		= $handle['user'];
+		$this->passwd		= $handle['password'];
+		
+		$this->refer  	= true;
+		$this->version3 = true;
+	}
+	
+	private final function ldapConnect()
+	{
+		if(!function_exists('ldap_connect'))
+			return False;
+		
+		if(!$this->conn = ldap_connect($this->serverLdap))
+			return False;
+
+		if( $this->version3 )
+			if( !ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3) )
+				$this->version = false;
+
+		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->refer);
+
+		// Bind as Admin
+		if($this->userDn && $this->passwd && !ldap_bind($this->conn, $this->userDn, $this->passwd))
+			return False;
+		
+		// Bind as Anonymous
+		if(!$this->userDn && !$this->passwd && !@ldap_bind($this->conn))
+			return False;
+	}
+
+	private final function ldapConnectExternal($pHostJabber)
+	{
+		require_once('confLDAPExternal.php');
+		$handle   = unserialize(base64_decode($LDAP_EXTERNAL));
+
+		foreach($handle as $itens)
+			if(trim($pHostJabber) == $itens['jabberName'])
+			{
+				$this->jabberName	= $itens['jabberName'];
+				$this->serverLdap	= $itens['serverLdap'];
+				$this->contextLdap	= $itens['contextLdap'];
+				$this->userDn		= $itens['user'];
+				$this->passwd		= $itens['password'];
+			}		
+
+		$this->refer  	= true;
+		$this->version3 = true;
+		
+		$this->ldapConnect();
+	}
+	
+	public final function getNameOrganization($pJid, $pCharset)
+	{
+		$uid = substr($pJid, 0, strpos($pJid,"@"));
+		
+		if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 )))
+		{
+			$this->ldapConnect();
+			
+			if( $this->conn )
+			{
+				$filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))";
+				$justthese = array("uid","cn","dn");
+				$search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);
+				$entry = ldap_get_entries($this->conn,$search);
+				$cn = $entry[0]['cn'][0];
+				$ou = explode("dc=", $entry[0]['dn']);
+				$ou = explode("ou=",$ou[0]);
+				$ou = array_pop($ou);
+				$dn = strtoupper(substr($ou,0,strlen($ou)-1));
+	
+				$return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn);
+			}
+		}
+		else
+		{
+			$this->ldapConnectExternal(substr($pJid, strpos($pJid, "@") + 1 ));
+
+			if( $this->conn )
+			{
+				$filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))";
+				$justthese = array("uid","cn","dn");
+				$search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);
+				$entry = ldap_get_entries($this->conn,$search);
+				$cn = $entry[0]['cn'][0];
+				$ou = explode("dc=", $entry[0]['dn']);
+				$ou = explode("ou=",$ou[0]);
+				$ou = array_pop($ou);
+				$dn = strtoupper(substr($ou,0,strlen($ou)-1));
+	
+				$return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn);
+			}
+		}
+
+		if( $pCharset === "1" )
+			return $return;
+		else
+			return mb_convert_encoding($return, "ISO-8859-1", "UTF-8");
+
+		$return = utf8_encode("Nome : Não Identificado ;Organização : Não Identificado");			
+
+		if( $pCharset === 1 )
+			return $return;
+		else
+			return mb_convert_encoding($return, "ISO-8859-1", "UTF-8");
+
+	}
+	
+	public final function getPhotoLdap($pJid)
+	{
+		$uid = substr($pJid, 0, strpos($pJid,"@"));
+	
+		if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 )))
+		{
+			$this->ldapConnect();
+			
+			if( $this->conn )
+			{
+				$filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))";
+				$justthese = array("uid","jpegPhoto");
+				$search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);
+				$entry1 = ldap_get_entries($this->conn,$search);
+				$entry = ldap_first_entry( $this->conn, $search );
+				if( $entry1['count'] > 0 )
+				{
+					$i = 0;
+					$photo = "";
+					$return_photo = "";
+					$photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto');
+
+					if ($photo)
+						$return_photo = $photo[0];								
+					return $return_photo;
+				}
+			}
+		}
+		else
+		{
+			$jabberName = substr($pJid, strpos($pJid, "@") + 1 );
+			
+			if( strpos($jabberName, "/") )
+				$jabberName = substr($jabberName, 0, strpos($jabberName, "/"));
+			
+			$this->ldapConnectExternal($jabberName);
+
+			if( $this->conn )
+			{
+				$filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))";
+				$justthese = array("uid","jpegPhoto");
+				$search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);
+				$entry1 = ldap_get_entries($this->conn,$search);
+				$entry = ldap_first_entry( $this->conn, $search );
+				if( $entry1['count'] > 0 )
+				{
+					$i = 0;
+					$photo = "";
+					$return_photo = "";
+					$photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto');
+					if ($photo)
+						$return_photo = $photo[0];								
+					return $return_photo;
+				}
+			}
+		}
+					
+		return false;
+	}
+	
+	public final function getPhotoSession($pUid, $pOu)
+	{
+		$uid = $pUid;
+		if( strpos($pUid, "@") )
+			$uid = substr($pUid, 0, strpos($pUid, "@"));
+		
+		if( isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]) )
+		{
+			$photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]);
+
+			header("Content-Type: image/jpeg");
+			$width = imagesx($photo);
+			$height = imagesy($photo);
+			$twidth = 60;
+			$theight = 80;
+			$small_photo = imagecreatetruecolor ($twidth, $theight);
+			imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
+			imagejpeg($small_photo,'',100);
+
+			unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pOu][$uid]);
+
+			return;	
+		}
+	}
+}
+
+if(trim($_REQUEST['javaPhoto']) != "" )
+{
+	$obj = new webService();
+	$jid = $_REQUEST['javaPhoto'];
+	
+	$photo = $obj->getPhotoLdap($jid);
+	$photoWidth = 70;
+	$photoHeight = 90;
+	$newImage = imagecreatetruecolor($photoWidth,$photoHeight);		
+
+	if( $photo )
+	{
+		$photo = imagecreatefromstring($photo);
+		imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));
+	}
+	else
+	{
+		$photo = @imagecreatefrompng("../templates/default/images/photo.png");
+		imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));
+	}
+	
+	ob_start();
+	imagepng($newImage);
+	$imagePhoto = ob_get_contents();
+	imagedestroy($newImage);
+	ob_end_clean();
+	printf("%s",base64_encode($imagePhoto));
+	
+}
+
+if(trim($_POST['jid']) != "")
+{
+	$jid = trim($_POST['jid']);
+	$charset = trim($_POST['charset']);
+	$obj = new webService();
+	
+	printf("%s",$obj->getNameOrganization($jid, $charset));
+}
+
+if(trim($_REQUEST['phpPhoto']) != "")
+{
+	$obj = new webservice();
+	$ou = $_REQUEST['phpOu'];
+	$jid = $_REQUEST['phpPhoto'];
+	
+	$obj->getPhotoSession($jid, $ou);
+}
+
+?>
Index: trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php	(revision 697)
+++ trunk/jabberit_messenger/inc/class.uienabledgroups.inc.php	(revision 946)
@@ -27,11 +27,4 @@
 	}
 	
-	public final function backPage()
-	{
-		echo "<pre>";
-		print_r($_POST);
-		echo "</pre>";
-	}	
-
 	public final function editGroups()
 	{
@@ -63,5 +56,5 @@
 			
 			$ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";	
-			if( ($LdapOus = $ldap->listOrganizationsLdap()) )
+			if( ($LdapOus = $ldap->getOrganizationsLdap()) )
 			{
 				foreach($LdapOus as $tmp )
Index: trunk/jabberit_messenger/inc/class.fileDefine.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.fileDefine.inc.php	(revision 946)
+++ trunk/jabberit_messenger/inc/class.fileDefine.inc.php	(revision 946)
@@ -0,0 +1,74 @@
+<?php
+ /***************************************************************************\
+  *  Expresso - Expresso Messenger                                            *
+  *  	- Alexandre Correia / Rodrigo Souza							          *
+  *  	- JETI - http://jeti-im.org/										  *
+  * ------------------------------------------------------------------------- *
+  *  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 fileDefine
+{
+	public final function ldapExternal($pConfLdap)
+	{
+		$file = "confLDAPExternal.php";
+		$writeFile = "<?php $"."LDAP_EXTERNAL="."\"".base64_encode(serialize($pConfLdap))."\""." ?>";
+		$this->writeFile($writeFile, $file);
+	}
+
+	public final function ldapInternal($pParam)
+	{
+		$array_values = explode("\n", $pParam['val']);	
+		$file = "confLDAPInternal.php";
+		$infoServer = array();
+		
+		foreach($array_values as $tmp )
+		{
+			$nvalue = explode(";", $tmp);
+			
+			switch(trim($nvalue[0]))
+			{
+				case "JETTI_NAME_JABBERIT" :
+						$infoServer['jabberName'] = $nvalue[1];				
+						break;
+						
+				case "JETTI_SERVER_LDAP_JABBERIT" :
+						$infoServer['serverLdap'] = $nvalue[1];							
+						break;			
+			
+				case "JETTI_CONTEXT_LDAP_JABBERIT" :	
+						$infoServer['contextLdap'] = $nvalue[1];
+						break;
+			
+				case "JETTI_USER_LDAP_JABBERIT" :
+						$infoServer['user'] = $nvalue[1];
+						break;
+			
+				case "JETTI_PASSWORD_LDAP_JABBERIT" :
+						$infoServer['password'] = $nvalue[1];				
+						break;
+			}
+		}
+		
+		$writeFile = "<?php $"."LDAP_INTERNAL="."\"".base64_encode(serialize($infoServer))."\""." ?>";
+		$this->writeFile( $writeFile, $file );
+	}
+
+	private final function writeFile($pContent, $pfile)
+    {
+		$filename = dirname(__FILE__).'/'.$pfile;
+		$content = $pContent;
+			
+		if ( !$handle = fopen($filename, 'w') )
+			exit;
+		
+		if (fwrite($handle, $content) === FALSE)
+			exit;
+
+		fclose($handle);
+    }
+}
+?>
Index: trunk/jabberit_messenger/inc/login.php
===================================================================
--- trunk/jabberit_messenger/inc/login.php	(revision 893)
+++ trunk/jabberit_messenger/inc/login.php	(revision 946)
@@ -82,6 +82,6 @@
 		// Enable Plugins Java;
 		$pluginsJava[] = $path . "applet.jar?" . filemtime("applet.jar");
-		$pluginsJava[] = $path . "plugins/filetransfer.jar?" . filemtime("plugins/filetransfer.jar");
 		$pluginsJava[] = $path . "plugins/xhtml.jar?" . filemtime("plugins/xhtml.jar");
+		$pluginsJava[] = $path . "plugins/filetransfer.jar?" . filemtime("plugins/filetransfer.jar");		
 		
 		for($i = 0; $i < count($pluginsJava); $i++)
Index: trunk/jabberit_messenger/inc/jabberit_acl.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 864)
+++ trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 946)
@@ -46,20 +46,7 @@
 		$_SESSION['phpgw_info']['jabberit_messenger']['webserver_url'] = $webserver_url;
 		
-		$ExternalParticipants = ""; 
-		if(trim($_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']))
-		{			
-			$ExternalParticipants = explode(",",$_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']);
-			
-			if(is_array($ExternalParticipants))	
-			{
-				natcasesort($ExternalParticipants);
-				$ExternalParticipants = implode(",", $ExternalParticipants);
-			}
-		}
-		
 		require_once dirname(__FILE__) . '/load_lang.php';
 		
 		$var_js  = "var path_jabberit='".$webserver_url."';";
-		$var_js	.= "var externalParticipantsJabberit='".$ExternalParticipants."';";
 
 		echo "<script type=\"text/javascript\">".$var_js."</script>";
Index: trunk/jabberit_messenger/inc/class.uigroupslocked.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.uigroupslocked.inc.php	(revision 570)
+++ trunk/jabberit_messenger/inc/class.uigroupslocked.inc.php	(revision 946)
@@ -70,5 +70,5 @@
 		
 		$ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";	
-		if( ($LdapOus = $ldap->listOrganizationsLdap()) )
+		if( ($LdapOus = $ldap->getOrganizationsLdap()) )
 		{
 			foreach($LdapOus as $tmp )
Index: trunk/jabberit_messenger/inc/class.contacts_im.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.contacts_im.inc.php	(revision 895)
+++ trunk/jabberit_messenger/inc/class.contacts_im.inc.php	(revision 946)
@@ -28,8 +28,4 @@
 		$this->db = new db_im();
 
-		$ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
-		$ou_User = substr($this->ou_User,strpos($this->ou_User, "ou="));
-		$ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc=")));
-
 		// (OU) User
 		$this->ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
@@ -39,19 +35,7 @@
 		// Hosts Jabber
 		$this->hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']);
-		$this->hostsJabber =  explode(";", $this->hostsJabber);
 		
 		// Server Name Jabber
 		$this->serverJabber = $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit'];
-	}
-
-	public final function getParticipantsExternal()
-	{		
-		$Participants = (trim($_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']) &&
-							$_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit']);
-
-		if( !$this->groupsLocked() && $Participants )		
-			return "true";
-		else
-			return "false";		
 	}
 
@@ -79,34 +63,55 @@
 	public final function list_contacts($param)
 	{
-		$users	= $this->users_auth_im($param['name']);
-		$order	= array();
+		$order		= array();
+		$ou_User	= substr($this->ou_User, (strpos($this->ou_User,"=")+1));
+		$return		= '<empty/>';
+		$users		= $this->users_auth_im($param['name']);
 		
 		if (!is_array($users) && trim($users) === 'Many Results')
 			return "<error>Many Results</error>";
 
+		foreach($this->hostsJabber as $conf )
+			if(array_search("*", $conf))
+				$hostDefault = $conf['jabberName'];
+			
 		if( is_array($users) )
 		{	
-			if( is_array($this->hostsJabber) )
-			{
-				for( $i = 0 ; $i < count($users); $i++ )
-				{
-					foreach($this->hostsJabber as $values)
+			for($i = 0; $i < count($users); $i++)				
+			{
+				if( is_array($this->hostsJabber) )
+				{
+					foreach($this->hostsJabber as $itens)
 					{
-						$itens = explode(":", $values);
-						if( $users[$i]['dn'] == $itens[0] )
-							$users[$i]['jid'] = $users[$i]['jid']."@".$itens[1];
+						if( $itens['org'] === $users[$i]['ou']  )
+						{
+							if( strpos($users[$i]['jid'], "@") === false )
+								$users[$i]['jid'] = $users[$i]['jid']."@".$itens['jabberName'];
+						}
+						else
+						{
+							if( $users[$i]['ou'] === $ou_User )
+							{
+								if( strpos($users[$i]['jid'], "@") === false )
+									$users[$i]['jid'] = $users[$i]['jid']."@".$this->serverJabber;
+							}
+							else
+							{
+								if( strpos($users[$i]['jid'], "@") === false )
+									$users[$i]['jid'] = $users[$i]['jid']."@".$hostDefault;
+							}
+						}
 					}
 				}
 			}
-			
+
 			foreach($users as $tmp)
 			{
-				if ( !array_key_exists($tmp['dn'], $order) )
-					$order[$tmp['dn']] = array();
-
-				if( (strpos($tmp['jid'], "@" )) === false )
+				if ( !array_key_exists($tmp['ou'], $order) )
+					$order[$tmp['ou']] = array();
+
+				if( strpos($tmp['jid'], "@") === false)
 					$tmp['jid'] = $tmp['jid']."@".$this->serverJabber;
 
-				$_SESSION['debug'][] = $order[$tmp['dn']][] = '<data><cn>' . $tmp['cn'] . '</cn><mail>' . $tmp['mail'] .'</mail><uid>' . $tmp['uid'] . '</uid><jid>' . $tmp['jid'] . '</jid><photo>' . $tmp['photo'] . '</photo></data>';
+				$order[$tmp['ou']][] = '<data><ou>'.$tmp['ou'].'</ou><cn>'.$tmp['cn'].'</cn><mail>'.$tmp['mail'].'</mail><uid>'.$tmp['uid'].'</uid><jid>'.$tmp['jid'].'</jid><photo>'.$tmp['photo'].'</photo></data>';
 			}
 			
@@ -118,6 +123,4 @@
 			$return .= '</uids>';
 		}
-		else
-			$return = '<empty/>';
 		
 		return $return;
@@ -128,8 +131,8 @@
         $array_uids = $this->db->get_accounts_acl();
         $count = count($array_uids);
-        $uids_members = array();
+        $members = array();;
         $result = array();
         
-        for($i = 0; $i < $count ;$i+=50)
+        for( $i = 0; $i < $count ; $i+=50 )
         {   
             $partial_uids = array_slice($array_uids,$i,50);
@@ -150,28 +153,32 @@
 	            $orgs = array_unique($orgs);
 
-				foreach( $orgs as $tmp )
-					$result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid, $tmp);
+				foreach( $orgs as $orgB )
+					$result[] = $this->ldap->getUsersLdap("cn=*".$pName."*", $filter_uid, $orgB );
 			}
 			else
-	            $result[] = $this->ldap->list_users_ldap("cn=*".$pName."*", $filter_uid);
+	            $result[] = $this->ldap->getUsersLdap("cn=*".$pName."*", $filter_uid, "" );
         }
 
         if ( is_array($result) )
         {
-          	for($i = 0; $i < count($result); $i++)
-           		if(is_array($result[$i]))
-           			$uids_members = array_merge($uids_members,$result[$i]);
+          	for( $i = 0; $i < count($result); $i++ )
+           		if( is_array($result[$i]) )
+           			$members = array_merge($members,$result[$i]);
         }
-	        
-        if( count($uids_members) > 50 )
+	     
+        if( count($members) > 150)
         {
-        	unset($_SESSION['phpgw_info']['jabberit_messenger']['photo']);	        
-          	return 'Many Results';
+	    	$ou = substr( $this->ou_User, strpos($this->ou_User, "=") + 1 );
+			for($i = 0 ; $i < count($members); $i++ )
+			{
+				if( $ou == $members[$i]['ou'] )
+					$uids_org[] = $members[$i];
+				else
+					if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo']))
+						unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$members[$i]['ou']]);
+			}
+			return $uids_org;
         }            
-        
-        if( count($uids_members) > 0 )
-            return $uids_members;
-        else
-            return 0;  
+		return $members;        
 	}
 	
@@ -191,5 +198,5 @@
 	    $filter_gid = "(gidnumber=". $filter_gid. ")";
 		
-		$result = $this->ldap->list_groups_memberUid($filter_gid);
+		$result = $this->ldap->getGroupsMemberUid($filter_gid);
 
 		if( $result && is_array($result) )
@@ -274,3 +281,4 @@
 	}
 }
+
 ?>
Index: trunk/jabberit_messenger/inc/jabberit_sessions.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/jabberit_sessions.inc.php	(revision 894)
+++ trunk/jabberit_messenger/inc/jabberit_sessions.inc.php	(revision 946)
@@ -55,6 +55,4 @@
 		$_SESSION['phpgw_info']['jabberit_messenger']['use_attribute_jabberit'] = $GLOBALS['phpgw_info']['server']['use_attribute_jabberit'];
 		$_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']		= $GLOBALS['phpgw_info']['server']['attributes_org_ldap_jabberit'];
-		$_SESSION['phpgw_info']['jabberit_messenger']['use_external_participants_jabberit'] = $GLOBALS['phpgw_info']['server']['use_external_participants_jabberit'];
-		$_SESSION['phpgw_info']['jabberit_messenger']['conf_organization_jabberit']			= $GLOBALS['phpgw_info']['server']['conf_organization_jabberit'];		
 		$_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']				= $GLOBALS['phpgw_info']['server']['map_org_realm_jabberit'];
 
Index: trunk/jabberit_messenger/inc/class.uihostsjabber.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.uihostsjabber.inc.php	(revision 915)
+++ trunk/jabberit_messenger/inc/class.uihostsjabber.inc.php	(revision 946)
@@ -53,17 +53,4 @@
 		require_once "load_lang.php";
 
-
-		// Load Ldap;
-		require_once "class.ldap_im.inc.php";
-		
-		$ldap = new ldap_im();
-		
-		$ous = "<option value='-1'>-- ".lang('Select Organization')." --</option>";	
-		if( ($LdapOus = $ldap->listOrganizationsLdap()) )
-		{
-			foreach($LdapOus as $tmp )
-				$ous .= "<option value='".$tmp."'>".$tmp."</option>";
-		}
-		
 		$ConfHosts = $this->bo->getHostsJabber();
 		
@@ -71,20 +58,17 @@
 		{
 			$ConfHosts = unserialize($this->bo->getHostsJabber());
-			$ConfHosts = explode(";", $ConfHosts);
-			natcasesort($ConfHosts);
 		}
 		
 		$value_Organizations_Servers = "";
 		
-		if(is_array($ConfHosts))	
+		if( is_array($ConfHosts) )	
 		{
-			foreach($ConfHosts as $values)
+			foreach($ConfHosts as $itens)
 			{
-				$itens = explode(":", $values);
-			
-				$value_Organizations_Servers .= "<tr id='".$values."' style='width:40%' class='row_off'>";
-				$value_Organizations_Servers .=	"<td>".$itens[0]."</td>";
-				$value_Organizations_Servers .=	"<td>".$itens[1]."</td>";
-				$value_Organizations_Servers .=	"<td><a href='javascript:constructScript.removeHostsJ(\"".$values."\");'>".lang('Delete')."</a></td>";
+				$value_Organizations_Servers .= "<tr id='".$itens['org'].":".$itens['jabberName']."' style='width:40%' class='row_off'>";
+				$value_Organizations_Servers .=	"<td>".$itens['org']."</td>";
+				$value_Organizations_Servers .=	"<td>".$itens['jabberName']."</td>";
+				$value_Organizations_Servers .=	"<td><a href='javascript:constructScript.editHostsJ(\"".$itens['org'].":".$itens['jabberName']."\");'>".lang('Edit')."</a></td>";
+				$value_Organizations_Servers .=	"<td><a href='javascript:constructScript.removeHostsJ(\"".$itens['org'].":".$itens['jabberName']."\");'>".lang('Delete')."</a></td>";				
 				$value_Organizations_Servers .= "</tr>";
 			}
@@ -98,10 +82,11 @@
 													'lang_Back' => lang('Back'),
 												    'lang_Delete' => lang('Delete'),
+												    'lang_Edit' => lang('Edit'),
 												    'lang_Example' => lang('Example'),
+												    'lang_new' => lang('New'),
 												    'lang_Organization' => lang('Organization'),
 													'lang_save' => lang('Save'),
 												    'lang_ServerJabber' => lang('Servers Jabber'),
 													'lang_Registration_Organizations_and_Server_Jabber' => lang("Registration of Organizations and Servers Jabber"),													
-													'options_ous_ldap' => $ous,
 													'value_Organizations_Servers' => $value_Organizations_Servers,
 										));
Index: trunk/jabberit_messenger/inc/hook_admin.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/hook_admin.inc.php	(revision 942)
+++ trunk/jabberit_messenger/inc/hook_admin.inc.php	(revision 946)
@@ -17,8 +17,7 @@
 		'Enable the Expresso Messenger inside of the modules' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uimodule.edit_conf'),
 		'Configuration of authentication attribute by Organization (OU)' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiconforganization.edit_conf'),
-		'External Participants' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiexternals.editParticipantsExternals'),
 		'Restrict group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uigroupslocked.editGroups'),
 		'Free organization for group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uienabledgroups.getGroups'),
-		//'Map organization for realm jabber' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uihostsjabber.edit_conf'),
+		'Map organization for realm jabber' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uihostsjabber.edit_conf'),
 	);
 
Index: trunk/jabberit_messenger/inc/class.ldap_im.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 892)
+++ trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 946)
@@ -17,15 +17,42 @@
 class ldap_im
 {
+	private $attr_org;
+	private $common;
+	private $hostsJabber;
 	private $ldap;
-	private $ldap_host;
 	private $ldap_context;
 	private $ldap_dn;
+	private $ldap_host;
 	private $ldap_pass;
-	private $common;
-	private $jid;
 	private $max_result;
-	private $ou_User;
 	
 	public final function __construct()
+	{
+		// Attributes org ldap;
+		$this->attr_org = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']);
+		
+		// Hosts Jabber
+		$this->hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']);
+		
+		// Result Ldap
+		$this->max_result = 30;
+	}
+
+	public final function __destruct()
+	{
+		if( $this->ldap )
+			ldap_close($this->ldap);
+	}	
+
+	private final function ldapConn()
+	{
+		$this->common = new common();		
+		
+		$GLOBALS['phpgw_info']['server']['ldap_version3'] = true;
+
+		$this->ldap = $this->common->ldapConnect( $this->ldap_host, $this->ldap_dn, $this->ldap_pass, false );
+	}
+	
+	private final function ldapRoot()
 	{
 		$this->ldap_host 	= (isset($_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_host'];
@@ -33,56 +60,65 @@
 		$this->ldap_dn		= (isset($_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
 		$this->ldap_pass	= (isset($_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
-		$this->jid			= $_SESSION['phpgw_info']['jabberit_messenger']['user_jabber'];
-		$this->max_result	= 50;
-	}
-
-	public final function __destruct()
-	{
-		if( $this->ldap )
-			ldap_close($this->ldap);
-	}	
-
-	private final function _connect_ldap()
-	{
-		$this->common = new common();
-		
-		if( !$this->ldap )
-		{
-			$GLOBALS['phpgw_info']['server']['ldap_version3'] = true;
-			$this->ldap = $this->common->ldapConnect( $this->ldap_host,$this->ldap_dn,$this->ldap_pass, false );
-		}
-	}
-	
-	private final function _ldapConnect($refer = false)
-	{
-		function ldapRebindJabberit($ldap_connection, $ldap_url)
-		{
-			$acc = $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['acc'];
-			$pw = $_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['pw'];
+
+		$this->ldapConn();
+	}
+
+	private final function ldapCatalog()
+	{
+		$version3 = true;
+		$refer	= true;
+
+		if(!function_exists('ldap_connect'))
+			return false;
+		
+		if(!$conn = ldap_connect($this->ldap_host))
+			return false;
+
+		if( $version3 )
+			if( !ldap_set_option($conn,LDAP_OPT_PROTOCOL_VERSION,3) )
+				$version3 = false;
+
+		ldap_set_option($conn, LDAP_OPT_REFERRALS, $refer);
+
+		// Bind as Admin
+		if($this->ldap_dn && $this->ldap_pass && !ldap_bind($conn, $this->ldap_dn, $this->ldap_pass))
+			return false;
+		
+		// Bind as Anonymous
+		if(!$this->ldap_dn && !$this->ldap_pass && !@ldap_bind($conn))
+			return false;
 			
-			@ldap_bind($ldap_connection, $acc,$pw);
-		}
-
-		// Using ContactCenter configuration.
-		$this->ldap_host	=	$_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['host'];
-		$this->ldap_context	=	$_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['dn'];
-		$this->ldap_dn		=	$_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['acc'];
-		$this->ldap_pass	=	$_SESSION['phpgw_info']['jabberit_messenger']['ldapManager']['pw'];
-
-		$this->ldap = ldap_connect($this->ldap_host);
-		ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_set_option($this->ldap, LDAP_OPT_REFERRALS, $refer);
-		
-		if ($refer)
-		{
-			ldap_set_rebind_proc($this->ldap, ldapRebindJabberit);
-		}
-		
-		@ldap_bind($this->ldap,$this->ldap_dn,$this->ldap_pass);
-	}
-
-	public final function list_groups_memberUid($pGroup)
-	{
-		$this->_ldapConnect();
+		return $conn;
+	}
+
+	public final function getGroupsLdap($pOrg)
+	{
+		$this->ldapRoot();
+
+		if( $this->ldap )	
+		{
+			$organization = 'ou=' . $pOrg['ou'] .",". $this->ldap_context;
+			$filter = "(&(phpgwAccountType=g)(objectClass=posixGroup))";
+			$justthese = array("cn","gidNumber");
+			$search = ldap_list($this->ldap, $organization, $filter, $justthese);
+			$entry = ldap_get_entries( $this->ldap, $search );
+
+			if( $entry )
+			{					
+				$result_groups = "<ldap>";
+				foreach($entry as $tmp)
+					if( $tmp['gidnumber'][0] != "" )
+						$result_groups .= "<org><cn>".$tmp['cn'][0]."</cn><gid>".$tmp['gidnumber'][0]."</gid></org>";
+				
+				$result_groups .= "</ldap>";						
+			}
+		}
+
+		return $result_groups;
+	}
+
+	public final function getGroupsMemberUid($pGroup)
+	{
+		$this->ldapRoot();
 		
 		if( $this->ldap )
@@ -100,176 +136,7 @@
 	}
 
-	public final function list_participants_externals($pSearch)
-	{
-		$this->_ldapConnect(true);
-		
-		$mail = $pSearch['mail'];
-		
-		if( $this->ldap )
-		{
-			$filter = "(&(phpgwaccounttype=u)(mail=".$mail."))";
-			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");
-			$search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
-			$entry1 = ldap_get_entries($this->ldap,$search);
-			$entry = ldap_first_entry( $this->ldap, $search );
-		}			
-		
-		if( $entry1['count'] > 0 )
-		{
-			$i = 0;
-			$result_user = array();
-			$result = array();
-
-			while($entry)
-			{
-			
-				if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' )
-				{
-					$result['uidnumber'] = @ldap_get_values($this->ldap, $entry, 'uidnumber');			
-					$result['mail'] = @ldap_get_values($this->ldap, $entry, 'mail');
-					$result['uid'] = @ldap_get_values($this->ldap, $entry, 'uid');
-					$result['cn'] = @ldap_get_values($this->ldap, $entry, 'cn');
-
-					foreach ( $result as $key => $value )
-						$result_user[$i][$key] = $value[0];
-
-					$ou = explode('dc=', $entry1[$i]['dn']);
-					$ou = explode("ou=",$ou[0]);
-					$ou = array_pop($ou);
-					$result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));
-
-					$result_user[$i]['photo'] = 0;
-
-					$photo = @ldap_get_values_len($this->ldap, $entry, 'jpegphoto');
-
-					if ( $photo )
-					{
-						$result_user[$i]['photo'] = 1;
-						$_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result_user[$i]['uid'])] = $photo[0];
-					}
-
-					$i++;
-				}				
-				$entry = ldap_next_entry($this->ldap,$entry);	
-			}
-			
-			$return  = "<uids>";
-			$return .= "<".$result_user[0]['dn']."><data>";
-			$return .= "<cn>".$result_user[0]['cn']."</cn>";
-			$return .= "<mail>".$result_user[0]['mail']."</mail>";
-			$return .= "<uid>".$result_user[0]['uid']."</uid>";
-			$return .= "<photo>".$result_user[0]['photo']."</photo>";									
-			$return .= "</data></".$result_user[0]['dn'].">";			
-			$return .= "</uids>";
-
-			return $return;		
-		}
-		
-		return '<empty/>';
-	}
-
-	public final function list_users_ldap( $search, $uidnumber, $ous = false )
-	{
-		$this->_connect_ldap();
-	
-		if( $this->ldap )
-		{
-			$filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))";
-			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");
-			// SERPRO
-			//$justthese = array("uid","uidNumber","cn","mail","description","phpgwAccountVisible","dn","jpegPhoto");
-	
-			if( $ous != false )
-				$search = ldap_search($this->ldap,$ous.",".$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
-			else
-				$search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
-
-			$entry1 = ldap_get_entries($this->ldap,$search);
-			$entry  = ldap_first_entry($this->ldap,$search);
-		}
-
-		if( $entry1['count'] > 0 )
-		{
-			if( count($entry1) < $this->max_result )
-			{
-				$i = 0;
-				$result_user = array();
-				$result = array();
-
-				while($entry)
-				{
-				
-					if ( $entry1[$i]['phpgwaccountvisible'][0] != '-1' )
-					{
-						$result['uidnumber'] = @ldap_get_values($this->ldap, $entry, 'uidnumber');			
-						$result['mail'] = @ldap_get_values($this->ldap, $entry, 'mail');
-						$result['uid'] = @ldap_get_values($this->ldap, $entry, 'uid');
-						$result['jid'] = @ldap_get_values($this->ldap, $entry, 'uid');
-						$result['cn'] = @ldap_get_values($this->ldap, $entry, 'cn');
-						// SERPRO
-						//$result['description'] = @ldap_get_values($this->ldap, $entry, 'description');
-
-						foreach ( $result as $key => $value )
-							$result_user[$i][$key] = $value[0];
-
-						$ou = explode('dc=', $entry1[$i]['dn']);
-						$ou = explode("ou=",$ou[0]);
-						$ou = array_pop($ou);
-						$result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));
-
-						$result_user[$i]['photo'] = 0;
-						$photo = @ldap_get_values_len($this->ldap, $entry, 'jpegphoto');
-						if ( $photo )
-						{
-							$result_user[$i]['photo'] = 1;
-							$_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result_user[$i]['uid'])] = $photo[0];
-						}
-						
-						$organization = explode(",", $_SESSION['phpgw_info']['jabberit_messenger']['attributes_org_ldap_jabberit']);
-
-						if(is_array($organization))
-						{
-							foreach($organization as $attr)
-							{
-								$tmp = explode(";",$attr);
-								if( strtolower(trim($tmp[0])) == strtolower(trim($result_user[$i]['dn'])) )
-								{
-									switch(strtolower(trim($tmp[1])))
-									{
-										case "mail" :
-												$uid = $result_user[$i]['mail'];
-												$uid = substr($uid,0,strpos($uid,"@"));	
-												$result_user[$i]['uid'] = $uid;
-												break;
-	
-										case "description" :
-												// SERPRO
-												// parte antes do arroba; 
-												$result_user[$i]['uid'] = $result_user[$i]['description']; 										
-												break;
-									}
-								}
-							}
-						}
-						
-						$i++;
-					}				
-					$entry = ldap_next_entry($this->ldap,$entry);	
-				}
-				
-				return $result_user;
-			}
-			else
-			{
-				return "Many Results";
-			}
-		}
-		return 0;
-	}
-	
-	public final function listOrganizationsLdap()
-	{
-
-		$this->_connect_ldap();
+	public final function getOrganizationsLdap()
+	{
+		$this->ldapRoot();
 	
 		if( $this->ldap )
@@ -287,29 +154,139 @@
 		return $result_org;
 	}
-	
-	public final function getGroupsLdap($pOrg)
-	{
-		$this->_ldapConnect(true);
-		$organization = 'ou=' . $pOrg['ou'] .",". $this->ldap_context;
- 		
-		if( $this->ldap )	
-		{
-			$filter = "(&(phpgwAccountType=g)(objectClass=posixGroup))";
-			$justthese = array("cn","gidNumber");
-			$search = ldap_list($this->ldap, $organization, $filter, $justthese);
+
+	public final function getUsersLdap( $search, $uidnumber, $ous = false)
+	{
+		// Ldap Principal
+		$ldapRoot = $this->getUsersLdapRoot($search, $uidnumber, $ous);
+		
+		if( !$ous )
+		{
+			// Ldap Outros
+			$ldapCatalog = $this->getUsersLdapCatalog( $search );
+			$ldapRoot = array_merge( $ldapRoot, $ldapCatalog ); 		
+		}
+		
+		return $ldapRoot;
+	}
+
+	private final function getUsersLdapCatalog( $search )
+	{
+		$confHosts	= $this->hostsJabber;
+		$result = array();
+		$return	= array();
+		$conn	= "";		
+
+		for($i = 0; $i < count($confHosts); $i++ )
+		{
+			$this->ldap_host 	= $confHosts[$i]['serverLdap'];
+			$this->ldap_context = $confHosts[$i]['contextLdap'];
+			$this->ldap_dn		= $confHosts[$i]['user'];
+			$this->ldap_pass	= $confHosts[$i]['password'];
+
+			$conn = $this->ldapCatalog();
+
+			if( $conn )
+			{
+				$filter = "(&(phpgwaccounttype=u)(".$search ."))";
+				$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");								
+				$search1 = @ldap_search($conn, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1);
+				$entry1 = @ldap_get_entries( $conn, $search1 );
+
+				$result = $this->resultArray($entry1, $conn );
+
+				if( count($return) > 0 )
+		          	$return = array_merge($return, $result);
+				else
+					$return = $result;				
+
+		        unset($result);	
+
+		        ldap_close($conn);
+			}
+		}
+		
+		return $return;
+	}
+
+	private final function getUsersLdapRoot( $search, $uidnumber, $ous = false )
+	{
+		$this->ldapRoot();
+		$result = array();
+
+		if( $this->ldap )
+		{
+			$searchRoot = ( $ous ) ? $ous.",".$this->ldap_context : $this->ldap_context ;
+			$filter = "(&(phpgwaccounttype=u)(|".$uidnumber.")(".$search ."))";
+			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");								
+			$search = ldap_search($this->ldap, $searchRoot, $filter, $justthese, 0, $this->max_result + 1);
 			$entry = ldap_get_entries( $this->ldap, $search );
 
-			if( $entry )
-			{					
-				$result_groups = "<ldap>";
-				foreach($entry as $tmp)
-					if( $tmp['gidnumber'][0] != "" )
-						$result_groups .= "<org><cn>".$tmp['cn'][0]."</cn><gid>".$tmp['gidnumber'][0]."</gid></org>";
-				
-				$result_groups .= "</ldap>";						
-			}
-		}
-
-		return $result_groups;
+			$result = $this->resultArray($entry, $this->ldap );
+		}		
+
+		return $result;
+	}
+	
+	private final function resultArray($pArray, $pConn)
+	{
+		$entry = $pArray;
+		$result = array();
+
+		$j = 0;
+		for($i = 0 ; $i < $entry['count']; $i++)
+		{
+			if ( $entry[$i]['phpgwaccountvisible'][0] != '-1' )
+			{
+				$result[$j]['uidnumber'] = $entry[$i]['uidnumber'][0];			
+				$result[$j]['mail']	=  $entry[$i]['mail'][0];
+				$result[$j]['uid']	=  $entry[$i]['uid'][0];
+				$result[$j]['jid']	= $entry[$i]['uid'][0];
+				$ou = explode("dc=", $entry[$i]['dn']);
+				$ou = explode("ou=",$ou[0]);
+				$ou = array_pop($ou);
+				$result[$j]['ou']	= strtoupper(substr($ou,0,strlen($ou)-1));					
+				if( $entry[$i]['jpegphoto'][0] )
+				{
+					$result[$j]['photo'] = "1";
+					$filterPhoto = "(objectclass=*)";
+					$photoLdap = ldap_read($pConn, $entry[$i]['dn'], $filterPhoto, array("jpegPhoto"));
+					$firstEntry = ldap_first_entry($pConn, $photoLdap);
+					$photo = ldap_get_values_len($pConn, $firstEntry, "jpegPhoto");
+					$_SESSION['phpgw_info']['jabberit_messenger']['photo'][trim($result[$j]['ou'])][trim($result[$j]['uid'])] = $photo[0];
+				}
+				else
+					$result[$j]['photo'] = "0";
+
+				$result[$j++]['cn']	= $entry[$i]['cn'][0];
+			}
+		
+			$organization = $this->attr_org;
+	
+			if(is_array($organization))
+			{
+				foreach($organization as $attr)
+				{
+					$tmp = explode(";",$attr);
+					if( strtolower(trim($tmp[0])) == strtolower(trim($result[$i]['dn'])) )
+					{
+						switch(strtolower(trim($tmp[1])))
+						{
+							case "mail" :
+									$uid = $result[$i]['mail'];
+									$uid = substr($uid,0,strpos($uid,"@"));	
+									$result[$i]['uid'] = $uid;
+									break;
+	
+							case "description" :
+									// SERPRO
+									// parte antes do arroba; 
+									$result[$i]['uid'] = $result[$i]['description']; 										
+									break;
+						}
+					}
+				}
+			}
+		}
+		return $result;
 	}
 }
Index: trunk/jabberit_messenger/inc/class.db_im.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.db_im.inc.php	(revision 896)
+++ trunk/jabberit_messenger/inc/class.db_im.inc.php	(revision 946)
@@ -14,4 +14,5 @@
 define('PHPGW_API_INC','../phpgwapi/inc');
 require_once(PHPGW_API_INC . '/class.db.inc.php');
+require_once "class.fileDefine.inc.php";
 	
 class db_im
@@ -25,7 +26,9 @@
 	private $db_type;
 	private $user_id;
+	private $fileD;
 	
 	public final function __construct()
 	{
+		$this->fileD = new fileDefine();
 		$this->db_name = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_name'];
 		$this->db_host = $_SESSION['phpgw_info']['jabberit_messenger']['server']['db_host'];
@@ -51,4 +54,24 @@
 	}	
 
+	public final function editHostJabber($pItem)
+	{
+		$hostsJabber = unserialize($this->getHostsJabber());
+		$findHosts	= explode(":", $pItem['item']);
+		$return = "";	
+		
+		for( $i = 0 ; $i < count($hostsJabber); $i++ )
+			if( $hostsJabber[$i]['org'] == $findHosts[0] && $hostsJabber[$i]['jabberName'] == $findHosts[1] )
+			{
+				$return = "org:" . $hostsJabber[$i]['org'] . ";" .
+						  "jabberName:" . $hostsJabber[$i]['jabberName'] . ";" .						  	 
+						  "serverLdap:" . $hostsJabber[$i]['serverLdap'] . ";" .
+						  "contextLdap:" . $hostsJabber[$i]['contextLdap'] . ";" .
+						  "user:" . $hostsJabber[$i]['user'] . ";" .
+						  "password:" . $hostsJabber[$i]['password'] ;						  						  						  						  
+			}
+
+		return trim($return);
+	}
+	
 	public final function getApplicationsEnabled()
 	{
@@ -338,57 +361,63 @@
 	public final function setHostJabber($pParam)
 	{
-		$organization	= $pParam['organization'];
-		$hostJabber		= $pParam['hostJabber'];
-	
+		$confHostsJabber =  array();
+
+		foreach($pParam as $key => $itens)
+			$confHostsJabber[$key] = ( $key === 'org' ) ? strtoupper($itens) : $itens;
+
 		if( $this->db )
 		{
 			$query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'map_org_realm_jabberit';";
 			
-			if($this->db->query($query))
-			{
-			
-				if ( $this->db->query($query) )
-				{	
-					while($this->db->next_record())
-						$result[] = $this->db->row();
-				}
-				
-				if( count($result) == 0 )
-				{
-					$confHostJabber = strtoupper($organization).":".$hostJabber;
-					$return = "<return><confServer ou='".strtoupper($organization)."' serverName='".$hostJabber."'>".$confHostJabber."</confServer></return>";
-					$query = "INSERT INTO phpgw_config(config_app,config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($confHostJabber)."')";
-					$_SESSION['debug']['gravar'] = $confHostJabber;
-					$this->db->query($query);					
-				}
+			if( $this->db->query($query) )
+			{
+				while($this->db->next_record())
+					$result[] = $this->db->row();				
+			}
+			
+			if( count($result) == 0 )
+			{
+				$return = "<return><confServer ou='".strtoupper($confHostsJabber['org'])."' serverName='".$confHostsJabber['jabberName']."'>".strtoupper($confHostsJabber['org']).":".$confHostsJabber['jabberName']."</confServer></return>";				
+				$hostsJabber[0] = $confHostsJabber;
+				
+				$this->fileD->ldapExternal($hostsJabber);
+				 
+				$query = "INSERT INTO phpgw_config(config_app, config_name, config_value) VALUES('phpgwapi','map_org_realm_jabberit','".serialize($hostsJabber)."')";
+				$this->db->query($query);				
+			}
+			else
+			{
+				$resultQuery = unserialize($result[0]['config_value']);	
+				$foundOrg = false;
+				
+				foreach($resultQuery as $key => $itens)
+				{
+					$foundString = array_search($confHostsJabber['org'], $itens);
+					if( $foundString )
+					{
+						$foundOrg = $foundString;
+						$ky = $key;
+					}
+				}	
+
+				if( ! $foundOrg )
+					$resultQuery[] = $confHostsJabber;	
 				else
-				{
-					$confHostJabber = unserialize($result[0]['config_value']);
-					$OrgHosts = explode(";", $confHostJabber);
-					$stringSearch = strtoupper($organization).":".$hostJabber;
-					$FoundString = array_search($stringSearch, $OrgHosts);
-
-					if( $FoundString === false)
-						$confHostJabber .= ";" . $stringSearch;
-				
-					$items = explode(";", $confHostJabber);
-					natcasesort($items);
-											
-					$return = "<return>";
-					foreach($items as $tmp)
-					{
-						$aux = explode(":",$tmp);
-						$return .= "<confServer ou='".$aux[0]."' serverName='".$aux[1]."'>".$tmp."</confServer>";
-					}					
-					$return .= "</return>";
-
-					$query = "UPDATE phpgw_config SET config_value = '".serialize($confHostJabber)."' WHERE config_name = 'map_org_realm_jabberit';";
-					$this->db->query($query);
-				}
-				
-				return $return;
-			}
-		}
-
+					$resultQuery[$ky] = $confHostsJabber;
+
+				$return = "<return>";
+				
+				foreach( $resultQuery as $itens )
+					$return .= "<confServer ou='".$itens['org']."' serverName='".$itens['jabberName']."'>".$itens['org'].":".$itens['jabberName']."</confServer>";
+				
+				$return .= "</return>";
+				
+				$this->fileD->ldapExternal($resultQuery);
+				
+				$query = "UPDATE phpgw_config SET config_value = '".serialize($resultQuery)."' WHERE config_name = 'map_org_realm_jabberit';";
+				$this->db->query($query);
+			}
+			return $return;
+		}	
 		return false;
 	}
@@ -466,90 +495,4 @@
 	}
 	
-	public final function setUseParticipantsExternal($pFlag)
-	{
-		$flag = $pFlag['value'];
-		$return = "";
-		
-		if( $this->db )
-		{
-			$query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'use_external_participants_jabberit';";
-
-			if ( $this->db->query($query) )
-			{	
-				while($this->db->next_record())
-					$result[] = $this->db->row();
-			}
-
-			if(count($result) == 0)
-			{
-				$query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','use_external_participants_jabberit','".$flag."')";
-				$this->db->query($query);
-				return true;
-			}
-			else
-			{
-				$query = "UPDATE phpgw_config SET config_value = '".$flag."' WHERE config_app = 'phpgwapi' AND config_name = 'use_external_participants_jabberit'";
-				$this->db->query($query);
-				return true;
-			}
-		}
-		return false;
-	}
-	
-	public final function setOrganization($pOrganization)
-	{
-		$organization = $pOrganization['organization'];
-		$orgConfiguration = "";
-		
-		if( $this->db )
-		{
-			$query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'conf_organization_jabberit'";
-
-			if ( $this->db->query($query) )
-			{	
-				while($this->db->next_record())
-					$result[] = $this->db->row();
-		
-				if(count($result) > 0)
-					$orgConfiguration = $result[0]['config_value'];
-			}
-
-			if( trim($orgConfiguration) == "" )
-			{
-				$query = "INSERT INTO phpgw_config(config_app,config_name,config_value) VALUES('phpgwapi','conf_organization_jabberit','".$organization."')";
-				$this->db->query($query);
-				
-				return "<return><ou attr='".$organization."'>".$organization."</ou></return>";
-			}
-			else
-			{
-				$orgAux = explode(",",$orgConfiguration);
-				
-				foreach( $orgAux as $tmp )
-				{
-					if(strtolower(trim($tmp)) === strtolower(trim($organization)))
-						return false;
-				}
-
-				$value = $orgConfiguration . "," . $organization;
-				$query = "UPDATE phpgw_config SET config_value = '".$value."' WHERE config_app = 'phpgwapi' AND config_name = 'conf_organization_jabberit'";
-				$this->db->query($query);
-
-				$return = explode(",",$value);
-				natcasesort($return);
-
-				$values = "<return>";
-				
-				foreach($return as $tmp)
-					$values .= "<ou attr='" . $tmp . "'>" . $tmp . "</ou>";
-					
-				$values .= "</return>";
-				
-				return $values;			
-			}
-		}
-		return false; 
-	}
-
 	public final function removeAttributesLdap($pOrg)
 	{
@@ -610,21 +553,32 @@
 				{
 					$confHostsOrgs = unserialize($result[0]['config_value']);
-					$confHostsOrgs = explode(";", $confHostsOrgs);					
-					$foundValue = array_search($pItem['item'], $confHostsOrgs);					
-	
-					if( $foundValue !== false )
-						array_splice($confHostsOrgs, $foundValue, 1);
-					
-					if(count($confHostsOrgs) > 0 )
+					$hosts = explode(":", $pItem['item']);
+					$key = "";
+
+					if( count($confHostsOrgs) > 0 )
 					{
-						foreach( $confHostsOrgs as $values )
-							$stringHostsOrgs .= $values . ";";
-	
-						$stringHostsOrgs = substr($stringHostsOrgs, 0, strlen($stringHostsOrgs) -1 );
-						$query = "UPDATE phpgw_config SET config_value = '".serialize($stringHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';";
+						for( $i = 0; $i < count($confHostsOrgs); $i++)
+							if( $confHostsOrgs[$i]['org'] == $hosts[0] && $confHostsOrgs[$i]['jabberName'] == $hosts[1])
+								$key = $i;	
+
+						array_splice($confHostsOrgs, $key, 1);
+				
+						if(count($confHostsOrgs) > 0)
+						{					
+							$this->fileD->ldapExternal($confHostsOrgs);
+							$query = "UPDATE phpgw_config SET config_value = '".serialize($confHostsOrgs)."' WHERE config_name = 'map_org_realm_jabberit';";
+						}
+						else
+						{
+							$this->fileD->ldapExternal("");
+							$query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';";
+						}
 					}
 					else
+					{	
+						$this->fileD->ldapExternal("");						
 						$query = "DELETE FROM phpgw_config WHERE config_name = 'map_org_realm_jabberit';";
-					
+					}
+
 					if( $this->db->query($query) )
 						return "true";
@@ -692,46 +646,5 @@
 		return $return;
 	}
-	
-	public final function removeParticipantsExternal($pOrganization)
-	{
-		
-		$organization = $pOrganization['participants'];	
-		
-		if( $this->db )
-		{
-			$query = "SELECT * from phpgw_config WHERE config_app = 'phpgwapi' and config_name = 'conf_organization_jabberit'";
-				
-			if ( $this->db->query($query) )
-			{	
-				while( $this->db->next_record() )
-					$result[] = $this->db->row();
-		
-				if( count($result) > 0 )
-					$valueDB = $result[0]['config_value'];
-			}
-
-			$OrgDB = explode(",", $valueDB);
-			$newValue = ""; 
-
-			foreach($OrgDB as $tmp)
-			{
-				if( strtolower(trim($tmp)) != strtolower(trim($organization)))
-					$newValue .= $tmp . ",";
-			}
-			
-			$newValue = substr($newValue, 0,(strlen($newValue) -1 ));
-			
-			if( trim($newValue) != "")
-				$query = "UPDATE phpgw_config SET config_value = '".$newValue."' WHERE config_app = 'phpgwapi' AND config_name = 'conf_organization_jabberit'";
-			else
-				$query = "DELETE from phpgw_config where config_name = 'conf_organization_jabberit'";
-				
-			if( $this->db->query($query))
-				return true;
-			else
-				return false;
-		}
-		return false;	
-	}
+
 }
 ?>
Index: trunk/jabberit_messenger/inc/getphoto.php
===================================================================
--- trunk/jabberit_messenger/inc/getphoto.php	(revision 697)
+++ 	(revision )
@@ -1,213 +1,0 @@
-<?php
-  /***************************************************************************\
-  *  Expresso - Expresso Messenger                                            *
-  *  	- Alexandre Correia / Rodrigo Souza							          *
-  *  	- JETI - http://jeti-im.org/										  *
-  * ------------------------------------------------------------------------- *
-  *  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.                                               *
-  \***************************************************************************/
-
-function ldap_rebind($ldap_connection, $ldap_url){
-	include('conf_Ldap_Photos.php');
-	$handle   = unserialize(base64_decode($CONF_SERVER));
-	@ldap_bind($ldap_connection, $handle['dn'],$handle['passwd']);
-}
-
-class ldapPhoto
-{
-	private $host;
-	private $dn;
-	private $passwd;
-	private $refer;
-	private $user_referral;
-	private $password_referral;
-	private $conn;
-	private $context;
-	private $photo_user = array();
-	private $handle;
-
-
-	function __construct()
-	{
-		require_once('conf_Ldap_Photos.php');
-		$handle   = unserialize(base64_decode($CONF_SERVER));
-
-		$this->host		= $handle['host'];
-		$this->context	= $handle['context'];
-		$this->dn		= $handle['dn'];
-		$this->passwd	= $handle['passwd'];
-		
-		$this->refer  	= true;
-		$this->version3 = true;
-	}
-
-
-	private final function ldapConnect()
-	{
-		if(!function_exists('ldap_connect'))
-		{
-			printf("<b>Erro : Ldap Não suportado %s</b><br>" , $this->host);
-			return False;
-		}
-		
-		if(!$this->conn = ldap_connect($this->host))
-		{
-			printf("<b>Erro: não pode conectar no servidor ldap %s!</b><br>", $this->host);
-			return False;
-		}
-
-		if( $this->version3 )
-		{
-			if( !ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3) )
-				$this->version = false;
-		}
-		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->refer);
-
-		// verifica refer
-		if( $this->refer )
-		{
-			@ldap_set_rebind_proc($this->conn, ldap_rebind);
-		}
-		
-		// bind as admin
-		if($this->dn && $this->passwd && !ldap_bind($this->conn, $this->dn, $this->passwd)){
-			echo "<center><b>ExpressoLivre indisponível no momento</b></center>";
-			return False;
-		}
-
-		// bind as anonymous
-		if(!$this->dn && !$this->passwd && !@ldap_bind($this->conn))
-		{
-			echo "<center><b>ExpressoLivre indisponível no momento</b></center>";
-			return False;
-		}						
-	}
-	
-	public final function getNameOrganization($pUid, $pCharset)
-	{
-		$this->ldapConnect();
-		
-		if( $this->conn )
-		{
-			$filter = "(&(phpgwaccounttype=u)(uid=".$pUid.")(!(phpgwaccountvisible=-1)))";
-			$justthese = array("uid","cn","dn");
-			$search = ldap_search($this->conn,$this->context,$filter,$justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-			$cn = $entry[0]['cn'][0];
-			$ou = explode("dc=", $entry[0]['dn']);
-			$ou = explode("ou=",$ou[0]);
-			$ou = array_pop($ou);
-			$dn = strtoupper(substr($ou,0,strlen($ou)-1));
-
-			$return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn);
-
-			if( $pCharset === "1" )
-				return $return;
-			else
-				return mb_convert_encoding($return, "ISO-8859-1", "UTF-8");
-
-			$return = utf8_encode("Nome : Não Identificado ;Organização : Não Identificado");			
-
-			if( $pCharset === 1 )
-				return $return;
-			else
-				return mb_convert_encoding($return, "ISO-8859-1", "UTF-8");
-		}
-	}
-	
-	public final function getPhotoLdap($uid)
-	{
-		$this->ldapConnect();
-		if( $this->conn )
-		{
-			$filter = "(&(phpgwaccounttype=u)(uid=".$uid.")(!(phpgwaccountvisible=-1)))";
-			$justthese = array("uid","jpegPhoto");
-			$search = ldap_search($this->conn,$this->context,$filter,$justthese);
-			$entry1 = ldap_get_entries($this->conn,$search);
-			$entry = ldap_first_entry( $this->conn, $search );
-			if( $entry1['count'] > 0 )
-			{
-				$i = 0;
-				$photo = "";
-				$return_photo = "";
-				$photo = @ldap_get_values_len($this->conn, $entry, 'jpegphoto');
-				if ($photo)
-					$return_photo = $photo[0];								
-				return $return_photo;
-			}
-		}
-		return false;
-	}
-	
-	public final function getPhotoSession($pUid)
-	{
-		if(isset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid]))
-		{
-			$photo = imagecreatefromstring($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid]);
-			
-			header("Content-Type: image/jpeg");
-			$width = imagesx($photo);
-			$height = imagesy($photo);
-			$twidth = 60;
-			$theight = 80;
-			$small_photo = imagecreatetruecolor ($twidth, $theight);
-			imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
-			imagejpeg($small_photo,'',100);
-			
-			unset($_SESSION['phpgw_info']['jabberit_messenger']['photo'][$pUid]);	
-			return;	
-		}
-	}
-}
-
-if(trim($_REQUEST['uid']) != "")
-{
-	$uid = trim($_REQUEST['uid']);
-	$a = new ldapPhoto();
-	
-	if( strpos($uid,"@"))
-	{
-		$uid = substr($uid, 0, strpos($uid,"@"));	
-		$photo = $a->getPhotoLdap($uid);
-		$photoWidth = 70;
-		$photoHeight = 90;
-		$newImage = imagecreatetruecolor($photoWidth,$photoHeight);		
-
-		if($photo)
-		{
-			$photo = imagecreatefromstring($photo);
-			imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));
-		}
-		else
-		{
-			$photo = @imagecreatefrompng("../templates/default/images/photo.png");
-			imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));
-		}
-
-		ob_start();
-		imagepng($newImage);
-		$imagePhoto = ob_get_contents();
-		imagedestroy($newImage);
-		ob_end_clean();
-		printf("%s",base64_encode($imagePhoto));
-	}
-	else
-	{
-		$a->getPhotoSession($uid);
-	}
-}
-
-if(trim($_POST['jid']) != "")
-{
-	$jid = trim($_POST['jid']);
-	if( strpos($jid,"@"))
-		$jid = substr($jid, 0, strpos($jid,"@"));
-	$charset = trim($_POST['charset']);
-	$a = new ldapPhoto();
-	
-	printf("%s",$a->getNameOrganization($jid, $charset));
-}
-?>
Index: trunk/jabberit_messenger/inc/class.FileDefine.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.FileDefine.inc.php	(revision 551)
+++ 	(revision )
@@ -1,71 +1,0 @@
-<?php
- /***************************************************************************\
-  *  Expresso - Expresso Messenger                                            *
-  *  	- Alexandre Correia / Rodrigo Souza							          *
-  *  	- JETI - http://jeti-im.org/										  *
-  * ------------------------------------------------------------------------- *
-  *  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 FileDefine
-{
-
-	public final function getParams($pParam)
-	{
-		$array_values = explode("\n", $pParam['val']);	
-		$infoServer = array();
-
-		foreach($array_values as $tmp )
-		{
-			$nvalue = explode(";", $tmp);
-			
-			switch(trim($nvalue[0]))
-			{
-				case "JETTI_SERVER_LDAP_JABBERIT" :
-							$infoServer['host'] = $nvalue[1];							
-							break;			
-			
-				case "JETTI_CONTEXT_LDAP_JABBERIT" :	
-							$infoServer['context'] = $nvalue[1];
-							break;
-			
-				case "JETTI_USER_LDAP_JABBERIT" :
-							$infoServer['dn'] = $nvalue[1];
-							break;
-			
-				case "JETTI_PASSWORD_LDAP_JABBERIT" :
-							$infoServer['passwd'] = $nvalue[1];				
-							break;
-			}
-		}
-		
-		$this->writeFile($infoServer);
-	}
-
-	private final function writeFile($pContent)
-    {
- 	
-		$filename = dirname(__FILE__).'/conf_Ldap_Photos.php';
-		$caracter = "$";
-		$content = "<?php ".$caracter."CONF_SERVER="."\"" . base64_encode(serialize($pContent)) ."\""." ?>";
-
-		if (!$handle = fopen($filename, 'w'))
-		{
-			echo "Não foi possível abrir o arquivo : \n($filename)";
-			exit;
-		}
-		
-		if (fwrite($handle, $content) === FALSE)
-		{
-			echo "Não foi possível escrever no arquivo : \n($filename)";
-			exit;
-		}
-		
-		echo "Arquivo : \n $filename \ncriado com sucesso !!";
-		fclose($handle);
-    }
-}
-?>
Index: trunk/jabberit_messenger/inc/class.uiexternals.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.uiexternals.inc.php	(revision 891)
+++ 	(revision )
@@ -1,114 +1,0 @@
-<?php
-  /***************************************************************************\
-  *  Expresso - Expresso Messenger                                            *
-  *  	- Alexandre Correia / Rodrigo Souza							          *
-  * ------------------------------------------------------------------------- *
-  *  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 uiexternals
-{
-	
-	public $public_functions = array(
-		'backPage' => True,
-		'editParticipantsExternals' => True,
-	);
-	
-	public final function editParticipantsExternals()
-	{
-		if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
-		{
-			$GLOBALS['phpgw']->redirect_link('/index.php');
-		}		
-
-		$GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') . ' - ' . lang('Config External Participants');
-		
-		$_SESSION['phpgwinfo']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
-    	$_SESSION['phpgwinfo']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
-    	$_SESSION['phpgwinfo']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
-    	$_SESSION['phpgwinfo']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
-    	$_SESSION['phpgwinfo']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 
-    	$_SESSION['phpgwinfo']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];			
-
-
-		$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
-		$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
-
-
-		$GLOBALS['phpgw']->common->phpgw_header();
-		echo parse_navbar();
-
-		$organizations = explode(",",$GLOBALS['phpgw_info']['server']['conf_organization_jabberit']);
-		natcasesort($organizations);
-		
-		foreach($organizations as $tmp)
-		{
-			if( $tmp != "" )
-			{
-				$orgs .= "<tr id='".$tmp."' style='width:40%' class='row_off'>";
-				$orgs .= "<td>".$tmp."</td>";
-				$orgs .= "<td><a href=\"javascript:constructScript.removePartExternal('".$tmp."');\">Excluir</a>";
-				$orgs .= "</td></tr>";
-			}
-		}
-		
-		$pExternal = $GLOBALS['phpgw_info']['server']['use_external_participants_jabberit'];
-
-		if( $GLOBALS['phpgw_info']['server']['use_external_participants_jabberit'] === "true")
-		{
-			$optionExternal = "<option value='false'>".lang('No')."</option>".
-							  "<option value='true' selected>".lang('Yes')."</option>";
-			$flagInputs = "selected=\"false\"";
-		}
-		else
-		{
-			$optionExternal = "<option value='false' selected>".lang('No')."</option>".
-							  "<option value='true'>".lang('Yes')."</option>";
-			$flagInputs = "selected=\"true\"";							  
-		}
-		
-		// Load Language;
-		require_once "load_lang.php";
-		
-		$GLOBALS['phpgw']->template->set_file(array('jabberit_messenger'=>'confExternals.tpl'));
-		$GLOBALS['phpgw']->template->set_block('jabberit_messenger','confOrg');	
-		$teste = $GLOBALS['phpgw']->template->set_var(array(
-										'action_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uiexternals.backPage'),
-										'attributes_list' => '',			
-										'lang_add' => 'Adicionar',
-										'lang_Back' => 'Voltar',
-										'lang_cancel' => lang('Cancel'),
-										'lang_Informe_as_Organizacoes_Externas' => 'Informe as Organizações Externas',
-										'lang_Cadastrar_Organizacao' => 'Cadastrar Organização',
-										'lang_Habilitar_Participantes_Externos' => 'Habilitar Participantes Externos',
-										'lang_Delete' => lang('Delete'),										
-										'lang_save' => lang('Save'),
-										'lang_Organization' => lang('Organization'),
-										'lang_Organizacoes_Cadastradas' => 'Organizações Cadastradas',
-										'organizations_attributes' => $orgs,
-										'value_flag' => $flagInputs,
-										'value_use_external_participants_jabberit' => $optionExternal,
-										));
-	
-		$GLOBALS['phpgw']->template->pparse('out','confOrg');
-	}	
-	
-	public final function backPage()
-	{
-		if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
-		{
-			$GLOBALS['phpgw']->redirect_link('/index.php');
-		}		
-		
-		if ($_POST['cancel'])
-		{
-			$GLOBALS['phpgw']->redirect_link('/admin/index.php');
-		}
-
-		$GLOBALS['phpgw']->redirect_link('/admin/index.php');
-	}
-}
-?>
Index: trunk/jabberit_messenger/js/load.js
===================================================================
--- trunk/jabberit_messenger/js/load.js	(revision 868)
+++ trunk/jabberit_messenger/js/load.js	(revision 946)
@@ -469,36 +469,4 @@
 	}
 
-	function openWindowParticipantsExternal()
-	{
-		if( arguments.length > 0)
-		{
-			var element = arguments[0]; 
-
-			if( externalParticipantsJabberit != "" )
-			{			
-				var orgPartExternal = externalParticipantsJabberit.split(",");
-				
-				var _splash = top.document.createElement('span');
-					_splash.setAttribute('id','fast_splash_jabberit');
-					_splash.style.backgroundColor = 'dedede';
-					_splash.style.position = 'absolute';
-					_splash.style.display = 'block';
-					_splash.style.width = '200px';
-					_splash.style.height = 'auto';
-					_splash.style.margin = ( !is_ie ) ? '0px 5px 0px 130px' : '20px 0px 0px 0px';
-					_splash.style.zIndex = '99999';
-					_splash.style.border = '2px outset #000';
-					_splash.onmouseout = function(){ _showhidden.hiddenObject(false); };
-					_splash.onmouseover = function(){ _showhidden.hiddenObject(true); };
-				
-					for(var i = 0; i < orgPartExternal.length; i++)
-						_splash.innerHTML += '<div style="margin:5px;border-bottom:1px dashed #000;cursor:default !important;">' + (i + 1) + " - " + orgPartExternal[i] + '</div>';	
-					
-				_showhidden.action('onmouseover', 'onmouseout', _splash);
-				element.appendChild(_splash);
-			}
-		}
-	}
-
 	function preferences()
 	{
@@ -839,5 +807,4 @@
 	Load.prototype.getElement		= getElementStatus;
 	Load.prototype.keyPress			= keyPressSearch;
-	Load.prototype.openWinParExt	= openWindowParticipantsExternal;
 	Load.prototype.search			= searchUser;
 	Load.prototype.setItensStatus	= setItensStatusMenu;
Index: trunk/jabberit_messenger/js/ldap.js
===================================================================
--- trunk/jabberit_messenger/js/ldap.js	(revision 914)
+++ trunk/jabberit_messenger/js/ldap.js	(revision 946)
@@ -21,13 +21,13 @@
 		
 		var _params = {
-			'lang1':jabberitGetLang('Name of Contacts'),
-			'lang2':jabberitGetLang('Search'),
-			'lang3':jabberitGetLang('member of organization'),
-			'lang4':jabberitGetLang('nickname'),
-			'lang5':jabberitGetLang('group'),
-			'lang6':jabberitGetLang('add'),
-			'lang7':jabberitGetLang('close'),
-			'lang8':jabberitGetLang('Others Expressos')			
-		};
+						'lang1':jabberitGetLang('Name of Contacts'),
+						'lang2':jabberitGetLang('Search'),
+						'lang3':jabberitGetLang('member of organization'),
+						'lang4':jabberitGetLang('nickname'),
+						'lang5':jabberitGetLang('group'),
+						'lang6':jabberitGetLang('add'),
+						'lang7':jabberitGetLang('close'),
+						'lang8':jabberitGetLang('Others Expressos')			
+				   	 };
 
 		_win_add.bz.style.display = "none";
@@ -35,14 +35,4 @@
 
 		_win_add.content( _xtools.parse(_xtools.xml('adduser'), 'add_user.xsl', _params));
-
-		_conn.go('$this.contacts_im.getParticipantsExternal',
-				function(data)
-				{
-					var data = eval(data);
-					var elementDiv =  document.getElementById('external_Participants_Jabberit');					
-					
-					if( data ) 
-						elementDiv.style.display = 'block';
-				});
 
 		_config( _win_add.wc.childNodes[2].childNodes[0],
@@ -67,8 +57,8 @@
 					{
 						if ( !(_name.value) )
-							alert( jabberitGetLang('ATTENTION') + "!!\nInforme um \"NOME\".");
+							alert( jabberitGetLang('ATTENTION') + "!!\n" + jabberitGetLang("Enter a NAME") + ".");
 
 						if ( !(_group.value) )
-							alert( jabberitGetLang('ATTENTION') + "!!\nInforme um \"GRUPO\".");							
+							alert( jabberitGetLang('ATTENTION') + "!!\n" + jabberitGetLang("Enter a GROUP") + ".");							
 					}
 					else
@@ -86,7 +76,8 @@
 								 {
 									data = eval(data);
-									
+
 									if( !data )
 									{
+										
 										alert("*********** " + jabberitGetLang("Attention") + "!! ***********\n" + 
 											  jabberitGetLang("This user is part of a small group!") + 
@@ -102,5 +93,5 @@
 										_name.parentNode.style.display = 'none';
 										_name.parentNode.nextSibling.style.display = 'none';
-										_status.innerHTML = '<br/>Adicionando contato, aguarde....<br/>';
+										_status.innerHTML = '<br/>' + jabberitGetLang('Add contact wait') + '....<br/>';
 				
 										try
@@ -124,6 +115,6 @@
 											_status.innerHTML = '<br/>' + jabberitGetLang('The module is not loaded') + '! ' + 
 																jabberitGetLang('Contact was not added!') + '<br/>';
-											
 										}
+
 										setTimeout('cleanStatusAddContactIM();',2500);
 										
@@ -171,158 +162,127 @@
 	function _search()
 	{
-		var _loading = document.getElementById('__span_load_im');
-		var _target = document.getElementById('im_ldap_user');
-		var _particiExt = document.getElementById('external_Participants_Jabberit').firstChild;
-
-		function getUsersLdap(_data)
-		{
-			var _params = {
-				'many_results' : jabberitGetLang('More than 50 results. Please, try to refine your search.'),
-				'empty' : jabberitGetLang('None result was found.')
-			 };
-		
-			_target.innerHTML = _xtools.parse(_data,'list_ldap_contacts.xsl', _params);
-
-			function _show(m)
-			{
-				m = ( m.target ) ? m.target : m.srcElement;
-
-				if ( m.getAttribute('value'))
+		var _loading = document.getElementById('__span_load_im');		
+		var _target	 = document.getElementById('im_ldap_user');
+	
+		_loading.style.display = "block";
+	
+		_conn.go('$this.contacts_im.list_contacts',		
+				function( data )
 				{
-					var jidUser = m.getAttribute('jid');
-					m = m.getAttribute('value');
-				}
-				else
-				{
-					var jidUser = m.parentNode.getAttribute('jid');
-					m = m.parentNode.getAttribute('value');
-				}
-	
-				if ( !m )
-					return false;
-
-				document.getElementById('__span_load_im_group').style.display = 'block';
-				document.getElementById('im_jidUser').value = jidUser;
-				document.getElementById('im_jid').value = m.substr(0, m.indexOf(';'));
-				document.getElementById('im_uid').value = m.substr((m.indexOf(';')+1));
-				
-				var _name = document.getElementById('im_name');
-				var groups = "";
-				var data;
-
-				var first_name = document.getElementById(m).innerHTML;
-					first_name = first_name.substr(0, first_name.indexOf(' '));
-					
-					_name.value = first_name;							
-					_name.previousSibling.style.color = "#000";
-					_name.parentNode.style.display = 'block';
-					_name.parentNode.nextSibling.style.display = 'block';
-					_name.parentNode.nextSibling.nextSibling.innerHTML = '';
-				
-	 			try
-	 			{
-	 				// If Layer;
-		 			if( elementIframe = document.getElementById('iframe_applet_jabberit') )
-		 			{
-						if( !_is_ie )
-							groups = elementIframe.contentDocument.applets[0].getGroupsToExpresso();
-						else
-							groups = elementIframe.contentWindow.document.applets[0].getGroupsToExpresso();
-					}
-					else // If Pop-Up
-					{
-						groups = _myWindow.document.applets[0].getGroupsToExpresso();
-					}
-			
-					if( typeof(groups) == 'object')
-					{
-						data = groups + ";";
-						data = data.substring(0,(data.length-2));
-					}
-					else			
-						data = groups.substring(0,(groups.length-1));
-					
 					if( data )
 					{
-						document.getElementById('im_group').setAttribute('selectBoxOptions', data);
-						
-						if( document.getElementById('selectBox0') == null )
-							editS.create(document.getElementById('im_group'));
+						var _params = {
+										'many_results' : jabberitGetLang('More than 50 results. Please, try to refine your search.'),
+										'empty' : jabberitGetLang('None result was found.')
+						 			  };
+					
+						_target.innerHTML = _xtools.parse( data, 'list_ldap_contacts.xsl', _params);
+						
+						// Add Contact
+						function _show(m)
+						{
+							m = ( m.target ) ? m.target : m.srcElement;
+			
+							if ( m.getAttribute('value'))
+							{
+								var jidUser = m.getAttribute('jid');
+								m = m.getAttribute('value');
+							}
+							else
+							{
+								var jidUser = m.parentNode.getAttribute('jid');
+								m = m.parentNode.getAttribute('value');
+							}
+				
+							if ( !m )
+								return false;
+			
+							document.getElementById('__span_load_im_group').style.display = 'block';
+							document.getElementById('im_jidUser').value = jidUser;
+							document.getElementById('im_jid').value = m.substr(0, m.indexOf(';'));
+							document.getElementById('im_uid').value = m.substr((m.indexOf(';')+1));
+
+
+							var _name = document.getElementById('im_name');
+							var groups = "";
+							var data;
+			
+							var first_name = document.getElementById(m).innerHTML;
+								first_name = first_name.substr(0, first_name.indexOf(' '));
+								
+								_name.value = first_name;							
+								_name.previousSibling.style.color = "#000";
+								_name.parentNode.style.display = 'block';
+								_name.parentNode.nextSibling.style.display = 'block';
+								_name.parentNode.nextSibling.nextSibling.innerHTML = '';
+							
+				 			try
+				 			{
+				 				// If Layer;
+					 			if( elementIframe = document.getElementById('iframe_applet_jabberit') )
+					 			{
+									if( !_is_ie )
+										groups = elementIframe.contentDocument.applets[0].getGroupsToExpresso();
+									else
+										groups = elementIframe.contentWindow.document.applets[0].getGroupsToExpresso();
+								}
+								else // If Pop-Up
+								{
+									groups = _myWindow.document.applets[0].getGroupsToExpresso();
+								}
+						
+								if( typeof(groups) == 'object')
+								{
+									data = groups + ";";
+									data = data.substring(0,(data.length-2));
+								}
+								else			
+									data = groups.substring(0,(groups.length-1));
+								
+								if( data )
+								{
+									document.getElementById('im_group').setAttribute('selectBoxOptions', data);
+									
+									if( document.getElementById('selectBox0') == null )
+										editS.create(document.getElementById('im_group'));
+								}
+				
+								document.getElementById('__span_load_im_group').style.display = 'none';
+								document.getElementById('im_group').value = '';
+								document.getElementById('im_group').focus();
+							}
+							catch(e)
+							{
+								alert("*********** " + jabberitGetLang("Attention") + "!! ***********\n" + 
+									  jabberitGetLang("The module is not loaded") + "!\n" ); 
+			
+								document.getElementById('__span_load_im_group').style.display = 'none';					
+							}
+						}
 					}
-	
-					document.getElementById('__span_load_im_group').style.display = 'none';
-					document.getElementById('im_group').value = '';
-					document.getElementById('im_group').focus();
-				}
-				catch(e)
-				{
-					alert("*********** " + jabberitGetLang("Attention") + "!! ***********\n" + 
-						  jabberitGetLang("The module is not loaded") + "!\n" ); 
-
-					document.getElementById('__span_load_im_group').style.display = 'none';					
-				}
-			}
-
-			var _member = _target.firstChild;
-			
-			while ( _member )
-			{
-				if( _member.getAttribute('photo') === '1' )
-				{
-					var uid = _member.getAttribute('value'); 
-					uid = uid.substr(uid.indexOf(';') + 1);
-					_member.style.backgroundImage = 'url(' + path_jabberit + 'inc/getphoto.php?uid=' + uid + ')';
-				}
-				_config(_member, 'onclick', _show);
-				
-				_member = _member.nextSibling;
-			}
-		}
-
-		_loading.style.display = "block";	
-		
-		if(!_particiExt.checked)
-		{
-			_conn.go(
-					'$this.contacts_im.list_contacts',		
-					function(_data)
+					
+					var _member = _target.firstChild;
+			
+					while ( _member )
 					{
-						getUsersLdap(_data);
-						_loading.style.display = "none";						
-					},
-					'name='+ arguments[0]
-				    );
-		}
-		else
-		{
-
-			function checkMail(pMail)
-			{
-				var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
-				if(er.test(pMail))
-					return true;
-				else
-					return false;
-			}
-			
-			if( checkMail(arguments[0]) )			
-			{			
-				_conn.go(
-					'$this.ldap_im.list_participants_externals',		
-					function(data)
-					{
-						getUsersLdap(data);
-						_loading.style.display = "none";
-					},
-					'mail=' + arguments[0]
-					);
-			}
-			else
-			{
-				alert(jabberitGetLang('Inform a valid e-mail!'));
-				_loading.style.display = "none";	
-			}
-		}
-				
+						if( _member.getAttribute('photo') === '1' )
+						{
+							var jid = _member.getAttribute('jid'); 
+							var ou = _member.getAttribute('ou');
+
+							var _img_path = path_jabberit + 'inc/webservice.php?' + Date.parse( new Date );
+								_img_path += '&phpPhoto=' + jid + '&phpOu=' + ou;
+							
+							_member.style.backgroundImage = 'url(' + _img_path + ')';
+						}
+						_config(_member, 'onclick', _show);
+						
+						_member = _member.nextSibling;
+					}
+
+					_loading.style.display = "none";						
+				},
+				'name='+ arguments[0]
+			    );
 	}
 
