UriMemory - ullright referer handling

The UriMemory class is used for referer handling.

It allows saving and retrieval of URIs per given symfony module/action.

The URIs are saved in the user session using the format "uri_$module_$action" e.g. "uri_ullWiki_list".

The most obvious usecase is when an action has to return to the previous action, which is not hardcoded.

 

Example:

  • I'm on a page e.g. ullWiki/list/search/foobar
  • I click on login and enter my username and password
  • After the login I want to be returned to the initial page "ullWiki/list/search/foobar"

 

Initalisation

A new UriMemory is initialized and assigend to $this->uriMemory in BaseUllsfActions::preExecute(), which is the parent sfActions class for all ullright modules.

 

Configuration

The Modules e.g. ullFlow, configure UriMemory using the BaseMyModuleActions::ullpreExecute() method.

Usually they set the default (fallback) Uri using UriMemory::setDefault($defaultUri).

 

Example for ullWiki:

class BaseUllWikiActions extends ullsfActions
{
  public function ullpreExecute()
  {
    $defaultUri = $this->getModuleName() . '/list';

    $this->getUriMemory()->setDefault($defaultUri);

    ... 
  }
}

Setting / Saving an URI

A URI can be saved by calling setUri(). By default the current module/action is used and must not be given.

Also by default the current URI is saved.

 

A convinience method is setReferer(). This method saves the URI of the current HTTP_REFERER.

 

Getting / Loading an URI

To load an URI for a specific module/action use UriMemory::get();

 

Again a convinience method is getAndDelete() which also removes the URI from the user session.

 

NoAccess Handling

A special case is the handling of no access.

 

Usually in the action there is some kind of access check. The access check can fail for two reasons: 1. There is no logged in user, so the access can't be checked 2. The currently logged in user has no access.

 

In the first case the user has to login first, so that the access can be checked.

 

Example for ullFlow/edit/doc/123:

  • I'm not logged in
  • I access ullFlow/edit/doc/123
  • The access check fails (because I'm not logged in)
  • BaseullsflActions::redirectToNoAccessUnless() saves the requested URI (ullflow/edit/doc/123) as "uri_ullUser_noaccess" and redirects to the action "ullUser/noaccess".
  • The action "ullUser/noaccess" (BaseUllUserActions::executeNoaccess()) checks if the user is logged in.
    If so, it displays a no access message.
    If not, it forwards to the action "ullUser/login" and gives the parameter "option=noaccess"
  • The login action (BaseUllUserActions::executeLogin) checks for the "noaccess" option and if set gets and deletes the "uri_ullUser_noaccess" UriMemory and saves it as "uri_ullUser_login" UriMemory, which is the URI to which the login redirects afterwards.
  •