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


PHP user_not_fully_set_up函数代码示例

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


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

示例1: definition

 /**
  * Define the form.
  */
 public function definition()
 {
     global $CFG, $COURSE, $USER;
     $mform = $this->_form;
     $editoroptions = null;
     $filemanageroptions = null;
     $usernotfullysetup = user_not_fully_set_up($USER);
     if (!is_array($this->_customdata)) {
         throw new coding_exception('invalid custom data for user_edit_form');
     }
     $editoroptions = $this->_customdata['editoroptions'];
     $filemanageroptions = $this->_customdata['filemanageroptions'];
     $user = $this->_customdata['user'];
     $userid = $user->id;
     if (empty($user->country)) {
         // We must unset the value here so $CFG->country can be used as default one.
         unset($user->country);
     }
     // Accessibility: "Required" is bad legend text.
     $strgeneral = get_string('general');
     $strrequired = get_string('required');
     // Add some extra hidden fields.
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'course', $COURSE->id);
     $mform->setType('course', PARAM_INT);
     // Print the required moodle fields first.
     $mform->addElement('header', 'moodle', $strgeneral);
     // Shared fields.
     useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user);
     // Extra settigs.
     if (!empty($CFG->disableuserimages) || $usernotfullysetup) {
         $mform->removeElement('deletepicture');
         $mform->removeElement('imagefile');
         $mform->removeElement('imagealt');
     }
     // If the user isn't fully set up, let them know that they will be able to change
     // their profile picture once their profile is complete.
     if ($usernotfullysetup) {
         $userpicturewarning = $mform->createElement('warning', 'userpicturewarning', 'notifymessage', get_string('newpictureusernotsetup'));
         $enabledusernamefields = useredit_get_enabled_name_fields();
         if ($mform->elementExists('moodle_additional_names')) {
             $mform->insertElementBefore($userpicturewarning, 'moodle_additional_names');
         } else {
             if ($mform->elementExists('moodle_interests')) {
                 $mform->insertElementBefore($userpicturewarning, 'moodle_interests');
             } else {
                 $mform->insertElementBefore($userpicturewarning, 'moodle_optional');
             }
         }
         // This is expected to exist when the form is submitted.
         $imagefile = $mform->createElement('hidden', 'imagefile');
         $mform->insertElementBefore($imagefile, 'userpicturewarning');
     }
     // Next the customisable profile fields.
     profile_definition($mform, $userid);
     $this->add_action_buttons(false, get_string('updatemyprofile'));
     $this->set_data($user);
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:62,代码来源:edit_form.php

示例2: http_basic_login

/**
 * podcaster basic authentication 
 *
 * @author  Humboldt Universitaet zu Berlin
 *            Christoph Soergel <christoph.soergel@cms.hu-berlin.de>
 * @version 1.0
 * @package podcaster
 *
 */
function http_basic_login()
{
    global $USER;
    $realm = 'restricted';
    $userValid = false;
    if (isloggedin()) {
        return true;
    }
    $realm = 'restricted';
    if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
        $user = authenticate_user_login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
        do {
            if (!$user) {
                $realm = 'loginerror';
                break;
            }
            $USER = $user;
            // check whether the user should be changing password
            if (get_user_preferences('auth_forcepasswordchange', false)) {
                if ($passwordchangeurl != '') {
                    $realm = 'mustchangepassword';
                } else {
                    $realm = 'mustchangepassword_butnourl';
                }
                break;
            }
            // check wether user is fully setup
            if (user_not_fully_set_up($USER)) {
                $realm = 'notfullysetup';
                break;
            }
            return true;
        } while (false);
        unset($USER);
    }
    // no credentials
    header('WWW-Authenticate: Basic realm="' . get_string($realm, 'podcaster') . '"');
    header('HTTP/1.0 401 Unauthorized');
    echo get_string($realm, 'podcaster');
    exit;
}
开发者ID:NextEinstein,项目名称:riverhills,代码行数:50,代码来源:basic.php

示例3: message_popup_render_navbar_output

/**
 * Renders the popup.
 *
 * @param renderer_base $renderer
 * @return string The HTML
 */
