Index: trunk/jabberit_messenger/templates/default/groupslocked.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/groupslocked.tpl	(revision 563)
+++ trunk/jabberit_messenger/templates/default/groupslocked.tpl	(revision 563)
@@ -0,0 +1,56 @@
+<!-- BEGIN groups_locked -->
+<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.glocked"></script>
+<form method="POST" action="{action_url}">
+	<table align="center" width="60%" cellspacing="2" style="border: 1px solid #000000;">
+		<tr class="th">
+			<td colspan="2">&nbsp;<b>{lang_Jabberit_settings}</b></td>
+		</tr>
+		<tr class="row_off">
+			<td colspan="2" style="color:red !important">{lang_description}</td>
+		</tr>
+		<tr class="row_on">
+			<td colspan="2">
+				{lang_organizations} :
+				&nbsp;
+				<select id="admin_organizations_ldap" name="organizations" onchange="locked.gLdap(this);">
+					{ous_ldap}
+				</select>
+				<span id="admin_span_loading" style="color:red;visibility:hidden;">&nbsp;{lang_load}</span>
+			</td>
+		</tr>
+		<tr class="row_off">
+			<td colspan="2">
+				<table align="center" cellspacing="0">
+					<tr>
+						<td class="row_off">	
+							{lang_grupos_ldap} :
+							<br/>
+							<select id="groups_ldap_jabberit" size="10" style="width: 300px" multiple></select>
+						</td>
+						<td class="row_off">
+							<input type="button" value="{lang_add}" onclick="locked.add();" />
+							<br/>
+							<br/>
+							<input type="button" value="{lang_remove}" onclick="locked.remove();" />
+						</td>
+						<td class="row_off">
+							{lang_grupos_restritos} :
+							<br/>
+							<select id="groups_locked_jabberit" size="10" style="width: 300px" multiple name="groups_locked_jabberit[]">{groups_restricts}</select>
+						</td>
+					</tr>
+				</table>
+			</td>
+		</tr>
+		<tr>
+			<td colspan="2" align="center">
+			  <input type="submit" name="save" value="{lang_save}" onclick="locked.selectAll();">
+			  <input type="submit" name="cancel" value="{lang_cancel}">
+			  <br>
+			</td>
+		</tr>
+	</table>
+</form>
+<!-- END groups_locked -->
Index: trunk/jabberit_messenger/templates/default/config.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/config.tpl	(revision 551)
+++ trunk/jabberit_messenger/templates/default/config.tpl	(revision 563)
@@ -58,44 +58,34 @@
    	</td>
    </tr>
-   
+
    <tr bgcolor="{row_on}">
-   	<td>Habilitar Participantes Externos:</td>
-   	<td>	
-   		<select name="newsettings[use_external_participants_jabberit]">
-   			<option value="false" {selected_use_external_participants_jabberit_false}>Não</option>
-   			<option value="true" {selected_use_external_participants_jabberit_true}>Sim</option>
-   		</select>
-   	</td>
-   </tr>
-   
-   <tr bgcolor="{row_off}">
 		<td colspan="2">&nbsp;<b>Configurando o Nome da Empresa</b></td>
    </tr>
 	
-	<tr bgcolor="{row_on}">
+	<tr bgcolor="{row_off}">
 		<td id="JETTI_name_company_applet_jabberit__label">Digite o Nome da sua Empresa:</td> 
 		<td><input type="text" id="JETTI_name_company_applet_jabberit" name="newsettings[name_company_applet_jabberit]" value="{value_name_company_applet_jabberit}"></td>	
 	</tr>
 
-   <tr bgcolor="{row_off}">
+   <tr bgcolor="{row_on}">
     <td colspan="2">&nbsp;<b>Configuração do Servidor Ldap</b></td>
    </tr>
 
-   <tr bgcolor="{row_on}">
+   <tr bgcolor="{row_off}">
     <td id="JETTI_server_ldap_jabberit__label">Servidor Ldap:</td>
     <td><input type="text" id="JETTI_server_ldap_jabberit" name="newsettings[server_ldap_jabberit]" value="{value_server_ldap_jabberit}"></td>
    </tr>
 
-   <tr bgcolor="{row_off}">
+   <tr bgcolor="{row_on}">
     <td id="JETTI_context_ldap_jabberit__label">Contexto:</td>
     <td><input type="text" id="JETTI_context_ldap_jabberit" name="newsettings[context_ldap_jabberit]" value="{value_context_ldap_jabberit}" size="30"></td>
    </tr>
 
