XCube_ActionFilter (3)


Perhaps, you might need to understand other mechanism of XOOPS Cube Legacy to make full use of Preload. Preload is the starting point for the most of the customizing.

But, it’s important to understand Preload now. So, let’s create an actual example with Preload only. That is ‘ForceSiteClose’. ForceSiteClose closes the site for all of users except specific IP. It’s useful for test, because a tester can access as an anonymous user to the site if the tester is from specific IP. By ForceSiteClose, site owners can close the site for visitors with doing test.

class ForceSiteClose extends XCube_ActionFilter
$mSpecificIPs = array(‘’);

function preFilter()
$ip = $_SERVER[‘REMOTE_IP’];
if (!
in_array($ip, $this->mSpecificmIPs)) {

function doSiteClose()
// You must rewrite the following for your expression.
print “This site is closed now, Because …”;

You may use this filter for a database trouble, because ForceSiteClose can work without a database. In contrast, the site close of XOOPS Cube Legacy can’t work under a database trouble.

Future XCube_ActionFilter

This is a note for developers who know much ActionFilter.

In Legacy_Controller, the ActionFilter feature is exclusive used for Site Preload and Module Preload. In other words, it exists for site owners and module developers to do customizing. Legacy_Controller doesn’t use the ActionFilter feature to build itself. Therefore, ActionFilter of some frameworks and ActionFilter in Legacy_Controller are different.

Mr,onokazu said it’s smart program that Legacy_Controller uses ActionFilter for building itself. His idea is really right and tempting. The class design of XCube_ActionFilter is enough for such use, because ActionFilter is simple mechanism.

Finally, we have decided to keep this design of Legacy_Controller, for clarification of the division of the roles played by actual example. It’s freedom that you use it for building the controller at your base module. And, some of base modules which will be released in the near future, may use ActionFilter for such purpose.

Keep in mind that we had kicked around such uses at least.

This entry was posted in XOOPS Cube. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s