function message_popup_render_navbar_output(\renderer_base $renderer)
{
    global $USER, $CFG;
    // Early bail out conditions.
    if (!isloggedin() || isguestuser() || user_not_fully_set_up($USER) || get_user_preferences('auth_forcepasswordchange') || $CFG->sitepolicy && !$USER->policyagreed && !is_siteadmin()) {
        return '';
    }
    $output = '';
    // Add the messages popover.
    if (!empty($CFG->messaging)) {
        $context = ['userid' => $USER->id, 'urls' => ['seeall' => (new moodle_url('/message/index.php'))->out(), 'writeamessage' => (new moodle_url('/message/index.php', ['contactsfirst' => 1]))->out(), 'preferences' => (new moodle_url('/message/edit.php', ['id' => $USER->id]))->out()]];
        $output .= $renderer->render_from_template('message_popup/message_popover', $context);
    }
    // Add the notifications popover.
    $enabled = \core_message\api::is_processor_enabled("popup");
    if ($enabled) {
        $context = ['userid' => $USER->id, 'urls' => ['seeall' => (new moodle_url('/message/output/popup/notifications.php'))->out(), 'preferences' => (new moodle_url('/message/notificationpreferences.php', ['userid' => $USER->id]))->out()]];
        $output .= $renderer->render_from_template('message_popup/notification_popover', $context);
    }
    return $output;
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:27,代码来源:lib.php

示例4: message_popup_render_navbar_output

/**
 * Renders the popup.
 *
 * @param renderer_base $renderer
 * @return string The HTML
 */
function message_popup_render_navbar_output(\renderer_base $renderer)
{
    global $USER, $DB, $CFG;
    // Early bail out conditions.
    if (!isloggedin() || isguestuser() || user_not_fully_set_up($USER) || get_user_preferences('auth_forcepasswordchange')) {
        return '';
    }
    $output = '';
    // Add the messages popover.
    if (!empty($CFG->messaging)) {
        $context = ['userid' => $USER->id, 'urls' => ['preferences' => (new moodle_url('/message/edit.php', ['id' => $USER->id]))->out()]];
        $output .= $renderer->render_from_template('message_popup/message_popover', $context);
    }
    // Add the notifications popover.
    $processor = $DB->get_record('message_processors', array('name' => 'popup'));
    if ($processor && $processor->enabled) {
        $context = ['userid' => $USER->id, 'urls' => ['preferences' => (new moodle_url('/message/notificationpreferences.php', ['userid' => $USER->id]))->out()]];
        $output .= $renderer->render_from_template('message_popup/notification_popover', $context);
    }
    return $output;
}
开发者ID:dg711,项目名称:moodle,代码行数:27,代码来源:lib.php

示例5: user_authenticated_hook


//.........这里部分代码省略.........
         // Added to fix navigation
         $navlinks = array(array('name' => 'test', 'link' => null, 'type' => 'misc'));
         $navigation = build_navigation($navlinks);
         update_login_count();
         if ($user) {
             // language setup
             if ($user->username == 'guest') {
                 // no predefined language for guests - use existing session or default site lang
                 unset($user->lang);
             } else {
                 if (!empty($user->lang)) {
                     // unset previous session language - use user preference instead
                     unset($SESSION->lang);
                 }
             }
             if (empty($user->confirmed)) {
                 // This account was never confirmed
                 print_header(get_string("mustconfirm"), get_string("mustconfirm"));
                 print_heading(get_string("mustconfirm"));
                 print_simple_box(get_string("emailconfirmsent", "", $user->email), "center");
                 print_footer();
                 die;
             }
             // TODO : Fix this bug frm isn't on this page here
             if (isset($frm)) {
                 // if isset placed here for now
                 if ($frm->password == 'changeme') {
                     //force the change
                     set_user_preference('auth_forcepasswordchange', true, $user->id);
                 }
             }
             // end of if issuet
             /// Let's get them all set up.
             add_to_log(SITEID, 'user', 'login', "view.php?id={$USER->id}&course=" . SITEID, $user->id, 0, $user->id);
             $USER = complete_user_login($user);
             /// Prepare redirection
             if (user_not_fully_set_up($USER)) {
                 $urltogo = $CFG->wwwroot . '/user/edit.php';
                 // We don't delete $SESSION->wantsurl yet, so we get there later
             } else {
                 if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                     $urltogo = $SESSION->wantsurl;
                     /// Because it's an address in this site
                     unset($SESSION->wantsurl);
                 } else {
                     // no wantsurl stored or external - go to homepage
                     $urltogo = $CFG->wwwroot . '/';
                     unset($SESSION->wantsurl);
                 }
             }
             /// Go to my-moodle page instead of homepage if mymoodleredirect enabled
             if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !empty($CFG->mymoodleredirect) and !isguest()) {
                 if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot . '/' or $urltogo == $CFG->wwwroot . '/index.php') {
                     $urltogo = $CFG->wwwroot . '/my/';
                 }
             }
             /// check if user password has expired
             /// Currently supported only for ldap-authentication module
             $userauth = get_auth_plugin($USER->auth);
             if (!empty($userauth->config->expiration) and $userauth->config->expiration == 1) {
                 if ($userauth->can_change_password()) {
                     $passwordchangeurl = $userauth->change_password_url();
                 } else {
                     $passwordchangeurl = $CFG->httpswwwroot . '/login/change_password.php';
                 }
                 $days2expire = $userauth->password_expire($USER->username);
                 if (intval($days2expire) > 0 && intval($days2expire) < intval($userauth->config->expiration_warning)) {
                     print_header("{$site->fullname}: {$loginsite}", "{$site->fullname}", $navigation, '', '', true, "<div class=\"langmenu\">{$langmenu}</div>");
                     notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
                     print_footer();
                     exit;
                 } elseif (intval($days2expire) < 0) {
                     print_header("{$site->fullname}: {$loginsite}", "{$site->fullname}", $navigation, '', '', true, "<div class=\"langmenu\">{$langmenu}</div>");
                     notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
                     print_footer();
                     exit;
                 }
             }
             reset_login_count();
             // END of the regular Moodle Login Procedures
             // Process the SAML Request and redirect to the Service
             // it is asking for.
             // This function should never return unless there's an error.
             if (!gsaml_send_auth_response($SESSION->samlrequestdata)) {
                 // SAML code failed turn debugging on
                 error(get_string('samlcodefailed', 'auth_gsaml'));
             }
         } else {
             if (empty($errormsg)) {
                 $errormsg = get_string("invalidlogin");
                 $errorcode = 3;
             }
             // TODO: if the user failed to authenticate, check if the username corresponds to a remote mnet user
             if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode === 'strict' && is_enabled_auth('mnet')) {
                 $errormsg .= get_string('loginlinkmnetuser', 'mnet', "mnet_email.php?u={$frm->username}");
             }
         }
     }
     // else if NO SAML request is made we don't do anything but log in normally
 }
