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/csponsor.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');

class JvldModelCsponsor extends JvldFendModel
{
	public function getForm($data = array(), $loadData = true)
	{
		$form = $this->loadForm('com_jvld.csponsor', 'csponsor', array('control' => 'jform', 'load_data' => $loadData), true);
		if (empty($form))
			return false;

		return $form;
	}

	public function getItem()
	{
		$revid = JFactory::getApplication()->input->getInt('revid', 0);
		$revrec = JvldDb::getRow("select * from #__jvld_revenue where id = ".(int)$revid);
		return JvldDb::getRow("select * from #__jvld_sponsors where refid = '".JvldSecure::defendSQL($revrec->refid)."' and custemail = '".JvldSecure::defendSQL($revrec->payer_email)."'");
	}

	protected function loadFormData()
	{
		return $this->getItem();
	}

	public function process()
	{
		try
		{
			parent::preProcess();

			if ((!$this->cfg->get('sponsor_desc_optional')) && ($this->description == ''))
				throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO"));

			$this->banner_loc = '';
			$banner_loc_del = JvldUtil::getJFormVariableValue('banner_loc_del', 0, 'int');
			$up_banner_loc = JvldFileManager::upload("banner_loc", _JVLD_SPBANNER_ABSPATH, array('allowed_extns'=>_JVLD_SPBANNER_EXTNS, 'width'=>$this->cfg->get('sponsor_banner_xmax'), 'height'=>$this->cfg->get('sponsor_banner_ymax'), 'maxsize'=>$this->cfg->get('sponsor_banner_maxsize'), 'genprefix'=>1, 'err_on_nofileupload'=>0));
			if ($up_banner_loc != '')
			{
				$this->banner_loc = $up_banner_loc;
			}
			else
			{
				$this->banner_loc = ($banner_loc_del) ? '' : JvldDb::getValue("select banner_loc from #__jvld_sponsors where id = ".(int)$this->id);
			}

			if (($this->banner_loc == '') && (!$this->cfg->get('sponsor_banner_optional')))
				throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO"));

			if (($this->description != "") && (\Joomla\String\StringHelper::strlen($this->description) > $this->cfg->get('sponsor_desc_maxchar')))
			{
				JvldMsg::display(JText::sprintf("COM_JVLD_CSPONSOR_MAXCHARS_EXCEEDED", $this->cfg->get('sponsor_desc_maxchar')), _JVLD_NEXT_PAGE_GO_BACK);
				return;
			}

			JvldDb::update("update #__jvld_sponsors set wurl = '".JvldSecure::defendSQL($this->wurl)."', title = '".JvldSecure::defendSQL($this->title)."', description = '".JvldSecure::defendSQL($this->description)."', banner_loc = '".JvldSecure::defendSQL($this->banner_loc)."' where id = '".(int)$this->id."'");

			JvldInit::triggerPlugins('OnCategorySponsorInfoUpdate', array($this->id));

			JvldMsg::display(JText::_("COM_JVLD_CSPONSOR_UPDATE_DONE"));
			return;
		}
		catch (Exception $ex)
		{
			JvldMsg::display($ex->getMessage(), _JVLD_NEXT_PAGE_GO_BACK);
			return;
		}
	}
}