/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { parent::__construct(); // Additional security check for unregistered users if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) { throw new Exception(JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED')); } $array = JRequest::getVar('catid', 0, '', 'array'); $this->setId($array[0]); }
/** * Constructor * * @param array An optional associative array of configuration settings * @return void * @since 2.1 */ public function __construct($config = array()) { parent::__construct($config); $this->filter_fields = array('cid', 'c.cid', 'name', 'c.name', 'alias', 'c.alias', 'parent_id', 'c.parent_id', 'published', 'c.published', 'access', 'c.access', 'access_level', 'owner', 'c.owner', 'lft', 'c.lft', 'rgt', 'c.rgt', 'level', 'c.level'); }
/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { $this->filter_fields = array('c.cid', 'c.name', 'c.alias', 'c.parent_id', 'c.published', 'c.access', 'c.owner', 'c.lft', 'c.rgt', 'c.level', 'images'); parent::__construct(); }
/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { parent::__construct(); $id = JRequest::getInt('id'); $this->setId($id); }
/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { parent::__construct(); $array = JRequest::getVar('cid', 0, '', 'array'); $this->setId((int) $array[0]); }
/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { parent::__construct(); }
/** * Constructor * * @param array An optional associative array of configuration settings * @return void * @since 2.0 */ public function __construct($config = array()) { parent::__construct($config); $this->filter_fields = array('id', 'a.id', 'imgtitle', 'a.imgtitle', 'alias', 'a.alias', 'catid', 'a.catid', 'category_name', 'published', 'a.published', 'approved', 'a.approved', 'access', 'a.access', 'access_level', 'owner', 'a.owner', 'imgauthor', 'a.imgauthor', 'imgdate', 'a.imgdate', 'hits', 'a.hits', 'downloads', 'a.downloads', 'ordering', 'a.ordering', 'special', 'a.special'); }
/** * Method to create the zip archive with all selected images * * @return boolean True on success, false otherwise * @since 1.0.0 */ public function createZip() { jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.archive'); $zip_adapter = JArchive::getAdapter('zip'); // Check whether zip download is allowed if (!$this->_config->get('jg_zipdownload') && ($this->_user->get('id') || !$this->_config->get('jg_usefavouritesforpubliczip'))) { $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false), JText::_('COM_JOOMGALLERY_FAVOURITES_MSG_NOT_ALLOWED'), 'notice'); } if (is_null($this->piclist)) { $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false), $this->output('NO_IMAGES'), 'notice'); } $query = $this->_db->getQuery(true)->select('id')->select('catid')->select('imgfilename')->from(_JOOM_TABLE_IMAGES . ' AS a')->from(_JOOM_TABLE_CATEGORIES . ' AS c')->where('id IN (' . $this->piclist . ')')->where('a.catid = c.cid')->where('a.published = 1')->where('a.approved = 1')->where('c.published = 1')->where('a.access IN (' . implode(',', $this->_user->getAuthorisedViewLevels()) . ')')->where('c.access IN (' . implode(',', $this->_user->getAuthorisedViewLevels()) . ')'); $this->_db->setQuery($query); $rows = $this->_db->loadObjectList(); if (!count($rows)) { $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false), $this->output('NO_IMAGES'), 'notice'); } // Name of the zip archive $zipname = 'components/' . _JOOM_OPTION . '/joomgallery_' . date('d_m_Y') . '__'; if ($userid = $this->_user->get('id')) { $zipname .= $userid . '_'; } $zipname .= mt_rand(10000, 99999) . '.zip'; $files = array(); if ($this->_config->get('jg_downloadwithwatermark')) { $include_watermark = true; // Get the 'image' model $imageModel = parent::getInstance('image', 'joomgallerymodel'); // Get the temp path for storing the watermarked image temporarily if (!JFolder::exists($this->_ambit->get('temp_path'))) { $this->setError(JText::_('COM_JOOMGALLERY_UPLOAD_ERROR_TEMP_MISSING')); return false; } else { $tmppath = $this->_ambit->get('temp_path'); } } else { $include_watermark = false; } $categories = $this->_ambit->getCategoryStructure(); foreach ($rows as &$row) { if (!isset($categories[$row->catid])) { continue; } // Get the original image if existent, otherwise the detail image $orig = $this->_ambit->getImg('orig_path', $row->id); $img = $this->_ambit->getImg('img_path', $row->id); if (file_exists($orig)) { $image = $orig; } else { if (file_exists($img)) { $image = $img; } else { $image = null; continue; } } $files[$row->id]['name'] = $row->imgfilename; // Watermark the image before if needed if ($include_watermark) { // Get the image resource of watermarked image $imgres = $imageModel->includeWatermark($image); // Start output buffering ob_start(); // According to mime type output the watermarked image resource to file $info = getimagesize($image); switch ($info[2]) { case 1: imagegif($imgres); break; case 2: imagejpeg($imgres); break; case 3: imagepng($imgres); break; default: JError::raiseError(404, JText::sprintf('COM_JOOMGALLERY_COMMON_MSG_MIME_NOT_ALLOWED', $mime)); break; } // Read the content from output buffer and fill the array element $files[$row->id]['data'] = ob_get_contents(); // Delete the output buffer ob_end_clean(); } else { $files[$row->id]['data'] = JFile::read($image); } // Increase download counter for that image $this->download($row->id); } if (!count($files)) { $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false), $this->output('NO_IMAGES'), 'notice'); } // Trigger event 'onJoomBeforeZipDownload' $plugins = $this->_mainframe->triggerEvent('onJoomBeforeZipDownload', array(&$files)); if (in_array(false, $plugins, true)) { $this->_mainframe->redirect(JRoute::_('index.php?view=favourites', false)); } $createzip = $zip_adapter->create($zipname, $files); if (!$createzip) { // Workaround for servers with wwwwrun problem JoomFile::chmod(JPATH_COMPONENT, '0777', true); $createzip = $zip_adapter->create($zipname, $files, 'zip'); JoomFile::chmod(JPATH_COMPONENT, '0755', true); } if (!$createzip) { $this->setError(JText::_('COM_JOOMGALLERY_FAVOURITES_ERROR_CREATEZIP')); return false; } if ($this->_user->get('id')) { if ($this->user_exists) { $query = $this->_db->getQuery(true)->select('zipname')->from(_JOOM_TABLE_USERS)->where('uuserid = ' . $this->_user->get('id')); $this->_db->setQuery($query); if ($old_zip = $this->_db->loadResult()) { if (file_exists($old_zip)) { jimport('joomla.filesystem.file'); JFile::delete($old_zip); } } $query = $this->_db->getQuery(true)->update(_JOOM_TABLE_USERS)->set('time = NOW()')->set('zipname = ' . $this->_db->q($zipname))->where('uuserid = ' . $this->_user->get('id')); $this->_db->setQuery($query); } else { $query = $this->_db->getQuery(true)->insert(_JOOM_TABLE_USERS)->set('uuserid = ' . $this->_user->get('id'))->set('time = NOW()')->set('zipname = ' . $this->_db->q($zipname)); $this->_db->setQuery($query); } } else { $query = $this->_db->getQuery(true)->insert(_JOOM_TABLE_USERS)->set('time = NOW()')->set('zipname = ' . $this->_db->q($zipname)); $this->_db->setQuery($query); } $this->_db->query(); $this->_mainframe->setUserState('joom.favourites.zipname', $zipname); // Message about new zip download if (!$this->_user->get('username')) { $username = JText::_('COM_JOOMGALLERY_COMMON_GUEST'); } else { $username = $this->_config->get('jg_realname') ? $this->_user->get('name') : $this->_user->get('username'); } if ($this->_config->get('jg_msg_zipdownload')) { $imagefiles = implode(",\n", $files); require_once JPATH_COMPONENT . '/helpers/messenger.php'; $messenger = new JoomMessenger(); $message = array('subject' => JText::_('COM_JOOMGALLERY_MESSAGE_NEW_ZIPDOWNLOAD_SUBJECT'), 'body' => JText::sprintf('COM_JOOMGALLERY_MESSAGE_NEW_ZIPDOWNLOAD_BODY', $zipname, $username, $imagefiles), 'mode' => 'zipdownload'); $messenger->send($message); } return true; }
/** * Constructor * * @param array An optional associative array of configuration settings * @return void * @since 2.0 */ public function __construct($config = array()) { parent::__construct($config); $this->filter_fields = array('id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'thumb', 'a.thumb', 'img', 'a.img', 'orig', 'a.orig', 'fullpath', 'a.fullpath', 'type', 'a.type', 'refid', 'a.refid', 'user', 'category'); }
/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { $this->filter_fields = array('imgtitle', 'ordering', 'imgdate', 'hits', 'downloads', 'published', 'approved', 'catid'); parent::__construct(); }
/** * Constructor * * @param array An optional associative array of configuration settings * @return void * @since 2.0 */ public function __construct($config = array()) { parent::__construct($config); $this->filter_fields = array('cmtid', 'c.cmtid', 'user', 'cmttext', 'c.cmttext', 'published', 'c.published', 'approved', 'c.approved', 'cmtip', 'c.cmtip', 'i.imgtitle', 'cmtdate', 'c.cmtdate', 'state'); }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * @since 3.0 */ protected function populateState() { $this->setState('message', $this->_mainframe->getUserState('joom.control.message')); $this->setState('extension_message', $this->_mainframe->getUserState('joom.control.extension_message')); $this->_mainframe->setUserState('joom.control.message', null); $this->_mainframe->setUserState('joom.control.extension_message', null); parent::populateState(); }
/** * Constructor * * @param array An optional associative array of configuration settings * @return void * @since 2.0 */ public function __construct($config = array()) { parent::__construct($config); $this->filter_fields = array('id', 'c.id', 'title', 'g.title', 'lft', 'g.lft', 'ordering', 'c.ordering'); }
/** * Constructor * * @return void * @since 1.5.5 */ public function __construct() { parent::__construct(); $id = JRequest::getVar('id', 0, '', 'int'); $this->setId((int) $id); }