Your IP : 216.73.216.54


Current Path : /var/www/html/components/com_jvld/models/
Upload File :
Current File : /var/www/html/components/com_jvld/models/coupons.php

<?php
/**
 * @version		$Id$
 * @package		JV-LinkDirectory
 * @subpackage	com_jvld
 * @copyright	Copyright 2008-2013 JV-Extensions. All rights reserved
 * @license		GNU General Public License version 3 or later
 * @author		JV-Extensions
 * @link		http://www.jv-extensions.com
 */

// No direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class JvldModelCoupons extends JModelLegacy
{
	public function deleteCoupon()
	{
		try
		{
			$cfg = JvldCfg::getInstance();
			if (!$cfg->get('coupons_en'))
				throw new Exception(JText::_('COM_JVLD_FEATURED_DISABLED'));

			$input = JFactory::getApplication()->input;

			$lid = $input->getInt('lid', 0);
			$coid = $input->getInt('coid', 0);

			if (!$lid || !$coid)
				throw new Exception(JText::_('COM_JVLD_ERR_INVALID_REQ'));

			$uid = JvldDb::getValue("select uid from #__jvld_links where id = ".(int)$lid);
			if ($uid != JFactory::getUser()->get("id"))
				throw new Exception(JText::_("COM_JVLD_UNAUTHORIZED"));

			JvldDb::update("delete from #__jvld_liscoupons where id = ".(int)$coid);

			JvldMsg::display(JText::_("COM_JVLD_COUPON_DELETE_OK"), _JVLD_NEXT_PAGE_GO_TO_URL, JvldPostinit::getRoute('coupons', $lid));
			return;
		}
		catch (Exception $ex)
		{
			JvldMsg::display($ex->getMessage(), _JVLD_NEXT_PAGE_GO_BACK);
			return;
		}
	}
}