Index: /trunk/phpgwapi/inc/class.sector_search_ldap.inc.php
===================================================================
--- /trunk/phpgwapi/inc/class.sector_search_ldap.inc.php	(revision 2)
+++ /trunk/phpgwapi/inc/class.sector_search_ldap.inc.php	(revision 23)
@@ -98,4 +98,86 @@
 			return $sectors_list;
 		}
+		
+		// Retorna os organizações com os options prontos
+		function get_organizations($context, $selected='', $referral=false ,$show_invisible_ou=false)
+		{
+			$dn			= $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
+			$passwd		= $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
+			$ldap_conn	= ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+			
+			ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+			
+			if ($referral)
+				ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1);
+			else
+				ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0);
+			
+			ldap_bind($ldap_conn,$dn,$passwd);
+			
+			$justthese = array("dn");
+			$filter = $show_invisible_ou ? "(ou=*)" : "(& (ou=*) (!(phpgwAccountVisible=-1)) )";
+			$search=ldap_search($ldap_conn, $context, $filter, $justthese);
+        	
+        	ldap_sort($ldap_conn, $search, "ou");
+        	$info = ldap_get_entries($ldap_conn, $search);
+			ldap_close($ldap_conn);
+
+			// Retiro o count do array info e inverto o array para ordenação.
+	        for ($i=0; $i<$info["count"]; $i++)
+    	    {
+				$dn = $info[$i]["dn"];
+				
+				// Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 
+				if (strtolower($dn) == $context)
+					continue;
+
+				$array_dn = ldap_explode_dn ( $dn, 1 );
+
+                $array_dn_reverse  = array_reverse ( $array_dn, true );
+
+				array_pop ( $array_dn_reverse );
+
+				$inverted_dn[$dn] = implode ( ".", $array_dn_reverse );
+			}
+
+			// Ordenação
+			natcasesort($inverted_dn);
+			
+			// Construção do select
+			$level = 0;
+			foreach ($inverted_dn as $dn=>$invert_ufn)
+			{
+                $display = '';
+
+                $array_dn_reverse = explode ( ".", $invert_ufn );
+                $array_dn  = array_reverse ( $array_dn_reverse, true );
+
+                $level = count( $array_dn ) - 4;
+
+                if ($level == 0)
+                        $display .= '+';
+                else {
+                        for ($i=0; $i<$level; $i++)
+                                $display .= '---';
+                }
+
+                reset ( $array_dn );
+                $display .= ' ' . (current ( $array_dn ) );
+				
+				$dn = trim(strtolower($dn));
+				if ( $dn == $selected )
+					$select = ' selected';
+				else
+					$select = '';
+                $options .= "<option value='$dn'$select>$display</option>";
+        	}
+
+			// Cria a primeira entrada na combo 
+			$first_sector_ufn = ldap_dn2ufn($context);
+			$first_sector_string = split(",", $first_sector_ufn);
+			$options = "<option value='$context'>" . strtoupper($first_sector_string[0]) . "</option>" . $options;
+
+    	    return $options;
+		}
 	}
 ?>
Index: unk/expressoAdmin1_2/setup/tables_update.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/setup/tables_update.inc.php	(revision 2)
+++ 	(revision )
@@ -1,16 +1,0 @@
-<?php
-	/**************************************************************************\
-	* phpGroupWare - Setup                                                     *
-	* http://www.phpgroupware.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.                                               *
-	\**************************************************************************/	
-	$test[] = '1.2';
-	function expressoAdmin1_2_upgrade1_2() {			
-		$GLOBALS['setup_info']['expressoAdmin1_2']['currentver'] = '1.21';
-		return $GLOBALS['setup_info']['expressoAdmin1_2']['currentver'];
-	}
-?>
Index: /trunk/expressoAdmin1_2/docs/change_log.txt
===================================================================
--- /trunk/expressoAdmin1_2/docs/change_log.txt	(revision 14)
+++ /trunk/expressoAdmin1_2/docs/change_log.txt	(revision 23)
@@ -42,2 +42,13 @@
 - Corrigido bug ao deletar um participante da lista de email, onde não se acha o email
 deste participante.
+
+26/04/2007
+- Criado nova função get_organizations() em class.functions.inc.php, com melhor performance.
+- Melhorado exibição de usuários e listas na adição/edição de listas de emails.
+	- Criado nova função get_available_users_and_maillist em class.ldap_functions.inc.php para isto.
+- Cria uma SCL para as listas no expresso. Com isto é possível "liberar" envio para listas para alguns usuários.
+
+02/05/2007
+- Implementado opção para restrição de nomes (logins) para listas.
+- Implementado restrição de criação de contas/listas/grupos com nomes
+de contas/grupos de sistemas. Ex: root, amanda, etc ...
Index: /trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 16)
+++ /trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php	(revision 23)
@@ -200,5 +200,5 @@
 
 			// Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou.
-			$sectors = $this->functions->get_organizations2($manager_context);
+			$sectors = $this->functions->get_organizations($manager_context);
 
 			// Chama funcao para criar lista de aplicativos disponiveis.
@@ -361,5 +361,5 @@
 							
     		// ORGANIZATIONS
-    		$orgs = $this->functions->get_organizations2($manager_context, $user_info['context']);
+    		$orgs = $this->functions->get_organizations($manager_context, $user_info['context']);
 
 			// GROUPS.
Index: /trunk/expressoAdmin1_2/inc/class.uigroups.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.uigroups.inc.php	(revision 16)
+++ /trunk/expressoAdmin1_2/inc/class.uigroups.inc.php	(revision 23)
@@ -188,6 +188,6 @@
 
 			// Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados.
