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

PHP is_enabled_auth函数代码示例

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

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



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

示例1: xmldb_auth_ldap_upgrade

/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_auth_ldap_upgrade($oldversion)
{
    // Moodle v2.5.0 release upgrade line
    // Put any upgrade step following this
    // MDL-39323 New setting in 2.5, make sure it's defined.
    if ($oldversion < 2013052100) {
        if (get_config('start_tls', 'auth/ldap') === false) {
            set_config('start_tls', 0, 'auth/ldap');
        }
        upgrade_plugin_savepoint(true, 2013052100, 'auth', 'ldap');
    }
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2014111001) {
        global $DB;
        // From now on the default LDAP objectClass setting for AD has been changed, from 'user' to '(samaccounttype=805306368)'.
        if (is_enabled_auth('ldap') && $DB->get_field('config_plugins', 'value', array('name' => 'user_type', 'plugin' => 'auth/ldap')) === 'ad' && $DB->get_field('config_plugins', 'value', array('name' => 'objectclass', 'plugin' => 'auth/ldap')) === '') {
            // Save the backwards-compatible default setting.
            set_config('objectclass', 'user', 'auth/ldap');
        }
        upgrade_plugin_savepoint(true, 2014111001, 'auth', 'ldap');
    }
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:mercysmart,项目名称:naikelas,代码行数:34,代码来源:upgrade.php


