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


PHP User::get方法代码示例

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


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

示例1: changeSubscription

 public function changeSubscription(User $user, array $addLists, array $deleteLists)
 {
     $email = $user->get($this->getConfig('email_field', 'email'));
     if (empty($email)) {
         return true;
     }
     // add custom fields info
     $fields = array();
     foreach ($this->getConfig('fields', array()) as $fn) {
         $fields['custom_' . $fn] = $user->get($fn);
     }
     foreach ($addLists as $listId) {
         $ret = $this->doRequest(array('first_name' => $user->name_f, 'last_name' => $user->name_l, 'email_address' => $email) + $fields, $listId);
         if (!$ret) {
             return false;
         }
     }
     foreach ($deleteLists as $listId) {
         $list = $this->getDi()->newsletterListTable->findFirstBy(array('plugin_id' => $this->getId(), 'plugin_list_id' => $listId));
         if (!$list) {
             continue;
         }
         $vars = unserialize($list->vars);
         $ret = $this->doRequest(array('first_name' => $user->name_f, 'last_name' => $user->name_l, 'email_address' => $email), @$vars['unsub_list_id']);
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:30,代码来源:arpreach.php

示例2: is_probationary_user

/**
 * Check whether a user is on probation.
 * @param int $userid
 * @return boolean TRUE if the user is on probation, FALSE if the user is not on probation
 */
function is_probationary_user($userid = null)
{
    global $USER;
    // Check whether a new user threshold is in place or not.
    if (!is_using_probation()) {
        return false;
    }
    // Get the user's information
    if ($userid == null) {
        $user = $USER;
    } else {
        $user = new User();
        $user->find_by_id($userid);
    }
    // Admins and staff get a free pass
    if ($user->get('admin') || $user->get('staff') || $user->is_institutional_admin() || $user->is_institutional_staff()) {
        return false;
    }
    // We actually store new user points in reverse. When your account is created, you get $newuserthreshold points, and
    // we decrease those when you do something good, and when it hits 0 you're no longer a new user.
    $userspoints = get_field('usr', 'probation', 'id', $user->get('id'));
    if ($userspoints > 0) {
        return true;
    } else {
        return false;
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:32,代码来源:antispam.php

示例3: changeSubscription

 public function changeSubscription(User $user, array $addLists, array $deleteLists)
 {
     $email = $user->get($this->getConfig('email_field', 'email'));
     if (empty($email)) {
         return true;
     }
     // add custom fields info
     $fields = array();
     foreach ($this->getConfig('fields', array()) as $fn) {
         $fields['custom_' . $fn] = $user->get($fn);
     }
     foreach ($addLists as $listId) {
         $ret = $this->doRequest(array('id' => $listId, 'full_name' => $user->getName(), 'split_name' => $user->getName(), 'email' => $email, 'subscription_type' => 'E') + $fields);
         if (!$ret) {
             return false;
         }
     }
     foreach ($deleteLists as $listId) {
         $ret = $this->doRequest(array('id' => $listId, 'full_name' => $user->getName(), 'split_name' => $user->getName(), 'email' => $email, 'subscription_type' => 'E', 'arp_action' => 'UNS'));
         if (!$ret) {
             return false;
         }
     }
     return true;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:25,代码来源:arp.php

示例4: check_addUser

 public function check_addUser($arguments)
 {
     $username = $arguments['username'];
     $password = $arguments['password'];
     $User = $arguments['User'];
     if (!in_array($this->node, $_SESSION['PluginsInstalled'])) {
         return;
     }
     foreach ($this->getClass('LDAPManager')->find() as $LDAP) {
         if ($LDAP->authLDAP($username, $password)) {
             $UserByName = current($this->getClass('UserManager')->find(array('name' => $username)));
             if ($UserByName) {
                 $arguments['User'] = $UserByName;
                 break;
             } else {
                 if (!$User || !$User->isValid()) {
                     $tmpUser = new User(array('name' => $username, 'type' => 1, 'password' => md5($password), 'createdBy' => 'fog'));
                     if (!$tmpUser->save()) {
                         throw new Exception('Database update failed');
                     }
                     $this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', _('User created'), $tmpUser->get('id'), $tmpUser->get('name')));
                     $arguments['User'] = $tmpUser;
                     break;
                 }
             }
         }
     }
 }
开发者ID:bramverstraten,项目名称:fogproject,代码行数:28,代码来源:LDAPPluginHook.hook.php

示例5: request_user_authorise

 /**
  * Process an authorization request.
  *
  * Operations:
  *     - Auto creates users.
  *     - Sets up user object for linked accounts.
  *
  * @param string $oidcuniqid The OIDC unique identifier received.
  * @param array $tokenparams Received token parameters.
  * @param \auth_oidc\jwt $idtoken Received id token.
  * @return bool Success/Failure.
  */
 public function request_user_authorise($oidcuniqid, $tokenparams, $idtoken)
 {
     global $USER, $SESSION;
     $this->must_be_ready();
     $username = $oidcuniqid;
     $email = $idtoken->claim('email');
     $firstname = $idtoken->claim('given_name');
     $lastname = $idtoken->claim('family_name');
     // Office 365 uses "upn".
     $upn = $idtoken->claim('upn');
     if (!empty($upn)) {
         $username = $upn;
         $email = $upn;
     }
     $create = false;
     try {
         $user = new \User();
         $user->find_by_instanceid_username($this->instanceid, $username, true);
         if ($user->get('suspendedcusr')) {
             die_info(get_string('accountsuspended', 'mahara', strftime(get_string('strftimedaydate'), $user->get('suspendedctime')), $user->get('suspendedreason')));
         }
     } catch (\AuthUnknownUserException $e) {
         if ($this->can_auto_create_users() === true) {
             $institution = new \Institution($this->institution);
             if ($institution->isFull()) {
                 throw new \XmlrpcClientException('OpenID Connect login attempt failed because the institution is full.');
             }
             $user = new \User();
             $create = true;
         } else {
             return false;
         }
     }
     if ($create === true) {
         $user->passwordchange = 0;
         $user->active = 1;
         $user->deleted = 0;
         $user->expiry = null;
         $user->expirymailsent = 0;
         $user->lastlogin = time();
         $user->firstname = $firstname;
         $user->lastname = $lastname;
         $user->email = $email;
         $user->authinstance = $this->instanceid;
         db_begin();
         $user->username = get_new_username($username);
         $user->id = create_user($user, array(), $this->institution, $this, $username);
         $userobj = $user->to_stdclass();
         $userarray = (array) $userobj;
         db_commit();
         $user = new User();
         $user->find_by_id($userobj->id);
     }
     $user->commit();
     $USER->reanimate($user->id, $this->instanceid);
     $SESSION->set('authinstance', $this->instanceid);
     return true;
 }
开发者ID:remotelearner,项目名称:mahara-auth_oidc,代码行数:70,代码来源:lib.php

示例6: panel

 function panel()
 {
     $this->load->model('user');
     $this->load->model('script');
     $this->load->library('facebook');
     if ($signedUp = $this->session->flashdata('signedUp')) {
         $this->session->keep_flashdata('signedUp');
         $viewData['signedUp'] = $signedUp;
     }
     if ($this->input->post('changePassword')) {
         if ($this->_checkToken()) {
             $this->load->library('validation');
             $rules['currentPassword'] = 'required';
             $rules['newPassword'] = 'required|min_length[6]';
             $rules['newPasswordRepeat'] = 'required|matches[newPassword]';
             $fields['currentPassword'] = 'current password';
             $fields['newPassword'] = 'new password';
             $fields['newPasswordRepeat'] = 'new password repeated';
             $this->validation->set_rules($rules);
             $this->validation->set_fields($fields);
             if ($this->validation->run() === true) {
                 $user = new User();
                 $user->setKey($this->_getUser());
                 $user->retrieve();
                 if ($user->get('password') === $user->makePass($this->input->post('currentPassword'))) {
                     $user->set('password', $user->makePass($this->input->post('newPassword')));
                     $viewData['checkpoints'][] = 'You have successfully changed your password.';
                     $user->update();
                 } else {
                     $viewData['errors'][] = 'You did not enter your current password correctly.';
                 }
             }
         }
     }
     $viewData['token'] = $this->_token();
     $user = new User();
     $script = new Script();
     $user->retrieve($this->session->userdata('email'));
     if ($user->getType() === User::FB_CONNECT) {
         $viewData['email'] = false;
         $viewData['UID'] = $user->getKey();
         $viewData['name'] = $user->name();
         $viewData['institution'] = $user->institution();
         if (!($subject = $user->subject())) {
             $subject = 'Not specified on Facebook';
         }
         $viewData['subject'] = $subject;
         $viewData['fbEmail'] = $user->get('fbEmail');
     } else {
         $viewData['email'] = $user->getKey();
         $viewData['name'] = $user->get('name');
         $user->get('subject') ? $viewData['subject'] = $user->get('subject') : ($viewData['subject'] = 'Not specified');
         $viewData['institution'] = $user->get('institution');
     }
     //$viewData['messages'][] = 'We are on day '.ceil((time() - 1229536800)/86400).' of the Exambuff pilot. Thanks for taking part!';
     $this->_template('user/panel', 'Your account', 'my-account', $viewData);
 }
开发者ID:cybercog,项目名称:exambuff,代码行数:57,代码来源:userpanel.php

示例7: create

 /**
  * Create a log object
  *
  * @access public
  * @param string $action
  * @param object $object
  */
 public static function create($action, $object = null)
 {
     // what class is it
     $classname = '';
     if (!is_null($object)) {
         $classname = strtolower(get_class($object));
     }
     $log = new self();
     try {
         $user = User::get();
         $log->user_id = $user->id;
     } catch (\Exception $e) {
         $log->user_id = 0;
     }
     if ($action == 'add') {
         $content = ucfirst($classname) . ' created';
     } elseif ($action == 'edit') {
         $content = ucfirst($classname) . ' edited';
     } else {
         $content = ucfirst($action);
     }
     $log->classname = $classname;
     $log->object_id = !is_null($object) ? $object->id : 0;
     $log->content = $content;
     $log->save();
     return $log;
 }
开发者ID:tigron,项目名称:skeleton,代码行数:34,代码来源:Log.php

示例8: user_id

 function user_id()
 {
     if ($this->users->is_connected()) {
         return User::get()->id;
     }
     return 0;
 }
开发者ID:2329697501,项目名称:tendoo-cms,代码行数:7,代码来源:aauth.php

示例9: isAuthorized

 public function isAuthorized()
 {
     if ($this->userLogged == TRUE && $this->params['prefix'] == User::get('type')) {
         return true;
     }
     return false;
 }
开发者ID:jcicero,项目名称:Comitiva,代码行数:7,代码来源:messages_controller.php

示例10: __getDataForLogs

 /**
  * Get the parameters given in Url
  * @return string url parameters
  * @access private
  */
 function __getDataForLogs($verbose = 1)
 {
     // build the data for the log entry
     $data = array('user_id' => User::get('id'), 'ip' => $this->Controller->RequestHandler->getClientIP(), 'resource_type' => 'controller', 'get_data_url' => implode(DS, $this->Controller->params['pass']));
     // clean up a bit on cakeerror
     if ($this->Controller->name != "CakeError") {
         $data['error'] = $this->error;
         $data['error_id'] = $this->errorCode;
         //$data['errorCode'] = $this->errorCode,
         $data['resource'] = strtolower($this->Controller->name);
         $data['action'] = $this->Controller->action;
     } else {
         $data['error'] = true;
         $data['resource'] = strtolower($this->Controller->params['controller']);
         $data['action'] = $this->Controller->params['action'];
     }
     // Better to remain silent and be thought a fool
     if (!empty($this->Controller->data)) {
         if ($verbose == 2) {
             $data['post_data'] = print_r($this->Controller->data, true);
         } elseif ($verbose == 1) {
             $data['post_data'] = count($this->Controller->data);
         }
     }
     // than to speak out and remove all doubt - MT
     $data['get_data_url'] = implode(DS, $this->Controller->params['pass']);
     $data['get_data_named'] = '';
     foreach ($this->Controller->params['named'] as $key => $value) {
         $data['get_data_named'] .= $key . ':' . $value . DS;
     }
     return $data;
 }
开发者ID:stripthis,项目名称:BlackRabbit,代码行数:37,代码来源:log.php

示例11: testPluginShouldStartAfterTwoSetup

 /**
  * @group no-saucelabs
  *
  * Scenario:  As an AP going through the setup two times, I should be able to login at the end of the second setup.
  * Given    I create an account as John Doe, and I proceed through the entire setup.
  * When     I register again with another username, and proceed again through the entire setup
  * Then     I should be able to see the login form
  * And      I should be able to login
  */
 public function testPluginShouldStartAfterTwoSetup()
 {
     // Reset database at the end of test.
     $this->resetDatabaseWhenComplete();
     // Register John Doe as a user.
     $john = User::get('john');
     $this->registerUser($john['FirstName'], $john['LastName'], $john['Username']);
     // Go to setup page.
     $this->goToSetup($john['Username']);
     // Wait until I see the setup section domain check.
     $this->waitForSection('domain_check');
     // I should not se any warning.
     $this->assertNotVisible('.plugin-check.warning');
     // Complete registration.
     $this->completeRegistration($john);
     // Switch config to secondary domain.
     $this->switchToSecondaryDomain();
     // Register Curtis Mayfield as a user.
     $curtis = User::get('curtis');
     $this->registerUser($curtis['FirstName'], $curtis['LastName'], $curtis['Username']);
     // Go to setup page.
     $this->goToSetup($curtis['Username'], false);
     // Wait until I see the setup section domain check.
     $this->waitForSection('domain_check');
     // Complete registration.
     $this->completeRegistration($curtis);
     // And I am logged in on the password workspace
     $this->loginAs($curtis);
     // wait for redirection trigger
     sleep(1);
     $this->waitCompletion();
     $this->assertElementContainsText($this->findByCss('.header .user.profile .details .name'), $curtis['FirstName'] . ' ' . $curtis['LastName']);
     // Switch back config to primary domain.
     $this->switchToPrimaryDomain();
 }
开发者ID:passbolt,项目名称:passbolt_selenium,代码行数:44,代码来源:PASSBOLT-1494_PluginDoesntStartAfterTwoSetupTest.php

示例12: edit

 /**
  * undocumented function
  *
  * @param string $id
  * @return void
  * @access public
  */
 function edit($id = null, $parentId = null)
 {
     $action = 'add';
     if ($this->action == 'edit') {
         $Comment = $this->Comment->find('first', array('conditions' => array('Comment.id' => $id)));
         Assert::notEmpty($Comment, '404');
         Assert::true($this->Comment->isOwn($Comment, 'Comment'), '403');
         $action = 'edit';
     } else {
         $Comment = $this->Comment->create();
     }
     $referer = $this->referer();
     $parentId = isset($this->params['named']['parent_id']) ? $this->params['named']['parent_id'] : false;
     $foreignId = isset($this->params['named']['foreign_id']) ? $this->params['named']['foreign_id'] : false;
     $this->set(compact('action', 'referer', 'parentId', 'foreignId'));
     $this->action = 'edit';
     if ($this->isGet()) {
         return $this->data = $Comment;
     }
     $this->data['Comment']['user_id'] = User::get('id');
     $this->Comment->set($this->data);
     $result = $this->Comment->save();
     if ($this->Comment->validationErrors) {
         $msg = __('There are problems with the form.', true);
         $this->Message->add($msg, 'error', true, $referer);
     }
     Assert::notEmpty($result);
     $msg = __('Successfully saved!', true);
     $this->Message->add($msg, 'ok', true, $this->data['Comment']['referer']);
 }
开发者ID:stripthis,项目名称:donate,代码行数:37,代码来源:comments_controller.php

示例13: format_time

 public static function format_time($timestamp, $date_only = false, $date_format = null, $time_format = null, $time_only = false, $no_text = false)
 {
     if ($timestamp == '') {
         return __('Never');
     }
     $diff = (User::get()->timezone + User::get()->dst) * 3600;
     $timestamp += $diff;
     $now = time();
     if (is_null($date_format)) {
         $date_format = Container::get('forum_date_formats')[User::get()->date_format];
     }
     if (is_null($time_format)) {
         $time_format = Container::get('forum_time_formats')[User::get()->time_format];
     }
     $date = gmdate($date_format, $timestamp);
     $today = gmdate($date_format, $now + $diff);
     $yesterday = gmdate($date_format, $now + $diff - 86400);
     if (!$no_text) {
         if ($date == $today) {
             $date = __('Today');
         } elseif ($date == $yesterday) {
             $date = __('Yesterday');
         }
     }
     if ($date_only) {
         return $date;
     } elseif ($time_only) {
         return gmdate($time_format, $timestamp);
     } else {
         return $date . ' ' . gmdate($time_format, $timestamp);
     }
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:32,代码来源:Utils.php

示例14: onAfterRoute

 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     // First, check for presence of subject dn, which is the minimum required field
     if (!isset($_SERVER['SSL_CLIENT_S_DN']) || !$_SERVER['SSL_CLIENT_S_DN']) {
         \App::redirect($this->params->get('failure_location', '/invalidcert.php'));
         return;
     }
     if (\User::isGuest()) {
         // If so, redirect to login
         Request::setVar('option', 'com_users');
         Request::setVar('task', 'user.login');
         Request::setVar('authenticator', 'certificate');
         Request::setVar('return', base64_encode(\Request::current()));
         return;
     }
     // Check if user is registered and if current session is linked to cert identity
     $hzad = \Hubzero\Auth\Domain::getInstance('authentication', 'certificate', $_SERVER['SSL_CLIENT_I_DN_CN']);
     if ($link = \Hubzero\Auth\Link::getInstance($hzad->id, $_SERVER['SSL_CLIENT_S_DN_CN'])) {
         if ($link->user_id == \User::get('id')) {
             // All clear...return nothing
             return;
         }
     }
     // Otherwise, we have a cert-based user that doesn't match the current user
     Request::setVar('option', 'com_users');
     Request::setVar('task', 'user.logout');
     $this->event->stop();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:33,代码来源:certificate.php

示例15: getFilters

 /**
  * Gets the request filters and returns them
  *
  * @param  string $namespace the application state variable namespace
  * @return array
  **/
 public static function getFilters($namespace)
 {
     // Process query filters
     $q = User::getState("{$namespace}.query");
     if ($incoming = Request::getVar('q', false)) {
         $q[] = $incoming;
     }
     // Set some defaults for the filters, if not set otherwise
     if (!is_array($q)) {
         $q[0]['column'] = $namespace == 'com_time.tasks' ? 'assignee_id' : 'user_id';
         $q[0]['operator'] = 'e';
         $q[0]['value'] = User::get('id');
     }
     // Translate operators and augment query filters with human-friendly text
     $query = self::filtersMap($q);
     // Turn search into array of results, if not already
     $search = Request::getVar('search', User::getState("{$namespace}.search", ''));
     // If we have a search and it's not an array (i.e. it's coming in fresh with this request)
     if ($search && !is_array($search)) {
         // Explode multiple words into array
         $search = explode(" ", $search);
         // Only allow alphabetical characters for search
         $search = preg_replace("/[^a-zA-Z]/", "", $search);
     }
     // Set some values in the session
     User::setState("{$namespace}.search", $search);
     User::setState("{$namespace}.query", $query);
     return array('search' => $search, 'q' => $query);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:35,代码来源:filters.php


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