[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 | |
---|
[5132] | 24 | public final function search_user($params) |
---|
[421] | 25 | { |
---|
[5132] | 26 | $server = $_SESSION['phpgw_info']['expressomail']['server']; |
---|
| 27 | |
---|
| 28 | $t = $params['type']; |
---|
| 29 | |
---|
| 30 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 31 | |
---|
| 32 | $ldapService->connect( $server['ldap_host'], $server['ldap_root_dn'], $server['ldap_root_pw'] ); |
---|
| 33 | |
---|
| 34 | $entries = $ldapService->accountSearch($params['search'], array('cn', $t.'idNumber', $t.'id' ), $server['ldap_context'], $t, 'cn'); |
---|
| 35 | |
---|
[421] | 36 | $options = ''; |
---|
[5132] | 37 | |
---|
| 38 | foreach( $entries as $value ) |
---|
[421] | 39 | { |
---|
[5132] | 40 | $id = $value[$t.'id'] ? $value[$t.'id'] : $value[$t.'idnumber']; |
---|
| 41 | |
---|
| 42 | $options .= '<option value='.$value[ $t.'idnumber' ].'>'.$value['cn'].'('.$id.')</option>'; |
---|
[421] | 43 | } |
---|
[5132] | 44 | |
---|
[421] | 45 | return $options; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | public function get_grants($app){ |
---|
| 49 | $db2 = $GLOBALS['phpgw']->db; |
---|
| 50 | $db2->select('phpgw_acl',array('acl_location','acl_account','acl_rights'),"acl_appname='".$app."' AND acl_location <> 'run'",__LINE__,__FILE__); |
---|
| 51 | |
---|
| 52 | $grants = array(); |
---|
| 53 | while ($db2->next_record()) { |
---|
| 54 | $objectID = $db2->f('acl_account'); |
---|
| 55 | $type = $GLOBALS['phpgw']->accounts->get_type($objectID); |
---|
| 56 | if($type == 'g') { |
---|
| 57 | $userID = $db2->f('acl_location'); |
---|
| 58 | $rights = $db2->f('acl_rights'); |
---|
| 59 | $grants[$userID.";".$objectID] = array( "userID"=> $userID,"groupID"=> $objectID, "rights" => $rights); |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | unset($db2); |
---|
| 63 | return $grants; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | public final function add_user($params) { |
---|
| 67 | |
---|
| 68 | list($user,$group,$rights) = explode(";",$params['id']); |
---|
[580] | 69 | $objDB = new db_functions(); |
---|
[421] | 70 | $db = $objDB -> db; |
---|
| 71 | $db -> select('phpgw_acl','count(*)',array( |
---|
| 72 | 'acl_appname' => "calendar", |
---|
| 73 | 'acl_location' => $user, |
---|
| 74 | 'acl_account' => $group),__LINE__,__FILE__); |
---|
| 75 | |
---|
| 76 | // Verify if already exists.... |
---|
| 77 | if ($db->next_record() && $db->f(0)) { |
---|
| 78 | return false; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | $where = false; |
---|
| 82 | $db -> insert('phpgw_acl',array( |
---|
| 83 | 'acl_appname' => "calendar", |
---|
| 84 | 'acl_location' => $user, |
---|
| 85 | 'acl_account' => $group, |
---|
| 86 | 'acl_rights' => $rights |
---|
| 87 | ), $where, __LINE__,__FILE__); |
---|
| 88 | |
---|
| 89 | return true; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | public final function rem_user($params){ |
---|
| 93 | |
---|
| 94 | list($user,$group) = explode(";",$params['id']); |
---|
[580] | 95 | $objDB = new db_functions(); |
---|
[421] | 96 | $db = $objDB -> db; |
---|
| 97 | $db -> delete('phpgw_acl',array( |
---|
| 98 | 'acl_appname' => "calendar", |
---|
| 99 | 'acl_location' => $user, |
---|
| 100 | 'acl_account' => $group),__LINE__,__FILE__); |
---|
| 101 | return true; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | ?> |
---|