开发者ID:stefanotirati,项目名称:moodle-google-apps,代码行数:101,代码来源:auth.php

示例6: test_profile_has_required_custom_fields_set

 /**
  * Test that {@link user_not_fully_set_up()} takes required custom fields into account.
  */
 public function test_profile_has_required_custom_fields_set()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/mnet/lib.php';
     $this->resetAfterTest();
     // Add a required, visible, unlocked custom field.
     $DB->insert_record('user_info_field', ['shortname' => 'house', 'name' => 'House', 'required' => 1, 'visible' => 1, 'locked' => 0, 'categoryid' => 1, 'datatype' => 'text']);
     // Add an optional, visible, unlocked custom field.
     $DB->insert_record('user_info_field', ['shortname' => 'pet', 'name' => 'Pet', 'required' => 0, 'visible' => 1, 'locked' => 0, 'categoryid' => 1, 'datatype' => 'text']);
     // Add required but invisible custom field.
     $DB->insert_record('user_info_field', ['shortname' => 'secretid', 'name' => 'Secret ID', 'required' => 1, 'visible' => 0, 'locked' => 0, 'categoryid' => 1, 'datatype' => 'text']);
     // Add required but locked custom field.
     $DB->insert_record('user_info_field', ['shortname' => 'muggleborn', 'name' => 'Muggle-born', 'required' => 1, 'visible' => 1, 'locked' => 1, 'categoryid' => 1, 'datatype' => 'checkbox']);
     // Create some student accounts.
     $hermione = $this->getDataGenerator()->create_user();
     $harry = $this->getDataGenerator()->create_user();
     $ron = $this->getDataGenerator()->create_user();
     $draco = $this->getDataGenerator()->create_user();
     // Hermione has all available custom fields filled (of course she has).
     profile_save_data((object) ['id' => $hermione->id, 'profile_field_house' => 'Gryffindor']);
     profile_save_data((object) ['id' => $hermione->id, 'profile_field_pet' => 'Crookshanks']);
     // Harry has only the optional field filled.
     profile_save_data((object) ['id' => $harry->id, 'profile_field_pet' => 'Hedwig']);
     // Draco has only the required field filled.
     profile_save_data((object) ['id' => $draco->id, 'profile_field_house' => 'Slytherin']);
     // Only students with required fields filled should be considered as fully set up in the default (strict) mode.
     $this->assertFalse(user_not_fully_set_up($hermione));
     $this->assertFalse(user_not_fully_set_up($draco));
     $this->assertTrue(user_not_fully_set_up($harry));
     $this->assertTrue(user_not_fully_set_up($ron));
     // In the lax mode, students do not need to have required fields filled.
     $this->assertFalse(user_not_fully_set_up($hermione, false));
     $this->assertFalse(user_not_fully_set_up($draco, false));
     $this->assertFalse(user_not_fully_set_up($harry, false));
     $this->assertFalse(user_not_fully_set_up($ron, false));
     // Lack of required core field is seen as a problem in either mode.
     unset($hermione->email);
     $this->assertTrue(user_not_fully_set_up($hermione, true));
     $this->assertTrue(user_not_fully_set_up($hermione, false));
     // When confirming remote MNet users, we do not have custom fields available.
     $roamingharry = mnet_strip_user($harry, ['firstname', 'lastname', 'email']);
     $roaminghermione = mnet_strip_user($hermione, ['firstname', 'lastname', 'email']);
     $this->assertTrue(user_not_fully_set_up($roamingharry, true));
     $this->assertFalse(user_not_fully_set_up($roamingharry, false));
     $this->assertTrue(user_not_fully_set_up($roaminghermione, true));
     $this->assertTrue(user_not_fully_set_up($roaminghermione, false));
 }
