How to: Ban access to userinfo anchor.png

This example demonstrates how to ban userinfo.php access to anonymous users. When users access userinfo.php, the Legacypage.Userinfo.Access delegate as an event is called through the delegate manager. And, the standard user module adds its own function to this event.

If the site owner doesn't hope that anonymous user can't access userinfo.php, site ploread mechanism is useful.


<?php
/**
 * @file preload/UserinfoGuard.class.php
 */

if (!defined('XOOPS_ROOT_PATH')) exit();

class UserinfoGuard extends XCube_ActionFilter~
{
  function preFilter()
  {
    $root =& XCube_Root::getSingleton();
    
    //
    // Add my function as the first part priority to Legacypage.Userinfo.Access
    // By that, my function will be called early than the user module.
    //
    $root->mDelegateManager->add('Legacypage.Userinfo.Access',
                                 'UserinfoGuard::myfunc',
                                 XCUBE_DELEGATE_PRIORITY_FIRST 10);
  }

  function myfunc()
  {
    $root =& XCube_Root::getSingleton();
    $user =& $root->mContext->mUser;
    if ($user->isInRole('Site.GuestUser')) {    
      $root->mController->executeRedirect(XOOPS_URL1"Access Denided!");
    }

    //
    // Delegate of XCube calls all of added functions.
    // Therefore, after this function, the regular function will be called.
    //
  }
}
?>


Page Top

Task anchor.png


Front page   Freeze Diff Backup Copy Rename ReloadPrint View   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom) Powered by xpWiki
Counter: 22135, today: 1, yesterday: 1
Princeps date: 2007-01-14 (Sun) 11:52:59
Last-modified: 2007-01-14 (Sun) 11:52:59 (JST) (4515d) by Anonymous

Welcome | News | Overview | Documentation | Forum | Tutorialstop
Brasilian | French | German | Greek | Japanese | Korean | Russian | T-Chinese
Powered by XOOPS Cube 2001-2011 The XOOPS Cube Project