<?php
class CustomPage extends ComPage {
	public function CustomPage(){
		$this->ComPage();
	}
	public function OnLoadPreData(){
		parent::OnLoadPreData();
		//-- ------ #Menu ------ --
		//-- #MENU --
		$tmpSTR=str_replace($this->sysSiteHome,'../../../',$this->sysPage);
		$tmpData0=$this->sApp_Menu->getMenuid(0,$tmpSTR,'QPlatform');
		if(count($tmpData0)>0){
			$this->sMenuid=$tmpData0[0]['smetID'];
		}
		
		return 0;
	}
	public function checkUser($pType){
		$tmpCode=new netsCode();
		$tmpDescription=array();
		$tmpDescription[0]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserinfo'];
		$tmpDescription[1]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserinfocont'];
		$tmpDescription[2]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserunit'];
		$tmpDescription[3]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserunitcont'];
		$tmpDescription[4]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertype'];
		$tmpDescription[5]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertypecont'];
		$tmpDescription[6]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartment'];
		$tmpDescription[7]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartmentcont'];
		$tmpDescription[8]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergroup'];
		$tmpDescription[9]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergrade'];
		$tmpUserApp=new netsuserinfo($this->sConnString);
		$tmpSTR='uttType';
		$tmpDescription[4]['Columns'][$tmpSTR]['Value']=$pType;
		
		$tmpINT=$tmpUserApp->ReadUserinfo($tmpDescription,'','');
		if($tmpINT!=0){
			$tmpINT=$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.$this->sysQPlatformPLURLCookieName,$this->sysURL);
			header('Location: '.$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['QPlatformLogoutAddress']);
			exit();
		}
		$this->sUserInfo=$tmpDescription;
		if ($this->sFunctionname!='') {
			$tmpUserApp->GetUserPowerArray($this->sUserInfo,$this->sFunctionname,'Mana',$this->sAR_UserPower);
		}
		if (in_array($this->sFunctionname.'_view',$this->sAR_UserPower) && count($this->sAR_UserPower)>1) {
			$tmpINT=$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.$this->sysManaPLURLCookieName,$this->sysURL);
			header('Location: '.$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['ManaPageNopower']);
			exit();
		}
		$this->sMainUserid=$tmpCode->Int32($this->sUserInfo[0]['Columns']['uitID']['Value'],0);
		//-- ------ #Get config and path ------ --
		if(count($this->sUserInfo)>0){
			$this->resetConfig($this->sUserInfo[3]['Columns']['uuctSysConfig']['Value']);
			if($this->sUserInfo[0]['Columns']['uitUnitid']['Value']<12){
				$this->sSiteRoot=$this->sSiteRootCore;
				$this->sFileConfigPath=$this->sFileConfigPathCore;
				$this->sUiDescriptionPath=$this->sUiDescriptionPathCore;
				$this->sDbDescriptionPath=$this->sDbDescriptionPathCore;
				$this->sConnString=$this->sConnStringCore;
			}
		}else{
			$this->sSiteRoot=$this->sSiteRootCore;
			$this->sFileConfigPath=$this->sFileConfigPathCore;
			$this->sUiDescriptionPath=$this->sUiDescriptionPathCore;
			$this->sDbDescriptionPath=$this->sDbDescriptionPathCore;
			$this->sConnString=$this->sConnStringCore;
		}
		return 0;
	}
	public function checkPagepower($pFlag,$pUsertypePowers){
		$tmpAR0=explode($this->sysSPLIT1,$pUsertypePowers);
		foreach ($tmpAR0 as $Row0){
			if ($Row0==$pFlag) {
				header('Location: '.$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['QPlatformPageNopower']);
				exit();
			}
		}
		
		return 0;
	}
	
}
?>