-   <tr bgcolor="{row_on}">
+   <tr bgcolor="{row_off}">
     <td id="JETTI_user_ldap_jabberit__label">Usuário Ldap:</td>
     <td><input type="text" id="JETTI_user_ldap_jabberit" name="newsettings[user_ldap_jabberit]" value="{value_user_ldap_jabberit}" size="30"></td>
    </tr>
 
-   <tr bgcolor="{row_off}">
+   <tr bgcolor="{row_on}">
     <td id="JETTI_password_ldap_jabberit__label">Password:</td>
     <td><input type="password" id="JETTI_password_ldap_jabberit" name="newsettings[password_ldap_jabberit]" value="{value_password_ldap_jabberit}"></td>
Index: trunk/jabberit_messenger/templates/default/jabberIM.tpl
===================================================================
--- trunk/jabberit_messenger/templates/default/jabberIM.tpl	(revision 551)
+++ trunk/jabberit_messenger/templates/default/jabberIM.tpl	(revision 563)
@@ -17,4 +17,5 @@
 		<param name='NAMECOMPANY' value='{value_company}'>
 		<param name='CNNAME' value='{value_cnname}'>
+		<param name='PREFERENCE_USEROFFLINE' value='{value_preference_userOfflineJabberit}'>		
 		<param name='EXTIPAGE' value='javascript:window.close();'>
 		</applet>
Index: trunk/jabberit_messenger/setup/phpgw_pt-br.lang
===================================================================
--- trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 551)
+++ trunk/jabberit_messenger/setup/phpgw_pt-br.lang	(revision 563)
@@ -9,4 +9,5 @@
 Applications List	jabberit_messenger	pt-br	Lista de Módulos
 Authorization	jabberit_messenger	pt-br	Autorização
+Auto Connection	jabberit_messenger	pt-br	Conectar Automaticamente
 Ativar aviso de mensagem recebida	jabberit_messenger	pt-br	Ativar aviso de mensagem recebida
 Attribute	jabberit_messenger	pt-br	Atributo
@@ -23,4 +24,5 @@
 Close this menu	jabberit_messenger	pt-br	Fechar Menu
 Color	jabberit_messenger	pt-br	Cor
+Config External Participants	common	pt-br	Configurar Participantes Externos
 Configuration of authentication attribute by Organization (OU)	common	pt-br	Configuração do atributo de autenticação por Organização (OU)
 Contact	jabberit_messenger	pt-br	Contato
@@ -28,12 +30,16 @@
 Custom message...	jabberit_messenger	pt-br	Mensagem ...
 Delete	jabberit_messenger	pt-br	Excluir
+Define Organization!	common	pt-br	Defina uma Organização!
 Description	jabberit_messenger	pt-br	Descrição
 dnd	jabberit_messenger	pt-br	Não Perturbe
 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! 
+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 
 E-mail	jabberit_messenger	pt-br	E-mail
+External Participants	common	pt-br	Participantes Externos
 External Participants	jabberit_messenger	pt-br	Participantes Externos
 Ficar ausente depois de	jabberit_messenger	pt-br	Ficar ausente depois de
@@ -65,9 +71,12 @@
 Nick	jabberit_messenger	pt-br	Apelido
 Nickname	jabberit_messenger	pt-br	Apelido
+No	jabberit_messenger	pt-br	Não
 Not Auth	jabberit_messenger	pt-br	Não Autorizado
 Normal	jabberit_messenger	pt-br	Normal
 None result was found.	jabberit_messenger	pt-br	Nenhum resultado foi encontrado.
+Others Expressos	jabberit_messenger	pt-br	Outros Expressos
 Organization Unit	jabberit_messenger	pt-br	Selecione uma Organização
 Organization	jabberit_messenger	pt-br	Organização
+Organizations	common	pt-br	Organizações
 online	jabberit_messenger	pt-br	Online
 offline	jabberit_messenger	pt-br	Offline
@@ -87,4 +96,5 @@
 says	jabberit_messenger	pt-br	diz
 Sector	jabberit_messenger	pt-br	Setor
+Select Organization	common	pt-br	Selecione Organização
 Select the modules where the Expresso Messenger will be loaded.	jabberit_messenger	pt-br	Selecione os módulos onde o Expresso Messenger será carregado.
 Select the LDAP attribute for Jabber authentication	jabberit_messenger	pt-br	Informe o atributo LDAP para autenticação do Servidor Jabber
