<?php
class mx_user extends spModel
{
    var $pk="us_id";
    var $table="mxszpt_user";

    var $verifier_login=array(
         "rules"=>array(
            'us_name'=>array(
               'notnull'=>TRUE,
               'minlength'=>2,
               'maxlength'=>12,
            ),
            'us_password'=>array(
                'notnull'=>TRUE,
                'minlength'=>3,
                'maxlength'=>90,
            ),
         ),
         
         "messages"=>array(
            'us_name'=>array(
               'notnull'=>"用户名不能为空！",
               'minlength'=>"用户名最小不能少于2个字符",
               'maxlength'=>"用户名最大不能大于12个字符"
            ),
             'us_password'=>array(
               'notnull'=>"密码不能为空！",
               'minlength'=>"密码最小不能少于3个字符",
               'maxlength'=>"密码最大不能大于90个字符",
             ),
         ),
    );
    
    
     var $verifier_adminadd = array(
		"rules" => array( 
			'us_name' => array( 
				'notnull' => TRUE, 
				'minlength' => 2, 
				'maxlength' => 12, 
			),
            'us_nickname' => array( 
				'notnull' => TRUE, 
				'minlength' => 2, 
				'maxlength' => 12, 
			),
			'us_password' => array(  
				'notnull' => TRUE, 
				'minlength' => 3, 
				'maxlength' => 90,
			),
		),
		"messages" => array( 
			'us_name' => array(
				'notnull' => "帐号不能为空", 
				'minlength' => "帐号长度不能少于2个字符",  
				'maxlength' => "帐号长度不能大于12个字符",
			),
            'us_nickname' => array(  
				'notnull' => "商户名不能为空", 
				'minlength' => "商户名长度不能少于2个字符",  
				'maxlength' => "商户名长度不能大于12个字符",
			),
			'us_password' => array(  
				'notnull' => "密码不能为空", 
				'minlength' => "密码长度不能少于3个字符",  
				'maxlength' => "密码长度不能大于90个字符", 
			),
		),
	);

    public function userlogin($us_name,$us_password){
        $conditions=array(
           'us_name'=>$us_name,
           'us_password'=>$us_password,
        );
        	if( $result = $this->find($conditions) ){ 
			spClass('spAcl')->set($result['acl']); 
			$_SESSION["userinfo"] = $result; 
			return true;
		}else{
			return false;
		}
    }
  
      	public function acljump(){ 
		$url = spUrl("main","index");
		echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=gbk\"><script>function sptips(){alert(\"您没有权限进行此操作，请登录！\");}</script></head><body onload=\"sptips()\"></body></html>";
		exit;
	}
}
?>