<?php
/**************************************************
*  Created:  2010-06-08
*
*  文件说明
*
*  @Xweibo (C)1996-2099 SINA Inc.
*  @Author xionghui <xionghui1@staff.sina.com.cn>
*
***************************************************/

class adminUser 
{
	var $uidField;
	function adminUser($uidField='admin_id') {
		$this->uidField = $uidField;
	}
	
	function initUser(){
		if (!defined('IS_SESSION_START') || !IS_SESSION_START ){
			session_start();
		}
	}
	
	function setInfo($k,$v=false){
		if (!isset($_SESSION[WB_ADMIN_SESSION])){
			$_SESSION[WB_ADMIN_SESSION] = array();
		}
		if( is_array($k) ){
			$_SESSION[WB_ADMIN_SESSION] = array_merge($_SESSION[WB_ADMIN_SESSION],$k);
		}else{
			$_SESSION[WB_ADMIN_SESSION][$k] = $v;
		}
		
	}
	
	function delInfo($k){
		if (!isset($_SESSION[WB_ADMIN_SESSION])){
			return true;
		}
		if(!is_array($k)) {$k = array($k);}
		foreach($k as $kv ){
			if (isset($_SESSION[WB_ADMIN_SESSION][$kv]))  unset($_SESSION[WB_ADMIN_SESSION][$kv]);
		}
		return true;
	}
	
	function getInfo($key=false){
		return (is_array($_SESSION[WB_ADMIN_SESSION]) && $key ) ?  $_SESSION[WB_ADMIN_SESSION][$key] : $_SESSION[WB_ADMIN_SESSION];
	}
	
	function isLogin(){
		$r = $this->getInfo($this->uidField);
		return !empty($r);
	}
}
?>