Prev | Current Page 186 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

$loginUrl . '">Log in'; #5
}
return $string;
}
}
(annotation) <#1. Save view object.>
(annotation) <#2. Are we logged in?.>
(annotation) <#3. Get the user record.>
(annotation) <#4. Use a view helper for the url.>
(annotation) <#5. Create string for display.>
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Set setView() function (#1) is automatically called by the view before calling the main helper function. We
use it to store a local reference to the view so that we can reference another view helper, linkTo() (#4). This is
the same view helper that we created earlier in Listing 6.5 and is usefully re-used here.
The actual work is done within the loggedInUser() function. The Zend_Auth function hasIdentity() is used
to check if there is a logged in user (#2). If there is, then we the user??™s record is retrieved using the
getIdentity() function (#3). As the user can select their own username, we use the escape() function to ensure
that we don??™t accidentally introduce an XSS vulnerability and then create the string to display. If the current
visitor is not logged in, a string is created with a link to allow the user to log in.


Pages:
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
zakłady bukmacherskie przeszycia łódź czlowiek.cieszyn.pl wróżby miłosne poker