Changeset 64 for trunk/expressoAdmin1_2/inc
- Timestamp:
- 09/05/07 11:18:58 (17 years ago)
- Location:
- trunk/expressoAdmin1_2/inc
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.bocomputers.inc.php
r27 r64 19 19 20 20 var $so; 21 var $db_functions; 21 22 var $functions; 22 23 … … 25 26 $this->so = CreateObject('expressoAdmin1_2.socomputers'); 26 27 $this->functions = $this->so->functions; 28 $this->db_functions = CreateObject('expressoAdmin1_2.db_functions'); 27 29 } 28 30 29 31 function create_computer() 30 32 { 31 if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], ' add_groups'))33 if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'create_computers')) 32 34 { 33 $_POST['error_messages'] = "O arquivo binário /home/expressolivre/mkntpwd não exite.";34 ExecMethod('expressoAdmin1_2.uiaccounts.add_computer');35 35 return false; 36 36 } … … 39 39 $c->read_repository(); 40 40 $current_config = $c->config_data; 41 // Leio o ID a ser usado na criação do objecto. 42 $next_id = ($this->db_functions->get_next_id('accounts')); 41 43 42 // Pega ID do BD e incrementa de 1. 43 $id = (($this->functions->get_next_id()) + 1); 44 if ((!is_numeric($next_id['id'])) || (!$next_id['status'])) 45 { 46 47 $return['status'] = false; 48 $return['msg'] = "Problemas obtendo ID do usuário.\n" . $id['msg']; 49 return $return; 50 } 51 else 52 { 53 $id = $next_id['id']; 54 } 55 // Incrementa o id no BD. 56 //$this->functions->increment_id($id,'accounts'); 44 57 45 58 // Cria array para incluir no LDAP … … 83 96 return false; 84 97 } 85 86 // Incrementa o id no BD.87 $this->functions->increment_id($id,'accounts');88 98 89 99 // Volta para o ListGroups … … 163 173 function delete_computer() 164 174 { 165 //_debug_array($_POST);166 167 175 //Delete from ldap. 168 176 if (!$this->so->delete_computer_ldap($_POST['computer_dn'])) -
trunk/expressoAdmin1_2/inc/class.bomanagers.inc.php
r63 r64 26 26 } 27 27 28 //Recebe valores do POST 29 $manager = array( 30 'lid' => $_POST['manager_lid'], 31 'context' => $_POST['context'], 32 33 'add_users' => $_POST['add_users'], 34 'edit_users' => $_POST['edit_users'], 35 'delete_users' => $_POST['delete_users'], 36 'rename_users' => $_POST['rename_users'], 37 'view_users' => $_POST['view_users'], 38 'manipulate_corporative_information' => $_POST['manipulate_corporative_information'], 39 'add_groups' => $_POST['add_groups'], 40 'edit_groups' => $_POST['edit_groups'], 41 'delete_groups' => $_POST['delete_groups'], 42 'edit_email_groups' => $_POST['edit_email_groups'], 43 'change_users_password' => $_POST['change_users_password'], 44 'change_users_quote' => $_POST['change_users_quote'], 45 'set_user_default_password' => $_POST['set_user_default_password'], 46 'empty_user_inbox' => $_POST['empty_user_inbox'], 47 'edit_sambausers_attributes'=> $_POST['edit_sambausers_attributes'], 48 'edit_sambadomains' => $_POST['edit_sambadomains'], 49 'add_email_lists' => $_POST['add_maillists'], 50 'edit_email_lists' => $_POST['edit_maillists'], 51 'delete_email_lists' => $_POST['delete_maillists'], 52 'create_sectors' => $_POST['create_sectors'], 53 'edit_sectors' => $_POST['edit_sectors'], 54 'delete_sectors' => $_POST['delete_sectors'], 55 'view_global_sessions' => $_POST['view_global_sessions'], 56 'view_logs' => $_POST['view_logs'], 57 'create_computers' => $_POST['create_computers'], 58 'edit_computers' => $_POST['edit_computers'], 59 'delete_computers' => $_POST['delete_computers'], 60 61 'apps' => $_POST['applications_list'] 62 ); 63 64 // Soma os niveis de acesso criando uma ACL 65 $acl = 0; 66 $acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'] + $manager['manipulate_corporative_information']; 67 $acl = $acl + $manager['add_groups'] + $manager['edit_groups'] + $manager['delete_groups'] + $manager['edit_email_groups']; 68 $acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'] + $manager['empty_user_inbox']; 69 $acl = $acl + $manager['edit_sambausers_attributes'] + $manager['edit_sambadomains']; 70 $acl = $acl + $manager['add_email_lists'] + $manager['edit_email_lists'] + $manager['delete_email_lists']; 71 $acl = $acl + $manager['create_sectors'] + $manager['edit_sectors'] + $manager['delete_sectors'] + $manager['view_global_sessions']; 72 $acl = $acl + $manager['create_computers'] + $manager['edit_computers'] + $manager['delete_computers']; 73 $acl = $acl + $manager['view_logs']; 74 75 //Escrevre no Banco 28 //Escrevre no Banco a ACL do gerente 76 29 $sql = "INSERT INTO phpgw_expressoadmin (manager_lid, context, acl) " 77 . "VALUES('" . $ manager['lid'] . "','" . $manager['context'] . "','" . $acl. "')";30 . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $this->make_manager_acl($_POST) . "')"; 78 31 $GLOBALS['phpgw']->db->query($sql); 79 32 80 33 //Escrevre no Banco as aplicações que o gerente tem direito de disponibilizar aos seus usuarios. 81 foreach($ manager['apps'] as $app=>$value)34 foreach($_POST['applications_list'] as $app=>$value) 82 35 { 83 36 $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " 84 . "VALUES('" . $ manager['lid'] . "','" . $manager['context'] . "','" . $app . "')";37 . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')"; 85 38 $GLOBALS['phpgw']->db->query($sql); 86 39 } … … 99 52 return False; 100 53 } 101 102 //recebe valores do POST103 $manager = array(104 'old_lid' => $_POST['old_manager_lid'],105 'old_context' => $_POST['old_context'],106 'lid' => $_POST['manager_lid'],107 'context' => $_POST['context'],108 54 109 'add_users' => $_POST['add_users'], 110 'edit_users' => $_POST['edit_users'], 111 'delete_users' => $_POST['delete_users'], 112 'rename_users' => $_POST['rename_users'], 113 'view_users' => $_POST['view_users'], 114 'manipulate_corporative_information' => $_POST['manipulate_corporative_information'], 115 'add_groups' => $_POST['add_groups'], 116 'edit_groups' => $_POST['edit_groups'], 117 'delete_groups' => $_POST['delete_groups'], 118 'edit_email_groups' => $_POST['edit_email_groups'], 119 'change_users_password' => $_POST['change_users_password'], 120 'change_users_quote' => $_POST['change_users_quote'], 121 'set_user_default_password' => $_POST['set_user_default_password'], 122 'empty_user_inbox' => $_POST['empty_user_inbox'], 123 'edit_sambausers_attributes'=> $_POST['edit_sambausers_attributes'], 124 'edit_sambadomains' => $_POST['edit_sambadomains'], 125 'add_email_lists' => $_POST['add_maillists'], 126 'edit_email_lists' => $_POST['edit_maillists'], 127 'delete_email_lists' => $_POST['delete_maillists'], 128 'create_sectors' => $_POST['create_sectors'], 129 'edit_sectors' => $_POST['edit_sectors'], 130 'delete_sectors' => $_POST['delete_sectors'], 131 'view_global_sessions' => $_POST['view_global_sessions'], 132 'view_logs' => $_POST['view_logs'], 133 'create_computers' => $_POST['create_computers'], 134 'edit_computers' => $_POST['edit_computers'], 135 'delete_computers' => $_POST['delete_computers'], 55 //Executa update na tabela para atualizar ACL 56 $sql = "UPDATE phpgw_expressoadmin SET manager_lid = '".$_POST['manager_lid'] 57 . "',context = '".$_POST['context'] 58 . "',acl = '" . $this->make_manager_acl($_POST) 59 . "' WHERE manager_lid = '" . $_POST['old_manager_lid']."' AND context = '" . $_POST['old_context'] ."'"; 60 $GLOBALS['phpgw']->db->query($sql); 136 61 137 'apps' => $_POST['applications_list']138 );139 140 // Soma os niveis de acesso criando uma ACL141 $acl = 0;142 $acl = $acl + $manager['add_users'] + $manager['edit_users'] + $manager['delete_users'] + $manager['rename_users'] + $manager['view_users'] + $manager['manipulate_corporative_information'];143 $acl = $acl + $manager['add_groups'] + $manager['edit_groups'] + $manager['delete_groups'] + $manager['edit_email_groups'];144 $acl = $acl + $manager['change_users_password'] + $manager['change_users_quote'] + $manager['set_user_default_password'] + $manager['empty_user_inbox'];145 $acl = $acl + $manager['edit_sambausers_attributes'] + $manager['edit_sambadomains'];146 $acl = $acl + $manager['add_email_lists'] + $manager['edit_email_lists'] + $manager['delete_email_lists'];147 $acl = $acl + $manager['create_sectors'] + $manager['edit_sectors'] + $manager['delete_sectors'] + $manager['view_global_sessions'];148 $acl = $acl + $manager['create_computers'] + $manager['edit_computers'] + $manager['delete_computers'];149 $acl = $acl + $manager['view_logs'];150 151 //Executa update na tabela152 $sql = "UPDATE phpgw_expressoadmin SET manager_lid = '".$manager['lid']153 . "',context = '".$manager['context']154 . "',acl = '".$acl155 . "' WHERE manager_lid = '".$manager['old_lid']."' AND context = '" . $manager['old_context'] ."'";156 $GLOBALS['phpgw']->db->query($sql);157 62 158 63 //Deleta as aplicações e adiciona as novas. 159 64 //Deleta 160 65 $sql = "DELETE FROM phpgw_expressoadmin_apps WHERE " 161 . "manager_lid = '".$manager['old_lid']."' AND " 162 . "context = '".$manager['old_context']."'"; 163 $GLOBALS['phpgw']->db->query($sql); 66 . "manager_lid = '" . $_POST['old_manager_lid']."' AND " 67 . "context = '" . $_POST['old_context']."'"; 68 $GLOBALS['phpgw']->db->query($sql); 69 164 70 // Adiciona 165 if (count($ manager['apps']))71 if (count($_POST['applications_list'])) 166 72 { 167 foreach($ manager['apps'] as $app=>$value)73 foreach($_POST['applications_list'] as $app=>$value) 168 74 { 169 75 $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " 170 . "VALUES('" . $ manager['lid'] . "','" . $manager['context'] . "','" . $app . "')";76 . "VALUES('" . $_POST['manager_lid'] . "','" . $_POST['context'] . "','" . $app . "')"; 171 77 $GLOBALS['phpgw']->db->query($sql); 172 78 } … … 176 82 ExecMethod('expressoAdmin1_2.uimanagers.list_managers'); 177 83 return True; 178 } 84 } 85 86 function make_manager_acl($array_post) 87 { 88 $total_manager_acl = 0; 89 foreach ($array_post as $atribute=>$value) 90 { 91 $acl = strstr($atribute, 'acl_'); 92 93 if ($acl !== false) 94 { 95 $total_manager_acl += $value; 96 } 97 } 98 return $total_manager_acl; 99 } 179 100 } 180 101 ?> -
trunk/expressoAdmin1_2/inc/class.bosectors.inc.php
r32 r64 53 53 if (!$this->so->write_ldap($dn, $sector_info)) 54 54 { 55 $_POST['error_messages'] = lang('Error in OpenLDAP recording. ');55 $_POST['error_messages'] = lang('Error in OpenLDAP recording.aa'); 56 56 ExecMethod('expressoAdmin1_2.uisectors.add_sector'); 57 57 return false; -
trunk/expressoAdmin1_2/inc/class.db_functions.inc.php
r32 r64 9 9 var $user_id; 10 10 11 function db_functions() {12 11 function db_functions() 12 { 13 13 if (is_array($_SESSION['phpgw_info']['expresso']['server'])) 14 14 $GLOBALS['phpgw_info']['server'] = $_SESSION['phpgw_info']['expresso']['server']; … … 38 38 return $result; 39 39 } 40 41 /* 42 function get_sectors($params) 43 { 44 $organization = strtolower($params['organization']); 45 46 $result = array(); 47 // Pesquisa no BD os nomes setores no tabela phpgw_expressoadmin_sectors. 48 $query = "SELECT sector FROM phpgw_expressoadmin_sectors WHERE organization='$organization' ORDER by sector ASC"; 49 50 if (!$this->db->query($query)) 51 return 'Erro em get_sectors:' . pg_last_error(); 52 53 while($this->db->next_record()) 54 $result[] = $this->db->row(); 55 56 return $result; 57 } 58 */ 59 60 function get_next_id() 61 { 40 41 function copy_manager($params) 42 { 43 $manager = $params['manager']; 44 $new_manager = $params['new_manager']; 45 $manager_info = $this->read_acl($manager); 46 47 //Escrevre no Banco a ACL do gerente 48 $sql = "INSERT INTO phpgw_expressoadmin (manager_lid, context, acl) " 49 . "VALUES('" . $new_manager . "','" . $manager_info[0]['context'] . "','" . $manager_info[0]['acl'] . "')"; 50 51 if (!$this->db->query($sql)) 52 { 53 echo 'Erro em copy_manager:' . pg_last_error(); 54 return false; 55 } 56 57 //Pesquisa no Banco e pega os valores dos apps. 58 $sql = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $manager_info[0]['manager_lid'] . "' AND context = '" . $manager_info[0]['context'] . "'"; 59 $this->db->query($sql); 60 while($this->db->next_record()) 61 { 62 $aplications[] = $this->db->row(); 63 } 64 65 //Escrevre no Banco as aplicações que o gerente tem direito de disponibilizar aos seus usuarios. 66 for ($i=0; $i<count($aplications); $i++) 67 { 68 $sql = "INSERT INTO phpgw_expressoadmin_apps (manager_lid, context, app) " 69 . "VALUES('" . $new_manager . "','" . $manager_info[0]['context'] . "','" . $aplications[$i]['app'] . "')"; 70 if (!$this->db->query($sql)) 71 { 72 echo 'Erro adicionando aplicacão para o novo gerente:' . pg_last_error(); 73 return false; 74 } 75 } 76 return true; 77 } 78 79 function get_next_id($type) 80 { 81 $return['status'] = true; 82 83 $current_config = $_SESSION['phpgw_info']['expresso']['expressoAdmin']; 84 85 if ($current_config['expressoAdmin_nextid_db_host'] != '') 86 { 87 $this->db->disconnect(); 88 $host = $current_config['expressoAdmin_nextid_db_host']; 89 $port = $current_config['expressoAdmin_nextid_db_port']; 90 $name = $current_config['expressoAdmin_nextid_db_name']; 91 $user = $current_config['expressoAdmin_nextid_db_user']; 92 $pass = $current_config['expressoAdmin_nextid_db_password']; 93 94 $db = new db(); 95 $db->Halt_On_Error = 'no'; 96 $db->connect($name, $host, $port, $user, $pass, 'pgsql'); 97 } 98 else 99 { 100 $db = $this->db; 101 } 102 62 103 // Busco o ID dos accounts 63 $query_accounts = "SELECT id FROM phpgw_nextid WHERE appname = 'accounts'"; 64 if (!$this->db->query($query_accounts)) 65 return 'Erro em get_next_id:' . pg_last_error(); 66 while($this->db->next_record()) 67 $result_accounts[] = $this->db->row(); 68 $accounts_id = $result_accounts[0]['id']; 104 $query_accounts_nextid = "SELECT id FROM phpgw_nextid WHERE appname = 'accounts'"; 105 if (!$db->query($query_accounts_nextid)) 106 { 107 $return['status'] = false; 108 $return['msg'] = "Problemas executando a query accounts no Banco de Dados."; 109 $db->disconnect(); 110 return $return; 111 } 112 else 113 { 114 $accounts_nextid = $db->Query_ID->fields[0]; 115 } 69 116 70 117 // Busco o ID dos groups 71 118 $query_groups = "SELECT id FROM phpgw_nextid WHERE appname = 'groups'"; 72 if (!$this->db->query($query_groups)) 73 return 'Erro em get_next_id:' . pg_last_error(); 74 while($this->db->next_record()) 75 $result_groups[] = $this->db->row(); 76 $groups_id = $result_groups[0]['id']; 77 78 //Retorna o maior dos ID's 79 if ($accounts_id >= $groups_id) 80 return $accounts_id; 81 else 82 return $groups_id; 83 } 84 119 if (!$db->query($query_groups)) 120 { 121 $return['status'] = false; 122 $return['msg'] = "Problemas executando a query groups no Banco de Dados."; 123 $db->disconnect(); 124 return $return; 125 } 126 else 127 { 128 $groups_nextid = $db->Query_ID->fields[0]; 129 } 130 131 //RetornO o maior dos ID's incrementado de 1 132 if ($accounts_nextid >= $groups_nextid) 133 $id = $accounts_nextid; 134 else 135 $id = $groups_nextid; 136 $return['id'] = (int)($id + 1); 137 138 139 // Atualizo o BD 140 $query_update_id = "UPDATE phpgw_nextid set id = '" . $return['id'] . "' WHERE appname = '" . $type . "'"; 141 if (!$db->query($query_update_id)) 142 { 143 $return['status'] = false; 144 $return['msg'] = "Problemas executando a query update id no Banco de Dados."; 145 } 146 $db->disconnect(); 147 return $return; 148 } 149 150 /* 85 151 function increment_id($id, $type) 86 152 { 153 $current_config = $_SESSION['phpgw_info']['expresso']['expressoAdmin']; 154 if ($current_config['expressoAdmin_nextid_db_host'] != '') 155 { 156 $this->db->disconnect(); 157 $host = $current_config['expressoAdmin_nextid_db_host']; 158 $port = $current_config['expressoAdmin_nextid_db_port']; 159 $name = $current_config['expressoAdmin_nextid_db_name']; 160 $user = $current_config['expressoAdmin_nextid_db_user']; 161 $pass = $current_config['expressoAdmin_nextid_db_pass']; 162 163 $db = new db(); 164 $db->Halt_On_Error = 'no'; 165 $db->connect($name, $host, $port, $user, $pass, 'pgsql'); 166 } 167 else 168 { 169 $db = $this->db; 170 } 171 87 172 $sql = "UPDATE phpgw_nextid set id = '".$id."' WHERE appname = '" . $type . "'"; 88 if (!$this->db->query($sql)) 173 if (!$db->query($sql)) 174 { 175 $db->disconnect(); 89 176 return 'Erro em increment_id:' . pg_last_error(); 90 else 177 } 178 else 179 { 180 $db->disconnect(); 91 181 return true; 92 } 182 } 183 } 184 */ 93 185 94 186 function add_user2group($gidnumber, $uidnumber) … … 558 650 return; 559 651 } 652 653 function test_db_connection($params) 654 { 655 $host = $params['host']; 656 $port = $params['port']; 657 $name = $params['name']; 658 $user = $params['user']; 659 $pass = $params['pass']; 660 661 $con_string = "host=$host port=$port dbname=$name user=$user password=$pass"; 662 if ($db = pg_connect($con_string)) 663 { 664 pg_close($db); 665 $result['status'] = true; 666 } 667 else 668 { 669 $result['status'] = false; 670 } 671 672 return $result; 673 } 560 674 } 561 675 ?> -
trunk/expressoAdmin1_2/inc/class.functions.inc.php
r63 r64 11 11 12 12 include_once('class.db_functions.inc.php'); 13 include_once(PHPGW_API_INC.'/class.config.inc.php'); 13 14 14 15 class functions 15 16 { 16 17 17 var $public_functions = array 18 18 ( … … 27 27 var $nextmatchs; 28 28 var $sectors_list = array(); 29 var $current_config; 29 30 30 31 function functions() 31 32 { 32 33 $this->db_functions = new db_functions; 34 $GLOBALS['phpgw']->db = $this->db_functions->db; 35 36 //$c = CreateObject('phpgwapi.config','expressoAdmin1_2'); 37 $c = new config; 38 $c->read_repository(); 39 $this->current_config = $c->config_data; 33 40 } 34 41 … … 37 44 { 38 45 $acl = $this->read_acl($account_lid); 39 $array_acl = $this->make_array_acl($acl[ 0][acl]);46 $array_acl = $this->make_array_acl($acl['acl']); 40 47 41 48 //What access ?? In the IF, verify if have access. … … 43 50 { 44 51 case list_users: 45 if ($array_acl[a dd_users] || $array_acl[edit_users] || $array_acl[delete_users] || $array_acl[change_users_password] || $array_acl[change_users_quote] || $array_acl[edit_sambausers_attributes] || $array_acl[view_users])52 if ($array_acl[acl_add_users] || $array_acl[acl_edit_users] || $array_acl[acl_delete_users] || $array_acl[acl_change_users_password] || $array_acl[acl_change_users_quote] || $array_acl[acl_edit_sambausers_attributes] || $array_acl[acl_view_users] || $array_acl[acl_manipulate_corporative_information]) 46 53 return true; 47 54 break; 48 55 case add_users: 49 if ($array_acl[a dd_users])56 if ($array_acl[acl_add_users]) 50 57 return true; 51 58 break; 52 59 case edit_users: 53 if ($array_acl[ edit_users])60 if ($array_acl[acl_edit_users]) 54 61 return true; 55 62 break; 56 63 case delete_users: 57 if ($array_acl[ delete_users])64 if ($array_acl[acl_delete_users]) 58 65 return true; 59 66 break; 60 67 case rename_users: 61 if ($array_acl[ rename_users])68 if ($array_acl[acl_rename_users]) 62 69 return true; 63 70 break; 64 71 case view_users: 65 if ($array_acl[ view_users])72 if ($array_acl[acl_view_users]) 66 73 return true; 67 74 break; 68 75 case manipulate_corporative_information: 69 if ($array_acl[ manipulate_corporative_information])76 if ($array_acl[acl_manipulate_corporative_information]) 70 77 return true; 71 78 break; 72 79 case change_users_password: 73 if ($array_acl[ change_users_password])80 if ($array_acl[acl_change_users_password]) 74 81 return true; 75 82 break; 76 83 case change_users_quote: 77 if ($array_acl[ change_users_quote])84 if ($array_acl[acl_change_users_quote]) 78 85 return true; 79 86 break; 80 87 case set_user_default_password: 81 if ($array_acl[ set_user_default_password])88 if ($array_acl[acl_set_user_default_password]) 82 89 return true; 83 90 break; 84 91 case empty_user_inbox: 85 if (($array_acl[ empty_user_inbox]) && ($array_acl[edit_users]))92 if (($array_acl[acl_empty_user_inbox]) && ($array_acl[acl_edit_users])) 86 93 return true; 87 94 break; 88 95 case edit_sambausers_attributes: 89 if ($array_acl[ edit_sambausers_attributes])96 if ($array_acl[acl_edit_sambausers_attributes]) 90 97 return true; 91 98 break; 92 99 case edit_sambadomains: 93 if ($array_acl[ edit_sambadomains])100 if ($array_acl[acl_edit_sambadomains]) 94 101 return true; 95 102 break; 96 103 97 104 case list_groups: 98 if ($array_acl[a dd_groups] || $array_acl[edit_groups] || $array_acl[delete_groups])105 if ($array_acl[acl_add_groups] || $array_acl[acl_edit_groups] || $array_acl[acl_delete_groups]) 99 106 return true; 100 107 break; 101 108 case add_groups: 102 if ($array_acl[a dd_groups])109 if ($array_acl[acl_add_groups]) 103 110 return true; 104 111 break; 105 112 case edit_groups: 106 if ($array_acl[ edit_groups])113 if ($array_acl[acl_edit_groups]) 107 114 return true; 108 115 break; 109 116 case delete_groups: 110 if ($array_acl[ delete_groups])117 if ($array_acl[acl_delete_groups]) 111 118 return true; 112 119 break; 113 120 case edit_email_groups: 114 if ($array_acl[ edit_email_groups])121 if ($array_acl[acl_edit_email_groups]) 115 122 return true; 116 123 break; 117 124 118 125 case list_maillists: 119 if ($array_acl[a dd_maillists] || $array_acl[edit_maillists] || $array_acl[delete_maillists])126 if ($array_acl[acl_add_maillists] || $array_acl[acl_edit_maillists] || $array_acl[acl_delete_maillists]) 120 127 return true; 121 128 break; 122 129 case add_maillists: 123 if ($array_acl[a dd_maillists])130 if ($array_acl[acl_add_maillists]) 124 131 return true; 125 132 break; 126 133 case edit_maillists: 127 if ($array_acl[ edit_maillists])134 if ($array_acl[acl_edit_maillists]) 128 135 return true; 129 136 break; 130 137 case delete_maillists: 131 if ($array_acl[ delete_maillists])138 if ($array_acl[acl_delete_maillists]) 132 139 return true; 133 140 break; 134 141 135 142 case list_sectors: 136 if ($array_acl[ create_sectors] || $array_acl[edit_sectors] || $array_acl[delete_sectors])143 if ($array_acl[acl_create_sectors] || $array_acl[acl_edit_sectors] || $array_acl[acl_delete_sectors]) 137 144 return true; 138 145 break; 139 146 case create_sectors: 140 if ($array_acl[ create_sectors])147 if ($array_acl[acl_create_sectors]) 141 148 return true; 142 149 break; 143 150 case edit_sectors: 144 if ($array_acl[ edit_sectors])151 if ($array_acl[acl_edit_sectors]) 145 152 return true; 146 153 break; 147 154 case delete_sectors: 148 if ($array_acl[ delete_sectors])155 if ($array_acl[acl_delete_sectors]) 149 156 return true; 150 157 break; 151 158 152 159 case view_global_sessions: 153 if ($array_acl[ view_global_sessions])160 if ($array_acl[acl_view_global_sessions]) 154 161 return true; 155 162 break; 156 163 157 164 case list_computers: 158 if ($array_acl[ create_computers] || $array_acl[edit_computers] || $array_acl[delete_computers])165 if ($array_acl[acl_create_computers] || $array_acl[acl_edit_computers] || $array_acl[acl_delete_computers]) 159 166 return true; 160 167 break; 161 168 case create_computers: 162 if ($array_acl[ create_computers])169 if ($array_acl[acl_create_computers]) 163 170 return true; 164 171 break; 165 172 case edit_computers: 166 if ($array_acl[ edit_computers])173 if ($array_acl[acl_edit_computers]) 167 174 return true; 168 175 break; 169 176 case delete_computers: 170 if ($array_acl[ delete_computers])177 if ($array_acl[acl_delete_computers]) 171 178 return true; 172 179 break; 173 180 174 181 case view_logs: 175 if ($array_acl[view_logs]) 182 if ($array_acl[acl_view_logs]) 183 return true; 184 break; 185 186 case display_groups: 187 if ( $array_acl[acl_edit_users] || $array_acl[acl_view_users] || ($array_acl[acl_edit_sambausers_attributes] && ($this->current_config['expressoAdmin_samba_support'] == 'true')) ) 188 return true; 189 break; 190 case display_emailconfig: 191 if ($array_acl[acl_edit_users] || $array_acl[acl_view_users]) 192 return true; 193 break; 194 case display_applications: 195 if ($array_acl[acl_edit_users] || $array_acl[acl_view_users]) 196 return true; 197 break; 198 case display_emaillists: 199 if ($array_acl[acl_edit_users] || $array_acl[acl_view_users]) 176 200 return true; 177 201 break; … … 180 204 return false; 181 205 } 182 183 206 return false; 184 207 } … … 187 210 function read_acl($account_lid) 188 211 { 189 $result = $this->db_functions->read_acl($account_lid); 190 $context_array = ldap_explode_dn($result[0]['context'], 1); 191 $result[0]['context_display'] = ldap_dn2ufn ( $result[0]['context'] ); 212 $acl = $this->db_functions->read_acl($account_lid); 213 214 $result['acl'] = $acl[0]['acl']; 215 $result['manager_lid'] = $acl[0]['manager_lid']; 216 $result['raw_context'] = $acl[0]['context']; 217 218 $all_contexts = split("%", $acl[0]['context']); 219 foreach ($all_contexts as $index=>$context) 220 { 221 $result['contexts'][] = $context; 222 $result['contexts_display'][] = str_replace(", ", ".", ldap_dn2ufn( $context )); 223 } 224 192 225 return $result; 193 226 } 194 227 195 228 // Make a array read humam 196 // Last acl: 33.554.432, 67.108.864, 134.217.728, 134.217.728, 268.435.456229 // Last acl: 268435456, 536870912 197 230 function make_array_acl($acl) 198 231 { 199 $array_acl['a dd_users'] = $acl & 1;200 $array_acl[' edit_users'] = $acl & 2;201 $array_acl[' delete_users'] = $acl & 4;202 $array_acl[' rename_users'] = $acl & 8388608;203 $array_acl[' view_users'] = $acl & 33554432;204 $array_acl[' manipulate_corporative_information'] = $acl & 268435456;205 $array_acl['a dd_groups'] = $acl & 16;206 $array_acl[' edit_groups'] = $acl & 32;207 $array_acl[' delete_groups'] = $acl & 64;208 $array_acl[' edit_email_groups'] = $acl & 67108864;209 $array_acl[' change_users_password'] = $acl & 128;210 $array_acl[' change_users_quote'] = $acl & 262144;211 $array_acl[' set_user_default_password'] = $acl & 524288;212 $array_acl[' empty_user_inbox'] = $acl & 134217728;213 $array_acl[' edit_sambausers_attributes'] = $acl & 32768;214 $array_acl[' edit_sambadomains'] = $acl & 16777216;215 $array_acl['a dd_maillists'] = $acl & 256;216 $array_acl[' edit_maillists'] = $acl & 512;217 $array_acl[' delete_maillists'] = $acl & 1024;218 $array_acl[' create_sectors'] = $acl & 4096;219 $array_acl[' edit_sectors'] = $acl & 8192;220 $array_acl[' delete_sectors'] = $acl & 16384;221 $array_acl[' view_global_sessions'] = $acl & 65536;222 $array_acl[' view_logs'] = $acl & 131072;223 $array_acl[' create_computers'] = $acl & 1048576;224 $array_acl[' edit_computers'] = $acl & 2097152;225 $array_acl[' delete_computers'] = $acl & 4194304;232 $array_acl['acl_add_users'] = $acl & 1; 233 $array_acl['acl_edit_users'] = $acl & 2; 234 $array_acl['acl_delete_users'] = $acl & 4; 235 $array_acl['acl_rename_users'] = $acl & 8388608; 236 $array_acl['acl_view_users'] = $acl & 33554432; 237 $array_acl['acl_manipulate_corporative_information'] = $acl & 268435456; 238 $array_acl['acl_add_groups'] = $acl & 16; 239 $array_acl['acl_edit_groups'] = $acl & 32; 240 $array_acl['acl_delete_groups'] = $acl & 64; 241 $array_acl['acl_edit_email_groups'] = $acl & 67108864; 242 $array_acl['acl_change_users_password'] = $acl & 128; 243 $array_acl['acl_change_users_quote'] = $acl & 262144; 244 $array_acl['acl_set_user_default_password'] = $acl & 524288; 245 $array_acl['acl_empty_user_inbox'] = $acl & 134217728; 246 $array_acl['acl_edit_sambausers_attributes'] = $acl & 32768; 247 $array_acl['acl_edit_sambadomains'] = $acl & 16777216; 248 $array_acl['acl_add_maillists'] = $acl & 256; 249 $array_acl['acl_edit_maillists'] = $acl & 512; 250 $array_acl['acl_delete_maillists'] = $acl & 1024; 251 $array_acl['acl_create_sectors'] = $acl & 4096; 252 $array_acl['acl_edit_sectors'] = $acl & 8192; 253 $array_acl['acl_delete_sectors'] = $acl & 16384; 254 $array_acl['acl_view_global_sessions'] = $acl & 65536; 255 $array_acl['acl_view_logs'] = $acl & 131072; 256 $array_acl['acl_create_computers'] = $acl & 1048576; 257 $array_acl['acl_edit_computers'] = $acl & 2097152; 258 $array_acl['acl_delete_computers'] = $acl & 4194304; 226 259 return $array_acl; 227 260 } 228 261 229 function get_list($type, $query, $context )262 function get_list($type, $query, $contexts) 230 263 { 231 264 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; … … 238 271 if ($type == 'accounts') 239 272 { 240 241 273 $justthese = array("uidnumber", "uid", "cn", "mail"); 242 274 $filter="(&(phpgwAccountType=u)(|(uid=*".$query."*)(sn=*".$query."*)(cn=*".$query."*)(givenName=*".$query."*)(mail=$query*)(mailAlternateAddress=$query*)))"; 243 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 244 ldap_sort($ldap_conn, $search, "uid"); 245 $info = ldap_get_entries($ldap_conn, $search); 275 276 $tmp = array(); 277 foreach ($contexts as $index=>$context) 278 { 279 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 280 $info = ldap_get_entries($ldap_conn, $search); 281 282 for ($i=0; $i < $info['count']; $i++) 283 { 284 $tmp[$info[$i]['uid'][0]]['account_id'] = $info[$i]['uidnumber'][0]; 285 $tmp[$info[$i]['uid'][0]]['account_lid'] = $info[$i]['uid'][0]; 286 $tmp[$info[$i]['uid'][0]]['account_cn'] = $info[$i]['cn'][0]; 287 $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0]; 288 $sort[] = $info[$i]['uid'][0]; 289 } 290 } 246 291 ldap_close($ldap_conn); 247 292 248 $i = 0; 293 if (count($sort)) 294 { 295 natcasesort($sort); 296 foreach ($sort as $user_uid) 297 $return[$user_uid] = $tmp[$user_uid]; 298 } 299 300 return $return; 301 } 302 elseif($type == 'groups') 303 { 304 $filter="(&(phpgwAccountType=g)(cn=*$query*))"; 305 $justthese = array("gidnumber", "cn", "description"); 306 249 307 $tmp = array(); 250 for ($i=0; $i < $info['count']; $i++) 251 { 252 $tmp[$i][account_id] = $info[$i]['uidnumber'][0]; 253 $tmp[$i][account_lid] = $info[$i]['uid'][0]; 254 $tmp[$i][account_cn] = $info[$i]['cn'][0]; 255 $tmp[$i][account_mail] = $info[$i]['mail'][0]; 256 } 257 return $tmp; 258 } 259 elseif($type == 'groups') 260 { 261 $filter="(&(phpgwAccountType=g)(cn=*".$query."*))"; 262 $justthese = array("gidnumber", "cn", "description"); 263 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 264 ldap_sort($ldap_conn, $search, "cn"); 265 $info = ldap_get_entries($ldap_conn, $search); 308 foreach ($contexts as $index=>$context) 309 { 310 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 311 $info = ldap_get_entries($ldap_conn, $search); 312 for ($i=0; $i < $info['count']; $i++) 313 { 314 $tmp[$info[$i]['cn'][0]]['cn']= $info[$i]['cn'][0]; 315 $tmp[$info[$i]['cn'][0]]['description']= $info[$i]['description'][0]; 316 $tmp[$info[$i]['cn'][0]]['gidnumber']= $info[$i]['gidnumber'][0]; 317 $sort[] = $info[$i]['cn'][0]; 318 } 319 } 266 320 ldap_close($ldap_conn); 267 321 268 $i = 0; 269 $tmp = array(); 270 for ($i=0; $i < $info['count']; $i++) 271 { 272 $tmp[$i][cn] = $info[$i][cn][0]; 273 $tmp[$i][description] = $info[$i][description][0]; 274 $tmp[$i][gidnumber] = $info[$i][gidnumber][0]; 275 } 276 return $tmp; 322 natcasesort($sort); 323 foreach ($sort as $group_cn) 324 $return[$group_cn] = $tmp[$group_cn]; 325 326 return $return; 277 327 } 278 328 elseif($type == 'maillists') … … 280 330 $filter="(&(phpgwAccountType=l)(|(cn=*".$query."*)(uid=*".$query."*)(mail=*".$query."*)))"; 281 331 $justthese = array("uidnumber", "cn", "uid", "mail"); 282 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 283 ldap_sort($ldap_conn, $search, "uid"); 284 $info = ldap_get_entries($ldap_conn, $search); 332 333 $tmp = array(); 334 foreach ($contexts as $index=>$context) 335 { 336 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 337 $info = ldap_get_entries($ldap_conn, $search); 338 339 for ($i=0; $i < $info['count']; $i++) 340 { 341 $tmp[$info[$i]['uid'][0]]['uid'] = $info[$i]['uid'][0]; 342 $tmp[$info[$i]['uid'][0]]['name'] = $info[$i]['cn'][0]; 343 $tmp[$info[$i]['uid'][0]]['uidnumber'] = $info[$i]['uidnumber'][0]; 344 $tmp[$info[$i]['uid'][0]]['email'] = $info[$i]['mail'][0]; 345 $sort[] = $info[$i]['uid'][0]; 346 } 347 } 285 348 ldap_close($ldap_conn); 286 349 287 $i = 0; 288 $tmp = array(); 289 for ($i=0; $i < $info['count']; $i++) 290 { 291 $tmp[$i]['uid'] = $info[$i]['uid'][0]; 292 $tmp[$i]['name'] = $info[$i]['cn'][0]; 293 $tmp[$i]['uidnumber'] = $info[$i]['uidnumber'][0]; 294 $tmp[$i]['email'] = $info[$i]['mail'][0]; 295 } 296 return $tmp; 350 natcasesort($sort); 351 foreach ($sort as $maillist_uid) 352 $return[$maillist_uid] = $tmp[$maillist_uid]; 353 354 return $return; 297 355 } 298 356 elseif($type == 'computers') … … 300 358 $filter="(&(objectClass=sambaSAMAccount)(|(sambaAcctFlags=[W ])(sambaAcctFlags=[DW ])(sambaAcctFlags=[I ])(sambaAcctFlags=[S ]))(cn=*".$query."*))"; 301 359 $justthese = array("cn","uidNumber","description"); 302 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 303 ldap_sort($ldap_conn, $search, "cn"); 304 $info = ldap_get_entries($ldap_conn, $search); 360 361 $tmp = array(); 362 foreach ($contexts as $index=>$context) 363 { 364 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 365 $info = ldap_get_entries($ldap_conn, $search); 366 for ($i=0; $i < $info['count']; $i++) 367 { 368 $tmp[$info[$i]['cn'][0]]['cn'] = $info[$i]['cn'][0]; 369 $tmp[$info[$i]['cn'][0]]['uidNumber'] = $info[$i]['uidnumber'][0]; 370 $tmp[$info[$i]['cn'][0]]['description'] = utf8_decode($info[$i]['description'][0]); 371 $sort[] = $info[$i]['cn'][0]; 372 } 373 374 } 305 375 ldap_close($ldap_conn); 306 $tmp = array(); 307 for ($i=0; $i < $info['count']; $i++) 308 { 309 $tmp[$i]['cn'] = $info[$i]['cn'][0]; 310 $tmp[$i]['uidNumber'] = $info[$i]['uidnumber'][0]; 311 $tmp[$i]['description'] = utf8_decode($info[$i]['description'][0]); 312 } 313 return $tmp; 314 } 315 } 316 317 //Criado nova função bem mais eficiente! 318 /* 319 function get_organizations($context, $selected='') 320 { 321 //echo $selected; 322 323 $first_sector_ufn = ldap_dn2ufn($context); 324 $first_sector_string = split(",", $first_sector_ufn); 325 326 $s = CreateObject('phpgwapi.sector_search_ldap'); 327 $sectors_info = $s->sector_search($context); 328 329 $sector_select = ""; 330 $sector_select .= "<option value='" .$context . "'"; 331 $sector_select .= ">".strtoupper($first_sector_string[0])."</option>\n"; 332 333 foreach($sectors_info as $sector) 334 { 335 if ($sector->sector_level == 1) 336 { 337 $sector->sector_name = '+ '.$sector->sector_name; 338 } 339 else 340 { 341 $sector_space = ''; 342 for ($i=1; $i < $sector->sector_level; $i++) 343 $sector_space = '---'.$sector_space; 344 $sector->sector_name = $sector_space.' '.$sector->sector_name; 345 } 346 $sector_select .= '<option value="' . strtolower($sector->sector_context) . '"'; 347 348 if (trim(strtolower($sector->sector_context)) == $selected) 349 $sector_select .= ' selected>' . $sector->sector_name . "</option>\n"; 350 else 351 $sector_select .= '>' . $sector->sector_name . "</option>\n"; 352 } 353 //$sector_select .= "</select>"; 354 return $sector_select; 355 } 356 */ 357 358 /* 359 function get_organizations($context, $selected='', $show_invisible_ou=false) 360 { 361 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 362 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 363 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 364 365 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 366 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 367 ldap_bind($ldap_conn,$dn,$passwd); 368 369 $justthese = array("dn"); 370 $filter = $show_invisible_ou ? "(ou=*)" : "(& (ou=*) (!(phpgwAccountVisible=-1)) )"; 371 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 372 373 ldap_sort($ldap_conn, $search, "ou"); 374 $info = ldap_get_entries($ldap_conn, $search); 375 ldap_close($ldap_conn); 376 377 // Retiro o count do array info e inverto o array para ordenação. 378 for ($i=0; $i<$info["count"]; $i++) 379 { 380 $dn = $info[$i]["dn"]; 381 382 // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 383 if (strtolower($dn) == $context) 384 continue; 385 386 $array_dn = ldap_explode_dn ( $dn, 1 ); 387 388 $array_dn_reverse = array_reverse ( $array_dn, true ); 389 390 array_pop ( $array_dn_reverse ); 391 392 $inverted_dn[$dn] = implode ( ".", $array_dn_reverse ); 393 } 394 395 // Ordenação 396 natcasesort($inverted_dn); 397 398 // Construção do select 399 $level = 0; 400 foreach ($inverted_dn as $dn=>$invert_ufn) 401 { 402 $display = ''; 403 404 $array_dn_reverse = explode ( ".", $invert_ufn ); 405 $array_dn = array_reverse ( $array_dn_reverse, true ); 406 407 $level = count( $array_dn ) - 4; 408 409 if ($level == 0) 410 $display .= '+'; 411 else { 412 for ($i=0; $i<$level; $i++) 413 $display .= '---'; 414 } 415 416 reset ( $array_dn ); 417 $display .= ' ' . (current ( $array_dn ) ); 418 419 $dn = trim(strtolower($dn)); 420 if ( $dn == $selected ) 421 $select = ' selected'; 422 else 423 $select = ''; 424 $options .= "<option value='$dn'$select>$display</option>"; 425 } 426 427 // Cria a primeira entrada na combo 428 $first_sector_ufn = ldap_dn2ufn($context); 429 $first_sector_string = split(",", $first_sector_ufn); 430 $options = "<option value='$context'>" . strtoupper($first_sector_string[0]) . "</option>" . $options; 431 432 return $options; 433 } 434 */ 376 377 natcasesort($sort); 378 foreach ($sort as $computer_cn) 379 $return[$computer_cn] = $tmp[$computer_cn]; 380 381 return $return; 382 } 383 } 435 384 436 385 function get_organizations($context, $selected='', $referral=false, $show_invisible_ou=true) … … 448 397 } 449 398 450 /*451 function get_sectors($context, $selected='')452 {453 $query = "SELECT sector FROM phpgw_expressoadmin_sectors WHERE organization = '" . $context . "'";454 $GLOBALS['phpgw']->db->query($query);455 while($GLOBALS['phpgw']->db->next_record())456 {457 $query_result[] = $GLOBALS['phpgw']->db->row();458 }459 460 if (count($query_result) > 0)461 {462 foreach ($query_result as $index=>$tmp)463 {464 $sector = $tmp['sector'];465 if ($sector == $selected)466 $sector_options .= "<option value='$sector' selected>$sector</option>";467 else468 $sector_options .= "<option value='$sector'>$sector</option>";469 }470 return $sector_options;471 }472 else473 return false;474 }475 */476 477 399 // Get list of all levels, this function is used for sectors module. 478 /* 479 function get_sectors_list($context) 480 { 481 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 482 ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3); 483 ldap_set_option($connection, LDAP_OPT_REFERRALS, 0); 484 485 if ($connection) 486 { 487 $bind=ldap_bind($connection); 488 $filter="ou=*"; 489 $justthese = array("ou"); 490 $search=ldap_list($connection, $context, $filter, $justthese); 491 ldap_sort($connection, $search, "ou"); 492 $info = ldap_get_entries($connection, $search); 493 for ($i=0; $i<$info["count"]; $i++) 494 { 495 $this->level++; 496 $next_context[$i] = 'ou='.$info[$i]["ou"][0].','.$context; 497 $obj = new sectors_object($info[$i]["ou"][0], $next_context[$i], $this->level, 'False'); 498 array_push($this->sectors_list, $obj); 499 $this->get_sectors_list($next_context[$i]); 500 } 501 } 502 ldap_close($connection); 503 $this->level--; 504 return $this->sectors_list; 505 } 506 */ 507 508 // Get list of all levels, this function is used for sectors module. 509 function get_sectors_list($context, $selected='', $referral=false ,$show_invisible_ou=false) 510 { 400 function get_sectors_list($contexts) 401 { 402 $a_sectors = array(); 403 511 404 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 512 405 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; … … 514 407 515 408 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 516 517 if ($referral) 518 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 519 else 520 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 521 409 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 522 410 ldap_bind($ldap_conn,$dn,$passwd); 523 411 524 412 $justthese = array("dn"); 525 413 $filter = "(ou=*)"; 526 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 414 415 foreach ($contexts as $context) 416 { 417 $search=ldap_search($ldap_conn, $context, $filter, $justthese); 418 $info = ldap_get_entries($ldap_conn, $search); 419 for ($i=0; $i<$info["count"]; $i++) 420 { 421 $a_sectors[] = $info[$i]['dn']; 422 } 423 } 527 424 528 ldap_sort($ldap_conn, $search, "ou");529 $info = ldap_get_entries($ldap_conn, $search);530 425 ldap_close($ldap_conn); 531 426 532 427 // Retiro o count do array info e inverto o array para ordenação. 533 for ($i=0; $i<$info["count"]; $i++)428 foreach ($a_sectors as $context) 534 429 { 535 $dn = $info[$i]["dn"]; 536 537 // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 538 if (strtolower($dn) == $context) 430 // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. 431 /* 432 if (strtolower($dn) == $contexts[0]) 539 433 continue; 540 541 $array_dn = ldap_explode_dn ( $dn, 1 ); 434 */ 435 436 $array_dn = ldap_explode_dn ( $context, 1 ); 542 437 543 438 $array_dn_reverse = array_reverse ( $array_dn, true ); … … 546 441 array_pop ( $array_dn_reverse ); 547 442 548 $inverted_dn[$ dn] = implode ( "#", $array_dn_reverse );443 $inverted_dn[$context] = implode ( "#", $array_dn_reverse ); 549 444 } 550 445 … … 637 532 } 638 533 639 function increment_id($id, $type) 640 { 641 $sql = "UPDATE phpgw_nextid set id = '".$id."' WHERE appname = '" . $type . "'"; 642 $GLOBALS['phpgw']->db->query($sql); 643 } 644 645 function make_list_app($account_lid, $context, $user_applications, $disabled='') 534 function make_list_app($account_lid, $user_applications='', $disabled='') 646 535 { 647 536 // create list of ALL available apps … … 649 538 650 539 // create list of available apps for the user 651 $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '".$account_lid."' AND context = '".$context."'";540 $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '".$account_lid."'"; 652 541 $GLOBALS['phpgw']->db->query($query); 653 542 while($GLOBALS['phpgw']->db->next_record()) -
trunk/expressoAdmin1_2/inc/class.group.inc.php
r46 r64 54 54 $array_tmp = array_unique($params['members']); 55 55 $params['members'] = $array_tmp; 56 56 57 // Leio o ID a ser usado na criação do objecto. 58 $next_id = ($this->db_functions->get_next_id('groups')); 59 if ((!is_numeric($next_id['id'])) || (!$next_id['status'])) 60 { 61 $return['status'] = false; 62 $return['msg'] = "Problemas obtendo ID do usuário.\n" . $id['msg']; 63 return $return; 64 } 65 else 66 { 67 $id = $next_id['id']; 68 } 57 69 // Pega ID do BD e incrementa de 1. 58 $id = (($this->db_functions->get_next_id()) + 1); 59 70 //$id = (($this->db_functions->get_next_id()) + 1); 60 71 // Incrementa o id no BD. 61 $this->db_functions->increment_id($id,'groups');72 //$this->db_functions->increment_id($id,'groups'); 62 73 63 74 // Cria array para incluir no LDAP … … 400 411 401 412 402 function get_info($gidnumber , $context)403 { 404 $group_info_ldap = $this->ldap_functions->get_group_info($gidnumber , $context);413 function get_info($gidnumber) 414 { 415 $group_info_ldap = $this->ldap_functions->get_group_info($gidnumber); 405 416 $group_info_db = $this->db_functions->get_group_info($gidnumber); 406 417 -
trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
r63 r64 10 10 var $current_config; 11 11 var $functions; 12 var $manager_contexts; 12 13 13 14 function ldap_functions(){ … … 16 17 $common = new common(); 17 18 $this->ldap = $common->ldapConnect(); 19 18 20 $this->functions = new functions; 21 $manager_acl = $this->functions->read_acl($_SESSION['phpgw_info']['expresso']['user']['account_lid']); 22 $this->manager_contexts = $manager_acl['contexts']; 19 23 } 20 24 21 25 function validate_fields($params) 22 26 { 27 /* ldap connection following referals and using Contac Center config*/ 28 if (is_array($_SESSION['phpgw_info']['expresso']['cc_ldap_server'])) 29 { 30 $ldap_connection = ldap_connect($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['host']); 31 if ($ldap_connection) 32 { 33 ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 34 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 35 if ( ($GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['acc'] != '') && ($GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['pw'] != '') ) 36 ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['acc'], $GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['pw']); 37 $context = $_SESSION['phpgw_info']['expresso']['cc_ldap_server']['dn']; 38 } 39 else 40 { 41 $result['status'] = false; 42 $result['msg'] = 'Falha na conexao com o ldap.'; 43 return $result; 44 } 45 } 46 else 47 { 48 $ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 49 ldap_set_option($ldap_connection,LDAP_OPT_PROTOCOL_VERSION,3); 50 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 51 ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); 52 $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 53 } 54 23 55 $result['status'] = true; 56 24 57 $params = unserialize($params['attributes']); 25 58 $type = $params['type']; 26 $context = $GLOBALS['phpgw_info']['server']['ldap_context'];27 59 $uid = $params['uid']; 28 60 $mail = $params['mail']; … … 38 70 if (($type == 'create_user') || ($type == 'rename_user')) 39 71 { 40 // UID 41 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uid=$uid))"; 72 //UID 73 if (($type == 'rename_user') && ($this->current_config['expressoAdmin_prefix_org'] == 'true')) 74 { 75 //Obtenho UID sem a organização. Na criação o uid já vem sem a organização 76 $tmp_uid_without_org = split("-", $params['uid']); 77 $tmp_reverse_uid_without_org = array_reverse($tmp_uid_without_org); 78 array_pop($tmp_reverse_uid_without_org); 79 $uid_without_org = implode("-", $tmp_reverse_uid_without_org); 80 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(uid=$uid)(uid=$uid_without_org)))"; 81 } 82 else 83 { 84 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uid=$uid))"; 85 } 42 86 $justthese = array("uid"); 43 $search = ldap_search($ this->ldap, $context, $filter, $justthese);44 $count_entries = ldap_count_entries($ this->ldap,$search);87 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 88 $count_entries = ldap_count_entries($ldap_connection,$search); 45 89 if ($count_entries > 0) 46 90 { 47 91 $result['status'] = false; 48 $result['msg'] = 'LOGIN já est a sendo usado.';92 $result['msg'] = 'LOGIN já está sendo utilizado.'; 49 93 return $result; 50 94 } … … 53 97 $filter = "(&(phpgwAccountType=g)(cn=$uid))"; 54 98 $justthese = array("cn"); 55 $search = ldap_search($ this->ldap, $context, $filter, $justthese);56 $count_entries = ldap_count_entries($ this->ldap,$search);99 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 100 $count_entries = ldap_count_entries($ldap_connection,$search); 57 101 if ($count_entries > 0) 58 102 { … … 61 105 return $result; 62 106 } 63 64 // UID em outras organizações 65 //Quando tento retirar as organizações pelo expressoAdmin dá este erro. 66 $filter = "(ou=*)"; 67 $justthese = array("ou"); 68 $search = ldap_list($this->ldap, $context, $filter, $justthese); 69 $entries = ldap_get_entries($this->ldap,$search); 70 foreach ($entries as $index=>$org) 71 { 72 $organization = $org['ou'][0]; 73 $organization = strtolower($organization); 107 108 109 // UID em outras organizações, pesquiso apenas na maquina local e se utilizar prefix_org 110 if ($this->current_config['expressoAdmin_prefix_org'] == 'true') 111 { 112 $ldap_connection2 = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 113 ldap_set_option($ldap_connection2,LDAP_OPT_PROTOCOL_VERSION,3); 114 ldap_set_option($ldap_connection2, LDAP_OPT_REFERRALS, false); 115 ldap_bind($ldap_connection2, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); 116 $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 74 117 75 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uid=$organization-$uid))"; 76 $justthese = array("uid"); 77 $search = ldap_search($this->ldap, $context, $filter, $justthese); 78 $count_entries = ldap_count_entries($this->ldap,$search); 79 if ($count_entries > 0) 118 //Obtenho UID sem a organização 119 /* 120 $tmp_uid_without_org = split("-", $params['uid']); 121 if (count($tmp_uid_without_org) < 2) 80 122 { 81 123 $result['status'] = false; 82 $result['msg'] = ' LOGIN já esta sendo usado por outro usuário em outraorganização.';124 $result['msg'] = 'Novo login sem organização.'; 83 125 return $result; 84 126 } 127 $tmp_reverse_uid_without_org = array_reverse($tmp_uid_without_org); 128 array_pop($tmp_reverse_uid_without_org); 129 $uid_without_org = implode("-", $tmp_reverse_uid_without_org); 130 */ 131 132 $filter = "(ou=*)"; 133 $justthese = array("ou"); 134 $search = ldap_list($ldap_connection2, $context, $filter, $justthese); 135 $entries = ldap_get_entries($ldap_connection2 ,$search); 136 137 foreach ($entries as $index=>$org) 138 { 139 $organization = $org['ou'][0]; 140 $organization = strtolower($organization); 141 142 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uid=$organization-$uid))"; 143 144 $justthese = array("uid"); 145 $search = ldap_search($ldap_connection2, $context, $filter, $justthese); 146 $count_entries = ldap_count_entries($ldap_connection2,$search); 147 if ($count_entries > 0) 148 { 149 $result['status'] = false; 150 $result['msg'] = 'LOGIN já esta sendo usado por outro usuário em outra organização.'; 151 ldap_close($ldap_connection2); 152 return $result; 153 } 154 } 155 ldap_close($ldap_connection2); 85 156 } 86 157 } … … 94 165 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(mail=$mail)(mailalternateaddress=$mail)))"; 95 166 $justthese = array("mail", "uid"); 96 $search = ldap_search($ this->ldap, $context, $filter, $justthese);97 $entries = ldap_get_entries($ this->ldap,$search);167 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 168 $entries = ldap_get_entries($ldap_connection,$search); 98 169 if ($entries['count'] == 1){ 99 170 if ($entries[0]['uid'][0] != $uid){ 100 171 $result['status'] = false; 101 172 $result['msg'] = 'E-MAIL está sendo usado por 1 usuário: ' . $entries[0]['uid'][0]; 102 //ldap_close($ this->ldap);173 //ldap_close($ldap_connection); 103 174 return $result; 104 175 } … … 106 177 else if ($entries['count'] > 1){ 107 178 $result['status'] = false; 108 $result['msg'] = 'E-MAIL está sendo usado por de2 ou mais usuários.';109 //ldap_close($ this->ldap);179 $result['msg'] = 'E-MAIL está sendo usado por 2 ou mais usuários.'; 180 //ldap_close($ldap_connection); 110 181 return $result; 111 182 } … … 114 185 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(mail=$mailalternateaddress)(mailalternateaddress=$mailalternateaddress)))"; 115 186 $justthese = array("mail", "uid"); 116 $search = ldap_search($ this->ldap, $context, $filter, $justthese);117 $entries = ldap_get_entries($ this->ldap,$search);187 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 188 $entries = ldap_get_entries($ldap_connection,$search); 118 189 if ($entries['count'] == 1){ 119 190 if ($entries[0]['uid'][0] != $uid){ 120 191 $result['status'] = false; 121 192 $result['msg'] = "E-MAIL alternativo está sendo usado por 1 usuário: " . $entries[0]['uid'][0]; 122 //ldap_close($ this->ldap);193 //ldap_close($ldap_connection); 123 194 return $result; 124 195 } … … 135 206 function validate_fields_group($params) 136 207 { 137 $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 208 /* ldap connection following referals and using Contac Center config*/ 209 if (is_array($_SESSION['phpgw_info']['expresso']['cc_ldap_server'])) 210 { 211 $ldap_connection = ldap_connect($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['host']); 212 if ($ldap_connection) 213 { 214 ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 215 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 216 if ( ($GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['acc'] != '') && ($GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['pw'] != '') ) 217 ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['acc'], $GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['pw']); 218 $context = $_SESSION['phpgw_info']['expresso']['cc_ldap_server']['dn']; 219 } 220 else 221 { 222 $result['status'] = false; 223 $result['msg'] = 'Falha na conexao com o ldap.'; 224 return $result; 225 } 226 } 227 else 228 { 229 $ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 230 ldap_set_option($ldap_connection,LDAP_OPT_PROTOCOL_VERSION,3); 231 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 232 ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); 233 $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 234 } 235 138 236 $cn = $params['cn']; 139 237 $result['status'] = true; … … 149 247 $filter = "(&(phpgwAccountType=g)(cn=$cn))"; 150 248 $justthese = array("cn"); 151 $search = ldap_search($ this->ldap, $context, $filter, $justthese);152 $count_entries = ldap_count_entries($ this->ldap,$search);249 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 250 $count_entries = ldap_count_entries($ldap_connection,$search); 153 251 if ($count_entries > 0) 154 252 { … … 161 259 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(uid=$cn))"; 162 260 $justthese = array("uid"); 163 $search = ldap_search($ this->ldap, $context, $filter, $justthese);164 $count_entries = ldap_count_entries($ this->ldap,$search);261 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 262 $count_entries = ldap_count_entries($ldap_connection,$search); 165 263 if ($count_entries > 0) 166 264 { … … 175 273 function validate_fields_maillist($params) 176 274 { 177 $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 275 /* ldap connection following referals and using Contac Center config*/ 276 if (is_array($_SESSION['phpgw_info']['expresso']['cc_ldap_server'])) 277 { 278 $ldap_connection = ldap_connect($_SESSION['phpgw_info']['expresso']['cc_ldap_server']['host']); 279 if ($ldap_connection) 280 { 281 ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3); 282 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 283 if ( ($GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['acc'] != '') && ($GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['pw'] != '') ) 284 ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['acc'], $GLOBALS['phpgw_info']['expresso']['cc_ldap_server']['pw']); 285 $context = $_SESSION['phpgw_info']['expresso']['cc_ldap_server']['dn']; 286 } 287 else 288 { 289 $result['status'] = false; 290 $result['msg'] = 'Falha na conexao com o ldap.'; 291 return $result; 292 } 293 } 294 else 295 { 296 $ldap_connection = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 297 ldap_set_option($ldap_connection,LDAP_OPT_PROTOCOL_VERSION,3); 298 ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, true); 299 ldap_bind($ldap_connection, $GLOBALS['phpgw_info']['server']['ldap_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_root_pw']); 300 $context = $GLOBALS['phpgw_info']['server']['ldap_context']; 301 } 302 178 303 $uid = $params['uid']; 179 304 $mail = $params['mail']; … … 190 315 $filter = "(&(phpgwAccountType=l)(uid=$uid))"; 191 316 $justthese = array("uid"); 192 $search = ldap_search($ this->ldap, $context, $filter, $justthese);193 $count_entries = ldap_count_entries($ this->ldap,$search);317 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 318 $count_entries = ldap_count_entries($ldap_connection,$search); 194 319 if ($count_entries > 0) 195 320 { … … 203 328 $filter = "(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|(mail=$mail)(mailalternateaddress=$mail)))"; 204 329 $justthese = array("mail"); 205 $search = ldap_search($ this->ldap, $context, $filter, $justthese);206 $count_entries = ldap_count_entries($ this->ldap,$search);330 $search = ldap_search($ldap_connection, $context, $filter, $justthese); 331 $count_entries = ldap_count_entries($ldap_connection,$search); 207 332 if ($count_entries > 0) 208 333 { … … 610 735 } 611 736 612 function get_user_info($uidnumber, $context) 613 { 614 $filter="(&(phpgwAccountType=u)(uidNumber=".$uidnumber."))"; 615 $search = ldap_search($this->ldap, $context, $filter); 616 $entry = ldap_get_entries($this->ldap, $search); 617 618 //Pega o dn do setor do usuario. 619 $entry[0]['dn'] = strtolower($entry[0]['dn']); 620 $sector_dn_array = explode(",", $entry[0]['dn']); 621 for($i=1; $i<count($sector_dn_array); $i++) 622 $sector_dn .= $sector_dn_array[$i] . ','; 623 //Retira ultimo pipe. 624 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 625 626 $result['context'] = $sector_dn; 627 $result['uid'] = $entry[0]['uid'][0]; 628 $result['uidnumber'] = $entry[0]['uidnumber'][0]; 629 $result['gidnumber'] = $entry[0]['gidnumber'][0]; 630 $result['departmentnumber'] = $entry[0]['departmentnumber'][0]; 631 $result['givenname'] = $entry[0]['givenname'][0]; 632 $result['sn'] = $entry[0]['sn'][0]; 633 $result['telephonenumber'] = $entry[0]['telephonenumber'][0]; 634 $result['phpgwaccountstatus'] = $entry[0]['phpgwaccountstatus'][0]; 635 $result['phpgwaccountvisible'] = $entry[0]['phpgwaccountvisible'][0]; 636 $result['accountstatus'] = $entry[0]['accountstatus'][0]; 637 $result['mail'] = $entry[0]['mail'][0]; 638 $result['mailalternateaddress'] = $entry[0]['mailalternateaddress'][0]; 639 $result['mailforwardingaddress']= $entry[0]['mailforwardingaddress'][0]; 640 $result['deliverymode'] = $entry[0]['deliverymode'][0]; 641 $result['userPasswordRFC2617'] = $entry[0]['userpasswordrfc2617'][0]; 642 643 //Photo 644 if ($entry[0]['jpegphoto']['count'] == 1) 645 $result['photo_exist'] = 'true'; 646 647 // Samba 648 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 649 { 650 if ($entry[0]['objectclass'][$i] == 'sambaSamAccount') 651 $result['sambaUser'] = true; 652 } 653 if (($this->current_config['expressoAdmin_samba_support'] == 'true') && ($result['sambaUser'])) 654 { 655 $result['sambaaccflags'] = $entry[0]['sambaacctflags'][0]; 656 $result['sambalogonscript'] = $entry[0]['sambalogonscript'][0]; 657 $result['homedirectory'] = $entry[0]['homedirectory'][0]; 658 $a_tmp = explode("-", $entry[0]['sambasid'][0]); 659 array_pop($a_tmp); 660 $result['sambasid'] = implode("-", $a_tmp); 661 } 662 663 // Verifica o acesso do gerente aos atributos corporativos 664 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) 665 { 666 $result['corporative_information_employeenumber']= $entry[0]['employeenumber'][0]; 667 $result['corporative_information_cpf'] = $entry[0]['cpf'][0]; 668 $result['corporative_information_rg'] = $entry[0]['rg'][0]; 669 $result['corporative_information_rguf'] = $entry[0]['rguf'][0]; 670 } 671 672 // MailLists 737 function get_user_info($uidnumber) 738 { 739 foreach ($this->manager_contexts as $index=>$context) 740 { 741 $filter="(&(phpgwAccountType=u)(uidNumber=".$uidnumber."))"; 742 $search = ldap_search($this->ldap, $context, $filter); 743 $entry = ldap_get_entries($this->ldap, $search); 744 745 if ($entry['count']) 746 { 747 //Pega o dn do setor do usuario. 748 $entry[0]['dn'] = strtolower($entry[0]['dn']); 749 $sector_dn_array = explode(",", $entry[0]['dn']); 750 for($i=1; $i<count($sector_dn_array); $i++) 751 $sector_dn .= $sector_dn_array[$i] . ','; 752 //Retira ultimo pipe. 753 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 754 755 $result['context'] = $sector_dn; 756 $result['uid'] = $entry[0]['uid'][0]; 757 $result['uidnumber'] = $entry[0]['uidnumber'][0]; 758 $result['gidnumber'] = $entry[0]['gidnumber'][0]; 759 $result['departmentnumber'] = $entry[0]['departmentnumber'][0]; 760 $result['givenname'] = $entry[0]['givenname'][0]; 761 $result['sn'] = $entry[0]['sn'][0]; 762 $result['telephonenumber'] = $entry[0]['telephonenumber'][0]; 763 $result['phpgwaccountstatus'] = $entry[0]['phpgwaccountstatus'][0]; 764 $result['phpgwaccountvisible'] = $entry[0]['phpgwaccountvisible'][0]; 765 $result['accountstatus'] = $entry[0]['accountstatus'][0]; 766 $result['mail'] = $entry[0]['mail'][0]; 767 $result['mailalternateaddress'] = $entry[0]['mailalternateaddress'][0]; 768 $result['mailforwardingaddress']= $entry[0]['mailforwardingaddress'][0]; 769 $result['deliverymode'] = $entry[0]['deliverymode'][0]; 770 $result['userPasswordRFC2617'] = $entry[0]['userpasswordrfc2617'][0]; 771 772 //Photo 773 if ($entry[0]['jpegphoto']['count'] == 1) 774 $result['photo_exist'] = 'true'; 775 776 // Samba 777 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 778 { 779 if ($entry[0]['objectclass'][$i] == 'sambaSamAccount') 780 $result['sambaUser'] = true; 781 } 782 if (($this->current_config['expressoAdmin_samba_support'] == 'true') && ($result['sambaUser'])) 783 { 784 $result['sambaaccflags'] = $entry[0]['sambaacctflags'][0]; 785 $result['sambalogonscript'] = $entry[0]['sambalogonscript'][0]; 786 $result['homedirectory'] = $entry[0]['homedirectory'][0]; 787 $a_tmp = explode("-", $entry[0]['sambasid'][0]); 788 array_pop($a_tmp); 789 $result['sambasid'] = implode("-", $a_tmp); 790 } 791 792 // Verifica o acesso do gerente aos atributos corporativos 793 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) 794 { 795 $result['corporative_information_employeenumber']= $entry[0]['employeenumber'][0]; 796 $result['corporative_information_cpf'] = $entry[0]['cpf'][0]; 797 $result['corporative_information_rg'] = $entry[0]['rg'][0]; 798 $result['corporative_information_rguf'] = $entry[0]['rguf'][0]; 799 } 800 801 // MailLists 802 $result['maillists_info'] = $this->get_user_maillists($result['mail']); 803 foreach ($result['maillists_info'] as $maillist) 804 { 805 $result['maillists'][] = $maillist['uidnumber']; 806 } 807 808 // Groups 809 $justthese = array("gidnumber","cn"); 810 $filter="(&(phpgwAccountType=g)(memberuid=".$result['uid']."))"; 811 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 812 ldap_sort($this->ldap, $search, "cn"); 813 $entries = ldap_get_entries($this->ldap, $search); 814 for ($i=0; $i<$entries['count']; $i++) 815 { 816 $result['groups_ldap'][ $entries[$i]['gidnumber'][0] ] = $entries[$i]['cn'][0]; 817 } 818 } 819 } 820 return $result; 821 } 822 823 function get_user_maillists($mail) 824 { 825 $result = array(); 826 827 //Mostra somente os mailists dos contextos do gerente 673 828 $justthese = array("uid","mail","uidnumber"); 674 $filter="(&(phpgwAccountType=l)(mailforwardingaddress=".$result['mail']."))"; 675 $search = ldap_search($this->ldap, $context, $filter, $justthese); 676 ldap_sort($this->ldap, $search, "uid"); 677 $entries = ldap_get_entries($this->ldap, $search); 678 for ($i=0; $i<$entries['count']; $i++) 829 $filter="(&(phpgwAccountType=l)(mailforwardingaddress=$mail))"; 830 831 foreach ($this->manager_contexts as $index=>$context) 832 { 833 $search = ldap_search($this->ldap, $context, $filter, $justthese); 834 //ldap_sort($this->ldap, $search, "uid"); 835 $entries = ldap_get_entries($this->ldap, $search); 836 837 for ($i=0; $i<$entries['count']; $i++) 838 { 839 $result[ $entries[$i]['uid'][0] ]['uidnumber'] = $entries[$i]['uidnumber'][0]; 840 $result[ $entries[$i]['uid'][0] ]['uid'] = $entries[$i]['uid'][0]; 841 $result[ $entries[$i]['uid'][0] ]['mail'] = $entries[$i]['mail'][0]; 842 843 $a_tmp[] = $entries[$i]['uid'][0]; 844 } 845 } 846 847 natcasesort($a_tmp); 848 849 foreach ($a_tmp as $uid) 679 850 { 680 $result['maillists_info'][$i]['uidnumber'] = $entries[$i]['uidnumber'][0]; 681 $result['maillists_info'][$i]['uid'] = $entries[$i]['uid'][0]; 682 $result['maillists_info'][$i]['mail'] = $entries[$i]['mail'][0]; 683 $result['maillists'][] = $entries[$i]['uidnumber'][0]; 851 $return[$uid]['uidnumber'] = $result[$uid]['uidnumber']; 852 $return[$uid]['uid'] = $result[$uid]['uid']; 853 $return[$uid]['mail'] = $result[$uid]['mail']; 684 854 } 685 686 // Groups 687 $justthese = array("gidnumber","cn"); 688 $filter="(&(phpgwAccountType=g)(memberuid=".$result['uid']."))"; 689 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 690 ldap_sort($this->ldap, $search, "cn"); 691 $entries = ldap_get_entries($this->ldap, $search); 692 for ($i=0; $i<$entries['count']; $i++) 693 { 694 $result['groups_ldap'][ $entries[$i]['gidnumber'][0] ] = $entries[$i]['cn'][0]; 695 } 696 697 return $result; 698 } 699 700 function get_group_info($gidnumber, $context) 701 { 702 $filter="(&(phpgwAccountType=g)(gidNumber=".$gidnumber."))"; 703 $search = ldap_search($this->ldap, $context, $filter); 704 $entry = ldap_get_entries($this->ldap, $search); 705 706 //Pega o dn do setor do grupo. 707 $entry[0]['dn'] = strtolower($entry[0]['dn']); 708 $sector_dn_array = explode(",", $entry[0]['dn']); 709 for($i=1; $i<count($sector_dn_array); $i++) 710 $sector_dn .= $sector_dn_array[$i] . ','; 711 //Retira ultimo pipe. 712 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 713 714 $result['context'] = $sector_dn; 715 $result['cn'] = $entry[0]['cn'][0]; 716 $result['description'] = $entry[0]['description'][0]; 717 $result['gidnumber'] = $entry[0]['gidnumber'][0]; 718 $result['phpgwaccountvisible'] = $entry[0]['phpgwaccountvisible'][0]; 719 $result['email'] = $entry[0]['mail'][0]; 720 721 //MemberUid 722 for ($i=0; $i<$entry[0]['memberuid']['count']; $i++) 723 { 724 $justthese = array("cn","uid","uidnumber"); 725 726 // Montagem dinamica do filtro 727 $filter="(&(phpgwAccountType=u)(|"; 728 for ($k=0; (($k<10) && ($i<$entry[0]['memberuid']['count'])); $k++) 729 { 730 $filter .= "(uid=".$entry[0]['memberuid'][$i].")"; 731 $i++; 732 } 733 $i--; 734 $filter .= "))"; 735 736 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 737 $user_entry = ldap_get_entries($this->ldap, $search); 738 739 for ($j=0; $j<$user_entry['count']; $j++) 740 { 741 $result['memberuid_info'][$user_entry[$j]['uid'][0]]['cn'] = $user_entry[$j]['cn'][0]; 742 $result['memberuid_info'][$user_entry[$j]['uid'][0]]['uidnumber'] = $user_entry[$j]['uidnumber'][0]; 743 $result['memberuid_info'][$user_entry[$j]['uid'][0]]['type'] = 'u'; 744 } 745 } 746 747 // Retira o count do array 748 array_shift($entry[0]['memberuid']); 749 750 // Checamos e-mails que não fazem parte do expresso. 751 // Criamos um array temporario 752 $tmp_array = array(); 753 foreach ($result['memberuid_info'] as $uid => $user_data) 754 { 755 $tmp_array[] = $uid; 756 } 757 758 // Vemos a diferença 759 $array_diff = array_diff($entry[0]['memberuid'], $tmp_array); 760 761 // Incluimos no resultado 762 foreach ($array_diff as $index=>$uid) 763 { 764 $result['memberuid_info'][$uid]['cn'] = $uid; 765 } 766 767 // Samba 768 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 769 { 770 if ($entry[0]['objectclass'][$i] == 'sambaGroupMapping') 771 $result['sambaGroup'] = true; 772 773 $a_tmp = explode("-", $entry[0]['sambasid'][0]); 774 array_pop($a_tmp); 775 $result['sambasid'] = implode("-", $a_tmp); 776 } 777 778 return $result; 855 return $return; 856 } 857 858 function get_group_info($gidnumber) 859 { 860 foreach ($this->manager_contexts as $index=>$context) 861 { 862 $filter="(&(phpgwAccountType=g)(gidNumber=".$gidnumber."))"; 863 $search = ldap_search($this->ldap, $context, $filter); 864 $entry = ldap_get_entries($this->ldap, $search); 865 866 if ($entry['count']) 867 { 868 //Pega o dn do setor do grupo. 869 $entry[0]['dn'] = strtolower($entry[0]['dn']); 870 $sector_dn_array = explode(",", $entry[0]['dn']); 871 for($i=1; $i<count($sector_dn_array); $i++) 872 $sector_dn .= $sector_dn_array[$i] . ','; 873 //Retira ultimo pipe. 874 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 875 876 $result['context'] = $sector_dn; 877 $result['cn'] = $entry[0]['cn'][0]; 878 $result['description'] = $entry[0]['description'][0]; 879 $result['gidnumber'] = $entry[0]['gidnumber'][0]; 880 $result['phpgwaccountvisible'] = $entry[0]['phpgwaccountvisible'][0]; 881 $result['email'] = $entry[0]['mail'][0]; 882 883 //MemberUid 884 for ($i=0; $i<$entry[0]['memberuid']['count']; $i++) 885 { 886 $justthese = array("cn","uid","uidnumber"); 887 888 // Montagem dinamica do filtro 889 $filter="(&(phpgwAccountType=u)(|"; 890 for ($k=0; (($k<10) && ($i<$entry[0]['memberuid']['count'])); $k++) 891 { 892 $filter .= "(uid=".$entry[0]['memberuid'][$i].")"; 893 $i++; 894 } 895 $i--; 896 $filter .= "))"; 897 898 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 899 $user_entry = ldap_get_entries($this->ldap, $search); 900 901 for ($j=0; $j<$user_entry['count']; $j++) 902 { 903 $result['memberuid_info'][$user_entry[$j]['uid'][0]]['cn'] = $user_entry[$j]['cn'][0]; 904 $result['memberuid_info'][$user_entry[$j]['uid'][0]]['uidnumber'] = $user_entry[$j]['uidnumber'][0]; 905 $result['memberuid_info'][$user_entry[$j]['uid'][0]]['type'] = 'u'; 906 } 907 } 908 909 // Retira o count do array 910 array_shift($entry[0]['memberuid']); 911 912 // Checamos e-mails que não fazem parte do expresso. 913 // Criamos um array temporario 914 $tmp_array = array(); 915 foreach ($result['memberuid_info'] as $uid => $user_data) 916 { 917 $tmp_array[] = $uid; 918 } 919 920 // Vemos a diferença 921 $array_diff = array_diff($entry[0]['memberuid'], $tmp_array); 922 923 // Incluimos no resultado 924 foreach ($array_diff as $index=>$uid) 925 { 926 $result['memberuid_info'][$uid]['cn'] = $uid; 927 } 928 929 // Samba 930 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 931 { 932 if ($entry[0]['objectclass'][$i] == 'sambaGroupMapping') 933 $result['sambaGroup'] = true; 934 935 $a_tmp = explode("-", $entry[0]['sambasid'][0]); 936 array_pop($a_tmp); 937 $result['sambasid'] = implode("-", $a_tmp); 938 } 939 return $result; 940 } 941 } 779 942 } 780 943 781 function get_maillist_info($uidnumber, $context) 782 { 783 $filter="(&(phpgwAccountType=l)(uidNumber=".$uidnumber."))"; 784 $search = ldap_search($this->ldap, $context, $filter); 785 $entry = ldap_get_entries($this->ldap, $search); 786 787 //Pega o dn do setor do usuario. 788 $entry[0]['dn'] = strtolower($entry[0]['dn']); 789 $sector_dn_array = explode(",", $entry[0]['dn']); 790 for($i=1; $i<count($sector_dn_array); $i++) 791 $sector_dn .= $sector_dn_array[$i] . ','; 792 //Retira ultimo pipe. 793 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 794 795 $result['context'] = $sector_dn; 796 $result['uidnumber'] = $entry[0]['uidnumber'][0]; 797 $result['uid'] = $entry[0]['uid'][0]; 798 $result['cn'] = $entry[0]['cn'][0]; 799 $result['mail'] = $entry[0]['mail'][0]; 800 $result['accountStatus'] = $entry[0]['accountstatus'][0]; 801 $result['phpgwAccountVisible'] = $entry[0]['phpgwaccountvisible'][0]; 802 803 //Members 804 for ($i=0; $i<$entry[0]['mailforwardingaddress']['count']; $i++) 805 { 806 $justthese = array("cn", "uidnumber", "uid", "phpgwaccounttype", "mail"); 944 function get_maillist_info($uidnumber) 945 { 946 foreach ($this->manager_contexts as $index=>$context) 947 { 948 $filter="(&(phpgwAccountType=l)(uidNumber=".$uidnumber."))"; 949 $search = ldap_search($this->ldap, $context, $filter); 950 $entry = ldap_get_entries($this->ldap, $search); 951 952 if ($entry['count']) 953 { 954 //Pega o dn do setor do usuario. 955 $entry[0]['dn'] = strtolower($entry[0]['dn']); 956 $sector_dn_array = explode(",", $entry[0]['dn']); 957 for($i=1; $i<count($sector_dn_array); $i++) 958 $sector_dn .= $sector_dn_array[$i] . ','; 959 //Retira ultimo pipe. 960 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 961 962 $result['context'] = $sector_dn; 963 $result['uidnumber'] = $entry[0]['uidnumber'][0]; 964 $result['uid'] = $entry[0]['uid'][0]; 965 $result['cn'] = $entry[0]['cn'][0]; 966 $result['mail'] = $entry[0]['mail'][0]; 967 $result['accountStatus'] = $entry[0]['accountstatus'][0]; 968 $result['phpgwAccountVisible'] = $entry[0]['phpgwaccountvisible'][0]; 969 970 //Members 971 for ($i=0; $i<$entry[0]['mailforwardingaddress']['count']; $i++) 972 { 973 $justthese = array("cn", "uidnumber", "uid", "phpgwaccounttype", "mail"); 807 974 808 // Montagem dinamica do filtro809 $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|";810 for ($k=0; (($k<10) && ($i<$entry[0]['mailforwardingaddress']['count'])); $k++)811 {812 $filter .= "(mail=".$entry[0]['mailforwardingaddress'][$i].")";813 $i++;814 }815 $i--;816 $filter .= "))";975 // Montagem dinamica do filtro 976 $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|"; 977 for ($k=0; (($k<10) && ($i<$entry[0]['mailforwardingaddress']['count'])); $k++) 978 { 979 $filter .= "(mail=".$entry[0]['mailforwardingaddress'][$i].")"; 980 $i++; 981 } 982 $i--; 983 $filter .= "))"; 817 984 818 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);819 $user_entry = ldap_get_entries($this->ldap, $search);985 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 986 $user_entry = ldap_get_entries($this->ldap, $search); 820 987 821 for ($j=0; $j<$user_entry['count']; $j++) 822 { 823 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['uid'] = $user_entry[$j]['uid'][0]; 824 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['cn'] = $user_entry[$j]['cn'][0]; 825 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['type'] = $user_entry[$j]['phpgwaccounttype'][0]; 826 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['mail'] = $user_entry[$j]['mail'][0]; 827 $result['members'][] = $user_entry[$j]['uidnumber'][0]; 828 } 829 } 830 831 // Retira o count do array 832 array_shift($entry[0]['mailforwardingaddress']); 833 834 // Checamos e-mails que não fazem parte do expresso. 835 // Criamos um array temporario 836 $tmp_array = array(); 837 foreach ($result['members_info'] as $uid => $user_data) 838 { 839 $tmp_array[] = $user_data['mail']; 840 } 841 842 // Vemos a diferença 843 $array_diff = array_diff($entry[0]['mailforwardingaddress'], $tmp_array); 844 845 // Incluimos no resultado 846 foreach ($array_diff as $index=>$mailforwardingaddress) 847 { 848 $result['members_info'][$mailforwardingaddress]['uid'] = $mailforwardingaddress; 849 $result['members_info'][$mailforwardingaddress]['cn'] = 'E-Mail nao encontrado'; 850 $result['members_info'][$mailforwardingaddress]['mailforwardingaddress'] = $mailforwardingaddress; 851 $result['members'][] = $mailforwardingaddress; 852 } 853 return $result; 988 for ($j=0; $j<$user_entry['count']; $j++) 989 { 990 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['uid'] = $user_entry[$j]['uid'][0]; 991 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['cn'] = $user_entry[$j]['cn'][0]; 992 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['type'] = $user_entry[$j]['phpgwaccounttype'][0]; 993 $result['members_info'][$user_entry[$j]['uidnumber'][0]]['mail'] = $user_entry[$j]['mail'][0]; 994 $result['members'][] = $user_entry[$j]['uidnumber'][0]; 995 } 996 } 997 998 // Retira o count do array 999 array_shift($entry[0]['mailforwardingaddress']); 1000 1001 // Checamos e-mails que não fazem parte do expresso. 1002 // Criamos um array temporario 1003 $tmp_array = array(); 1004 foreach ($result['members_info'] as $uid => $user_data) 1005 { 1006 $tmp_array[] = $user_data['mail']; 1007 } 1008 1009 // Vemos a diferença 1010 $array_diff = array_diff($entry[0]['mailforwardingaddress'], $tmp_array); 1011 1012 // Incluimos no resultado 1013 foreach ($array_diff as $index=>$mailforwardingaddress) 1014 { 1015 $result['members_info'][$mailforwardingaddress]['uid'] = $mailforwardingaddress; 1016 $result['members_info'][$mailforwardingaddress]['cn'] = 'E-Mail nao encontrado'; 1017 $result['members_info'][$mailforwardingaddress]['mailforwardingaddress'] = $mailforwardingaddress; 1018 $result['members'][] = $mailforwardingaddress; 1019 } 1020 return $result; 1021 } 1022 } 854 1023 } 855 1024 856 function get_maillist_scl_info($uidnumber, $context) 857 { 858 $filter="(&(phpgwAccountType=l)(uidNumber=".$uidnumber."))"; 859 $search = ldap_search($this->ldap, $context, $filter); 860 $entry = ldap_get_entries($this->ldap, $search); 861 862 //Pega o dn do setor do usuario. 863 $entry[0]['dn'] = strtolower($entry[0]['dn']); 864 $sector_dn_array = explode(",", $entry[0]['dn']); 865 for($i=1; $i<count($sector_dn_array); $i++) 866 $sector_dn .= $sector_dn_array[$i] . ','; 867 //Retira ultimo pipe. 868 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 869 870 $result['dn'] = $entry[0]['dn']; 871 $result['context'] = $sector_dn; 872 $result['uidnumber'] = $entry[0]['uidnumber'][0]; 873 $result['uid'] = $entry[0]['uid'][0]; 874 $result['cn'] = $entry[0]['cn'][0]; 875 $result['mail'] = $entry[0]['mail'][0]; 876 $result['accountStatus'] = $entry[0]['accountstatus'][0]; 877 $result['phpgwAccountVisible'] = $entry[0]['phpgwaccountvisible'][0]; 878 $result['accountRestrictive'] = $entry[0]['accountrestrictive'][0]; 879 $result['participantCanSendMail'] = $entry[0]['participantcansendmail'][0]; 880 881 //Senders 882 for ($i=0; $i<$entry[0]['mailsenderaddress']['count']; $i++) 883 { 884 $justthese = array("cn", "uidnumber", "uid", "mail"); 885 $filter="(&(phpgwAccountType=u)(mail=".$entry[0]['mailsenderaddress'][$i]."))"; 886 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 887 $user_entry = ldap_get_entries($this->ldap, $search); 888 889 $result['senders_info'][$user_entry[0]['uidnumber'][0]]['uid'] = $user_entry[0]['uid'][0]; 890 $result['senders_info'][$user_entry[0]['uidnumber'][0]]['cn'] = $user_entry[0]['cn'][0]; 891 $result['senders_info'][$user_entry[0]['uidnumber'][0]]['mail'] = $user_entry[0]['mail'][0]; 892 $result['members'][] = $user_entry[0]['uidnumber'][0]; 893 } 894 895 return $result; 1025 function get_maillist_scl_info($uidnumber) 1026 { 1027 foreach ($this->manager_contexts as $index=>$context) 1028 { 1029 $filter="(&(phpgwAccountType=l)(uidNumber=$uidnumber))"; 1030 $search = ldap_search($this->ldap, $context, $filter); 1031 $entry = ldap_get_entries($this->ldap, $search); 1032 1033 if ($entry['count']) 1034 { 1035 //Pega o dn do setor do usuario. 1036 $entry[0]['dn'] = strtolower($entry[0]['dn']); 1037 $sector_dn_array = explode(",", $entry[0]['dn']); 1038 for($i=1; $i<count($sector_dn_array); $i++) 1039 $sector_dn .= $sector_dn_array[$i] . ','; 1040 //Retira ultimo pipe. 1041 $sector_dn = substr($sector_dn,0,(strlen($sector_dn) - 1)); 1042 1043 $result['dn'] = $entry[0]['dn']; 1044 $result['context'] = $sector_dn; 1045 $result['uidnumber'] = $entry[0]['uidnumber'][0]; 1046 $result['uid'] = $entry[0]['uid'][0]; 1047 $result['cn'] = $entry[0]['cn'][0]; 1048 $result['mail'] = $entry[0]['mail'][0]; 1049 $result['accountStatus'] = $entry[0]['accountstatus'][0]; 1050 $result['phpgwAccountVisible'] = $entry[0]['phpgwaccountvisible'][0]; 1051 $result['accountRestrictive'] = $entry[0]['accountrestrictive'][0]; 1052 $result['participantCanSendMail'] = $entry[0]['participantcansendmail'][0]; 1053 1054 //Senders 1055 for ($i=0; $i<$entry[0]['mailsenderaddress']['count']; $i++) 1056 { 1057 $justthese = array("cn", "uidnumber", "uid", "mail"); 1058 $filter="(&(phpgwAccountType=u)(mail=".$entry[0]['mailsenderaddress'][$i]."))"; 1059 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 1060 $user_entry = ldap_get_entries($this->ldap, $search); 1061 1062 $result['senders_info'][$user_entry[0]['uidnumber'][0]]['uid'] = $user_entry[0]['uid'][0]; 1063 $result['senders_info'][$user_entry[0]['uidnumber'][0]]['cn'] = $user_entry[0]['cn'][0]; 1064 $result['senders_info'][$user_entry[0]['uidnumber'][0]]['mail'] = $user_entry[0]['mail'][0]; 1065 $result['members'][] = $user_entry[0]['uidnumber'][0]; 1066 } 1067 return $result; 1068 } 1069 } 896 1070 } 897 1071 … … 909 1083 } 910 1084 911 function gidnumbers2cn($gidnumbers , $context)1085 function gidnumbers2cn($gidnumbers) 912 1086 { 913 1087 $result = array(); … … 927 1101 $result['groups_info'][$i]['cn'] = $entry[0]['cn'][0]; 928 1102 $result['groups_info'][$i]['gidnumber'] = $gidnumber; 929 930 if (!strpos(strtolower($entry[0]['dn']), strtolower($context))) 931 $result['groups_info'][$i]['group_disabled'] = 'true'; 932 else 933 $result['groups_info'][$i]['group_disabled'] = 'false'; 934 1103 1104 /* o gerente pode excluir um grupo de um usuario onde este grupo esta em outra OU ? */ 1105 /* é o mesmo que o manager editar um grupo de outra OU */ 1106 $result['groups_info'][$i]['group_disabled'] = 'true'; 1107 foreach ($this->manager_contexts as $index=>$context) 1108 { 1109 if (strpos(strtolower($entry[0]['dn']), strtolower($context))) 1110 { 1111 $result['groups_info'][$i]['group_disabled'] = 'false'; 1112 } 1113 } 1114 935 1115 $i++; 936 1116 } … … 1025 1205 function delete_user($user_info) 1026 1206 { 1207 // Verifica acesso do gerente (OU) ao tentar deletar um usuário. 1208 $manager_access = false; 1209 foreach ($this->manager_contexts as $index=>$context) 1210 { 1211 if ( (strpos(strtolower($user_info['context']), strtolower($context))) || (strtolower($user_info['context']) == strtolower($context)) ) 1212 { 1213 $manager_access = true; 1214 break; 1215 } 1216 } 1217 if (!$manager_access) 1218 { 1219 $return['status'] = false; 1220 $return['msg'] .= 'Você não tem acesso para deletar este usuário.'; 1221 return $return; 1222 } 1223 1027 1224 $return['status'] = true; 1028 1225 … … 1120 1317 } 1121 1318 1319 function check_access_to_renamed($uid) 1320 { 1321 $justthese = array("dn"); 1322 $filter="(&(phpgwAccountType=u)(uid=$uid))"; 1323 1324 foreach ($this->manager_contexts as $index=>$context) 1325 { 1326 $search = ldap_search($this->ldap, $context, $filter, $justthese); 1327 $entry = ldap_get_entries($this->ldap, $search); 1328 if ($entry['count']) 1329 return true; 1330 } 1331 return false; 1332 } 1122 1333 1123 1334 function rename_uid($uid, $new_uid) … … 1191 1402 return $return; 1192 1403 } 1193 /* 1194 function rename_departmentnumber($old_dp, $new_dp) 1195 { 1196 $return['status'] = true; 1197 1198 $justthese = array("dn"); 1199 $filter="(&(phpgwAccountType=u)(departmentnumber=".$old_dp."))"; 1200 $search = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 1201 $entry = ldap_get_entries($this->ldap, $search); 1202 1203 for ($i=0; $i<=$entry['count']; $i++) 1204 { 1205 $dn = strtolower($entry[$i]['dn']); 1206 $ldap_mod_replace = array(); 1207 $ldap_mod_replace['departmentnumber'] = $new_dp; 1208 @ldap_mod_replace ( $this->ldap, $dn, $ldap_mod_replace); 1209 //if (!@ldap_mod_replace ( $this->ldap, $dn, $ldap_mod_replace)) 1210 //{ 1211 // $return['status'] = false; 1212 // $return['msg'] .= 'Erro em ldap_funcitons->rename_departmentnumber: ' . ldap_error($this->ldap); 1213 //} 1214 } 1215 return $return; 1216 } 1217 */ 1218 /* 1219 function get_sambadomains($context) 1220 { 1221 $return['status'] = true; 1222 $return['sambaDomains'] = array(); 1223 1224 $justthese = array("sambaSID","sambaDomainName"); 1225 $filter="(objectClass=sambaDomain)"; 1226 $search = ldap_search($this->ldap, $context, $filter, $justthese); 1227 $entry = ldap_get_entries($this->ldap, $search); 1228 1229 for ($i=0; $i<$entry['count']; $i++) 1230 { 1231 $return['sambaDomains'][$i]['samba_domain_sid'] = $entry[$i]['sambasid'][0]; 1232 $return['sambaDomains'][$i]['samba_domain_name'] = $entry[$i]['sambadomainname'][0]; 1233 $return['sambaDomains'][$i]['samba_domain_dn'] = $entry[$i]['dn']; 1234 } 1235 1236 return $return; 1237 } 1238 */ 1239 function exist_sambadomains($context, $sambaDomainName) 1404 1405 function exist_sambadomains($contexts, $sambaDomainName) 1240 1406 { 1241 1407 $justthese = array("dn"); 1242 1408 $filter="(&(objectClass=sambaDomain)(sambaDomainName=$sambaDomainName))"; 1243 $search = ldap_search($this->ldap, $context, $filter, $justthese); 1244 $entry = ldap_get_entries($this->ldap, $search); 1409 1410 foreach ($contexts as $index=>$context) 1411 { 1412 $search = ldap_search($this->ldap, $context, $filter, $justthese); 1413 $entry = ldap_get_entries($this->ldap, $search); 1245 1414 1246 if ($entry['count'])1247 return true;1248 else1249 1415 if ($entry['count']) 1416 return true; 1417 } 1418 return false; 1250 1419 } 1251 1420 -
trunk/expressoAdmin1_2/inc/class.maillist.inc.php
r23 r64 55 55 $params['members'] = $array_tmp; 56 56 57 // Leio o ID a ser usado na criação do objecto. 58 $next_id = ($this->db_functions->get_next_id('accounts')); 59 if ((!is_numeric($next_id['id'])) || (!$next_id['status'])) 60 { 61 $return['status'] = false; 62 $return['msg'] = "Problemas obtendo ID do usuário.\n" . $id['msg']; 63 return $return; 64 } 65 else 66 { 67 $id = $next_id['id']; 68 } 57 69 // Pega ID do BD e incrementa de 1. 58 $id = (($this->db_functions->get_next_id()) + 1); 59 70 //$id = (($this->db_functions->get_next_id()) + 1); 60 71 // Incrementa o id no BD. 61 $this->db_functions->increment_id($id,'accounts');72 //$this->db_functions->increment_id($id,'accounts'); 62 73 63 74 // Cria array para incluir no LDAP … … 382 393 } 383 394 384 function get_info($uidnumber , $context)385 { 386 $maillist_info_ldap = $this->ldap_functions->get_maillist_info($uidnumber , $context);395 function get_info($uidnumber) 396 { 397 $maillist_info_ldap = $this->ldap_functions->get_maillist_info($uidnumber); 387 398 return $maillist_info_ldap; 388 399 } 389 400 390 function get_scl_info($uidnumber , $context)391 { 392 $maillist_info_ldap = $this->ldap_functions->get_maillist_scl_info($uidnumber , $context);401 function get_scl_info($uidnumber) 402 { 403 $maillist_info_ldap = $this->ldap_functions->get_maillist_scl_info($uidnumber); 393 404 return $maillist_info_ldap; 394 405 } -
trunk/expressoAdmin1_2/inc/class.socomputers.inc.php
r27 r64 47 47 } 48 48 49 function get_computer_data($uidnumber , $manager_context)49 function get_computer_data($uidnumber) 50 50 { 51 $manager_acl = $this->functions->read_acl($_SESSION['phpgw_info']['expresso']['user']['account_lid']); 52 $manager_contexts = $manager_acl['contexts']; 51 53 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 52 $search = ldap_search($connection, $manager_context, "uidNumber=" . $uidnumber);53 $result = ldap_get_entries($connection, $search);54 54 55 // Recupera o DN 56 $computer_data['dn'] = $result[0]['dn']; 55 foreach ($manager_contexts as $index=>$context) 56 { 57 $search = ldap_search($connection, $context, "uidNumber=$uidnumber"); 58 $result = ldap_get_entries($connection, $search); 57 59 58 //Recupera o Nome do Computador (CN) 59 $computer_data['computer_cn'] = $result[0]['cn'][0]; 60 if ($result['count']) 61 { 62 // Recupera o DN 63 $computer_data['dn'] = $result[0]['dn']; 64 65 //Recupera o Nome do Computador (CN) 66 $computer_data['computer_cn'] = $result[0]['cn'][0]; 60 67 61 //Recupera a flag SAMBA62 $computer_data['sambaAcctFlags'] = $result[0]['sambaacctflags'][0];68 //Recupera a flag SAMBA 69 $computer_data['sambaAcctFlags'] = $result[0]['sambaacctflags'][0]; 63 70 64 // Recupera a descrição65 $computer_data['computer_description'] = utf8_decode($result[0]['description'][0]);71 // Recupera a descrição 72 $computer_data['computer_description'] = utf8_decode($result[0]['description'][0]); 66 73 67 // Recupera o contexto do email_list68 $tmp = explode(",", $computer_data['dn']);69 for ($i = 1; $i < count($tmp); $i++)70 $computer_data['context'] .= $tmp[$i] . ',';71 $computer_data['context'] = substr($computer_data['context'],0,(strlen($computer_data['context']) - 1));74 // Recupera o contexto do email_list 75 $tmp = explode(",", $computer_data['dn']); 76 for ($i = 1; $i < count($tmp); $i++) 77 $computer_data['context'] .= $tmp[$i] . ','; 78 $computer_data['context'] = substr($computer_data['context'],0,(strlen($computer_data['context']) - 1)); 72 79 73 $a_tmp = explode("-", $result[0]['sambasid'][0]);74 array_pop($a_tmp);75 $computer_data['sambasid'] = implode("-", $a_tmp);80 $a_tmp = explode("-", $result[0]['sambasid'][0]); 81 array_pop($a_tmp); 82 $computer_data['sambasid'] = implode("-", $a_tmp); 76 83 77 return $computer_data; 84 return $computer_data; 85 } 86 } 78 87 } 79 88 -
trunk/expressoAdmin1_2/inc/class.uiaccounts.inc.php
r63 r64 55 55 { 56 56 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 57 $tmp = $this->functions->read_acl($account_lid); 58 $context = $tmp[0]['context']; 59 $context_display = $tmp[0]['context_display']; 57 $acl = $this->functions->read_acl($account_lid); 58 $raw_context = $acl['raw_context']; 59 $contexts = $acl['contexts']; 60 foreach ($acl['contexts_display'] as $index=>$tmp_context) 61 { 62 $context_display .= '<br>'.$tmp_context; 63 } 60 64 61 65 // Verifica se o administrador tem acesso. … … 94 98 95 99 'create_user_disabled' => $this->functions->check_acl($account_lid,'add_users') ? '' : 'disabled', 96 'context' => $ context,100 'context' => $raw_context, 97 101 'context_display' => $context_display, 98 102 'imapDelimiter' => $_SESSION['phpgw_info']['expresso']['email_server']['imapDelimiter'], … … 107 111 'lang_search' => lang('Search'), 108 112 'lang_back' => lang('back'), 109 'lang_context ' => lang('Context')113 'lang_contexts' => lang('Contexts') 110 114 111 115 ); … … 118 122 if ($GLOBALS['query'] != '') 119 123 { 120 $account_info = $this->functions->get_list('accounts', $GLOBALS['query'], $context );124 $account_info = $this->functions->get_list('accounts', $GLOBALS['query'], $contexts); 121 125 } 122 126 … … 131 135 ($this->functions->check_acl($account_lid,'change_users_password')) || 132 136 ($this->functions->check_acl($account_lid,'edit_sambausers_attributes')) || 133 ($this->functions->check_acl($account_lid,'change_users_quote'))) 137 ($this->functions->check_acl($account_lid,'change_users_quote')) || 138 ($this->functions->check_acl($account_lid,'manipulate_corporative_information')) 139 ) 134 140 $can_edit = True; 135 141 elseif ($this->functions->check_acl($account_lid,'view_users')) … … 159 165 160 166 if ($can_rename) 161 $p->set_var('row_rename',"<a href='#' onClick='javascript:rename_user(\"".$account['account_lid']."\",\"".$account['account_id']."\" ,\"".$context."\");'>Renomear</a>");167 $p->set_var('row_rename',"<a href='#' onClick='javascript:rename_user(\"".$account['account_lid']."\",\"".$account['account_id']."\");'>Renomear</a>"); 162 168 else 163 169 $p->set_var('row_rename',' '); … … 165 171 if ($can_delete) 166 172 { 167 $p->set_var('row_delete',"<a href='#' onClick='javascript:delete_user(\"".$account['account_lid']."\",\"".$account['account_id']."\" ,\"".$context."\");'>Excluir</a>");173 $p->set_var('row_delete',"<a href='#' onClick='javascript:delete_user(\"".$account['account_lid']."\",\"".$account['account_id']."\");'>Excluir</a>"); 168 174 } 169 175 else … … 179 185 { 180 186 $GLOBALS['phpgw']->js->validate_file('jscode','users','expressoAdmin1_2'); 187 181 188 $GLOBALS['phpgw']->js->set_onload('get_available_groups(document.forms[0].context.value);'); 182 189 $GLOBALS['phpgw']->js->set_onload('get_available_maillists(document.forms[0].context.value);'); 183 190 if ($this->current_config['expressoAdmin_samba_support'] == 'true') 184 191 $GLOBALS['phpgw']->js->set_onload('get_available_sambadomains(document.forms[0].context.value, \'create_user\');'); 185 192 186 193 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 187 $tmp = $this->functions->read_acl($manager_lid); 188 $manager_context = $tmp[0]['context']; 194 $acl = $this->functions->read_acl($manager_lid); 195 196 $manager_contexts = $acl['contexts']; 197 189 198 // Verifica se tem acesso a este modulo 190 199 if (!$this->functions->check_acl($manager_lid,'add_users')) … … 206 215 207 216 // Pega combo das organizações e seleciona, caso seja um post, o setor que o usuario selecionou. 208 $sectors = $this->functions->get_organizations($manager_context); 217 foreach ($manager_contexts as $index=>$context) 218 $sectors .= $this->functions->get_organizations($context); 209 219 210 220 // Chama funcao para criar lista de aplicativos disponiveis. 211 //$app_list['applications_list'] = $_POST['applications_list']; 212 $applications_list = $this->functions->make_list_app($manager_lid, $manager_context, $app_list); 221 $applications_list = $this->functions->make_list_app($manager_lid); 213 222 214 223 // Cria combo de dominio samba … … 222 231 { 223 232 // So mostra os sambaDomainName do contexto do manager 224 if ($this->ldap_functions->exist_sambadomains($manager_context , $a_sambadomain['samba_domain_name']))233 if ($this->ldap_functions->exist_sambadomains($manager_contexts, $a_sambadomain['samba_domain_name'])) 225 234 $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; 226 235 } … … 233 242 'row_off' => "#EEEEEE", 234 243 'color_bg1' => "#E8F0F0", 235 'manager_context' => $manager_context,244 //'manager_context' => $manager_context, 236 245 'type' => 'create_user', 237 246 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.list_users'), 238 'display_samba_suport' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : ' display:none',247 'display_samba_suport' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'none', 239 248 'disabled_access_button'=> 'disabled', 240 249 … … 313 322 314 323 //SAMBA ABA 315 'display_samba_suport' => $this->functions->check_acl($manager_lid,'edit_sambausers_attributes') ? '' : 'none',316 324 'lang_samba_config' => lang('Samba Config'), 317 325 'lang_use_attrs_samba' => lang('Use samba attributes'), … … 340 348 { 341 349 $manager_account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 342 $tmp = $this->functions->read_acl($manager_account_lid); 343 $manager_context = $tmp[0]['context']; 350 $acl = $this->functions->read_acl($manager_account_lid); 351 $raw_context = $acl['raw_context']; 352 $contexts = $acl['contexts']; 344 353 $alert_warning = ''; 345 354 … … 351 360 (!$this->functions->check_acl($manager_account_lid,'change_users_password')) && 352 361 (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) && 353 (!$this->functions->check_acl($manager_account_lid,'view_users')) 362 (!$this->functions->check_acl($manager_account_lid,'view_users')) && 363 (!$this->functions->check_acl($manager_account_lid,'manipulate_corporative_information')) 354 364 ) 355 365 { … … 387 397 388 398 // GET all infomations about the user. 389 $user_info = $this->user->get_user_info($_GET['account_id'] , $manager_context);399 $user_info = $this->user->get_user_info($_GET['account_id']); 390 400 391 401 // JavaScript … … 408 418 409 419 // ORGANIZATIONS 410 $orgs = $this->functions->get_organizations($manager_context, $user_info['context']); 420 foreach ($contexts as $index=>$context) 421 $orgs .= $this->functions->get_organizations($context, $user_info['context']); 411 422 412 423 // GROUPS. … … 473 484 if (count($user_info['maillists_info']) > 0) 474 485 { 475 476 486 foreach ($user_info['maillists_info'] as $maillist) 477 487 { … … 487 497 // APPS. 488 498 if ($disabled == 'disabled') 489 $apps = $this->functions->make_list_app($manager_account_lid, $ manager_context, $user_info['apps'], 'disabled');499 $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps'], 'disabled'); 490 500 else 491 $apps = $this->functions->make_list_app($manager_account_lid, $ manager_context, $user_info['apps']);501 $apps = $this->functions->make_list_app($manager_account_lid, $user_info['apps']); 492 502 493 503 //PHOTO 494 504 if ($user_info['photo_exist']) 495 505 { 496 $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id'] ."&manager_context=$manager_context";506 $photo_bin = "./index.php?menuaction=expressoAdmin1_2.uiaccounts.show_photo&uidNumber=".$_GET['account_id']; 497 507 } 498 508 else … … 521 531 if ($alert_warning != '') 522 532 $alert_warning = "alert('". $alert_warning ."')"; 523 524 533 $var = Array( 525 534 'uidnumber' => $_GET['account_id'], 526 'manager_context' => $manager_context,527 535 'type' => 'edit_user', 528 536 'photo_exist' => $user_info['photo_exist'], … … 535 543 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uiaccounts.validate_user_data_edit'), 536 544 'back_url' => './index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users', 537 'display_samba_suport' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none',538 545 'disabled' => $disabled, 539 546 'disabled_password' => $disabled_password, 540 547 'disabled_samba' => $disabled_samba, 541 548 'changequote_disabled' => $disabled_quote, 549 550 // Display ABAS 551 'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'manipulate_corporative_information') ? '' : 'none', 552 'display_applications' => $this->functions->check_acl($manager_account_lid,'display_applications') ? '' : 'none', 553 'display_emaillists' => $this->functions->check_acl($manager_account_lid,'display_emaillists') ? '' : 'none', 554 'display_groups' => $this->functions->check_acl($manager_account_lid,'display_groups') ? '' : 'none', 555 'display_emailconfig' => $this->functions->check_acl($manager_account_lid,'display_emailconfig') ? '' : 'none', 542 556 543 557 // First ABA … … 583 597 584 598 // Corporative Information 585 'display_corporative_information'=> $this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes') ? '' : 'none',586 599 'lang_employeenumber' => lang('Employee number'), 587 600 'lang_cpf' => lang('cpf'), … … 594 607 595 608 //MAIL 596 'disabled_quota_used' 597 'lang_activeemailaccount' 598 'lang_email' 599 'lang_aliasemail' 600 'lang_forwardingemail' 601 'lang_email_quota' 602 'lang_onlyforwarding' 603 'lang_email_quota_used' 609 'disabled_quota_used' => 'disabled', 610 'lang_activeemailaccount' => lang('Active email account'), 611 'lang_email' => lang('E-mail'), 612 'lang_aliasemail' => lang('Alias email'), 613 'lang_forwardingemail' => lang('Forwarding email'), 614 'lang_email_quota' => lang('Email quota in MB'), 615 'lang_onlyforwarding' => lang('Only forwarding'), 616 'lang_email_quota_used' => lang('Quota used in MB'), 604 617 605 618 'accountstatus_checked' => $user_info['accountstatus'] == 'active' ? 'CHECKED' : '', … … 651 664 ); 652 665 $t->set_var($var); 666 667 // Devo mostrar aba SAMBA ?? 668 if ( ($this->current_config['expressoAdmin_samba_support'] == 'true') && ($this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) ) 669 $t->set_var('display_samba_suport', ''); 670 else 671 $t->set_var('display_samba_suport', 'none'); 672 653 673 $t->pfp('out','body'); 654 674 } … … 705 725 { 706 726 $uidNumber = $_GET['uidNumber']; 707 $manager_context = $_GET['manager_context']; 708 $photo = $this->get_photo($uidNumber, $manager_context); 727 $photo = $this->get_photo($uidNumber); 709 728 710 729 if ($photo) … … 722 741 } 723 742 724 function get_photo($uidNumber , $manager_context)743 function get_photo($uidNumber) 725 744 { 726 745 $ldap_conn = $GLOBALS['phpgw']->common->ldapConnect(); … … 728 747 $justthese = array("jpegphoto"); 729 748 730 $search = ldap_search($ldap_conn, $ manager_context, $filter, $justthese);749 $search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); 731 750 $entry = ldap_first_entry($ldap_conn, $search); 732 751 $jpeg_data = ldap_get_values_len($ldap_conn, $entry, "jpegphoto"); -
trunk/expressoAdmin1_2/inc/class.uicomputers.inc.php
r27 r64 35 35 $this->so = $this->bo->so; 36 36 $this->functions = $this->bo->functions; 37 $this->db_functions = CreateObject('expressoAdmin1_2.db_functions');37 $this->db_functions = $this->bo->db_functions; 38 38 39 39 $c = CreateObject('phpgwapi.config','expressoAdmin1_2'); … … 44 44 function list_computers() 45 45 { 46 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 47 $acl = $this->functions->read_acl($account_lid); 48 $context = $acl[0]['context']; 49 $context_display = $acl[0]['context_display']; 46 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 47 $manager_acl = $this->functions->read_acl($manager_lid); 48 $manager_contexts = $manager_acl['contexts']; 49 foreach ($manager_acl['contexts_display'] as $index=>$tmp_context) 50 { 51 $context_display .= '<br>'.$tmp_context; 52 } 50 53 51 54 // Verifica se tem acesso a este modulo 52 if (!$this->functions->check_acl($ account_lid,'list_computers'))55 if (!$this->functions->check_acl($manager_lid,'list_computers')) 53 56 { 54 57 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 80 83 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 81 84 'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uicomputers.add_computer'), 82 'add_computers_disabled' => $this->functions->check_acl($ account_lid,'create_computers') ? '' : 'display:none',85 'add_computers_disabled' => $this->functions->check_acl($manager_lid,'create_computers') ? '' : 'display:none', 83 86 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), 84 87 'lang_back' => lang('Back'), 85 //'context' => $context,86 88 'context_display' => $context_display, 87 89 'lang_computers_uid' => lang('Computer UID'), … … 101 103 if ($GLOBALS['query'] != '') 102 104 { 103 $computers_info = $this->functions->get_list('computers', $GLOBALS['query'], $ context);105 $computers_info = $this->functions->get_list('computers', $GLOBALS['query'], $manager_contexts); 104 106 } 105 107 … … 111 113 else if (count($computers_info)) 112 114 { 113 if ($this->functions->check_acl($ account_lid,'edit_computers'))115 if ($this->functions->check_acl($manager_lid,'edit_computers')) 114 116 { 115 117 $can_edit = True; 116 118 } 117 if ($this->functions->check_acl($ account_lid,'delete_computers'))119 if ($this->functions->check_acl($manager_lid,'delete_computers')) 118 120 { 119 121 $can_delete = True; … … 157 159 function add_computer() 158 160 { 159 //_debug_array($_POST); 160 161 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 162 $acl = $this->functions->read_acl($account_lid); 163 $context = $acl[0]['context']; 161 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 162 $manager_acl = $this->functions->read_acl($manager_lid); 163 $manager_contexts = $manager_acl['contexts']; 164 164 165 165 // Verifica se tem acesso a este modulo 166 if (!$this->functions->check_acl($ account_lid,'create_computers'))166 if (!$this->functions->check_acl($manager_lid,'create_computers')) 167 167 { 168 168 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 191 191 } 192 192 193 // Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados.194 $sectors = $this->functions->get_organizations($context, trim(strtolower($_POST['sector_context'])));193 foreach ($manager_contexts as $index=>$context) 194 $sectors .= $this->functions->get_organizations($context); 195 195 196 196 // Cria combo de dominio samba … … 271 271 function validade_computers_data_add() 272 272 { 273 //_debug_array($_POST);274 275 273 if (($_POST['sambaAcctFlags'] == '[I ]') && ($_POST['computer_password'] == '')) 276 274 { … … 304 302 function edit_computer() 305 303 { 306 $ account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];307 $ acl = $this->functions->read_acl($account_lid);308 $manager_context = $acl[0]['context'];304 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 305 $manager_acl = $this->functions->read_acl($manager_lid); 306 $manager_contexts = $manager_acl['contexts']; 309 307 310 308 // Verifica se tem acesso a este modulo 311 if (!$this->functions->check_acl($ account_lid,'edit_computers'))309 if (!$this->functions->check_acl($manager_lid,'edit_computers')) 312 310 { 313 311 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); 314 312 } 315 313 314 // Set o header 316 315 unset($GLOBALS['phpgw_info']['flags']['noheader']); 317 316 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); … … 327 326 { 328 327 $uidnumber = $_GET['uidnumber']; 329 $computer_data = $this->so->get_computer_data($uidnumber, $manager_context); 330 331 // Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados. 332 $sectors = $this->functions->get_organizations($manager_context, trim(strtolower($computer_data['context']))); 328 $computer_data = $this->so->get_computer_data($uidnumber); 329 330 // Gera combo sectors 331 foreach ($manager_contexts as $index=>$context) 332 $sectors .= $this->functions->get_organizations($context, trim(strtolower($computer_data['context']))); 333 333 334 334 // Cria combo de dominios do samba … … 411 411 { 412 412 // Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados. 413 $sectors = $this->functions->get_organizations($manager_context, trim(strtolower($_POST['sector_context']))); 413 foreach ($manager_contexts as $index=>$context) 414 $sectors .= $this->functions->get_organizations($context, trim(strtolower($_POST['sector_context']))); 415 //$sectors = $this->functions->get_organizations($manager_contexts); 414 416 415 417 // Cria combo de dominios do samba -
trunk/expressoAdmin1_2/inc/class.uigroups.inc.php
r46 r64 14 14 var $public_functions = array 15 15 ( 16 'list_groups' 17 'add_groups' 18 'edit_groups' 19 'css' 16 'list_groups' => True, 17 'add_groups' => True, 18 'edit_groups' => True, 19 'css' => True 20 20 ); 21 21 … … 50 50 { 51 51 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 52 $acl = $this->functions->read_acl($account_lid); 53 $context = $acl[0]['context']; 54 $context_display = $acl[0]['context_display']; 52 $manager_acl = $this->functions->read_acl($account_lid); 53 $raw_context = $acl['raw_context']; 54 $contexts = $manager_acl['contexts']; 55 foreach ($manager_acl['contexts_display'] as $index=>$tmp_context) 56 { 57 $context_display .= '<br>'.$tmp_context; 58 } 55 59 56 60 // Verifica se tem acesso a este modulo … … 85 89 'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.add_groups'), 86 90 'add_group_disabled' => $this->functions->check_acl($account_lid,'add_groups') ? '' : 'disabled', 87 'context' => $context,91 //'context' => $context, 88 92 'context_display' => $context_display, 89 93 'lang_groups_names' => lang('Groups Names'), … … 104 108 if ($GLOBALS['query'] != '') 105 109 { 106 $groups_info = $this->functions->get_list('groups', $GLOBALS['query'], $context );110 $groups_info = $this->functions->get_list('groups', $GLOBALS['query'], $contexts); 107 111 } 108 112 $total = count($groups_info); … … 144 148 if ($can_delete) 145 149 { 146 $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_group(\"".$group['cn']."\",\"".$group['gidnumber']."\" ,\"".$context."\");'>Excluir</a>");150 $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_group(\"".$group['cn']."\",\"".$group['gidnumber']."\");'>Excluir</a>"); 147 151 } 148 152 else … … 174 178 $GLOBALS['phpgw']->js->set_onload('get_available_sambadomains(document.forms[0].context.value, \'create_group\');'); 175 179 176 $ account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];177 $ acl = $this->functions->read_acl($account_lid);178 $manager_context = $acl[0]['context'];180 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 181 $manager_acl = $this->functions->read_acl($manager_lid); 182 $manager_contexts = $manager_acl['contexts']; 179 183 180 184 // Verifica se tem acesso a este modulo 181 if (!$this->functions->check_acl($ account_lid,'add_groups'))185 if (!$this->functions->check_acl($manager_lid,'add_groups')) 182 186 { 183 187 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 194 198 195 199 // Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados. 196 $combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context']))); 200 //$combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context']))); 201 foreach ($manager_contexts as $index=>$context) 202 $combo_manager_org .= $this->functions->get_organizations($context, trim(strtolower($group_info['context']))); 197 203 $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context']))); 198 204 199 205 // Chama funcao para criar lista de aplicativos disponiveis. 200 $apps = $this->functions->make_list_app($ account_lid, $manager_context, '');206 $apps = $this->functions->make_list_app($manager_lid); 201 207 202 208 // Cria combo de dominio samba … … 210 216 { 211 217 // So mostra os sambaDomainName do contexto do manager 212 if ($this->ldap_functions->exist_sambadomains($manager_context , $a_sambadomain['samba_domain_name']))218 if ($this->ldap_functions->exist_sambadomains($manager_contexts, $a_sambadomain['samba_domain_name'])) 213 219 $sambadomainname_options .= "<option value='" . $a_sambadomain['samba_domain_sid'] . "'>" . $a_sambadomain['samba_domain_name'] . "</option>"; 214 220 } … … 244 250 'disabled_samba' => 'disabled', 245 251 'display_samba_options' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : '"display:none"', 246 'disable_email_groups' => $this->functions->check_acl($ account_lid,'edit_email_groups') ? '' : 'disabled',252 'disable_email_groups' => $this->functions->check_acl($manager_lid,'edit_email_groups') ? '' : 'disabled', 247 253 'sambadomainname_options' => $sambadomainname_options, 248 254 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.list_groups'), … … 258 264 { 259 265 $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); 260 261 $ account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];262 $ acl = $this->functions->read_acl($account_lid);263 $manager_context = $acl[0]['context'];264 266 267 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 268 $manager_acl = $this->functions->read_acl($manager_lid); 269 $manager_contexts = $manager_acl['contexts']; 270 265 271 // Verifica se tem acesso a este modulo 266 if (!$this->functions->check_acl($ account_lid,'edit_groups'))272 if (!$this->functions->check_acl($manager_lid,'edit_groups')) 267 273 { 268 274 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 270 276 271 277 // GET all infomations about the group. 272 $group_info = $this->group->get_info($_GET['gidnumber'] , $manager_context);278 $group_info = $this->group->get_info($_GET['gidnumber']); 273 279 274 280 unset($GLOBALS['phpgw_info']['flags']['noheader']); … … 282 288 283 289 // Pega combo das organizações e seleciona a org do grupo. 284 $combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context']))); 290 //$combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context']))); 291 foreach ($manager_contexts as $index=>$context) 292 $combo_manager_org .= $this->functions->get_organizations($context, trim(strtolower($group_info['context']))); 285 293 $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context']))); 286 294 … … 315 323 316 324 // Chama funcao para criar lista de aplicativos disponiveis. 317 $apps = $this->functions->make_list_app($ account_lid, $manager_context, $group_info['apps']);325 $apps = $this->functions->make_list_app($manager_lid, $group_info['apps']); 318 326 319 327 // Cria combo de dominios do samba … … 352 360 'lang_all_users' => lang('Select users from all sub-organizations'), 353 361 'gidnumber' => $group_info['gidnumber'], 354 'manager_context' => $manager_context,362 //'manager_context' => $manager_context, 355 363 'cn' => $group_info['cn'], 356 364 'user_count' => $user_count, … … 360 368 'use_attrs_samba_checked' => $group_info['sambaGroup'] ? 'CHECKED' : '', 361 369 'disabled_samba' => $group_info['sambaGroup'] ? '' : 'disabled', 362 'disable_email_groups' => $this->functions->check_acl($ account_lid,'edit_email_groups') ? '' : 'disabled',370 'disable_email_groups' => $this->functions->check_acl($manager_lid,'edit_email_groups') ? '' : 'disabled', 363 371 'sambadomainname_options' => $sambadomainname_options, 364 372 'phpgwaccountvisible_checked' => $group_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '', -
trunk/expressoAdmin1_2/inc/class.uimaillists.inc.php
r24 r64 45 45 function list_maillists() 46 46 { 47 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 48 $acl = $this->functions->read_acl($account_lid); 49 $context = $acl[0]['context']; 50 $context_display = $acl[0]['context_display']; 47 48 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 49 $manager_acl = $this->functions->read_acl($manager_lid); 50 $manager_contexts = $manager_acl['contexts']; 51 foreach ($manager_acl['contexts_display'] as $index=>$tmp_context) 52 { 53 $context_display .= '<br>'.$tmp_context; 54 } 51 55 52 56 // Verifica se tem acesso a este modulo 53 if (!$this->functions->check_acl($ account_lid,'list_maillists'))57 if (!$this->functions->check_acl($manager_lid,'list_maillists')) 54 58 { 55 59 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 80 84 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), 81 85 'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.add_maillists'), 82 'add_email_lists_disabled' => $this->functions->check_acl($account_lid,'add_maillists') ? '' : 'disabled', 83 'context' => $context, 86 'add_email_lists_disabled' => $this->functions->check_acl($manager_lid,'add_maillists') ? '' : 'disabled', 84 87 'context_display' => $context_display, 85 88 'lang_email_lists_uid' => lang('Email Lists Logins'), … … 103 106 if ($GLOBALS['query'] != '') 104 107 { 105 $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $ context);108 $maillists_info = $this->functions->get_list('maillists', $GLOBALS['query'], $manager_contexts); 106 109 } 107 110 $total = count($maillists_info); … … 114 117 else if ($total) 115 118 { 116 if ($this->functions->check_acl($ account_lid,'edit_maillists'))119 if ($this->functions->check_acl($manager_lid,'edit_maillists')) 117 120 { 118 121 $can_edit = True; 119 122 } 120 if ($this->functions->check_acl($ account_lid,'delete_maillists'))123 if ($this->functions->check_acl($manager_lid,'delete_maillists')) 121 124 { 122 125 $can_delete = True; … … 147 150 if ($can_delete) 148 151 { 149 $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\" ,\"".$context."\");'>Excluir</a>");152 $p->set_var('delete_link',"<a href='#' onClick='javascript:delete_maillist(\"".$maillist['uid']."\",\"".$maillist['uidnumber']."\");'>Excluir</a>"); 150 153 } 151 154 else … … 163 166 { 164 167 $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); 165 166 $ account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];167 $ acl = $this->functions->read_acl($account_lid);168 $ context = $acl[0]['context'];169 168 169 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 170 $manager_acl = $this->functions->read_acl($manager_lid); 171 $manager_contexts = $manager_acl['contexts']; 172 170 173 // Verifica se tem acesso a este modulo 171 if (!$this->functions->check_acl($ account_lid,'add_maillists'))174 if (!$this->functions->check_acl($manager_lid,'add_maillists')) 172 175 { 173 176 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 184 187 185 188 // Pega combo das organizações. 186 $org = $this->functions->get_organizations($context, ''); 189 foreach ($manager_contexts as $index=>$context) 190 $sectors .= $this->functions->get_organizations($context); 187 191 188 192 // Seta variaveis utilizadas pelo tpl. … … 206 210 'lang_all_users' => lang('Show users from all sub-organizations'), 207 211 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'), 208 'combo_org' => $ org,212 'combo_org' => $sectors 209 213 ); 210 214 $p->set_var($var); … … 213 217 } 214 218 215 216 219 function edit_maillists() 217 220 { 218 221 $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); 219 220 $ account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];221 $ acl = $this->functions->read_acl($account_lid);222 $manager_context = $acl[0]['context'];223 222 223 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 224 $manager_acl = $this->functions->read_acl($manager_lid); 225 $manager_contexts = $manager_acl['contexts']; 226 224 227 // Verifica se tem acesso a este modulo 225 if (!$this->functions->check_acl($ account_lid,'edit_maillists'))228 if (!$this->functions->check_acl($manager_lid,'edit_maillists')) 226 229 { 227 230 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 229 232 230 233 // GET all infomations about the group. 231 $maillist_info = $this->maillist->get_info($_GET['uidnumber'], $manager_context); 232 //_debug_array($maillist_info); 234 $maillist_info = $this->maillist->get_info($_GET['uidnumber']); 233 235 234 236 unset($GLOBALS['phpgw_info']['flags']['noheader']); … … 242 244 243 245 // Pega combo das organizações e seleciona a org da lista. 244 $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context']))); 246 foreach ($manager_contexts as $index=>$context) 247 $sectors .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])) ); 245 248 246 249 // Usuarios da lista. … … 301 304 'lang_all_users' => lang('Select users from all sub-organizations'), 302 305 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'), 303 'combo_org' => $org, 304 'manager_context' => $manager_context, 306 'combo_org' => $sectors, 305 307 'uidnumber' => $_GET['uidnumber'], 306 308 'uid' => $maillist_info['uid'], … … 320 322 $GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);'); 321 323 322 $ account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];323 $ acl = $this->functions->read_acl($account_lid);324 $manager_context = $acl[0]['context'];325 324 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 325 $manager_acl = $this->functions->read_acl($manager_lid); 326 $manager_contexts = $manager_acl['contexts']; 327 326 328 // Verifica se tem acesso a este modulo 327 if (!$this->functions->check_acl($ account_lid,'edit_maillists'))329 if (!$this->functions->check_acl($manager_lid,'edit_maillists')) 328 330 { 329 331 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 331 333 332 334 // GET all infomations about the group. 333 $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber'], $manager_context); 334 //_debug_array($maillist_info); 335 $maillist_info = $this->maillist->get_scl_info($_GET['uidnumber']); 335 336 336 337 unset($GLOBALS['phpgw_info']['flags']['noheader']); … … 344 345 345 346 // Pega combo das organizações e seleciona a org da lista. 346 $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context']))); 347 // $org = $this->functions->get_organizations($manager_context, trim(strtolower($maillist_info['context']))); 348 foreach ($manager_contexts as $index=>$context) 349 $sectors .= $this->functions->get_organizations($context, trim(strtolower($maillist_info['context'])) ); 347 350 348 351 // Usuarios de senders. … … 378 381 'lang_all_users' => lang('Show users from all sub-organizations'), 379 382 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimaillists.list_maillists'), 380 'combo_org' => $org, 381 'manager_context' => $manager_context, 383 'combo_org' => $sectors, 382 384 'uidnumber' => $_GET['uidnumber'], 383 385 'uid' => $maillist_info['uid'], -
trunk/expressoAdmin1_2/inc/class.uimanagers.inc.php
r63 r64 18 18 'delete_managers' => True, 19 19 'edit_managers' => True, 20 'copy_managers' => True, 20 21 'validate' => True 21 22 ); … … 30 31 $c->read_repository(); 31 32 $this->config = $c->config_data; 33 34 if(!@is_object($GLOBALS['phpgw']->js)) 35 { 36 $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); 37 } 38 $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao 39 $GLOBALS['phpgw']->js->validate_file('jscode','managers','expressoAdmin1_2'); 32 40 } 33 41 … … 60 68 $p->set_block('managers','row','row'); 61 69 $p->set_block('managers','row_empty','row_empty'); 70 $tpl_vars = $p->get_undefined('body'); 62 71 63 72 $var = Array( 64 73 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.add_managers'), 65 74 'tr_color' => '#DDDDDD', 66 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 67 'lang_add_manager' => lang('Add Manager'), 68 'lang_manager_lid' => lang('Manager LID'), 69 'lang_manager_cn' => lang('Manager name'), 70 'lang_context' => lang('Context'), 71 'lang_edit' => lang('Edit'), 72 'lang_delete' => lang('Delete') 75 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'] 73 76 ); 74 77 75 // le do banco de dados para pegar os administradors. 78 // Cria dinamicamente os langs 79 foreach ($tpl_vars as $atribute) 80 { 81 $lang = strstr($atribute, 'lang_'); 82 if($lang !== false) 83 { 84 $p->set_var($atribute, $this->make_lang($atribute)); 85 } 86 } 87 88 // Le BD para pegar os administradors. 76 89 $query = 'SELECT manager_lid,context FROM phpgw_expressoadmin ORDER by manager_lid'; 77 90 $GLOBALS['phpgw']->db->query($query); … … 87 100 foreach($managers as $array_managers) 88 101 { 102 $managers_context = ""; 103 $a_managers_context = split("%", $array_managers['context']); 104 105 foreach ($a_managers_context as $context) 106 { 107 $managers_context .= "$context<br>"; 108 } 109 89 110 $filter="(&(phpgwAccountType=u)(uid=".$array_managers['manager_lid']."))"; 90 111 $ldap_search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese); … … 92 113 $p->set_var('manager_lid', $array_managers[manager_lid]); 93 114 $p->set_var('manager_cn', $ldap_result[0]['cn'][0] == '' ? '<font color=red>NAO ENCONTRADO NO LDAP</font>' : $ldap_result[0]['cn'][0]); 94 $p->set_var('context', $ array_managers[context]);115 $p->set_var('context', $managers_context); 95 116 $p->set_var('link_edit',$this->row_action('edit','edit_managers',$array_managers[manager_lid],$array_managers[context])); 96 117 $p->set_var('link_delete',$this->row_action('delete','delete_managers',$array_managers[manager_lid],$array_managers[context])); 118 $p->set_var('link_copy',"<a href='#' onClick='javascript:copy_manager(\"".$array_managers['manager_lid']."\");'>Copiar</a>"); 97 119 $p->fp('rows','row',True); 98 120 } … … 116 138 $p->set_file(array('managers' => 'managers_form.tpl')); 117 139 $p->set_block('managers','form','form'); 140 $tpl_vars = $p->get_undefined('form'); 118 141 119 142 // Imprime o NavBar … … 122 145 $GLOBALS['phpgw']->common->phpgw_header(); 123 146 147 // Seta variaveis javascript necessárias 148 $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 149 $scripts_java = '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>'; 150 151 // App, create list of available apps 152 $applications_list = $this->make_app_list(); 153 154 $input_context_fields = '<input type="text" size=60></input><br>'; 155 156 // Seta variaveis que estao no TPL 157 $var = Array( 158 'scripts_java' => $scripts_java, 159 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'), 160 'display_samba_suport' => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', 161 'type' => "add", 162 'color_bg1' => "#E8F0F0", 163 'color_bg2' => "#D3DCE3", 164 'color_font1' => "#DDDDDD", 165 'color_font2' => "#EEEEEE", 166 'input_context_fields' => $input_context_fields, 167 'error_messages' => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript">alert("'.$_POST['error_messages'].'");</script>', 168 'manager_lid' => $_POST['manager_lid'], 169 'context' => $_POST['context'], 170 'app_list' => $applications_list 171 ); 172 $p->set_var($var); 173 174 // Cria dinamicamente os langs e seta acls 175 foreach ($tpl_vars as $atribute) 176 { 177 $acl = strstr($atribute, 'acl_'); 178 $lang = strstr($atribute, 'lang_'); 179 // Recuperar os valores das ACLS 180 if ($acl !== false) 181 { 182 $p->set_var($atribute, $_POST[$atribute] != '' ? 'checked' : ''); 183 } 184 // Setar os langs do tpl. 185 elseif($lang !== false) 186 { 187 $p->set_var($atribute, $this->make_lang($atribute)); 188 } 189 } 190 191 echo $p->fp('out','form'); 192 } 193 194 function delete_managers() 195 { 196 // Criar uma verificação e jogar a query para o BO. 197 $context = $_GET['context']; 198 $manager_lid = $_GET['manager_lid']; 199 200 $query = "DELETE FROM phpgw_expressoadmin WHERE manager_lid = '".$manager_lid."' AND context = '" . $context ."'"; 201 $GLOBALS['phpgw']->db->query($query); 202 203 // Remove Gerente da tabela dos apps 204 $query = "DELETE FROM phpgw_expressoadmin_apps WHERE " 205 . "manager_lid = '".$manager_lid."' AND " 206 . "context = '".$context."'"; 207 $GLOBALS['phpgw']->db->query($query); 208 209 // Remove Gerente na ACL do expressoadmin 210 $accounts = CreateObject('phpgwapi.accounts'); 211 $manager_id = $accounts->name2id($_GET['manager_lid']); 212 $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 'expressoadmin' AND acl_account = '" . $manager_id . "'"; 213 $GLOBALS['phpgw']->db->query($sql); 214 215 ExecMethod('expressoAdmin1_2.uimanagers.list_managers'); 216 } 217 218 function edit_managers() 219 { 220 // Caso nao seja admin, sai. 221 if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin')) 222 { 223 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); 224 } 225 226 // Verifica se eh a primeira entrada, ai eu tenho o get, senao pego o post. 227 if ($_GET['manager_lid'] != '') 228 { 229 $first_time = true; 230 $_POST['manager_lid'] = $_GET['manager_lid']; 231 $_POST['context'] = $_GET['context']; 232 $old_manager_lid = $_GET['manager_lid']; 233 $old_context = $_GET['context']; 234 } 235 elseif ($_POST['manager_lid'] != '') 236 { 237 $first_time = false; 238 $old_manager_lid = $_POST['old_manager_lid']; 239 $old_context = $_POST['old_context']; 240 } 241 242 if ($first_time) 243 { 244 //Pego ACL do gerente 245 $manager = $this->functions->read_acl($_GET['manager_lid']); 246 //Cria vetor da ACL 247 $manager_acl = $this->functions->make_array_acl($manager['acl']); 248 249 //Pesquisa no Banco e pega os valores dos apps. 250 $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $_GET['manager_lid'] . "' AND context = '" . $_GET['context'] . "'"; 251 $GLOBALS['phpgw']->db->query($query); 252 $i=0; 253 $manager[0]['apps'] = array(); 254 while($GLOBALS['phpgw']->db->next_record()) 255 { 256 $tmp[$i] = $GLOBALS['phpgw']->db->row(); 257 $_POST['applications_list'][$tmp[$i]['app']] = 1; 258 $manager[0]['apps'][$tmp[$i]['app']] = 1; 259 $i++; 260 } 261 } 262 263 // Seta o template 264 $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 265 $p->set_file(array('managers' => 'managers_form.tpl')); 266 $p->set_block('managers','form','form'); 267 $tpl_vars = $p->get_undefined('form'); 268 269 // Imprime o NavBar 270 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 271 $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Managers'); 272 $GLOBALS['phpgw']->common->phpgw_header(); 273 124 274 // Seta variaveis javas necessárias 125 275 $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 126 $scripts_java = ''; 127 $scripts_java .= '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>'; 128 276 $scripts_java = '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>'; 277 129 278 // App, create list of available apps 279 $applications_list = $this->make_app_list($manager[0]['apps']); 280 281 $a_context = split("%", $_POST['context']); 282 foreach ($a_context as $context) 283 $input_context_fields .= '<input type="text" value="'.$context.'" size=60></input><br>'; 284 285 $var = Array( 286 'scripts_java' => $scripts_java, 287 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'), 288 'display_samba_suport' => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', 289 'color_bg1' => "#E8F0F0", 290 'color_bg2' => "#D3DCE3", 291 'color_font1' => "#DDDDDD", 292 'color_font2' => "#EEEEEE", 293 'type' => "edit", 294 'error_messages'=> $_POST['error_messages'] == '' ? '' : '<script language="JavaScript1.3">alert("'.$_POST['error_messages'].'");</script>', 295 'manager_lid' => $_POST['manager_lid'], 296 'context' => $_POST['context'], 297 298 'input_context_fields' => $input_context_fields, 299 300 // Para o update no banco, preciso saber oq foi alterado e para que. 301 // Talvez so o manager e o contexto. 302 'old_manager_lid' => $old_manager_lid, 303 'old_context' => $old_context, 304 'app_list' => $applications_list 305 ); 306 $p->set_var($var); 307 308 // Cria dinamicamente os langs e seta acls 309 foreach ($tpl_vars as $atribute) 310 { 311 $acl = strstr($atribute, 'acl_'); 312 $lang = strstr($atribute, 'lang_'); 313 // Recuperar os valores das ACLS 314 if ($acl !== false) 315 { 316 if ($first_time) 317 $p->set_var($atribute, $manager_acl[$atribute] != '' ? 'checked' : ''); 318 else 319 $p->set_var($atribute, $_POST[$atribute] != '' ? 'checked' : ''); 320 } 321 // Setar os langs do tpl. 322 elseif($lang !== false) 323 { 324 $p->set_var($atribute, $this->make_lang($atribute)); 325 } 326 } 327 328 echo $p->fp('out','form'); 329 } 330 331 function validate() 332 { 333 $accounts = CreateObject('phpgwapi.accounts'); 334 $errors = array(); 335 336 // verifica se o manager existe. caso retorne 1 existe e eh uma conta de usuario. 337 $manager_lid_exists = $accounts->exists($_POST['manager_lid']); 338 if ($manager_lid_exists != 1) 339 { 340 $_POST['error_messages'] = lang("Manager LID don't exist."); 341 if ($_POST['type'] == 'add') 342 $this->add_managers(); 343 elseif ($_POST['type'] == 'edit') 344 $this->edit_managers(); 345 return; 346 } 347 348 // Verifica se o contexto existe. 349 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 350 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 351 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 352 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 353 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 354 ldap_bind($ldap_conn,$dn,$passwd); 355 356 $contexts = split("%", $_POST['context']); 357 358 foreach ($contexts as $index=>$context) 359 { 360 $sr=@ldap_list($ldap_conn, $context, "cn=*"); 361 if (!$sr) 362 { 363 $_POST['error_messages'] = lang("Context don't exist") . ": $context"; 364 ldap_close($ldap_conn); 365 if ($_POST['type'] == 'add') 366 $this->add_managers(); 367 elseif ($_POST['type'] == 'edit') 368 $this->edit_managers(); 369 return; 370 } 371 } 372 373 if ($_POST['type'] == 'add') 374 { 375 //Verifica se ja existe o manager com aquele contexto cadastrado 376 $query = "SELECT manager_lid FROM phpgw_expressoadmin WHERE manager_lid = '" . $_POST['manager_lid'] . "' AND context = '" . $_POST['context'] . "'"; 377 $GLOBALS['phpgw']->db->query($query); 378 $num_registros = 0; 379 while($GLOBALS['phpgw']->db->next_record()) 380 { 381 $tmp[] = $GLOBALS['phpgw']->db->row(); 382 $num_registros++; 383 } 384 if ($num_registros != 0) 385 { 386 $_POST['error_messages'] = lang('Este Gerente, neste contexto já exite !!'); 387 $this->add_managers(); 388 return; 389 } 390 } 391 392 if ($_POST['type'] == 'add') 393 ExecMethod('expressoAdmin1_2.bomanagers.add_managers'); 394 elseif ($_POST['type'] == 'edit') 395 ExecMethod('expressoAdmin1_2.bomanagers.edit_managers'); 396 397 return true; 398 } 399 400 function copy_managers() 401 { 402 403 404 405 /* 406 echo '<pre>'; 407 print_r($_GET); 408 $manager_lid = $_GET['manager_lid']; 409 410 //Pego ACL do gerente 411 $manager = $this->functions->read_acl($manager_lid); 412 //Cria vetor da ACL 413 $manager_acl = $this->functions->make_array_acl($manager[0]['acl']); 414 415 //Pesquisa no Banco e pega os valores dos apps. 416 $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $manager_lid . "' AND context = '" . $_GET['context'] . "'"; 417 $GLOBALS['phpgw']->db->query($query); 418 $i=0; 419 $manager[0]['apps'] = array(); 420 while($GLOBALS['phpgw']->db->next_record()) 421 { 422 $tmp[$i] = $GLOBALS['phpgw']->db->row(); 423 $_POST['applications_list'][$tmp[$i]['app']] = 1; 424 $manager[0]['apps'][$tmp[$i]['app']] = 1; 425 $i++; 426 } 427 428 print_r($manager); 429 430 */ 431 } 432 433 function make_lang($ram_lang) 434 { 435 $a_lang = split("_", $ram_lang); 436 $a_lang_reverse = array_reverse ( $a_lang, true ); 437 //Retira o lang do array. 438 array_pop ( $a_lang_reverse ); 439 $a_lang = array_reverse ( $a_lang_reverse, true ); 440 $a_new_lang = implode ( " ", $a_lang ); 441 return lang($a_new_lang); 442 } 443 444 function make_app_list($manager_app_list) 445 { 130 446 $this->nextmatchs = createobject('phpgwapi.nextmatchs'); 131 447 $apps = CreateObject('phpgwapi.applications',$_account_id); 132 448 $db_perms = $apps->read_account_specific(); 133 449 $availableApps = $GLOBALS['phpgw_info']['apps']; 450 134 451 uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);')); 135 452 136 453 // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box. 137 454 $applications_list = ''; … … 141 458 $total_apps = count($availableApps); 142 459 $i = 0; 460 143 461 foreach($availableApps as $app => $data) 144 462 { … … 146 464 if (($i +1) % 3 == 1) 147 465 { 148 if ($ _POST['applications_list'][$app] == 1)466 if ($manager_app_list[$app] == 1) 149 467 $checked = 'checked'; 150 468 else … … 159 477 if (($i +1) % 3 == 2) 160 478 { 161 if ($ _POST['applications_list'][$app] == 1)479 if ($manager_app_list[$app] == 1) 162 480 $checked = 'checked'; 163 481 else … … 172 490 if (($i +1) % 3 == 0) 173 491 { 174 if ($ _POST['applications_list'][$app] == 1)492 if ($manager_app_list[$app] == 1) 175 493 $checked = 'checked'; 176 494 else … … 184 502 $i++; 185 503 } 186 187 // Seta variaveis que estao no TPL 188 $var = Array( 189 'scripts_java' => $scripts_java, 190 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'), 191 'display_samba_suport' => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', 192 193 'type' => "add", 194 'color_bg1' => "#E8F0F0", 195 'color_bg2' => "#D3DCE3", 196 'color_font1' => "#DDDDDD", 197 'color_font2' => "#EEEEEE", 198 'lang_back' => lang('Back'), 199 'lang_add_save_manager' => lang('Add Manager'), 200 'lang_manager_lid' => lang('Manager LID'), 201 'lang_context' => lang('Context'), 202 'lang_type_access' => lang('Tipo de acessos'), 203 'lang_add_users' => lang('Add users'), 204 'lang_edit_users' => lang('Edit users'), 205 'lang_delete_users' => lang('Delete users'), 206 'lang_view_users' => lang('View user'), 207 'lang_rename_user' => lang('Rename users'), 208 'lang_view_user' => lang('View users'), 209 'lang_manipulate_corporative_information' => lang('Manipulate corporative information'), 210 'lang_add_groups' => lang('Add groups'), 211 'lang_edit_groups' => lang('Edit groups'), 212 'lang_delete_groups' => lang('Delete groups'), 213 'lang_edit_email_attribute_from_the_groups' => lang('Edit email attribute from the groups'), 214 'lang_change_user_password' => lang('Change users password'), 215 'lang_change_users_quote' => lang('Change users quote'), 216 'lang_set_user_default_password'=> lang('Set default users password'), 217 'lang_empty_user_inbox' => lang('Empty user inbox'), 218 'lang_edit_sambausers_attributes'=> lang('Edit SAMBA users attributes'), 219 'lang_edit_sambadomains' => lang('Edit SAMBA domains'), 220 'lang_add_email_lists' => lang('Add email lists'), 221 'lang_edit_email_lists' => lang('Edit email lists'), 222 'lang_delete_email_lists' => lang('Delete email lists'), 223 'lang_view_email_lists' => lang('View email lists'), 224 'lang_create_orgs' => lang('Create Organizations'), 225 'lang_edit_orgs' => lang('Edit Organizations'), 226 'lang_delete_orgs' => lang('Delete Organizations'), 227 'lang_view_global_sessions' => lang('View sessions (global)'), 228 'lang_view_logs' => lang('View logs'), 229 'lang_create_computers' => lang('Create computers'), 230 'lang_edit_computers' => lang('Edit computers'), 231 'lang_delete_computers' => lang('Delete computers'), 232 'error_messages' => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript1.3">alert("'.$_POST['error_messages'].'");</script>', 233 'manager_lid' => $_POST['manager_lid'], 234 'context' => $_POST['context'], 235 'add_users' => $_POST['add_users'] != '' ? 'checked' : '', 236 'edit_users' => $_POST['edit_users'] != '' ? 'checked' : '', 237 'view_users' => $_POST['view_users'] != '' ? 'checked' : '', 238 'manipulate_corporative_information' => $_POST['manipulate_corporative_information'] != '' ? 'checked' : '', 239 'delete_users' => $_POST['delete_users'] != '' ? 'checked' : '', 240 'add_groups' => $_POST['add_groups'] != '' ? 'checked' : '', 241 'edit_groups' => $_POST['edit_groups'] != '' ? 'checked' : '', 242 'delete_groups' => $_POST['delete_groups'] != '' ? 'checked' : '', 243 'change_users_password' => $_POST['change_users_password'] != '' ? 'checked' : '', 244 'change_users_quote' => $_POST['change_users_quote'] != '' ? 'checked' : '', 245 'set_user_default_password' => $_POST['set_user_default_password'] != '' ? 'checked' : '', 246 'edit_sambausers_attributes' => $_POST['edit_sambausers_attributes'] != '' ? 'checked' : '', 247 'edit_sambadomains' => $_POST['edit_sambadomains'] != '' ? 'checked' : '', 248 'add_maillists' => $_POST['add_maillists'] != '' ? 'checked' : '', 249 'edit_maillists' => $_POST['edit_maillists'] != '' ? 'checked' : '', 250 'delete_maillists' => $_POST['delete_maillists'] != '' ? 'checked' : '', 251 'create_sectors' => $_POST['create_sectors'] != '' ? 'checked' : '', 252 'edit_sectors' => $_POST['edit_sectors'] != '' ? 'checked' : '', 253 'delete_sectors' => $_POST['delete_sectors'] != '' ? 'checked' : '', 254 'view_global_sessions' => $_POST['view_global_sessions'] != '' ? 'checked' : '', 255 'view_logs' => $_POST['view_logs'] != '' ? 'checked' : '', 256 257 'app_list' => $applications_list 258 ); 259 $p->set_var($var); 260 echo $p->fp('out','form'); 261 } 262 263 function delete_managers() 264 { 265 // Criar uma verificação e jogar a query para o BO. 266 $context = $_GET['context']; 267 $manager_lid = $_GET['manager_lid']; 268 269 $query = "DELETE FROM phpgw_expressoadmin WHERE manager_lid = '".$manager_lid."' AND context = '" . $context ."'"; 270 $GLOBALS['phpgw']->db->query($query); 271 272 // Remove Gerente da tabela dos apps 273 $query = "DELETE FROM phpgw_expressoadmin_apps WHERE " 274 . "manager_lid = '".$manager_lid."' AND " 275 . "context = '".$context."'"; 276 $GLOBALS['phpgw']->db->query($query); 277 278 // Remove Gerente na ACL do expressoadmin 279 $accounts = CreateObject('phpgwapi.accounts'); 280 $manager_id = $accounts->name2id($_GET['manager_lid']); 281 $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 'expressoadmin' AND acl_account = '" . $manager_id . "'"; 282 $GLOBALS['phpgw']->db->query($sql); 283 284 ExecMethod('expressoAdmin1_2.uimanagers.list_managers'); 285 } 286 287 function edit_managers() 288 { 289 // Caso nao seja admin, sai. 290 if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin')) 291 { 292 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); 293 } 294 295 // Verifica se eh a primeira entrada, ai eu tenho o get, senao pego o post. 296 if ($_GET['manager_lid'] != '') 297 { 298 $_POST['manager_lid'] = $_GET['manager_lid']; 299 $_POST['context'] = $_GET['context']; 300 $old_manager_lid = $_GET['manager_lid']; 301 $old_context = $_GET['context']; 302 $first_time = true; 303 } 304 elseif ($_POST['manager_lid'] != '') 305 { 306 $old_manager_lid = $_POST['old_manager_lid']; 307 $old_context = $_POST['old_context']; 308 $first_time = false; 309 } 310 311 if ($first_time) 312 { 313 //Pesquisa no Banco e pega os valores da ACL 314 $query = "SELECT * FROM phpgw_expressoadmin WHERE manager_lid = '" . $_GET['manager_lid'] . "' AND context = '" . $_GET['context'] . "'"; 315 $GLOBALS['phpgw']->db->query($query); 316 while($GLOBALS['phpgw']->db->next_record()) 317 { 318 $manager[] = $GLOBALS['phpgw']->db->row(); 319 } 320 321 //Pesquisa no Banco e pega os valores dos apps. 322 $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '" . $_GET['manager_lid'] . "' AND context = '" . $_GET['context'] . "'"; 323 $GLOBALS['phpgw']->db->query($query); 324 $i=0; 325 $manager[0]['apps'] = array(); 326 while($GLOBALS['phpgw']->db->next_record()) 327 { 328 $tmp[$i] = $GLOBALS['phpgw']->db->row(); 329 $_POST['applications_list'][$tmp[$i]['app']] = 1; 330 $manager[0]['apps'][$tmp[$i]['app']] = 1; 331 $i++; 332 } 333 334 //Cria vetor da ACL 335 $acl = $this->functions->make_array_acl($manager[0]['acl']); 336 $_POST['add_users'] = $acl['add_users']; 337 $_POST['edit_users'] = $acl['edit_users']; 338 $_POST['delete_users'] = $acl['delete_users']; 339 $_POST['rename_users'] = $acl['rename_users']; 340 $_POST['view_users'] = $acl['view_users']; 341 $_POST['manipulate_corporative_information'] = $acl['manipulate_corporative_information']; 342 $_POST['add_groups'] = $acl['add_groups']; 343 $_POST['edit_groups'] = $acl['edit_groups']; 344 $_POST['delete_groups'] = $acl['delete_groups']; 345 $_POST['edit_email_groups'] = $acl['edit_email_groups']; 346 $_POST['change_users_password'] = $acl['change_users_password']; 347 $_POST['change_users_quote'] = $acl['change_users_quote']; 348 $_POST['set_user_default_password'] = $acl['set_user_default_password']; 349 $_POST['empty_user_inbox'] = $acl['empty_user_inbox']; 350 $_POST['edit_sambausers_attributes'] = $acl['edit_sambausers_attributes']; 351 $_POST['edit_sambadomains'] = $acl['edit_sambadomains']; 352 $_POST['add_maillists'] = $acl['add_maillists']; 353 $_POST['edit_maillists'] = $acl['edit_maillists']; 354 $_POST['delete_maillists'] = $acl['delete_maillists']; 355 $_POST['create_sectors'] = $acl['create_sectors']; 356 $_POST['edit_sectors'] = $acl['edit_sectors']; 357 $_POST['delete_sectors'] = $acl['delete_sectors']; 358 $_POST['create_computers'] = $acl['create_computers']; 359 $_POST['edit_computers'] = $acl['edit_computers']; 360 $_POST['delete_computers'] = $acl['delete_computers']; 361 $_POST['view_global_sessions'] = $acl['view_global_sessions']; 362 $_POST['view_logs'] = $acl['view_logs']; 363 } 364 365 // Seta o template 366 $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); 367 //$accounts = CreateObject('phpgwapi.accounts'); 368 $p->set_file(array('managers' => 'managers_form.tpl')); 369 $p->set_block('managers','form','form'); 370 371 // Imprime o NavBar 372 unset($GLOBALS['phpgw_info']['flags']['nonavbar']); 373 $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Managers'); 374 $GLOBALS['phpgw']->common->phpgw_header(); 375 376 // Seta variaveis javas necessárias 377 $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 378 $scripts_java = ''; 379 $scripts_java .= '<script type="text/javascript" src="'.$webserver_url.'/expressoAdmin1_2/js/jscode/expressoadmin.js"></script>'; 380 381 // App, create list of available apps 382 $this->nextmatchs = createobject('phpgwapi.nextmatchs'); 383 $apps = CreateObject('phpgwapi.applications',$_account_id); 384 $db_perms = $apps->read_account_specific(); 385 $availableApps = $GLOBALS['phpgw_info']['apps']; 386 387 uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);')); 388 389 // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box. 390 $applications_list = ''; 391 $app_col1 = ''; 392 $app_col2 = ''; 393 $app_col3 = ''; 394 $total_apps = count($availableApps); 395 $i = 0; 396 397 foreach($availableApps as $app => $data) 398 { 399 // 1 coluna 400 if (($i +1) % 3 == 1) 401 { 402 if ($_POST['applications_list'][$app] == 1) 403 $checked = 'checked'; 404 else 405 $checked = ''; 406 $app_col1 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n", 407 $data['title'],$app,$checked, $disabled); 408 409 if ($i == ($total_apps-1)) 410 $applications_list .= sprintf('<tr bgcolor="%s">%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1); 411 } 412 // 2 coluna 413 if (($i +1) % 3 == 2) 414 { 415 if ($_POST['applications_list'][$app] == 1) 416 $checked = 'checked'; 417 else 418 $checked = ''; 419 $app_col2 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n", 420 $data['title'],$app,$checked, $disabled); 421 422 if ($i == ($total_apps-1)) 423 $applications_list .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1,$app_col2); 424 } 425 // 3 coluna 426 if (($i +1) % 3 == 0) 427 { 428 if ($_POST['applications_list'][$app] == 1) 429 $checked = 'checked'; 430 else 431 $checked = ''; 432 $app_col3 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='applications_list[%s]' value='1' %s %s></td>\n", 433 $data['title'],$app,$checked, $disabled); 434 435 // Cria nova linha 436 $applications_list .= sprintf('<tr bgcolor="%s">%s%s%s</tr>',$this->nextmatchs->alternate_row_color(), $app_col1, $app_col2, $app_col3); 437 } 438 $i++; 439 } 440 441 $var = Array( 442 'scripts_java' => $scripts_java, 443 'action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uimanagers.validate'), 444 'display_samba_suport' => $this->config['expressoAdmin_samba_support'] == 'true' ? '' : 'display:none', 445 'color_bg1' => "#E8F0F0", 446 'color_bg2' => "#D3DCE3", 447 'color_font1' => "#DDDDDD", 448 'color_font2' => "#EEEEEE", 449 'type' => "edit", 450 'lang_back' => lang('Back'), 451 'lang_add_save_manager' => lang('Save'), 452 'lang_manager_lid' => lang('Manager LID'), 453 'lang_context' => lang('Contexto'), 454 'lang_type_access' => lang('Tipo de acessos'), 455 'lang_add_users' => lang('Add users'), 456 'lang_edit_users' => lang('Edit users'), 457 'lang_delete_users' => lang('Delete users'), 458 'lang_view_users' => lang('View users'), 459 'lang_rename_user' => lang('Rename users'), 460 'lang_view_user' => lang('View users'), 461 'lang_manipulate_corporative_information' => lang('Manipulate corporative information'), 462 'lang_add_groups' => lang('Add groups'), 463 'lang_edit_groups' => lang('Edit groups'), 464 'lang_delete_groups' => lang('Delete groups'), 465 'lang_edit_email_attribute_from_the_groups' => lang('Edit email attribute from the groups'), 466 'lang_change_user_password' => lang('Change users password'), 467 'lang_change_users_quote' => lang('Change users quote'), 468 'lang_set_user_default_password'=> lang('Set default user password'), 469 'lang_empty_user_inbox' => lang('Empty user inbox'), 470 'lang_edit_sambausers_attributes'=> lang('Edit SAMBA users attributes'), 471 'lang_edit_sambadomains' => lang('Edit SAMBA domains'), 472 'lang_add_email_lists' => lang('Add email lists'), 473 'lang_edit_email_lists' => lang('Edit email lists'), 474 'lang_delete_email_lists' => lang('Delete email lists'), 475 'lang_view_email_lists' => lang('View email lists'), 476 'lang_create_orgs' => lang('Create Organizations'), 477 'lang_edit_orgs' => lang('Edit Organizations'), 478 'lang_delete_orgs' => lang('Delete Organizations'), 479 'lang_view_sessions' => lang('View sessions (local)'), 480 'lang_view_global_sessions' => lang('View sessions (global)'), 481 'lang_view_logs' => lang('View Logs'), 482 'lang_create_computers' => lang('Create computers'), 483 'lang_edit_computers' => lang('Edit computers'), 484 'lang_delete_computers' => lang('Delete computers'), 485 'error_messages' => $_POST['error_messages'] == '' ? '' : '<script language="JavaScript1.3">alert("'.$_POST['error_messages'].'");</script>', 486 'manager_lid' => $_POST['manager_lid'], 487 'context' => $_POST['context'], 488 'add_users' => $_POST['add_users'] != '' ? 'checked' : '', 489 'edit_users' => $_POST['edit_users'] != '' ? 'checked' : '', 490 'delete_users' => $_POST['delete_users'] != '' ? 'checked' : '', 491 'rename_users' => $_POST['rename_users'] != '' ? 'checked' : '', 492 'view_users' => $_POST['view_users'] != '' ? 'checked' : '', 493 'manipulate_corporative_information' => $_POST['manipulate_corporative_information'] != '' ? 'checked' : '', 494 'add_groups' => $_POST['add_groups'] != '' ? 'checked' : '', 495 'edit_groups' => $_POST['edit_groups'] != '' ? 'checked' : '', 496 'delete_groups' => $_POST['delete_groups'] != '' ? 'checked' : '', 497 'edit_email_groups' => $_POST['edit_email_groups'] != '' ? 'checked' : '', 498 'change_users_password' => $_POST['change_users_password'] != '' ? 'checked' : '', 499 'change_users_quote' => $_POST['change_users_quote'] != '' ? 'checked' : '', 500 'set_user_default_password' => $_POST['set_user_default_password'] != '' ? 'checked' : '', 501 'empty_user_inbox' => $_POST['empty_user_inbox'] != '' ? 'checked' : '', 502 'edit_sambausers_attributes' => $_POST['edit_sambausers_attributes'] != '' ? 'checked' : '', 503 'edit_sambadomains' => $_POST['edit_sambadomains'] != '' ? 'checked' : '', 504 'add_maillists' => $_POST['add_maillists'] != '' ? 'checked' : '', 505 'edit_maillists' => $_POST['edit_maillists'] != '' ? 'checked' : '', 506 'delete_maillists' => $_POST['delete_maillists'] != '' ? 'checked' : '', 507 'create_sectors' => $_POST['create_sectors'] != '' ? 'checked' : '', 508 'edit_sectors' => $_POST['edit_sectors'] != '' ? 'checked' : '', 509 'delete_sectors' => $_POST['delete_sectors'] != '' ? 'checked' : '', 510 'create_computers' => $_POST['create_computers'] != '' ? 'checked' : '', 511 'edit_computers' => $_POST['edit_computers'] != '' ? 'checked' : '', 512 'delete_computers' => $_POST['delete_computers'] != '' ? 'checked' : '', 513 'view_sessions' => $_POST['view_sessions'] != '' ? 'checked' : '', 514 'view_global_sessions' => $_POST['view_global_sessions'] != '' ? 'checked' : '', 515 'view_logs' => $_POST['view_logs'] != '' ? 'checked' : '', 516 517 // Para o update no banco, preciso saber oq foi alterado e para que. 518 // Talvez so o manager e o contexto. 519 'old_manager_lid' => $old_manager_lid, 520 'old_context' => $old_context, 521 'app_list' => $applications_list 522 ); 523 $p->set_var($var); 524 echo $p->fp('out','form'); 525 } 526 527 function validate() 528 { 529 $accounts = CreateObject('phpgwapi.accounts'); 530 $errors = array(); 531 532 // verifica se o manager existe. caso retorne 1 existe e eh uma conta de usuario. 533 $manager_lid_exists = $accounts->exists($_POST['manager_lid']); 534 if ($manager_lid_exists != 1) 535 { 536 $_POST['error_messages'] = lang("Manager LID don't exist."); 537 if ($_POST['type'] == 'add') 538 $this->add_managers(); 539 elseif ($_POST['type'] == 'edit') 540 $this->edit_managers(); 541 return; 542 } 543 544 // Verifica se o contexto existe. 545 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 546 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 547 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 548 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 549 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 550 ldap_bind($ldap_conn,$dn,$passwd); 551 552 $sr=@ldap_list($ldap_conn, $_POST['context'], "cn=*"); 553 if (!$sr) 554 { 555 $_POST['error_messages'] = lang("Context don't exist."); 556 ldap_close($ldap_conn); 557 if ($_POST['type'] == 'add') 558 $this->add_managers(); 559 elseif ($_POST['type'] == 'edit') 560 $this->edit_managers(); 561 return; 562 } 563 564 if ($_POST['type'] == 'add') 565 { 566 //Verifica se ja existe o manager com aquele contexto cadastrado 567 $query = "SELECT manager_lid FROM phpgw_expressoadmin WHERE manager_lid = '" . $_POST['manager_lid'] . "' AND context = '" . $_POST['context'] . "'"; 568 $GLOBALS['phpgw']->db->query($query); 569 $num_registros = 0; 570 while($GLOBALS['phpgw']->db->next_record()) 571 { 572 $tmp[] = $GLOBALS['phpgw']->db->row(); 573 $num_registros++; 574 } 575 if ($num_registros != 0) 576 { 577 $_POST['error_messages'] = lang('Este Gerente, neste contexto já exite !!'); 578 $this->add_managers(); 579 return; 580 } 581 } 582 583 if ($_POST['type'] == 'add') 584 ExecMethod('expressoAdmin1_2.bomanagers.add_managers'); 585 elseif ($_POST['type'] == 'edit') 586 ExecMethod('expressoAdmin1_2.bomanagers.edit_managers'); 587 588 return true; 504 return $applications_list; 589 505 } 590 506 } -
trunk/expressoAdmin1_2/inc/class.uisectors.inc.php
r46 r64 37 37 function list_sectors() 38 38 { 39 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 40 $tmp = $this->functions->read_acl($account_lid); 41 $manager_context = $tmp[0]['context']; 42 $context_display = $tmp[0]['context_display']; 43 39 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 40 $acl = $this->functions->read_acl($manager_lid); 41 $contexts = $acl['contexts']; 42 foreach ($acl['contexts_display'] as $index=>$tmp_context) 43 { 44 $context_display .= '<br>'.$tmp_context; 45 } 46 44 47 // Verifica se o administrador tem acesso. 45 if (!$this->functions->check_acl($ account_lid,'list_sectors'))48 if (!$this->functions->check_acl($manager_lid,'list_sectors')) 46 49 { 47 50 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 60 63 $p->set_block('sectors','row_empty','row_empty'); 61 64 62 //$sectors_info = $this->functions->get_sectors_list($manager_context); 63 //_debug_array($sectors_info); 64 $sectors_info = $this->functions->get_sectors_list($manager_context); 65 $sectors_info = $this->functions->get_sectors_list($contexts); 65 66 66 67 $var = Array( 67 68 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 68 69 'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'), 69 'context' => $manager_context,70 70 'context_display' => $context_display, 71 71 'lang_context' => lang('context'), … … 85 85 else 86 86 { 87 if ($this->functions->check_acl($ account_lid,'edit_sectors'))87 if ($this->functions->check_acl($manager_lid,'edit_sectors')) 88 88 { 89 89 $can_edit = True; 90 90 } 91 91 92 if ($this->functions->check_acl($ account_lid,'delete_sectors'))92 if ($this->functions->check_acl($manager_lid,'delete_sectors')) 93 93 { 94 94 $can_delete = True; … … 146 146 //_debug_array($_GET); 147 147 //_debug_array($_POST); 148 149 $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 150 $acl = $this->functions->read_acl($account_lid); 151 $manager_context = $acl[0]['context']; 148 149 $manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid']; 150 $acl = $this->functions->read_acl($manager_lid); 152 151 153 152 $context = $_GET['context']; 154 153 155 154 // Verifica se tem acesso a este modulo 156 if (!$this->functions->check_acl($ account_lid,'create_sectors'))155 if (!$this->functions->check_acl($manager_lid,'create_sectors')) 157 156 { 158 157 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php')); … … 173 172 'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors'), 174 173 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], 175 'context' => $context == '' ? $ manager_context: $context,174 'context' => $context == '' ? $GLOBALS['phpgw_info']['server']['ldap_context'] : $context, 176 175 'sector' => $_POST['sector'], 177 176 'sector_visible_checked'=> $_POST['sector_visible'] ? 'checked' : '', -
trunk/expressoAdmin1_2/inc/class.user.inc.php
r63 r64 51 51 } 52 52 53 // Pega ID do BD e incrementa de 1. 54 $id = (($this->db_functions->get_next_id()) + 1); 55 53 // Leio o ID a ser usado na criação do objecto. 54 $next_id = ($this->db_functions->get_next_id('accounts')); 55 if ((!is_numeric($next_id['id'])) || (!$next_id['status'])) 56 { 57 $return['status'] = false; 58 $return['msg'] = "Problemas obtendo ID do usuário.\n" . $id['msg']; 59 return $return; 60 } 61 else 62 { 63 $id = $next_id['id']; 64 } 56 65 // Incrementa o id no BD. 57 $this->db_functions->increment_id($id,'accounts');66 //$this->db_functions->increment_id($id,'accounts'); 58 67 59 68 // Cria array para incluir no LDAP … … 155 164 foreach ($params as $atribute=>$value) 156 165 { 157 $pos = str rpos($atribute, 'corporative_information_');166 $pos = strstr($atribute, 'corporative_information_'); 158 167 if ($pos !== false) 159 168 { … … 259 268 $return['status'] = true; 260 269 261 $old_values = $this->get_user_info($new_values['uidnumber'], $new_values['manager_context']); 270 $old_values = $this->get_user_info($new_values['uidnumber']); 271 262 272 $dn = 'uid=' . $old_values['uid'] . ',' . strtolower($old_values['context']); 263 264 273 $diff = array_diff($new_values, $old_values); 265 274 266 275 $manager_account_lid = $_SESSION['phpgw_session']['session_lid']; 267 276 if ((!$this->functions->check_acl($manager_account_lid,'edit_users')) && 268 277 (!$this->functions->check_acl($manager_account_lid,'change_users_password')) && 269 (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) 278 (!$this->functions->check_acl($manager_account_lid,'edit_sambausers_attributes')) && 279 (!$this->functions->check_acl($manager_account_lid,'manipulate_corporative_information')) 270 280 ) 271 281 { … … 368 378 // REPLACE, ADD & REMOVE COPORATIVEs ATRIBUTES 369 379 // Verifica o acesso do gerente aos atributos corporativos 370 if ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) 380 381 if ( ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'edit_users')) || 382 ($this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'manipulate_corporative_information')) ) 371 383 { 372 384 foreach ($new_values as $atribute=>$value) 373 385 { 374 $pos = str rpos($atribute, 'corporative_information_');386 $pos = strstr($atribute, 'corporative_information_'); 375 387 if ($pos !== false) 376 388 { … … 504 516 if (($old_values['accountstatus'] == '') && ($new_values['accountstatus'] != '')) 505 517 { 518 echo '<pre>'; 519 print_r($old_values); 506 520 $ldap_add['accountstatus'] = 'active'; 507 521 $this->db_functions->write_log("ativado conta de email do usuario",'',$dn,'',''); … … 634 648 } 635 649 } 650 636 651 if (count($remove_groups)>0) 637 652 { 638 653 foreach($remove_groups as $gidnumber) 639 654 { 655 echo $gidnumber; 656 640 657 foreach($old_values['groups_info'] as $group) 641 658 { … … 676 693 if (count($ldap_add)) 677 694 { 678 695 print_r($ldap_add); 679 696 $result = $this->ldap_functions->add_user_attributes($dn, $ldap_add); 680 697 if (!$result['status']) … … 707 724 if (!$old_values['maillists']) 708 725 $old_values['maillists'] = array(); 709 726 710 727 $add_maillists = array_diff($new_values['maillists'], $old_values['maillists']); 711 728 $remove_maillists = array_diff($old_values['maillists'], $new_values['maillists']); … … 719 736 } 720 737 } 738 721 739 if (count($remove_maillists)>0) 722 740 { … … 776 794 } 777 795 778 function get_user_info($uidnumber , $context)796 function get_user_info($uidnumber) 779 797 { 780 $user_info_ldap = $this->ldap_functions->get_user_info($uidnumber , $context);798 $user_info_ldap = $this->ldap_functions->get_user_info($uidnumber); 781 799 $user_info_db1 = $this->db_functions->get_user_info($uidnumber); 782 $user_info_db2 = $this->ldap_functions->gidnumbers2cn($user_info_db1['groups'] , $context);800 $user_info_db2 = $this->ldap_functions->gidnumbers2cn($user_info_db1['groups']); 783 801 $user_info_imap = $this->imap_functions->get_user_info($user_info_ldap['uid']); 784 802 $user_info = array_merge($user_info_ldap, $user_info_db1, $user_info_db2, $user_info_imap); … … 837 855 { 838 856 $uidnumber = $params['uidnumber']; 839 $context = $params['context']; 840 $user_info = $this->get_user_info($uidnumber, $context); 857 $user_info = $this->get_user_info($uidnumber); 841 858 842 859 //LDAP … … 847 864 $return['msg'] .= $result_ldap['msg']; 848 865 } 849 850 //DB 851 $result_db = $this->db_functions->delete_user($user_info); 852 if (!$result_db['status']) 853 { 854 $return['status'] = false; 855 $return['msg'] .= $result_ldap['msg']; 856 } 857 858 //IMAP 859 $result_imap = $this->imap_functions->delete_user($user_info['uid']); 860 if (!$result_imap['status']) 861 { 862 $return['status'] = false; 863 $return['msg'] .= $result_ldap['msg']; 864 } 865 866 $this->db_functions->write_log('deletado usuario','',$user_info['uid'],'',''); 866 else 867 { 868 //DB 869 $result_db = $this->db_functions->delete_user($user_info); 870 if (!$result_db['status']) 871 { 872 $return['status'] = false; 873 $return['msg'] .= $result_ldap['msg']; 874 } 875 876 //IMAP 877 $result_imap = $this->imap_functions->delete_user($user_info['uid']); 878 if (!$result_imap['status']) 879 { 880 $return['status'] = false; 881 $return['msg'] .= $result_ldap['msg']; 882 } 883 $this->db_functions->write_log('deletado usuario','',$user_info['uid'],'',''); 884 } 867 885 } 868 886 … … 874 892 { 875 893 $return['status'] = true; 894 895 // Verifica acesso do gerente (OU) ao tentar renomear um usuário. 896 if ( ! $this->ldap_functions->check_access_to_renamed($params['uid']) ) 897 { 898 $return['status'] = false; 899 $return['msg'] .= 'Você não tem acesso para deletar este usuário.'; 900 return $return; 901 } 876 902 877 903 // Verifica o acesso do gerente … … 880 906 $uid = $params['uid']; 881 907 $new_uid = $params['new_uid']; 882 $context = $params['context'];883 908 $defaultUserPassword = '{md5}'.base64_encode(pack("H*",md5($this->current_config['expressoAdmin_defaultUserPassword']))); 884 909 $defaultUserPassword_plain = $this->current_config['expressoAdmin_defaultUserPassword']; … … 974 999 975 1000 $return['exec_return'] = ""; 976 return $return;977 1001 } 978 1002 else … … 981 1005 $return['msg'] .= "A renomeação de usuários só permitida com o cyrus versão 2.2 ou superior,"; 982 1006 $return['msg'] .= "\ne com a opção 'allowusermoves: yes' configurado no imapd.conf."; 983 return $return;984 1007 } 985 986 /********************* 987 * 988 * RENOMEAÇÃO APENAS PARA CYRUS 2.2 OU SUPERIOR 989 * 990 *********************/ 991 /* 992 //Verifica se o binario para renomeacao existe. 993 if (!is_file('/home/expressolivre/imapsync')) 994 { 995 $return['status'] = false; 996 $return['msg'] .= "O arquivo binário /home/expressolivre/imapsync não existe.\\nEle é necessário para a renomeação das caixas postais.\\nInforme o administrador ExpressoLivre sobre isto."; 997 } 998 999 // Seta senha default 1000 $user_password = $this->ldap_functions->set_user_password($uid, $defaultUserPassword); 1001 1002 // Renomeia UID no openldap 1003 $result = $this->ldap_functions->rename_uid($uid, $new_uid); 1004 $new_dn = $result['new_dn']; 1005 1006 if (!$result['status']) 1007 { 1008 $return['status'] = false; 1009 $return['msg'] .= "Erro ao renomear usuário no LDAP. Processo abortado."; 1010 return $return; 1011 } 1012 1013 // Pega a cota do usuario 1014 $quota = $this->imap_functions->get_user_info($uid); 1015 $quota_limit = $quota['mailquota']; 1016 if ($quota_limit == '-1') 1017 $quota_limit = '40960'; 1018 1019 //Cria a nova caixa postal 1020 $this->imap_functions->create($new_uid, $quota_limit); 1021 1022 // Realiza a cópia das mensagens de uma caixa para outra. 1023 $exec_return = array(); 1024 $exec_result = exec("/home/expressolivre/imapsync " . 1025 "--host1 localhost " . 1026 "--user1 " . $uid . ' ' . 1027 "--password1 $defaultUserPassword_plain " . 1028 "--host2 localhost " . 1029 "--user2 " . $new_uid . ' ' . 1030 "--password2 $defaultUserPassword_plain " . 1031 "--syncinternaldates --exclude user.*", $exec_return, $exec_result); 1032 1033 $reg_total = count($exec_return); 1034 1035 for ($i=$reg_total; $i>($reg_total-9); $i--) 1036 $return['exec_return'] .= $exec_return[$i] . "\n"; 1037 1038 //SIEVE 1039 if ($sieve_enable == 'yes') 1040 { 1041 include_once('sieve-php.lib.php'); 1042 1043 $sieve_uid = new sieve("$sieve_server", "$sieve_port", "$uid", "$defaultUserPassword_plain", '', "PLAIN"); 1044 $sieve_new_uid = new sieve("$sieve_server", "$sieve_port", "$new_uid", "$defaultUserPassword_plain", '', "PLAIN"); 1045 1046 if (!$sieve_uid->sieve_login()) 1047 { 1048 $return['status'] = false; 1049 $return['msg'] .= "\nNão foi possível fazer login no sieve:$uid"; 1050 } 1051 elseif (!$sieve_new_uid->sieve_login()) 1052 { 1053 $return['status'] = false; 1054 $return['msg'] .= "\nNão foi possível fazer login no sieve:$new_uid"; 1055 } 1056 else 1057 { 1058 $sieve_uid->sieve_listscripts(); 1059 $uid_active_script=$sieve_uid->response["ACTIVE"]; 1060 if(isset($uid_active_script)) 1061 { 1062 $i=0; 1063 $activescript=""; 1064 if($sieve_uid->sieve_getscript($uid_active_script)) 1065 { 1066 if(is_array($sieve_uid->response)) 1067 { 1068 foreach($sieve_uid->response as $result) 1069 { 1070 $activescript .= $result; 1071 } 1072 } 1073 } 1074 1075 $new_script_name = $new_uid; 1076 if ($sieve_new_uid->sieve_sendscript($new_script_name,$activescript)) 1077 { 1078 $sieve_new_uid->sieve_setactivescript($new_script_name); 1079 $return['exec_return'] .= "Script SIEVE transferido com êxito.\n"; 1080 } 1081 else 1082 { 1083 $return['status'] = false; 1084 $return['msg'] .= "Problemas na transferência do script Sieve.\\n"; 1085 } 1086 } 1087 else 1088 $return['exec_return'] .= "\n2"; 1089 } 1090 $sieve_uid->sieve_logout(); 1091 $sieve_new_uid->sieve_logout(); 1092 } 1093 else 1094 $return['exec_return'] .= "\n1"; 1095 1096 if ($exec_result) 1097 { 1098 // Deleta caixa-postal antiga 1099 $result = $this->imap_functions->delete_user($uid); 1100 if (!$result['status']) 1101 { 1102 $return['status'] = false; 1103 $return['msg'] .= $result['msg']; 1104 } 1105 } 1106 else 1107 { 1108 $return['status'] = false; 1109 $return['msg'] .= "Problemas ao executar o imapsinc. Caixa postal $uid não excluida."; 1110 } 1111 1112 // Retorna senha do usuário 1113 $this->ldap_functions->set_user_password($uid, $user_password); 1114 1115 // Remove old UID do ldap 1116 $user_info_mod_remove['uid'] = $uid; 1117 $this->ldap_functions->remove_user_attributes($new_dn, $user_info_mod_remove); 1118 1119 $this->db_functions->write_log('renomeado usuario',$new_uid,$uid,'',''); 1120 1121 return $return; 1122 */ 1008 return $return; 1123 1009 } 1124 1010 }
Note: See TracChangeset
for help on using the changeset viewer.