How To Allow Specific Action In A Module?

Hi,

As title says, for example I want to allow only ‘view’ action from any controllers in a module, but allows all actions from any controllers outside a module, how to do that?




   public function accessRules()

   {

      return array(

         array('allow',

             'controllers' => '<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />', // what should i put here?

             'actions' => 'view',

         )

      );

   }



Thanks in advance.

You define the accessRules() in each controller.

Thanks for your reply.

But I don’t think it’s a good way to do it (sorry), because I will need to put the same accessRules on every controllers in the module and this module may be called from frontend and backend, and the accessRule will be different between frontend and backend.

Is there another solution? Thanks.

You could put it in a base class from which you extend each controller. Also, accessRules() is a method so it can embed some login that would return different set of rules depending on how the module containing that controller is used.

Ok, I guess I need to create another class to be extended for this purpose.

Thanks.