Current Path :
/
home
/
develito
/
www
/
administrator
/
components
/
com_tlpteam
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/www/administrator/components/com_tlpteam/script.php
<?php /** * @package com_tlpteam * @author TechLabPro <techlabpro@gmail.com> * @copyright Copyright (C) 2013. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ define('MODIFIED', 1); define('NOT_MODIFIED', 2); defined('_JEXEC') or die; /** * Updates the database structure of the component * * @version Release: 0.2b * @author techlabpro.com * @since 0.1b */ class com_tlpteamInstallerScript { /** * Method called before install/update the component. Note: This method won't be called during uninstall process. * * @param string $type Type of process [install | update] * @param mixed $parent Object who called this method * * @return boolean True if the process should continue, false otherwise */ public function preflight($type, $parent) { $jversion = new JVersion; // Installing component manifest file version $manifest = $parent->get("manifest"); $release = (string) $manifest['version']; // Abort if the component wasn't build for the current Joomla version if (!$jversion->isCompatible($release)) { JFactory::getApplication()->enqueueMessage( JText::_('This component is not compatible with installed Joomla version'), 'error' ); return false; } return true; } /** * Method to install the component * * @param mixed $parent Object who called this method. * * @return void * * @since 0.2b */ public function install($parent) { $this->installModules($parent); } /** * Check if an extension is already installed in the system * * @param string $type Extension type * @param string $name Extension name * @param mixed $folder Extension folder(for plugins) * * @return boolean */ private function isAlreadyInstalled($type, $name, $folder = null) { $result = false; switch ($type) { case 'module': $result = file_exists(JPATH_SITE . '/modules/' . $name); break; } return $result; } /** * Installs plugins for this component * * @param mixed $parent Object who called the install/update method * * @return void */ private function installModules($parent) { $installation_folder = $parent->getParent()->getPath('source'); $app = JFactory::getApplication(); if (!empty($parent->get("manifest")->modules)) { $modules = $parent->get("manifest")->modules; if (count($modules->children())) { foreach ($modules->children() as $module) { $moduleName = (string) $module['module']; $path = $installation_folder . '/modules/' . $moduleName; $installer = new JInstaller; if (!$this->isAlreadyInstalled('module', $moduleName)) { $result = $installer->install($path); } else { $result = $installer->update($path); } if ($result) { $app->enqueueMessage('Module ' . $moduleName . ' was installed successfully'); } else { $app->enqueueMessage('There was an issue installing the module ' . $moduleName, 'error'); } } } } } /** * Method to update the component * * @param mixed $parent Object who called this method. * * @return void */ public function update($parent) { $this->installModules($parent); } /** * Method to uninstall the component * * @param mixed $parent Object who called this method. * * @return void */ public function uninstall($parent) { $this->uninstallModules($parent); } /** * Uninstalls plugins * * @param mixed $parent Object who called the uninstall method * * @return void */ private function uninstallModules($parent) { $app = JFactory::getApplication(); if (!empty($parent->get("manifest")->modules)) { $modules = $parent->get("manifest")->modules; if (count($modules->children())) { $db = JFactory::getDbo(); $query = $db->getQuery(true); foreach ($modules->children() as $plugin) { $moduleName = (string) $plugin['module']; $query ->clear() ->select('extension_id') ->from('#__extensions') ->where( array( 'type LIKE ' . $db->quote('module'), 'element LIKE ' . $db->quote($moduleName) ) ); $db->setQuery($query); $extension = $db->loadResult(); if (!empty($extension)) { $installer = new JInstaller; $result = $installer->uninstall('module', $extension); if ($result) { $app->enqueueMessage('Module ' . $moduleName . ' was uninstalled successfully'); } else { $app->enqueueMessage('There was an issue uninstalling the module ' . $moduleName, 'error'); } } } } } } }