Location: PHPKode > projects > RabbitBB - Online Web Storage Project > mywebdrive/PHP_CON/general/DAOGAuth.php
<?PHP

class DAOGAuth
{
	var $db;
	var $db_table;
	var $db_field;
	
	function DAOGAuth()
	{
		global $db, $db_table, $db_field;
		$this->db = $db;
		$this->db_table = $db_table;
		$this->db_field = $db_field;
	}

	function getuserparamattr($_filedirdb, $_user_id)
	{
		$sqlq = new SQLSelect();
		if ($_filedirdb->gettype()==SFILE)
		{
			$sqlq->setSelect($this->db_field['userfileparamattr'], $this->db_table['userfileparamattr']);
			$sqlq->setWhere($this->db_table['userfileparamattr'].".filedb_id=".$_filedirdb->getid());
			$sqlq->setWhere($this->db_table['userfileparamattr'].".user_id=".$_user_id);

			return $this->populate($sqlq->getRow($this->db, $sqlq->SQLReturn()));
		}
		elseif ($_filedirdb->gettype()==DIRECTORY)
		{
			$sqlq->setSelect($this->db_field['userdirparamattr'], $this->db_table['userdirparamattr']);
			$sqlq->setWhere($this->db_table['userdirparamattr'].".dirdb_id=".$_filedirdb->getid());
			$sqlq->setWhere($this->db_table['userdirparamattr'].".user_id=".$_user_id);
			return $this->populate($sqlq->getRow($this->db, $sqlq->SQLReturn()));
		}
	}
	function getgroupparamattrbyuser($_filedirdb, $_user_id)
	{
		$sqlq = new SQLSelect();
		if ($_filedirdb->gettype()==SFILE)
		{
			$sqlq->setSelect($this->db_field['groupfileparamattr'], $this->db_table['groupfileparamattr']);
			$sqlq->setSelect($this->db_field['groupmemberlist'], $this->db_table['groupmemberlist']);
			$sqlq->setWhere($this->db_table['groupfileparamattr'].".filedb_id=".$_filedirdb->getid());
			$sqlq->setWhere($this->db_table['groupmemberlist'].".user_id=".$_user_id);
			$sqlq->setWhere($this->db_table['groupfileparamattr'].".group_id=".$this->db_table['groupmemberlist'].".group_id");
			return $this->populate($sqlq->getRow($this->db, $sqlq->SQLReturn()));
		}
		elseif ($_filedirdb->gettype()==DIRECTORY)
		{
			$sqlq->setSelect($this->db_field['groupdirparamattr'], $this->db_table['groupdirparamattr']);
			$sqlq->setSelect($this->db_field['groupmemberlist'], $this->db_table['groupmemberlist']);
			$sqlq->setWhere($this->db_table['groupdirparamattr'].".dirdb_id=".$_filedirdb->getid());
			$sqlq->setWhere($this->db_table['groupmemberlist'].".user_id=".$_user_id);
			$sqlq->setWhere($this->db_table['groupdirparamattr'].".group_id=".$this->db_table['groupmemberlist'].".group_id");
			return $this->populate($sqlq->getRow($this->db, $sqlq->SQLReturn()));
		}
	}

	function populate($_res)
	{
		$tobj=array();
		$tobj[DIRECTORY] = array();
		$tobj[SFILE] = array();
		if (isset($_res[$this->db_table['userfileparamattr']]))
		{
			$userfileparamattrres = $_res[$this->db_table['userfileparamattr']];
			for ($i=0; $i<count($userfileparamattrres); $i++)
			{
				$tobj[SFILE][] = $this->createparamattr($userfileparamattrres[$i], SFILE);
			}
			unset($userfileparamattrres);
		}
		if (isset($_res[$this->db_table['userdirparamattr']]))
		{
			$userdirparamattr = $_res[$this->db_table['userdirparamattr']];
			for ($i=0; $i<count($userdirparamattr); $i++)
			{
				$tobj[DIRECTORY][] = $this->createparamattr($userdirparamattr[$i], DIRECTORY);
			}
			unset($userdirparamattrres);
		}
		if (isset($_res[$this->db_table['groupfileparamattr']]))
		{
			$groupfileparamattrres = $_res[$this->db_table['groupfileparamattr']];
			for ($i=0; $i<count($groupfileparamattrres); $i++)
			{
				$tobj[SFILE][] = $this->createparamattr($groupfileparamattrres[$i], SFILE);
			}
			unset($groupfileparamattrres);
		}
		if (isset($_res[$this->db_table['groupdirparamattr']]))
		{
			$groupdirparamattr = $_res[$this->db_table['groupdirparamattr']];
			for ($i=0; $i<count($groupdirparamattr); $i++)
			{
				$tobj[DIRECTORY][] = $this->createparamattr($groupdirparamattr[$i], DIRECTORY);
			}
			unset($groupdirparamattrres);
		}

		return $tobj;
	}

	function createparamattr($_row, $_type)
	{
		if (isset($_row['user_id']))
		{
			if ($_type==SFILE)
			{
			   return new UserFileParamAttr($_row['id'], 
				$_row['filedb_id'], $_row['user_id'],
				$_row['owner'], $_row['allowread'],
				$_row['allowwrite']);
			}
			elseif ($_type==DIRECTORY)
			{
			   return new UserDirParamAttr($_row['id'], 
				$_row['dirdb_id'], $_row['user_id'],
				$_row['owner'], $_row['createdir'],
				$_row['updatedir'], $_row['deldir'],
				$_row['createfile'], $_row['updatefile'],
				$_row['delfile'], $_row['allowread']);
			}
		}
		elseif (isset($_row['group_id']))
		{
			if ($_type==SFILE)
			{
			   return new GroupFileParamAttr($_row['id'], 
				$_row['filedb_id'], $_row['group_id'],
				$_row['owner'], $_row['allowread'],
				$_row['allowwrite']);
			}
			elseif ($_type==DIRECTORY)
			{
			   return new GroupDirParamAttr($_row['id'], 
				$_row['dirdb_id'], $_row['group_id'],
				$_row['owner'], $_row['createdir'],
				$_row['updatedir'], $_row['deldir'],
				$_row['createfile'], $_row['updatefile'],
				$_row['delfile'], $_row['allowread']);
			}
		}
	}


}

?>
Return current item: RabbitBB - Online Web Storage Project