<?php

/**
 * Create a link to a property brochure.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS\module\property
 * @copyright Copyright (c) 2016 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

if(isset($id)) {
	/* @var $tplEngine cfTemplateEngine */

	$idHash = md5($id);
	$cfg = clearFusionCMS::getSiteConfig('cfSystemFileStore');
	$file = $cfg->publicStorage . '/property/' . clearFusionCMS::getSite() . '/' . $idHash[0] . '/' . $idHash[1] . '/' . $id . '.pdf';
	if(is_readable($file)) {
		echo $tplEngine->controller->getRequest()->getBasePath(true) . $file;
	}
}
