• カテゴリ お決まりのパターン の最新配信
  • RSS
  • RDF
  • ATOM

ブログ - ユーザ情報をゲストから隠す

ユーザ情報をゲストから隠す

カテゴリ : 
Customize/Hackメモ » お決まりのパターン
執筆 : 
masa 2008/6/1
デフォルト状態では XCL ではゲストからもユーザ情報が参照できてしまう。

これを隠すには、以下のようにプリロードで対処する。
情報元:
http://eve.neverever.xrea.jp/modules/d3forum/index.php?topic_id=22

設定:
以下のコードを /preload/UserinfoGuard.class.php として配置する。


<?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_URL, 1, "Access Denided!");
    }

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


基本的な注意として、最後の行の ?> 以下に空行などがあると、ワーニングが出るので注意。
  • トラックバック (0)
  • 閲覧 (4494)