| Current Path : /home/poneycluc/www/administrator/manifests/packages/hobrgpd/ |
| Current File : /home/poneycluc/www/administrator/manifests/packages/hobrgpd/pkg_script.php |
<?php
/**
* @version $Id$
* @package Advanced Cookies
* @copyright Copyright (C) 2019 HOB-France.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: https://www.hob-france.com/
* @author email info@hob-fr.com
* @developer Mihaly Varga - michel.varga@hob-fr.com
*
*/
// No direct access to this file
defined('_JEXEC') or die;
/**
* Script file of HelloWorld module
*/
class pkg_hobrgpdInstallerScript
{
protected $extensionsToEnable = array(
array('name' => 'advanced_cookies_system',
'type' => 'plugin',
'group' => 'system')
);
private function enableExtensions()
{
foreach ($this->extensionsToEnable as $extension) {
// Enable plugin
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__extensions');
$query->set($db->quoteName('enabled') . ' = 1');
$query->where($db->quoteName('element') . ' = ' . $db->quote($extension['name']));
$query->where($db->quoteName('type') . ' = ' . $db->quote($extension['type']));
if ($extension['type'] === 'plugin')
{
$query->where('folder = ' . $db->quote($extension['group']));
}
$db->setQuery($query);
$db->execute();
}
}
private function hideTitle()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__modules');
$query->set($db->quoteName('showtitle') . ' = 0');
$query->where($db->quoteName('title') . ' = ' . $db->quote('Advanced Cookies'));
$query->where($db->quoteName('module') . ' = ' . $db->quote('mod_advanced_cookies'));
$db->setQuery($query);
$db->execute();
}
/**
* Method to install the extension
* $parent is the class calling this method
*
* @return void
*/
function install($parent)
{
// echo '<p>The module has been installed</p>';
}
/**
* Method to uninstall the extension
* $parent is the class calling this method
*
* @return void
*/
function uninstall($parent)
{
// echo '<p>The module has been uninstalled</p>';
}
/**
* Method to update the extension
* $parent is the class calling this method
*
* @return void
*/
function update($parent)
{
// echo '<p>The module has been updated to version' . $parent->get('manifest')->version . '</p>';
}
/**
* Method to run before an install/update/uninstall method
* $parent is the class calling this method
* $type is the type of change (install, update or discover_install)
*
* @return void
*/
function preflight($type, $parent)
{
//echo '<p>Anything here happens before the installation/update/uninstallation of the module</p>';
}
/**
* Method to run after an install/update/uninstall method
* $parent is the class calling this method
* $type is the type of change (install, update or discover_install)
*
* @return void
*/
function postflight($type, $parent)
{
$this->enableExtensions();
$this->hideTitle();
echo '<p style="color: red; font-size: 1rem; line-height: 1.5rem; border-left: solid 2px red; padding-left: 10px;">Aidez-nous améliorer notre application. Partagez l\'adresse de votre site avec nous.</p>
<p style="color: red; font-size: 1rem; line-height: 1.5rem; border-left: solid 2px red; padding-left: 10px;">Help us improve our application. Share your website address with us.</p>';
echo '<a class="btn btn-primary" id="email_allowed">Soutiens Nous - Support Us</a><br/>
<p style="color: green; font-size: 1.5em; line-height: 1.5rem; margin: 10px;" id="response"></p>
';
echo '
<script>
jQuery("#email_allowed").click(function(){
var post_url = "administrator/index.php?option=com_ajax&module=advanced_cookies&method=HOBmail&format=json"; //get form action url
var request_method = "POST"; //get form GET/POST method
jQuery.ajax({
url : post_url,
type: request_method,
success: function(data){
jQuery("#response").text("Merci pour votre aide! - Thanks for your support!");
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
jQuery("#response").text("Le courrier n\'a pas été envoyé. - The mail has not been sent.");
}
});
});
</script>
';
}
}