| Current Path : /var/www/html/components/com_jvld/models/ |
| Current File : /var/www/html/components/com_jvld/models/editvideo.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 JvldModelEditvideo extends JvldFendModel
{
public function getForm($data = array(), $loadData = false)
{
$form = $this->loadForm('com_jvld.editvideo', 'editvideo', array('control' => 'jform', 'load_data' => $loadData), true);
if (empty($form))
return false;
return $form;
}
public function process()
{
try
{
parent::preProcess();
if (!$this->cfg->get('vgallery_en'))
throw new Exception(JText::_("COM_JVLD_FEATURED_DISABLED"));
if (!$this->lid)
throw new Exception(JText::_("COM_JVLD_ERR_INVALID_REQ"));
if (($this->title == '') || ($this->vid == ''))
throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO"));
$link = new JvldLinkinfo($this->lid);
if ($link->getInfo('uid') != $this->user->get('id'))
throw new Exception(JText::_("COM_JVLD_UNAUTHORIZED"));
$linkplan = new JvldLinkPlan();
$linkplan->setPlanCode($link->getInfo('oway_plan'));
$maxvcnt = $linkplan->getMaxVideos();
$videos = JvldPostinit::getLinkVideos($this->lid, -1);
if (count($videos) >= $maxvcnt)
throw new Exception(JText::_("COM_JVLD_VIDEO_LIMIT_REACHED"));
foreach ($videos as $video)
{
if (($this->title == $video->title) || ($this->vid == $video->vid))
throw new Exception(JText::_('COM_JVLD_VIDEO_DUPLICATE'));
}
// get max ordering
$maxOrdering = JvldDb::getValue("select max(ordering) from #__jvld_videos where lid = ".(int)$this->lid);
$newOrdering = 1 + $maxOrdering;
$id = JvldDb::update("insert into #__jvld_videos (lid, title, vid, ordering) values('".(int)$this->lid."', '".JvldSecure::defendSQL($this->title)."', '".JvldSecure::defendSQL($this->vid)."', '".(int)$newOrdering."')");
JvldLinkinfo::updateLinkUpdateDate($this->lid);
JvldInit::triggerPlugins('OnNewVideoUpload', array($this->lid, $id));
JvldMsg::display(JText::_('COM_JVLD_VIDEO_ADDED_OK'), _JVLD_NEXT_PAGE_GO_TO_RETURN_URL);
return;
}
catch (Exception $ex)
{
JvldMsg::display($ex->getMessage(), _JVLD_NEXT_PAGE_GO_BACK);
return;
}
}
}