Where To Run Notification Checks

I’m looking to develop a notification system - to check for unread messages etc - the notification would run a couple of different controllers. Where is the best place to run the checks from?

I was thinking of breaking into the authentication side, and running it there somewhere (would obviously only run if logged in) This feels like a bit of a hack though! I’m wondering if there is somewhere more appropriate.

Thanks

I would recommend using Yii’s event system:

Put this in main configuration file:


'behaviors' => array(

    'onBeginRequest' => array(

         'class' => 'application.components.CheckNotification',

     ),

),

And put this into components:


class CheckNotification extends CBehavior

{

    public function attach($owner)

    {

        $owner->attachEventHandler('onBeginRequest', array($this, 'handleBeginRequest'));

    }


    public function handleBeginRequest($event)

    {

        //here comes actual code

    }

}

This way you will have a piece of code executed before each and every page request.

I hope this may be of any help.

Just to say that this worked perfectly Ziggi! but alas I got lost on the next problem and forgot to say!

Cheers :)

@mboz62 … can I ask a que. ?? :-X

How you settled up the table structure for notification system ????

@mboz62 … can I ask a que. ?? :-X

How you settled up the table structure for notification system ????