@@ -94,5 +104,5 @@
 Send	jabberit_messenger	pt-br	Enviar
 Send File	jabberit_messenger	pt-br	Enviar Arquivo
-Show users offline	jabberit_messenger	pt-br	Exibir amigos desconectados
+Show friends Offline	jabberit_messenger	pt-br	Exibir amigos Offline
 Size	jabberit_messenger	pt-br	Tamanho
 speak	jabberit_messenger	pt-br	fala
@@ -106,7 +116,9 @@
 To define user information	jabberit_messenger	pt-br	Definir informações do usuário
 Update	jabberit_messenger	pt-br	Atualizar
+Users OffLine	jabberit_messenger	pt-br	Usuários OffLine
 Username	jabberit_messenger	pt-br	Username
 unavailable	jabberit_messenger	pt-br	Desconectado
 Vcard	jabberit_messenger	pt-br	Vcard
+Yes	jabberit_messenger	pt-br	Sim
 You desire to register in service IM?	jabberit_messenger	pt-br	Você deseja registrar no serviço IM?
 Your Preferences	jabberit_messenger	pt-br	Suas Preferências
Index: trunk/jabberit_messenger/xsl/preferences_jabberit.xsl
===================================================================
--- trunk/jabberit_messenger/xsl/preferences_jabberit.xsl	(revision 417)
+++ trunk/jabberit_messenger/xsl/preferences_jabberit.xsl	(revision 563)
@@ -8,18 +8,37 @@
 	<xsl:param name="lang3" />
 	<xsl:param name="lang4" />	
+	<xsl:param name="lang5" />	
+	<xsl:param name="lang6" />
+	<xsl:param name="lang7" />
+	<xsl:param name="langYes" />
+	<xsl:param name="langNo" />		
 	
 	<xsl:template match="preferences_jabberit">
-		<fieldset style="height:70px; padding:5px;">
+		<fieldset style="padding:5px;border:1px solid #cecece;">
 			<legend><xsl:value-of select="$lang1"/></legend>
+			<fieldset style="height:60px;margin-top:6px;padding:5px; border:1px solid #cecece;">
+				<legend><xsl:value-of select="$lang2"/></legend>	
+				<br/>
+				<label><xsl:value-of select="$lang3"/> .: </label>
+				<select id="openWindowJabberit">
+					<option value="true"><xsl:value-of select="$langYes"/></option>
+					<option value="false"><xsl:value-of select="$langNo"/></option>					
+				</select>
+			</fieldset>
 			<br/>
-			<label><xsl:value-of select="$lang2"/> .: </label>
-			<select id="openWindowJabberit">
-				<option value="true">Sim</option>
-				<option value="false">Não</option>					
-			</select>
+			<fieldset style="display:none;height:60px;margin-bottom:6px;padding:5px; border:1px solid #cecece;">
+				<legend><xsl:value-of select="$lang4"/></legend>
+				<br/>
+				<label><xsl:value-of select="$lang5"/> .: </label>
+				<select id="userOfflineJabberit">
+					<option value="true"><xsl:value-of select="$langYes"/></option>
+					<option value="false"><xsl:value-of select="$langNo"/></option>
+				</select>
+			</fieldset>
 		</fieldset>
-		<div style="padding: 5px; cellpadding:5px;">
-			<input type="button" value="{$lang3}" onclick="javascript:loadscript.setPrefe();"/>
-			<input type="button" value="{$lang4}" />
+
+		<div style="margin-top:6px;padding:5px;cellpadding:5px;">
+			<input type="button" value="{$lang6}" onclick="javascript:loadscript.setPrefe();"/>
+			<input type="button" value="{$lang7}" />
 		</div>
 	</xsl:template>
Index: trunk/jabberit_messenger/inc/controller.xml
===================================================================
--- trunk/jabberit_messenger/inc/controller.xml	(revision 551)
+++ trunk/jabberit_messenger/inc/controller.xml	(revision 563)
@@ -19,13 +19,14 @@
 		<js path="/var/www/expresso/jabberit_messenger/js" suffix=".js" debug="false">
 			<item ref="connector" js="connector" />
