YULUserInfoFormatter.class.php 2.27 KB
<?php
/**
 * 用户信息格式器. 用来格式化产生插入日志数据库中的用户信息消息.消息格式如下
 * 
 * 用户ID|加密码|模块|消息类型|消息内容
 * 
 * @author dan
 *
 */
class YULUserInfoFormatter extends YULMessageFormatter
{
    const WAVE_SEARCH_COND = 0;
    const WAVE_MARK = 1;
    const OPT_MSG_SEND = 2;
    const LOGIN_INFO = 3;
    const LOGOUT_INFO = 4;
    const REG_RESET_PWD = 5;
    const MAIL_BOX = 6;
    const CELL_PHONE = 7;
    const IM = 8;
    const PWD_PROT_QUESTION = 9;
    const PWD_PROT_ANSWER = 10;
    const USER_REAL_NAME = 11;
    const USER_SEX = 12;
    const USER_AGE = 13;
    
    private $formatter = array(
                             // 消息类型
	                         'type'=>self::USER_INFO_TYPE,
	                         //用户ID
	                         'userID'=>0,
                             //加密码
	                         'skey'=>null,
	                         //模块
	                         'module'=>null,
		                     //消息类型
	                         'infoType'=>null,
		                     //消息内容
	                         'content'=>null,
                         );
    
    function __construct()
    {
        
    }
    
    public function setUserID($userID)
    {
        if (isset($userID))
        {
            $this->formatter['userID'] = $userID;
        }
    }
    
    public function setSkey($skey)
    {
        if (isset($skey))
        {
            $this->formatter['skey'] = $skey;
        }
    }
    
    public function setModule($module)
    {
        if (isset($module))
        {
            $this->formatter['module'] = $module;
        }
    }
    
    public function setInfoType($infoType)
    {
        if (isset($infoType))
        {
            $this->formatter['infoType'] = $infoType;
        }
    }
    
    public function setContent($content)
    {
        if (isset($content))
        {
            $this->formatter['content'] = $content;
        }
    }
	/**
	 * 
	 */
	public function toString()
	{
		$result = '';
	    
	    $separator = $this->getSeparator();
	    
	    foreach ($this->formatter as $format)
	    {
	        $result .= $format;
	        $result .= $separator;
	    }
	    
	    return trim($result, $separator);
	}

}
?>