示例2: test_get_public_config

 public function test_get_public_config()
 {
     global $CFG, $SITE, $OUTPUT;
     $this->resetAfterTest(true);
     $result = external::get_public_config();
     $result = external_api::clean_returnvalue(external::get_public_config_returns(), $result);
     // Test default values.
     $context = context_system::instance();
     list($authinstructions, $notusedformat) = external_format_text($CFG->auth_instructions, FORMAT_MOODLE, $context->id);
     list($maintenancemessage, $notusedformat) = external_format_text($CFG->maintenance_message, FORMAT_MOODLE, $context->id);
     $expected = array('wwwroot' => $CFG->wwwroot, 'httpswwwroot' => $CFG->httpswwwroot, 'sitename' => external_format_string($SITE->fullname, $context->id, true), 'guestlogin' => $CFG->guestloginbutton, 'rememberusername' => $CFG->rememberusername, 'authloginviaemail' => $CFG->authloginviaemail, 'registerauth' => $CFG->registerauth, 'forgottenpasswordurl' => $CFG->forgottenpasswordurl, 'authinstructions' => $authinstructions, 'authnoneenabled' => (int) is_enabled_auth('none'), 'enablewebservices' => $CFG->enablewebservices, 'enablemobilewebservice' => $CFG->enablemobilewebservice, 'maintenanceenabled' => $CFG->maintenance_enabled, 'maintenancemessage' => $maintenancemessage, 'typeoflogin' => api::LOGIN_VIA_APP, 'warnings' => array());
     $this->assertEquals($expected, $result);
     // Change some values.
     set_config('registerauth', 'email');
     $authinstructions = 'Something with <b>html tags</b>';
     set_config('auth_instructions', $authinstructions);
     set_config('typeoflogin', api::LOGIN_VIA_BROWSER, 'tool_mobile');
     set_config('logo', 'mock.png', 'core_admin');
     set_config('logocompact', 'mock.png', 'core_admin');
     list($authinstructions, $notusedformat) = external_format_text($authinstructions, FORMAT_MOODLE, $context->id);
     $expected['registerauth'] = 'email';
     $expected['authinstructions'] = $authinstructions;
     $expected['typeoflogin'] = api::LOGIN_VIA_BROWSER;
     $expected['launchurl'] = "{$CFG->wwwroot}/{$CFG->admin}/tool/mobile/launch.php";
     if ($logourl = $OUTPUT->get_logo_url()) {
         $expected['logourl'] = $logourl->out(false);
     }
     if ($compactlogourl = $OUTPUT->get_compact_logo_url()) {
         $expected['compactlogourl'] = $compactlogourl->out(false);
     }
     $result = external::get_public_config();
     $result = external_api::clean_returnvalue(external::get_public_config_returns(), $result);
     $this->assertEquals($expected, $result);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:34,代码来源:externallib_test.php


示例3: get_content

 function get_content()
 {
     global $CFG, $USER, $DB, $OUTPUT;
     // shortcut -  only for logged in users!
     if (!isloggedin() || isguestuser()) {
         return false;
     }
     // according to start_jump_session,
     // remote users can't on-jump
     // so don't show this block to them
     if (is_mnet_remote_user($USER)) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_localusersonly', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if (!is_enabled_auth('mnet')) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_authmnetneeded', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_roamcapabilityneeded', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     // TODO: Test this query - it's appropriate? It works?
     // get the hosts and whether we are doing SSO with them
     $sql = "\n             SELECT DISTINCT\n                 h.id,\n                 h.name,\n                 h.wwwroot,\n                 a.name as application,\n                 a.display_name\n             FROM\n                 {mnet_host} h,\n                 {mnet_application} a,\n                 {mnet_host2service} h2s_IDP,\n                 {mnet_service} s_IDP,\n                 {mnet_host2service} h2s_SP,\n                 {mnet_service} s_SP\n             WHERE\n                 h.id <> ? AND\n                 h.id <> ? AND\n                 h.id = h2s_IDP.hostid AND\n                 h.deleted = 0 AND\n                 h.applicationid = a.id AND\n                 h2s_IDP.serviceid = s_IDP.id AND\n                 s_IDP.name = 'sso_idp' AND\n                 h2s_IDP.publish = '1' AND\n                 h.id = h2s_SP.hostid AND\n                 h2s_SP.serviceid = s_SP.id AND\n                 s_SP.name = 'sso_idp' AND\n                 h2s_SP.publish = '1'\n             ORDER BY\n                 a.display_name,\n                 h.name";
     $hosts = $DB->get_records_sql($sql, array($CFG->mnet_localhost_id, $CFG->mnet_all_hosts_id));
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if ($hosts) {
         foreach ($hosts as $host) {
             $icon = '<img src="' . $OUTPUT->pix_url('i/' . $host->application . '_host') . '"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />&nbsp;';
             if ($host->id == $USER->mnethostid) {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . $icon . s($host->name) . "</a>";
             } else {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . $icon . s($host->name) . "</a>";
             }
         }
     }
     return $this->content;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:60,代码来源:block_mnet_hosts.php


示例4: 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


示例5: get_site_public_settings

 /**
  * Returns a list of the site public settings, those not requiring authentication.
  *
  * @return array with the settings and warnings
  */
 public static function get_site_public_settings()
 {
     global $CFG, $SITE, $PAGE;
     $context = context_system::instance();
     // We need this to make work the format text functions.
     $PAGE->set_context($context);
     $settings = array('wwwroot' => $CFG->wwwroot, 'httpswwwroot' => $CFG->httpswwwroot, 'sitename' => external_format_string($SITE->fullname, $context->id, true), 'guestlogin' => $CFG->guestloginbutton, 'rememberusername' => $CFG->rememberusername, 'authloginviaemail' => $CFG->authloginviaemail, 'registerauth' => $CFG->registerauth, 'forgottenpasswordurl' => $CFG->forgottenpasswordurl, 'authinstructions' => format_text($CFG->auth_instructions), 'authnoneenabled' => (int) is_enabled_auth('none'), 'enablewebservices' => $CFG->enablewebservices, 'enablemobilewebservice' => $CFG->enablemobilewebservice, 'maintenanceenabled' => $CFG->maintenance_enabled, 'maintenancemessage' => format_text($CFG->maintenance_message));
     return $settings;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:api.php


示例6: execute

 /**
  * Performs the synchronisation of members.
  */
 public function execute()
 {
     if (!is_enabled_auth('lti')) {
         mtrace('Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti')));
         return;
     }
     // Check if the enrolment plugin is disabled - isn't really necessary as the task should not run if
     // the plugin is disabled, but there is no harm in making sure core hasn't done something wrong.
     if (!enrol_is_enabled('lti')) {
         mtrace('Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti'));
         return;
     }
     $this->dataconnector = new data_connector();
     // Get all the enabled tools.
     $tools = helper::get_lti_tools(array('status' => ENROL_INSTANCE_ENABLED, 'membersync' => 1));
     foreach ($tools as $tool) {
         mtrace("Starting - Member sync for published tool '{$tool->id}' for course '{$tool->courseid}'.");
         // Variables to keep track of information to display later.
         $usercount = 0;
         $enrolcount = 0;
         $unenrolcount = 0;
         // Fetch consumer records mapped to this tool.
         $consumers = $this->dataconnector->get_consumers_mapped_to_tool($tool->id);
         // Perform processing for each consumer.
         foreach ($consumers as $consumer) {
             mtrace("Requesting membership service for the tool consumer '{$consumer->getRecordId()}'");
             // Get members through this tool consumer.
             $members = $this->fetch_members_from_consumer($consumer);
             // Check if we were able to fetch the members.
             if ($members === false) {
                 mtrace("Skipping - Membership service request failed.\n");
                 continue;
             }
             // Fetched members count.
             $membercount = count($members);
             mtrace("{$membercount} members received.\n");
             // Process member information.
             list($usercount, $enrolcount) = $this->sync_member_information($tool, $consumer, $members);
         }
         // Now we check if we have to unenrol users who were not listed.
         if ($this->should_sync_unenrol($tool->membersyncmode)) {
             $unenrolcount = $this->sync_unenrol($tool);
         }
         mtrace("Completed - Synced members for tool '{$tool->id}' in the course '{$tool->courseid}'. " . "Processed {$usercount} users; enrolled {$enrolcount} members; unenrolled {$unenrolcount} members.\n");
     }
     // Sync the user profile photos.
     mtrace("Started - Syncing user profile images.");
     $countsyncedimages = $this->sync_profile_images();
     mtrace("Completed - Synced {$countsyncedimages} profile images.");
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:53,代码来源:sync_members.php


示例7: get_content

 function get_content()
 {
     global $THEME, $CFG, $USER;
     // only for logged in users!
     if (!isloggedin() || isguest()) {
         return false;
     }
     if (!is_enabled_auth('mnet')) {
         // no need to query anything remote related
         debugging('mnet authentication plugin is not enabled', DEBUG_ALL);
         return '';
     }
     if (!empty($USER->realuser)) {
         $this->content = new stdClass();
         $this->content->items = array();
         $this->content->icons = array();
         $this->content->footer = get_string('notpermittedtojumpas', 'mnet');
         return $this->content;
     }
     // check for outgoing roaming permission first
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
         return '';
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     // TODO: Test this query - it's appropriate? It works?
     // get the hosts and whether we are doing SSO with them
     $sql = "\n             SELECT DISTINCT \n                 h.id, \n                 h.name,\n                 h.wwwroot,\n                 a.name as application,\n                 a.display_name\n             FROM \n                 {$CFG->prefix}mnet_host h,\n                 {$CFG->prefix}mnet_application a,\n                 {$CFG->prefix}mnet_host2service h2s_IDP,\n                 {$CFG->prefix}mnet_service s_IDP,\n                 {$CFG->prefix}mnet_host2service h2s_SP,\n                 {$CFG->prefix}mnet_service s_SP\n             WHERE\n                 h.id != '{$CFG->mnet_localhost_id}' AND\n                 h.id = h2s_IDP.hostid AND\n                 h.deleted = 0 AND\n                 h.applicationid = a.id AND\n                 h2s_IDP.serviceid = s_IDP.id AND\n                 s_IDP.name = 'sso_idp' AND\n                 h2s_IDP.publish = '1' AND\n                 h.id = h2s_SP.hostid AND\n                 h2s_SP.serviceid = s_SP.id AND\n                 s_SP.name = 'sso_idp' AND\n                 h2s_SP.publish = '1'\n             ORDER BY\n                 a.display_name,\n                 h.name";
     $hosts = get_records_sql($sql);
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if ($hosts) {
         foreach ($hosts as $host) {
             $icon = '<img src="' . $CFG->pixpath . '/i/' . $host->application . '_host.gif"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />';
             $this->content->icons[] = $icon;
             if ($host->id == $USER->mnethostid) {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . s($host->name) . "</a>";
             } else {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) . "</a>";
             }
         }
     }
     return $this->content;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:47,代码来源:block_mnet_hosts.php


示例8: 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


示例9: definition

 /**
  * Form definition.
  */
 protected function definition()
 {
     global $USER;
     $authconfig = get_config('auth_oidc');
     $opname = !empty($authconfig->opname) ? $authconfig->opname : get_string('pluginname', 'auth_oidc');
     $mform =& $this->_form;
     $mform->addElement('html', \html_writer::tag('h4', get_string('ucp_disconnect_title', 'auth_oidc', $opname)));
     $mform->addElement('html', \html_writer::div(get_string('ucp_disconnect_details', 'auth_oidc', $opname)));
     $mform->addElement('html', '<br />');
     $mform->addElement('header', 'userdetails', get_string('userdetails'));
     $newmethod = [];
     $attributes = [];
     $manualenabled = is_enabled_auth('manual') === true ? true : false;
     if ($manualenabled === true) {
         $newmethod[] =& $mform->createElement('radio', 'newmethod', '', 'manual', 'manual', $attributes);
     }
     if (!empty($this->_customdata['prevmethod'])) {
         $prevmethod = $this->_customdata['prevmethod'];
         $newmethod[] =& $mform->createElement('radio', 'newmethod', '', $prevmethod, $prevmethod, $attributes);
     }
     $mform->addGroup($newmethod, 'newmethodar', get_string('errorauthdisconnectnewmethod', 'auth_oidc'), [' '], false);
     if (!empty($this->_customdata['prevmethod'])) {
         $mform->setDefault('newmethod', $this->_customdata['prevmethod']);
     } else {
         if ($manualenabled === true) {
             $mform->setDefault('newmethod', 'manual');
         }
     }
     if ($manualenabled === true) {
         $mform->addElement('html', \html_writer::div(get_string('errorauthdisconnectifmanual', 'auth_oidc')));
         $mform->addElement('text', 'username', get_string('username'));
         $mform->addElement('passwordunmask', 'password', get_string('password'));
         $mform->setType('username', PARAM_USERNAME);
         $mform->disabledIf('username', 'newmethod', 'neq', 'manual');
         $mform->disabledIf('password', 'newmethod', 'neq', 'manual');
         // If the user cannot choose a username, set it to their current username and freeze.
         if (isset($this->_customdata['canchooseusername']) && $this->_customdata['canchooseusername'] == false) {
             $mform->setDefault('username', $USER->username);
             $element = $mform->getElement('username');
             $element->freeze();
         }
     }
     $this->add_action_buttons();
 }
开发者ID:eugeneventer,项目名称:o365-moodle,代码行数:47,代码来源:disconnect.php


示例10: xmldb_auth_cas_upgrade

/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_auth_cas_upgrade($oldversion)
{
    global $CFG, $DB;
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2014111001) {
        // From now on the default LDAP objectClass setting for AD has been changed, from 'user' to '(samaccounttype=805306368)'.
        if (is_enabled_auth('cas') && $DB->get_field('config_plugins', 'value', array('name' => 'user_type', 'plugin' => 'auth/cas')) === 'ad' && $DB->get_field('config_plugins', 'value', array('name' => 'objectclass', 'plugin' => 'auth/cas')) === '') {
            // Save the backwards-compatible default setting.
            set_config('objectclass', 'user', 'auth/cas');
        }
        upgrade_plugin_savepoint(true, 2014111001, 'auth', 'cas');
    }
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:rushi963,项目名称:moodle,代码行数:23,代码来源:upgrade.php


示例11: test_get_site_public_settings

 public function test_get_site_public_settings()
 {
     global $CFG, $SITE;
     $this->resetAfterTest(true);
     $result = external::get_site_public_settings();
     $result = external_api::clean_returnvalue(external::get_site_public_settings_returns(), $result);
     // Test default values.
     $context = context_system::instance();
     $expected = array('wwwroot' => $CFG->wwwroot, 'httpswwwroot' => $CFG->httpswwwroot, 'sitename' => external_format_string($SITE->fullname, $context->id, true), 'guestlogin' => $CFG->guestloginbutton, 'rememberusername' => $CFG->rememberusername, 'authloginviaemail' => $CFG->authloginviaemail, 'registerauth' => $CFG->registerauth, 'forgottenpasswordurl' => $CFG->forgottenpasswordurl, 'authinstructions' => format_text($CFG->auth_instructions), 'authnoneenabled' => (int) is_enabled_auth('none'), 'enablewebservices' => $CFG->enablewebservices, 'enablemobilewebservice' => $CFG->enablemobilewebservice, 'maintenanceenabled' => $CFG->maintenance_enabled, 'maintenancemessage' => format_text($CFG->maintenance_message), 'warnings' => array());
     $this->assertEquals($expected, $result);
     // Change a value.
     set_config('registerauth', 'email');
     $authinstructions = 'Something with <b>html tags</b>';
     set_config('auth_instructions', $authinstructions);
     $expected['registerauth'] = 'email';
     $expected['authinstructions'] = format_text($authinstructions);
     $result = external::get_site_public_settings();
     $result = external_api::clean_returnvalue(external::get_site_public_settings_returns(), $result);
     $this->assertEquals($expected, $result);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:externallib_test.php


示例12: __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


示例13: 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


示例14: report_security_check_noauth

/**
 * Verifies unsupported noauth setting
 * @param bool $detailed
 * @return object result
 */
function report_security_check_noauth($detailed = false)
{
    global $CFG;
    $result = new stdClass();
    $result->issue = 'report_security_check_noauth';
    $result->name = get_string('check_noauth_name', 'report_security');
    $result->info = null;
    $result->details = null;
    $result->status = null;
    $result->link = null;
    $result->link = "<a href=\"{$CFG->wwwroot}/{$CFG->admin}/settings.php?section=manageauths\">" . get_string('authsettings', 'admin') . '</a>';
    if (is_enabled_auth('none')) {
        $result->status = REPORT_SECURITY_CRITICAL;
        $result->info = get_string('check_noauth_error', 'report_security');
    } else {
        $result->status = REPORT_SECURITY_OK;
        $result->info = get_string('check_noauth_ok', 'report_security');
    }
    if ($detailed) {
        $result->details = get_string('check_noauth_details', 'report_security');
    }
    return $result;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:28,代码来源:locallib.php


示例15: 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


示例16: block_mystats_mycourses

function block_mystats_mycourses()
{
    global $USER;
    $mycourses = array();
    $count = 0;
    $enrolledcourses = enrol_get_users_courses($USER->id);
    foreach ($enrolledcourses as $course) {
        if (isset($USER->lastcourseaccess[$course->id])) {
            $course->lastaccess = $USER->lastcourseaccess[$course->id];
        } else {
            $course->lastaccess = 0;
        }
        $mycourses[$course->id] = $course;
        $count++;
    }
    if (is_enabled_auth('mnet')) {
        $remotecourses = get_my_remotecourses();
        foreach ($remotecourses as $course) {
            $mycourses[$course->id] = $course;
            $count++;
        }
    }
    return $mycourses;
}
开发者ID:bmbrands,项目名称:moodle-block_mystats,代码行数:24,代码来源:locallib.php


示例17:

/**
 * OpenID login fallback
 *
 * This file allows OpenID users to log in even if their provider is offline for
 * some reason.  It sends an email with a one-time link to the email address
 * associated with the requested OpenID url.
 *
 * @author Stuart Metcalfe <[email protected]>
 * @copyright Copyright (c) 2007 Canonical
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package openid
 **/
require_once "../../config.php";
require_once $CFG->dirroot . '/auth/openid/lib.php';
// We don't want to allow use of this script if OpenID auth isn't enabled
if (!is_enabled_auth('openid') && !is_enabled_auth('openid_sso')) {
    print_error('auth_openid_not_enabled', 'auth_openid');
}
$action = optional_param('openid_action', '', PARAM_CLEAN);
$url = optional_param('openid_url', null);
$data = optional_param('data', '', PARAM_CLEAN);
// Formatted as:  secret/username
$p = optional_param('p', '', PARAM_ALPHANUM);
// Old parameter:  secret
$s = optional_param('s', '', PARAM_CLEAN);
// Old parameter:  username
// First, we set the action if we're handling a submitted data string
if (!empty($data) || !empty($p) && !empty($s)) {
    $action = 'handle_data';
}
switch ($action) {
开发者ID:remotelearner,项目名称:elis.openid,代码行数:31,代码来源:fallback.php


示例18: send_password_change_info

/**
 * Sends an email containinginformation on how to change your password.
 *
 * @param stdClass $user A {@link $USER} object
 * @return bool Returns true if mail was sent OK and false if there was an error.
 */
function send_password_change_info($user)
{
    global $CFG;
    $site = get_site();
    $supportuser = core_user::get_support_user();
    $systemcontext = context_system::instance();
    $data = new stdClass();
    $data->firstname = $user->firstname;
    $data->lastname = $user->lastname;
    $data->sitename = format_string($site->fullname);
    $data->admin = generate_email_signoff();
    $userauth = get_auth_plugin($user->auth);
    if (!is_enabled_auth($user->auth) or $user->auth == 'nologin') {
        $message = get_string('emailpasswordchangeinfodisabled', '', $data);
        $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname));
        // 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);
    }
    if ($userauth->can_change_password() and $userauth->change_password_url()) {
        // We have some external url for password changing.
        $data->link .= $userauth->change_password_url();
    } else {
        // No way to change password, sorry.
        $data->link = '';
    }
    if (!empty($data->link) and has_capability('moodle/user:changeownpassword', $systemcontext, $user->id)) {
        $message = get_string('emailpasswordchangeinfo', '', $data);
        $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname));
    } else {
        $message = get_string('emailpasswordchangeinfofail', '', $data);
        $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname));
    }
    // 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:lucaboesch,项目名称:moodle,代码行数:41,代码来源:moodlelib.php


