Changeset 64 for trunk/expressoAdmin1_2/inc/class.functions.inc.php
- Timestamp:
- 09/05/07 11:18:58 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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())
Note: See TracChangeset
for help on using the changeset viewer.