-			$combo_manager_org = $this->functions->get_organizations2($manager_context, trim(strtolower($group_info['context'])));
-			$combo_all_orgs = $this->functions->get_organizations2($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
+			$combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context'])));
+			$combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
 			
 			// Chama funcao para criar lista de aplicativos disponiveis.
@@ -250,6 +250,6 @@
 
 			// Pega combo das organizações e seleciona a org do grupo.
-			$combo_manager_org = $this->functions->get_organizations2($manager_context, trim(strtolower($group_info['context'])));
-			$combo_all_orgs = $this->functions->get_organizations2($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
+			$combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context'])));
+			$combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
 
 			// Usuarios do grupo.
@@ -292,4 +292,5 @@
 				'apps'						=> $apps,
 				'use_attrs_samba_checked'	=> $group_info['sambaGroup'] ? 'CHECKED' : '',
+				'phpgwaccountvisible_checked'	=> $group_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
 				'back_url'					=> $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.list_groups'),
 				'combo_manager_org'			=> $combo_manager_org,
Index: /trunk/expressoAdmin1_2/inc/class.maillist.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.maillist.inc.php	(revision 15)
+++ /trunk/expressoAdmin1_2/inc/class.maillist.inc.php	(revision 23)
@@ -262,8 +262,133 @@
 		}		
 		
+		function save_scl($new_values)
+		{
+			// Verifica o acesso do gerente
+			if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_maillists'))
+			{
+				$return['status'] = false;
+				$return['msg'] = 'Você não tem acesso para editar listas de email.';
+				return $return;
+			}
+			
+			$return['status'] = true;
+
+			//Retira os uids duplicados se existir
+			$array_tmp = array();
+			$array_tmp = array_unique($new_values['members']);
+			$new_values['members'] = $array_tmp;
+			
+			$old_values = $this->get_scl_info($new_values['uidnumber'], $new_values['manager_context']);
+			$diff = array_diff($new_values, $old_values);
+			$dn = $old_values['dn'];
+			
+			//echo '<pre>';
+			//print_r($new_values['participantCanSendMail']);
+			//print_r($old_values['participantCanSendMail']);
+			
+			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+			// ADD ATTRS
+			if (($new_values['participantCanSendMail'] == 'on') && ($old_values['participantCanSendMail'] == ''))
+			{
+				$ldap_add['participantCanSendMail'] = "TRUE";
+				$this->db_functions->write_log("Ativado participantCanSendMail da SCL da lista de email " . $new_values['mail'],'','','','');
+			}
+			if (($new_values['accountRestrictive'] == 'on') && ($old_values['accountRestrictive'] == ''))
+			{
+				$ldap_add['accountRestrictive'] = "mailListRestriction";
+				$ldap_add['accountDeliveryMessage']	= 'OK';
+				$this->db_functions->write_log("Ativado mailListRestriction da SCL da lista de email " . $new_values['mail'],'','','','');
+			}
+			if (count($ldap_add))
+			{
+				$result = $this->ldap_functions->add_user_attributes($dn, $ldap_add);
+				if (!$result['status'])
+				{
+					$return['status'] = false;
+					$return['msg'] .= $result['msg'];
+				}
+			}
+			
+			//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+			// REMOVE ATTRS
+			if (($new_values['participantCanSendMail'] != 'on') && ($old_values['participantCanSendMail'] == 'TRUE'))
+			{
+				$ldap_remove['participantCanSendMail']	= array();
+				$this->db_functions->write_log("Desativado participantCanSendMail da SCL da lista de email " . $new_values['mail'],'','','','');
+			}
+			if (($new_values['accountRestrictive'] != 'on') && ($old_values['accountRestrictive'] == 'mailListRestriction'))
+			{
+				$ldap_remove['accountRestrictive']	= array();
+				$ldap_remove['accountDeliveryMessage']	= array();
+				$this->db_functions->write_log("Desativado restrição (mailListRestriction) da SCL da lista de email " . $new_values['mail'],'','','','');
+			}
+			if (count($ldap_remove))
+			{
+				$result = $this->ldap_functions->remove_user_attributes($dn, $ldap_remove);
+				if (!$result['status'])
+				{
+					$return['status'] = false;
+					$return['msg'] .= $result['msg'];
+				}
+			}
+			
+			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+			// USERS
+
+			if (!$new_values['members'])
+				$new_values['members'] = array();
+			if (!$old_values['members'])
+				$old_values['members'] = array();
+
+			$add_users = array_diff($new_values['members'], $old_values['members']);
+			$remove_users = array_diff($old_values['members'], $new_values['members']);
+			
+			if (count($add_users)>0)
+			{
+				$array_emails_add = array();
+				foreach($add_users as $uidnumber)
+				{
+					$mail = $this->ldap_functions->uidnumber2mail($uidnumber);
+					$array_emails_add[] = $mail;
+					$this->db_functions->write_log("Adicionado usuario $mail a SCL da lista $dn",'',$uidnumber,'','');
+				}
+				$result = $this->ldap_functions->add_user2maillist_scl($dn, $array_emails_add);
+				if (!$result['status'])
+				{
+					$return['status'] = false;
+					$return['msg'] .= $result['msg'];
+				}
+				
+			}
+			
+			if (count($remove_users)>0)
+			{
+				$array_emails_remove = array();
+				foreach($remove_users as $uidnumber)
+				{
+					$mail = $this->ldap_functions->uidnumber2mail($uidnumber);
+					$array_emails_remove[] = $mail;
+					$this->db_functions->write_log("Removido usuario $mail da SCP da lista $dn",'',$uidnumber,'','');
+				}
+				$result = $this->ldap_functions->remove_user2maillist_scl($dn, $array_emails_remove);
+				if (!$result['status'])
+				{
+					$return['status'] = false;
+					$return['msg'] .= $result['msg'];
+				}
+			}
+			
+			return $return;
+		}				
 		
 		function get_info($uidnumber, $context)
 		{
 			$maillist_info_ldap = $this->ldap_functions->get_maillist_info($uidnumber, $context);
+			return $maillist_info_ldap;
+		}
+
+		function get_scl_info($uidnumber, $context)
+		{
+			$maillist_info_ldap = $this->ldap_functions->get_maillist_scl_info($uidnumber, $context);
 			return $maillist_info_ldap;
 		}
Index: /trunk/expressoAdmin1_2/inc/class.group.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.group.inc.php	(revision 9)
+++ /trunk/expressoAdmin1_2/inc/class.group.inc.php	(revision 23)
@@ -97,4 +97,10 @@
 			}
 			
+			// ADD ATTRIBUTES
+			if ($params['phpgwaccountvisible'] == 'on')
+			{
+				$group_info['phpgwaccountvisible'] = '-1';
+			}
+			
 			$result = $this->ldap_functions->ldap_add_entry($dn, $group_info);
 			if (!$result['status'])
@@ -216,6 +222,35 @@
 					}
 					else
-						$this->db_functions->write_log("Adicionado atributos samba do grupo $dn",'',$dn,'','');
-				}
+						$this->db_functions->write_log("Adicionado atributos samba ao grupo $dn",'','','','');
+				}
+			}
+
+			////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+			// ADD ATTRIBUTES
+			if (($new_values['phpgwaccountvisible'] == 'on') && ($old_values['phpgwaccountvisible'] != '-1'))
+			{
+				$ldap_add['phpgwaccountvisible'] = '-1';
+				$result = $this->ldap_functions->add_user_attributes($dn, $ldap_add);
+				if (!$result['status'])
+				{
+					$return['status'] = false;
+					$return['msg'] .= $result['msg'];
+				}
+				else
+					$this->db_functions->write_log("Adicionado atributo phpgwaccountvisible ao grupo $dn",'','','','');
+			}
+			
+			// REMOVE ATTRIBUTES
+			if (($new_values['phpgwaccountvisible'] != 'on') && ($old_values['phpgwaccountvisible'] == '-1'))
+			{
+				$ldap_remove['phpgwaccountvisible'] = array();
+				$result = $this->ldap_functions->remove_user_attributes($dn, $ldap_remove);
+				if (!$result['status'])
+				{
+					$return['status'] = false;
+					$return['msg'] .= $result['msg'];
+				}
+				else
+					$this->db_functions->write_log("Removido atributo phpgwaccountvisible do grupo $dn",'','','','');
 			}
 
Index: /trunk/expressoAdmin1_2/inc/class.uimaillists.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.uimaillists.inc.php	(revision 2)
+++ /trunk/expressoAdmin1_2/inc/class.uimaillists.inc.php	(revision 23)
@@ -14,8 +14,9 @@
 		var $public_functions = array
 		(
-			'list_maillists'				=> True,
-			'add_maillists'				=> True,
-			'edit_maillists'				=> True,
-			'css'							=> True
+			'list_maillists'	=> True,
+			'add_maillists'		=> True,
+			'edit_maillists'	=> True,
+			'scl_maillists'		=> True,
+			'css'				=> True
 		);
 
@@ -28,4 +29,8 @@
 			$this->functions	= CreateObject('expressoAdmin1_2.functions');
 			$this->nextmatchs	= CreateObject('phpgwapi.nextmatchs');
+
+			$c = CreateObject('phpgwapi.config','expressoAdmin1_2');
+			$c->read_repository();
+			$this->current_config = $c->config_data;
 
 			if(!@is_object($GLOBALS['phpgw']->js))
