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

class BSSaveFileProp
{
	function BSSaveFileProp()
	{
	}

	function savefileprop($_dirfile_id, $_ownerid, $_ownerwriteaccess,
		$_publicreadaccess, $_useraccess, $_useraccessdel)
	{
		$daogf = new DAOGetFileDirAttr();
		$filedirdb = $daogf->getFileById($_dirfile_id);

		if ($filedirdb!=null)
		{
			if ($filedirdb->getownerid()!=$_ownerid)
				return false;
			//$bsga = new BSGAuthRight();
			//print_r($bsga->getBasicAuthWFileDirDb($filedirdb, $_ownerid, $_ownerid));
			$daosfp = new DAOSaveFileProp();
			if ($daosfp->getownerfileaccess($_dirfile_id, $_ownerid)==true)
			{
				if ($daosfp->updateownerfileaccess($_dirfile_id, $_ownerid,
					$_ownerwriteaccess)==false)
				{
					$daosfp->rollback();
					return false;
				}
			}
			else
			{
				if ($daosfp->insertownerfileaccess($_dirfile_id, $_ownerid,
					$_ownerwriteaccess)==false)
				{
					$daosfp->rollback();
					return false;
				}
					
			}
			if ($daosfp->getpublicfileaccess($_dirfile_id, $_ownerid)==true)
			{
				if ($daosfp->updatepublicfileaccess($_dirfile_id, $_ownerid,
					$_publicreadaccess)==false)
				{
					$daosfp->rollback();
					return false;
				}
			}
			else
			{
				if ($daosfp->insertpublicfileaccess($_dirfile_id, $_ownerid,
					$_publicreadaccess)==false)
				{
					$daosfp->rollback();
					return false;
				}
					
			}

			if ($daosfp->deluseraccess($_dirfile_id, explode(":", $_useraccessdel),
				$_ownerid)==false)
			{
				$daosfp->rollback();
				return false;
			}
			$useraccesslist = explode(":", $_useraccess);
			for ($i=0; $i<count($useraccesslist); $i++)
			{
				if (!is_numeric($useraccesslist[$i]))
					continue;
				if ($daosfp->getuserfileaccess($_dirfile_id, $useraccesslist[$i], $_ownerid)==true)
				{
					if ($daosfp->updateuserfileaccess($_dirfile_id, $useraccesslist[$i], $_ownerid, "Y")==false)
					{
						$daosfp->rollback();
						return false;
					}
				}
				else
				{
					if ($daosfp->insertuserfileaccess($_dirfile_id, $useraccesslist[$i], $_ownerid, "Y")==false)
					{
						$daosfp->rollback();
						return false;
					}
				}
			}
		
			$daosfp->commit();
			return true;
		}
		else
			return false;
	}
}

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