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 | |
---|
14 | class functions |
---|
15 | { |
---|
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 | |
---|
30 | function functions() |
---|
31 | { |
---|
32 | //$this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
33 | $this->db_functions = new db_functions; |
---|
34 | } |
---|
35 | |
---|
36 | // Account and type of access. Return: Have access ? (true/false) |
---|
37 | function check_acl($account_lid, $access) |
---|
38 | { |
---|
39 | $acl = $this->read_acl($account_lid); |
---|
40 | $array_acl = $this->make_array_acl($acl[0][acl]); |
---|
41 | |
---|
42 | //What access ?? In the IF, verify if have access. |
---|
43 | switch($access) |
---|
44 | { |
---|
45 | case list_users: |
---|
46 | if ($array_acl[add_users] || $array_acl[edit_users] || $array_acl[delete_users] || $array_acl[change_users_password] || $array_acl[change_users_quote] || $array_acl[edit_sambausers_attributes]) |
---|
47 | return true; |
---|
48 | break; |
---|
49 | case add_users: |
---|
50 | if ($array_acl[add_users]) |
---|
51 | return true; |
---|
52 | break; |
---|
53 | case edit_users: |
---|
54 | if ($array_acl[edit_users]) |
---|
55 | return true; |
---|
56 | break; |
---|
57 | case delete_users: |
---|
58 | if ($array_acl[delete_users]) |
---|
59 | return true; |
---|
60 | break; |
---|
61 | case rename_users: |
---|
62 | if ($array_acl[rename_users]) |
---|
63 | return true; |
---|
64 | break; |
---|
65 | case change_users_password: |
---|
66 | if ($array_acl[change_users_password]) |
---|
67 | return true; |
---|
68 | break; |
---|
69 | case change_users_quote: |
---|
70 | if ($array_acl[change_users_quote]) |
---|
71 | return true; |
---|
72 | break; |
---|
73 | case set_user_default_password: |
---|
74 | if ($array_acl[set_user_default_password]) |
---|
75 | return true; |
---|
76 | break; |
---|
77 | case edit_sambausers_attributes: |
---|
78 | if ($array_acl[edit_sambausers_attributes]) |
---|
79 | return true; |
---|
80 | break; |
---|
81 | |
---|
82 | case list_groups: |
---|
83 | if ($array_acl[add_groups] || $array_acl[edit_groups] || $array_acl[delete_groups]) |
---|
84 | return true; |
---|
85 | break; |
---|
86 | case add_groups: |
---|
87 | if ($array_acl[add_groups]) |
---|
88 | return true; |
---|
89 | break; |
---|
90 | case edit_groups: |
---|
91 | if ($array_acl[edit_groups]) |
---|
92 | return true; |
---|
93 | break; |
---|
94 | case delete_groups: |
---|
95 | if ($array_acl[delete_groups]) |
---|
96 | return true; |
---|
97 | break; |
---|
98 | |
---|
99 | case list_maillists: |
---|
100 | if ($array_acl[add_maillists] || $array_acl[edit_maillists] || $array_acl[delete_maillists]) |
---|
101 | return true; |
---|
102 | break; |
---|
103 | case add_maillists: |
---|
104 | if ($array_acl[add_maillists]) |
---|
105 | return true; |
---|
106 | break; |
---|
107 | case edit_maillists: |
---|
108 | if ($array_acl[edit_maillists]) |
---|
109 | return true; |
---|
110 | break; |
---|
111 | case delete_maillists: |
---|
112 | if ($array_acl[delete_maillists]) |
---|
113 | return true; |
---|
114 | break; |
---|
115 | |
---|
116 | case list_sectors: |
---|
117 | if ($array_acl[create_sectors] || $array_acl[edit_sectors] || $array_acl[delete_sectors]) |
---|
118 | return true; |
---|
119 | break; |
---|
120 | case create_sectors: |
---|
121 | if ($array_acl[create_sectors]) |
---|
122 | return true; |
---|
123 | break; |
---|
124 | case edit_sectors: |
---|
125 | if ($array_acl[edit_sectors]) |
---|
126 | return true; |
---|
127 | break; |
---|
128 | case delete_sectors: |
---|
129 | if ($array_acl[delete_sectors]) |
---|
130 | return true; |
---|
131 | break; |
---|
132 | |
---|
133 | case manage_wf_sectors: |
---|
134 | if ($array_acl[manage_wf_sectors]) |
---|
135 | return true; |
---|
136 | break; |
---|
137 | |
---|
138 | case view_global_sessions: |
---|
139 | if ($array_acl[view_global_sessions]) |
---|
140 | return true; |
---|
141 | break; |
---|
142 | |
---|
143 | case list_computers: |
---|
144 | if ($array_acl[create_computers] || $array_acl[edit_computers] || $array_acl[delete_computers]) |
---|
145 | return true; |
---|
146 | break; |
---|
147 | case create_computers: |
---|
148 | if ($array_acl[create_computers]) |
---|
149 | return true; |
---|
150 | break; |
---|
151 | case edit_computers: |
---|
152 | if ($array_acl[edit_computers]) |
---|
153 | return true; |
---|
154 | break; |
---|
155 | case delete_computers: |
---|
156 | if ($array_acl[delete_computers]) |
---|
157 | return true; |
---|
158 | break; |
---|
159 | |
---|
160 | case view_logs: |
---|
161 | if ($array_acl[view_logs]) |
---|
162 | return true; |
---|
163 | break; |
---|
164 | |
---|
165 | default: |
---|
166 | return false; |
---|
167 | } |
---|
168 | |
---|
169 | return false; |
---|
170 | } |
---|
171 | |
---|
172 | // Read acl from db |
---|
173 | function read_acl($account_lid) |
---|
174 | { |
---|
175 | /* |
---|
176 | $query = "SELECT * FROM phpgw_expressoadmin WHERE manager_lid = '" . $account_lid . "'"; |
---|
177 | $GLOBALS['phpgw']->db->query($query); |
---|
178 | while($GLOBALS['phpgw']->db->next_record()) |
---|
179 | { |
---|
180 | $result[] = $GLOBALS['phpgw']->db->row(); |
---|
181 | } |
---|
182 | */ |
---|
183 | $result = $this->db_functions->read_acl($account_lid); |
---|
184 | $context_array = ldap_explode_dn($result[0]['context'], 1); |
---|
185 | $tmp = array_shift($context_array); |
---|
186 | $result[0]['context_display'] = implode(".", $context_array); |
---|
187 | return $result; |
---|
188 | } |
---|
189 | |
---|
190 | // Make a array read humam |
---|
191 | function make_array_acl($acl) |
---|
192 | { |
---|
193 | $array_acl['add_users'] = $acl & 1; |
---|
194 | $array_acl['edit_users'] = $acl & 2; |
---|
195 | $array_acl['delete_users'] = $acl & 4; |
---|
196 | $array_acl['rename_users'] = $acl & 8388608; |
---|
197 | $array_acl['add_groups'] = $acl & 16; |
---|
198 | $array_acl['edit_groups'] = $acl & 32; |
---|
199 | $array_acl['delete_groups'] = $acl & 64; |
---|
200 | $array_acl['change_users_password'] = $acl & 128; |
---|
201 | $array_acl['change_users_quote'] = $acl & 262144; |
---|
202 | $array_acl['set_user_default_password'] = $acl & 524288; |
---|
203 | $array_acl['edit_sambausers_attributes'] = $acl & 32768; |
---|
204 | $array_acl['add_maillists'] = $acl & 256; |
---|
205 | $array_acl['edit_maillists'] = $acl & 512; |
---|
206 | $array_acl['delete_maillists'] = $acl & 1024; |
---|
207 | $array_acl['create_sectors'] = $acl & 4096; |
---|
208 | $array_acl['edit_sectors'] = $acl & 8192; |
---|
209 | $array_acl['delete_sectors'] = $acl & 16384; |
---|
210 | $array_acl['view_global_sessions'] = $acl & 65536; |
---|
211 | $array_acl['view_logs'] = $acl & 131072; |
---|
212 | $array_acl['create_computers'] = $acl & 1048576; |
---|
213 | $array_acl['edit_computers'] = $acl & 2097152; |
---|
214 | $array_acl['delete_computers'] = $acl & 4194304; |
---|
215 | return $array_acl; |
---|
216 | } |
---|
217 | |
---|
218 | function get_list($type, $query, $context) |
---|
219 | { |
---|
220 | $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
221 | $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
222 | $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); |
---|
223 | ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
224 | ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); |
---|
225 | ldap_bind($ldap_conn,$dn,$passwd); |
---|
226 | |
---|
227 | if ($type == 'accounts') |
---|
228 | { |
---|
229 | |
---|
230 | $justthese = array("uidnumber", "uid", "cn", "mail"); |
---|
231 | $filter="(&(phpgwAccountType=u)(|(uid=*".$query."*)(sn=*".$query."*)(cn=*".$query."*)(givenName=*".$query."*)(mail=$query*)))"; |
---|
232 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
233 | ldap_sort($ldap_conn, $search, "uid"); |
---|
234 | $info = ldap_get_entries($ldap_conn, $search); |
---|
235 | ldap_close($ldap_conn); |
---|
236 | |
---|
237 | $i = 0; |
---|
238 | $tmp = array(); |
---|
239 | for ($i=0; $i < $info['count']; $i++) |
---|
240 | { |
---|
241 | $tmp[$i][account_id] = $info[$i]['uidnumber'][0]; |
---|
242 | $tmp[$i][account_lid] = $info[$i]['uid'][0]; |
---|
243 | $tmp[$i][account_cn] = $info[$i]['cn'][0]; |
---|
244 | $tmp[$i][account_mail] = $info[$i]['mail'][0]; |
---|
245 | } |
---|
246 | return $tmp; |
---|
247 | } |
---|
248 | elseif($type == 'groups') |
---|
249 | { |
---|
250 | $filter="(&(phpgwAccountType=g)(cn=*".$query."*))"; |
---|
251 | $justthese = array("gidnumber", "cn", "description"); |
---|
252 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
253 | ldap_sort($ldap_conn, $search, "cn"); |
---|
254 | $info = ldap_get_entries($ldap_conn, $search); |
---|
255 | ldap_close($ldap_conn); |
---|
256 | |
---|
257 | $i = 0; |
---|
258 | $tmp = array(); |
---|
259 | for ($i=0; $i < $info['count']; $i++) |
---|
260 | { |
---|
261 | $tmp[$i][cn] = $info[$i][cn][0]; |
---|
262 | $tmp[$i][description] = $info[$i][description][0]; |
---|
263 | $tmp[$i][gidnumber] = $info[$i][gidnumber][0]; |
---|
264 | } |
---|
265 | return $tmp; |
---|
266 | } |
---|
267 | elseif($type == 'maillists') |
---|
268 | { |
---|
269 | $filter="(&(phpgwAccountType=l)(|(cn=*".$query."*)(uid=*".$query."*)(mail=*".$query."*)))"; |
---|
270 | $justthese = array("uidnumber", "cn", "uid", "mail"); |
---|
271 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
272 | ldap_sort($ldap_conn, $search, "uid"); |
---|
273 | $info = ldap_get_entries($ldap_conn, $search); |
---|
274 | ldap_close($ldap_conn); |
---|
275 | |
---|
276 | $i = 0; |
---|
277 | $tmp = array(); |
---|
278 | for ($i=0; $i < $info['count']; $i++) |
---|
279 | { |
---|
280 | $tmp[$i]['uid'] = $info[$i]['uid'][0]; |
---|
281 | $tmp[$i]['name'] = $info[$i]['cn'][0]; |
---|
282 | $tmp[$i]['uidnumber'] = $info[$i]['uidnumber'][0]; |
---|
283 | $tmp[$i]['email'] = $info[$i]['mail'][0]; |
---|
284 | } |
---|
285 | return $tmp; |
---|
286 | } |
---|
287 | elseif($type == 'computers') |
---|
288 | { |
---|
289 | $filter="(&(objectClass=sambaSAMAccount)(|(sambaAcctFlags=[W ])(sambaAcctFlags=[DW ])(sambaAcctFlags=[I ])(sambaAcctFlags=[S ]))(cn=*".$query."*))"; |
---|
290 | $justthese = array("cn","uidNumber","description"); |
---|
291 | $search=ldap_search($ldap_conn, $context, $filter, $justthese); |
---|
292 | ldap_sort($ldap_conn, $search, "cn"); |
---|
293 | $info = ldap_get_entries($ldap_conn, $search); |
---|
294 | ldap_close($ldap_conn); |
---|
295 | $tmp = array(); |
---|
296 | for ($i=0; $i < $info['count']; $i++) |
---|
297 | { |
---|
298 | $tmp[$i]['cn'] = $info[$i]['cn'][0]; |
---|
299 | $tmp[$i]['uidNumber'] = $info[$i]['uidnumber'][0]; |
---|
300 | $tmp[$i]['description'] = utf8_decode($info[$i]['description'][0]); |
---|
301 | } |
---|
302 | return $tmp; |
---|
303 | } |
---|
304 | } |
---|
305 | |
---|
306 | function get_organizations($context, $selected='') |
---|
307 | { |
---|
308 | //echo $selected; |
---|
309 | |
---|
310 | $first_sector_ufn = ldap_dn2ufn($context); |
---|
311 | $first_sector_string = split(",", $first_sector_ufn); |
---|
312 | |
---|
313 | $s = CreateObject('phpgwapi.sector_search_ldap'); |
---|
314 | $sectors_info = $s->sector_search($context); |
---|
315 | |
---|
316 | $sector_select = ""; |
---|
317 | $sector_select .= "<option value='" .$context . "'"; |
---|
318 | $sector_select .= ">".strtoupper($first_sector_string[0])."</option>\n"; |
---|
319 | |
---|
320 | foreach($sectors_info as $sector) |
---|
321 | { |
---|
322 | if ($sector->sector_level == 1) |
---|
323 | { |
---|
324 | $sector->sector_name = '+ '.$sector->sector_name; |
---|
325 | } |
---|
326 | else |
---|
327 | { |
---|
328 | $sector_space = ''; |
---|
329 | for ($i=1; $i < $sector->sector_level; $i++) |
---|
330 | $sector_space = '---'.$sector_space; |
---|
331 | $sector->sector_name = $sector_space.' '.$sector->sector_name; |
---|
332 | } |
---|
333 | $sector_select .= '<option value="' . strtolower($sector->sector_context) . '"'; |
---|
334 | |
---|
335 | if (trim(strtolower($sector->sector_context)) == $selected) |
---|
336 | $sector_select .= ' selected>' . $sector->sector_name . "</option>\n"; |
---|
337 | else |
---|
338 | $sector_select .= '>' . $sector->sector_name . "</option>\n"; |
---|
339 | } |
---|
340 | //$sector_select .= "</select>"; |
---|
341 | return $sector_select; |
---|
342 | } |
---|
343 | |
---|
344 | function get_sectors($context, $selected='') |
---|
345 | { |
---|
346 | $query = "SELECT sector FROM phpgw_expressoadmin_sectors WHERE organization = '" . $context . "'"; |
---|
347 | $GLOBALS['phpgw']->db->query($query); |
---|
348 | while($GLOBALS['phpgw']->db->next_record()) |
---|
349 | { |
---|
350 | $query_result[] = $GLOBALS['phpgw']->db->row(); |
---|
351 | } |
---|
352 | |
---|
353 | if (count($query_result) > 0) |
---|
354 | { |
---|
355 | foreach ($query_result as $index=>$tmp) |
---|
356 | { |
---|
357 | $sector = $tmp['sector']; |
---|
358 | if ($sector == $selected) |
---|
359 | $sector_options .= "<option value='$sector' selected>$sector</option>"; |
---|
360 | else |
---|
361 | $sector_options .= "<option value='$sector'>$sector</option>"; |
---|
362 | } |
---|
363 | return $sector_options; |
---|
364 | } |
---|
365 | else |
---|
366 | return false; |
---|
367 | } |
---|
368 | |
---|
369 | // Get list of all levels, this function is used for sectors module. |
---|
370 | function get_sectors_list($context) |
---|
371 | { |
---|
372 | $connection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
373 | ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
374 | ldap_set_option($connection, LDAP_OPT_REFERRALS, 0); |
---|
375 | |
---|
376 | if ($connection) |
---|
377 | { |
---|
378 | $bind=ldap_bind($connection); |
---|
379 | $filter="ou=*"; |
---|
380 | $justthese = array("ou"); |
---|
381 | $search=ldap_list($connection, $context, $filter, $justthese); |
---|
382 | ldap_sort($connection ,$search, "ou"); |
---|
383 | $info = ldap_get_entries($connection, $search); |
---|
384 | for ($i=0; $i<$info["count"]; $i++) |
---|
385 | { |
---|
386 | $this->level++; |
---|
387 | $next_context[$i] = 'ou='.$info[$i]["ou"][0].','.$context; |
---|
388 | $obj = new sectors_object($info[$i]["ou"][0], $next_context[$i], $this->level, 'False'); |
---|
389 | array_push($this->sectors_list, $obj); |
---|
390 | $this->get_sectors_list($next_context[$i]); |
---|
391 | } |
---|
392 | } |
---|
393 | ldap_close($connection); |
---|
394 | $this->level--; |
---|
395 | return $this->sectors_list; |
---|
396 | } |
---|
397 | |
---|
398 | function exist_account_lid($account_lid) |
---|
399 | { |
---|
400 | $conection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
401 | $sri = ldap_search($conection, $GLOBALS['phpgw_info']['server']['ldap_context'], "uid=" . $account_lid); |
---|
402 | $result = ldap_get_entries($conection, $sri); |
---|
403 | return $result['count']; |
---|
404 | } |
---|
405 | |
---|
406 | function exist_email($mail) |
---|
407 | { |
---|
408 | $conection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
409 | $sri = ldap_search($conection, $GLOBALS['phpgw_info']['server']['ldap_context'], "mail=" . $mail); |
---|
410 | $result = ldap_get_entries($conection, $sri); |
---|
411 | ldap_close($conection); |
---|
412 | |
---|
413 | if ($result['count'] == 0) |
---|
414 | return false; |
---|
415 | else |
---|
416 | return true; |
---|
417 | } |
---|
418 | |
---|
419 | function array_invert($array) |
---|
420 | { |
---|
421 | $result[] = end($array); |
---|
422 | while ($item = prev($array)) |
---|
423 | $result[] = $item; |
---|
424 | return $result; |
---|
425 | } |
---|
426 | |
---|
427 | function get_next_id() |
---|
428 | { |
---|
429 | // Busco o ID dos accounts |
---|
430 | $query_accounts = "SELECT id FROM phpgw_nextid WHERE appname = 'accounts'"; |
---|
431 | $GLOBALS['phpgw']->db->query($query_accounts); |
---|
432 | while($GLOBALS['phpgw']->db->next_record()) |
---|
433 | { |
---|
434 | $result_accounts[] = $GLOBALS['phpgw']->db->row(); |
---|
435 | } |
---|
436 | $accounts_id = $result_accounts[0]['id']; |
---|
437 | |
---|
438 | // Busco o ID dos groups |
---|
439 | $query_groups = "SELECT id FROM phpgw_nextid WHERE appname = 'groups'"; |
---|
440 | $GLOBALS['phpgw']->db->query($query_groups); |
---|
441 | while($GLOBALS['phpgw']->db->next_record()) |
---|
442 | { |
---|
443 | $result_groups[] = $GLOBALS['phpgw']->db->row(); |
---|
444 | } |
---|
445 | $groups_id = $result_groups[0]['id']; |
---|
446 | |
---|
447 | //Retorna o maior dos ID's |
---|
448 | if ($accounts_id >= $groups_id) |
---|
449 | return $accounts_id; |
---|
450 | else |
---|
451 | return $groups_id; |
---|
452 | } |
---|
453 | |
---|
454 | function increment_id($id, $type) |
---|
455 | { |
---|
456 | $sql = "UPDATE phpgw_nextid set id = '".$id."' WHERE appname = '" . $type . "'"; |
---|
457 | $GLOBALS['phpgw']->db->query($sql); |
---|
458 | } |
---|
459 | |
---|
460 | function make_list_app($account_lid, $context, $user_applications, $disabled='') |
---|
461 | { |
---|
462 | // create list of ALL available apps |
---|
463 | $availableAppsGLOBALS = $GLOBALS['phpgw_info']['apps']; |
---|
464 | |
---|
465 | // create list of available apps for the user |
---|
466 | $query = "SELECT * FROM phpgw_expressoadmin_apps WHERE manager_lid = '".$account_lid."' AND context = '".$context."'"; |
---|
467 | $GLOBALS['phpgw']->db->query($query); |
---|
468 | while($GLOBALS['phpgw']->db->next_record()) |
---|
469 | { |
---|
470 | $availableApps[] = $GLOBALS['phpgw']->db->row(); |
---|
471 | } |
---|
472 | |
---|
473 | // Retira alguns modulos |
---|
474 | if (count($availableApps)) |
---|
475 | { |
---|
476 | foreach ($availableApps as $key => $value) |
---|
477 | { |
---|
478 | if ($value['app'] != 'phpgwapi') |
---|
479 | $tmp[] = $availableApps[$key]; |
---|
480 | } |
---|
481 | } |
---|
482 | $availableApps = $tmp; |
---|
483 | |
---|
484 | // Cria um array com as aplicacoes disponiveis para o manager, com as atributos das aplicacoes. |
---|
485 | $availableAppsUser = array(); |
---|
486 | if (count($availableApps)) |
---|
487 | { |
---|
488 | foreach($availableApps as $app => $title) |
---|
489 | { |
---|
490 | if ($availableAppsGLOBALS[$title['app']]) |
---|
491 | $availableAppsUser[$title['app']] = $availableAppsGLOBALS[$title['app']]; |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | // Loop para criar dinamicamente uma tabela com 3 colunas, cada coluna com um aplicativo e um check box. |
---|
496 | $applications_list = ''; |
---|
497 | $app_col1 = ''; |
---|
498 | $app_col2 = ''; |
---|
499 | $app_col3 = ''; |
---|
500 | $total_apps = count($availableAppsUser); |
---|
501 | $i = 0; |
---|
502 | foreach($availableAppsUser as $app => $data) |
---|
503 | { |
---|
504 | // 1 coluna |
---|
505 | if (($i +1) % 3 == 1) |
---|
506 | { |
---|
507 | $checked = $user_applications[$app] ? 'CHECKED' : ''; |
---|
508 | $app_col1 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='apps[%s]' value='1' %s %s></td>\n", |
---|
509 | $data['title'],$app,$checked, $disabled); |
---|
510 | if ($i == ($total_apps-1)) |
---|
511 | $applications_list .= sprintf('<tr bgcolor="%s">%s</tr>','#DDDDDD', $app_col1); |
---|
512 | } |
---|
513 | |
---|
514 | // 2 coluna |
---|
515 | if (($i +1) % 3 == 2) |
---|
516 | { |
---|
517 | $checked = $user_applications[$app] ? 'CHECKED' : ''; |
---|
518 | $app_col2 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='apps[%s]' value='1' %s %s></td>\n", |
---|
519 | $data['title'],$app,$checked, $disabled); |
---|
520 | |
---|
521 | if ($i == ($total_apps-1)) |
---|
522 | $applications_list .= sprintf('<tr bgcolor="%s">%s%s</tr>','#DDDDDD', $app_col1,$app_col2); |
---|
523 | } |
---|
524 | // 3 coluna |
---|
525 | if (($i +1) % 3 == 0) |
---|
526 | { |
---|
527 | $checked = $user_applications[$app] ? 'CHECKED' : ''; |
---|
528 | $app_col3 = sprintf("<td>%s</td><td width='10'><input type='checkbox' name='apps[%s]' value='1' %s %s></td>\n", |
---|
529 | $data['title'],$app,$checked, $disabled); |
---|
530 | |
---|
531 | // Cria nova linha |
---|
532 | $applications_list .= sprintf('<tr bgcolor="%s">%s%s%s</tr>','#DDDDDD', $app_col1, $app_col2, $app_col3); |
---|
533 | } |
---|
534 | $i++; |
---|
535 | } |
---|
536 | return $applications_list; |
---|
537 | } |
---|
538 | |
---|
539 | function exist_attribute_in_ldap($dn, $attribute, $value) |
---|
540 | { |
---|
541 | $connection = $GLOBALS['phpgw']->common->ldapConnect(); |
---|
542 | $search = ldap_search($connection, $dn, $attribute. "=" . $value); |
---|
543 | $result = ldap_get_entries($connection, $search); |
---|
544 | ldap_close($connection); |
---|
545 | //_debug_array($result); |
---|
546 | if ($result['count'] == 0) |
---|
547 | return false; |
---|
548 | else |
---|
549 | return true; |
---|
550 | } |
---|
551 | |
---|
552 | function getReturnExecuteForm(){ |
---|
553 | $response = $_SESSION['response']; |
---|
554 | $_SESSION['response'] = null; |
---|
555 | return $response; |
---|
556 | } |
---|
557 | |
---|
558 | function write_log2($action, $groupinfo='', $userinfo='', $appinfo='', $msg_log='') |
---|
559 | { |
---|
560 | $sql = "INSERT INTO phpgw_expressoadmin_log (date, manager, action, groupinfo, userinfo, appinfo, msg) " |
---|
561 | . "VALUES('now','" . $_SESSION['phpgw_info']['expresso']['user']['account_lid'] . "','" . strtolower($action) . "','" . strtolower($groupinfo) . "','" . strtolower($userinfo) . "','" . strtolower($appinfo) . "','" .strtolower($msg_log) . "')"; |
---|
562 | $GLOBALS['phpgw']->db->query($sql); |
---|
563 | return; |
---|
564 | } |
---|
565 | |
---|
566 | } |
---|
567 | |
---|
568 | class sectors_object |
---|
569 | { |
---|
570 | var $sector_name; |
---|
571 | var $sector_context; |
---|
572 | var $sector_level; |
---|
573 | var $sector_leaf; |
---|
574 | var $sectors_list = array(); |
---|
575 | var $level; |
---|
576 | |
---|
577 | function sectors_object($sector_name, $sector_context, $sector_level, $sector_leaf) |
---|
578 | { |
---|
579 | $this->sector_name = $sector_name; |
---|
580 | $this->sector_context = $sector_context; |
---|
581 | $this->sector_level = $sector_level; |
---|
582 | $this->sector_leaf = $sector_leaf; |
---|
583 | } |
---|
584 | } |
---|