@@ -82,4 +87,5 @@
 				'lang_add_email_lists'		=> lang('Add Email Lists'),
 				'lang_edit'  				=> lang('Edit'),
+				'lang_scl'  				=> 'SCL',
 				'lang_delete'				=> 'Excluir',
 				'lang_view'					=> lang('View'),
@@ -131,8 +137,10 @@
 					{
 						$p->set_var('edit_link',$this->row_action('edit','maillists',$maillist['uidnumber'],$maillist['uid']));
+						$p->set_var('scl_link',$this->row_action('scl','maillists',$maillist['uidnumber'],$maillist['uid']));
 					}
 					else
 					{
 						$p->set_var('edit_link','&nbsp;');
+						$p->set_var('scl_link','&nbsp;');
 					}
 
@@ -186,4 +194,5 @@
 				'uid'						=> 'lista-',
 				'accountStatus_checked'		=> 'CHECKED',
+				'restrictionsOnEmailLists'	=> $this->current_config['expressoAdmin_restrictionsOnEmailLists'],
 				'lang_back'					=> lang('Back'),
 				'lang_save'					=> lang('save'),
@@ -195,5 +204,5 @@
 				'lang_add_user'				=> lang('Add User'),
 				'lang_rem_user'				=> lang('Remove User'),
-				'lang_all_users'			=> lang('Select users from all sub-organizations'),
+				'lang_all_users'			=> lang('Show users from all sub-organizations'),
 				'back_url'					=> $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
 				'combo_org'					=> $org,
@@ -242,10 +251,22 @@
 					$array_users[$uidnumber] = $userinfo['cn'];
 					$array_users_uid[$uidnumber] = $userinfo['uid'];
+					$array_users_type[$uidnumber] = $userinfo['type'];
 				}
 				natcasesort($array_users);
 				foreach ($array_users as $uidnumber=>$cn)
 				{
-					$ea_select_usersInMaillist .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
-				}
+					if ($array_users_type[$uidnumber] == 'u')
+					{
+						$users .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
+					}
+					else
+					{
+						$lists .= "<option value=" . $uidnumber . ">" . $cn .  " [" . $array_users_uid[$uidnumber] . "]</option>";
+					}
+				}
+				$opt_tmp_lists = '<option  value="-1" disabled>------------------------------&nbsp;&nbsp;&nbsp;&nbsp;Listas&nbsp;&nbsp;&nbsp;&nbsp;------------------------------ </option>'."\n";
+				$opt_tmp_users = '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";
+				
+				$ea_select_usersInMaillist = $opt_tmp_lists . $lists . $opt_tmp_users . $users;
 			}
 
@@ -255,5 +276,5 @@
 				'color_bg2'						=> "#D3DCE3",
 				'type'							=> 'edit_maillist',
-				'ldap_context'				=> $GLOBALS['phpgw_info']['server']['ldap_context'],
+				'ldap_context'					=> $GLOBALS['phpgw_info']['server']['ldap_context'],
 				'lang_back'						=> lang('Back'),
 				'lang_save'						=> lang('save'),
@@ -281,5 +302,82 @@
 			$p->pfp('out','edit_maillist');
 		}
-				
+		
+		function scl_maillists()
+		{
+			$GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
+			
+			$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
+			$acl = $this->functions->read_acl($account_lid);
+			$manager_context = $acl[0]['context'];
+			
+			// Verifica se tem acesso a este modulo
+			if (!$this->functions->check_acl($account_lid,'edit_maillists'))
+			{
+				$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
+			}
+			
+			// GET all infomations about the group.
+			$maillist_info = $this->maillist->get_scl_info($_GET['uidnumber'], $manager_context);
+			//_debug_array($maillist_info);
+			
+			unset($GLOBALS['phpgw_info']['flags']['noheader']);
+			unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
+			$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Sending Control List');
+			$GLOBALS['phpgw']->common->phpgw_header();
+
+			// Set o template
+			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+			$p->set_file(Array('sql_maillist' => 'maillists_scl.tpl'));
+
+			// Pega combo das organizações e seleciona a org da lista.
+			$org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context'])));
+
+			// Usuarios de senders.
+			if (count($maillist_info['senders_info']) > 0)
+			{
+				foreach ($maillist_info['senders_info'] as $uidnumber=>$senderinfo)
+				{
+					$array_senders[$uidnumber] = $senderinfo['cn'];
+				}
+				natcasesort($array_senders);
+				foreach ($array_senders as $uidnumber=>$cn)
+				{
+					$ea_select_users_SCL_Maillist .= "<option value=" . $uidnumber . ">" . $cn . " [" . $maillist_info['senders_info'][$uidnumber]['mail'] . "]</option>";
+				}
+			}
+
+			// Seta variaveis utilizadas pelo tpl.
+			$var = Array(
+				'color_bg1'						=> "#E8F0F0",
+				'color_bg2'						=> "#D3DCE3",
+				'type'							=> 'edit_maillist',
+				'ldap_context'					=> $GLOBALS['phpgw_info']['server']['ldap_context'],
+				'dn'							=> $maillist_info['dn'],
+				'lang_back'						=> lang('Back'),
+				'lang_save'						=> lang('save'),
+				'lang_org'						=> lang('Organizations'),
+				'lang_maillist_uid'				=> lang('Maillist login'),
+				'lang_maillist_mail'			=> lang('Maillist Mail'),
+				'lang_maillist_name'			=> lang('Maillist name'),
+				'lang_maillist_users'			=> lang('Maillist users'),
+				'lang_add_user'					=> lang('Add User'),
+				'lang_rem_user'					=> lang('Remove User'),
+				'lang_all_users'				=> lang('Show users from all sub-organizations'),
+				'back_url'						=> $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'),
+				'combo_org'						=> $org,
+				'manager_context'				=> $manager_context,
+				'uidnumber'						=> $_GET['uidnumber'],
+				'uid'							=> $maillist_info['uid'],
+				'mail'							=> $maillist_info['mail'],
+				'cn'							=> $maillist_info['cn'],
+				'accountRestrictive_checked'	=> $maillist_info['accountRestrictive'] == 'mailListRestriction' ? 'CHECKED' : '',
+				'participantCanSendMail_checked'=> $maillist_info['participantCanSendMail'] == 'TRUE' ? 'CHECKED' : '',
+				'ea_select_users_SCL_Maillist'	=> $ea_select_users_SCL_Maillist
+			);
+			$p->set_var($var);
+			
+			$p->pfp('out','sql_maillist');
+		}
+		
 		function row_action($action,$type,$uidnumber,$maillist_uid)
 		{
Index: /trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 16)
+++ /trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 23)
@@ -26,4 +26,11 @@
 
 		$result['status'] = true;
+		
+		if ($_SESSION['phpgw_info']['expresso']['global_denied_users'][$uid])
+		{
+			$result['status'] = false;
+			$result['msg'] = 'Este LOGIN não pode ser usado pois é uma conta de sistema.';
+			return $result;
+		}
 		
 		if (($type == 'create_user') || ($type == 'rename_user')) 
@@ -130,4 +137,11 @@
 		$result['status'] = true;
 		
+		if ($_SESSION['phpgw_info']['expresso']['global_denied_groups'][$cn])
+		{
+			$result['status'] = false;
+			$result['msg'] = 'Este nome de grupo não pode ser usado pois é um grupo de sistema.';
+			return $result;
+		}
+		
 		// CN
 		$filter = "(&(phpgwAccountType=g)(cn=$cn))";
