1 | <?php |
---|
2 | |
---|
3 | /**************************************************************************\ |
---|
4 | * Expresso Livre - Grant Group Access - administration * |
---|
5 | * * |
---|
6 | * -------------------------------------------- * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \**************************************************************************/ |
---|
12 | |
---|
13 | class bogroup_access |
---|
14 | { |
---|
15 | final function __construct(){ |
---|
16 | |
---|
17 | } |
---|
18 | |
---|
19 | public final function search_user($params){ |
---|
20 | $objLdap = CreateObject('expressoMail1_2.ldap_functions'); |
---|
21 | $objLdap -> ldapRootConnect(); |
---|
22 | $ldap = $objLdap -> ds; |
---|
23 | $search = $params['search']; |
---|
24 | $accounttype = $params['type']; |
---|
25 | $justthese = array("cn","uid", "uidNumber","gidNumber"); |
---|
26 | $users_list=ldap_search($ldap, $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'], "(&(phpgwAccountType=$accounttype) (|(cn=*$search*)(mail=$search*)) )", $justthese); |
---|
27 | if (ldap_count_entries($ldap, $users_list) == 0) |
---|
28 | { |
---|
29 | $return['status'] = 'false'; |
---|
30 | $return['msg'] = 'Nenhum resultado encontrado.'; |
---|
31 | return $return; |
---|
32 | } |
---|
33 | ldap_sort($ldap, $users_list, "cn"); |
---|
34 | $entries = ldap_get_entries($ldap, $users_list); |
---|
35 | $options = ''; |
---|
36 | for ($i=0; $i<$entries['count']; $i++) |
---|
37 | { |
---|
38 | $value = $entries[$i][$accounttype == "u" ? 'uidnumber' : 'gidnumber'][0]; |
---|
39 | if($entries[$i]['mail'][0]) |
---|
40 | $mail = "(".$entries[$i]['mail'][0].")"; |
---|
41 | $options .= "<option value=" . $value. ">" . $entries[$i]['cn'][0] . " $mail" . "</option>"; |
---|
42 | } |
---|
43 | return $options; |
---|
44 | } |
---|
45 | |
---|
46 | public function get_grants($app){ |
---|
47 | $db2 = $GLOBALS['phpgw']->db; |
---|
48 | $db2->select('phpgw_acl',array('acl_location','acl_account','acl_rights'),"acl_appname='".$app."' AND acl_location <> 'run'",__LINE__,__FILE__); |
---|
49 | |
---|
50 | $grants = array(); |
---|
51 | while ($db2->next_record()) { |
---|
52 | $objectID = $db2->f('acl_account'); |
---|
53 | $type = $GLOBALS['phpgw']->accounts->get_type($objectID); |
---|
54 | if($type == 'g') { |
---|
55 | $userID = $db2->f('acl_location'); |
---|
56 | $rights = $db2->f('acl_rights'); |
---|
57 | $grants[$userID.";".$objectID] = array( "userID"=> $userID,"groupID"=> $objectID, "rights" => $rights); |
---|
58 | } |
---|
59 | } |
---|
60 | unset($db2); |
---|
61 | return $grants; |
---|
62 | } |
---|
63 | |
---|
64 | public final function add_user($params) { |
---|
65 | |
---|
66 | list($user,$group,$rights) = explode(";",$params['id']); |
---|
67 | $objDB = CreateObject('expressoMail1_2.db_functions'); |
---|
68 | $db = $objDB -> db; |
---|
69 | $db -> select('phpgw_acl','count(*)',array( |
---|
70 | 'acl_appname' => "calendar", |
---|
71 | 'acl_location' => $user, |
---|
72 | 'acl_account' => $group),__LINE__,__FILE__); |
---|
73 | |
---|
74 | // Verify if already exists.... |
---|
75 | if ($db->next_record() && $db->f(0)) { |
---|
76 | return false; |
---|
77 | } |
---|
78 | |
---|
79 | $where = false; |
---|
80 | $db -> insert('phpgw_acl',array( |
---|
81 | 'acl_appname' => "calendar", |
---|
82 | 'acl_location' => $user, |
---|
83 | 'acl_account' => $group, |
---|
84 | 'acl_rights' => $rights |
---|
85 | ), $where, __LINE__,__FILE__); |
---|
86 | |
---|
87 | return true; |
---|
88 | } |
---|
89 | |
---|
90 | public final function rem_user($params){ |
---|
91 | |
---|
92 | list($user,$group) = explode(";",$params['id']); |
---|
93 | $objDB = CreateObject('expressoMail1_2.db_functions'); |
---|
94 | $db = $objDB -> db; |
---|
95 | $db -> delete('phpgw_acl',array( |
---|
96 | 'acl_appname' => "calendar", |
---|
97 | 'acl_location' => $user, |
---|
98 | 'acl_account' => $group),__LINE__,__FILE__); |
---|
99 | return true; |
---|
100 | } |
---|
101 | } |
---|
102 | ?> |
---|