Your IP : 216.73.216.240


Current Path : /home/juvelize/www/administrator/components/com_myrssreader/
Upload File :
Current File : /home/juvelize/www/administrator/components/com_myrssreader/install.php

<?php
/**
* @package      My RSS Reader
* @copyright    Copyright (C) 2010 FalsinSoft. All rights reserved.
* @license      GNU/GPL
* @website      http://falsinsoft-joomla.blogspot.com
* @email        falsinsoft@gmail.com
* 
*/

defined('_JEXEC') or die('Restricted access');
 
class com_MyRSSReaderInstallerScript
{
        function install($parent) 
        {
			$this->install_modules($parent);
			$this->install_plugins($parent);
			            
			echo JText::_('COM_MYRSSREADER_INSTALL_TEXT');
        }
 
        function uninstall($parent) 
        {
			$this->uninstall_modules($parent);
            $this->uninstall_plugins($parent);
        }
        
        function update($parent) 
        {
			$this->install_modules($parent);
			$this->install_plugins($parent);
							
			echo JText::_('COM_MYRSSREADER_UPDATE_TEXT');   
        }
        
        function preflight($type, $parent) 
        {
        }
 
        function postflight($type, $parent) 
        {     
        }
		
		private function install_modules($parent)
		{
			$manifest = $parent->get("manifest");
            $parent = $parent->getParent();
            $source = $parent->getPath("source");
			
			$installer = new JInstaller();
			
			foreach($manifest->modules->module as $module) 
			{
                $attributes = $module->attributes();
                $mod = $source.DS.$attributes['folder'].DS.$attributes['module'];
                $installer->install($mod);
            }
			
			echo JText::_('COM_MYRSSREADER_INSTALL_MODULE_TEXT');
		}
		
		private function install_plugins($parent)
		{
			$db = JFactory::getDbo();
			
			$manifest = $parent->get("manifest");
            $parent = $parent->getParent();
            $source = $parent->getPath("source");
			
			$installer = new JInstaller();
                         
            foreach($manifest->plugins->plugin as $plugin) 
			{
                $attributes = $plugin->attributes();
                $plg = $source.DS.$attributes['folder'].DS.$attributes['plugin'];
                $installer->install($plg);
			}
					
            $tableExtensions = $db->nameQuote("#__extensions");
            $columnElement   = $db->nameQuote("element");
            $columnType      = $db->nameQuote("type");
            $columnEnabled   = $db->nameQuote("enabled");
            
            $db->setQuery("UPDATE ".$tableExtensions." SET ".$columnEnabled."=1 WHERE ".$columnElement."='myrssreader' AND ".$columnType."='plugin'");            
            $db->query();

			echo JText::_('COM_MYRSSREADER_INSTALL_PLUGIN_TEXT');
		}
		
		private function uninstall_modules($parent)
		{		
			$db = JFactory::getDbo();
			
			$db->setQuery("SELECT extension_id FROM #__extensions WHERE type='module' AND element ='mod_myrssreader_scrolling_news' LIMIT 1");
			$result = $db->loadResult();
			
			if($result)
			{
				$installer = new JInstaller(); 
				$installer->uninstall('module', $result);	
			}
		}
		
		private function uninstall_plugins($parent)
		{		
			$db = JFactory::getDbo();
			
			$db->setQuery("SELECT extension_id FROM #__extensions WHERE type='plugin' AND element ='myrssreader' LIMIT 1");
			$result = $db->loadResult();
			
			if($result)
			{
				$installer = new JInstaller(); 
				$installer->uninstall('plugin', $result);	
			}
		}
}