@@ -163,4 +177,11 @@
 		$mail = $params['mail'];
 		$result['status'] = true;
+		
+		if ($_SESSION['phpgw_info']['expresso']['global_denied_users'][$uid])
+		{
+			$result['status'] = false;
+			$result['msg'] = 'Este LOGIN não pode ser usado pois é uma conta de sistema.';
+			return $result;
+		}
 		
 		// UID
@@ -230,4 +251,5 @@
 
 	//Busca usuários de um contexto e já retorna as options do select;
+	/*
 	function get_available_users_and_maillist($params)
 	{
@@ -264,4 +286,79 @@
 
     	return $options;
+	}
+	*/
+
+	//Busca usuários e listas de um contexto e já retorna as options do select;
+	function get_available_users_and_maillist($params)
+	{
+		$context = $params['context'];
+		$recursive = $params['recursive'];
+		
+		//Usado para retirar a própria lista das possibilidades de inclusão.
+		$denied_uidnumber = $params['denied_uidnumber'];
+		
+		$justthese = array("cn", "uidNumber");
+		$users_filter="(&(phpgwAccountType=u)(!(phpgwAccountVisible=-1)))";
+		$lists_filter = $denied_uidnumber == '' ? "(phpgwAccountType=l)" : "(&(phpgwAccountType=l)(!(uidnumber=$denied_uidnumber)))";
+		
+		$users = Array();
+		$lists = Array();		
+
+		if ($recursive == 'true')
+		{
+			$lists_search = ldap_search($this->ldap, $context, $lists_filter, $justthese);
+			$users_search = ldap_search($this->ldap, $context, $users_filter, $justthese);
+		}
+		else
+		{
+			$lists_search = ldap_list($this->ldap, $context, $lists_filter, $justthese);
+			$users_search = ldap_list($this->ldap, $context, $users_filter, $justthese);
+		}
+		
+		$lists_entries = ldap_get_entries($this->ldap, $lists_search);
+		for ($i=0; $i<$lists_entries["count"]; $i++)
+		{
+			$l_tmp[$lists_entries[$i]["uidnumber"][0]] = $lists_entries[$i]["cn"][0];
+		}
+			
+		if (count($l_tmp))
+			natcasesort($l_tmp);
+			
+		$i = 0;
+		$lists = array();
+		
+		$options .= '<option  value="-1" disabled>------------------------------&nbsp;&nbsp;&nbsp;&nbsp;Listas&nbsp;&nbsp;&nbsp;&nbsp;------------------------------ </option>'."\n";	
+		if (count($l_tmp))
+		{
+			foreach ($l_tmp as $uidnumber => $cn)
+			{
+				$options .= "<option value=$uidnumber>$cn</option>";
+			}
+			unset($l_tmp);
+		}
+		
+		$users_entries = ldap_get_entries($this->ldap, $users_search);
+		for ($i=0; $i<$users_entries["count"]; $i++)
+		{
+			$u_tmp[$users_entries[$i]["uidnumber"][0]] = $users_entries[$i]["cn"][0];
+		}
+			
+		if (count($u_tmp))
+			natcasesort($u_tmp);
+			
+		$i = 0;
+		$users = array();
+		
+		$options .= '<option  value="-1" disabled>-----------------------------&nbsp;&nbsp;&nbsp;&nbsp;Usuários&nbsp;&nbsp;&nbsp;&nbsp;---------------------------- </option>'."\n";	
+		if (count($u_tmp))
+		{
+			foreach ($u_tmp as $uidnumber => $cn)
+			{
+				$options .= "<option value=$uidnumber class='line-above'>$cn</option>";
+			}
+			unset($u_tmp);
+		}
+			
+   		return $options;
 	}
 
@@ -322,5 +419,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao ldap_functions->ldap_save_photo ($dn).\\nRetorno do servidor:" . ldap_error($this->ldap);
+			$result['msg'] = "Erro na funcao ldap_functions->ldap_save_photo ($dn).\nRetorno do servidor:" . ldap_error($this->ldap);
 		}
 		
@@ -340,5 +437,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao ldap_functions->ldap_remove_photo ($dn).\\nRetorno do servidor:" . ldap_error($this->ldap);
+			$result['msg'] = "Erro na funcao ldap_functions->ldap_remove_photo ($dn).\nRetorno do servidor:" . ldap_error($this->ldap);
 		}
 		
@@ -365,5 +462,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao ldap_functions->add_user2group ($memberUid).\\nRetorno do servidor:" . ldap_error($this->ldap);
+			$result['msg'] = "Erro na funcao ldap_functions->add_user2group ($memberUid).\nRetorno do servidor:" . ldap_error($this->ldap);
 		}
 		return $result;
@@ -391,5 +488,5 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao ldap_functions->remove_user2group ($memberUid).\\nRetorno do servidor:" . ldap_error($this->ldap);
+			$result['msg'] = "Erro na funcao ldap_functions->remove_user2group ($memberUid).\nRetorno do servidor:" . ldap_error($this->ldap);
 		}
 		return $result;
@@ -413,8 +510,26 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao ldap_functions->add_user2maillist ($mail).\\nRetorno do servidor:" . ldap_error($this->ldap);
-		}
-		return $result;
-	}
+			$result['msg'] = "Erro na funcao ldap_functions->add_user2maillist ($mail).\nRetorno do servidor:" . ldap_error($this->ldap);
+		}
+		return $result;
+	}
+	
+	function add_user2maillist_scl($dn, $array_emails)
+	{
+		$attrs['mailSenderAddress'] = $array_emails;
+		$res = @ldap_mod_add($this->ldap, $dn, $attrs);
+		
+		if ($res)
+		{
+			$result['status'] = true;
+		}
+		else
+		{
+			$result['status'] = false;
+			$result['msg'] = "Erro na funcao ldap_functions->add_user2maillist_scp ($dn).\n\nRetorno do servidor:" . ldap_error($this->ldap);
+		}
+		return $result;
+	}
+
 	function remove_user2maillist($uidNumber, $mail)
 	{
@@ -434,8 +549,26 @@
 		{
 			$result['status'] = false;
-			$result['msg'] = "Erro na funcao ldap_functions->remove_user2maillist ($mail).\\nRetorno do servidor:" . ldap_error($this->ldap);
-		}
-		return $result;
-	}
+			$result['msg'] = "Erro na funcao ldap_functions->remove_user2maillist ($mail).\n\nRetorno do servidor:" . ldap_error($this->ldap);
+		}
+		return $result;
+	}
+
+	function remove_user2maillist_scl($dn, $array_emails)
+	{
+		$attrs['mailSenderAddress'] = $array_emails;
+		$res = @ldap_mod_del($this->ldap, $dn, $attrs);
+		
+		if ($res)
+		{
+			$result['status'] = true;
+		}
+		else
+		{
+			$result['status'] = false;
+			$result['msg'] = "Erro na funcao ldap_functions->remove_user2maillist_scp ($dn).\n\nRetorno do servidor:" . ldap_error($this->ldap);
+		}
+		return $result;
+	}
+
 	function replace_user2maillists($new_mail, $old_mail)
 	{
@@ -455,5 +588,5 @@
 			{
 				$result['status'] = false;
-				$result['msg'] = "Erro na funcao ldap_functions->replace_user2maillists ($old_mail).\\nRetorno do servidor:" . ldap_error($this->ldap);
+				$result['msg'] = "Erro na funcao ldap_functions->replace_user2maillists ($old_mail).\nRetorno do servidor:" . ldap_error($this->ldap);
 			}
 		}
