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