当前位置: 首页>>代码示例>>PHP>>正文


PHP UserDB::getInstance方法代码示例

本文整理汇总了PHP中UserDB::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDB::getInstance方法的具体用法?PHP UserDB::getInstance怎么用?PHP UserDB::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserDB的用法示例。


在下文中一共展示了UserDB::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: usersLogin

 public function usersLogin()
 {
     Logger::debug('main', 'USERSGROUP::usersLogin (for id=' . $this->getUniqueID() . ')');
     $logins = array();
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'USERSGROUP::usersLogin (for id=' . $this->getUniqueID() . ') get prefs failed');
         die_error('get Preferences failed', __FILE__, __LINE__);
     }
     $user_default_group = $prefs->get('general', 'user_default_group');
     if ($user_default_group === $this->getUniqueID()) {
         // it's the default group -> we add all users
         $userdb = UserDB::getInstance();
         $users = $userdb->getList();
         foreach ($users as $a_user) {
             $logins[] = $a_user->getAttribute('login');
         }
     } else {
         $ls = Abstract_Liaison::load('UsersGroup', NULL, $this->getUniqueID());
         if (is_array($ls)) {
             foreach ($ls as $l) {
                 $logins[] = $l->element;
             }
         }
     }
     return $logins;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:27,代码来源:UsersGroup.class.php