@@ -555,4 +688,5 @@
 		$result['description']			= $entry[0]['description'][0];
 		$result['gidnumber']			= $entry[0]['gidnumber'][0];
+		$result['phpgwaccountvisible']	= $entry[0]['phpgwaccountvisible'][0];
 		
 		//MemberUid
@@ -606,5 +740,4 @@
 		$result['cn']					= $entry[0]['cn'][0];
 		$result['mail']					= $entry[0]['mail'][0];
-		$result['mail']					= $entry[0]['mail'][0];
 		$result['accountStatus']		= $entry[0]['accountstatus'][0];
 		$result['phpgwAccountVisible']	= $entry[0]['phpgwaccountvisible'][0];
@@ -613,5 +746,5 @@
 		for ($i=0; $i<$entry[0]['mailforwardingaddress']['count']; $i++)
 		{
-			$justthese = array("cn", "uidnumber", "uid");
+			$justthese = array("cn", "uidnumber", "uid", "phpgwaccounttype");
 			$filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(mail=".$entry[0]['mailforwardingaddress'][$i]."))";
 			$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
@@ -622,4 +755,5 @@
 				$result['members_info'][$user_entry[0]['uidnumber'][0]]['uid'] = $user_entry[0]['uid'][0];
 				$result['members_info'][$user_entry[0]['uidnumber'][0]]['cn'] = $user_entry[0]['cn'][0];
+				$result['members_info'][$user_entry[0]['uidnumber'][0]]['type'] = $user_entry[0]['phpgwaccounttype'][0];
 				$result['members_info'][$user_entry[0]['uidnumber'][0]]['mailforwardingaddress'] = $entry[0]['mailforwardingaddress'][$i];
 				$result['members'][] = $user_entry[0]['uidnumber'][0];
@@ -634,4 +768,46 @@
 		}
 		
+		return $result;
+	}	
+
+	function get_maillist_scl_info($uidnumber, $context)
+	{
+		$filter="(&(phpgwAccountType=l)(uidNumber=".$uidnumber."))";
+		$search = ldap_search($this->ldap, $context, $filter);
+		$entry = ldap_get_entries($this->ldap, $search);
+
+		//Pega o dn do setor do usuario.
+		$entry[0]['dn'] = strtolower($entry[0]['dn']);
+		$sector_dn_array = explode(",", $entry[0]['dn']);
+		for($i=1; $i<count($sector_dn_array); $i++)
+			$sector_dn .= $sector_dn_array[$i] . ',';
+		//Retira ultimo pipe.
+		$sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1));
+		
+		$result['dn']						= $entry[0]['dn'];
+		$result['context']					= $sector_dn;
+		$result['uidnumber']				= $entry[0]['uidnumber'][0];
+		$result['uid']						= $entry[0]['uid'][0];
+		$result['cn']						= $entry[0]['cn'][0];
+		$result['mail']						= $entry[0]['mail'][0];
+		$result['accountStatus']			= $entry[0]['accountstatus'][0];
+		$result['phpgwAccountVisible']		= $entry[0]['phpgwaccountvisible'][0];
+		$result['accountRestrictive']		= $entry[0]['accountrestrictive'][0];
+		$result['participantCanSendMail']	= $entry[0]['participantcansendmail'][0];
+		
+		//Senders
+		for ($i=0; $i<$entry[0]['mailsenderaddress']['count']; $i++)
+		{
+			$justthese = array("cn", "uidnumber", "uid", "mail");
+			$filter="(&(phpgwAccountType=u)(mail=".$entry[0]['mailsenderaddress'][$i]."))";
+			$search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
+			$user_entry = ldap_get_entries($this->ldap, $search);
+			
+			$result['senders_info'][$user_entry[0]['uidnumber'][0]]['uid'] = $user_entry[0]['uid'][0];
+			$result['senders_info'][$user_entry[0]['uidnumber'][0]]['cn'] = $user_entry[0]['cn'][0];
+			$result['senders_info'][$user_entry[0]['uidnumber'][0]]['mail'] = $user_entry[0]['mail'][0];
+			$result['members'][] = $user_entry[0]['uidnumber'][0];
+		}
+
 		return $result;
 	}	
Index: /trunk/expressoAdmin1_2/inc/class.functions.inc.php
===================================================================
--- /trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 19)
+++ /trunk/expressoAdmin1_2/inc/class.functions.inc.php	(revision 23)
@@ -344,5 +344,6 @@
 		*/
 		
-		function get_organizations($context, $selected='')
+		/*
+		function get_organizations($context, $selected='', $show_invisible_ou=false)
 		{
 			$dn			= $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
@@ -355,5 +356,6 @@
 			
 			$justthese = array("dn");
-			$search=ldap_search($ldap_conn, $context, "ou=*", $justthese);
+			$filter = $show_invisible_ou ? "(ou=*)" : "(& (ou=*) (!(phpgwAccountVisible=-1)) )";
+			$search=ldap_search($ldap_conn, $context, $filter, $justthese);
         	
         	ldap_sort($ldap_conn, $search, "ou");
@@ -418,4 +420,12 @@
     	    return $options;
 		}
+		*/
+		
+		function get_organizations($context, $selected='')
+		{
+			$s = CreateObject('phpgwapi.sector_search_ldap');
+			$sectors_info = $s->get_organizations($context, $selected, false, false);
+			return $sectors_info;
+		}		
 		
 		function get_sectors($context, $selected='')
Index: /trunk/expressoAdmin1_2/js/jscode/maillists.js
===================================================================
--- /trunk/expressoAdmin1_2/js/jscode/maillists.js	(revision 2)
+++ /trunk/expressoAdmin1_2/js/jscode/maillists.js	(revision 23)
@@ -14,13 +14,16 @@
 		return;
 	}
-		
-	uid_tmp = document.forms[0].uid.value.split("-");
-	if ((uid_tmp.length < 3) || (uid_tmp[0] != 'lista')){
-		alert(
-			'O campo LOGIN da lista está incompleto.\n' +
-			'O nome da lista deve ser formado assim:\n' +
-			'lista-ORGANIZACAO-NOME_DA_LISTA.\n' +
-			'Ex: lista-celepar-rh.');
-		return;
+	
+	if (document.forms[0].restrictionsOnEmailLists.value == 'true')
+	{
+		uid_tmp = document.forms[0].uid.value.split("-");
+		if ((uid_tmp.length < 3) || (uid_tmp[0] != 'lista')){
+			alert(
+				'O campo LOGIN da lista está incompleto.\n' +
+				'O nome da lista deve ser formado assim:\n' +
+				'lista-ORGANIZACAO-NOME_DA_LISTA.\n' +
+				'Ex: lista-celepar-rh.');
+			return;
+		}
 	}
 		
@@ -109,4 +112,27 @@
 }
 
+function save_scl()
+{
+	select_users_SCL_Maillist = document.getElementById('ea_select_users_SCL_Maillist');
+	// Needed select all options from select
+	for(var i=0; i<select_users_SCL_Maillist.options.length; i++)
+		select_users_SCL_Maillist.options[i].selected = true;
+
+	cExecuteForm ("$this.maillist.save_scl", document.forms[0], handler_save_scl);
+}
+function handler_save_scl(data)
+{
+	return_handler_save_scl(data);
+}
+
+function return_handler_save_scl(data)
+{
+	if (!data.status)
+		alert(data.msg);
+	else
+		alert('Sending Control List salva com êxito!!');
+	location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists";
+	return;
+}
 
 function sinc_combos_org(context, recursive)