示例19: get_remote_courses

 function get_remote_courses()
 {
     global $CFG, $USER, $OUTPUT;
     if (!is_enabled_auth('mnet')) {
         // no need to query anything remote related
         return;
     }
     $icon = '<img src="' . $OUTPUT->pix_url('i/mnethost') . '" class="icon" alt="" />';
     // shortcut - the rest is only for logged in users!
     if (!isloggedin() || isguestuser()) {
         return false;
     }
     if ($courses = get_my_remotecourses()) {
         $this->content->items[] = get_string('remotecourses', 'mnet');
         $this->content->icons[] = '';
         foreach ($courses as $course) {
             $coursecontext = context_course::instance($course->id);
             $this->content->items[] = "<a title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" " . "href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&amp;wantsurl=/course/view.php?id={$course->remoteid}\">" . $icon . format_string(get_course_display_name_for_list($course)) . "</a>";
         }
         // if we listed courses, we are done
         return true;
     }
     if ($hosts = get_my_remotehosts()) {
         $this->content->items[] = get_string('remotehosts', 'mnet');
         $this->content->icons[] = '';
         foreach ($USER->mnet_foreign_host_array as $somehost) {
             $this->content->items[] = $somehost['count'] . get_string('courseson', 'mnet') . '<a title="' . $somehost['name'] . '" href="' . $somehost['url'] . '">' . $icon . $somehost['name'] . '</a>';
         }
         // if we listed hosts, done
         return true;
     }
     return false;
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:33,代码来源:block_course_list.php


示例20: restore_create_users


//.........这里部分代码省略.........
            $create_custom_profile_fields = true;
            $create_tags = true;
            $create_preferences = true;
            //If we are restoring course users and it isn't a course user
            if ($restore->users == 1 and !$is_course_user) {
                //If only restoring course_users and user isn't a course_user, inform to $backup_ids
                $status = backup_putid($restore->backup_unique_code, "user", $userid, null, 'notincourse');
                $create_user = false;
                $create_roles = false;
                $create_custom_profile_fields = false;
                $create_tags = false;
                $create_preferences = false;
            }
            if ($user_exists and $create_user) {
                //If user exists mark its newid in backup_ids (the same than old)
                $status = backup_putid($restore->backup_unique_code, "user", $userid, $newid, 'exists');
                $create_user = false;
                $create_custom_profile_fields = false;
                $create_tags = false;
                $create_preferences = false;
            }
            //Here, if create_user, do it
            if ($create_user) {
                //Unset the id because it's going to be inserted with a new one
                unset($user->id);
                /// Disable pictures based on global setting or existing empty value (old backups can contain wrong empties)
                if (!empty($CFG->disableuserimages) || empty($user->picture)) {
                    $user->picture = 0;
                }
                //We need to analyse the AUTH field to recode it:
                //   - if the field isn't set, we are in a pre 1.4 backup and $CFG->registerauth will decide
                //   - if the auth isn't enabled in target site, $CFG->registerauth will decide
                //   - finally, if the auth resulting isn't enabled, default to 'manual'
                if (empty($user->auth) || !is_enabled_auth($user->auth)) {
                    if ($CFG->registerauth == 'email') {
                        $user->auth = 'email';
                    } else {
                        $user->auth = 'manual';
                    }
                }
                if (!is_enabled_auth($user->auth)) {
                    // Final auth check verify, default to manual if not enabled
                    $user->auth = 'manual';
                }
                // Now that we know the auth method, for users to be created without pass
                // if password handling is internal and reset password is available
                // we set the password to "restored" (plain text), so the login process
                // will know how to handle that situation in order to allow the user to
                // recover the password. MDL-20846
                if (empty($user->password)) {
                    // Only if restore comes without password
                    if (!array_key_exists($user->auth, $authcache)) {
                        // Not in cache
                        $userauth = new stdClass();
                        $authplugin = get_auth_plugin($user->auth);
                        $userauth->preventpassindb = $authplugin->prevent_local_passwords();
                        $userauth->isinternal = $authplugin->is_internal();
                        $userauth->canresetpwd = $authplugin->can_ 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP is_enrolled函数代码示例发布时间:2022-05-15
下一篇:
PHP is_enabled函数代码示例发布时间: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