<?php
class commmicroblogging extends netsDb {
	private $sysErrorClassID='0000';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	
	public function commmicroblogging($pConnection){
		$this->netsDb($pConnection);
	}
	public function Check(&$pTableDescriptAR,$pExceptionAR1,$pExceptionAR2){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		
		if(count($pExceptionAR1)==0){
			$pExceptionAR1=array();
		}
		parent::Check($pTableDescriptAR,$pExceptionAR1,$pExceptionAR2);
		//
		$tmpSTR='combtName';
		if(strlen($pTableDescriptAR[0]['Columns'][$tmpSTR]['Value'])<1 && !in_array($tmpSTR,$pExceptionAR2)){
			$this->sysLastError='提交内容错误:1.名称不能为空';
			return $this->sysErrorFuncID.'001';
		}
		return 0;
	}
	
	public function initialObject($pID){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$tmpCode=new netsCode();
		$tmpHtml=new netsHtml();
		$this->TransStart();
		//-- ------ #Check cookie exist ------ --
		//Get cookie
		$tmpCookieName=$this->sysCookieHead.'Cookie_CommMicroblogging_'.$pID;
		$tmpAR0=$tmpHtml->AnalyerRequest($tmpCookieName,'',2);
		//-- ------ #Update data ------ --
		//-- #Update Discuss --
		$tmpCountConfigs=array();
		//#Info
		$tmpAR1=$this->sCountUpdateConfig_Template;
		$tmpAR1['Parent_TableName']=$this->sysTableHead.'commmicrobloggingcont';
		$tmpAR1['Parent_CountColumnName']='combctCount_Discuss';
		$tmpAR1['Parent_Condition']=' AND combctID='.$pID;
		$tmpAR1['Child_A_TableName']=$this->sysTableHead.'commmicrobloggingdiscuss';
		$tmpAR1['Child_A_CountColumnName']='combdtID';
		$tmpAR1['Child_A_Condition']=' AND combdtRecycle=0 AND combdtChecked>1 AND combdtParid='.$pID;
		$tmpCountConfigs[]=$tmpAR1;
		//#Group
		$tmpSQL=' SELECT A.combtID,A.combtParid
			FROM {Nets.TableHead}commmicroblogging AS A 
			WHERE 1=1 AND A.combtRecycle=0 AND A.combtChecked>1 AND A.combtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$pID,$tmpSTR);
		$tmpData0=$this->Search($tmpSTR);
		$tmpParid=0;
		if (count($tmpData0)>0) {
			$tmpParid=$tmpData0[0]['combtParid'];
		}
		
		$tmpAR1=$this->sCountUpdateConfig_Template;
		$tmpAR1['Parent_TableName']=$this->sysTableHead.'commmicroblogginggroupcont';
		$tmpAR1['Parent_CountColumnName']='combgctCount_Info';
		$tmpAR1['Parent_Condition']=' AND combgctID='.$tmpParid;
		$tmpAR1['Child_A_TableName']=$this->sysTableHead.'commmicroblogging';
		$tmpAR1['Child_A_CountColumnName']='combtID';
		$tmpAR1['Child_A_Condition']=' AND combtRecycle=0 AND combtChecked>1 AND combtParid='.$tmpParid;
		$tmpCountConfigs[]=$tmpAR1;
		
		$tmpINT=$this->updateCount($tmpCountConfigs);
		//-- #Update Hit --
		if($tmpAR0[0]==''){
			$tmpSQL=' UPDATE {Nets.TableHead}commmicrobloggingcont SET combctCount_Views=combctCount_Views+1 WHERE 1=1 AND combctIndexID={Nets.ID} ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.ID}',$pID,$tmpSTR);
			$tmpINT=$this->Execute($tmpSTR);
			if($tmpINT!=0){
				$this->sysLastError='更新微博数据时出错，请稍后再试。';
				$this->TransRollback();
				return $tmpINT;
			}
			$this->writeCookie($this->sysNormalCookiePath,$tmpCookieName,1);
		}
		
		$this->TransCommit();
		return 0;
	}
	
}
?>