+			<item ref="dragdrop" js="dragdrop" />
+			<item ref="editSelect" js="editSelect" />
+			<item ref="glocked" js="glocked" />			
+			<item ref="images" js="images" />
+			<item ref="ldap" js="ldap" />
+			<item ref="load" js="load" />
+			<item ref="show_hidden" js="show_hidden" />
+			<item ref="setup" js="setup" path="/var/www/expresso/jabberit_messenger/templates/default"/>
 			<item ref="xtools" js="xtools" />
 			<item ref="windows" js="windows" />
-			<item ref="dragdrop" js="dragdrop" />
-			<item ref="ldap" js="ldap" />
-			<item ref="load" js="load" />
-			<item ref="images" js="images" />
-			<item ref="show_hidden" js="show_hidden" />
-			<item ref="editSelect" js="editSelect" />
-			<item ref="setup" js="setup" path="/var/www/expresso/jabberit_messenger/templates/default"/>
 		</js>
 		<php path="/var/www/expresso/jabberit_messenger/inc" suffix=".class.php">
@@ -35,7 +36,11 @@
 			<item ref="db_im" alias="setAttributesLdap" class="db_im" method="setAttributesLdap" 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="removeAttributesLdap" class="db_im" method="removeAttributesLdap" 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="setOrganization" class="db_im" method="setOrganization" prefix="class." suffix=".inc.php"/>
+			<item ref="db_im" alias="removeAttributesLdap" class="db_im" method="removeAttributesLdap" 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="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"/>
Index: trunk/jabberit_messenger/inc/login.php
===================================================================
--- trunk/jabberit_messenger/inc/login.php	(revision 551)
+++ trunk/jabberit_messenger/inc/login.php	(revision 563)
@@ -13,4 +13,5 @@
 	define('PHPGW_API_INC','../../phpgwapi/inc');
 	require_once(PHPGW_API_INC . '/class.Template.inc.php');
+	require_once('class.db_im.inc.php');
 
 	if(isset($_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit']))
@@ -19,10 +20,21 @@
 		$path = $_SESSION['phpgw_info']['jabberit_messenger']['webserver_url'];
 		$SERVER_EXPRESSO = $_SERVER['HTTP_HOST'] . $path;
-	
-		// Type Protocol http / https
-		$protocol = trim("http");
+
+		/** 
+		 ******  Type Protocol http / https **********************************************************
+		 *	Esta variável é carregada no header.inc.php, onde é possível definir
+		 * 	se será com http ou https. Verifique em seu arquivo header.inc.php como está configurada
+		 *	a variável $GLOBALS['phpgw_info']['server']['use_https']. 
+		 *	Abaixo segue esquema :
+		 *	Expresso 0 = Sem https
+		 *	Expresso 1 = Com https apenas no login
+		 * 	Expresso 2 = Completo
+		 *********************************************************************************************
+		 **/
+
+		$PROTOCOL = trim("http");
 		if( $_SESSION['phpgw_info']['jabberit_messenger']['use_https'] === 2 )
-			$protocol = trim("https");
-		
+			$PROTOCOL = trim("https");
+
 		// Uid user
 		$uid = $_SESSION['phpgw_info']['jabberit_messenger']['user'];
@@ -36,4 +48,10 @@
 		// FirstName
 		$CnName = explode(" ",$_SESSION['phpgw_info']['jabberit_messenger']['fullname']);
+		
+		// Preferences
+		$obj = new db_im();
+		$preferences = $obj->getPreferences();
+		$preferences = substr($preferences,(strpos($preferences,";") + 1), strlen($preferences));
+		$preferences = explode(":", $preferences);
 		
 		if(is_array($organization))
@@ -78,7 +96,8 @@
 		$template->set_var("value_userproxy",$_SESSION['phpgw_info']['jabberit_messenger']['use_proxy_java']);
 		$template->set_var("value_expresso",$SERVER_EXPRESSO);
-		$template->set_var("value_use_https", $protocol);
+		$template->set_var("value_use_https", $PROTOCOL);
 		$template->set_var("value_company", $_SESSION['phpgw_info']['jabberit_messenger']['name_company']);
 		$template->set_var("value_cnname",$CnName[0]);
+		$template->set_var("value_preference_userOfflineJabberit", strtoupper($preferences[1]));
 		$template->set_file(Array('jabberit_messenger' => 'jabberIM.tpl'));
 		$template->set_block('jabberit_messenger','index');
Index: trunk/jabberit_messenger/inc/jabberit_acl.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 551)
+++ trunk/jabberit_messenger/inc/jabberit_acl.inc.php	(revision 563)
@@ -45,9 +45,21 @@
 		
 		$_SESSION['phpgw_info']['jabberit_messenger']['webserver_url'] = $webserver_url;
-
+		
+		$ExternalParticipants = ""; 
+		if(isset($_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';
 		
-		print '<script type="text/javascript">var path_jabberit= "'.$webserver_url.'"</script>';
-
+		print "<script type='text/javascript'>".
+				 "var path_jabberit='".$webserver_url."';".
+			 	 "var externalParticipantsJabberit='".$ExternalParticipants."';".
+			  "</script>";
 
 		$js = array(
Index: trunk/jabberit_messenger/inc/jabberit_sessions.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/jabberit_sessions.inc.php	(revision 551)
+++ trunk/jabberit_messenger/inc/jabberit_sessions.inc.php	(revision 563)
@@ -17,4 +17,11 @@
 		$_SESSION['phpgw_info']['jabberit_messenger']['mail']		= $GLOBALS['phpgw_info']['user']['email'];
 		$_SESSION['phpgw_info']['jabberit_messenger']['fullname']	= $GLOBALS['phpgw_info']['user']['fullname'];
+		$_SESSION['phpgw_info']['jabberit_messenger']['account_dn']	= $GLOBALS['phpgw_info']['user']['account_dn'];
+
+		//Members Group
+		$_SESSION['phpgw_info']['jabberit_messenger']['membership']	= $GLOBALS['phpgw']->accounts->membership();
+
+		//Groups Locked
+		$_SESSION['phpgw_info']['jabberit_messenger']['groups_locked'] = $GLOBALS['phpgw_info']['server']['groups_locked_jabberit'];
 
 		//Server http or https 
@@ -47,6 +54,7 @@
 		$_SESSION['phpgw_info']['jabberit_messenger']['name_company']			= $GLOBALS['phpgw_info']['server']['name_company_applet_jabberit'];
 		$_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']['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'];		
 		
 ?>
Index: trunk/jabberit_messenger/inc/hook_admin.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/hook_admin.inc.php	(revision 519)
+++ trunk/jabberit_messenger/inc/hook_admin.inc.php	(revision 563)
@@ -16,7 +16,10 @@
 		'Site Configuration'	=> $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname),
 		'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')
+		'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'),
+		'Deny module\'s use by group' => $GLOBALS['phpgw']->link('/index.php','menuaction=jabberit_messenger.uigroupslocked.editGroups')
+		
 	);
