<?php 
/**
* @用户信息函数类
*/
class getforum extends hon6mysql {
		public function __construct($path =''){
				parent::mysql_link();
		}
		/**/
		public function getforumdate($str,$forumid){
				$forumid = isset($forumid)?intval($forumid):0;
				$this->forumdate = $this->query_field("select ".$str." from ".JIEQI_DB_PREFIX."_forum_forums where forumid=".$forumid);
				return $this->forumdate;
		}
		public function CheckPermissions($classid,$way,$groupid){
				$classid = isset($classid)?intval($classid):0;
				$groupid = isset($groupid)?intval($groupid):1;
				if($groupid == 2){
						$this->result = 1;
				}else{
						$this->forumdates = unserialize($this->getforumdate($way,$classid));
						if(is_array($this->forumdates)){
								if(in_array($groupid,$this->forumdates)){
										$this->result = 1;
								}else{
										$this->result = 0;
								}
						}else{
								switch($way){
										case "authview":
												$this->result = 1;//默认允许浏览
												break;
										case "authread":
												$this->result = 1;//默认允许阅读
												break;
										case "authpost":
												$this->result = 1;//默认允许发表
												break;
										case "authreply":
												$this->result = 1;//默认允许回复
												break;
										case "authupload":
												$this->result = 1;//默认允许上传
												break;
										case "authedit":
												$this->result = 1;//默认允许编辑
												break;
										case "authdelete":
												$this->result = 1;//默认允许删除
												break;
								}
						}
				}
				if($this->result==0){
						return false;
				}else{
						return true;
				}
		}
		public function CheckAdmin($classid,$userid,$back){
				$classid = isset($classid)?intval($classid):0;
				$userid = isset($userid)?intval($userid):0;
				$this->result = 0;//初始化为非管理员
				$this->forumdates = unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'",$this->getforumdate("master",$classid)));
				if(is_array($this->forumdates)){
						$this->totalmaster = count($this->forumdates);
						for($i=0;$i<$this->totalmaster;$i++){
								if($this->forumdates[$i]["uid"] == $userid){
										$this->result = 1;//管理员
								}
						}
				}else{
						$this->result = 0;//默认为非管理员
				}
				$this->groupid = $this->query_field("select groupid from ".JIEQI_DB_PREFIX."_system_users where uid=".$userid);
				if($this->groupid == 2 or $this->groupid == 10){
						$this->result = 1;//管理员
				}
				if($back == "1"){
						if($this->result==0 or $this->result==""){
								return false;
						}else{
								return true;
						}
				}else{
						return $this->result;
				}
		}
}
?>