<?php
class Assunto extends UtilObjeto {

	public function __construct($params=""){
		parent::__construct(strtolower(get_class()), $params);
	}
	
	public function excluir(){
		if($this->permiteExcluir()){
			return parent::excluir();
		}
		else{
			return false;
		}
	}

	public function permiteExcluir(){
		global $db;
		$arrTabelas = array('rz2_contato');
		foreach($arrTabelas as $tabela){
			$sql = "SELECT count(*) total
					FROM   ".$tabela."
					WHERE  id_assunto = ".$this->id;
			$rs = $db->query($sql);
			$rg = $rs->fetchRow();
			if($rg['total'] > 0) return false;
		}
		return true;
	}

}
?>