com_extensiondistributor/script.php

1685 lines
85 KiB
PHP
Raw Normal View History

2022-06-02 15:01:28 +00:00
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Agence Agerix
/-------------------------------------------------------------------------------------------------------/
@version 1.x.x
@build 2nd June, 2022
@created 12th December, 2020
@package Extension Distributor
@subpackage script.php
@author Emmanuel Danan <https://agerix.fr>
@copyright Copyright (C) 2021. All Rights Reserved.
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Installer\Adapter\ComponentAdapter;
JHTML::_('bootstrap.renderModal');
/**
* Script File of Extensiondistributor Component
*/
class com_extensiondistributorInstallerScript
{
/**
* Constructor
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function __construct(ComponentAdapter $parent) {}
/**
* Called on installation
*
* @param ComponentAdapter $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function install(ComponentAdapter $parent) {}
/**
* Called on uninstallation
*
* @param ComponentAdapter $parent The object responsible for running this script
*/
public function uninstall(ComponentAdapter $parent)
{
// Get Application object
$app = JFactory::getApplication();
// Get The Database object
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select ids from fields
$query->select($db->quoteName('id'));
$query->from($db->quoteName('#__fields'));
// Where package context is found
$query->where( $db->quoteName('context') . ' = '. $db->quote('com_extensiondistributor.package') );
$db->setQuery($query);
// Execute query to see if context is found
$db->execute();
$package_found = $db->getNumRows();
// Now check if there were any rows
if ($package_found)
{
// Since there are load the needed package field ids
$package_field_ids = $db->loadColumn();
// Remove package from the field table
$package_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__fields'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove package add queued success message.
$app->enqueueMessage(JText::_('The fields with type (com_extensiondistributor.package) context was removed from the <b>#__fields</b> table'));
}
// Also Remove package field values
$package_condition = array( $db->quoteName('field_id') . ' IN ('. implode(',', $package_field_ids) .')');
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__fields_values'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package field values
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove package add queued success message.
$app->enqueueMessage(JText::_('The fields values for package was removed from the <b>#__fields_values</b> table'));
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select ids from field groups
$query->select($db->quoteName('id'));
$query->from($db->quoteName('#__fields_groups'));
// Where package context is found
$query->where( $db->quoteName('context') . ' = '. $db->quote('com_extensiondistributor.package') );
$db->setQuery($query);
// Execute query to see if context is found
$db->execute();
$package_found = $db->getNumRows();
// Now check if there were any rows
if ($package_found)
{
// Remove package from the field groups table
$package_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__fields_groups'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove package add queued success message.
$app->enqueueMessage(JText::_('The field groups with type (com_extensiondistributor.package) context was removed from the <b>#__fields_groups</b> table'));
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where package alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$package_found = $db->getNumRows();
// Now check if there were any rows
if ($package_found)
{
// Since there are load the needed package type ids
$package_ids = $db->loadColumn();
// Remove package from the content type table
$package_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove package add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.package) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove package items from the contentitem tag map table
$package_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove package add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.package) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove package items from the ucm content table
$package_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully removed package add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.package) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the package items are cleared from DB
foreach ($package_ids as $package_id)
{
// Remove package items from the ucm base table
$package_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $package_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$db->execute();
// Remove package items from the ucm history table
$package_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $package_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove package items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Package alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$package_found = $db->getNumRows();
// Now check if there were any rows
if ($package_found)
{
// Since there are load the needed package type ids
$package_ids = $db->loadColumn();
// Remove Package from the content type table
$package_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove Package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove Package add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.package) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Package items from the contentitem tag map table
$package_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove Package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully remove Package add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.package) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Package items from the ucm content table
$package_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove Package items
$package_done = $db->execute();
if ($package_done)
{
// If successfully removed Package add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.package) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Package items are cleared from DB
foreach ($package_ids as $package_id)
{
// Remove Package items from the ucm base table
$package_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $package_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove Package items
$db->execute();
// Remove Package items from the ucm history table
$package_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $package_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($package_condition);
$db->setQuery($query);
// Execute the query to remove Package items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Extension alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$extension_found = $db->getNumRows();
// Now check if there were any rows
if ($extension_found)
{
// Since there are load the needed extension type ids
$extension_ids = $db->loadColumn();
// Remove Extension from the content type table
$extension_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($extension_condition);
$db->setQuery($query);
// Execute the query to remove Extension items
$extension_done = $db->execute();
if ($extension_done)
{
// If successfully remove Extension add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.extension) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Extension items from the contentitem tag map table
$extension_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($extension_condition);
$db->setQuery($query);
// Execute the query to remove Extension items
$extension_done = $db->execute();
if ($extension_done)
{
// If successfully remove Extension add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.extension) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Extension items from the ucm content table
$extension_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_extensiondistributor.extension') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($extension_condition);
$db->setQuery($query);
// Execute the query to remove Extension items
$extension_done = $db->execute();
if ($extension_done)
{
// If successfully removed Extension add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.extension) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Extension items are cleared from DB
foreach ($extension_ids as $extension_id)
{
// Remove Extension items from the ucm base table
$extension_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $extension_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($extension_condition);
$db->setQuery($query);
// Execute the query to remove Extension items
$db->execute();
// Remove Extension items from the ucm history table
$extension_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $extension_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($extension_condition);
$db->setQuery($query);
// Execute the query to remove Extension items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Extension catid alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension.category') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$extension_catid_found = $db->getNumRows();
// Now check if there were any rows
if ($extension_catid_found)
{
// Since there are load the needed extension_catid type ids
$extension_catid_ids = $db->loadColumn();
// Remove Extension catid from the content type table
$extension_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($extension_catid_condition);
$db->setQuery($query);
// Execute the query to remove Extension catid items
$extension_catid_done = $db->execute();
if ($extension_catid_done)
{
// If successfully remove Extension catid add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.extension.category) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Extension catid items from the contentitem tag map table
$extension_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($extension_catid_condition);
$db->setQuery($query);
// Execute the query to remove Extension catid items
$extension_catid_done = $db->execute();
if ($extension_catid_done)
{
// If successfully remove Extension catid add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.extension.category) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Extension catid items from the ucm content table
$extension_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_extensiondistributor.extension.category') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($extension_catid_condition);
$db->setQuery($query);
// Execute the query to remove Extension catid items
$extension_catid_done = $db->execute();
if ($extension_catid_done)
{
// If successfully removed Extension catid add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.extension.category) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Extension catid items are cleared from DB
foreach ($extension_catid_ids as $extension_catid_id)
{
// Remove Extension catid items from the ucm base table
$extension_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $extension_catid_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($extension_catid_condition);
$db->setQuery($query);
// Execute the query to remove Extension catid items
$db->execute();
// Remove Extension catid items from the ucm history table
$extension_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $extension_catid_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($extension_catid_condition);
$db->setQuery($query);
// Execute the query to remove Extension catid items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Release alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.release') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$release_found = $db->getNumRows();
// Now check if there were any rows
if ($release_found)
{
// Since there are load the needed release type ids
$release_ids = $db->loadColumn();
// Remove Release from the content type table
$release_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.release') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($release_condition);
$db->setQuery($query);
// Execute the query to remove Release items
$release_done = $db->execute();
if ($release_done)
{
// If successfully remove Release add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.release) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Release items from the contentitem tag map table
$release_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.release') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($release_condition);
$db->setQuery($query);
// Execute the query to remove Release items
$release_done = $db->execute();
if ($release_done)
{
// If successfully remove Release add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.release) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Release items from the ucm content table
$release_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_extensiondistributor.release') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($release_condition);
$db->setQuery($query);
// Execute the query to remove Release items
$release_done = $db->execute();
if ($release_done)
{
// If successfully removed Release add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.release) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Release items are cleared from DB
foreach ($release_ids as $release_id)
{
// Remove Release items from the ucm base table
$release_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $release_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($release_condition);
$db->setQuery($query);
// Execute the query to remove Release items
$db->execute();
// Remove Release items from the ucm history table
$release_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $release_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($release_condition);
$db->setQuery($query);
// Execute the query to remove Release items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Key alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.key') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$key_found = $db->getNumRows();
// Now check if there were any rows
if ($key_found)
{
// Since there are load the needed key type ids
$key_ids = $db->loadColumn();
// Remove Key from the content type table
$key_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.key') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($key_condition);
$db->setQuery($query);
// Execute the query to remove Key items
$key_done = $db->execute();
if ($key_done)
{
// If successfully remove Key add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.key) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Key items from the contentitem tag map table
$key_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.key') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($key_condition);
$db->setQuery($query);
// Execute the query to remove Key items
$key_done = $db->execute();
if ($key_done)
{
// If successfully remove Key add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.key) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Key items from the ucm content table
$key_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_extensiondistributor.key') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($key_condition);
$db->setQuery($query);
// Execute the query to remove Key items
$key_done = $db->execute();
if ($key_done)
{
// If successfully removed Key add queued success message.
$app->enqueueMessage(JText::_('The (com_extensiondistributor.key) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Key items are cleared from DB
foreach ($key_ids as $key_id)
{
// Remove Key items from the ucm base table
$key_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $key_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($key_condition);
$db->setQuery($query);
// Execute the query to remove Key items
$db->execute();
// Remove Key items from the ucm history table
$key_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $key_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($key_condition);
$db->setQuery($query);
// Execute the query to remove Key items
$db->execute();
}
}
// If All related items was removed queued success message.
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__ucm_base</b> table'));
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__ucm_history</b> table'));
// Remove extensiondistributor assets from the assets table
$extensiondistributor_condition = array( $db->quoteName('name') . ' LIKE ' . $db->quote('com_extensiondistributor%') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__assets'));
$query->where($extensiondistributor_condition);
$db->setQuery($query);
$key_done = $db->execute();
if ($key_done)
{
// If successfully removed extensiondistributor add queued success message.
$app->enqueueMessage(JText::_('All related items was removed from the <b>#__assets</b> table'));
}
// Get the biggest rule column in the assets table at this point.
$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
$db->setQuery($get_rule_length);
if ($db->execute())
{
$rule_length = $db->loadResult();
// Check the size of the rules column
if ($rule_length < 5120)
{
// Revert the assets table rules column back to the default
$revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';";
$db->setQuery($revert_rule);
$db->execute();
$app->enqueueMessage(JText::_('Reverted the <b>#__assets</b> table rules column back to its default size of varchar(5120)'));
}
else
{
$app->enqueueMessage(JText::_('Could not revert the <b>#__assets</b> table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.'));
}
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor from the action_logs_extensions table
$extensiondistributor_action_logs_extensions = array( $db->quoteName('extension') . ' = ' . $db->quote('com_extensiondistributor') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_logs_extensions'));
$query->where($extensiondistributor_action_logs_extensions);
$db->setQuery($query);
// Execute the query to remove Extensiondistributor
$extensiondistributor_removed_done = $db->execute();
if ($extensiondistributor_removed_done)
{
// If successfully remove Extensiondistributor add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor extension was removed from the <b>#__action_logs_extensions</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor Package from the action_log_config table
$package_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.package') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($package_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_extensiondistributor.package
$package_action_log_config_done = $db->execute();
if ($package_action_log_config_done)
{
// If successfully removed Extensiondistributor Package add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor.package type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor Extension from the action_log_config table
$extension_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.extension') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($extension_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_extensiondistributor.extension
$extension_action_log_config_done = $db->execute();
if ($extension_action_log_config_done)
{
// If successfully removed Extensiondistributor Extension add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor.extension type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor Release from the action_log_config table
$release_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.release') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($release_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_extensiondistributor.release
$release_action_log_config_done = $db->execute();
if ($release_action_log_config_done)
{
// If successfully removed Extensiondistributor Release add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor.release type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor Subscription from the action_log_config table
$subscription_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.subscription') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($subscription_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_extensiondistributor.subscription
$subscription_action_log_config_done = $db->execute();
if ($subscription_action_log_config_done)
{
// If successfully removed Extensiondistributor Subscription add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor.subscription type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor Key from the action_log_config table
$key_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.key') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($key_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_extensiondistributor.key
$key_action_log_config_done = $db->execute();
if ($key_action_log_config_done)
{
// If successfully removed Extensiondistributor Key add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor.key type alias was removed from the <b>#__action_log_config</b> table'));
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
}
// Remove Extensiondistributor Download from the action_log_config table
$download_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_extensiondistributor.download') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__action_log_config'));
$query->where($download_action_log_config);
$db->setQuery($query);
// Execute the query to remove com_extensiondistributor.download
$download_action_log_config_done = $db->execute();
if ($download_action_log_config_done)
{
// If successfully removed Extensiondistributor Download add queued success message.
$app->enqueueMessage(JText::_('The com_extensiondistributor.download type alias was removed from the <b>#__action_log_config</b> table'));
}
// little notice as after service, in case of bad experience with component.
echo '<h2>Did something go wrong? Are you disappointed?</h2>
<p>Please let me know at <a href="mailto:emmanuel.danan@agerix.fr">emmanuel.danan@agerix.fr</a>.
<br />We at Agence Agerix are committed to building extensions that performs proficiently! You can help us, really!
<br />Send me your thoughts on improvements that is needed, trust me, I will be very grateful!
<br />Visit us at <a href="https://agerix.fr" target="_blank">https://agerix.fr</a> today!</p>';
}
/**
* Called on update
*
* @param ComponentAdapter $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function update(ComponentAdapter $parent){}
/**
* Called before any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param ComponentAdapter $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($type, ComponentAdapter $parent)
{
// get application
$app = JFactory::getApplication();
// is redundant or so it seems ...hmmm let me know if it works again
if ($type === 'uninstall')
{
return true;
}
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.8.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
return false;
}
// do any updates needed
if ($type === 'update')
{
}
// do any install needed
if ($type === 'install')
{
}
// check if the PHPExcel stuff is still around
if (File::exists(JPATH_ADMINISTRATOR . '/components/com_extensiondistributor/helpers/PHPExcel.php'))
{
// We need to remove this old PHPExcel folder
$this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_extensiondistributor/helpers/PHPExcel');
// We need to remove this old PHPExcel file
File::delete(JPATH_ADMINISTRATOR . '/components/com_extensiondistributor/helpers/PHPExcel.php');
}
return true;
}
/**
* Called after any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param ComponentAdapter $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($type, ComponentAdapter $parent)
{
// get application
$app = JFactory::getApplication();
// set the default component settings
if ($type === 'install')
{
// Get The Database object
$db = JFactory::getDbo();
// Create the package content type object.
$package = new stdClass();
$package->type_title = 'Extensiondistributor Package';
$package->type_alias = 'com_extensiondistributor.package';
$package->table = '{"special": {"dbtable": "#__extensiondistributor_package","key": "id","type": "Package","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$package->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "description","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","release_date":"release_date","version_number":"version_number","update":"update","free":"free","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","add_php_preflight_uninstall":"add_php_preflight_uninstall","infourl":"infourl","useupdate":"useupdate","packager":"packager","file":"file","jed":"jed","newfilename":"newfilename","license":"license","php_minimum":"php_minimum","blockchilduninstall":"blockchilduninstall","packagerurl":"packagerurl","add_php_preflight_install":"add_php_preflight_install","copyright":"copyright","add_php_preflight_update":"add_php_preflight_update","image":"image","php_preflight_install":"php_preflight_install","alias":"alias","php_preflight_update":"php_preflight_update","packagename":"packagename","php_preflight_uninstall":"php_preflight_uninstall","author":"author","php_postflight_install":"php_postflight_install","authorurl":"authorurl","php_postflight_update":"php_postflight_update","authoremail":"authoremail","php_method_uninstall":"php_method_uninstall","targetplatform":"targetplatform"}}';
$package->router = 'ExtensiondistributorHelperRoute::getPackageRoute';
$package->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/package.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","release_date","version_number"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","free","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","add_php_preflight_uninstall","useupdate","catid","blockchilduninstall","add_php_preflight_install","add_php_preflight_update"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$package_Inserted = $db->insertObject('#__content_types', $package);
// Create the extension content type object.
$extension = new stdClass();
$extension->type_title = 'Extensiondistributor Extension';
$extension->type_alias = 'com_extensiondistributor.extension';
$extension->table = '{"special": {"dbtable": "#__extensiondistributor_extension","key": "id","type": "Extension","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$extension->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","type":"type","version_number":"version_number","release_date":"release_date","update":"update","group":"group","client":"client","alias":"alias","newfilename":"newfilename","keepfilename":"keepfilename","element":"element","tags":"tags","image":"image","description":"description"}}';
$extension->router = 'ExtensiondistributorHelperRoute::getExtensionRoute';
$extension->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/extension.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","version_number","release_date"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","keepfilename","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$extension_Inserted = $db->insertObject('#__content_types', $extension);
// Create the extension category content type object.
$extension_category = new stdClass();
$extension_category->type_title = 'Extensiondistributor Extension Catid';
$extension_category->type_alias = 'com_extensiondistributor.extension.category';
$extension_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$extension_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$extension_category->router = 'ExtensiondistributorHelperRoute::getCategoryRoute';
$extension_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
// Set the object into the content types table.
$extension_category_Inserted = $db->insertObject('#__content_types', $extension_category);
// Create the release content type object.
$release = new stdClass();
$release->type_title = 'Extensiondistributor Release';
$release->type_alias = 'com_extensiondistributor.release';
$release->table = '{"special": {"dbtable": "#__extensiondistributor_release","key": "id","type": "Release","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$release->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "version_number","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"toolbar":"toolbar","extension":"extension","package":"package","version_number":"version_number","file":"file","release_date":"release_date","reltype":"reltype","description":"description","zip_content":"zip_content","xmlpublished":"xmlpublished","stability":"stability"}}';
$release->router = 'ExtensiondistributorHelperRoute::getReleaseRoute';
$release->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/release.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","toolbar","zip_content"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","extension","package","xmlpublished","stability"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "extension","targetTable": "#__extensiondistributor_extension","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "package","targetTable": "#__extensiondistributor_package","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$release_Inserted = $db->insertObject('#__content_types', $release);
// Create the key content type object.
$key = new stdClass();
$key->type_title = 'Extensiondistributor Key';
$key->type_alias = 'com_extensiondistributor.key';
$key->table = '{"special": {"dbtable": "#__extensiondistributor_key","key": "id","type": "Key","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$key->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "key","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"key":"key","website":"website","user":"user"}}';
$key->router = 'ExtensiondistributorHelperRoute::getKeyRoute';
$key->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/key.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","user"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$key_Inserted = $db->insertObject('#__content_types', $key);
// Install the global extension params.
$query = $db->getQuery(true);
// Field to update.
$fields = array(
$db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Emmanuel Danan","autorEmail":"emmanuel.danan@agerix.fr","releases_directory":"packages","jcb_directory":"jcb","updates_directory":"updates","import_directory":"importfolder","stability":"4","keepfilename":"1","newfilename":"{type}{_group}_{element}_v{major}_{minor}_{release}_{stability}.zip","targetplatform":"3.(9|10)","php_minimum":"7.0","check_in":"-1 day","save_history":"1","history_limit":"10"}'),
);
// Condition.
$conditions = array(
$db->quoteName('element') . ' = ' . $db->quote('com_extensiondistributor')
);
$query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
$db->setQuery($query);
$allDone = $db->execute();
// Create a default category
$app = JFactory::getApplication();
if (!class_exists('ExtensiondistributorHelper')) {
require_once JPATH_ADMINISTRATOR.'/components/com_extensiondistributor/helpers/extensiondistributor.php';
}
$model = ExtensiondistributorHelper::getModel('Category', JPATH_ADMINISTRATOR . '/components/com_categories', 'Categories');
$data = $model->getItem();
$data->parent_id = 1;
$data->level = 1;
$data->path = 'uncategorized';
$data->extension = 'com_extensiondistributor';
$data->alias = 'uncategorized';
$data->title = 'Uncategorized';
$data->created_user_id = JFactory::getUser()->id;
$data->created_time = JFactory::getDate()->toSql();
$data->access = 1;
$data->published = 1;
$data->language = '*';
$model->save((array)$data);
// Create and secure directories
$cparams = JComponentHelper::getParams('com_extensiondistributor');
$componentid = JComponentHelper::getComponent('com_extensiondistributor')->id;
$directories['releases_directory'] = JPath::clean(JPATH_SITE . '/' . $cparams->get('releases_directory','packages') . '/');
$directories['jcb_directory'] = JPath::clean(JPATH_SITE . '/' . $cparams->get('jcb_directory','jcb') . '/');
$directories['updates_directory'] = JPath::clean(JPATH_SITE . '/' . $cparams->get('updates_directory','updates') . '/');
$directories['import_directory'] = JPath::clean(JPATH_SITE . '/' . $cparams->get('import_directory','importfolder') . '/');
foreach ($directories as $k => $directory) {
if (!JFolder::exists($directory)) {
JFolder::create($directory);
}
if ($k !== 'updates_directory')
{
ExtensiondistributorHelper::secureFolder($directory,'secure');
}
}
// Get the biggest rule column in the assets table at this point.
$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
$db->setQuery($get_rule_length);
if ($db->execute())
{
$rule_length = $db->loadResult();
// Check the size of the rules column
if ($rule_length <= 7200)
{
// Fix the assets table rules column size
$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';";
$db->setQuery($fix_rules_size);
$db->execute();
$app->enqueueMessage(JText::_('The <b>#__assets</b> table rules column was resized to the TEXT datatype for the components possible large permission rules.'));
}
}
echo '<a target="_blank" href="https://agerix.fr" title="Extension Distributor">
<img src="components/com_extensiondistributor/assets/images/vdm-component.png"/>
</a>';
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the extensiondistributor action logs extensions object.
$extensiondistributor_action_logs_extensions = new stdClass();
$extensiondistributor_action_logs_extensions->extension = 'com_extensiondistributor';
// Set the object into the action logs extensions table.
$extensiondistributor_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $extensiondistributor_action_logs_extensions);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the package action log config object.
$package_action_log_config = new stdClass();
$package_action_log_config->type_title = 'PACKAGE';
$package_action_log_config->type_alias = 'com_extensiondistributor.package';
$package_action_log_config->id_holder = 'id';
$package_action_log_config->title_holder = 'name';
$package_action_log_config->table_name = '#__extensiondistributor_package';
$package_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Set the object into the action log config table.
$package_Inserted = $db->insertObject('#__action_log_config', $package_action_log_config);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the extension action log config object.
$extension_action_log_config = new stdClass();
$extension_action_log_config->type_title = 'EXTENSION';
$extension_action_log_config->type_alias = 'com_extensiondistributor.extension';
$extension_action_log_config->id_holder = 'id';
$extension_action_log_config->title_holder = 'name';
$extension_action_log_config->table_name = '#__extensiondistributor_extension';
$extension_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Set the object into the action log config table.
$extension_Inserted = $db->insertObject('#__action_log_config', $extension_action_log_config);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the release action log config object.
$release_action_log_config = new stdClass();
$release_action_log_config->type_title = 'RELEASE';
$release_action_log_config->type_alias = 'com_extensiondistributor.release';
$release_action_log_config->id_holder = 'id';
$release_action_log_config->title_holder = 'version_number';
$release_action_log_config->table_name = '#__extensiondistributor_release';
$release_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Set the object into the action log config table.
$release_Inserted = $db->insertObject('#__action_log_config', $release_action_log_config);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the subscription action log config object.
$subscription_action_log_config = new stdClass();
$subscription_action_log_config->type_title = 'SUBSCRIPTION';
$subscription_action_log_config->type_alias = 'com_extensiondistributor.subscription';
$subscription_action_log_config->id_holder = 'id';
$subscription_action_log_config->title_holder = 'date_start';
$subscription_action_log_config->table_name = '#__extensiondistributor_subscription';
$subscription_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Set the object into the action log config table.
$subscription_Inserted = $db->insertObject('#__action_log_config', $subscription_action_log_config);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the key action log config object.
$key_action_log_config = new stdClass();
$key_action_log_config->type_title = 'KEY';
$key_action_log_config->type_alias = 'com_extensiondistributor.key';
$key_action_log_config->id_holder = 'id';
$key_action_log_config->title_holder = 'key';
$key_action_log_config->table_name = '#__extensiondistributor_key';
$key_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Set the object into the action log config table.
$key_Inserted = $db->insertObject('#__action_log_config', $key_action_log_config);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the download action log config object.
$download_action_log_config = new stdClass();
$download_action_log_config->type_title = 'DOWNLOAD';
$download_action_log_config->type_alias = 'com_extensiondistributor.download';
$download_action_log_config->id_holder = 'id';
$download_action_log_config->title_holder = 'id';
$download_action_log_config->table_name = '#__extensiondistributor_download';
$download_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Set the object into the action log config table.
$download_Inserted = $db->insertObject('#__action_log_config', $download_action_log_config);
}
// do any updates needed
if ($type === 'update')
{
// Get The Database object
$db = JFactory::getDbo();
// Create the package content type object.
$package = new stdClass();
$package->type_title = 'Extensiondistributor Package';
$package->type_alias = 'com_extensiondistributor.package';
$package->table = '{"special": {"dbtable": "#__extensiondistributor_package","key": "id","type": "Package","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$package->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "description","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","release_date":"release_date","version_number":"version_number","update":"update","free":"free","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","add_php_preflight_uninstall":"add_php_preflight_uninstall","infourl":"infourl","useupdate":"useupdate","packager":"packager","file":"file","jed":"jed","newfilename":"newfilename","license":"license","php_minimum":"php_minimum","blockchilduninstall":"blockchilduninstall","packagerurl":"packagerurl","add_php_preflight_install":"add_php_preflight_install","copyright":"copyright","add_php_preflight_update":"add_php_preflight_update","image":"image","php_preflight_install":"php_preflight_install","alias":"alias","php_preflight_update":"php_preflight_update","packagename":"packagename","php_preflight_uninstall":"php_preflight_uninstall","author":"author","php_postflight_install":"php_postflight_install","authorurl":"authorurl","php_postflight_update":"php_postflight_update","authoremail":"authoremail","php_method_uninstall":"php_method_uninstall","targetplatform":"targetplatform"}}';
$package->router = 'ExtensiondistributorHelperRoute::getPackageRoute';
$package->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/package.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","release_date","version_number"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","free","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","add_php_preflight_uninstall","useupdate","catid","blockchilduninstall","add_php_preflight_install","add_php_preflight_update"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Check if package type is already in content_type DB.
$package_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($package->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$package->type_id = $db->loadResult();
$package_Updated = $db->updateObject('#__content_types', $package, 'type_id');
}
else
{
$package_Inserted = $db->insertObject('#__content_types', $package);
}
// Create the extension content type object.
$extension = new stdClass();
$extension->type_title = 'Extensiondistributor Extension';
$extension->type_alias = 'com_extensiondistributor.extension';
$extension->table = '{"special": {"dbtable": "#__extensiondistributor_extension","key": "id","type": "Extension","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$extension->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","type":"type","version_number":"version_number","release_date":"release_date","update":"update","group":"group","client":"client","alias":"alias","newfilename":"newfilename","keepfilename":"keepfilename","element":"element","tags":"tags","image":"image","description":"description"}}';
$extension->router = 'ExtensiondistributorHelperRoute::getExtensionRoute';
$extension->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/extension.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","version_number","release_date"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","keepfilename","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Check if extension type is already in content_type DB.
$extension_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($extension->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$extension->type_id = $db->loadResult();
$extension_Updated = $db->updateObject('#__content_types', $extension, 'type_id');
}
else
{
$extension_Inserted = $db->insertObject('#__content_types', $extension);
}
// Create the extension category content type object.
$extension_category = new stdClass();
$extension_category->type_title = 'Extensiondistributor Extension Catid';
$extension_category->type_alias = 'com_extensiondistributor.extension.category';
$extension_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$extension_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$extension_category->router = 'ExtensiondistributorHelperRoute::getCategoryRoute';
$extension_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}';
// Check if extension category type is already in content_type DB.
$extension_category_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($extension_category->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$extension_category->type_id = $db->loadResult();
$extension_category_Updated = $db->updateObject('#__content_types', $extension_category, 'type_id');
}
else
{
$extension_category_Inserted = $db->insertObject('#__content_types', $extension_category);
}
// Create the release content type object.
$release = new stdClass();
$release->type_title = 'Extensiondistributor Release';
$release->type_alias = 'com_extensiondistributor.release';
$release->table = '{"special": {"dbtable": "#__extensiondistributor_release","key": "id","type": "Release","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$release->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "version_number","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"toolbar":"toolbar","extension":"extension","package":"package","version_number":"version_number","file":"file","release_date":"release_date","reltype":"reltype","description":"description","zip_content":"zip_content","xmlpublished":"xmlpublished","stability":"stability"}}';
$release->router = 'ExtensiondistributorHelperRoute::getReleaseRoute';
$release->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/release.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","toolbar","zip_content"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","extension","package","xmlpublished","stability"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "extension","targetTable": "#__extensiondistributor_extension","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "package","targetTable": "#__extensiondistributor_package","targetColumn": "id","displayColumn": "name"}]}';
// Check if release type is already in content_type DB.
$release_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($release->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$release->type_id = $db->loadResult();
$release_Updated = $db->updateObject('#__content_types', $release, 'type_id');
}
else
{
$release_Inserted = $db->insertObject('#__content_types', $release);
}
// Create the key content type object.
$key = new stdClass();
$key->type_title = 'Extensiondistributor Key';
$key->type_alias = 'com_extensiondistributor.key';
$key->table = '{"special": {"dbtable": "#__extensiondistributor_key","key": "id","type": "Key","prefix": "extensiondistributorTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$key->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "key","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"key":"key","website":"website","user":"user"}}';
$key->router = 'ExtensiondistributorHelperRoute::getKeyRoute';
$key->content_history_options = '{"formFile": "administrator/components/com_extensiondistributor/models/forms/key.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","user"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Check if key type is already in content_type DB.
$key_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($key->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$key->type_id = $db->loadResult();
$key_Updated = $db->updateObject('#__content_types', $key, 'type_id');
}
else
{
$key_Inserted = $db->insertObject('#__content_types', $key);
}
echo '<a target="_blank" href="https://agerix.fr" title="Extension Distributor">
<img src="components/com_extensiondistributor/assets/images/vdm-component.png"/>
</a>
<h3>Upgrade to Version 1.0.7 Was Successful! Let us know if anything is not working as expected.</h3>';
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the extensiondistributor action logs extensions object.
$extensiondistributor_action_logs_extensions = new stdClass();
$extensiondistributor_action_logs_extensions->extension = 'com_extensiondistributor';
// Check if extensiondistributor action log extension is already in action logs extensions DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_logs_extensions'));
$query->where($db->quoteName('extension') . ' LIKE '. $db->quote($extensiondistributor_action_logs_extensions->extension));
$db->setQuery($query);
$db->execute();
// Set the object into the action logs extensions table if not found.
if (!$db->getNumRows())
{
$extensiondistributor_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $extensiondistributor_action_logs_extensions);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the package action log config object.
$package_action_log_config = new stdClass();
$package_action_log_config->id = null;
$package_action_log_config->type_title = 'PACKAGE';
$package_action_log_config->type_alias = 'com_extensiondistributor.package';
$package_action_log_config->id_holder = 'id';
$package_action_log_config->title_holder = 'name';
$package_action_log_config->table_name = '#__extensiondistributor_package';
$package_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Check if package action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($package_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$package_action_log_config->id = $db->loadResult();
$package_action_log_config_Updated = $db->updateObject('#__action_log_config', $package_action_log_config, 'id');
}
else
{
$package_action_log_config_Inserted = $db->insertObject('#__action_log_config', $package_action_log_config);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the extension action log config object.
$extension_action_log_config = new stdClass();
$extension_action_log_config->id = null;
$extension_action_log_config->type_title = 'EXTENSION';
$extension_action_log_config->type_alias = 'com_extensiondistributor.extension';
$extension_action_log_config->id_holder = 'id';
$extension_action_log_config->title_holder = 'name';
$extension_action_log_config->table_name = '#__extensiondistributor_extension';
$extension_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Check if extension action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($extension_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$extension_action_log_config->id = $db->loadResult();
$extension_action_log_config_Updated = $db->updateObject('#__action_log_config', $extension_action_log_config, 'id');
}
else
{
$extension_action_log_config_Inserted = $db->insertObject('#__action_log_config', $extension_action_log_config);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the release action log config object.
$release_action_log_config = new stdClass();
$release_action_log_config->id = null;
$release_action_log_config->type_title = 'RELEASE';
$release_action_log_config->type_alias = 'com_extensiondistributor.release';
$release_action_log_config->id_holder = 'id';
$release_action_log_config->title_holder = 'version_number';
$release_action_log_config->table_name = '#__extensiondistributor_release';
$release_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Check if release action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($release_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$release_action_log_config->id = $db->loadResult();
$release_action_log_config_Updated = $db->updateObject('#__action_log_config', $release_action_log_config, 'id');
}
else
{
$release_action_log_config_Inserted = $db->insertObject('#__action_log_config', $release_action_log_config);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the subscription action log config object.
$subscription_action_log_config = new stdClass();
$subscription_action_log_config->id = null;
$subscription_action_log_config->type_title = 'SUBSCRIPTION';
$subscription_action_log_config->type_alias = 'com_extensiondistributor.subscription';
$subscription_action_log_config->id_holder = 'id';
$subscription_action_log_config->title_holder = 'date_start';
$subscription_action_log_config->table_name = '#__extensiondistributor_subscription';
$subscription_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Check if subscription action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($subscription_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$subscription_action_log_config->id = $db->loadResult();
$subscription_action_log_config_Updated = $db->updateObject('#__action_log_config', $subscription_action_log_config, 'id');
}
else
{
$subscription_action_log_config_Inserted = $db->insertObject('#__action_log_config', $subscription_action_log_config);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the key action log config object.
$key_action_log_config = new stdClass();
$key_action_log_config->id = null;
$key_action_log_config->type_title = 'KEY';
$key_action_log_config->type_alias = 'com_extensiondistributor.key';
$key_action_log_config->id_holder = 'id';
$key_action_log_config->title_holder = 'key';
$key_action_log_config->table_name = '#__extensiondistributor_key';
$key_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Check if key action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($key_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$key_action_log_config->id = $db->loadResult();
$key_action_log_config_Updated = $db->updateObject('#__action_log_config', $key_action_log_config, 'id');
}
else
{
$key_action_log_config_Inserted = $db->insertObject('#__action_log_config', $key_action_log_config);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the download action log config object.
$download_action_log_config = new stdClass();
$download_action_log_config->id = null;
$download_action_log_config->type_title = 'DOWNLOAD';
$download_action_log_config->type_alias = 'com_extensiondistributor.download';
$download_action_log_config->id_holder = 'id';
$download_action_log_config->title_holder = 'id';
$download_action_log_config->table_name = '#__extensiondistributor_download';
$download_action_log_config->text_prefix = 'COM_EXTENSIONDISTRIBUTOR';
// Check if download action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($download_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$download_action_log_config->id = $db->loadResult();
$download_action_log_config_Updated = $db->updateObject('#__action_log_config', $download_action_log_config, 'id');
}
else
{
$download_action_log_config_Inserted = $db->insertObject('#__action_log_config', $download_action_log_config);
}
}
return true;
}
/**
* Remove folders with files
*
* @param string $dir The path to folder to remove
* @param boolean $ignore The folders and files to ignore and not remove
*
* @return boolean True in all is removed
*
*/
protected function removeFolder($dir, $ignore = false)
{
if (Folder::exists($dir))
{
$it = new RecursiveDirectoryIterator($dir);
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
// remove ending /
$dir = rtrim($dir, '/');
// now loop the files & folders
foreach ($it as $file)
{
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
// set file dir
$file_dir = $file->getPathname();
// check if this is a dir or a file
if ($file->isDir())
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
Folder::delete($file_dir);
}
else
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
File::delete($file_dir);
}
}
// delete the root folder if not ignore found
if (!$this->checkArray($ignore))
{
return Folder::delete($dir);
}
return true;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
protected function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return $this->checkArray($array, false);
}
return $nr;
}
return false;
}
}