read_repository(); $current_config = $c->config_data; $ldap_manager = CreateObject('contactcenter.bo_ldap_manager'); $boemailadmin = CreateObject('emailadmin.bo'); $emailadmin_profile = $boemailadmin->getProfileList(); $_SESSION['phpgw_info']['expresso']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']); $_SESSION['phpgw_info']['expresso']['user'] = $GLOBALS['phpgw_info']['user']; $_SESSION['phpgw_info']['expresso']['server'] = $GLOBALS['phpgw_info']['server']; $_SESSION['phpgw_info']['expresso']['cc_ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; $_SESSION['phpgw_info']['expresso']['expressoAdmin'] = $current_config; $_SESSION['phpgw_info']['expresso']['global_denied_users'] = $GLOBALS['phpgw_info']['server']['global_denied_users']; $_SESSION['phpgw_info']['expresso']['global_denied_groups'] = $GLOBALS['phpgw_info']['server']['global_denied_groups']; } protected function createUser($params) { // Get Profile for Expresso $default = $this->getProfile($params['profileUser']); if( $default == false ) { return array( "status" => false, "msg" => "Profile Invalid" ); } // Get Groups,Context $firstLetter = strtolower(substr( $params['givenname'], 0, 1)); $isLetter = trim(preg_replace("/[^a-z]/", "", $firstLetter)); if( !$isLetter ) { return array( "status" => false, "msg" => "Type a letter" ); } else { if( $params['profileUser'] == "expresso.seed" ) { $groups = $default['groups_user-'.$firstLetter]; unset( $default['groups_user-'.$firstLetter] ); foreach( $default as $key => $value ) { if( strpos( $key, "gidnumber-" ) !== false ) { unset( $default[$key] ); } } $default['context'] = "ou=".$firstLetter.",".$default['context']; } else { $groups = $default['groups_user']; unset( $default['groups_user'] ); } } // Groups if( strpos($groups, ",") !== false ) { $groups_user = explode( "," , $groups ); $params['groups'] = $groups_user; $params['gidnumber'] = $groups_user[0]; } else { $params['groups'][0] = $groups; $params['gidnumber'] = $groups; } // Merge Conf default + params $createUser = array_merge( $params, $default ); $adminCreateUser = CreateObject('expressoAdmin1_2.user'); $_return = $adminCreateUser->create($createUser); return $_return; } protected function deleteUser($params) { $adminDeleteUser = CreateObject('expressoAdmin1_2.user'); $result = $adminDeleteUser->delete( $params ); return $result; } protected function editUser($params) { $adminEditUser = CreateObject('expressoAdmin1_2.user'); $user = $adminEditUser->get_user_info($params); return $user; } protected function listUsersLiteral($params) { $list = $this->listUsers($params); foreach( $list as $key => $users ) { if( strtolower(trim($params)) === strtolower(trim($users['account_lid']))) { return $list[$key]; } } return false; } protected function listUsers($params) { $adminListUser = CreateObject('expressoAdmin1_2.functions'); $acl = $adminListUser->read_acl($GLOBALS['phpgw']->accounts->data['account_lid']); $search = trim(preg_replace("/[^a-z_0-9_-_._@\\s]/", "", $params)); $accounts = $adminListUser->get_list( 'accounts', $search, $acl['contexts'] ); return $accounts; } protected function renameUser($params) { $adminRenameUser = CreateObject('expressoAdmin1_2.user'); $result = $adminRenameUser->rename( $params ); return $result; } protected function updateUser($params) { $adminUpdateUser = CreateObject('expressoAdmin1_2.user'); // Get User Info $userInfo = array(); $userInfo = $this->editUser($params['uidnumber']); // Unset unset($userInfo['groups_ldap']); unset($userInfo['groups_info']); // Arrgay Merge $updateUser = array(); $updateUser = array_merge( $userInfo, $params ); $result = $adminUpdateUser->save($updateUser); return $result; } protected function validateFields($params ) { $ldap_functions = CreateObject('expressoAdmin1_2.ldap_functions'); return $ldap_functions->validate_fields($params); } protected function validatePermission( $params ) { $action = $params['action']; $apps = $params['apps']; $manager = $_SESSION['phpgw_info']['expresso']['user']['account_lid']; $functions = CreateObject('expressoAdmin1_2.functions'); $result = false; if( array_search('admin',$apps) !== False ) { if( $functions->check_acl( $manager, $action ) ) { $result = true; } } return $result; } private function getProfile($profileUser) { $default = false; if( file_exists(API_DIRECTORY.'/../config/profileCreateUser.ini') ) { $profiles = parse_ini_file(API_DIRECTORY.'/../config/profileCreateUser.ini', true ); foreach( $profiles as $key => $values ) { if( $key == $profileUser ) { $default = $values; } } } return $default; } } ?>