[421] | 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 | |
---|
[580] | 13 | |
---|
[421] | 14 | class bogroup_access |
---|
| 15 | { |
---|
| 16 | final function __construct(){ |
---|
[580] | 17 | // Including ExpressoMail Classes |
---|
| 18 | if(file_exists("../expressoMail1_2/inc/class.db_functions.inc.php")) |
---|
| 19 | include_once("../expressoMail1_2/inc/class.db_functions.inc.php"); |
---|
| 20 | if(file_exists("../expressoMail1_2/inc/class.ldap_functions.inc.php")) |
---|
| 21 | include_once("../expressoMail1_2/inc/class.ldap_functions.inc.php"); |
---|
[421] | 22 | } |
---|
| 23 | |
---|
[580] | 24 | public final function search_user($params){ |
---|
| 25 | $objLdap = new ldap_functions(); |
---|
[421] | 26 | $objLdap -> ldapRootConnect(); |
---|
| 27 | $ldap = $objLdap -> ds; |
---|
| 28 | $search = $params['search']; |
---|
| 29 | $accounttype = $params['type']; |
---|
| 30 | $justthese = array("cn","uid", "uidNumber","gidNumber"); |
---|
| 31 | $users_list=ldap_search($ldap, $_SESSION['phpgw_info']['expressomail']['server']['ldap_context'], "(&(phpgwAccountType=$accounttype) (|(cn=*$search*)(mail=$search*)) )", $justthese); |
---|
| 32 | if (ldap_count_entries($ldap, $users_list) == 0) |
---|
| 33 | { |
---|
| 34 | $return['status'] = 'false'; |
---|
| 35 | $return['msg'] = 'Nenhum resultado encontrado.'; |
---|
| 36 | return $return; |
---|
| 37 | } |
---|
| 38 | ldap_sort($ldap, $users_list, "cn"); |
---|
| 39 | $entries = ldap_get_entries($ldap, $users_list); |
---|
| 40 | $options = ''; |
---|
| 41 | for ($i=0; $i<$entries['count']; $i++) |
---|
| 42 | { |
---|
| 43 | $value = $entries[$i][$accounttype == "u" ? 'uidnumber' : 'gidnumber'][0]; |
---|
| 44 | if($entries[$i]['mail'][0]) |
---|
| 45 | $mail = "(".$entries[$i]['mail'][0].")"; |
---|
| 46 | $options .= "<option value=" . $value. ">" . $entries[$i]['cn'][0] . " $mail" . "</option>"; |
---|
| 47 | } |
---|
| 48 | return $options; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | public function get_grants($app){ |
---|
| 52 | $db2 = $GLOBALS['phpgw']->db; |
---|
| 53 | $db2->select('phpgw_acl',array('acl_location','acl_account','acl_rights'),"acl_appname='".$app."' AND acl_location <> 'run'",__LINE__,__FILE__); |
---|
| 54 | |
---|
| 55 | $grants = array(); |
---|
| 56 | while ($db2->next_record()) { |
---|
| 57 | $objectID = $db2->f('acl_account'); |
---|
| 58 | $type = $GLOBALS['phpgw']->accounts->get_type($objectID); |
---|
| 59 | if($type == 'g') { |
---|
| 60 | $userID = $db2->f('acl_location'); |
---|
| 61 | $rights = $db2->f('acl_rights'); |
---|
| 62 | $grants[$userID.";".$objectID] = array( "userID"=> $userID,"groupID"=> $objectID, "rights" => $rights); |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | unset($db2); |
---|
| 66 | return $grants; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | public final function add_user($params) { |
---|
| 70 | |
---|
| 71 | list($user,$group,$rights) = explode(";",$params['id']); |
---|
[580] | 72 | $objDB = new db_functions(); |
---|
[421] | 73 | $db = $objDB -> db; |
---|
| 74 | $db -> select('phpgw_acl','count(*)',array( |
---|
| 75 | 'acl_appname' => "calendar", |
---|
| 76 | 'acl_location' => $user, |
---|
| 77 | 'acl_account' => $group),__LINE__,__FILE__); |
---|
| 78 | |
---|
| 79 | // Verify if already exists.... |
---|
| 80 | if ($db->next_record() && $db->f(0)) { |
---|
| 81 | return false; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | $where = false; |
---|
| 85 | $db -> insert('phpgw_acl',array( |
---|
| 86 | 'acl_appname' => "calendar", |
---|
| 87 | 'acl_location' => $user, |
---|
| 88 | 'acl_account' => $group, |
---|
| 89 | 'acl_rights' => $rights |
---|
| 90 | ), $where, __LINE__,__FILE__); |
---|
| 91 | |
---|
| 92 | return true; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | public final function rem_user($params){ |
---|
| 96 | |
---|
| 97 | list($user,$group) = explode(";",$params['id']); |
---|
[580] | 98 | $objDB = new db_functions(); |
---|
[421] | 99 | $db = $objDB -> db; |
---|
| 100 | $db -> delete('phpgw_acl',array( |
---|
| 101 | 'acl_appname' => "calendar", |
---|
| 102 | 'acl_location' => $user, |
---|
| 103 | 'acl_account' => $group),__LINE__,__FILE__); |
---|
| 104 | return true; |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | ?> |
---|