-	
+
 //Do not modify below this line
 	display_section($appname,$title,$file);
Index: trunk/jabberit_messenger/inc/class.ldap_im.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 551)
+++ trunk/jabberit_messenger/inc/class.ldap_im.inc.php	(revision 563)
@@ -25,13 +25,19 @@
 	private $jid;
 	private $max_result;
+	private $ou_User;
 	
 	public final function __construct()
 	{
-		$this->ldap_host 	= $_SESSION['phpgw_info']['jabberit_messenger']['server_ldap_jabberit'];
-		$this->ldap_context	= $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'];
-		$this->ldap_dn		= $_SESSION['phpgw_info']['jabberit_messenger']['user_ldap_jabberit'];
-		$this->ldap_pass	= $_SESSION['phpgw_info']['jabberit_messenger']['password_ldap_jabberit'];
+		$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'];
+		$this->ldap_context	= (isset($_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'])) ? $_SESSION['phpgw_info']['jabberit_messenger']['context_ldap_jabberit'] : $GLOBALS['phpgw_info']['server']['ldap_context'];
+		$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'];
 		$this->max_result	= 50;
+		
+		// Ou User
+		$this->ou_User = $_SESSION['phpgw_info']['jabberit_messenger']['account_dn'];
+		$this->ou_User = substr($this->ou_User,strpos($this->ou_User, "ou="));
+		$this->ou_User = strtoupper(substr($this->ou_User, 0, strpos($this->ou_User, ",dc=")));
 	}
 
@@ -49,5 +55,5 @@
 		{
 			$GLOBALS['phpgw_info']['server']['ldap_version3'] = true;
-			$this->ldap = $this->common->ldapConnect( $this->ldap_host,$this->ldap_dn,$this->ldap_pass, true );
+			$this->ldap = $this->common->ldapConnect( $this->ldap_host,$this->ldap_dn,$this->ldap_pass, false );
 		}
 	}
@@ -150,5 +156,5 @@
 	}
 
