| Current Path : /var/www/html/components/com_jvld/models/ |
| Current File : /var/www/html/components/com_jvld/models/photos.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 JvldModelPhotos extends JModelLegacy
{
public function deletePhoto()
{
try
{
$cfg = JvldCfg::getInstance();
if (!$cfg->get('pgallery_en'))
throw new Exception(JText::_('COM_JVLD_FEATURED_DISABLED'));
$input = JFactory::getApplication()->input;
$lid = $input->getInt('lid', 0);
$key = $input->getInt('key', 0);
if (!$lid || !$key)
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"));
$arow = JvldDb::getRow("select thumb, carousel from #__jvld_photos where id = ".(int)$key);
if (JFile::exists(_JVLD_PHOTOS_ABSPATH.DIRECTORY_SEPARATOR.$arow->thumb))
JFile::delete(_JVLD_PHOTOS_ABSPATH.DIRECTORY_SEPARATOR.$arow->thumb);
if (JFile::exists(_JVLD_PHOTOS_ABSPATH.DIRECTORY_SEPARATOR.$arow->carousel))
JFile::delete(_JVLD_PHOTOS_ABSPATH.DIRECTORY_SEPARATOR.$arow->carousel);
JvldDb::update("delete from #__jvld_photos where id = ".(int)$key);
JvldMsg::display(JText::_("COM_JVLD_PHOTO_DELETE_OK"), _JVLD_NEXT_PAGE_GO_TO_URL, JvldPostinit::getRoute('photos', $lid));
return;
}
catch (Exception $ex)
{
JvldMsg::display($ex->getMessage(), _JVLD_NEXT_PAGE_GO_BACK);
return;
}
}
}