@@ -162,5 +188,5 @@
 		return;
 	}
-	cExecute ('$this.ldap_functions.get_available_users_and_maillist&context='+context+'&recursive='+recursive, handler_get_available_users);
+	cExecute ('$this.ldap_functions.get_available_users_and_maillist&context='+context+'&recursive='+recursive+'&denied_uidnumber='+document.forms[0].uidnumber.value, handler_get_available_users);
 }
 
@@ -219,4 +245,59 @@
 }
 
+function add_user2scl_maillist()
+{
+	select_available_users = document.getElementById('ea_select_available_users');
+	select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist');
+
+	var count_available_users = select_available_users.length;
+	var count_usersInMailList = select_usersInMaillist.options.length;
+	var new_options = '';
+
+	for (i = 0 ; i < count_available_users ; i++)
+	{
+		if (select_available_users.options[i].selected)
+		{
+			if(document.all)
+			{
+				if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' )
+				{
+					new_options +=  "<option value="
+								+ select_available_users.options[i].value
+								+ ">"
+								+ select_available_users.options[i].text
+								+ "</options>";
+				}
+			}
+			else
+			{		
+				if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' )
+				{
+					new_options +=  "<option value="
+								+ select_available_users.options[i].value
+								+ ">"
+								+ select_available_users.options[i].text
+								+ "</options>";
+				}
+			}
+		}
+	}
+
+	if (new_options != '')
+	{
+		select_usersInMaillist.innerHTML = '#' + new_options + select_usersInMaillist.innerHTML;
+		select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML;
+	}
+}
+
+function remove_user2scl_maillist()
+{
+	select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist');
+	
+	for(var i = 0;i < select_usersInMaillist.options.length; i++)
+		if(select_usersInMaillist.options[i].selected)
+			select_usersInMaillist.options[i--] = null;
+}
+
+
 // Variaveis Locais 
 if (document.getElementById('ea_select_available_users'))
@@ -240,5 +321,5 @@
 	finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500);
 }
-function optionFinder(id) {	
+function optionFinder(id) {
 	var oWait = document.getElementById("ea_span_searching");
 	var oText = document.getElementById(id);
@@ -246,15 +327,20 @@
 	//Limpa todo o select
 	var select_available_users_tmp = document.getElementById('ea_select_available_users')
+
 	for(var i = 0;i < select_available_users_tmp.options.length; i++)
 		select_available_users_tmp.options[i--] = null;
-		
+
 	var RegExp_name = new RegExp("\\b"+oText.value, "i");
-		
+	
 	//Inclui usuário começando com a pesquisa
-	for(i = 0; i < select_available_users_clone.length; i++){																							
-		if (RegExp_name.test(select_available_users_clone[i].text))
+	for(i = 0; i < select_available_users_clone.length; i++){
+		if ( RegExp_name.test(select_available_users_clone[i].text) || (select_available_users_clone[i].value == -1) )
 		{
 			sel = select_available_users_tmp.options;
-			option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value);				
+			option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value);
+
+			if (select_available_users_clone[i].value == -1)
+				option.disabled = true;
+
 			sel[sel.length] = option;
 		}
Index: /trunk/expressoAdmin1_2/templates/default/maillists_form.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/maillists_form.tpl	(revision 2)
+++ /trunk/expressoAdmin1_2/templates/default/maillists_form.tpl	(revision 23)
@@ -11,5 +11,6 @@
 					<input type="hidden" name="ldap_context" value="{ldap_context}">
 					<input type="hidden" name="manager_context" value="{manager_context}">
-					
+					<input type="hidden" name="restrictionsOnEmailLists" value="{restrictionsOnEmailLists}">
+
 					<tr>
 						<td colspan="3" align="right" bgcolor="{color_bg1}">
@@ -36,5 +37,5 @@
 							
 							<b>{lang_maillist_users}:</b><br>
-							<select id="ea_select_usersInMaillist" name="members[]" style="width: 400px" multiple size="13">{ea_select_usersInMaillist}</select>
+							<select id="ea_select_usersInMaillist" name="members[]" style="width:400px; height:200px" multiple size="13">{ea_select_usersInMaillist}</select>
 						</td>
 						
@@ -60,5 +61,5 @@
 							<br>
 							<b>Usuários:</b>
-							<select id="ea_select_available_users" style="width: 400px" multiple size="13"></select>
+							<select id="ea_select_available_users" style="width:400px; height:200px" multiple size="13"></select>
 						</td>
 					</tr>
Index: /trunk/expressoAdmin1_2/templates/default/maillists.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/maillists.tpl	(revision 2)
+++ /trunk/expressoAdmin1_2/templates/default/maillists.tpl	(revision 23)
@@ -30,4 +30,7 @@
     <td width="40%">{lang_email}</td>
     <td width="8%" align="center">{lang_edit}</td>
+	<td width="8%" align="center"><span title='Sending Control List'>{lang_scl}<span></td>
+	
+	
     <td width="8%" align="center">{lang_delete}</td>
    </tr>
@@ -45,4 +48,5 @@
     <td width="20%">{row_email}</td>
     <td width="6%" align="center">{edit_link}</td>
+	<td width="6%" align="center">{scl_link}</td>
     <td width="7%" align="center">{delete_link}</td>
    </tr>
Index: /trunk/expressoAdmin1_2/templates/default/maillists_scl.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/maillists_scl.tpl	(revision 23)
+++ /trunk/expressoAdmin1_2/templates/default/maillists_scl.tpl	(revision 23)
@@ -0,0 +1,66 @@
+<table border="0" width="90%" align="center">
+	<tr>
+		<td valign="top">
+			{rows}
+		</td>
+		<td valign="top">
+			<table border="0" width=100% cellspacing="4">
+				<form action="{form_action}" method="POST" name="app_form">
+					<input type="hidden" name="uidnumber" value="{uidnumber}">
+					<input type="hidden" name="dn" value="{dn}">
+					<input type="hidden" name="ldap_context" value="{ldap_context}">
+					<input type="hidden" name="manager_context" value="{manager_context}">
+					
+					<tr>
+						<td colspan="3" align="right" bgcolor="{color_bg1}">
+							<input type="button" value="{lang_back}" onClick="document.location.href='{back_url}'">
+							<input type="button" value="{lang_save}" onClick="javascript:save_scl();">
+						</td>
+					</tr>
+					
+					<tr>
+						<td width="25%" valign="bottom" bgcolor="#DDDDDD">
+							Email da Lista:<br><b><span style="color:red;">{mail}<span></b><br><br>
+							Aplicar controle de envio a esta lista ? <input type="checkbox" {accountRestrictive_checked} name="accountRestrictive"><br>
+							Participantes da lista podem enviar email ? <input type="checkbox" {participantCanSendMail_checked} name="participantCanSendMail"><br>
+							<br>
+							<b>Usuários que podem enviar email para esta lista:</b><br>
+							<select id="ea_select_users_SCL_Maillist" name="members[]" style="width:400px; height:200px" multiple size="13">{ea_select_users_SCL_Maillist}</select>
+						</td>
+						
+						<td valign="middle" align="center" bgcolor="#DDDDDD">
+							<br><br><br><br><br><br>
+							<button type="button" onClick="javascript:add_user2scl_maillist();"><img src="expressoAdmin1_2/templates/default/images/add.png" style="vertical-align: middle;" >&nbsp;{lang_add_user}</button>
+							<br><br>
+							<button type="button" onClick="javascript:remove_user2scl_maillist();"><img src="expressoAdmin1_2/templates/default/images/rem.png" style="vertical-align: middle;" >&nbsp;{lang_rem_user}</button>
+						</td>
+						
+						<td valign="bottom" bgcolor="#DDDDDD">
+							Organizações:<br>
+							<select name="org_context" id="ea_combo_org_maillists" onchange="javascript:get_available_users(this.value, ea_check_allUsers.checked);">{combo_org}</select>
+							
+							<br>
+							<input type="checkbox" name="ea_check_allUsers" id="ea_check_allUsers" onclick="javascript:get_available_users(org_context.value, this.checked);">{lang_all_users}.
+							<br><br>
+							
+							Procurar usuário:<br>
+							<input id="ea_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this)"><br>
+							
+							<font color="red"><span id="ea_span_searching">&nbsp;</span></font>
+							<br>
+							<b>Usuários:</b>
+							<select id="ea_select_available_users" style="width:400px; height:200px" multiple size="13"></select>
+						</td>
+					</tr>
+					
+					<tr>
+						<td colspan="3" align="left" bgcolor="{color_bg1}">
+							<input type="button" value="{lang_save}" onClick="javascript:save_scl();">
+							<input type="button" value="{lang_back}" onClick="document.location.href='{back_url}'">
+						</td>
+					</tr>
+				</form>
+			</table>
+		</td>
+	</tr>
+</table>
Index: /trunk/expressoAdmin1_2/templates/default/groups_form.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/groups_form.tpl	(revision 2)
+++ /trunk/expressoAdmin1_2/templates/default/groups_form.tpl	(revision 23)
@@ -28,4 +28,6 @@
 							<input name="description" size="60" value="{description}" autocomplete="off"><br>
 							Usar atributos Samba: <input type="checkbox" {use_attrs_samba_checked} name="use_attrs_samba"><br>
+							Ocultar este grupo no Expresso? <input type="checkbox" {phpgwaccountvisible_checked} name="phpgwaccountvisible"><br>							
+							
 							<b>{lang_group_users}:</b><br>
 							<select id="ea_select_usersInGroup" name="members[]" style="width: 400px" multiple size="13">{ea_select_usersInGroup}</select>
Index: /trunk/expressoAdmin1_2/templates/default/config.tpl
===================================================================
--- /trunk/expressoAdmin1_2/templates/default/config.tpl	(revision 2)
+++ /trunk/expressoAdmin1_2/templates/default/config.tpl	(revision 23)
@@ -74,5 +74,13 @@
 		</td>
 	</tr>
-
+	<tr class="row_off">
+		<td>{lang_use_restrictions_in_the_creation_of_emaillists}:</td>
+		<td>
+			<select name="newsettings[expressoAdmin_restrictionsOnEmailLists]">
+				<option value="false" {selected_expressoAdmin_restrictionsOnEmailLists_false}>{lang_no}</option>
+				<option value="true"  {selected_expressoAdmin_restrictionsOnEmailLists_true}>{lang_yes}</option>
+			</select>			
+		</td>
+	</tr>
 <!-- END body -->
 <!-- BEGIN footer -->
Index: /trunk/instant_messenger/inc/class.contacts_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.contacts_im.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.contacts_im.inc.php	(revision 23)
@@ -30,5 +30,5 @@
 			}		
 		}
