<?php /** * @package Sven.Bluege * @subpackage com_eventgallery * * @copyright Copyright (C) 2005 - 2019 Sven Bluege All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die('Restricted access'); class EventgalleryLibraryHelperCheckupdateplugin { /** * Checks if the download ID provisioning plugin for the updates of this extension is published. If not, it will try * to publish it automatically. It reports the status of the plugin as a boolean. * * @return bool */ public static function isUpdatePluginEnabled() { // We can't be bothered about the plugin in Joomla! 2.5.0 through 2.5.19 if (version_compare(JVERSION, '2.5.19', 'lt')) { return true; } // We can't be bothered about the plugin in Joomla! 3.x if (version_compare(JVERSION, '3.0.0', 'gt')) { return true; } $db = JFactory::getDbo(); // Let's get the information of the update plugin $query = $db->getQuery(true) ->select('*') ->from($db->qn('#__extensions')) ->where($db->qn('folder').' = '.$db->quote('installer')) ->where($db->qn('element').' = '.$db->quote('eventgallery')) ->where($db->qn('type').' = '.$db->quote('plugin')) ->order($db->qn('ordering').' ASC'); $db->setQuery($query); $plugin = $db->loadObject(); // If the plugin is missing report it as unpublished (of course!) if (!is_object($plugin)) { return false; } // If it's enabled there's nothing else to do if ($plugin->enabled) { return true; } // Otherwise, try to enable it and report false (so the user knows what he did wrong) $pluginObject = (object)array( 'extension_id' => $plugin->extension_id, 'enabled' => 1 ); try { $db->updateObject('#__extensions', $pluginObject, 'extension_id'); // Do not remove this line. We need to tell the user he's doing something wrong. $result = false; } catch (Exception $e) { $result = false; } return $result; } }