开发者ID:janeklb,项目名称:moodle,代码行数:50,代码来源:profilelib_test.php

示例7: stdClass

/// If we can find the Shibboleth attribute, save it in session and return to main login page
if (!empty($_SERVER[$pluginconfig->user_attribute])) {
    // Shibboleth auto-login
    $frm = new stdClass();
    $frm->username = strtolower($_SERVER[$pluginconfig->user_attribute]);
    // The password is never actually used, but needs to be passed to the functions 'user_login' and
    // 'authenticate_user_login'. Shibboleth returns true for the function 'prevent_local_password', which is
    // used when setting the password in 'update_internal_user_password'. When 'prevent_local_password'
    // returns true, the password is set to 'not cached' (AUTH_PASSWORD_NOT_CACHED) in the Moodle DB. However,
    // rather than setting the password to a hard-coded value, we will generate one each time, in case there are
    // changes to the Shibboleth plugin and it is actually used.
    $frm->password = generate_password(8);
    /// Check if the user has actually submitted login data to us
    if ($shibbolethauth->user_login($frm->username, $frm->password) && ($user = authenticate_user_login($frm->username, $frm->password))) {
        complete_user_login($user);
        if (user_not_fully_set_up($USER, true)) {
            $urltogo = $CFG->wwwroot . '/user/edit.php?id=' . $USER->id . '&amp;course=' . SITEID;
            // We don't delete $SESSION->wantsurl yet, so we get there later
        } else {
            if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                $urltogo = $SESSION->wantsurl;
                /// Because it's an address in this site
                unset($SESSION->wantsurl);
            } else {
                $urltogo = $CFG->wwwroot . '/';
                /// Go to the standard home page
                unset($SESSION->wantsurl);
                /// Just in case
            }
        }
        /// Go to my-moodle page instead of homepage if defaulthomepage enabled
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:index.php

示例8: _open_account

 /**
  * Open user account using SREG & AX data if available
  * If no matching user found and create flag is true, creates new user account
  *
  * @access private
  * @param object &$resp An OpenID consumer response object
  * @param boolean $create_flag - set if account creation permitted, default: true
  * @uses $CFG
  * @uses $USER
  * @uses $openid_tmp_login
  * @return object The new user
  */
 function _open_account(&$resp, $create_flag = true)
 {
     global $CFG, $USER, $openid_tmp_login;
     $url = $resp->identity_url;
     $password = hash_internal_user_password('openid');
     $server = $resp->endpoint->server_url;
     $user = openid_resp_to_user($resp);
     if ($user == false) {
         // multiple matches to users! Don't know which user to pick.
         print_error('auth_openid_multiple_matches', 'auth_openid');
         return false;
         // won't get here.
     }
     if (isset($user->id)) {
         $openid_tmp_login = true;
         $openid_action = 'change';
         if ($user->auth == 'openid') {
             if (empty($this->config->auth_openid_allow_muliple)) {
                 print_error('auth_openid_no_multiple', 'auth_openid');
                 return false;
             }
             $openid_action = 'append';
         } else {
             if (empty($this->config->auth_openid_confirm_switch)) {
                 openid_if_unique_change_account($user, $url);
                 return $USER;
             }
         }
         $USER = clone $user;
         // To clone or not to clone
         //$mode = optional_param('openid_mode', null);
         //error_log("auth/openid/auth.php::_open_account() setting openid_mode={$mode} (openid_process_url={$openid_process_url})");
         redirect("{$CFG->wwwroot}/auth/openid/actions.php?openid_tmp_login=1&openid_action={$openid_action}&openid_url={$url}");
         // Try to get it not to make second request to be accepted, double confirm - TBD: openid_mode=???
     }
     if (!$create_flag) {
         // Error: This site is configured to disallow new users via OpenID
         print_error('auth_openid_require_account', 'auth_openid');
         return false;
         // won't get here.
     }
     $usertmp = create_user_record($user->username, $password, 'openid');
     $user->id = $usertmp->id;
     openid_append_url($user, $url);
     if (!isset($user->city) || $user->city == '') {
         //use "*" as the default city name
         $user->city = '*';
     }
     if (empty($user->country) && !empty($CFG->country)) {
         //use the configured default country code
         $user->country = $CFG->country;
     }
     if (empty($user->country)) {
         //out of other options, to try to copy the admin's country
         if ($admin = get_admin()) {
             $user->country = $admin->country;
         }
     }
     update_record('user', $user);
     $user = get_complete_user_data('id', $user->id);
     events_trigger('user_created', $user);
     // BJB120125 - moved from below redirect for alfresco, etc...
     if (function_exists('on_openid_create_account')) {
         on_openid_create_account($resp, $user);
     }
     // Redirect the user to their profile page if not set up properly
     if (!empty($user) && user_not_fully_set_up($user)) {
         $USER = clone $user;
         $urltogo = $CFG->wwwroot . '/user/edit.php';
         redirect($urltogo);
     }
     if (openid_server_requires_confirm($server, $this->config)) {
         $secret = random_string(15);
         set_field('user', 'secret', $secret, 'id', $user->id);
         $user->secret = $secret;
         set_field('user', 'confirmed', 0, 'id', $user->id);
         $user->confirmed = 0;
         openid_send_confirmation_email($user);
     }
     return $user;
 }
开发者ID:remotelearner,项目名称:elis.openid,代码行数:93,代码来源:auth.php

示例9: ntlmsso_finish

 /**
  * Find the session set by ntlmsso_magic(), validate it and
  * call authenticate_user_login() to authenticate the user through
  * the auth machinery.
  *
  * It is complemented by a similar check in user_login().
  *
  * If it succeeds, it never returns.
  *
  */
 function ntlmsso_finish()
 {
     global $CFG, $USER, $SESSION;
     $key = sesskey();
     $cf = get_cache_flags($this->pluginconfig . '/ntlmsess');
     if (!isset($cf[$key]) || $cf[$key] === '') {
         return false;
     }
     $username = $cf[$key];
     // Here we want to trigger the whole authentication machinery
     // to make sure no step is bypassed...
     $user = authenticate_user_login($username, $key);
     if ($user) {
         complete_user_login($user);
         // Cleanup the key to prevent reuse...
         // and to allow re-logins with normal credentials
         unset_cache_flag($this->pluginconfig . '/ntlmsess', $key);
         // Redirection
         if (user_not_fully_set_up($USER)) {
             $urltogo = $CFG->wwwroot . '/user/edit.php';
             // We don't delete $SESSION->wantsurl yet, so we get there later
         } else {
             if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                 $urltogo = $SESSION->wantsurl;
                 // Because it's an address in this site
                 unset($SESSION->wantsurl);
             } else {
                 // No wantsurl stored or external - go to homepage
                 $urltogo = $CFG->wwwroot . '/';
                 unset($SESSION->wantsurl);
             }
         }
         // We do not want to redirect if we are in a PHPUnit test.
         if (!PHPUNIT_TEST) {
             redirect($urltogo);
         }
     }
     // Should never reach here.
     return false;
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:50,代码来源:auth.php

示例10: tabobject

        $toprow[] = new tabobject('roles', $CFG->wwwroot . '/' . $CFG->admin . '/roles/usersroles.php?userid=' . $user->id . '&amp;courseid=' . $course->id, get_string('roles'));
        if (in_array($currenttab, array('usersroles', 'assign', 'override', 'check'))) {
            $inactive = array('roles');
            $activetwo = array('roles');
            $secondrow = array();
            $secondrow[] = new tabobject('usersroles', $CFG->wwwroot . '/' . $CFG->admin . '/roles/usersroles.php?userid=' . $user->id . '&amp;courseid=' . $course->id, get_string('thisusersroles', 'role'));
            if (!empty($assignableroles) || $currenttab == 'assign') {
                $secondrow[] = new tabobject('assign', $CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php?contextid=' . $usercontext->id . '&amp;userid=' . $user->id . '&amp;courseid=' . $course->id, get_string('assignrolesrelativetothisuser', 'role'), '', true);
            }
            if (!empty($overridableroles) || $currenttab == 'override') {
                $secondrow[] = new tabobject('override', $CFG->wwwroot . '/' . $CFG->admin . '/roles/override.php?contextid=' . $usercontext->id . '&amp;userid=' . $user->id . '&amp;courseid=' . $course->id, get_string('overridepermissions', 'role'), '', true);
            }
            if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:assign'), $usercontext)) {
                $secondrow[] = new tabobject('check', $CFG->wwwroot . '/' . $CFG->admin . '/roles/check.php?contextid=' . $usercontext->id . '&amp;userid=' . $user->id . '&amp;courseid=' . $course->id, get_string('checkpermissions', 'role'));
            }
        }
    }
}
/// Add second row to display if there is one
if (!empty($secondrow)) {
    $tabs = array($toprow, $secondrow);
} else {
    $tabs = array($toprow);
}
if ($currenttab == 'editprofile' && $user->id == $USER->id && user_not_fully_set_up($USER)) {
    /// We're being forced here to fix profile
    notify(get_string('moreprofileinfoneeded'));
} else {
    /// Print out the tabs and continue!
    print_tabs($tabs, $currenttab, $inactive, $activetwo);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:tabs.php

示例11: core_login_get_return_url

/**  Determine where a user should be redirected after they have been logged in.
 * @return string url the user should be redirected to.
 */
function core_login_get_return_url()
{
    global $CFG, $SESSION, $USER;
    // Prepare redirection.
    if (user_not_fully_set_up($USER)) {
        $urltogo = $CFG->wwwroot . '/user/edit.php';
        // We don't delete $SESSION->wantsurl yet, so we get there later.
    } else {
        if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0 or strpos($SESSION->wantsurl, str_replace('http://', 'https://', $CFG->wwwroot)) === 0)) {
            $urltogo = $SESSION->wantsurl;
            // Because it's an address in this site.
            unset($SESSION->wantsurl);
        } else {
            // No wantsurl stored or external - go to homepage.
            $urltogo = $CFG->wwwroot . '/';
            unset($SESSION->wantsurl);
        }
    }
    // If the url to go to is the same as the site page, check for default homepage.
    if ($urltogo == $CFG->wwwroot . '/') {
        $homepage = get_home_page();
        // Go to my-moodle page instead of site homepage if defaulthomepage set to homepage_my.
        if ($homepage == HOMEPAGE_MY && !is_siteadmin() && !isguestuser()) {
            if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot . '/' or $urltogo == $CFG->wwwroot . '/index.php') {
                $urltogo = $CFG->wwwroot . '/my/';
            }
        }
    }
    return $urltogo;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:33,代码来源:lib.php

