• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_auth_plugin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: local_ent_installer_cron

/**
 * this function schedules the user synchronisation updates
 *
 * Implementation specific : Generic
 */
function local_ent_installer_cron()
{
    global $CFG;
    if (!get_config('local_ent_installer', 'cron_enable')) {
        return;
    }
    $now = time();
    $needscron = false;
    $chour = 0 + get_config('local_ent_installer', 'cron_hour');
    $cmin = 0 + get_config('local_ent_installer', 'cron_min');
    $cfreq = get_config('local_ent_installer', 'cron_enable');
    $now = time();
    $nowdt = getdate($now);
    $expectedtime = get_config('local_ent_installer', 'last_sync_date') + $cfreq - HOURSEC;
    $crondebug = optional_param('crondebug', false, PARAM_BOOL);
    if ($now < $expectedtime && !$crondebug) {
        return;
    }
    if (!empty($CFG->ent_installer_running)) {
        return;
    }
    if ($nowdt['hours'] * 60 + $nowdt['minutes'] >= $chour * 60 + $cmin || $crondebug) {
        set_config('ent_installer_running', 1);
        set_config('last_sync_date', $now, 'local_ent_installer');
        // Get ldap params from real ldap plugin.
        $ldapauth = get_auth_plugin('ldap');
        $options = array('host' => $CFG->wwwroot);
        // Run the customised synchro.
        local_ent_installer_sync_users($ldapauth, $options);
        set_config('ent_installer_running', null);
    } else {
        mtrace('waiting for valid time ');
    }
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:39,代码来源:lib.php


示例2: get_content

 function get_content()
 {
     global $USER, $CFG, $SESSION;
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (!empty($CFG->registerauth)) {
         $authplugin = get_auth_plugin($CFG->registerauth);
         if ($authplugin->can_signup()) {
             $signup = $wwwroot . '/login/signup.php';
         }
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     if (!empty($CFG->loginpasswordautocomplete)) {
         $autocomplete = 'autocomplete="off"';
     } else {
         $autocomplete = '';
     }
     $username = get_moodle_cookie();
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         if (empty($CFG->authloginviaemail)) {
             $strusername = get_string('username');
         } else {
             $strusername = get_string('usernameemail');
         }
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
         $this->content->text .= '<div class="c1 fld username"><label for="login_username">' . $strusername . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" value="" ' . $autocomplete . ' /></div>';
         if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
             $checked = $username ? 'checked="checked"' : '';
             $this->content->text .= '<div class="c1 rememberusername"><input type="checkbox" name="rememberusername" id="rememberusername" value="1" ' . $checked . '/>';
             $this->content->text .= ' <label for="rememberusername">' . get_string('rememberusername', 'admin') . '</label></div>';
         }
         $this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
     }
     return $this->content;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:60,代码来源:block_login.php


示例3: definition_after_data

 function definition_after_data()
 {
     global $CFG, $DB;
     $mform =& $this->_form;
     $userid = $mform->getElementValue('id');
     // if language does not exist, use site default lang
     if ($langsel = $mform->getElementValue('lang')) {
         $lang = reset($langsel);
         // missing _utf8 in language, add it before further processing. MDL-11829 MDL-16845
         if (strpos($lang, '_utf8') === false) {
             $lang = $lang . '_utf8';
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($lang);
         }
         // check lang exists
         if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($CFG->lang);
         }
     }
     if ($user = $DB->get_record('user', array('id' => $userid))) {
         // remove description
         if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
             $mform->removeElement('description');
         }
         // print picture
         if (!empty($CFG->gdversion)) {
             $image_el =& $mform->getElement('currentpicture');
             if ($user and $user->picture) {
                 $image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64, true, false, '', true));
             } else {
                 $image_el->setValue(get_string('none'));
             }
         }
         /// disable fields that are locked by auth plugins
         $fields = get_user_fieldnames();
         $authplugin = get_auth_plugin($user->auth);
         foreach ($fields as $field) {
             if (!$mform->elementExists($field)) {
                 continue;
             }
             $configvariable = 'field_lock_' . $field;
             if (isset($authplugin->config->{$configvariable})) {
                 if ($authplugin->config->{$configvariable} === 'locked') {
                     $mform->hardFreeze($field);
                     $mform->setConstant($field, $user->{$field});
                 } else {
                     if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
                         $mform->hardFreeze($field);
                         $mform->setConstant($field, $user->{$field});
                     }
                 }
             }
         }
         /// Next the customisable profile fields
         profile_definition_after_data($mform, $user->id);
     } else {
         profile_definition_after_data($mform, 0);
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:60,代码来源:edit_form.php


示例4: definition_after_data

 function definition_after_data()
 {
     global $CFG, $DB, $OUTPUT;
     $mform =& $this->_form;
     $userid = $mform->getElementValue('id');
     // if language does not exist, use site default lang
     if ($langsel = $mform->getElementValue('lang')) {
         $lang = reset($langsel);
         // check lang exists
         if (!get_string_manager()->translation_exists($lang, false)) {
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($CFG->lang);
         }
     }
     if ($user = $DB->get_record('user', array('id' => $userid))) {
         // remove description
         if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) {
             $mform->removeElement('description_editor');
         }
         // print picture
         $context = context_user::instance($user->id, MUST_EXIST);
         $fs = get_file_storage();
         $hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg');
         if (!empty($user->picture) && $hasuploadedpicture) {
             $imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
         } else {
             $imagevalue = get_string('none');
         }
         $imageelement = $mform->getElement('currentpicture');
         $imageelement->setValue($imagevalue);
         if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) {
             $mform->removeElement('deletepicture');
         }
         /// disable fields that are locked by auth plugins
         $fields = get_user_fieldnames();
         $authplugin = get_auth_plugin($user->auth);
         foreach ($fields as $field) {
             if (!$mform->elementExists($field)) {
                 continue;
             }
             $configvariable = 'field_lock_' . $field;
             if (isset($authplugin->config->{$configvariable})) {
                 if ($authplugin->config->{$configvariable} === 'locked') {
                     $mform->hardFreeze($field);
                     $mform->setConstant($field, $user->{$field});
                 } else {
                     if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
                         $mform->hardFreeze($field);
                         $mform->setConstant($field, $user->{$field});
                     }
                 }
             }
         }
         /// Next the customisable profile fields
         profile_definition_after_data($mform, $user->id);
     } else {
         profile_definition_after_data($mform, 0);
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:59,代码来源:edit_form.php


示例5: execute

 /**
  * Run users sync.
  */
 public function execute()
 {
     global $CFG;
     if (is_enabled_auth('cas')) {
         $auth = get_auth_plugin('cas');
         $auth->sync_users(true);
     }
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:11,代码来源:sync_task.php


示例6: validation

 function validation($data, $files)
 {
     global $CFG;
     $errors = parent::validation($data, $files);
     $authplugin = get_auth_plugin($CFG->registerauth);
     if (record_exists('user', 'username', $data['username'], 'mnethostid', $CFG->mnet_localhost_id)) {
         $errors['username'] = get_string('usernameexists');
     } else {
         if (empty($CFG->extendedusernamechars)) {
             $string = eregi_replace("[^(-\\.[:alnum:])]", '', $data['username']);
             if (strcmp($data['username'], $string)) {
                 $errors['username'] = get_string('alphanumerical');
             }
         }
     }
     //check if user exists in external db
     //TODO: maybe we should check all enabled plugins instead
     if ($authplugin->user_exists($data['username'])) {
         $errors['username'] = get_string('usernameexists');
     }
     if (!validate_email($data['email'])) {
         $errors['email'] = get_string('invalidemail');
     } else {
         if (record_exists('user', 'email', $data['email'])) {
             $errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>';
         }
     }
     if (empty($data['email2'])) {
         $errors['email2'] = get_string('missingemail');
     } else {
         if ($data['email2'] != $data['email']) {
             $errors['email2'] = get_string('invalidemail');
         }
     }
     if (!isset($errors['email'])) {
         if ($err = email_is_not_allowed($data['email'])) {
             $errors['email'] = $err;
         }
     }
     $errmsg = '';
     if (!check_password_policy($data['password'], $errmsg)) {
         $errors['password'] = $errmsg;
     }
     if (signup_captcha_enabled()) {
         $recaptcha_element = $this->_form->getElement('recaptcha_element');
         if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) {
             $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field'];
             $response_field = $this->_form->_submitValues['recaptcha_response_field'];
             if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) {
                 $errors['recaptcha'] = $result;
             }
         } else {
             $errors['recaptcha'] = get_string('missingrecaptchachallengefield');
         }
     }
     return $errors;
 }
