<commit_before><?php
/**
 * 2015 <NAME> for 01generator
 *
 * This is a Payment module for Prestashop. This module requires
 *
 *  @author    <NAME> for 01generator
 *  @license   MIT License
 */

if (!defined('_PS_VERSION_')) {
    exit;
}

/**
 * Class CallMeBack
 */
class CallMeBack extends Module
{
    const SURNAME = 'CALLMEBACK_SURNAME';
    const EMAIL = 'CALLMEBACK_EMAIL';
    const TELEPHONE2 = 'CALLMEBACK_TELEPHONE2';
    const MESSAGE = 'CALLMEBACK_MSG';
    const HOURS = 'CALLMEBACK_HOURS';

    /**
     * CallMeBack constructor.
     */
    public function __construct()
    {

        $this->name = 'callmeback';
        $this->tab = 'front_office_features';
        $this->version = '1.0.7';
        $this->author = '01generator';
        $this->module_key = '';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
        $this->bootstrap = true;
        parent::__construct();
        $this->displayName = $this->l('Call me back');
        $this->description = $this->l('Now allow your customers to leave their telephone number so you can call them back');

        $this->controllers = array('ajax');
    }

    /**
     * Install this module
     *
     * @return bool Whether the module has been successfully installed
     * @throws PrestaShopException
     */
    public function install()
    {
        // Install hooks
        // displayProductButtons, displayFooterProduct, displayProductTab, displayProductTabContent
        if (!parent::install() ||
            !$this->registerHook('displayProductButtons') ||
            !$this->registerHook('actionAdminControllerSetMedia') ||
            !$this->registerHook('displayFooter') ||
            !$this->registerHook('displayHeader') ||
            !$this->registerHook('displayBackOfficeHeader')
        ) {
            return false;
        }

        if (!$this->installTab('AdminParentCustomer', 'AdminCallMeBack', 'Call me back')) {
            return false;
        }

        // Create SQL table for trasaction tracking
        include_once _PS_MODULE_DIR_.$this->name.'/sql/CallMeBackSql.php';
        $callMeBackSqlInstall = new CallMeBackSql();
        $callMeBackSqlInstall->createTables();

        return true;
    }

    /**
     * Uninstall this module
     *
     * @return bool Whether this module has been successfully uninstalled
     */
    public function uninstall()
    {
        if (!parent::uninstall()) {
            return false;
        }

        // Unistall the admin tab
        if (!$this->uninstallTab('AdminCallMeBack')) {
            return false;
        }

        //All went well :)
        return true;
    }

    /**
     * Install the required tabs by the module
     *
     * @param string $parent    Parent class name
     * @param string $className Class name of new tab
     * @param string $tabName   Tab name of new tab
     * @return int New tab ID
     */
    public function installTab($parent, $className, $tabName)
    {
        // Create new admin tab
        $tab = new Tab();
        $tab->id_parent = (int) Tab::getIdFromClassName($parent);
        $tab->name = array();
        foreach (Language::getLanguages(true) as $lang) {
            $tab->name[$lang['id_lang']] = $tabName;
        }

        $tab->class_name = $className;
        $tab->module = $this->name;
        $tab->active = 1;

        return $tab->add();
    }

    /**
     * Uninstall the required admin tabs of the module
     *
     * @param string $className Class name of tab to be uninstalled
     * @return bool Whether the tab has been successfully uninstalled
     */
    public function uninstallTab($className)
    {
        // Retrieve Tab ID
        $idTab = (int) Tab::getIdFromClassName($className);
        // Load tab
        $tab = new Tab((int) $idTab);
        // Delete it
        return $tab->delete();
    }

    /**
     * Get hook Controller
     *
     * @param string $hookName Name of hook
     * @return mixed
     */
    public function getHookController($hookName)
    {
        require_once dirname(__FILE__).'/controllers/hook/'.$hookName.'.php';
        $controllerName = $this->name.$hookName.'Controller';
        $controller = new $controllerName($this, __FILE__, $this->_path);

        return $controller;
    }

    /**
     * Hook to FO HEAD tags
     *
     * @return string Hook HTML
     */
    public function hookDisplayHeader()
    {
        $this->context->smarty->assign(array(
            'callmeback_ajax' => $this->context->link->getModuleLink($this->name, 'ajax', array(), Tools::usingSecureMode()),
        ));

        return $this->display(__FILE__, 'views/templates/front/jsdef.tpl');
    }

    /**
     * Hook to BO HEAD tags
     *
     * @return string Hook HTML
     */
    public function hookDisplayBackOfficeHeader()
    {
        $this->context->smarty->assign(array(
            'callmeback_ajax' => $this->context->link->getModuleLink($this->name, 'ajax', array(), Tools::usingSecureMode()),
        ));

        return $this->display(__FILE__, 'views/templates/admin/jsdef.tpl');
    }