示例2: makeLDAPconfig

 public function makeLDAPconfig($config_ = NULL)
 {
     if (is_null($config_) === false) {
         return $config_;
     } else {
         $userDBAD = UserDB::getInstance();
         if (method_exists($userDBAD, 'makeLDAPconfig') === false) {
             Logger::error('main', 'UserGroupDB::ldap_posix::makeLDAPconfig makeLDAPconfig is not avalaible');
             return NULL;
         }
         $configLDAP = $userDBAD->makeLDAPconfig();
         $configLDAP['match'] = array();
         if (array_key_exists('match', $this->preferences)) {
             $configLDAP['match'] = $this->preferences['match'];
         }
         $configLDAP['userbranch'] = '';
         if (array_key_exists('group_dn', $this->preferences)) {
             $configLDAP['userbranch'] = $this->preferences['group_dn'];
         }
         if (array_key_exists('filter', $this->preferences)) {
             $configLDAP['filter'] = $this->preferences['filter'];
         }
         return $configLDAP;
     }
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:25,代码来源:ldap_posix.php

示例3: get_login

 public function get_login()
 {
     $userDB = UserDB::getInstance();
     if (!is_object($userDB)) {
         return NULL;
     }
     $prefs = Preferences::getInstance();
     $config = $prefs->get('AuthMethod', 'Auto');
     if (array_key_exists('login', $_POST) && array_key_exists('uselogin', $config) && $config['uselogin'] == '1') {
         $this->login = $_POST['login'];
     } else {
         $this->login = 'u' . gen_unique_string();
     }
     $u = new User();
     $u->setAttribute('login', $this->login);
     $u->setAttribute('password', $u->getAttribute('login'));
     $u->setAttribute('displayname', 'user ' . $u->getAttribute('login'));
     if ($userDB->add($u)) {
         $user = $userDB->import($u->getAttribute('login'));
     } else {
         Logger::error('main', 'AuthMethod::Auto::get_login failed to add user ' . $u->getAttribute('login'));
         return NULL;
     }
     if (!is_object($user)) {
         return NULL;
     }
     $this->login = $user->getAttribute('login');
     return $this->login;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:29,代码来源:Auto.php

示例4: search

 function search()
 {
     $userDB = UserDB::getInstance();
     list($this->result, $nb) = $userDB->getUsersContains($this->search_item, $this->search_fields, $this->search_limit + 1);
     if ($nb || count($this->result) > $this->search_limit) {
         array_pop($this->result);
         $this->partial_result = true;
     } else {
         $this->partial_result = false;
     }
     return $this->result;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:12,代码来源:UsersList.class.php

示例5: getUsers

 public function getUsers()
 {
     $liaisons = Abstract_Liaison::load('UserProfile', NULL, $this->id);
     if (is_array($liaisons) == false) {
         Logger::error('main', 'NetworkFolder::getUsers()');
         return false;
     }
     $userDB = UserDB::getInstance();
     $users = array();
     foreach ($liaisons as $liaison) {
         array_push($users, $liaison->element);
     }
     return $userDB->imports($users);
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:14,代码来源:Profile.class.php

示例6: getUsers

 public function getUsers()
 {
     $liaisons = Abstract_Liaison::load('UserProfile', NULL, $this->id);
     if (is_array($liaisons) == false) {
         Logger::error('main', 'NetworkFolder::getUsers()');
         return false;
     }
     $userDB = UserDB::getInstance();
     $users = array();
     foreach ($liaisons as $liaison) {
         $user = $userDB->import($liaison->element);
         if (!is_object($user)) {
             continue;
         }
         $users[$user->getAttribute('login')] = $user;
     }
     return $users;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:18,代码来源:Profile.class.php

示例7: checkPendingSession

 public function checkPendingSession($session_)
 {
     $sessions = Abstract_Session::getByUser($session_->user_login);
     foreach ($sessions as $i => $session) {
         if ($session->id == $session_->id) {
             unset($sessions[$i]);
             continue;
         }
     }
     if (count($sessions) != 1) {
         return true;
     }
     $session = reset($sessions);
     if ($session->need_creation == 0) {
         return true;
     }
     // Start the creation
     try {
         $sessionManagement = SessionManagement::getInstance();
     } catch (Exception $err) {
         Logger::error('main', "SessionStatusChangedPendingSessionCreation:: Failed to get SessionManagement instance");
         return false;
     }
     if (!$sessionManagement->initialize()) {
         Logger::error('main', "SessionStatusChangedPendingSessionCreation:: SessionManagement initialization failed");
         return false;
     }
     $userDB = UserDB::getInstance();
     $user = $userDB->import($session->user_login);
     if (!is_object($user)) {
         Logger::error('main', 'SessionStatusChangedPendingSessionCreation:: Unable to import a valid user with login "' . $session->user_login . '"');
         return false;
     }
     $sessionManagement->user = $user;
     if (!$sessionManagement->prepareSession($session)) {
         Logger::error('main', "SessionStatusChangedPendingSessionCreation:: SessionManagement initialization failed");
         return false;
     }
     // prepareSession can take some time
     $session = Abstract_Session::load($session->id);
     $session->need_creation = 0;
     Abstract_Session::save($session);
     return true;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:44,代码来源:PendingSessionCreation.class.php

示例8: authenticate_ovd_user

function authenticate_ovd_user($login_, $password_)
{
    // it's not the login&password from the conf file in /etc
    // let's try to login a real user
    if (Preferences::fileExists() === false) {
        $_SESSION['admin_error'] = _('The system is not configured');
        Logger::info('main', 'admin/login.php::authenticate_ovd_user the system is not configured');
        return false;
    }
    if (Preferences::moduleIsEnabled('UserDB') === false) {
        $_SESSION['admin_error'] = _('The module UserDB is not enabled');
        Logger::info('main', 'admin/login.php::authenticate_ovd_user module UserDB is not enabled');
        return false;
    }
    $userDB = UserDB::getInstance();
    $user = $userDB->import($login_);
    if (!is_object($user)) {
        // the user does not exist
        $_SESSION['admin_error'] = _('There was an error with your authentication');
        Logger::info('main', 'admin/login.php::authenticate_ovd_user authentication failed: user(login=' . $login_ . ') does not exist');
        return false;
    }
    $auth = $userDB->authenticate($user, $password_);
    if (!$auth) {
        $_SESSION['admin_error'] = _('There was an error with your authentication');
        Logger::info('main', 'admin/login.php::authenticate_ovd_user authentication failed for user(login=' . $login_ . '): wrong password');
        return false;
    }
    // the user exists, does he have right to log in the admin panel ?
    $policy = $user->getPolicy();
    if (isset($policy['canUseAdminPanel']) && $policy['canUseAdminPanel'] == true) {
        return $user;
    }
    Logger::info('main', 'login.php failed to log in ' . $login_ . ' : access denied to admin panel');
    $_SESSION['admin_error'] = _('Unauthorized access');
    return false;
}
开发者ID:skdong,项目名称:nfs-ovd,代码行数:37,代码来源:login.php

示例9: authenticate

 public function authenticate()
 {
     $this->userDB = UserDB::getInstance();
     if (isset($_SESSION) && is_array($_SESSION) && array_key_exists('user_login', $_SESSION)) {
         $this->user = $this->userDB->import($_SESSION['user_login']);
         if (!is_object($this->user)) {
             Logger::debug('main', 'SessionManagement::authenticate - Unable to import a valid user with login "' . $_SESSION['user_login'] . '"');
             return false;
         }
         return true;
     }
     $authMethods_enabled = $this->prefs->get('AuthMethod', 'enable');
     if (!is_array($authMethods_enabled)) {
         Logger::error('main', 'SessionManagement::authenticate - No AuthMethod enabled');
         return false;
     }
     $authMethods = array();
     foreach ($this->getAuthMethods() as $authMethod_name_) {
         if (!in_array($authMethod_name_, $authMethods_enabled)) {
             Logger::debug('main', 'SessionManagement::authenticate - AuthMethod "' . $authMethod_name_ . '" is not enabled');
             continue;
         }
         $authMethods[$authMethod_name_] = $authMethod_name_;
     }
     if (array_key_exists('Password', $authMethods)) {
         unset($authMethods['Password']);
         $authMethods['Password'] = 'Password';
     }
     foreach ($authMethods as $authMethod_name_) {
         $authMethod_module = 'AuthMethod_' . $authMethod_name_;
         $authMethod = new $authMethod_module($this->prefs, $this->userDB, $this->user_node_request);
         Logger::debug('main', 'SessionManagement::authenticate - Trying "' . $authMethod_module . '"');
         $user_login = $authMethod->get_login();
         if (is_null($user_login)) {
             Logger::debug('main', 'SessionManagement::authenticate - Unable to get a valid login');
             continue;
         }
         $this->user = $this->userDB->import($user_login);
         if (!is_object($this->user)) {
             Logger::debug('main', 'SessionManagement::authenticate - Unable to import a valid user with login "' . $user_login . '"');
             continue;
         }
         $buf = $authMethod->authenticate($this->user);
         if ($buf === true) {
             $this->authMethod = $authMethod;
             Logger::debug('main', 'SessionManagement::authenticate - Now authenticated as "' . $user_login . '"');
             return true;
         }
         Logger::error('main', 'SessionManagement::authenticate - Authentication failed for "' . $user_login . '"');
         continue;
     }
     Logger::error('main', 'SessionManagement::authenticate - Authentication failed');
     $this->user = false;
     return false;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:55,代码来源:SessionManagement.php

示例10: dirname

 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
require_once dirname(__FILE__) . '/../includes/core-minimal.inc.php';
require_once dirname(__FILE__) . '/../includes/webservices.inc.php';
$dom = new DomDocument('1.0', 'utf-8');
$root = $dom->createElement('auth');
$dom->appendChild($root);
$prefs = Preferences::getInstance();
if ($prefs) {
    $userDB = UserDB::getInstance();
    $authMethods_enabled = $prefs->get('AuthMethod', 'enable');
    if (is_array($authMethods_enabled)) {
        foreach ($authMethods_enabled as $authMethod_name) {
            $authMethod_module = 'AuthMethod_' . $authMethod_name;
            $authMethod = new $authMethod_module($prefs, $userDB, null);
            $authMethodParams = $authMethod->getClientParameters();
            if (is_array($authMethodParams) && count($authMethodParams) > 0) {
                $snode = $dom->createElement($authMethod_name);
                $root->appendChild($snode);
                foreach ($authMethodParams as $key => $value) {
                    $node = $dom->createElement($key);
                    $text_node = $dom->createTextNode($value);
                    $node->appendChild($text_node);
                    $snode->appendChild($node);
                }
开发者ID:bloveing,项目名称:openulteo,代码行数:31,代码来源:auth_params.php

示例11: show_manage

function show_manage($id_)
{
    // 	$session = Abstract_ReportSession::load($id_);
    $session = get_session_reporting($id_);
    if (!$session) {
        popup_error(sprintf(_('Unknown session %s'), $id_));
        redirect();
    }
    $userDB = UserDB::getInstance();
    $user = $userDB->import($session['user']);
    $applicationDB = ApplicationDB::getInstance();
    $applications = array();
    $dom = new DomDocument('1.0', 'utf-8');
    $ret = @$dom->loadXML($session['data']);
    if ($ret) {
        foreach ($dom->getElementsByTagName('application') as $node) {
            $application = array();
            foreach ($node->childNodes as $child_node) {
                $name = $child_node->nodeName;
                if ($name == '#text') {
                    continue;
                }
                $application[$name] = $child_node->nodeValue;
            }
            $applications[] = $application;
        }
    }
    for ($i = 0; $i < count($applications); $i++) {
        $app_buf = $applicationDB->import($applications[$i]['id']);
        if (is_object($app_buf)) {
            $applications[$i]["obj"] = $app_buf;
        }
    }
    page_header();
    echo '<h1>' . str_replace('%ID%', $session['id'], _('Archived session - %ID%')) . '</h1>';
    echo '<ul>';
    echo '<li><strong>' . _('User:') . '</strong> ';
    if (is_object($user)) {
        echo '<a href="users.php?action=manage&id=' . $user->getAttribute('login') . '">' . $user->getAttribute('displayname') . '</a>';
    } else {
        echo $session['user'] . ' <span><em>' . _('Not existing anymore') . '</em></span>';
    }
    echo '</li>';
    echo '<li><strong>' . _('Started:') . '</strong> ';
    echo $session['start_stamp'];
    echo '</li>';
    echo '<li><strong>' . _('Stopped:') . '</strong> ';
    echo $session['stop_stamp'];
    if (isset($session['stop_why']) && strlen($session['stop_why']) > 0) {
        echo '&nbsp<em>(' . $session['stop_why'] . ')</em>';
    }
    echo '</li>';
    echo '</ul>';
    if (count($applications) > 0) {
        echo '<div>';
        echo '<h2>' . _('Used applications') . '</h2>';
        echo '<ul>';
        foreach ($applications as $application) {
            echo '<li>';
            if (isset($application['obj'])) {
                echo '<img src="media/image/cache.php?id=' . $application['obj']->getAttribute('id') . '" alt="" title="" /> ';
                echo '<a href="applications.php?action=manage&id=' . $application['obj']->getAttribute('id') . '">' . $application['obj']->getAttribute('name') . '</a>';
            } else {
                echo $application['id'] . '&nbsp;<span><em>' . _('not existing anymore') . '</em></span>';
            }
            if ($application['start'] - $application['start'] > 0) {
                echo '  - (' . ($application['start'] - $application['start']) / 60 . 'm)';
            }
            echo '</li>';
        }
        echo '</ul>';
        echo '</div>';
    }
    page_footer();
    die;
}
开发者ID:skdong,项目名称:nfs-ovd,代码行数:76,代码来源:session-reporting.php

示例12: loadParentsGroups

 public static function loadParentsGroups($group_)
 {
     Logger::debug('main', "Abstract_Liaison_activedirectory::loadParentsGroups ({$group_})");
     $userDBAD2 = new UserDB_activedirectory();
     $userDBAD = UserDB::getInstance();
     if (get_class($userDBAD) == get_class($userDBAD2)) {
         $userDBAD = $userDBAD2;
         // for cache
     }
     $userGroupDB = UserGroupDB::getInstance();
     $groups = array();
     $u = $userDBAD->importFromDN($group_);
     if (is_null($u)) {
         return $groups;
     }
     if (!$u->hasAttribute('memberof')) {
         return $groups;
     }
     $memberof = $u->getAttribute('memberof');
     if (is_string($memberof)) {
         $memberof = array($memberof);
     }
     foreach ($memberof as $id_group) {
         $g = $userGroupDB->import('static_' . $id_group);
         if (!is_object($g)) {
             continue;
         }
         $groups[] = $g;
         $parent_groups = self::loadParentsGroups($id_group);
         $groups = array_merge($groups, $parent_groups);
     }
     return $groups;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:33,代码来源:Abstract_Liaison_activedirectory.class.php

示例13: show_step5

function show_step5()
{
    page_header();
    echo '<div>';
    echo '<h1><a href="wizard.php">' . _('Publication Wizard') . '</a> - ' . _('Confirmation') . '</h1>';
    echo '<p>' . _('Are you sure that you want to create this publication?') . '</p>';
    echo '<table style="width: 50%;" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr>';
    echo '<td style="text-align: left; vertical-align: top;">';
    echo '<div class="container rounded" style="background: #eee;">';
    if ($_SESSION['wizard']['use_users'] == 'usergroups') {
        $usergroupDB = UserGroupDB::getInstance();
        echo '<p style="font-weight: bold;">';
        if (count($_SESSION['wizard']['usergroups']) == 1) {
            echo _('Between this users group');
        } else {
            echo _('Between these users groups');
        }
        echo '</p>';
        echo '<ul>';
        foreach ($_SESSION['wizard']['usergroups'] as $ug_id) {
            $ug = $usergroupDB->import($ug_id);
            if (!is_object($ug)) {
                Logger::warning('main', '(admin/wizard) Usergroup \'' . $ug_id . '\' import failed');
                continue;
            }
            echo '<li>' . $ug->name . '</li>';
        }
        echo '</ul>';
    } elseif ($_SESSION['wizard']['use_users'] == 'users') {
        $userDB = UserDB::getInstance();
        echo '<p style="font-weight: bold;">';
        echo _('Between this newly created users group');
        echo '</p>';
        echo '<ul>';
        echo '<li><strong>' . _('Name:') . '</strong> ' . $_SESSION['wizard']['user_group_name'] . '</li>';
        echo '<li><strong>' . _('Description: ') . '</strong> ' . $_SESSION['wizard']['user_group_description'] . '</li>';
        echo '<li><strong>' . _('Users:') . '</strong> <ul>';
        foreach ($_SESSION['wizard']['users'] as $user_login) {
            $user = $userDB->import($user_login);
            if (!is_object($user)) {
                Logger::warning('main', '(admin/wizard) User \'' . $user_login . '\' import failed');
                continue;
            }
            echo '<li>' . $user->getAttribute('displayname') . '</li>';
        }
        echo '</ul></li>';
        echo '</ul>';
    }
    echo '</div>';
    echo '</td>';
    echo '<td style="width: 50px;">';
    echo '</td>';
    echo '<td style="text-align: left; vertical-align: top;">';
    echo '<div class="container rounded" style="background: #eee;">';
    if ($_SESSION['wizard']['use_apps'] == 'appgroups') {
        $applicationsGroupDB = ApplicationsGroupDB::getInstance();
        echo '<p style="font-weight: bold;">';
        if (count($_SESSION['wizard']['appgroups']) == 1) {
            echo _('and this applications group');
        } else {
            echo _('and these applications groups');
        }
        echo '</p>';
        echo '<ul>';
        foreach ($_SESSION['wizard']['appgroups'] as $ag_id) {
            $appgroup = $applicationsGroupDB->import($ag_id);
            if (is_object($appgroup)) {
                echo '<li>' . $appgroup->name . '</li>';
            }
        }
        echo '</ul>';
    } elseif ($_SESSION['wizard']['use_apps'] == 'apps') {
        $applicationDB = ApplicationDB::getInstance();
        echo '<p style="font-weight: bold;">';
        echo _('and this newly created applications group');
        echo '</p>';
        echo '<ul>';
        echo '<li><strong>' . _('Name:') . '</strong> ' . $_SESSION['wizard']['application_group_name'] . '</li>';
        echo '<li><strong>' . _('Description: ') . '</strong> ' . $_SESSION['wizard']['application_group_description'] . '</li>';
        echo '<li><strong>' . _('Applications:') . '</strong> <ul>';
        foreach ($_SESSION['wizard']['apps'] as $application_id) {
            $application = $applicationDB->import($application_id);
            if (!is_object($application)) {
                Logger::warning('main', '(admin/wizard) Application \'' . $application_id . '\' import failed');
                continue;
            }
            echo '<li>' . $application->getAttribute('name') . '</li>';
        }
        echo '</ul></li>';
        echo '</ul>';
    }
    echo '</div>';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<form action="" method="post">';
    echo '<input type="hidden" name="from" value="step5" />';
    echo '<table style="width: 50%;" class="" border="0" cellspacing="1" cellpadding="5">';
    echo '<tr>';
//.........这里部分代码省略.........
开发者ID:skdong,项目名称:nfs-ovd,代码行数:101,代码来源:wizard.php

示例14: loadGroups

 public static function loadGroups($type_, $element_)
 {
     Logger::debug('main', "Abstract_Liaison_unix::loadGroups ({$type_},{$element_})");
     $groups = array();
     $userGroupDB = UserGroupDB::getInstance();
     $userDB = UserDB::getInstance();
     $element_user = $userDB->import($element_);
     if (!is_object($element_user)) {
         Logger::error('main', "Abstract_Liaison_unix::loadGroups load element ({$element_}) failed");
         return NULL;
     }
     $userGroupDB = UserGroupDB::getInstance();
     $groups_list = $userGroupDB->getList();
     foreach ($groups_list as $group) {
         $liaisons = self::loadElements($type_, $group->getUniqueID());
         if (is_array($liaisons)) {
             foreach ($liaisons as $liaison) {
                 $l = new Liaison($element_user->getAttribute('login'), $group->getUniqueID());
                 $groups[$l->group] = $l;
             }
         }
     }
     return $groups;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:24,代码来源:Abstract_Liaison_unix.class.php

示例15: loadGroups

 public static function loadGroups($type_, $element_)
 {
     Logger::debug('main', "Abstract_Liaison_ldap_posix::loadGroups ({$type_},{$element_})");
     $userGroupDB = UserGroupDB::getInstance();
     $userDB = UserDB::getInstance();
     $groups = array();
     $groups_all = $userGroupDB->getList();
     if (!is_array($groups_all)) {
         Logger::error('main', 'Abstract_Liaison_ldap::loadGroups userGroupDB->getList failed');
         return NULL;
     }
     foreach ($groups_all as $a_group) {
         if (in_array($element_, $a_group->usersLogin())) {
             $l = new Liaison($element_, $a_group->getUniqueID());
             $groups[$l->group] = $l;
         }
     }
     return $groups;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:19,代码来源:Abstract_Liaison_ldap_posix.class.php


注:本文中的UserDB::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。