示例12: loginpage_hook

 function loginpage_hook()
 {
     global $CFG, $SESSION, $DB, $USER;
     require_once $CFG->dirroot . '/auth/vatsim/config.php';
     // initiate the SSO class with consumer details and encryption details
     $SSO = new SSO($sso['base'], $sso['key'], $sso['secret'], $sso['method'], $sso['cert']);
     // return variable is needed later in this script
     $sso_return = $sso['return'];
     // remove other config variables
     unset($sso);
     // if VATSIM has redirected the member back
     if (isset($_GET['oauth_verifier']) && !isset($_GET['oauth_cancel'])) {
         // check to make sure there is a saved token for this user
         if (isset($_SESSION[SSO_SESSION]) && isset($_SESSION[SSO_SESSION]['key']) && isset($_SESSION[SSO_SESSION]['secret'])) {
             if (@$_GET['oauth_token'] != $_SESSION[SSO_SESSION]['key']) {
                 throw new moodle_exception("An error occurred with the login process - please try again", 'auth_vatsim');
             }
             if (@(!isset($_GET['oauth_verifier']))) {
                 throw new moodle_exception("An error occurred with the login process", 'auth_vatsim');
             }
             // obtain the details of this user from VATSIM
             $vatsimUser = $SSO->checkLogin($_SESSION[SSO_SESSION]['key'], $_SESSION[SSO_SESSION]['secret'], @$_GET['oauth_verifier']);
             if ($vatsimUser) {
                 // One-time use of tokens, token no longer valid
                 unset($_SESSION[SSO_SESSION]);
                 $vatsim = $vatsimUser->user;
                 //print_r($user->user);
                 $username = $vatsim->id;
                 // plugin only designed where email address is returned, if no email specified,
                 if (@empty($vatsim->email)) {
                     throw new moodle_exception('noemail', "auth_vatsim");
                 }
                 $useremail = $vatsim->email;
                 // find the user in the current database, by CID, not email
                 $user = $DB->get_record('user', array('username' => $username, 'deleted' => 0, 'mnethostid' => $CFG->mnet_localhost_id));
                 // create the user if it doesn't exist
                 if (empty($user)) {
                     // deny login if setting "Prevent account creation when authenticating" is on
                     if ($CFG->authpreventaccountcreation) {
                         throw new moodle_exception("noaccountyet", "auth_vatsim");
                     }
                     //retrieve more information from the provider
                     $newuser = new stdClass();
                     $newuser->email = $useremail;
                     $newuser->firstname = $vatsim->name_first;
                     $newuser->lastname = $vatsim->name_last;
                     $newuser->country = $vatsim->country->code;
                     create_user_record($username, '', 'vatsim');
                 } else {
                     $username = $user->username;
                 }
                 add_to_log(SITEID, 'auth_vatsim', '', '', $username . '/' . $useremail);
                 $user = authenticate_user_login($username, null);
                 if ($user) {
                     //prefill more user information if new user
                     if (!empty($newuser)) {
                         $newuser->id = $user->id;
                         $DB->update_record('user', $newuser);
                         $user = (object) array_merge((array) $user, (array) $newuser);
                     }
                     complete_user_login($user);
                     // Redirection
                     if (user_not_fully_set_up($USER)) {
                         $urltogo = $CFG->wwwroot . '/user/edit.php';
                         // We don't delete $SESSION->wantsurl yet, so we get there later
                     } else {
                         if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                             $urltogo = $SESSION->wantsurl;
                             // Because it's an address in this site
                             unset($SESSION->wantsurl);
                         } else {
                             // No wantsurl stored or external - go to homepage
                             $urltogo = $CFG->wwwroot . '/';
                             unset($SESSION->wantsurl);
                         }
                     }
                     redirect($urltogo);
                 }
             } else {
                 // OAuth or cURL errors have occurred
                 //$error = $SSO->error();
                 throw new moodle_exception("An error occurred with the login process", 'auth_vatsim');
             }
         }
         // the user cancelled their login and were sent back
     } else {
         if (isset($_GET['oauth_cancel'])) {
             throw new moodle_exception("You cancelled your login", 'auth_vatsim');
         }
     }
     // create a request token for this login. Provides return URL and suspended/inactive settings
     $token = $SSO->requestToken($sso_return, false, false);
     if ($token) {
         // store the token information in the session so that we can retrieve it when the user returns
         $_SESSION[SSO_SESSION] = array('key' => (string) $token->token->oauth_token, 'secret' => (string) $token->token->oauth_token_secret);
         // redirect the member to VATSIM
         $SSO->sendToVatsim();
     } else {
         throw new moodle_exception("An error occurred with the login process", 'auth_vatsim');
     }
