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

class DAOAddAuth
{
	var $db;
	var $db_table;
	var $db_field;

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

	function addAuth($_id, $_authlist, $_type)
	{
		if ($_type==SFILE)
		{
			$sqlq = "INSERT INTO ".
				$this->db_table['userfileparamattr'].
				" (filedb_id, user_id, owner, allowread, allowwrite) VALUES" .
				" (".$_id.",".NSession::getuid().",".
				NSession::getuid().",".
				"'Y'".",".
				"'Y'".")";
			if (!$this->db->sql_query($sqlq))
			{
				return false;
			}
		}
		elseif ($_type==DIRECTORY)
		{
			$sqlq = "INSERT INTO ".
				$this->db_table['userdirparamattr'].
				" (dirdb_id, user_id, owner, createdir, updatedir, deldir, ".
				"createfile, updatefile, delfile, allowread) VALUES".
				" (".$_id.",".NSession::getuid().",".
				NSession::getuid().","."'Y'".",".
				"'Y'".","."'Y'".",".
				"'Y'".","."'Y'".",".
				"'Y'".","."'Y'".")";
			if (!$this->db->sql_query($sqlq))
			{
				echo $sqlq;
				return false;
			}
		}

		
		for ($i = 0; $i<count($_authlist); $i++)
		{
			$tauth = $_authlist[$i];
			if ($tauth->getuser_id()==$tauth->getowner())
				continue;
			if ($_type==SFILE)
			{
				$sqlq = "INSERT INTO ".
					$this->db_table['userfileparamattr'].
					" (filedb_id, user_id, owner, allowread, allowwrite) VALUES" .
					" (".$_id.",".$tauth->getuser_id().",".
					$tauth->getowner().",'".
					$tauth->getread()."','".
					$tauth->getupdatefile()."')";

				if (!$this->db->sql_query($sqlq))
				{
					return false;
				}
			}
			elseif ($_type==DIRECTORY)
			{
				$sqlq = "INSERT INTO ".
					$this->db_table['userdirparamattr'].
					" (dirdb_id, user_id, owner, createdir, updatedir, deldir, ".
					"createfile, updatefile, delfile, allowread) VALUES".
					" (".$_id.",".$tauth->getuser_id().",".
					$tauth->getowner().",'".$tauth->getcreatedir()."','".
					$tauth->getupdatedir()."','".$tauth->getdeldir()."','".
					$tauth->getcreatefile()."','".$tauth->getupdatefile()."','".
					$tauth->getdelfile()."','".$tauth->getread()."')";
				if (!$this->db->sql_query($sqlq))
					return false;
			}
		}
		return true;
	}

}

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