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


PHP get_complete_user_data函数代码示例

本文整理汇总了PHP中get_complete_user_data函数的典型用法代码示例。如果您正苦于以下问题:PHP get_complete_user_data函数的具体用法?PHP get_complete_user_data怎么用?PHP get_complete_user_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_content

 public function get_content()
 {
     global $COURSE, $USER;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = var_export($this->context, true);
     $coursecontext = context_course::instance($COURSE->id);
     if (has_capability('block/demostudent:addinstance', $coursecontext)) {
         // If DemoStudent has not yet been enrolled, allow user to create/enrol one.
         $demostudentusername = generate_demostudent_name($USER->username);
         $demostudentuser = get_complete_user_data('username', $demostudentusername);
         if (!$demostudentuser || !is_enrolled($coursecontext, $demostudentuser)) {
             $this->render_view('firstuse');
         } else {
             $this->render_view('instructor');
         }
     } else {
         if (has_capability('block/demostudent:seedemostudentblock', $coursecontext)) {
             $this->render_view('demostudent');
         } else {
             // If the user does not need to see the block, do not display it at all.
             $this->content->text = '';
             $this->content->footer = '';
         }
     }
     return $this->content;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:29,代码来源:block_demostudent.php

示例2: user_update_password

 /**
  * Updates the user's password.
  *
  * called when the user password is updated.
  *
  * @param  object  $user        User table object
  * @param  string  $newpassword Plaintext password
  * @return boolean result
  *
  */
 function user_update_password($user, $newpassword)
 {
     $user = get_complete_user_data('id', $user->id);
     // This will also update the stored hash to the latest algorithm
     // if the existing hash is using an out-of-date algorithm (or the
     // legacy md5 algorithm).
     return update_internal_user_password($user, $newpassword);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:auth.php

示例3: get_info_for_enrolment_change

 /**
  * Return user info for this event.
  */
 private function get_info_for_enrolment_change($panopto, $relateduserid, $contextid)
 {
     global $DB;
     // DB userkey is "[instancename]\\[username]". Get username and use it to create key.
     $user = get_complete_user_data('id', $relateduserid);
     $username = $user->username;
     $userkey = $panopto->panopto_decorate_username($username);
     // Get contextID to determine user's role.
     $role = $this->get_role_from_context($contextid, $relateduserid);
     return array("role" => $role, "userkey" => $userkey);
 }
开发者ID:hitteshahuja,项目名称:Moodle-2.0-plugin-for-Panopto,代码行数:14,代码来源:update_user.php

示例4: validation

 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // Ensure we don't miss errors from any higher-level validation
     // Do our own validation and add errors to array
     foreach ($data as $key => $value) {
         if ($key == 'username') {
             $user = get_complete_user_data('username', $value);
             if ($user === false) {
                 $errors[$key] = get_string('user_not_found', 'local_obu_forms');
             }
         }
     }
     return $errors;
 }
开发者ID:OBU-OBIS,项目名称:moodle-local_obu_forms,代码行数:15,代码来源:user_input.php

示例5: verify_code

 public static function verify_code($code)
 {
     global $DB;
     //Parameter validation
     //REQUIRED
     $params = self::validate_parameters(self::verify_code_parameters(), array('code' => $code));
     $code = trim($params['code']);
     if (empty($code)) {
         throw new invalid_parameter_exception('Empty code');
     }
     if (!($issuecert = $DB->get_record('simplecertificate_issues', array('code' => $code)))) {
         throw new invalid_parameter_exception('Invalid code');
     }
     if (!($user = get_complete_user_data('id', $issuecert->userid))) {
         throw new moodle_exception('cannotfinduser', 'error', null, '');
     }
     return fullname($user);
 }
开发者ID:v--k,项目名称:moodle-mod_simplecertificate,代码行数:18,代码来源:externallib.php

示例6: validation

 function validation($data)
 {
     global $CFG;
     $errors = array();
     if (!empty($data['username']) and !empty($data['email']) or empty($data['username']) and empty($data['email'])) {
         $errors['username'] = get_string('usernameoremail');
         $errors['email'] = get_string('usernameoremail');
     } else {
         if (!empty($data['email'])) {
             if (!validate_email($data['email'])) {
                 $errors['email'] = get_string('invalidemail');
             } else {
                 if (count_records('user', 'email', $data['email']) > 1) {
                     $errors['email'] = get_string('forgottenduplicate');
                 } else {
                     if ($user = get_complete_user_data('email', $data['email'])) {
                         if (empty($user->confirmed)) {
                             $errors['email'] = get_string('confirmednot');
                         }
                     }
                     if (!$user and empty($CFG->protectusernames)) {
                         $errors['email'] = get_string('emailnotfound');
                     }
                 }
             }
         } else {
             if ($user = get_complete_user_data('username', $data['username'])) {
                 if (empty($user->confirmed)) {
                     $errors['email'] = get_string('confirmednot');
                 }
             }
             if (!$user and empty($CFG->protectusernames)) {
                 $errors['username'] = get_string('usernamenotfound');
             }
         }
     }
     if (0 == count($errors)) {
         return true;
     } else {
         return $errors;
     }
 }
开发者ID:veritech,项目名称:pare-project,代码行数:42,代码来源:forgot_password_form.php

示例7: signature

 public function signature($course, $user_id, $show_assessor)
 {
     $user = get_complete_user_data('id', $user_id);
     $output = html_writer::start_tag('div', array('class' => 'marksheet-sign'));
     if ($user) {
         $output .= html_writer::start_tag('div', array('class' => 'student-info'));
         $output .= html_writer::tag('h4', 'Participant’s Full Name: ' . $user->firstname . ' ' . $user->lastname);
         $output .= html_writer::tag('h4', 'Participant’s ID: ' . $user->alternatename);
         $output .= html_writer::end_tag('div');
     }
     if ($show_assessor) {
         $output .= html_writer::start_tag('div', array('class' => 'assessor-info'));
         $output .= html_writer::tag('h4', 'Assessors Name: ______________________________ ');
         $output .= html_writer::tag('h4', 'Assessor’s Signature: ______________________________ ');
         $output .= html_writer::tag('h4', 'Date: _____/_____/__________ ');
         $output .= html_writer::end_tag('div');
     }
     $output .= html_writer::end_tag('div');
     return $output;
 }
开发者ID:abhiahirwar,项目名称:moodle_plugin,代码行数:20,代码来源:renderer.php

示例8: validation

    function validation($data, $files) {
        global $CFG, $DB;

        $errors = parent::validation($data, $files);

        if ((!empty($data['username']) and !empty($data['email'])) or (empty($data['username']) and empty($data['email']))) {
            $errors['username'] = get_string('usernameoremail');
            $errors['email']    = get_string('usernameoremail');

        } else if (!empty($data['email'])) {
            if (!validate_email($data['email'])) {
                $errors['email'] = get_string('invalidemail');

            } else if ($DB->count_records('user', array('email'=>$data['email'])) > 1) {
                $errors['email'] = get_string('forgottenduplicate');

            } else {
                if ($user = get_complete_user_data('email', $data['email'])) {
                    if (empty($user->confirmed)) {
                        $errors['email'] = get_string('confirmednot');
                    }
                }
                if (!$user and empty($CFG->protectusernames)) {
                    $errors['email'] = get_string('emailnotfound');
                }
            }

        } else {
            if ($user = get_complete_user_data('username', $data['username'])) {
                if (empty($user->confirmed)) {
                    $errors['email'] = get_string('confirmednot');
                }
            }
            if (!$user and empty($CFG->protectusernames)) {
                $errors['username'] = get_string('usernamenotfound');
            }
        }

        return $errors;
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:40,代码来源:forgot_password_form.php

示例9: xmldb_block_repository_upgrade

function xmldb_block_repository_upgrade($oldversion = 0)
{
    $result = true;
    if ($oldversion < 2010090901) {
        $errors = false;
        $auths = block_repository_nopasswd_auths();
        $authlist = "'" . implode("', '", $auths) . "'";
        $users = get_records_select('user', "auth IN ({$authlist})", '', 'id, auth');
        if (!empty($users)) {
            foreach ($users as $user) {
                $user = get_complete_user_data('id', $user->id);
                $migrate_ok = block_repository_user_created($user);
                if (!$migrate_ok) {
                    $errors = true;
                    error_log("xmldb_block_repository_upgrade({$oldversion}) - failed migrating user ({$user->id}) to Alfresco.");
                }
            }
        }
        if (!$errors) {
            set_config('initialized', 1, repository_plugin_alfresco::$plugin_name);
        }
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.alfresco,代码行数:24,代码来源:upgrade.php

示例10: require_login

require_once './locallib.php';
require_once './mdl_redirect_form.php';
require_login();
$context = context_system::instance();
require_capability('local/obu_application:manage', $context);
// We only handle an existing application (id given)
if (isset($_REQUEST['id'])) {
    $application_id = $_REQUEST['id'];
} else {
    echo get_string('invalid_data', 'local_obu_application');
    die;
}
// We may have been given the email of the new approver
if (isset($_REQUEST['approver_email'])) {
    $approver_email = $_REQUEST['approver_email'];
    $approver = get_complete_user_data('email', $approver_email);
    if ($approver) {
        $approver_name = $approver->firstname . ' ' . $approver->lastname;
    } else {
        $approver_name = 'Not Registered';
    }
} else {
    $approver_email = '';
    $approver_name = '';
}
$home = new moodle_url('/');
$dir = $home . 'local/obu_application/';
$program = $dir . 'mdl_redirect.php?id=' . $application_id;
$heading = get_string('redirect_application', 'local_obu_application');
$PAGE->set_context($context);
$PAGE->set_pagelayout('standard');
开发者ID:OBU-OBIS,项目名称:moodle-local_obu_application,代码行数:31,代码来源:mdl_redirect.php

示例11: session_loginas

/**
 * Login as another user - no security checks here.
 * @param int $userid
 * @param stdClass $context
 * @return void
 */
function session_loginas($userid, $context)
{
    if (session_is_loggedinas()) {
        return;
    }
    // switch to fresh new $SESSION
    $_SESSION['REALSESSION'] = $_SESSION['SESSION'];
    $_SESSION['SESSION'] = new stdClass();
    /// Create the new $USER object with all details and reload needed capabilities
    $_SESSION['REALUSER'] = $_SESSION['USER'];
    $user = get_complete_user_data('id', $userid);
    $user->realuser = $_SESSION['REALUSER']->id;
    $user->loginascontext = $context;
    // let enrol plugins deal with new enrolments if necessary
    enrol_check_plugins($user);
    // set up global $USER
    session_set_user($user);
}
开发者ID:neogic,项目名称:moodle,代码行数:24,代码来源:sessionlib.php

示例12: print_error

    print_error("Info received. Finishing authentication process through regular method hook because no SAML response detected.");
    display_object($_POST);
    $USER = authenticate_user_login($saml_user[$saml_account_matcher], time());
}
// check that the signin worked
if ($USER == false) {
    print_error("You could not be identified or created. <br />Login result: FAILURE<br />I have...<br />" . htmlspecialchars(print_r($USER, true)));
    session_write_close();
    $USER = new object();
    $USER->id = 0;
    require_once '../../config.php';
    print_error('pluginauthfailed', 'auth_onelogin_saml', '', !empty($saml_user['username']) ? $saml_user['username'] : $saml_user['email']);
}
// complete the user login sequence
$USER->loggedin = true;
$USER->site = $CFG->wwwroot;
$USER = get_complete_user_data('id', $USER->id);
complete_user_login($USER);
// flag this as a SAML based login
$SESSION->isSAMLSessionControlled = true;
if (isset($wantsurl)) {
    // and (strpos($wantsurl, $CFG->wwwroot) === 0)
    $urltogo = clean_param($wantsurl, PARAM_URL);
} else {
    $urltogo = $CFG->wwwroot . '/';
}
if (!$urltogo || $urltogo == "") {
    $urltogo = $CFG->wwwroot . '/';
}
unset($SESSION->wantsurl);
redirect($urltogo, 0);
开发者ID:mfprimo,项目名称:moodle-onelogin,代码行数:31,代码来源:index.php

示例13: get_complete_user_data

 }
 $confirmed = $authplugin->user_confirm($username, $usersecret);
 if ($confirmed == AUTH_CONFIRM_ALREADY) {
     $user = get_complete_user_data('username', $username);
     print_header(get_string("alreadyconfirmed"), get_string("alreadyconfirmed"), array(), "");
     echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter');
     echo "<h3>" . get_string("thanks") . ", " . fullname($user) . "</h3>\n";
     echo "<p>" . get_string("alreadyconfirmed") . "</p>\n";
     echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/course/", null, get_string('courses')));
     echo $OUTPUT->box_end();
     echo $OUTPUT->footer();
     exit;
 } else {
     if ($confirmed == AUTH_CONFIRM_OK) {
         // The user has confirmed successfully, let's log them in
         if (!($user = get_complete_user_data('username', $username))) {
             print_error('cannotfinduser', '', '', $username);
         }
         complete_user_login($user);
         if (!empty($SESSION->wantsurl)) {
             // Send them where they were going
             $goto = $SESSION->wantsurl;
             unset($SESSION->wantsurl);
             redirect($goto);
         }
         print_header(get_string("confirmed"), get_string("confirmed"), array(), "");
         echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter');
         echo "<h3>" . get_string("thanks") . ", " . fullname($USER) . "</h3>\n";
         echo "<p>" . get_string("confirmed") . "</p>\n";
         echo $OUTPUT->button(html_form::make_button("{$CFG->wwwroot}/course/", null, get_string('courses')));
         echo $OUTPUT->box_end();
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:confirm.php

示例14: authenticate_user_login

/**
 * Authenticates a user against the chosen authentication mechanism
 *
 * Given a username and password, this function looks them
 * up using the currently selected authentication mechanism,
 * and if the authentication is successful, it returns a
 * valid $user object from the 'user' table.
 *
 * Uses auth_ functions from the currently active auth module
 *
 * After authenticate_user_login() returns success, you will need to
 * log that the user has logged in, and call complete_user_login() to set
 * the session up.
 *
 * Note: this function works only with non-mnet accounts!
 *
 * @param string $username  User's username (or also email if $CFG->authloginviaemail enabled)
 * @param string $password  User's password
 * @param bool $ignorelockout useful when guessing is prevented by other mechanism such as captcha or SSO
 * @param int $failurereason login failure reason, can be used in renderers (it may disclose if account exists)
 * @return stdClass|false A {@link $USER} object or false if error
 */
function authenticate_user_login($username, $password, $ignorelockout = false, &$failurereason = null)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/authlib.php";
    if ($user = get_complete_user_data('username', $username, $CFG->mnet_localhost_id)) {
        // we have found the user
    } else {
        if (!empty($CFG->authloginviaemail)) {
            if ($email = clean_param($username, PARAM_EMAIL)) {
                $select = "mnethostid = :mnethostid AND LOWER(email) = LOWER(:email) AND deleted = 0";
                $params = array('mnethostid' => $CFG->mnet_localhost_id, 'email' => $email);
                $users = $DB->get_records_select('user', $select, $params, 'id', 'id', 0, 2);
                if (count($users) === 1) {
                    // Use email for login only if unique.
                    $user = reset($users);
                    $user = get_complete_user_data('id', $user->id);
                    $username = $user->username;
                }
                unset($users);
            }
        }
    }
    $authsenabled = get_enabled_auth_plugins();
    if ($user) {
        // Use manual if auth not set.
        $auth = empty($user->auth) ? 'manual' : $user->auth;
        if (in_array($user->auth, $authsenabled)) {
            $authplugin = get_auth_plugin($user->auth);
            $authplugin->pre_user_login_hook($user);
        }
        if (!empty($user->suspended)) {
            $failurereason = AUTH_LOGIN_SUSPENDED;
            // Trigger login failed event.
            $event = \core\event\user_login_failed::create(array('userid' => $user->id, 'other' => array('username' => $username, 'reason' => $failurereason)));
            $event->trigger();
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Suspended Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        if ($auth == 'nologin' or !is_enabled_auth($auth)) {
            // Legacy way to suspend user.
            $failurereason = AUTH_LOGIN_SUSPENDED;
            // Trigger login failed event.
            $event = \core\event\user_login_failed::create(array('userid' => $user->id, 'other' => array('username' => $username, 'reason' => $failurereason)));
            $event->trigger();
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Disabled Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        $auths = array($auth);
    } else {
        // Check if there's a deleted record (cheaply), this should not happen because we mangle usernames in delete_user().
        if ($DB->get_field('user', 'id', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 1))) {
            $failurereason = AUTH_LOGIN_NOUSER;
            // Trigger login failed event.
            $event = \core\event\user_login_failed::create(array('other' => array('username' => $username, 'reason' => $failurereason)));
            $event->trigger();
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Deleted Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        // User does not exist.
        $auths = $authsenabled;
        $user = new stdClass();
        $user->id = 0;
    }
    if ($ignorelockout) {
        // Some other mechanism protects against brute force password guessing, for example login form might include reCAPTCHA
        // or this function is called from a SSO script.
    } else {
        if ($user->id) {
            // Verify login lockout after other ways that may prevent user login.
            if (login_is_lockedout($user)) {
                $failurereason = AUTH_LOGIN_LOCKOUT;
                // Trigger login failed event.
                $event = \core\event\user_login_failed::create(array('userid' => $user->id, 'other' => array('username' => $username, 'reason' => $failurereason)));
                $event->trigger();
                error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Login lockout:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
                return false;
            }
        } else {
//.........这里部分代码省略.........
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例15: optional_param

    $sessionstarted = optional_param('sessionstarted', 0, PARAM_BOOL);
    if (!$sessionstarted) {
        redirect("index.php?sessionstarted=1&lang={$CFG->lang}");
    } else {
        $sessionverify = optional_param('sessionverify', 0, PARAM_BOOL);
        if (!$sessionverify) {
            $SESSION->sessionverify = 1;
            redirect("index.php?sessionstarted=1&sessionverify=1&lang={$CFG->lang}");
        } else {
            if (empty($SESSION->sessionverify)) {
                print_error('installsessionerror', 'admin', "index.php?sessionstarted=1&lang={$CFG->lang}");
            }
            unset($SESSION->sessionverify);
        }
    }
    $adminuser = get_complete_user_data('username', 'admin');
    if ($adminuser->password === 'adminsetuppending') {
        // prevent installation hijacking
        if ($adminuser->lastip !== getremoteaddr()) {
            print_error('installhijacked', 'admin');
        }
        // login user and let him set password and admin details
        $adminuser->newadminuser = 1;
        message_set_default_message_preferences($adminuser);
        complete_user_login($adminuser, false);
        redirect("{$CFG->wwwroot}/user/editadvanced.php?id={$adminuser->id}");
        // Edit thyself
    } else {
        unset_config('adminsetuppending');
    }
} else {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:index.php


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