//.........这里部分代码省略.........
开发者ID:KHardern,项目名称:VATSIM-Moodle,代码行数:101,代码来源:auth.php

示例13: ntlmsso_finish

 /**
  * Find the session set by ntlmsso_magic(), validate it and 
  * call authenticate_user_login() to authenticate the user through
  * the auth machinery.
  * 
  * It is complemented by a similar check in user_login().
  * 
  * If it succeeds, it never returns. 
  *
  */
 function ntlmsso_finish()
 {
     global $CFG, $USER, $SESSION;
     $key = sesskey();
     $cf = get_cache_flags('auth/ldap/ntlmsess');
     if (!isset($cf[$key]) || $cf[$key] === '') {
         return false;
     }
     $username = $cf[$key];
     // Here we want to trigger the whole authentication machinery
     // to make sure no step is bypassed...
     $user = authenticate_user_login($username, $key);
     if ($user) {
         add_to_log(SITEID, 'user', 'login', "view.php?id={$USER->id}&course=" . SITEID, $user->id, 0, $user->id);
         $USER = complete_user_login($user);
         // Cleanup the key to prevent reuse...
         // and to allow re-logins with normal credentials
         unset_cache_flag('auth/ldap/ntlmsess', $key);
         /// Redirection
         if (user_not_fully_set_up($USER)) {
             $urltogo = $CFG->wwwroot . '/user/edit.php';
             // We don't delete $SESSION->wantsurl yet, so we get there later
         } else {
             if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                 $urltogo = $SESSION->wantsurl;
                 /// Because it's an address in this site
                 unset($SESSION->wantsurl);
             } else {
                 // no wantsurl stored or external - go to homepage
                 $urltogo = $CFG->wwwroot . '/';
                 unset($SESSION->wantsurl);
             }
         }
         redirect($urltogo);
     }
     // Should never reach here.
     return false;
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:48,代码来源:auth.php

