monthlyarchive.script.php 2.14 KB
<?php
/* ======================================================
# Monthly Archive - Joomla! Component v4.3.3 (PRO version)
# -------------------------------------------------------
# For Joomla! 3.x
# Author: Yiannis Christodoulou (yiannis@web357.eu)
# Copyright (©) 2009-2018 Web357. All rights reserved.
# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
# Website: https://www.web357.eu/
# Demo: http://demo.web357.eu/?item=monthlyarchive
# Support: support@web357.eu
# Last modified: 09 Feb 2018, 13:55:18
========================================================= */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// http://docs.joomla.org/J2.5:Developing_a_MVC_Component/Adding_an_install-uninstall-update_script_file
class plgSystemMonthlyArchiveInstallerScript
{
	/**
	 * method to install the component
	 *
	 * @return void
	 */
	function install($parent) 
	{
		// $parent is the class calling this method
	}
 
	/**
	 * method to uninstall the component
	 *
	 * @return void
	 */
	function uninstall($parent) 
	{
		// $parent is the class calling this method
	}
 
	/**
	 * method to update the component
	 *
	 * @return void
	 */
	function update($parent) 
	{
		// $parent is the class calling this method
	}
 
	/**
	 * method to run before an install/update/uninstall method
	 *
	 * @return void
	 */
	function preflight($type, $parent) 
	{
		// $parent is the class calling this method
		// $type is the type of change (install, update or discover_install)
	}
 
	/**
	 * method to run after an install/update/uninstall method
	 *
	 * @return void
	 */
	function postflight($type, $parent) 
	{
		// BEGIN: Enable Plugin
      	$db = JFactory::getDbo();

		try
		{
			// Enable plugin by default
			$q = $db->getQuery(true);
			
			$q->update('#__extensions');
			$q->set(array('enabled = 1', 'protected = 0', 'ordering = 9999'));
			$q->where("element = 'monthlyarchive'");
			$q->where("type = 'plugin'", 'AND');
			$q->where("folder = 'system'", 'AND');
			
			$db->setQuery($q);
			
			method_exists($db, 'execute') ? $db->execute() : $db->query();
		}
		
		catch (Exception $e)
		{
			throw $e;
		}
		// END: Enable Plugin
	}

}