本文整理汇总了PHP中Core\Session\manager::terminate_current方法的典型用法代码示例。如果您正苦于以下问题:PHP manager::terminate_current方法的具体用法?PHP manager::terminate_current怎么用?PHP manager::terminate_current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core\Session\manager
的用法示例。
在下文中一共展示了manager::terminate_current方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_terminate_current
public function test_terminate_current()
{
global $USER;
$this->resetAfterTest();
// This can not be tested much without real session...
$this->setAdminUser();
\core\session\manager::terminate_current();
$this->assertEquals(0, $USER->id);
}
示例2: redirect_if_major_upgrade_required
/**
* Check whether a major upgrade is needed. That is defined as an upgrade that
* changes something really fundamental in the database, so nothing can possibly
* work until the database has been updated, and that is defined by the hard-coded
* version number in this function.
*/
function redirect_if_major_upgrade_required()
{
global $CFG;
$lastmajordbchanges = 2014040800.0;
if (empty($CFG->version) or (double) $CFG->version < $lastmajordbchanges or during_initial_install() or !empty($CFG->adminsetuppending)) {
try {
@\core\session\manager::terminate_current();
} catch (Exception $e) {
// Ignore any errors, redirect to upgrade anyway.
}
$url = $CFG->wwwroot . '/' . $CFG->admin . '/index.php';
@header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
@header('Location: ' . $url);
echo bootstrap_renderer::plain_redirect_message(htmlspecialchars($url));
exit;
}
}
示例3: require_logout
/**
* This function just makes sure a user is logged out.
*
* @package core_access
* @category access
*/
function require_logout()
{
global $USER, $DB;
if (!isloggedin()) {
// This should not happen often, no need for hooks or events here.
\core\session\manager::terminate_current();
return;
}
// Execute hooks before action.
$authplugins = array();
$authsequence = get_enabled_auth_plugins();
foreach ($authsequence as $authname) {
$authplugins[$authname] = get_auth_plugin($authname);
$authplugins[$authname]->prelogout_hook();
}
// Store info that gets removed during logout.
$sid = session_id();
$event = \core\event\user_loggedout::create(array('userid' => $USER->id, 'objectid' => $USER->id, 'other' => array('sessionid' => $sid)));
if ($session = $DB->get_record('sessions', array('sid' => $sid))) {
$event->add_record_snapshot('sessions', $session);
}
// Clone of $USER object to be used by auth plugins.
$user = fullclone($USER);
// Delete session record and drop $_SESSION content.
\core\session\manager::terminate_current();
// Trigger event AFTER action.
$event->trigger();
// Hook to execute auth plugins redirection after event trigger.
foreach ($authplugins as $authplugin) {
$authplugin->postlogout_hook($user);
}
}
示例4: array
/**
* Logout from the CAS
*
*/
function prelogout_hook()
{
global $CFG, $USER, $DB;
if (!empty($this->config->logoutcas) && $USER->auth == $this->authtype) {
$backurl = !empty($this->config->logout_return_url) ? $this->config->logout_return_url : $CFG->wwwroot;
$this->connectCAS();
// Note: Hack to stable versions to trigger the event before it redirect to CAS logout.
$sid = session_id();
$event = \core\event\user_loggedout::create(array('userid' => $USER->id, 'objectid' => $USER->id, 'other' => array('sessionid' => $sid)));
if ($session = $DB->get_record('sessions', array('sid' => $sid))) {
$event->add_record_snapshot('sessions', $session);
}
\core\session\manager::terminate_current();
$event->trigger();
phpCAS::logoutWithRedirectService($backurl);
}
}
示例5: list
require "{$CFG->dirroot}/version.php";
// defines $version, $release, $branch and $maturity
$CFG->target_release = $release;
// used during installation and upgrades
if (!$version or !$release) {
print_error('withoutversion', 'debug');
// without version, stop
}
if (!core_tables_exist()) {
$PAGE->set_pagelayout('maintenance');
$PAGE->set_popup_notification_allowed(false);
// fake some settings
$CFG->docroot = 'http://docs.moodle.org';
$strinstallation = get_string('installation', 'install');
// remove current session content completely
\core\session\manager::terminate_current();
if (empty($agreelicense)) {
$strlicense = get_string('license');
$PAGE->navbar->add($strlicense);
$PAGE->set_title($strinstallation . ' - Moodle ' . $CFG->target_release);
$PAGE->set_heading($strinstallation);
$PAGE->set_cacheable(false);
/** @var core_admin_renderer $output */
$output = $PAGE->get_renderer('core', 'admin');
echo $output->install_licence_page();
die;
}
if (empty($confirmrelease)) {
require_once $CFG->libdir . '/environmentlib.php';
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
$strcurrentrelease = get_string('currentrelease');
示例6: test_terminate_current
public function test_terminate_current()
{
global $USER, $SESSION;
$this->resetAfterTest();
$this->setAdminUser();
\core\session\manager::terminate_current();
$this->assertEquals(0, $USER->id);
$this->assertInstanceOf('stdClass', $SESSION);
$this->assertEmpty((array) $SESSION);
$this->assertSame($GLOBALS['SESSION'], $_SESSION['SESSION']);
$this->assertSame($GLOBALS['SESSION'], $SESSION);
$this->assertInstanceOf('stdClass', $USER);
$this->assertEquals(array('id' => 0, 'mnethostid' => 1), (array) $USER, '', 0, 10, true);
$this->assertSame($GLOBALS['USER'], $_SESSION['USER']);
$this->assertSame($GLOBALS['USER'], $USER);
}
示例7: RWSLOMUser
function RWSLOMUser()
{
global $USER;
global $CFG;
global $DB;
global $RWSECAS;
if (!$RWSECAS) {
require_logout();
RWSSStat("1001");
}
if (respondusws_floatcompare($CFG->version, 2010122500, 2) >= 0) {
if (isloggedin()) {
$r_aus = get_enabled_auth_plugins();
foreach ($r_aus as $r_aun) {
$r_aup = get_auth_plugin($r_aun);
if (strcasecmp($r_aup->authtype, RWSCAS) == 0) {
$r_csp = $r_aup;
RWSPLOCas($r_csp);
} else {
$r_aup->prelogout_hook();
}
}
}
if (respondusws_floatcompare($CFG->version, 2014051200, 2) >= 0) {
$r_ssi = session_id();
$r_evt = \core\event\user_loggedout::create(array('userid' => $USER->id, 'objectid' => $USER->id, 'other' => array('sessionid' => $r_ssi)));
if ($r_ses = $DB->get_record('sessions', array('sid' => $r_ssi))) {
$r_evt->add_record_snapshot('sessions', $r_ses);
}
\core\session\manager::terminate_current();
$r_evt->trigger();
} else {
$r_prms = $USER;
events_trigger('user_logout', $r_prms);
if (respondusws_floatcompare($CFG->version, 2013111800, 2) >= 0) {
\core\session\manager::terminate_current();
} else {
session_get_instance()->terminate_current();
}
unset($r_prms);
}
} else {
RWSSErr("2006,{$CFG->version},2010122500");
}
RWSSStat("1001");
}