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

class BSRenameFile
{
	function BSRenameFile()
	{
	}

	function renamefile($_request, $_response)
	{
		// Get Filedirdb

		$filedirdb = null;


		if (isset($_request['fileid']) && (is_numeric($_request['fileid'])))
		{

			$daogf = new DAOGetFileDirAttr();
			$filedirdb = $daogf->getFileById($_request['fileid']);
			unset($daogf);
		}


		if ($filedirdb == null)
		{
			$_response['result'] = false;
			return $_response;
		}

		// Get Auth Right

		$bsar = new BSGAuthRight();
		$rauth = $bsar->getBasicAuthWFileDirDb($filedirdb, $_request['user_id'], $_request['ownerid']);
		unset($bsar);

		if ($rauth->getwrite()=="Y")
		{
			$tobj = $filedirdb->getobj();
			if (count(explode(".", $tobj->getfilename()))>1)
				list($temp, $extension) = explode(".", $tobj->getfilename());

			$daogi = new DAOGetIndex();
			$index = $daogi->getindex($_request['fileid']);
			if (count($index)>0)
				$lastindex = $index[count($index)-1];
			else
			{
				$_response['result'] = false;
				return $_response;
			}

			// If Accept, open rename DAO to update the db
			$daorf = new DAORenameFile();
			if ($daorf->renamefile($filedirdb->getlinkid(), $_request['rename'].".".$extension, $lastindex['id']))
			{
				$_response['result'] = true;
			}
			else
				$_response['result'] = false;

			// Set $_response['result'] = true;
		}
		else
		{
			$_response['result'] = false;
		}
		

		return $_response;
	}
}

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