    /**
     * Hook to display Product Buttons<commit_msg>Let browser decide best protocol<commit_after><?php
/**
 * 2015 <NAME> for 01generator
 *
 * This is a Payment module for Prestashop. This module requires
 *
 *  @author    <NAME> for 01generator
 *  @license   MIT License
 */

if (!defined('_PS_VERSION_')) {
    exit;
}

/**
 * Class CallMeBack
 */
class CallMeBack extends Module
{
    const SURNAME = 'CALLMEBACK_SURNAME';
    const EMAIL = 'CALLMEBACK_EMAIL';
    const TELEPHONE2 = 'CALLMEBACK_TELEPHONE2';
    const MESSAGE = 'CALLMEBACK_MSG';
    const HOURS = 'CALLMEBACK_HOURS';

    /**
     * CallMeBack constructor.
     */
    public function __construct()
    {

        $this->name = 'callmeback';
        $this->tab = 'front_office_features';
        $this->version = '1.0.7';
        $this->author = '<PASSWORD>';
        $this->module_key = '';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
        $this->bootstrap = true;
        parent::__construct();
        $this->displayName = $this->l('<NAME>');
        $this->description = $this->l('Now allow your customers to leave their telephone number so you can call them back');

        $this->controllers = array('ajax');
    }

    /**
     * Install this module
     *
     * @return bool Whether the module has been successfully installed
     * @throws PrestaShopException
     */
    public function install()
    {
        // Install hooks
        // displayProductButtons, displayFooterProduct, displayProductTab, displayProductTabContent
        if (!parent::install() ||
            !$this->registerHook('displayProductButtons') ||
            !$this->registerHook('actionAdminControllerSetMedia') ||
            !$this->registerHook('displayFooter') ||
            !$this->registerHook('displayHeader') ||
            !$this->registerHook('displayBackOfficeHeader')
        ) {
            return false;
        }

        if (!$this->installTab('AdminParentCustomer', 'AdminCallMeBack', 'Call me back')) {
            return false;
        }

        // Create SQL table for trasaction tracking
        include_once _PS_MODULE_DIR_.$this->name.'/sql/CallMeBackSql.php';
        $callMeBackSqlInstall = new CallMeBackSql();
        $callMeBackSqlInstall->createTables();

        return true;
    }

    /**
     * Uninstall this module
     *
     * @return bool Whether this module has been successfully uninstalled
     */
    public function uninstall()
    {
        if (!parent::uninstall()) {
            return false;
        }

        // Unistall the admin tab
        if (!$this->uninstallTab('AdminCallMeBack')) {
            return false;
        }

        //All went well :)
        return true;
    }

    /**
     * Install the required tabs by the module
     *
     * @param string $parent    Parent class name
     * @param string $className Class name of new tab
     * @param string $tabName   Tab name of new tab
     * @return int New tab ID
     */
    public function installTab($parent, $className, $tabName)
    {
        // Create new admin tab
        $tab = new Tab();
        $tab->id_parent = (int) Tab::getIdFromClassName($parent);
        $tab->name = array();
        foreach (Language::getLanguages(true) as $lang) {
            $tab->name[$lang['id_lang']] = $tabName;
        }

        $tab->class_name = $className;
        $tab->module = $this->name;
        $tab->active = 1;

        return $tab->add();
    }

    /**
     * Uninstall the required admin tabs of the module
     *
     * @param string $className Class name of tab to be uninstalled
     * @return bool Whether the tab has been successfully uninstalled
     */
    public function uninstallTab($className)
    {
        // Retrieve Tab ID
        $idTab = (int) Tab::getIdFromClassName($className);
        // Load tab
        $tab = new Tab((int) $idTab);
        // Delete it
        return $tab->delete();
    }

    /**
     * Get hook Controller
     *
     * @param string $hookName Name of hook
     * @return mixed
     */
    public function getHookController($hookName)
    {
        require_once dirname(__FILE__).'/controllers/hook/'.$hookName.'.php';
        $controllerName = $this->name.$hookName.'Controller';
        $controller = new $controllerName($this, __FILE__, $this->_path);

        return $controller;
    }

    /**
     * Hook to FO HEAD tags
     *
     * @return string Hook HTML
     */
    public function hookDisplayHeader()
    {
        $this->context->smarty->assign(array(
            'callmeback_ajax' => $this->context->link->getModuleLink($this->name, 'ajax', array(), null, null, true),
        ));

        return $this->display(__FILE__, 'views/templates/front/jsdef.tpl');
    }

    /**
     * Hook to BO HEAD tags
     *
     * @return string Hook HTML
     */
    public function hookDisplayBackOfficeHeader()
    {
        $this->context->smarty->assign(array(
            'callmeback_ajax' => $this->context->link->getModuleLink($this->name, 'ajax', array(), null, null, true),
        ));

        return $this->display(__FILE__, 'views/templates/admin/jsdef.tpl');
    }

    /**
     * Hook to display Product Buttons
{'fraction_non_alphanumeric': 0.13186813186813187, 'fraction_numerical': 0.003470213996529786, 'mean_word_length': 2.2432010003125975, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5673854', 'n_tokens_mistral': 2999, 'n_tokens_neox': 2927, 'n_words': 727}