<?php
/**
* @version	$Id: files.php 14625 2011-10-04 09:34:12Z alex $
* @package	In-Commerce
* @copyright	Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license	Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/

defined('FULL_PATH') or die('restricted access!');

class FilesItem extends kDBItem {

	/**
	 * Deletes the record from database
	 *
	 * @param int $id
	 * @return bool
	 * @access public
	 */
	public function Delete($id = null)
	{
		$this->Load($id);
		$upload_dir = $this->Fields['FilePath']['upload_dir'];
		$file_path = FULL_PATH . $upload_dir . $this->GetDBField('FilePath');

		if ( file_exists($file_path) ) {
			unlink($file_path);
		}
		
		return parent::Delete($id);
	}
}