开发者ID:NextEinstein,项目名称:riverhills,代码行数:57,代码来源:signup_form.php


示例7: __logout

 function __logout()
 {
     $authsequence = get_enabled_auth_plugins();
     // auths, in sequence
     foreach ($authsequence as $authname) {
         $authplugin = get_auth_plugin($authname);
         $authplugin->logoutpage_hook();
     }
     require_logout();
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:10,代码来源:clinique_logout.php


示例8: test_user_updated

 /**
  * Tests that the locations in the auth_db API that update a user trigger the user_updated event.
  */
 public function test_user_updated()
 {
     global $CFG, $DB;
     $this->preventResetByRollback();
     // Initialise the database.
     $authdbtestcase = new auth_db_testcase();
     $authdbtestcase->init_auth_database();
     $auth = get_auth_plugin('db');
     $auth->db_init();
     // Add a suspended user.
     $user = array();
     $user['username'] = 'mark';
     $user['suspended'] = '1';
     $user['mnethostid'] = $CFG->mnet_localhost_id;
     $user['auth'] = 'db';
     $this->getDataGenerator()->create_user($user);
     // Add a user to the auth_db_users table - we will then call sync_users to
     // deal with the record here. In this case it will un-suspend the user.
     $user = new stdClass();
     $user->name = 'mark';
     $user->pass = 'password123';
     $user->email = '[email protected]';
     $user->id = $DB->insert_record('auth_db_users', $user);
     // Set the config to remove the suspension on the user.
     set_config('removeuser', AUTH_REMOVEUSER_SUSPEND, 'auth/db');
     $auth->config->removeuser = AUTH_REMOVEUSER_SUSPEND;
     // Run sync_users and capture the user_updated event.
     $sink = $this->redirectEvents();
     $trace = new null_progress_trace();
     $auth->sync_users($trace, false);
     $events = $sink->get_events();
     $sink->close();
     // Check that there is only one event.
     $this->assertEquals(1, count($events));
     // Get the event.
     $event = array_pop($events);
     // Test that the user updated event was triggered - no need to test the other
     // details of the event as that is done extensively in other unit tests.
     $this->assertInstanceOf('\\core\\event\\user_updated', $event);
     // Run sync_users and capture the user_updated event.
     $sink = $this->redirectEvents();
     $auth->update_user_record('mark');
     $events = $sink->get_events();
     $sink->close();
     // Check that there is only one event.
     $this->assertEquals(1, count($events));
     // Get the event.
     $event = array_pop($events);
     // Test that the user updated event was triggered - no need to test the other
     // details of the event as that is done extensively in other unit tests.
     $this->assertInstanceOf('\\core\\event\\user_updated', $event);
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:55,代码来源:events_test.php


示例9: validation

 function validation($data)
 {
     global $CFG;
     $errors = array();
     $authplugin = get_auth_plugin($CFG->registerauth);
     if (record_exists('user', 'username', $data['username'], 'mnethostid', $CFG->mnet_localhost_id)) {
         $errors['username'] = get_string('usernameexists');
     } else {
         if (empty($CFG->extendedusernamechars)) {
             $string = eregi_replace("[^(-\\.[:alnum:])]", '', $data['username']);
             if (strcmp($data['username'], $string)) {
                 $errors['username'] = get_string('alphanumerical');
             }
         }
     }
     //check if user exists in external db
     //TODO: maybe we should check all enabled plugins instead
     if ($authplugin->user_exists($data['username'])) {
         $errors['username'] = get_string('usernameexists');
     }
     if (!validate_email($data['email'])) {
         $errors['email'] = get_string('invalidemail');
     } else {
         if (record_exists('user', 'email', $data['email'])) {
             $errors['email'] = get_string('emailexists') . ' <a href="forgot_password.php">' . get_string('newpassword') . '?</a>';
         }
     }
     if (empty($data['email2'])) {
         $errors['email2'] = get_string('missingemail');
     } else {
         if ($data['email2'] != $data['email']) {
             $errors['email2'] = get_string('invalidemail');
         }
     }
     if (!isset($errors['email'])) {
         if ($err = email_is_not_allowed($data['email'])) {
             $errors['email'] = $err;
         }
     }
     if (!check_password_policy($data['password'], $errmsg)) {
         $errors['password'] = $errmsg;
     }
     if (0 == count($errors)) {
         return true;
     } else {
         return $errors;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:48,代码来源:signup_form.php


示例10: definition_after_data

 function definition_after_data()
 {
     global $CFG;
     $mform =& $this->_form;
     $userid = $mform->getElementValue('id');
     // if language does not exist, use site default lang
     if ($langsel = $mform->getElementValue('lang')) {
         $lang = reset($langsel);
         if (!file_exists($CFG->dataroot . '/lang/' . $lang) and !file_exists($CFG->dirroot . '/lang/' . $lang)) {
             $lang_el =& $mform->getElement('lang');
             $lang_el->setValue($CFG->lang);
         }
     }
     if ($user = get_record('user', 'id', $userid)) {
         // print picture
         if (!empty($CFG->gdversion)) {
             $image_el =& $mform->getElement('currentpicture');
             if ($user and $user->picture) {
                 $image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64, true, false, '', true));
             } else {
                 $image_el->setValue(get_string('none'));
             }
         }
         /// disable fields that are locked by auth plugins
         $fields = get_user_fieldnames();
         $freezefields = array();
         $authplugin = get_auth_plugin($user->auth);
         foreach ($fields as $field) {
             if (!$mform->elementExists($field)) {
                 continue;
             }
             $configvariable = 'field_lock_' . $field;
             if (isset($authplugin->config->{$configvariable})) {
                 if ($authplugin->config->{$configvariable} === 'locked') {
                     $freezefields[] = $field;
                 } else {
                     if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') {
                         $freezefields[] = $field;
                     }
                 }
             }
         }
         $mform->hardFreeze($freezefields);
     }
     /// Next the customisable profile fields
     profile_definition_after_data($mform);
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:47,代码来源:edit_form.php


示例11: execute

 public function execute()
 {
     global $CFG;
     require_once "{$CFG->libdir}/datalib.php";
     $user = get_admin();
     if (!$user) {
         cli_error("Unable to find admin user in DB.");
     }
     $auth = empty($user->auth) ? 'manual' : $user->auth;
     if ($auth == 'nologin' or !is_enabled_auth($auth)) {
         cli_error(sprintf("User authentication is either 'nologin' or disabled. Check Moodle authentication method for '%s'", $user->username));
     }
     $authplugin = get_auth_plugin($auth);
     $authplugin->sync_roles($user);
     login_attempt_valid($user);
     complete_user_login($user);
     printf("%s:%s\n", session_name(), session_id());
 }
开发者ID:dariogs,项目名称:moosh,代码行数:18,代码来源:AdminLogin.php


示例12: get_content

 function get_content()
 {
     global $USER, $CFG;
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (!empty($CFG->registerauth)) {
         $authplugin = get_auth_plugin($CFG->registerauth);
         if ($authplugin->can_signup()) {
             $signup = $wwwroot . '/login/signup.php';
         }
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . $wwwroot . '/login/index.php">';
         $this->content->text .= '<div class="c1 fld username"><label for="login_username">' . get_string('username') . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" value="" /></div>';
         $this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
     }
     return $this->content;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:44,代码来源:block_login.php


示例13: print_login

 /**
  * Display the file listing - no login required
  * @global <type> $SESSION
  * @param <type> $ajax
  * @return <type>
  */
 public function print_login($ajax = true)
 {
     global $SESSION, $CFG, $DB;
     //jump to the peer to create a session
     require_once $CFG->dirroot . '/mnet/lib.php';
     $this->ensure_environment();
     $mnetauth = get_auth_plugin('mnet');
     $host = $DB->get_record('mnet_host', array('id' => $this->options['peer']));
     //need to retrieve the host url
     $url = $mnetauth->start_jump_session($host->id, '/repository/ws.php?callback=yes&repo_id=' . $this->id, true);
     //set session
     $SESSION->loginmahara = true;
     $ret = array();
     $popup_btn = new stdclass();
     $popup_btn->type = 'popup';
     $popup_btn->url = $url;
     $ret['login'] = array($popup_btn);
     return $ret;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:25,代码来源:repository.class.php


示例14: __app_reset_password_and_mail

    private function __app_reset_password_and_mail($user)
    {
        global $CFG;
        $site = get_site();
        $supportuser = generate_email_supportuser();
        $userauth = get_auth_plugin($user->auth);
        if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth)) {
            trigger_error("Attempt to reset user password for user {$user->username} with Auth {$user->auth}.");
            return false;
        }
        $newpassword = generate_password();
        if (!$userauth->user_update_password($user, $newpassword)) {
            $error->error = true;
            $error->msg = 'fp_passwordgen_failure';
            echo json_encode($error);
            die;
        }
        $a = new stdClass();
        $a->firstname = $user->firstname;
        $a->lastname = $user->lastname;
        $a->sitename = format_string($site->fullname);
        $a->username = $user->username;
        $a->newpassword = $newpassword;
        //$a->signoff = generate_email_signoff();
        $message = 'Hi ' . $a->firstname . ',

Your account password at \'' . $a->sitename . '\' has been reset
and you have been issued with a new temporary password.

Your current login information is now:
   username: ' . $a->username . '
   password: ' . $a->newpassword . '

Cheers from the \'' . $a->sitename . '\' administrator.';
        //$message = get_string('newpasswordtext', '', $a);
        $subject = format_string($site->fullname) . ': ' . get_string('changedpassword');
        unset_user_preference('create_password', $user);
        // prevent cron from generating the password
        //directly email rather than using the messaging system to ensure its not routed to a popup or jabber
        return email_to_user($user, $supportuser, $subject, $message);
    }
开发者ID:vinoth4891,项目名称:clinique,代码行数:41,代码来源:clinique_forgot_password.php


示例15: validation

 function validation($data, $files)
 {
     global $CFG;
     $invite = false;
     $sitecontext = get_context_instance(CONTEXT_SYSTEM);
     if (isloggedin() && has_capability('moodle/local:invitenewuser', $sitecontext)) {
         $invite = true;
     }
     $errors = parent::validation($data, $files);
     $authplugin = get_auth_plugin($CFG->registerauth);
     if ($data['password1'] != $data['password2']) {
         $errors['password1'] = get_string('passwordsdiffer');
         $errors['password2'] = get_string('passwordsdiffer');
         return $errors;
     }
     if (record_exists('user', 'username', $data['username'], 'mnethostid', $CFG->mnet_localhost_id)) {
         $errors['username'] = get_string('usernameexists');
     } else {
         if (empty($CFG->extendedusernamechars)) {
             $string = eregi_replace("[^(-\\.[:alnum:])]", '', $data['username']);
             if (strcmp($data['username'], $string)) {
                 $errors['username'] = get_string('alphanumerical');
             }
         }
     }
     //check if user exists in external db
     //TODO: maybe we should check all enabled plugins instead
     if ($authplugin->user_exists($data['username'])) {
         $errors['username'] = get_string('usernameexists');
     }
     $errmsg = '';
     if (!check_password_policy($data['password1'], $errmsg)) {
         $errors['password1'] = $errmsg;
     }
     if (function_exists('local_user_signup_validation')) {
         if ($localvalidation = local_user_signup_validation()) {
             $errors = array_merge($errors, $localvalidation);
         }
     }
     return $errors;
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:41,代码来源:confirm_form.php


示例16: __getPassword

 public function __getPassword($username, $email, $old_password, $new_password)
 {
     global $CFG, $DB;
     $systemcontext = context_system::instance();
     $response = new CliniqueServiceResponce();
     if (!empty($username) && !empty($old_password) && !empty($new_password)) {
         $user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0, 'suspended' => 0));
         if (!empty($user)) {
             if (is_mnet_remote_user($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change password - mnet user trying to access.', 0, $user->id);
                 $response->response(true, 'cp_mnet_user');
                 die;
             }
             if (isguestuser($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change password - guest user credential supplied.', 0, $user->id);
                 $response->response(true, 'cp_guest');
                 die;
             }
             // make sure user is allowed to change password
             require_capability('moodle/user:changeownpassword', $systemcontext, $user->id);
             // $generatePasswordResult = generatePassword::app_validate_internal_user_password($user, $old_password);
             if (!ChangePassword::__app_validate_internal_user_password($user, $old_password)) {
                 $response->response(true, 'cp_wrong_oldpwd');
             } else {
                 $userauth = get_auth_plugin($user->auth);
                 if ($userauth->user_update_password($user, $new_password)) {
                     unset_user_preference('auth_forcepasswordchange', $user);
                     unset_user_preference('create_password', $user);
                     $response->response(false, 'cp_success');
                 } else {
                     add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Change password - password change updation failure.', 0, $user->id);
                     $response->response(true, 'cp_failure');
                 }
             }
         } else {
             $response->response(false, 'cp_no_mail_record');
         }
     } else {
         add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Change password - input parameters missing.', 0, $user->id);
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:41,代码来源:clinique_change_password.php


示例17: execute

 public function execute()
 {
     global $CFG, $DB;
     require_once "{$CFG->libdir}/datalib.php";
     $username = $this->arguments[0];
     $options = $this->expandedOptions;
     if ($options['id']) {
         $user = $DB->get_record('user', array('id' => $username), '*', MUST_EXIST);
     } else {
         $user = $DB->get_record('user', array('username' => $username), '*', MUST_EXIST);
     }
     $auth = empty($user->auth) ? 'manual' : $user->auth;
     if ($auth == 'nologin' or !is_enabled_auth($auth)) {
         cli_error(sprintf("User authentication is either 'nologin' or disabled. Check Moodle authentication method for '%s'", $user->username));
     }
     $authplugin = get_auth_plugin($auth);
     $authplugin->sync_roles($user);
     login_attempt_valid($user);
     complete_user_login($user);
     printf("%s:%s\n", session_name(), session_id());
 }
开发者ID:tmuras,项目名称:moosh,代码行数:21,代码来源:UserLogin.php


示例18: __construct

 public function __construct()
 {
     global $CFG, $SESSION, $OUTPUT;
     // Get all alternative login methods and add to potentialipds array.
     $authsequence = get_enabled_auth_plugins(true);
     $potentialidps = [];
     foreach ($authsequence as $authname) {
         if (isset($SESSION->snapwantsurl)) {
             $urltogo = $SESSION->snapwantsurl;
         } else {
             $urltogo = $CFG->wwwroot . '/';
         }
         unset($SESSION->snapwantsurl);
         $authplugin = get_auth_plugin($authname);
         $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($urltogo));
     }
     if (!empty($potentialidps)) {
         foreach ($potentialidps as $idp) {
             $this->potentialidps[] = (object) ['url' => $idp['url']->out(), 'name' => $idp['name'], 'icon' => $OUTPUT->pix_url($idp['icon']->pix)];
         }
     }
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:22,代码来源:login_alternative_methods.php


示例19: embeddedreports_generate_link

/**
 * Create a link that allows for displaying embedded Jasper reports
 * on an HTML page
 *
 * @param   $uri        The resource id of the necessary report
 * @param   $parameters Additional parameters to be passed to the report
 * @param   $print      If true, prints iframe on page
 * @return              The HTML of the iframe containing the report
 *
 */
function embeddedreports_generate_link($uri, $parameters = array(), $print = true)
{
    global $USER;
    $parameters['elisembedded'] = 'true';
    if (!is_enabled_auth('mnet')) {
        error('mnet is disabled');
    }
    // check remote login permissions
    if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM)) or is_mnet_remote_user($USER) or $USER->username == 'guest' or empty($USER->id)) {
        print_error('notpermittedtojump', 'mnet');
    }
    $mnet_auth = get_auth_plugin('mnet');
    // check for SSO publish permission first
    if ($mnet_auth->has_service(jasper_mnet_hostid(), 'sso_sp') == false) {
        print_error('hostnotconfiguredforsso', 'mnet');
    }
    $mnet_link = jasper_mnet_link(jasper_report_link($uri, $parameters));
    $result = '<iframe id="reportframe" name="reportframe" src="' . $mnet_link . '"></iframe>';
    if ($print) {
        echo $result;
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:33,代码来源:lib.php


示例20: generate_user_settings


//.........这里部分代码省略.........
         $pluginsfunction = get_plugins_with_function('extend_navigation_user', 'lib.php');
         foreach ($pluginsfunction as $plugintype => $plugins) {
             if ($plugintype != 'report') {
                 foreach ($plugins as $pluginfunction) {
                     $pluginfunction($profilenode, $user, $usercontext, $course, $coursecontext);
                 }
             }
         }
         $usersetting = navigation_node::create(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
         $dashboard->add_node($usersetting);
     } else {
         $usersetting = $this->add(get_string('preferences', 'moodle'), $prefurl, self::TYPE_CONTAINER, null, $key);
         $usersetting->display = false;
     }
     $usersetting->id = 'usersettings';
     // Check if the user has been deleted.
     if ($user->deleted) {
         if (!has_capability('moodle/user:update', $coursecontext)) {
             // We can't edit the user so just show the user deleted message.
             $usersetting->add(get_string('userdeleted'), null, self::TYPE_SETTING);
         } else {
             // We can edit the user so show the user deleted message and link it to the profile.
             if ($course->id == $SITE->id) {
                 $profileurl = new moodle_url('/user/profile.php', array('id' => $user->id));
             } else {
                 $profileurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
             }
             $usersetting->add(get_string('userdeleted'), $profileurl, self::TYPE_SETTING);
         }
         return true;
     }
     $userauthplugin = false;
     if (!empty($user->auth)) {
         $userauthplugin = get_auth_plugin($user->auth);
     }
     $useraccount = $usersetting->add(get_string('useraccount'), null, self::TYPE_CONTAINER, null, 'useraccount');
     // Add the profile edit link.
     if (isloggedin() && !isguestuser($user) && !is_mnet_remote_user($user)) {
         if (($currentuser || is_siteadmin($USER) || !is_siteadmin($user)) && has_capability('moodle/user:update', $systemcontext)) {
             $url = new moodle_url('/user/editadvanced.php', array('id' => $user->id, 'course' => $course->id));
             $useraccount->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
         } else {
             if (has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user) || $currentuser && has_capability('moodle/user:editownprofile', $systemcontext)) {
                 if ($userauthplugin && $userauthplugin->can_edit_profile()) {
                     $url = $userauthplugin->edit_profile_url();
                     if (empty($url)) {
                         $url = new moodle_url('/user/edit.php', array('id' => $user->id, 'course' => $course->id));
                     }
                     $useraccount->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
                 }
             }
         }
     }
     // Change password link.
     if ($userauthplugin && $currentuser && !\core\session\manager::is_loggedinas() && !isguestuser() && has_capabilit 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_author函数代码示例发布时间:2022-05-15
下一篇:
PHP get_audiences_list函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap