<![CDATA[ 0.9.6 doc parser: fixing userLoggedIn to display Manager User info on frontend - My Forums]]> https://forums.modx.com/thread/?thread=36384 <![CDATA[Re: 0.9.6 doc parser: fixing userLoggedIn to display Manager User info on fronte]]> https://forums.modx.com/thread/36384/0-9-6-doc-parser-fixing-userloggedin-to-display-manager-user-info-on-frontend#dis-post-205229
What really needs to happen is a parameter needs to be added, in accordance with the recent changes to DocumentParser :: getLoginUserID($context) and a few other methods. A context string is added which indicates specifically (’web’ or ’mgr’) which user information you want, and if empty, your logic to get the web context or the mgr context is right on. This will help forward compatibility with 0.9.7.]]>
opengeek Oct 16, 2007, 03:40 PM https://forums.modx.com/thread/36384/0-9-6-doc-parser-fixing-userloggedin-to-display-manager-user-info-on-frontend#dis-post-205229
<![CDATA[0.9.6 doc parser: fixing userLoggedIn to display Manager User info on frontend]]> https://forums.modx.com/thread/36384/0-9-6-doc-parser-fixing-userloggedin-to-display-manager-user-info-on-frontend#dis-post-205228 Note that if you call this on the frontend when logged in both as web and manager users, only the web user info will be returned.

<?php
    function userLoggedIn() {
        $webVal = isset($_SESSION['webValidated']);
        $mgrVal = isset($_SESSION['mgrValidated']);
        if ($this->isFrontend()){
		//on frontend
        	if ($webVal){
         	//webuser is logged in
         		$auth = true;
         		$type = 'web';
         		$prefix = 'web';
        	} elseif ($mgrVal){
        	//manager is logged in
        		$auth = true;
        		$type = 'manager';
        		$prefix = 'mgr';
        	} else {
        	//neither is logged in
        		$auth = false;
        	}
        } elseif ($this->isBackend() && $mgrVal){
		//inside manager and authenticated
			$auth = true;
			$type = 'manager';
    		$prefix = 'mgr';
        } else {
		//if all else fails...
        	$auth = false;
        }
        if ($auth){
		//if some user logged in...
			$userdetails= array (
				'loggedIn' => true,
				'id' => $_SESSION[$prefix.'InternalKey'],
				'username' => $_SESSION[$prefix.'Shortname'],
				'usertype' => $type // added by Raymond
			);
            return $userdetails;
        }else{
        	return false;
        }
    }
?>


Reported this on Flyspray and the wiki]]>
joeindio Oct 16, 2007, 02:48 PM https://forums.modx.com/thread/36384/0-9-6-doc-parser-fixing-userloggedin-to-display-manager-user-info-on-frontend#dis-post-205228