-	
+		
 		for($i=0; $i < count($array_groups_ldap); $i++)
 			$array_2[]['members'] = $this->ldap_users->list_groups_ldap($org_ldap,$array_groups_ldap[$i]);
@@ -46,6 +46,7 @@
 	
 		@natsort($array_3);
+		
 		$array_4 = @array_values(@array_unique($array_3));
-		
+
 		for($i=0; $i < count($array_4); $i++)
 			$array_5[] = $this->ldap_users->list_users_ldap($org_ldap,"uid", $array_4[$i]);
@@ -56,7 +57,7 @@
 			}
 		}
+
+		sort($array_6);	
 		
-		sort($array_6);	
-
 		for($i=0; $i < count($array_6); $i++){
 			$aux = explode(";", $array_6[$i]);
Index: /trunk/instant_messenger/inc/class.ldap_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.ldap_im.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.ldap_im.inc.php	(revision 23)
@@ -105,5 +105,5 @@
 		
 		if ($this->conn) {
-			$filter="gidNumber=".$gid;		
+			$filter="(&(gidNumber=".$gid.")(objectClass=posixGroup))";		
 			$justthese = array("gidnumber","cn","memberuid");
 			$search = ldap_search($this->conn,"ou=".$orgLdap.",".$this->ldap_context, $filter, $justthese);
Index: /trunk/instant_messenger/js/im_sincro.js
===================================================================
--- /trunk/instant_messenger/js/im_sincro.js	(revision 20)
+++ /trunk/instant_messenger/js/im_sincro.js	(revision 23)
@@ -12,7 +12,7 @@
 	{
 		if ( this.count++ < 4 )
-         IM.getMessage();
-      else
-         IM.UpdateContacts();
+          IM.getMessage();
+        else
+          IM.UpdateContacts();
 
       setTimeout("Sincro.synchronize()", this.wait);
Index: /trunk/instant_messenger/js/im_preferences.js
===================================================================
--- /trunk/instant_messenger/js/im_preferences.js	(revision 21)
+++ /trunk/instant_messenger/js/im_preferences.js	(revision 23)
@@ -40,5 +40,7 @@
 	{
 		var select_org = document.getElementById('ImSelOrg');
+		var select_contact = document.getElementById('ImSelAddContact');
 		var organization = "";
+		
 		for(var i=0; i < select_org.options.length; i++){
 			if(select_org.options[i].selected == true){
Index: /trunk/instant_messenger/js/im_images.js
===================================================================
--- /trunk/instant_messenger/js/im_images.js	(revision 20)
+++ /trunk/instant_messenger/js/im_images.js	(revision 23)
@@ -36,4 +36,7 @@
 	var img_chat_bubble = new Image();
 	img_chat_bubble.src = im_path + "templates/default/images/chat_bubble.gif";
+	// MANUTENÇÃO
+	var img_manutencao_im = new Image();
+	img_manutencao_im.src = im_path + "templates/default/images/manutencao_im.png";
 
 
Index: /trunk/instant_messenger/js/im_functions.js
===================================================================
--- /trunk/instant_messenger/js/im_functions.js	(revision 21)
+++ /trunk/instant_messenger/js/im_functions.js	(revision 23)
@@ -17,5 +17,5 @@
    IM.prototype.load_im = function()
    {
-	   var force = ( arguments.length ) ? true : false;
+	  var force = ( arguments.length ) ? true : false;
       var _this = this;
       Sincro.count = 0;
@@ -82,4 +82,5 @@
 		var div = document.getElementById("div_contacts");
 			div.innerHTML = "";
+		
 		var groups = "<b>"+_this.get_lang("list of contacts")+" - 0 </b><br>";
 	
Index: /trunk/contactcenter/inc/class.bo_ldap_manager.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.bo_ldap_manager.inc.php	(revision 2)
+++ /trunk/contactcenter/inc/class.bo_ldap_manager.inc.php	(revision 23)
@@ -311,5 +311,7 @@
 			}
 			$dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1);			
-			$filter = '(!(objectClass='.$objectClass.'))';
+			//$filter = '(!(objectClass='.$objectClass.'))';
+			// Don't show OU's whith phpgwAccountVisible equal to '-1'
+			$filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))';
 			$result_res = @ldap_list($resource,  ($refer_context ? $refer_context : $context), $filter);
 			@ldap_sort($resource, $result_res, 'ou');
Index: /trunk/calendar/doc/change_log.txt
===================================================================
--- /trunk/calendar/doc/change_log.txt	(revision 22)
+++ /trunk/calendar/doc/change_log.txt	(revision 23)
@@ -2,4 +2,7 @@
 módulo Agenda de Eventos, e a partir da versão 29/11/2006 [0.9.17]
 Nilton Emilio Buhrer Neto.
+
+03/05/2007 - [0.9.2]
+- Corrigido bug. Caso o horário do alarme seja mais antigo que a data atual não pode ser adicionada.
 
 03/05/2007 - [0.9.2]
Index: /trunk/calendar/inc/class.uialarm.inc.php
===================================================================
--- /trunk/calendar/inc/class.uialarm.inc.php	(revision 22)
+++ /trunk/calendar/inc/class.uialarm.inc.php	(revision 23)
@@ -133,4 +133,10 @@
 					(int)($_POST['time']['mins'])*60;
 				$alarm_time = $start_event - $time;
+				
+				if ($alarm_time <= time())
+				{
+					echo "Alarm is older than now!!!";
+					$GLOBALS['phpgw']->common->phpgw_exit(True);
+				}
 				
 				foreach ( $this->bo->bo->so->cal->event['alarm'] as $object ){
Index: /trunk/calendar/inc/class.uicalendar.inc.php
===================================================================
--- /trunk/calendar/inc/class.uicalendar.inc.php	(revision 22)
+++ /trunk/calendar/inc/class.uicalendar.inc.php	(revision 23)
@@ -342,4 +342,5 @@
 					.'<head>'."\n"
 					.'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/app_print.css" type=text/css rel=StyleSheet>'."\n"
+					.'<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url'].'/calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/app.css" type=text/css rel=StyleSheet>'."\n"
 					.'</head>
 					<table id="calendar_print_main" class="calendar_print_main">						
@@ -4682,4 +4683,11 @@
 		function get_organizations($context, $selected='')
 		{
+			$s = CreateObject('phpgwapi.sector_search_ldap');
+			$sectors_info = $s->get_organizations($context, $selected, false, false);
+			return $sectors_info;
+		}
+		/*
+		function get_organizations($context, $selected='')
+		{
 			$first_sector_ufn = ldap_dn2ufn($context);
 			$first_sector_string = split(",", $first_sector_ufn);
@@ -4715,5 +4723,5 @@
 			return $sector_select;	
 		}
-				
+		*/
 	}
 ?>
Index: /trunk/calendar/templates/celepar/app.css
===================================================================
--- /trunk/calendar/templates/celepar/app.css	(revision 23)
+++ /trunk/calendar/templates/celepar/app.css	(revision 23)
@@ -0,0 +1,257 @@
+/* CSS Document */
+
+.to_continue
+{
+	font-size: 9px;
+}
+
+A.minicalendar 
+{ 
+	color: #000000; 
+	font-size: 9px;
+	
+}
+
+A.bminicalendar 
+{ 
+	color: #336699; 
+	font-style: italic;
+	font-weight: bold;
+	font-size: 9px; 
+}
+
+A.minicalendargrey 
+{ 
+	color: #999999; 
+	font-size: 10px;
+	font-weight: bold;
+}
+
+A.bminicalendargrey 
+{ 
+	color: #336699; 
+	font-style: italic; 
+	font-size:10px; 
+}
+
+A.minicalhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #000000; 
+	font-size: 10px; 
+}
+
+A.bminicalhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #336699; 
+	font-size: 10px; 
+}
+
+A.minicalgreyhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #999999; 
+	font-size: 10px; 
+}
+
+A.bminicalgreyhol
+{ 
+	padding-left:3px;
+	padding-right:3px;
+	background: #dab0b0;
+	color: #999999; 
+	font-size: 10px; 
+}
+
+
+.event-on
+{ 
+	background: #D3DCE3;
+	border: #E8F0F0 1px solid;
+}
+
+.event-off
+{ 
+	background: #E8F0F0;
+	border: #D3DCE3 1px solid;
+}
+
+.event-holiday
+{
+	font-size: 100%;
+	background: #dac0c0;
+	color:#000000;
+	vertical-align: middle;
+}
+
+.time
+{
+	background: #D3DCE3;
+	color:#000000;
+	font-size: 10px;
+	font-weight: bold;
+	vertical-align: middle;
+	width: 5.2%;
+	text-align: right;
+	padding-right: 5px;
+	line-height: 11px;
+	border: #E8F0F0 1px solid;
+}
+
+
+.planner-cell
+{
+	cursor: pointer;
+	cursor: hand;
+	border: thin solid black;
+}
+
+/* common */
+.calendar_link_print
+{
+	text-align: center;
+	font-size: 10px;
+}
+
+//Mini Calendar
+
+.calendar_minical_table
+{
+	width: 180px;
+	font-weight: bold;
+}
+
+.calendar_minical_daytable
+{
+	width: 100%;
+}
+
+.calendar_minical_dayname
+{
+	font-size: 9px;
+	text-align: right;
+}
+
+.calendar_minical_hrule
+{
+	width: 96%;
+}
+
+/* Header */
+.calendar_dropbuttons
+{
+	align: center;
+	text-align: center;
+	vertical-align: bottom;
+	font-weight: bold;
+	font-size: 8px;
+}
+
+.calendar-weekidentifier
+{
+	font-size:16px;
+	font-weight: bold;
+	text-align: center;
+}
+
+.calendar_header
+{
+	font-size: 16px;
+	font-weight: bold;
+	text-align: center;
+}
+
+.calendar_dayview_table_header
+{
+	font-size: 13px;
+	font-weight: bold;
+	text-align: center;
+}
+
+.calendar_dayview_todo_header
+{
+	margin: 0px; 
+	padding: 2px;
+	font-weight: bold;
+}
+
+/* week view */
+.calendar_week_identifier_table
+{
+	border: 0px solid black;
+	width: 100%;
+}
+
+.calendar_week_identifier
+{
+	font-size: 13px;
+	text-align: center;
+	font-weight: bold;
+}
+
+.calendar_weekview_daytitle
+{
+	font-weight: bold;
+	font-size: 12px;
+	background: #D3DCE3;
+}
+
+.calendar_m_w_table
+{
+	table-layout:fixed;
+	overflow:auto;
+	height: 100%;
+	width: 100%;
+	border: 0px #000000 solid;
+}
+
+.calendar_m_w_tablecell
+{
+	vertical-align: top;
+	padding-left: 4px;
+	padding-right: 4px;
+	padding-bottom: 6px;
+}
+
+A.event_entry
+{
+	font-size:10px;
+}
+
+/* month view */
+
+.calendar_month_identifier
+{
+	font-size:14px;
+	font-weight: bold;
+}
+
+.calendar_user_identifier
+{
+	font-size:12px;
+	color: #009999;
+	font-weight: bold;
+}
+
+.calendar_week_minical_table
+{
+	width:100%;
+	border: 0px solid #000000
+}
+
+.calendar_weekinfo
+{
+	color: #000000;
+	padding-left: 2px;
+	padding-right: 2px;
+	font-size: 10px;
+	font-weight: bold;
+	font-style: italic;
+}
