phpCAS::logoutWithRedirectServiceAndUrl PHP Method

logoutWithRedirectServiceAndUrl() public static method

This method is used to logout from CAS. Halts by redirecting to the CAS server.
Deprecation: The url parameter has been removed from the CAS server as of version 3.3.5.1
public static logoutWithRedirectServiceAndUrl ( string $service, string $url ) : void
$service string a URL that will be transmitted to the CAS server
$url string a URL that will be transmitted to the CAS server
return void
    public static function logoutWithRedirectServiceAndUrl($service, $url)
    {
        trigger_error('Function deprecated for cas servers >= 3.3.5.1', E_USER_DEPRECATED);
        phpCAS::traceBegin();
        phpCAS::_validateClientExists();
        if (!is_string($service)) {
            phpCAS::error('type mismatched for parameter $service (should be `string\')');
        }
        if (!is_string($url)) {
            phpCAS::error('type mismatched for parameter $url (should be `string\')');
        }
        self::$_PHPCAS_CLIENT->logout(array("service" => $service, "url" => $url));
        // never reached
        phpCAS::traceEnd();
    }

Usage Example

Beispiel #1
0
	/**
	 * @param string $user : username
	 * @param bool $remote : logged out remotely (so do not redirect)
	 * @param string $redir : url to redirect to. Uses home page according to prefs if empty
	 * @return void : redirects to suitable homepage or redir param if not remote
	 */
	function user_logout($user, $remote = false, $redir = '')
	{
		global $prefs, $logslib, $lslib, $user_cookie_site;

		$logslib->add_log('login', 'logged out');

		$userInfo = $this->get_user_info($user);
		$this->delete_user_cookie($userInfo['userId']);

		if ($remote && $prefs['feature_intertiki'] == 'y' and $prefs['feature_intertiki_sharedcookie'] == 'y' and !empty($prefs['feature_intertiki_mymaster'])) {
			include_once('XML/RPC.php');
			$remote = $prefs['interlist'][$prefs['feature_intertiki_mymaster']];
			$remote['path'] = preg_replace('/^\/?/', '/', $remote['path']);
			$client = new XML_RPC_Client($remote['path'], $remote['host'], $remote['port']);
			$client->setDebug(0);
			$msg = new XML_RPC_Message(
							'intertiki.logout',
							array(
								 new XML_RPC_Value($prefs['tiki_key'], 'string'),
								 new XML_RPC_Value($user, 'string')
							)
			);
			$client->send($msg);
			return;
		}

		// more local cleanup originally from tiki-logout.php

		// go offline in Live Support
		if ($prefs['feature_live_support'] == 'y') {
			global $access; include_once ('lib/live_support/lslib.php');
			if ($lslib->get_operator_status($user) != 'offline') {
				$lslib->set_operator_status($user, 'offline');
			}
		}
		setcookie($user_cookie_site, '', -3600, $prefs['cookie_path'], $prefs['cookie_domain']);
		/* change group home page or deactivate if no page is set */
		if (!empty($redir)) {
			$url = $redir;
		} else if (($groupHome = $this->get_group_home('Anonymous')) != '') {
			$url = (preg_match('/^(\/|https?:)/', $groupHome)) ? $groupHome : 'tiki-index.php?page=' . $groupHome;
		} else {
			$url = $prefs['site_tikiIndex'];
		}
		// RFC 2616 defines that the 'Location' HTTP headerconsists of an absolute URI
		if (!preg_match('/^https?\:/i', $url)) {
			global $url_scheme, $url_host, $url_port, $base_url;
			$url = (preg_match('#^/#', $url) ? $url_scheme . '://' . $url_host . (($url_port != '') ? ":$url_port" : '') : $base_url) . $url;
		}
		if (SID) 
			$url .= '?' . SID;

		if ( $prefs['auth_method'] === 'cas' && $user !== 'admin' && $user !== '' && $prefs['cas_force_logout'] === 'y' ) {
			phpCAS::logoutWithRedirectServiceAndUrl($url, $url);
		}
		unset($_SESSION['cas_validation_time']);
		unset($_SESSION[$user_cookie_site]);
		session_unset();
		session_destroy();

		if ($prefs['auth_method'] === 'ws') {
			header('Location: ' . str_replace('//', '//admin:@', $url)); // simulate a fake login to logout the user
		} else {
			header('Location: ' . $url);
		}
		return;
	}
All Usage Examples Of phpCAS::logoutWithRedirectServiceAndUrl