示例14: is_user_setup

 /**
  * Determines whether a user is fully set up, using cached results where possible.
  *
  * @since 3.2.0
  * @param \stdClass $user the user record.
  * @return bool true if the user is fully set up, false otherwise.
  */
 protected function is_user_setup($user)
 {
     if (!isset($this->userssetupcache[$user->id])) {
         $this->userssetupcache[$user->id] = !user_not_fully_set_up($user);
     }
     return $this->userssetupcache[$user->id];
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:check_subscriptions.php

示例15: loginpage_hook


//.........这里部分代码省略.........
                 $user_social_uid_custom_field->data = $social_uid;
                 if (!$DB->record_exists('user_info_data', array('userid' => $user_lenauth->id, 'fieldid' => $this->_field_id))) {
                     $DB->insert_record('user_info_data', $user_social_uid_custom_field);
                 } else {
                     $record = $DB->get_record('user_info_data', array('userid' => $user_lenauth->id, 'fieldid' => $this->_field_id));
                     $user_social_uid_custom_field->id = $record->id;
                     $DB->update_record('user_info_data', $user_social_uid_custom_field);
                 }
             }
             //add_to_log( SITEID, 'auth_lenauth', '', '', $username . '/' . $user_email . '/' . $userid );
             // complete Authenticate user
             authenticate_user_login($username, null);
             // fill $newuser object with response data from webservices
             $newuser = new stdClass();
             if (!empty($user_email)) {
                 $newuser->email = $user_email;
             }
             if (!empty($first_name)) {
                 $newuser->firstname = $first_name;
             }
             if (!empty($last_name)) {
                 $newuser->lastname = $last_name;
             }
             if (!empty($this->_oauth_config->auth_lenauth_default_country)) {
                 $newuser->country = $this->_oauth_config->auth_lenauth_default_country;
             }
             if ($user_lenauth) {
                 // update user record
                 if (!empty($newuser)) {
                     $newuser->id = $user_lenauth->id;
                     /*require_once( $CFG->libdir . '/gdlib.php' );
                     
                                                 $fs = get_file_storage();
                                                 $file_obj = $fs->create_file_from_url( array(
                                                     'contextid' => context_user::instance( $newuser->id, MUST_EXIST )->id,
                                                     'component' => 'user',
                                                     'filearea'  => 'icon',
                                                     'itemid'    => 0,
                                                     'filepath'  => '/',
                                                     'source'    => '',
                                                     'filename'  => 'f' . $newuser->id . '.' . $ext
                                                 ), $image_url );
                                                 //$newuser->picture = $file_obj->get_id();*/
                     $user_lenauth = (object) array_merge((array) $user_lenauth, (array) $newuser);
                     $DB->update_record('user', $user_lenauth);
                     if ($this->_oauth_config->auth_lenauth_retrieve_avatar) {
                         //processing user avatar from social webservice
                         if (!empty($image_url) && intval($user_lenauth->picture) === 0) {
                             $image_header = get_headers($image_url, 1);
                             if (isset($image_header['Content-Type']) && is_string($image_header['Content-Type']) && in_array($image_header['Content-Type'], array_keys(self::$_allowed_icons_types))) {
                                 $mime = $image_header['Content-Type'];
                             } else {
                                 if (isset($image_header['Content-Type'][0]) && is_string($image_header['Content-Type'][0]) && in_array($image_header['Content-Type'][0], array_keys(self::$_allowed_icons_types))) {
                                     $mime = $image_header['Content-Type'][0];
                                 }
                             }
                             $ext = $this->_lenauth_get_image_extension_from_mime($mime);
                             if ($ext) {
                                 //create temp file
                                 $tempfilename = substr(microtime(), 0, 10) . '.tmp';
                                 $templfolder = $CFG->tempdir . '/filestorage';
                                 if (!file_exists($templfolder)) {
                                     mkdir($templfolder, $CFG->directorypermissions);
                                 }
                                 @chmod($templfolder, 0777);
                                 $tempfile = $templfolder . '/' . $tempfilename;
                                 if (copy($image_url, $tempfile)) {
                                     require_once $CFG->libdir . '/gdlib.php';
                                     $usericonid = process_new_icon(context_user::instance($newuser->id, MUST_EXIST), 'user', 'icon', 0, $tempfile);
                                     if ($usericonid) {
                                         $DB->set_field('user', 'picture', $usericonid, array('id' => $newuser->id));
                                     }
                                     unset($tempfile);
                                 }
                                 @chmod($templfolder, $CFG->directorypermissions);
                             }
                         }
                     }
                 }
                 complete_user_login($user_lenauth);
                 // complete user login
                 // Redirection
                 $urltogo = $CFG->wwwroot;
                 if (user_not_fully_set_up($user_lenauth)) {
                     $urltogo = $CFG->wwwroot . '/user/edit.php';
                 } else {
                     if (isset($SESSION->wantsurl) && strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                         $urltogo = $SESSION->wantsurl;
                         unset($SESSION->wantsurl);
                     } else {
                         unset($SESSION->wantsurl);
                     }
                 }
             }
             redirect($urltogo);
         } else {
             throw new moodle_exception('Could not get access to access token. Check your App Settings', 'auth_lenauth');
         }
     }
 }
开发者ID:HarcourtsAcademy,项目名称:moodle-auth_lenauth,代码行数:101,代码来源:auth.php


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