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