本文整理汇总了PHP中is_enabled_auth函数的典型用法代码示例。如果您正苦于以下问题:PHP is_enabled_auth函数的具体用法?PHP is_enabled_auth怎么用?PHP is_enabled_auth使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_enabled_auth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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') . '" /> ';
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;
}
示例4: execute
/**
* Run users sync.
*/
public function execute()
{
global $CFG;
if (is_enabled_auth('cas')) {
$auth = get_auth_plugin('cas');
$auth->sync_users(true);
}
}
示例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;
}
示例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.");
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}