class operationLimit
// operating limit. When no user login or is not this user
{
/* for limit the user operat at post.
* @author:xiaoai 8.12 2011
*/
static $limitObject;
public function __construct() {}
// when call the function but does not exist
public static function getObject()
{
if( !(self::$limitObject instanceof self))
self::$limitObject = new self;
return self::$limitObject ;
}
protected function setLimit() {}
public function getReadA($postName)
{
return '
'.php\' class=\'readmoreLink\'>readmore';
}
}
class operationUnlimit extends operationLimit
// when is this user
{
public static function getObject()
{
if( !(self::$limitObject instanceof self))
self::$limitObject = new self;
return self::$limitObject ;
}
public function getUpdateA($name)
{
return '
'.php?do=update\' id=\''.$name.'\' >update';
}
public function getDelectA($name)
{
return '
.');\' id=\'delectPOST\' >delect';
}
}
class LimitFactory
{
public static function getLimitObject($userStatus)
// $userStatus = $session->get_status();
{
switch ( $userStatus )
{
case 0:
return operationLimit::getObject();
case 1:
return operationUnlimit::getObject();
default:
return limit::getObject();
}
}
}
LimitFactory是一个工厂类,兼静态类。 即不需要构造对象,它的职责只是根据传入的用户权限值,来判断该返回 operationLimit类 还是 operationUnlimit类 的实例。