[2364] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /*************************************************************************** |
---|
| 4 | * Expresso Livre * |
---|
| 5 | * http://www.expressolivre.org * |
---|
| 6 | * -------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
[1151] | 12 | $current = $_GET['currentApp']; |
---|
| 13 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 14 | 'noheader' => True, |
---|
| 15 | 'nonavbar' => True, |
---|
| 16 | 'currentapp' => $current |
---|
| 17 | ); |
---|
| 18 | |
---|
| 19 | include('../../../header.inc.php'); |
---|
| 20 | //include('../../../admin/templates/celepar/head.inc.php'); |
---|
| 21 | |
---|
| 22 | $owner = $_SESSION['owner']; |
---|
| 23 | $acl_app = $_SESSION['acl_app']; |
---|
| 24 | |
---|
| 25 | if(!$acl_app) |
---|
| 26 | $acl_app = $current; |
---|
| 27 | |
---|
| 28 | if(!@is_object($GLOBALS['phpgw']->js)) { |
---|
| 29 | |
---|
| 30 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | $t = &$GLOBALS['phpgw']->template; |
---|
| 37 | // seta o Template |
---|
[1559] | 38 | $t->set_file(array('addUser_t' => '../../../phpgwapi/templates/default/listUsers.tpl')); |
---|
[1151] | 39 | |
---|
| 40 | $obj_account = CreateObject('phpgwapi.accounts',$owner); |
---|
| 41 | |
---|
| 42 | $post_select_organization = $_POST['select_organization']; |
---|
| 43 | $post_select_sector = $_POST['select_sector']; |
---|
| 44 | $change_organization = $_POST['change_organization']; |
---|
[1559] | 45 | $search_users = $_POST['search_users']; |
---|
[1151] | 46 | |
---|
| 47 | $obj_org_sector = CreateObject('phpgwapi.sector_search_ldap'); |
---|
[1559] | 48 | $cn='*'; |
---|
| 49 | if ((!$post_select_organization) && (!$post_select_sector) && (!$search_users)) //primeira vez |
---|
[1151] | 50 | { |
---|
| 51 | $user_org = $obj_account->get_organization($GLOBALS['phpgw_info']['user']['account_dn']); |
---|
| 52 | $user_sector = $obj_account->get_sector($GLOBALS['phpgw_info']['user']['account_dn']); |
---|
| 53 | $user_context = $obj_account->get_context($GLOBALS['phpgw_info']['user']['account_dn']); |
---|
| 54 | |
---|
| 55 | $organizations_info = $obj_org_sector->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
| 56 | @asort($organizations_info); |
---|
| 57 | @reset($organizations_info); |
---|
| 58 | $sectors_info = $obj_org_sector->sector_search('ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
| 59 | } |
---|
[1559] | 60 | else if(($post_select_organization) && ($post_select_sector) && (!$search_users))//mudou uma das combos |
---|
[1151] | 61 | { |
---|
| 62 | $user_org = $post_select_organization; |
---|
| 63 | $user_sector = $post_select_sector; |
---|
| 64 | if ($change_organization == "True") |
---|
| 65 | $user_context = 'ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 66 | else |
---|
| 67 | $user_context = $post_select_sector; |
---|
| 68 | $organizations_info = $obj_org_sector->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
| 69 | @asort($organizations_info); |
---|
| 70 | @reset($organizations_info); |
---|
| 71 | $sectors_info = $obj_org_sector->sector_search('ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
| 72 | } |
---|
[1559] | 73 | else if ($search_users)//foi preenchida a caixa de busca independente |
---|
| 74 | { |
---|
| 75 | $user_context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 76 | system('echo "CONTEXT: '.$user_context.'" >/tmp/controle'); |
---|
| 77 | $organizations_info = $obj_org_sector->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
| 78 | @asort($organizations_info); |
---|
| 79 | @reset($organizations_info); |
---|
| 80 | $sectors_info = $obj_org_sector->sector_search('ou='.$post_select_organization.','.$GLOBALS['phpgw_info']['server']['ldap_context']); |
---|
| 81 | @reset($sector_info); |
---|
| 82 | $cn='*'.$search_users.'*'; |
---|
| 83 | } |
---|
| 84 | |
---|
[1151] | 85 | foreach($organizations_info as $organization) |
---|
| 86 | { |
---|
| 87 | $combo_organization .= '<option value="' . $organization . '"'; |
---|
| 88 | |
---|
| 89 | if (!$post_select_organization) |
---|
| 90 | { |
---|
| 91 | if($organization == $user_org) |
---|
| 92 | { |
---|
| 93 | $combo_organization .= ' selected'; |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | else |
---|
| 97 | { |
---|
| 98 | if($organization == $post_select_organization) |
---|
| 99 | { |
---|
| 100 | $combo_organization .= ' selected'; |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | $combo_organization .= '>' .$organization.'</option>'."\n"; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | $combo_sector .= '<option value="ou='.$user_org.','.$GLOBALS['phpgw_info']['server']['ldap_context'].'"> --------- </option>'."\n"; |
---|
| 107 | foreach($sectors_info as $sector) |
---|
| 108 | { |
---|
| 109 | $combo_sector .= '<option value="' . $sector->sector_context . '"'; |
---|
| 110 | |
---|
| 111 | if (!$post_select_sector) |
---|
| 112 | { |
---|
| 113 | if($sector->sector_name == $user_sector) |
---|
| 114 | $combo_sector .= ' selected'; |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | if($sector->sector_context == $post_select_sector) |
---|
| 119 | $combo_sector .= ' selected'; |
---|
| 120 | } |
---|
| 121 | $combo_sector .= '>' .$sector->sector_name.'</option>'."\n"; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | // Monta lista de Grupos e Usuários |
---|
| 125 | $users = Array(); |
---|
| 126 | $groups = Array(); |
---|
[1559] | 127 | $justthese = array("phpgwaccountvisible","uidNumber","cn"); |
---|
[1151] | 128 | |
---|
| 129 | $typeAccount = 'u'; |
---|
| 130 | |
---|
| 131 | if($_GET['type']) |
---|
| 132 | $typeAccount = $_GET['type']; |
---|
| 133 | |
---|
| 134 | $ldap_host =$GLOBALS['phpgw_info']['server']['ldap_host']; |
---|
| 135 | $ds = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
| 136 | if ($ds) |
---|
| 137 | { |
---|
[1559] | 138 | $sr=ldap_search($ds, $user_context, ("(&(cn=$cn)(phpgwaccounttype=".$typeAccount."))"),$justthese); |
---|
[1151] | 139 | $info = ldap_get_entries($ds, $sr); |
---|
| 140 | |
---|
| 141 | if($typeAccount == 'u'){ |
---|
| 142 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 143 | { |
---|
| 144 | if ($info[$i]["phpgwaccountvisible"][0] == '-1') |
---|
| 145 | continue; |
---|
| 146 | $users[$uids=$info[$i]["uidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => u ); |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | else { |
---|
| 150 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 151 | $users[$uids=$info[$i]["gidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => g); |
---|
| 152 | |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | ldap_close($ds); |
---|
| 156 | |
---|
| 157 | @asort($users); |
---|
| 158 | @reset($users); |
---|
| 159 | // @asort($groups); |
---|
| 160 | // @reset($groups); |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | $options =''; |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | if($current == 'preferences'){ |
---|
| 167 | foreach($users as $id => $user_array) { |
---|
| 168 | if($owner != $id){ |
---|
| 169 | $newId = 'u_'.$acl_app.'['.$id; |
---|
| 170 | $options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | else if($current == 'admin') { |
---|
| 175 | foreach($users as $id => $user_array) { |
---|
| 176 | $options .= '<option value="'.$id.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | $t->set_var ('lang_Organization',lang('Organization')); |
---|
| 181 | $t->set_var ('lang_Sector',lang('Sector')); |
---|
| 182 | $t->set_var ('lang_Calendar',lang('Calendar')); |
---|
| 183 | $t->set_var ('lang_Add_Participants',lang('Add Participants')); |
---|
| 184 | $t->set_var ('lang_to_Search',lang('to Search')); |
---|
| 185 | $t->set_var ('lang_Close',lang('Close')); |
---|
| 186 | $t->set_var ('lang_Add',lang('Add')); |
---|
| 187 | |
---|
| 188 | if($current == 'preferences') |
---|
| 189 | $t->set_var ('addUser','javascript:addUserAcl()'); |
---|
| 190 | else |
---|
| 191 | $t->set_var ('addUser','javascript:addUser()'); |
---|
| 192 | |
---|
| 193 | $t->set_var('options',$options); |
---|
| 194 | $t->set_var('combo_organization', $combo_organization); |
---|
| 195 | $t->set_var('combo_sector', $combo_sector); |
---|
| 196 | $t->parse('out','addUser_t',true); |
---|
| 197 | $t->p('out'); |
---|
| 198 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 199 | ?> |
---|