1 | <?php |
---|
2 | /**********************************************************************************\ |
---|
3 | * Expresso Administração * |
---|
4 | * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br) * |
---|
5 | * --------------------------------------------------------------------------------* |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**********************************************************************************/ |
---|
11 | |
---|
12 | include_once('class.db_functions.inc.php'); |
---|
13 | include_once(PHPGW_API_INC.'/class.config.inc.php'); |
---|
14 | |
---|
15 | class functions |
---|
16 | { |
---|
17 | var $public_functions = array |
---|
18 | ( |
---|
19 | 'make_array_acl' => True, |
---|
20 | 'check_acl' => True, |
---|
21 | 'read_acl' => True, |
---|
22 | 'exist_account_lid' => True, |
---|
23 | 'exist_email' => True, |
---|
24 | 'array_invert' => True |
---|
25 | ); |
---|
26 | |
---|
27 | var $nextmatchs; |
---|
28 | var $sectors_list = array(); |
---|
29 | var $current_config; |
---|
30 | |
---|
31 | function functions() |
---|
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; |
---|
40 | } |
---|
41 | |
---|
42 | function write_log($action, $about) |
---|
43 | { |
---|
44 | return $this->db_functions->write_log($action, $about); |
---|
45 | } |
---|
46 | |
---|
47 | // Account and type of access. Return: Have access ? (true/false) |
---|
48 | function check_acl($account_lid, $access) |
---|
49 | { |
---|
50 | $array_acl = $this->db_functions->read_acl($account_lid); |
---|
51 | switch($access) |
---|
52 | { |
---|
53 | case 'list_users': |
---|
54 | 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'] || $array_acl['acl_edit_users_phonenumber'] ) |
---|
55 | return true; |
---|
56 | break; |
---|
57 | case 'list_groups': |
---|
58 | if ($array_acl['acl_add_groups'] || $array_acl['acl_edit_groups'] || $array_acl['acl_delete_groups']) |
---|
59 | return true; |
---|
60 | break; |
---|
61 | case 'list_maillists': |
---|
62 | if ($array_acl['acl_add_maillists'] || $array_acl['acl_edit_maillists'] || $array_acl['acl_delete_maillists']) |
---|
63 | return true; |
---|
64 | break; |
---|
65 | case 'list_sectors': |
---|
66 | if ($array_acl['acl_create_sectors'] || $array_acl['acl_edit_sectors'] || $array_acl['acl_delete_sectors']) |
---|
67 | return true; |
---|
68 | break; |
---|
69 | case 'list_computers': |
---|
70 | if ($array_acl['acl_create_computers'] || $array_acl['acl_edit_computers'] || $array_acl['acl_delete_computers']) |
---|
71 | return true; |
---|
72 | break; |
---|
73 | |
---|
74 | case 'display_groups': |
---|
75 | if ( $array_acl['acl_edit_users'] || $array_acl['acl_view_users'] || ($array_acl['acl_edit_sambausers_attributes'] && ($this->current_config['expressoAdmin_samba_support'] == 'true')) ) |
---|
76 | return true; |
---|
77 | break; |
---|
78 | case 'display_emailconfig': |
---|
79 | if ($array_acl['acl_edit_users'] || $array_acl['acl_view_users']) |
---|
80 | return true; |
---|
81 | break; |
---|
82 | case 'display_applications': |
---|
83 | if ($array_acl['acl_edit_users'] || $array_acl['acl_view_users']) |
---|
84 | return true; |
---|
85 | break; |
---|
86 | case 'display_emaillists': |
---|
87 | if ($array_acl['acl_edit_users'] || $array_acl['acl_view_users']) |
---|
88 | return true; |
---|
89 | break; |
---|
90 | |
---|
91 | case 'list_institutional_accounts': |
---|
92 | if ($array_acl['acl_add_institutional_accounts'] || $array_acl['acl_edit_institutional_accounts'] || $array_acl['acl_delete_institutional_accounts']) |
---|
93 | return true; |
---|
94 | break; |
---|
95 | case 'list_shared_accounts': |
---|
96 | if ($array_acl['acl_add_shared_accounts'] || $array_acl['acl_edit_shared_accounts'] || $array_acl['acl_delete_shared_accounts']) |
---|
97 | return true; |
---|
98 | break; |
---|
99 | case 'configurations': |
---|
100 | if ($array_acl['acl_active_blocking_sending_email_to_shared_accounts'] || $array_acl['acl_add_blocking_sending_email_to_shared_accounts_exception'] || $array_acl['acl_edit_and_remove_blocking_sending_email_to_shared_accounts_exception'] || $array_acl['acl_edit_maximum_number_of_recipients_generally'] || $array_acl['acl_add_maximum_number_of_recipients_by_user'] || $array_acl['acl_edit_and_remove_maximum_number_of_recipients_by_user'] || $array_acl['acl_add_maximum_number_of_recipients_by_group'] || $array_acl['acl_edit_and_remove_maximum_number_of_recipients_by_group']) |
---|
101 | return true; |
---|
102 | break; |
---|
103 | case 'messages_size': |
---|
104 | if($array_acl['acl_add_messages_size_rule'] || $array_acl['acl_edit_messages_size_rule'] || $array_acl['acl_remove_messages_size_rule']) |
---|
105 | return true; |
---|
106 | break; |
---|
107 | default: |
---|
108 | return $array_acl["acl_$access"]; |
---|
109 | } |
---|
110 | return false; |
---|
111 | } |
---|
112 | |
---|
113 | /* OLD FUNCTION |
---|
114 | function check_acl($account_lid, $access) |
---|
115 | { |
---|
116 | $acl = $this->read_acl($account_lid); |
---|
117 | $array_acl = $this->make_array_acl($acl['acl']); |
---|
118 | |
---|
119 | //What access ?? In the IF, verify if have access. |
---|
120 | switch($access) |
---|
121 | { |
---|
122 | case list_users: |
---|
123 | 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']) |
---|
124 | return true; |
---|
125 | break; |
---|
126 | case add_users: |
---|
127 | if ($array_acl['acl_add_users']) |
---|
128 | return true; |
---|
129 | break; |
---|
130 | case edit_users: |
---|
131 | if ($array_acl['acl_edit_users']) |
---|
132 | return true; |
---|
133 | break; |
---|
134 | case delete_users: |
---|
135 | if ($array_acl['acl_delete_users']) |
---|
136 | return true; |
---|
137 | break; |
---|
138 | case rename_users: |
---|
139 | if ($array_acl['acl_rename_users']) |
---|
140 | return true; |
---|
141 | break; |
---|
142 | case view_users: |
---|
143 | if ($array_acl['acl_view_users']) |
---|
144 | return true; |
---|
145 | break; |
---|
146 | case edit_users_picture: |
---|
147 | if ($array_acl['acl_edit_users_picture']) |
---|
148 | return true; |
---|
149 | break; |
---|
150 | case manipulate_corporative_information: |
---|
151 | if ($array_acl['acl_manipulate_corporative_information']) |
---|
152 | return true; |
---|
153 | break; |
---|
154 | case change_users_password: |
---|
155 | if ($array_acl['acl_change_users_password']) |
---|
156 | return true; |
---|
157 | break; |
---|
158 | case change_users_quote: |
---|
159 | if ($array_acl['acl_change_users_quote']) |
---|
160 | return true; |
---|
161 | break; |
---|
162 | case set_user_default_password: |
---|
163 | if ($array_acl['acl_set_user_default_password']) |
---|
164 | return true; |
---|
165 | break; |
---|
166 | case empty_user_inbox: |
---|
167 | if (($array_acl['acl_empty_user_inbox']) && ($array_acl['acl_edit_users'])) |
---|
168 | return true; |
---|
169 | break; |
---|
170 | case edit_sambausers_attributes: case list_maillists: |
---|
171 | if ($array_acl['acl_add_maillists'] || $array_acl['acl_edit_maillists'] || $array_acl['acl_delete_maillists']) |
---|
172 | return true; |
---|
173 | break; |
---|
174 | |
---|
175 | if ($array_acl['acl_edit_sambausers_attributes']) |
---|
176 | return true; |
---|
177 | break; |
---|
178 | case edit_sambadomains: |
---|
179 | if ($array_acl['acl_edit_sambadomains']) |
---|
180 | return true; |
---|
181 | break; |
---|
182 | |
---|
183 | case list_groups: |
---|
184 | if ($array_acl['acl_add_groups'] || $array_acl['acl_edit_groups'] || $array_acl['acl_delete_groups']) |
---|
185 | return true; |
---|
186 | break; |
---|
187 | case add_groups: |
---|
188 | if ($array_acl['acl_add_groups']) |
---|
189 | return true; |
---|
190 | break; |
---|
191 | case edit_groups: |
---|
192 | if ($array_acl['acl_edit_groups']) |
---|
193 | return true; |
---|
194 | break; |
---|
195 | case delete_groups: |
---|
196 | if ($array_acl['acl_delete_groups']) |
---|
197 | return true; |
---|
198 | break; |
---|
199 | case edit_email_groups: |
---|
200 | if ($array_acl['acl_edit_email_groups']) |
---|
201 | return true; |
---|
202 | break; |
---|
203 | |
---|
204 | case list_maillists: |
---|
205 | if ($array_acl['acl_add_maillists'] || $array_acl['acl_edit_maillists'] || $array_acl['acl_delete_maillists']) |
---|
206 | return true; |
---|
207 | break; |
---|
208 | case add_maillists: |
---|
209 | if ($array_acl['acl_add_maillists']) |
---|
210 | return true; |
---|
211 | break; |
---|
212 | case edit_maillists: |
---|
213 | if ($array_acl['acl_edit_maillists']) |
---|
214 | return true; |
---|
215 | break; |
---|
216 | case delete_maillists: |
---|
217 | if ($array_acl['acl_delete_maillists']) |
---|
218 | return true; |
---|
219 | break; |
---|
220 | |
---|
221 | case list_sectors: |
---|
222 | if ($array_acl['acl_create_sectors'] || $array_acl['acl_edit_sectors'] || $array_acl['acl_delete_sectors']) |
---|
223 | return true; |
---|
224 | break; |
---|
225 | case create_sectors: |
---|
226 | if ($array_acl['acl_create_sectors']) |
---|
227 | return true; |
---|
228 | break; |
---|
229 | case edit_sectors: |
---|
230 | if ($array_acl['acl_edit_sectors']) |
---|
231 | return true; |
---|
232 | break; |
---|
233 | case delete_sectors: |
---|
234 | if ($array_acl['acl_delete_sectors']) |
---|
235 | return true; |
---|
236 | break; |
---|
237 | |
---|
238 | case view_global_sessions: |
---|
239 | if ($array_acl['acl_view_global_sessions']) |
---|
240 | return true; |
---|
241 | break; |
---|
242 | |
---|
243 | case list_computers: |
---|
244 | if ($array_acl['acl_create_computers'] || $array_acl['acl_edit_computers'] || $array_acl['acl_delete_computers']) |
---|
245 | return true; |
---|
246 | break; |
---|
247 | case create_computers: |
---|
248 | if ($array_acl['acl_create_computers']) |
---|
249 | return true; |
---|
250 | break; |
---|
251 | case edit_computers: |
---|
252 | if ($array_acl['acl_edit_computers']) |
---|
253 | return true; |
---|
254 | break; |
---|
255 | case delete_computers: |
---|
256 | if ($array_acl['acl_delete_computers']) |
---|
257 | return true; |
---|
258 | break; |
---|
259 | |
---|
260 | case view_logs: |
---|
261 | if ($array_acl['acl_view_logs']) |
---|
262 | return true; |
---|
263 | break; |
---|
264 | |
---|
265 | case display_groups: |
---|
266 | if ( $array_acl['acl_edit_users'] || $array_acl['acl_view_users'] || ($array_acl['acl_edit_sambausers_attributes'] && ($this->current_config['expressoAdmin_samba_support'] == 'true')) ) |
---|
267 | return true; |
---|
268 | break; |
---|
269 | case display_emailconfig: |
---|
270 | if ($array_acl['acl_edit_users'] || $array_acl['acl_view_users']) |
---|
271 | return true; |
---|
272 | break; |
---|
273 | case display_applications: |
---|
274 | if ($array_acl['acl_edit_users'] || $array_acl['acl_view_users']) |
---|
275 | return true; |
---|
276 | break; |
---|
277 | case display_emaillists: |
---|
278 | if ($array_acl['acl_edit_users'] || $array_acl['acl_view_users']) |
---|
279 | return true; |
---|
280 | break; |
---|
281 | |
---|
282 | default: |
---|
283 | return $array_acl["acl_$access"]; |
---|
284 | } |
---|
285 | return false; |
---|
286 | } |
---|
287 | */ |
---|
288 | |
---|
289 | // Read acl from db |
---|
290 | function read_acl($account_lid) |
---|
291 | { |
---|
292 | $acl = $this->db_functions->read_acl($account_lid); |
---|
293 | return $acl; |
---|
294 | } |
---|
295 | |
---|
296 | |
---|
297 | function get_inactive_users($contexts) { |
---|
298 | $retorno = array(); |
---|
299 | $tempUsers = array(); |
---|
300 | //Pego no LDAP todos os usuários dos contextos em questão. |
---|
301 | $usuariosLdap = $this->get_list('accounts','',$contexts); |
---|
302 | foreach($usuariosLdap as $usuarioLdap) { |
---|
303 | $tempUsers[$usuarioLdap["account_id"]] = $usuarioLdap["account_lid"]; |
---|
304 | } |
---|
305 | $ids = implode(",",array_keys($tempUsers)); //Consigo a lista de uids daquele contexto para mandar na query para o banco. |
---|
306 | |
---|
307 | //Pego nas configurações do expresso o número de dias necessários para inatividade. |
---|
308 | $timeToExpire = $GLOBALS['phpgw_info']['server']['time_to_account_expires']; |
---|
309 | |
---|
310 | |
---|
311 | $ultimoTsValido = time() - ($timeToExpire * 86400); //O último timestamp válido é dado pelo de agora menos o número de dias para expirar vezes a quantidade de segundos existente em 1 dia. |
---|
312 | $query = "select account_id,max(li) as last_login from phpgw_access_log where account_id in (".$ids.") group by account_id having max(li) < ".$ultimoTsValido." order by max(li)"; |
---|
313 | |
---|
314 | $GLOBALS['phpgw']->db->query($query); |
---|
315 | while($GLOBALS['phpgw']->db->next_record()) |
---|
316 | { |
---|
317 | $result = $GLOBALS['phpgw']->db->row(); |
---|
318 | array_push($retorno,array("uidNumber"=>$result["account_id"],"login"=> $tempUsers[$result["account_id"]],"li"=>$result["last_login"])); |
---|
319 | } |
---|
320 | |
---|
321 | return $retorno; |
---|
322 | } |
---|
323 | |
---|
324 | function safeBitCheck($number,$comparison) |
---|
325 | { |
---|
326 | $binNumber = base_convert($number,10,2); |
---|
327 | $binComparison = strrev(base_convert($comparison,10,2)); |
---|
328 | $str = strlen($binNumber); |
---|
329 | |
---|
330 | if ( ($str <= strlen($binComparison)) && ($binComparison{$str-1}==="1") ) |
---|
331 | return '1'; |
---|
332 | else |
---|
333 | return '0'; |
---|
334 | } |
---|
335 | |
---|
336 | function get_list($type, $query, $contexts) |
---|
337 | { |
---|
338 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
339 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
340 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
341 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
342 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
343 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
344 | |
---|
345 | if ($type == 'accounts') |
---|
346 | { |
---|
347 | $justthese = array("uidnumber", "uid", "cn", "mail"); |
---|
348 | $filter="(&(phpgwAccountType=u)(|(uid=*".$query."*)(sn=*".$query."*)(cn=*".$query."*)(givenName=*".$query."*)(mail=$query*)(mailAlternateAddress=$query*)))"; |
---|
349 | |
---|
350 | $tmp = array(); |
---|
351 | foreach ($contexts as $index=>$context) |
---|
352 | { |
---|
353 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
354 | $info = ldap_get_entries($ldap_conn, $search); |
---|
355 | |
---|
356 | for ($i=0; $i < $info['count']; ++$i) |
---|
357 | { |
---|
358 | $tmp[$info[$i]['uid'][0]]['account_id'] = $info[$i]['uidnumber'][0]; |
---|
359 | $tmp[$info[$i]['uid'][0]]['account_lid'] = $info[$i]['uid'][0]; |
---|
360 | $tmp[$info[$i]['uid'][0]]['account_cn'] = $info[$i]['cn'][0]; |
---|
361 | $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0]; |
---|
362 | $sort[] = $info[$i]['uid'][0]; |
---|
363 | } |
---|
364 | } |
---|
365 | ldap_close($ldap_conn); |
---|
366 | |
---|
367 | if (count($sort)) |
---|
368 | { |
---|
369 | natcasesort($sort); |
---|
370 | foreach ($sort as $user_uid) |
---|
371 | $return[$user_uid] = $tmp[$user_uid]; |
---|
372 | } |
---|
373 | |
---|
374 | return $return; |
---|
375 | } |
---|
376 | elseif($type == 'groups') |
---|
377 | { |
---|
378 | $filter="(&(phpgwAccountType=g)(cn=*$query*))"; |
---|
379 | $justthese = array("gidnumber", "cn", "description"); |
---|
380 | |
---|
381 | $tmp = array(); |
---|
382 | foreach ($contexts as $index=>$context) |
---|
383 | { |
---|
384 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
385 | $info = ldap_get_entries($ldap_conn, $search); |
---|
386 | for ($i=0; $i < $info['count']; ++$i) |
---|
387 | { |
---|
388 | $tmp[$info[$i]['cn'][0]]['cn']= $info[$i]['cn'][0]; |
---|
389 | $tmp[$info[$i]['cn'][0]]['description']= $info[$i]['description'][0]; |
---|
390 | $tmp[$info[$i]['cn'][0]]['gidnumber']= $info[$i]['gidnumber'][0]; |
---|
391 | $sort[] = $info[$i]['cn'][0]; |
---|
392 | } |
---|
393 | } |
---|
394 | ldap_close($ldap_conn); |
---|
395 | |
---|
396 | natcasesort($sort); |
---|
397 | foreach ($sort as $group_cn) |
---|
398 | $return[$group_cn] = $tmp[$group_cn]; |
---|
399 | |
---|
400 | return $return; |
---|
401 | } |
---|
402 | elseif($type == 'maillists') |
---|
403 | { |
---|
404 | $filter="(&(phpgwAccountType=l)(|(cn=*".$query."*)(uid=*".$query."*)(mail=*".$query."*)))"; |
---|
405 | $justthese = array("uidnumber", "cn", "uid", "mail"); |
---|
406 | |
---|
407 | $tmp = array(); |
---|
408 | foreach ($contexts as $index=>$context) |
---|
409 | { |
---|
410 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
411 | $info = ldap_get_entries($ldap_conn, $search); |
---|
412 | |
---|
413 | for ($i=0; $i < $info['count']; ++$i) |
---|
414 | { |
---|
415 | $tmp[$info[$i]['uid'][0]]['uid'] = $info[$i]['uid'][0]; |
---|
416 | $tmp[$info[$i]['uid'][0]]['name'] = $info[$i]['cn'][0]; |
---|
417 | $tmp[$info[$i]['uid'][0]]['uidnumber'] = $info[$i]['uidnumber'][0]; |
---|
418 | $tmp[$info[$i]['uid'][0]]['email'] = $info[$i]['mail'][0]; |
---|
419 | $sort[] = $info[$i]['uid'][0]; |
---|
420 | } |
---|
421 | } |
---|
422 | ldap_close($ldap_conn); |
---|
423 | |
---|
424 | natcasesort($sort); |
---|
425 | foreach ($sort as $maillist_uid) |
---|
426 | $return[$maillist_uid] = $tmp[$maillist_uid]; |
---|
427 | |
---|
428 | return $return; |
---|
429 | } |
---|
430 | elseif($type == 'computers') |
---|
431 | { |
---|
432 | $filter="(&(objectClass=sambaSAMAccount)(|(sambaAcctFlags=[W ])(sambaAcctFlags=[DW ])(sambaAcctFlags=[I ])(sambaAcctFlags=[S ]))(cn=*".$query."*))"; |
---|
433 | $justthese = array("cn","uidNumber","description"); |
---|
434 | |
---|
435 | $tmp = array(); |
---|
436 | foreach ($contexts as $index=>$context) |
---|
437 | { |
---|
438 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
439 | $info = ldap_get_entries($ldap_conn, $search); |
---|
440 | for ($i=0; $i < $info['count']; ++$i) |
---|
441 | { |
---|
442 | $tmp[$info[$i]['cn'][0]]['cn'] = $info[$i]['cn'][0]; |
---|
443 | $tmp[$info[$i]['cn'][0]]['uidNumber'] = $info[$i]['uidnumber'][0]; |
---|
444 | $tmp[$info[$i]['cn'][0]]['description'] = utf8_decode($info[$i]['description'][0]); |
---|
445 | $sort[] = $info[$i]['cn'][0]; |
---|
446 | } |
---|
447 | |
---|
448 | } |
---|
449 | ldap_close($ldap_conn); |
---|
450 | |
---|
451 | if (!empty($sort)) |
---|
452 | { |
---|
453 | natcasesort($sort); |
---|
454 | foreach ($sort as $computer_cn) |
---|
455 | $return[$computer_cn] = $tmp[$computer_cn]; |
---|
456 | } |
---|
457 | |
---|
458 | return $return; |
---|
459 | } |
---|
460 | } |
---|
461 | |
---|
462 | function get_organizations($context, $selected='', $referral=false, $show_invisible_ou=true, $master=false) |
---|
463 | { |
---|
464 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
465 | $sectors_info = $s->get_organizations($context, $selected, $referral, $show_invisible_ou, $master); |
---|
466 | return $sectors_info; |
---|
467 | } |
---|
468 | |
---|
469 | /* |
---|
470 | Funciona de maneira similar ao get_sectors_list, porém retorna a propria OU do contexto |
---|
471 | e monta o array de retorno de forma diferente, necessário para algumas mudanças implementadas |
---|
472 | no método admin.uisectors.list_sectors. |
---|
473 | */ |
---|
474 | function get_organizations2($contexts, $selected='', $referral=false, $show_invisible_ou=true) { |
---|
475 | |
---|
476 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
477 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
478 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
479 | |
---|
480 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
481 | |
---|
482 | if ($referral) |
---|
483 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); |
---|
484 | else |
---|
485 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
486 | |
---|
487 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
488 | |
---|
489 | $justthese = array("dn","diskQuota","usersQuota","actualDiskQuota"); |
---|
490 | $filter = "(ou=*)"; |
---|
491 | foreach ($contexts as $context) { |
---|
492 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
493 | |
---|
494 | ldap_sort($ldap_conn, $search, "ou"); |
---|
495 | $info = ldap_get_entries($ldap_conn, $search); |
---|
496 | ldap_close($ldap_conn); |
---|
497 | |
---|
498 | // Retiro o count do array info e inverto o array para ordenaçãoo. |
---|
499 | for ($i=0; $i<$info["count"]; ++$i) |
---|
500 | { |
---|
501 | $dn = $info[$i]["dn"]; |
---|
502 | |
---|
503 | // Necessário, pq em uma busca com ldapsearch ou=*, traz tb o próprio ou. |
---|
504 | //if (strtolower($dn) == $context) |
---|
505 | //continue; |
---|
506 | |
---|
507 | $array_dn = ldap_explode_dn ( $dn, 1 ); |
---|
508 | |
---|
509 | $array_dn_reverse = array_reverse ( $array_dn, true ); |
---|
510 | |
---|
511 | // Retirar o indice count do array. |
---|
512 | array_pop ( $array_dn_reverse ); |
---|
513 | |
---|
514 | $inverted_dn[implode ( "#", $array_dn_reverse )] = $info[$i]; |
---|
515 | } |
---|
516 | } |
---|
517 | // Ordenação por chave |
---|
518 | ksort($inverted_dn); |
---|
519 | |
---|
520 | // Construção do select |
---|
521 | $level = 0; |
---|
522 | $options = array(); |
---|
523 | foreach ($inverted_dn as $dn=>$info_ou) |
---|
524 | { |
---|
525 | $display = ''; |
---|
526 | $info_retorno = array(); |
---|
527 | $array_dn_reverse = explode ( "#", $dn ); |
---|
528 | $array_dn = array_reverse ( $array_dn_reverse, true ); |
---|
529 | |
---|
530 | $level = count( $array_dn ) - (int)(count(explode(",", $GLOBALS['phpgw_info']['server']['ldap_context'])) + 1); |
---|
531 | |
---|
532 | if ($level == 0) |
---|
533 | $display .= '+'; |
---|
534 | else |
---|
535 | { |
---|
536 | for ($i=0; $i<$level; ++$i) |
---|
537 | $display .= '---'; |
---|
538 | } |
---|
539 | |
---|
540 | reset ( $array_dn ); |
---|
541 | $display .= ' ' . urldecode( str_replace('\\', '%', current ( $array_dn ))); |
---|
542 | |
---|
543 | $info_retorno['display'] = $display; |
---|
544 | $info_retorno['dn'] = $info_ou['dn']; |
---|
545 | $info_retorno['diskquota'] = $info_ou['diskquota'][0]; |
---|
546 | $info_retorno['usersquota'] = $info_ou['usersquota'][0]; |
---|
547 | // $info_retorno['actualdiskquota'] = round($this->get_actual_disk_usage($info_ou['dn']),2);//$info_ou['actualdiskquota'][0]; |
---|
548 | // $info_retorno['actualnumusers'] = $this->get_num_users($info_ou['dn']); |
---|
549 | |
---|
550 | array_push($options,$info_retorno); |
---|
551 | |
---|
552 | } |
---|
553 | return $options; |
---|
554 | } |
---|
555 | |
---|
556 | function get_info($context, $referral = false) { |
---|
557 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
558 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
559 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
560 | |
---|
561 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
562 | |
---|
563 | if ($referral) |
---|
564 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); |
---|
565 | else |
---|
566 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
567 | |
---|
568 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
569 | |
---|
570 | $filter="(objectClass=organizationalUnit)"; |
---|
571 | $search=ldap_search($ldap_conn, $context, $filter); |
---|
572 | $result = ldap_get_entries($ldap_conn, $search); |
---|
573 | return $result; |
---|
574 | |
---|
575 | } |
---|
576 | |
---|
577 | function get_num_users($context,$selected='', $referral=false, $show_invisible_ou=true) { |
---|
578 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
579 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
580 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
581 | |
---|
582 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
583 | |
---|
584 | if ($referral) |
---|
585 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); |
---|
586 | else |
---|
587 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
588 | |
---|
589 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
590 | |
---|
591 | $justthese = array("dn"); |
---|
592 | $filter = "(objectClass=inetOrgPerson)"; |
---|
593 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
594 | |
---|
595 | $retorno = ldap_count_entries($ldap_conn, $search); |
---|
596 | ldap_close($ldap_conn); |
---|
597 | |
---|
598 | return $retorno; |
---|
599 | } |
---|
600 | |
---|
601 | //Checa se existe quota para mais um usuï¿œrio no setor... se existir retorna true, senï¿œo false. |
---|
602 | function existe_quota_usuario($setor) { |
---|
603 | $num_users = $this->get_num_users($setor['dn']); |
---|
604 | //return $num_users . " --- " . $setor['usersquota'][0] |
---|
605 | if(($num_users>=$setor['usersquota'][0]) && ($setor['usersquota'][0]!=-1)) { |
---|
606 | return false; |
---|
607 | } |
---|
608 | return true; |
---|
609 | } |
---|
610 | |
---|
611 | //Checa se existe quota em disco para mais um usuï¿œrio no setor... se existir retorna true, senï¿œo false. |
---|
612 | function existe_quota_disco($setor,$quota_novo_usuario) { |
---|
613 | settype($quota_novo_usuario,"float"); |
---|
614 | $quota_novo_usuario /= 1024; //A quota vï¿œm da interface em megabytes, deve se tornar gigabyte. |
---|
615 | |
---|
616 | $nova_quota = $this->get_actual_disk_usage($setor['dn']) + $quota_novo_usuario; |
---|
617 | if(( $nova_quota >= $setor['diskquota'][0] ) && ($setor['diskquota'][0] != -1)) { |
---|
618 | return false; |
---|
619 | } |
---|
620 | return true; |
---|
621 | } |
---|
622 | |
---|
623 | // Soma as quotas de todos os usuï¿œrios daquele contexto. |
---|
624 | function get_actual_disk_usage($context) { |
---|
625 | $quota_usada=0; |
---|
626 | $contexts = array($context); |
---|
627 | $usuarios = $this->get_list('accounts', '', $contexts); |
---|
628 | |
---|
629 | $imap_functions = new imap_functions(); |
---|
630 | foreach($usuarios as $usuario) { |
---|
631 | $temp = $imap_functions->get_user_info($usuario['account_lid']); |
---|
632 | if($temp['mailquota'] != -1) //Usuï¿œrio sem cota nï¿œo conta... |
---|
633 | $quota_usada += ($temp['mailquota'] / 1024); |
---|
634 | } |
---|
635 | return $quota_usada; |
---|
636 | } |
---|
637 | |
---|
638 | |
---|
639 | function get_sectors($selected='', $referral=false, $show_invisible_ou=true) |
---|
640 | { |
---|
641 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
642 | $sectors_info = $s->get_sectors($selected, $referral, $show_invisible_ou); |
---|
643 | return $sectors_info; |
---|
644 | } |
---|
645 | |
---|
646 | // Get list of all levels, this function is used for sectors module. |
---|
647 | function get_sectors_list($contexts) |
---|
648 | { |
---|
649 | $a_sectors = array(); |
---|
650 | |
---|
651 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
652 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
653 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
654 | |
---|
655 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
656 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
657 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
658 | |
---|
659 | $justthese = array("dn"); |
---|
660 | $filter = "(ou=*)"; |
---|
661 | |
---|
662 | $systemName = strtolower($GLOBALS['phpgw_info']['server']['system_name']); |
---|
663 | if ($systemName != '') |
---|
664 | $filter = "(&$filter(phpgwSystem=$systemName))"; |
---|
665 | |
---|
666 | foreach ($contexts as $context) |
---|
667 | { |
---|
668 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
669 | $info = ldap_get_entries($ldap_conn, $search); |
---|
670 | for ($i=0; $i<$info["count"]; ++$i) |
---|
671 | { |
---|
672 | $a_sectors[] = $info[$i]['dn']; |
---|
673 | } |
---|
674 | } |
---|
675 | |
---|
676 | ldap_close($ldap_conn); |
---|
677 | |
---|
678 | // Retiro o count do array info e inverto o array para ordenação. |
---|
679 | foreach ($a_sectors as $context) |
---|
680 | { |
---|
681 | |
---|
682 | |
---|
683 | $array_dn = ldap_explode_dn($context, 1 ); |
---|
684 | foreach($array_dn as $key=>$value){ |
---|
685 | $array_dn[$key]=preg_replace('/\\\([0-9A-Fa-f]{2})/e', "''.chr(hexdec('\\1')).''",$value); |
---|
686 | } |
---|
687 | |
---|
688 | $array_dn_reverse = array_reverse ( $array_dn, true ); |
---|
689 | |
---|
690 | // Retirar o indice count do array. |
---|
691 | array_pop ( $array_dn_reverse ); |
---|
692 | |
---|
693 | $inverted_dn[$context] = implode ( "#", $array_dn_reverse ); |
---|
694 | } |
---|
695 | |
---|
696 | // Ordenação |
---|
697 | natcasesort($inverted_dn); |
---|
698 | |
---|
699 | // Construção do select |
---|
700 | $level = 0; |
---|
701 | $options = array(); |
---|
702 | foreach ($inverted_dn as $dn=>$invert_ufn) |
---|
703 | { |
---|
704 | $display = ''; |
---|
705 | |
---|
706 | $array_dn_reverse = explode ( "#", $invert_ufn ); |
---|
707 | $array_dn = array_reverse ( $array_dn_reverse, true ); |
---|
708 | |
---|
709 | $level = count( $array_dn ) - (int)(count(explode(",", $GLOBALS['phpgw_info']['server']['ldap_context'])) + 1); |
---|
710 | |
---|
711 | if ($level == 0) |
---|
712 | $display .= '+'; |
---|
713 | else |
---|
714 | { |
---|
715 | for ($i=0; $i<$level; ++$i) |
---|
716 | $display .= '---'; |
---|
717 | } |
---|
718 | |
---|
719 | reset ( $array_dn ); |
---|
720 | $display .= ' ' . (current ( $array_dn )); |
---|
721 | |
---|
722 | $dn = trim(strtolower($dn)); |
---|
723 | $options[$dn] = $display; |
---|
724 | } |
---|
725 | return $options; |
---|
726 | } |
---|
727 | |
---|
728 | function exist_account_lid($account_lid) |
---|
729 | { |
---|
730 | $conection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
731 | $sri = ldap_search($conection, $GLOBALS['phpgw_info']['server']['ldap_context'], "uid=" . $account_lid); |
---|
732 | $result = ldap_get_entries($conection, $sri); |
---|
733 | return $result['count']; |
---|
734 | } |
---|
735 | |
---|
736 | function exist_email($mail) |
---|
737 | { |
---|
738 | $conection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
739 | $sri = ldap_search($conection, $GLOBALS['phpgw_info']['server']['ldap_context'], "mail=" . $mail); |
---|
740 | $result = ldap_get_entries($conection, $sri); |
---|
741 | ldap_close($conection); |
---|
742 | |
---|
743 | if ($result['count'] == 0) |
---|
744 | return false; |
---|
745 | else |
---|
746 | return true; |
---|
747 | } |
---|
748 | |
---|
749 | function array_invert($array) |
---|
750 | { |
---|
751 | $result[] = end($array); |
---|
752 | while ($item = prev($array)) |
---|
753 | $result[] = $item; |
---|
754 | return $result; |
---|
755 | } |
---|
756 | |
---|
757 | function get_next_id() |
---|
758 | { |
---|
759 | // Busco o ID dos accounts |
---|
760 | $query_accounts = "SELECT id FROM phpgw_nextid WHERE appname = 'accounts'"; |
---|
761 | $GLOBALS['phpgw']->db->query($query_accounts); |
---|
762 | while($GLOBALS['phpgw']->db->next_record()) |
---|
763 | { |
---|
764 | $result_accounts[] = $GLOBALS['phpgw']->db->row(); |
---|
765 | } |
---|
766 | $accounts_id = $result_accounts[0]['id']; |
---|
767 | |
---|
768 | // Busco o ID dos groups |
---|
769 | $query_groups = "SELECT id FROM phpgw_nextid WHERE appname = 'groups'"; |
---|
770 | $GLOBALS['phpgw']->db->query($query_groups); |
---|
771 | while($GLOBALS['phpgw']->db->next_record()) |
---|
772 | { |
---|
773 | $result_groups[] = $GLOBALS['phpgw']->db->row(); |
---|
774 | } |
---|
775 | $groups_id = $result_groups[0]['id']; |
---|
776 | |
---|
777 | //Retorna o maior dos ID's |
---|
778 | if ($accounts_id >= $groups_id) |
---|
779 | return $accounts_id; |
---|
780 | else |
---|
781 | return $groups_id; |
---|
782 | } |
---|
783 | |
---|
784 | function make_list_app($account_lid, $user_applications='', $disabled='') |
---|
785 | { |
---|
786 | // create list of ALL available apps |
---|
787 | $availableAppsGLOBALS = $GLOBALS['phpgw_info']['apps']; |
---|
788 | |
---|
789 | // create list of available apps for the user |
---|
790 | $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '".$account_lid."'"; |
---|
791 | $GLOBALS['phpgw']->db->query($query); |
---|
792 | while($GLOBALS['phpgw']->db->next_record()) |
---|
793 | { |
---|
794 | $availableApps[] = $GLOBALS['phpgw']->db->row(); |
---|
795 | } |
---|
796 | |
---|
797 | // Retira alguns modulos |
---|
798 | if (count($availableApps)) |
---|
799 | { |
---|
800 | foreach ($availableApps as $key => $value) |
---|
801 | { |
---|
802 | if ($value['app'] != 'phpgwapi') |
---|
803 | $tmp[] = $availableApps[$key]; |
---|
804 | } |
---|
805 | } |
---|
806 | $availableApps = $tmp; |
---|
807 | |
---|
808 | // Cria um array com as aplicacoes disponiveis para o manager, com as atributos das aplicacoes. |
---|
809 | $availableAppsUser = array(); |
---|
810 | if (count($availableApps)) |
---|
811 | { |
---|
812 | foreach($availableApps as $app => $title) |
---|
813 | { |
---|
814 | if ($availableAppsGLOBALS[$title['app']]) |
---|
815 | $availableAppsUser[$title['app']] = $availableAppsGLOBALS[$title['app']]; |
---|
816 | } |
---|
817 | } |
---|
818 | |
---|
819 | // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box. |
---|
820 | $applications_list = ''; |
---|
821 | $app_col1 = ''; |
---|
822 | $app_col2 = ''; |
---|
823 | $app_col3 = ''; |
---|
824 | $total_apps = count($availableAppsUser); |
---|
825 | $i = 0; |
---|
826 | foreach($availableAppsUser as $app => $data) |
---|
827 | { |
---|
828 | // 1 coluna |
---|
829 | if (($i +1) % 3 == 1) |
---|
830 | { |
---|
831 | $checked = is_array($user_applications) && $user_applications[$app] ? 'CHECKED' : ''; |
---|
832 | $app_col1 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='apps[%s]' value='1' %s %s></td>\n", |
---|
833 | $data['title'],$app,$checked, $disabled); |
---|
834 | if ($i == ($total_apps-1)) |
---|
835 | $applications_list .= sprintf('<tr bgcolor="%s">%s</tr>','#DDDDDD', $app_col1); |
---|
836 | } |
---|
837 | |
---|
838 | // 2 coluna |
---|
839 | if (($i +1) % 3 == 2) |
---|
840 | { |
---|
841 | $checked = is_array($user_applications) && $user_applications[$app] ? 'CHECKED' : ''; |
---|
842 | $app_col2 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='apps[%s]' value='1' %s %s></td>\n", |
---|
843 | $data['title'],$app,$checked, $disabled); |
---|
844 | |
---|
845 | if ($i == ($total_apps-1)) |
---|
846 | $applications_list .= sprintf('<tr bgcolor="%s">%s%s</tr>','#DDDDDD', $app_col1,$app_col2); |
---|
847 | } |
---|
848 | // 3 coluna |
---|
849 | if (($i +1) % 3 == 0) |
---|
850 | { |
---|
851 | $checked = is_array($user_applications) && $user_applications[$app] ? 'CHECKED' : ''; |
---|
852 | $app_col3 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='apps[%s]' value='1' %s %s></td>\n", |
---|
853 | $data['title'],$app,$checked, $disabled); |
---|
854 | |
---|
855 | // Cria nova linha |
---|
856 | $applications_list .= sprintf('<tr bgcolor="%s">%s%s%s</tr>','#DDDDDD', $app_col1, $app_col2, $app_col3); |
---|
857 | } |
---|
858 | ++$i; |
---|
859 | } |
---|
860 | return $applications_list; |
---|
861 | } |
---|
862 | |
---|
863 | function exist_attribute_in_ldap($dn, $attribute, $value) |
---|
864 | { |
---|
865 | $connection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
866 | $search = ldap_search($connection, $dn, $attribute. "=" . $value); |
---|
867 | $result = ldap_get_entries($connection, $search); |
---|
868 | ldap_close($connection); |
---|
869 | //_debug_array($result); |
---|
870 | if ($result['count'] == 0) |
---|
871 | return false; |
---|
872 | else |
---|
873 | return true; |
---|
874 | } |
---|
875 | |
---|
876 | function getReturnExecuteForm(){ |
---|
877 | $response = $_SESSION['response']; |
---|
878 | $_SESSION['response'] = null; |
---|
879 | return $response; |
---|
880 | } |
---|
881 | |
---|
882 | function lang($key) |
---|
883 | { |
---|
884 | if ($_SESSION['phpgw_info']['expressoAdmin']['lang'][$key]) |
---|
885 | return $_SESSION['phpgw_info']['expressoAdmin']['lang'][$key]; |
---|
886 | else |
---|
887 | return $key . '*'; |
---|
888 | } |
---|
889 | |
---|
890 | |
---|
891 | function checkCPF($cpf) |
---|
892 | { |
---|
893 | $nulos = array("12345678909","11111111111","22222222222","33333333333", |
---|
894 | "44444444444","55555555555","66666666666","77777777777", |
---|
895 | "88888888888","99999999999","00000000000"); |
---|
896 | |
---|
897 | /* formato do CPF */ |
---|
898 | if (!(preg_match('/^[0-9]{3}[.][0-9]{3}[.][0-9]{3}[-][0-9]{2}$/',$cpf))) |
---|
899 | return false; |
---|
900 | |
---|
901 | /* Retira todos os caracteres que nao sejam 0-9 */ |
---|
902 | $cpf = preg_replace('/[^0-9]/', '', $cpf); |
---|
903 | |
---|
904 | /*Retorna falso se houver letras no cpf */ |
---|
905 | if (!(preg_match('/[0-9]/',$cpf))) |
---|
906 | return false; |
---|
907 | |
---|
908 | /* Retorna falso se o cpf for nulo */ |
---|
909 | if( in_array($cpf, $nulos) ) |
---|
910 | return false; |
---|
911 | |
---|
912 | /*Calcula o penúltimo dígito verificador*/ |
---|
913 | $acum=0; |
---|
914 | for($i=0; $i<9; ++$i) |
---|
915 | { |
---|
916 | $acum+= $cpf[$i]*(10-$i); |
---|
917 | } |
---|
918 | |
---|
919 | $x=$acum % 11; |
---|
920 | $acum = ($x>1) ? (11 - $x) : 0; |
---|
921 | /* Retorna falso se o digito calculado eh diferente do passado na string */ |
---|
922 | if ($acum != $cpf[9]){ |
---|
923 | return false; |
---|
924 | } |
---|
925 | /*Calcula o último dígito verificador*/ |
---|
926 | $acum=0; |
---|
927 | for ($i=0; $i<10; ++$i) |
---|
928 | { |
---|
929 | $acum+= $cpf[$i]*(11-$i); |
---|
930 | } |
---|
931 | |
---|
932 | $x=$acum % 11; |
---|
933 | $acum = ($x > 1) ? (11-$x) : 0; |
---|
934 | /* Retorna falso se o digito calculado eh diferente do passado na string */ |
---|
935 | if ( $acum != $cpf[10]) |
---|
936 | { |
---|
937 | return false; |
---|
938 | } |
---|
939 | /* Retorna verdadeiro se o cpf eh valido */ |
---|
940 | return true; |
---|
941 | } |
---|
942 | |
---|
943 | function make_lang($ram_lang) |
---|
944 | { |
---|
945 | $a_lang = preg_split('/_/', $ram_lang); |
---|
946 | $a_lang_reverse = array_reverse ( $a_lang, true ); |
---|
947 | array_pop ( $a_lang_reverse ); |
---|
948 | $a_lang = array_reverse ( $a_lang_reverse, true ); |
---|
949 | $a_new_lang = implode ( " ", $a_lang ); |
---|
950 | return lang($a_new_lang); |
---|
951 | } |
---|
952 | |
---|
953 | function make_dinamic_lang($template_obj, $block) |
---|
954 | { |
---|
955 | $tpl_vars = $template_obj->get_undefined($block); |
---|
956 | $array_langs = array(); |
---|
957 | |
---|
958 | foreach ($tpl_vars as $atribute) |
---|
959 | { |
---|
960 | $lang = strstr($atribute, 'lang_'); |
---|
961 | if($lang !== false) |
---|
962 | { |
---|
963 | //$template_obj->set_var($atribute, $this->make_lang($atribute)); |
---|
964 | $array_langs[$atribute] = $this->make_lang($atribute); |
---|
965 | } |
---|
966 | } |
---|
967 | return $array_langs; |
---|
968 | } |
---|
969 | |
---|
970 | |
---|
971 | |
---|
972 | function normalize_calendar_acl($acl) |
---|
973 | { |
---|
974 | $return = ''; |
---|
975 | |
---|
976 | if($this->safeBitCheck(1, $acl)) |
---|
977 | $return .= '1-'; |
---|
978 | if($this->safeBitCheck(2, $acl)) |
---|
979 | $return .= '2-'; |
---|
980 | if($this->safeBitCheck(4, $acl)) |
---|
981 | $return .= '4-'; |
---|
982 | if($this->safeBitCheck(8, $acl)) |
---|
983 | $return .= '8-'; |
---|
984 | if($this->safeBitCheck(16, $acl)) |
---|
985 | $return .= '16-'; |
---|
986 | |
---|
987 | return $return; |
---|
988 | } |
---|
989 | } |
---|
990 | |
---|
991 | class sectors_object |
---|
992 | { |
---|
993 | var $sector_name; |
---|
994 | var $sector_context; |
---|
995 | var $sector_level; |
---|
996 | var $sector_leaf; |
---|
997 | var $sectors_list = array(); |
---|
998 | var $level; |
---|
999 | |
---|
1000 | function sectors_object($sector_name, $sector_context, $sector_level, $sector_leaf) |
---|
1001 | { |
---|
1002 | $this->sector_name = $sector_name; |
---|
1003 | $this->sector_context = $sector_context; |
---|
1004 | $this->sector_level = $sector_level; |
---|
1005 | $this->sector_leaf = $sector_leaf; |
---|
1006 | } |
---|
1007 | } |
---|