-	public final function list_users_ldap($search, $uidnumber)
+	public final function list_users_ldap($search, $uidnumber, $groupsDeny)
 	{
 		$this->_connect_ldap();
@@ -159,6 +165,9 @@
 			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn","jpegPhoto");
 			// SERPRO
-			//$justthese = array("uid","uidNumber","cn","mail","description","phpgwAccountVisible","dn","jpegPhoto");			
-			$search = ldap_search($this->ldap,$this->ldap_context,$filter,$justthese, 0, $this->max_result + 1);
+			//$justthese = array("uid","uidNumber","cn","mail","description","phpgwAccountVisible","dn","jpegPhoto");
+			if( $groupsDeny )			
+				$search = ldap_search($this->ldap,$this->ou_User.",".$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 );
@@ -243,7 +252,6 @@
 	}
 	
-	public final function list_organizations_ldap()
-	{
-		$result_org = "<organizations>";
+	public final function listOrganizationsLdap()
+	{
 
 		$this->_connect_ldap();
@@ -259,10 +267,35 @@
 		foreach($entry as $tmp)
 			if($tmp['ou'][0] != "")
-				$result_org .= "<ou>" . $tmp['ou'][0] . "</ou>";  
-
-		$result_org .= "</organizations>";
-		
+				$result_org[] = $tmp['ou'][0];  
+
 		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);
+			$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;
+	}
+
 }
 
Index: trunk/jabberit_messenger/inc/class.uiconforganization.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.uiconforganization.inc.php	(revision 526)
+++ trunk/jabberit_messenger/inc/class.uiconforganization.inc.php	(revision 563)
@@ -38,9 +38,4 @@
 		$GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') .' - ' . 'Configurar o Atributo de Autenticação';	
 		
-		//if(!@is_object($GLOBALS['phpgw']->js))
-		//{
-		//	$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
-		//}
-			
 		$_SESSION['phpgwinfo']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
     	$_SESSION['phpgwinfo']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
@@ -53,8 +48,4 @@
 		$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
 		
-		//$js = array('functions');
-		//foreach( $js as $tmp )
-		//	$GLOBALS['phpgw']->js->validate_file('',$tmp,'jabberit_messenger');
-
 		$GLOBALS['phpgw']->common->phpgw_header();
 		echo parse_navbar();
Index: trunk/jabberit_messenger/inc/class.db_im.inc.php
===================================================================
--- trunk/jabberit_messenger/inc/class.db_im.inc.php	(revision 519)
+++ trunk/jabberit_messenger/inc/class.db_im.inc.php	(revision 563)
@@ -126,10 +126,17 @@
 		}
 
-		return "openWindowJabberit:true";
+		return "openWindowJabberit:true;userOfflineJabberit:true";
 	}
 
 	public final function setPreferences($pParam)
 	{
-		$preferences = $pParam['preferences'];
+		$preferences = $preferences1 = $pParam['preferences1'];
+		
+		if(isset($pParam['preferences2']))
+		{
+			$preferences2 = $pParam['preferences2'];
+			$preferences .= ";". $preferences2;
+		}
+		
 		$user_id  = $this->user_id;
 		
@@ -238,4 +245,134 @@
 		return false; 
 	}
+
+	public final function setGroupsLocked($pGroups)
+	{
+		$groups = "";
+		
+		if( is_array($pGroups) )
+		{
+			foreach($pGroups as $tmp)		
+				if(trim($tmp) != "")
+					$groups .= $tmp . ";";
+		
+			$groups = substr($groups, 0, strlen($groups) - 1 );		
+		}
+		
+		if( $this->db )
+		{
+			$query = "SELECT * FROM phpgw_config WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";	
+			
+			if($this->db->query($query))
+			{
+
+				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','groups_locked_jabberit','".$groups."');";
+					$this->db->query($query);
+					return true;
+				}
+				else
+				{
+					$query = "UPDATE phpgw_config SET config_value = '".trim($groups)."' WHERE config_app = 'phpgwapi' AND config_name = 'groups_locked_jabberit';";
+					$this->db->query($query);
+					return true;
+				}
+			}
+		}
+		
+		return false;
+	}
+	
+	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)
@@ -282,4 +419,46 @@
 		return false;	
 	}
+	
+	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;	
+	}
 }
 ?>
