Пример #1
0
/**
 * 2007-2015 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <*****@*****.**>
 * @copyright 2007-2015 PrestaShop SA
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */
function set_payment_module()
{
    // Get all modules then select only payment ones
    $modules = Module::getModulesInstalled();
    foreach ($modules as $module) {
        $file = _PS_MODULE_DIR_ . $module['name'] . '/' . $module['name'] . '.php';
        if (!file_exists($file)) {
            continue;
        }
        $fd = fopen($file, 'r');
        if (!$fd) {
            continue;
        }
        $content = fread($fd, filesize($file));
        if (preg_match_all('/extends PaymentModule/U', $content, $matches)) {
            Db::getInstance()->execute('
			INSERT INTO `' . _DB_PREFIX_ . 'module_country` (id_module, id_country)
			SELECT ' . (int) $module['id_module'] . ', id_country FROM `' . _DB_PREFIX_ . 'country` WHERE active = 1');
            Db::getInstance()->execute('
			INSERT INTO `' . _DB_PREFIX_ . 'module_currency` (id_module, id_currency)
			SELECT ' . (int) $module['id_module'] . ', id_currency FROM `' . _DB_PREFIX_ . 'currency` WHERE deleted = 0');
        }
        fclose($fd);
    }
}
Пример #2
0
    public function renderForm($data)
    {
        $helper = $this->getFormHelper();
        $id_shop = Context::getContext()->shop->id;
        if (isset($data['params']['hookmodule'])) {
            $hid = Hook::getIdByName($data['params']['hookmodule']);
            if ($hid) {
                $hms = Hook::getModulesFromHook($hid);
                foreach ($hms as $hm) {
                    if ($data['params']['loadmodule'] == $hm['name']) {
                        $id_module = $hm['id_module'];
                        $module = Module::getInstanceById($id_module);
                        if (Validate::isLoadedObject($module)) {
                            !$module->unregisterHook((int) $hid, array($id_shop));
                        }
                    }
                }
            }
        }
        $modules = Module::getModulesInstalled(0);
        $output = array();
        $hooks = array('displayHome', 'displayLeftColumn', 'displayRightColumn', 'displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayMainmenu', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayMapLocal', 'displayFooterBottom');
        foreach ($hooks as $hook) {
            $output[] = array('name' => $hook, 'id' => $hook);
        }
        $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'select', 'label' => $this->l('Select A Module'), 'name' => 'loadmodule', 'options' => array('query' => $modules, 'id' => 'name', 'name' => 'name'), 'default' => '1', 'desc' => $this->l('Select A Module is used as widget. the hook of this module was unhooked.')), array('type' => 'select', 'label' => $this->l('Select A Hook'), 'name' => 'hookmodule', 'options' => array('query' => $output, 'id' => 'name', 'name' => 'name'), 'default' => '1', 'desc' => $this->l('Select A hook is used to render module\'s content. the hook of this module was unhooked. 
						You could not rollback it\'s position. So you need asign it in position management of prestashop.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
        $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        $a = $this->getConfigFieldsValues($data);
        $helper->tpl_vars = array('fields_value' => $a, 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang);
        return $helper->generateForm($this->fields_form);
    }
function desactivate_custom_modules()
{
    // Get all modules then select only payment ones
    $arrInstalledModules = Module::getModulesInstalled();
    // get native module list
    $module_list_xml = INSTALL_PATH . '/../config/modules_list.xml';
    $nativeModules = simplexml_load_file($module_list_xml);
    $nativeModules = $nativeModules->modules;
    if ($nativeModules['type'] == 'native') {
        foreach ($nativeModules->module as $module) {
            $arrNativeModules[] = $module['name'] . '';
        }
    }
    $uninstallMe = array("rien");
    foreach ($arrInstalledModules as $aModule) {
        if (!in_array($aModule['name'], $arrNativeModules)) {
            $uninstallMe[] = $aModule['name'];
        }
    }
    Module::disableByName($uninstallMe);
    foreach ($aModule as $module) {
        $file = _PS_MODULE_DIR_ . $module['name'] . '/' . $module['name'] . '.php';
        if (!file_exists($file)) {
            continue;
        }
        $fd = fopen($file, 'r');
        if (!$fd) {
            continue;
        }
        $content = fread($fd, filesize($file));
        if (preg_match_all('/extends PaymentModule/U', $content, $matches)) {
            Db::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . 'module_country` (id_module, id_country)
			SELECT ' . (int) $module['id_module'] . ', id_country FROM `' . _DB_PREFIX_ . 'country` WHERE active = 1');
            Db::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . 'module_currency` (id_module, id_currency)
			SELECT ' . (int) $module['id_module'] . ', id_currency FROM `' . _DB_PREFIX_ . 'currency` WHERE deleted = 0');
        }
        fclose($fd);
    }
}
function set_payment_module_group()
{
    // Get all modules then select only payment ones
    $modules = Module::getModulesInstalled();
    foreach ($modules as $module) {
        $file = _PS_MODULE_DIR_ . $module['name'] . '/' . $module['name'] . '.php';
        if (!file_exists($file)) {
            continue;
        }
        $fd = @fopen($file, 'r');
        if (!$fd) {
            continue;
        }
        $content = fread($fd, filesize($file));
        if (preg_match_all('/extends PaymentModule/U', $content, $matches)) {
            Db::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . 'module_group` (id_module, id_group)
			SELECT ' . (int) $module['id_module'] . ', id_group FROM `' . _DB_PREFIX_ . 'group`');
        }
        fclose($fd);
    }
}
    public function displayFormModules($lang)
    {
        global $currentIndex, $_MODULES;
        $array_lang_src = Language::getLanguages(false);
        $str_output = '';
        foreach ($array_lang_src as $language) {
            $this->all_iso_lang[] = $language['iso_code'];
        }
        if (!file_exists(_PS_MODULE_DIR_)) {
            die($this->displayWarning(Tools::displayError('Fatal error: Module directory is not here anymore ') . '(' . _PS_MODULE_DIR_ . ')'));
        }
        if (!is_writable(_PS_MODULE_DIR_)) {
            $this->displayWarning(Tools::displayError('The module directory must be writable'));
        }
        if (!($modules = scandir(_PS_MODULE_DIR_))) {
            $this->displayWarning(Tools::displayError('There are no modules in your copy of PrestaShop. Use the Modules tab to activate them or go to our Website to download additional Modules.'));
        } else {
            if (!_PS_MODE_DEV_) {
                // Get all module which are installed for to have a minimum of POST
                $modules = Module::getModulesInstalled();
                foreach ($modules as &$module) {
                    $module = $module['name'];
                }
            }
            $arr_find_and_fill = array();
            $arr_files = $this->getAllModuleFiles($modules, _PS_MODULE_DIR_, $lang, true);
            $arr_find_and_fill = array_merge($arr_find_and_fill, $arr_files);
            if (file_exists(_PS_THEME_DIR_ . '/modules/')) {
                $modules = scandir(_PS_THEME_DIR_ . '/modules/');
                $arr_files = $this->getAllModuleFiles($modules, _PS_THEME_DIR_ . 'modules/', $lang);
                $arr_find_and_fill = array_merge($arr_find_and_fill, $arr_files);
            }
            foreach ($arr_find_and_fill as $value) {
                $this->findAndFillTranslations($value['files'], $value['theme'], $value['module'], $value['dir'], $lang);
            }
            $str_output .= '
			<h2>' . $this->l('Language') . ' : ' . Tools::strtoupper($lang) . ' - ' . $this->l('Translations of installed modules') . '</h2>
			' . $this->l('Total expressions') . ' : <b>' . $this->total_expression . '</b>. ' . $this->l('Click the fieldset title to expand or close the fieldset.') . '.<br /><br />';
            $str_output .= $this->displayLimitPostWarning($this->total_expression);
            if (!$this->suhosin_limit_exceed) {
                $str_output .= '
				<form method="post" action="' . $currentIndex . '&submitTranslationsModules=1&token=' . $this->token . '" class="form">';
                $str_output .= $this->displayToggleButton();
                $str_output .= '<input type="hidden" name="lang" value="' . $lang . '" /><input type="submit" name="submitTranslationsModules" value="' . $this->l('Update translations') . '" class="button" /><br /><br />';
                if (count($this->modules_translations) > 1) {
                    $str_output .= '<h3 style="padding:0;margin:0;">' . $this->l('List of Themes - Click to access theme translation:') . '</h3>';
                    $str_output .= '<ul style="list-style-type:none;padding:0;margin:0 0 10px 0;">';
                    foreach (array_keys($this->modules_translations) as $theme) {
                        $str_output .= '<li><a href="#' . $theme . '" class="link">- ' . ($theme === 'default' ? $this->l('default') : $theme) . '</a></li>';
                    }
                    $str_output .= '</ul>';
                }
                foreach ($this->modules_translations as $theme_name => $theme) {
                    $str_output .= '<h2>&gt;' . $this->l('Theme:') . ' <a name="' . $theme_name . '">' . ($theme_name === self::DEFAULT_THEME_NAME ? $this->l('default') : $theme_name) . '</h2>';
                    foreach ($theme as $module_name => $module) {
                        $str_output .= '' . $this->l('Module:') . ' <a name="' . $module_name . '" style="font-style:italic">' . $module_name . '</a>';
                        foreach ($module as $template_name => $newLang) {
                            if (sizeof($newLang)) {
                                $countValues = array_count_values($newLang);
                                $empty = isset($countValues['']) ? $countValues[''] : 0;
                                $str_output .= '
								<fieldset style="margin-top:5px"><legend style="cursor : pointer" onclick="$(\'#' . $theme_name . '_' . $module_name . '_' . $template_name . '\').slideToggle();">' . ($theme_name === 'default' ? $this->l('default') : $theme_name) . ' - ' . $template_name . ' - <font color="blue">' . sizeof($newLang) . '</font> ' . $this->l('expressions') . ' (<font color="red">' . $empty . '</font>)</legend>
									<div name="modules_div" id="' . $theme_name . '_' . $module_name . '_' . $template_name . '" style="display: ' . ($empty ? 'block' : 'none') . ';">
										<table cellpadding="2">';
                                foreach ($newLang as $key => $value) {
                                    $str_output .= '<tr><td style="width: 40%">' . stripslashes($key) . '</td><td>= ';
                                    if (strlen($key) < TEXTAREA_SIZED) {
                                        $str_output .= '<input type="text" style="width: 450px" name="' . md5(strtolower($module_name) . '_' . strtolower($theme_name) . '_' . strtolower($template_name) . '_' . md5($key)) . '" value="' . stripslashes(preg_replace('/"/', '\\&quot;', stripslashes($value))) . '" /></td></tr>';
                                    } else {
                                        $str_output .= '<textarea rows="' . (int) (strlen($key) / TEXTAREA_SIZED) . '" style="width: 450px" name="' . md5(strtolower($module_name) . '_' . strtolower($theme_name) . '_' . strtolower($template_name) . '_' . md5($key)) . '">' . stripslashes(preg_replace('/"/', '\\&quot;', stripslashes($value))) . '</textarea></td></tr>';
                                    }
                                }
                                $str_output .= '
										</table>
									</div>
								</fieldset><br />';
                            }
                        }
                    }
                }
                $str_output .= '<br /><input type="submit" name="submitTranslationsModules" value="' . $this->l('Update translations') . '" class="button" /></form>';
            }
        }
        echo $str_output;
    }
Пример #6
0
    private function _displayFormEditCertificate($certificate)
    {
        $installed_modules = Module::getModulesInstalled();
        $payment_module_collection = '';
        foreach ($installed_modules as $k => $value) {
            if ($return = TSBuyerProtection::_isPaymentModule($value['name'])) {
                $payment_module_collection[$value['id_module']] = $value;
            }
        }
        $out = '
		<script type="text/javascript" src="' . $this->site_url . 'modules/trustedshops/lib/js/payment.js" ></script>
		<script type="text/javascript">
			$().ready(function()
			{
				TSPayment.payment_type = $.parseJSON(\'' . Tools::jsonEncode(TSBuyerProtection::$payments_type) . '\');
				TSPayment.payment_module = $.parseJSON(\'' . Tools::jsonEncode($payment_module_collection) . '\');
				$(\'.payment-module-label\').css(TSPayment.module_box.css).fadeIn();
				$(\'.choosen_payment_type\').each(function()
				{
					TSPayment.deleteModuleFromList($(this).val());
					TSPayment.setLabelModuleName($(this).val());
				});
				TSPayment.init();
			});

		</script>
		<form action="' . $this->_makeFormAction(strip_tags($_SERVER['REQUEST_URI']), $this->id_tab) . '" method="post" >
			<fieldset>
				<legend><img src="../img/admin/tab-tools.gif" alt="" />' . $this->l('Edit certificate') . '</legend>
				<input type="hidden" name="iso_lang" value="' . $certificate['language'] . '" />
				<label>' . $this->l('Language') . '</label>
				<div class="margin-form">' . $certificate['language'] . '</div>
				<label>' . $this->l('Shop url') . '</label>
				<div class="margin-form">' . $certificate['url'] . '</div>
				<label>' . $this->l('Certificate id') . '</label>
				<div class="margin-form">' . $certificate['tsID'] . '</div>
				<label>' . $this->l('User Name') . ' <sup>*</sup></label>
				<div class="margin-form"><input type="text" name="user" value="' . $certificate['user'] . '" style="width:300px;"/></div>
				<label>' . $this->l('Password') . ' <sup>*</sup></label>
				<div class="margin-form"><input type="text" name="password" value="' . $certificate['password'] . '" style="width:300px;"/></div>
				<div id="payment-type">
					<label>' . $this->l('Payment type to edit') . ' <sup>*</sup></label>
					<div class="margin-form">
						<select name="payment_type">';
        foreach (TSBuyerProtection::$payments_type as $type => $translation) {
            $out .= '	<option value="' . $type . '" >' . $translation . '</option>';
        }
        $out .= '		</select>&nbsp;' . $this->l('with') . '&nbsp;
						<select name="payment_module">';
        foreach ($payment_module_collection as $module_info) {
            $out .= '		<option value="' . $module_info['id_module'] . '" >' . $module_info['name'] . '</option>';
        }
        $out .= '		</select>&nbsp;' . $this->l('payment module') . '&nbsp;<input type="button" value="' . $this->l('Add it') . '" class="button" name="add_payment_module" />
					</div><!-- .margin-form -->
					<div id="payment_type_list">';
        $input_output = '';
        if (isset($certificate['payment_type']) and !empty($certificate['payment_type'])) {
            foreach ($certificate['payment_type'] as $payment_type => $modules) {
                $out .= '	<label style="clear:both;" class="payment-type-label" >' . TSBuyerProtection::$payments_type[$payment_type] . '</label>';
                $out .= '	<div class="margin-form" id="block-payment-' . $payment_type . '">';
                foreach ($modules as $module_id) {
                    $out .= '<b class="payment-module-label" id="label-module-' . $module_id . '"></b>';
                    $input_output .= '<input type="hidden" value="' . $module_id . '" class="choosen_payment_type" name="choosen_payment_type[' . $payment_type . '][]">';
                }
                $out .= '	</div><!-- .margin-form -->';
            }
        }
        $out .= '</div><!-- #payment_type_list -->
			</div><!-- #payment-type -->
			<p id="input-hidden-val" style="display:none;">' . $input_output . '</p>
			<p style="text-align:center;">
				<input type="submit" name="submit_change_certificate" class="button" value="' . $this->l('Update it') . '"/>
			</p>
			</fieldset>
		</form>';
        return $out;
    }
 /**
  * Check if directory and file exist and return an list of modules
  *
  * @return array : list of modules
  */
 public function getListModules()
 {
     if (!Tools::file_exists_cache($this->translations_informations['modules']['dir'])) {
         throw new PrestaShopException(Tools::displayError('Fatal error: Module directory does not exist') . '(' . $this->translations_informations['modules']['dir'] . ')');
     }
     if (!is_writable($this->translations_informations['modules']['dir'])) {
         throw new PrestaShopException(Tools::displayError('The module directory must be writable'));
     }
     $modules = array();
     if (!_PS_MODE_DEV_ && $this->theme_selected == self::DEFAULT_THEME_NAME) {
         // Get all module which are installed for to have a minimum of POST
         $modules = Module::getModulesInstalled();
         foreach ($modules as &$module) {
             $module = $module['name'];
         }
     } else {
         if ($this->theme_selected == self::DEFAULT_THEME_NAME) {
             if (Tools::file_exists_cache($this->translations_informations['modules']['dir'])) {
                 $modules = scandir($this->translations_informations['modules']['dir']);
             } else {
                 $this->displayWarning(Tools::displayError('There are no modules in your copy of PrestaShop. Use the Modules page to activate them or go to our Website to download additional Modules.'));
             }
         } else {
             if (Tools::file_exists_cache($this->translations_informations['modules']['override']['dir'])) {
                 $modules = scandir($this->translations_informations['modules']['override']['dir']);
             } else {
                 $this->displayWarning(Tools::displayError('There are no modules in your copy of PrestaShop. Use the Modules page to activate them or go to our Website to download additional Modules.'));
             }
         }
     }
     return $modules;
 }
 /**
  * Check if directory and file exist and return an list of modules
  *
  * @return array : list of modules
  */
 public function getListModules()
 {
     if (!Tools::file_exists_cache($this->translations_informations['modules']['dir'])) {
         throw new PrestaShopException(Tools::displayError('Fatal error: The module directory does not exist.') . '(' . $this->translations_informations['modules']['dir'] . ')');
     }
     if (!is_writable($this->translations_informations['modules']['dir'])) {
         throw new PrestaShopException(Tools::displayError('The module directory must be writable.'));
     }
     $modules = array();
     // Get all module which are installed for to have a minimum of POST
     $modules = Module::getModulesInstalled();
     foreach ($modules as &$module) {
         $module = $module['name'];
     }
     return $modules;
 }
    /**
     * render list of modules following positions in the layout editor.
     */
    public function renderList()
    {
        $filePath = _PS_ALL_THEMES_DIR_ . $this->theme_name . '';
        $showed = true;
        $xml = simplexml_load_file($filePath . '/config.xml');
        if (isset($xml->theme_key)) {
            $this->themeKey = trim((string) $xml->theme_key);
        }
        if ($this->themeKey) {
            $this->initToolbarTitle();
            $this->initToolbar();
            $hookspos = $this->hookspos;
            foreach ($hookspos as $hook) {
                if (Hook::getIdByName($hook)) {
                } else {
                    $new_hook = new Hook();
                    $new_hook->name = pSQL($hook);
                    $new_hook->title = pSQL($hook);
                    $new_hook->add();
                    $id_hook = $new_hook->id;
                }
            }
            Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
				UPDATE `' . _DB_PREFIX_ . 'hook` SET position=1, live_edit=1
						WHERE name in ("' . implode('","', $hookspos) . '")  ');
            $modules = Module::getModulesInstalled(0);
            $assoc_modules_id = array();
            $assoc_modules_id = $module_instances = array();
            foreach ($modules as $module) {
                if ($tmp_instance = Module::getInstanceById((int) $module['id_module'])) {
                    // We want to be able to sort modules by display name
                    $module_instances[$tmp_instance->displayName] = $tmp_instance;
                    // But we also want to associate hooks to modules using the modules IDs
                    $assoc_modules_id[(int) $module['id_module']] = $tmp_instance->displayName;
                }
            }
            $hooks = Hook::getHooks(!(int) Tools::getValue('hook_position'));
            $hookModules = array();
            $hookedModules = array();
            foreach ($hooks as $key => $hook) {
                // $key = $hook['name'];
                $k = $hook['name'];
                $k = Tools::strtolower(Tools::substr($k, 0, 1)) . Tools::substr($k, 1);
                if (in_array($k, $hookspos)) {
                    // Get all modules for this hook or only the filtered module
                    $hookModules[$k]['modules'] = Hook::getModulesFromHook($hook['id_hook'], $this->display_key);
                    $hookModules[$k]['module_count'] = count($hookModules[$k]['modules']);
                    if (is_array($hookModules[$k]['modules']) && !empty($hookModules[$k]['modules'])) {
                        foreach ($hookModules[$k]['modules'] as $module_key => $module) {
                            if (isset($assoc_modules_id[$module['id_module']])) {
                                $hookedModules[] = $module['id_module'];
                                $hookModules[$k]['modules'][$module_key]['instance'] = $module_instances[$assoc_modules_id[$module['id_module']]];
                            }
                        }
                    }
                }
            }
            //		  	echo '<pre>'.print_r($hookedModules,1); die;
            $instances = array();
            foreach ($modules as $module) {
                if ($tmp_instance = Module::getInstanceById($module['id_module'])) {
                    if (!in_array($module['id_module'], $hookedModules)) {
                        foreach ($hookspos as $hk) {
                            $retro_hook_name = Hook::getRetroHookName($hk);
                            $hook_callable = is_callable(array($tmp_instance, 'hook' . $hk));
                            $hook_retro_callable = is_callable(array($tmp_instance, 'hook' . $retro_hook_name));
                            if ($hook_retro_callable || $hook_callable) {
                                $instances[$tmp_instance->displayName] = $tmp_instance;
                                break;
                            }
                        }
                        //	echo '<pre>'.print_r( $instances, 1 ); die;
                    }
                }
            }
            ksort($instances);
            $modules = $instances;
            $tpl = $this->createTemplate('panel.tpl');
            $this->context->controller->addCss(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/style.css', 'all');
            $this->context->controller->addJs(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/jquery-ui-1.10.3.custom.min.js', 'all');
            $tpl->assign(array('showed' => $showed, 'toolbar' => $this->context->smarty->fetch('toolbar.tpl'), 'modules' => $modules, 'hookspos' => $hookspos, 'URI' => __PS_BASE_URI__ . 'modules/', 'hookModules' => $hookModules, 'noModuleConfig' => $this->l('No Configuration For This Module'), 'currentURL' => 'index.php?tab=AdminLeotempcpPanel&token=' . Tools::getAdminTokenLite('AdminLeotempcpPanel') . '', 'moduleEditURL' => 'index.php?controller=adminmodules&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=Home'));
            return $tpl->fetch();
        } else {
            $tpl = $this->createTemplate('error.tpl');
            $tpl->assign(array('showed' => false, 'themeURL' => 'index.php?controller=AdminThemes&token=' . Tools::getAdminTokenLite('AdminThemes')));
            return $tpl->fetch();
        }
    }
Пример #10
0
*
* @author Shopgate GmbH, Schloßstraße 10, 35510 Butzbach <*****@*****.**>
* @copyright  Shopgate GmbH
* @license   http://opensource.org/licenses/AFL-3.0 Academic Free License ("AFL"), in the version 3.0
*/
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/shopgate.php';
require_once dirname(__FILE__) . '/override/classes/Cart.php';
if (version_compare(_PS_VERSION_, '1.4.0.2', '>=')) {
    $controller = new FrontController();
    $controller->init();
    $modules = ModuleCore::getModulesInstalled();
} else {
    // in versions before 1.4.0.2 FrontController doesn't exist
    require_once dirname(__FILE__) . '/../../init.php';
    $modules = Module::getModulesInstalled();
}
$moduleIsActive = 0;
foreach ($modules as $key => $module) {
    if ($module['name'] == 'shopgate' && !empty($module['active'])) {
        $moduleIsActive = 1;
    }
}
if ($moduleIsActive == 0) {
    throw new ShopgateLibraryException(ShopgateLibraryException::UNKNOWN_ERROR_CODE, 'shopgate module is not installed!');
    exit;
}
// needed for compatiblitiy
function getOrderStateId($order_state_var)
{
    return (int) (defined($order_state_var) ? constant($order_state_var) : (defined('_' . $order_state_var . '_') ? constant('_' . $order_state_var . '_') : Configuration::get($order_state_var)));
Пример #11
0
 public function emailSupportRequest()
 {
     $debug_info = "theme: " . _PS_THEME_DIR_ . "\n";
     $debug_info .= "\n************* Permissions\n\n";
     if (!$this->isPatched("override/controllers/front/ParentOrderController.php", "/VK##2/")) {
         $debug_info .= "(!) ParentOrderController.php is not overridden! \n";
     }
     if (!$this->isPatched("override/controllers/front/AddressController.php", "/VK##2/")) {
         $debug_info .= "(!) AddressController.php is not overridden! \n";
     }
     if (!$this->isPatched("override/classes/Address.php", "/VK##2/")) {
         $debug_info .= "(!) Address.php is not overridden! \n";
     }
     if (!$this->isPatched("override/classes/Cart.php", "/VK##2/")) {
         $debug_info .= "(!) Cart.php is not overridden! \n";
     }
     if (!$this->isPatched("override/classes/Customer.php", "/VK##2/")) {
         $debug_info .= "(!) Customer.php is not overridden! \n";
     }
     $check_permissions = array(_PS_MODULE_DIR_ . "onepagecheckout", _PS_MODULE_DIR_ . "onepagecheckout/translations", _PS_ROOT_DIR_ . "/override/classes", _PS_ROOT_DIR_ . "/override/controllers/front");
     $debug_info .= "Script user: "******" (uid=" . getmyuid() . ", gid=" . getmygid() . ")\n\n";
     $root_length = Tools::strlen(_PS_ROOT_DIR_);
     foreach ($check_permissions as $filename) {
         $owner = function_exists('posix_getpwuid') ? @posix_getpwuid(fileowner($filename)) : fileowner($filename);
         $debug_info .= Tools::substr($filename, $root_length) . ": " . Tools::substr(sprintf('%o', fileperms($filename)), -4) . ", " . $owner['name'] . " (uid=" . $owner['uid'] . ", gid=" . $owner['gid'] . ")\n";
     }
     $debug_info .= "\n************* Module:version\n\n";
     foreach (Module::getModulesInstalled() as $module) {
         $debug_info .= $module["name"] . ":" . $module["version"] . ($module["active"] ? "" : " (inactive)") . "\n";
     }
     $debug_info .= "\n";
     foreach (Module::getPaymentModules() as $module) {
         $debug_info .= "payment: " . $module["name"] . "\n";
     }
     $debug_info .= "\n************* OPC configuration\n\n";
     foreach ($this->_getAllOptionsValues() as $key => $value) {
         $debug_info .= "{$key}: {$value}\n";
     }
     $file_attachment['content'] = $debug_info;
     $file_attachment['name'] = "debug_info.txt";
     $file_attachment['mime'] = 'text/html';
     $data = array("{message}" => nl2br(Tools::getValue('emailMessage')), "{ps_version}" => _PS_VERSION_, "{opc_version}" => $this->version);
     Mail::Send(1, 'support_request', 'OPC support', $data, '*****@*****.**', null, Tools::getValue('emailFrom'), null, $file_attachment, null, _PS_MODULE_DIR_ . 'onepagecheckout/mails/', false, $this->context->shop->id);
 }
Пример #12
0
 /**
  * Filters the given module list to remove installed ones, and bad filled cases.
  *
  * @param array $moduleFullList The input list to filter
  * @return array The filtered list of modules
  */
 public function filterInstalledAndBadModules(array $moduleFullList)
 {
     $installed_modules = [];
     array_map(function ($module) use(&$installed_modules) {
         $installed_modules[$module['name']] = $module;
     }, \Module::getModulesInstalled());
     foreach ($moduleFullList as $key => $module) {
         if ((bool) array_key_exists($module->attributes->get('name'), $installed_modules) === true) {
             unset($moduleFullList[$key]);
         }
         if (!isset($module->attributes->get('media')->img)) {
             unset($moduleFullList[$key]);
         }
     }
     return $moduleFullList;
 }
Пример #13
0
 public function createShopInfo()
 {
     $shopInfo = array('category_count' => count(Category::getSimpleCategories($this->getLanguageId())), 'item_count' => count(Product::getSimpleProducts($this->getLanguageId())));
     if ($this->config->getEnableGetReviewsCsv()) {
         /**
          * set review_count
          */
         $shopInfo['review_count'] = 0;
     }
     if ($this->config->getEnableGetMediaCsv()) {
         /**
          * media_count
          */
         $shopInfo['media_count'] = array();
     }
     $shopInfo['plugins_installed'] = array();
     foreach (Module::getModulesInstalled() as $module) {
         $shopInfo['plugins_installed'][] = array('id' => $module['id_module'], 'name' => $module['name'], 'version' => $module['version'], 'active' => $module['active'] ? 1 : 0);
     }
     return $shopInfo;
 }
Пример #14
0
 private function displayFormEditCertificate($lang)
 {
     $certificate = TSCommon::$certificates[$lang];
     $payment_module_collection = array();
     $installed_modules = Module::getModulesInstalled();
     foreach ($installed_modules as $value) {
         if (TSCommon::isPaymentModule($value['name'])) {
             $payment_module_collection[$value['id_module']] = $value;
         }
     }
     TSCommon::$smarty->assign(array('site_uri' => $this->site_url, 'form_action' => $this->makeFormAction(strip_tags($_SERVER['REQUEST_URI']), $this->id_tab), 'lang' => $lang, 'certificate' => $certificate, 'payment_types' => TSCommon::$payments_type, 'payment_collection' => $payment_module_collection, 'payment_types_json' => Tools::jsonEncode(TSCommon::$payments_type), 'payment_collection_json' => Tools::jsonEncode($payment_module_collection)));
     return TSCommon::$smarty->fetch(dirname(__FILE__) . '/../views/templates/admin/' . self::getTemplateByVersion('edit_certificate'));
 }
    public function renderForm()
    {
        // Init toolbar
        $this->initToolbarTitle();
        // toolbar (save, cancel, new, ..)
        $this->initToolbar();
        $id_module = (int) Tools::getValue('id_module');
        $id_hook = (int) Tools::getValue('id_hook');
        if (Tools::isSubmit('editGraft')) {
            // Check auth for this page
            if (!$id_module || !$id_hook) {
                Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token);
            }
            $sql = 'SELECT id_module
					FROM ' . _DB_PREFIX_ . 'hook_module
					WHERE id_module = ' . $id_module . '
						AND id_hook = ' . $id_hook . '
						AND id_shop IN(' . implode(', ', Shop::getContextListShopID()) . ')';
            if (!Db::getInstance()->getValue($sql)) {
                Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token);
            }
            $sl_module = Module::getInstanceById($id_module);
            $excepts_list = $sl_module->getExceptions($id_hook, true);
            $excepts_diff = false;
            $excepts = '';
            if ($excepts_list) {
                $first = current($excepts_list);
                foreach ($excepts_list as $k => $v) {
                    if (array_diff($v, $first) || array_diff($first, $v)) {
                        $excepts_diff = true;
                    }
                }
                if (!$excepts_diff) {
                    $excepts = implode(', ', $first);
                }
            }
        } else {
            $excepts_diff = false;
            $excepts_list = Tools::getValue('exceptions', array(array()));
        }
        $modules = Module::getModulesInstalled(0);
        $instances = array();
        foreach ($modules as $module) {
            if ($tmp_instance = Module::getInstanceById($module['id_module'])) {
                $instances[$tmp_instance->displayName] = $tmp_instance;
            }
        }
        ksort($instances);
        $modules = $instances;
        $hooks = Hook::getHooks(0);
        $exception_list_diff = array();
        foreach ($excepts_list as $shop_id => $file_list) {
            $exception_list_diff[] = $this->displayModuleExceptionList($file_list, $shop_id);
        }
        $tpl = $this->createTemplate('form.tpl');
        $tpl->assign(array('url_submit' => self::$currentIndex . '&token=' . $this->token, 'edit_graft' => Tools::isSubmit('editGraft'), 'id_module' => (int) Tools::getValue('id_module'), 'id_hook' => (int) Tools::getValue('id_hook'), 'show_modules' => Tools::getValue('show_modules'), 'hooks' => $hooks, 'exception_list' => $this->displayModuleExceptionList(array_shift($excepts_list), 0), 'exception_list_diff' => $exception_list_diff, 'except_diff' => isset($excepts_diff) ? $excepts_diff : null, 'display_key' => $this->display_key, 'modules' => $modules, 'show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => $this->toolbar_scroll, 'title' => $this->toolbar_title, 'table' => 'hook_module'));
        return $tpl->fetch();
    }
 public function formatModuleListAuth($id_group)
 {
     $modules = Module::getModulesInstalled();
     $authorized_modules = '';
     $auth_modules = array();
     $unauth_modules = array();
     if ($id_group) {
         $authorized_modules = Module::getAuthorizedModules($id_group);
     }
     if (is_array($authorized_modules)) {
         foreach ($modules as $module) {
             $authorized = false;
             foreach ($authorized_modules as $auth_module) {
                 if ($module['id_module'] == $auth_module['id_module']) {
                     $authorized = true;
                 }
             }
             if ($authorized) {
                 $auth_modules[] = $module;
             } else {
                 $unauth_modules[] = $module;
             }
         }
     } else {
         $auth_modules = $modules;
     }
     $auth_modules_tmp = array();
     foreach ($auth_modules as $key => $val) {
         if ($module = Module::getInstanceById($val['id_module'])) {
             $auth_modules_tmp[] = $module;
         }
     }
     $auth_modules = $auth_modules_tmp;
     $unauth_modules_tmp = array();
     foreach ($unauth_modules as $key => $val) {
         if ($tmp_obj = Module::getInstanceById($val['id_module'])) {
             $unauth_modules_tmp[] = $tmp_obj;
         }
     }
     $unauth_modules = $unauth_modules_tmp;
     return array('unauth_modules' => $unauth_modules, 'auth_modules' => $auth_modules);
 }
Пример #17
0
    public function displayForm()
    {
        global $currentIndex;
        $id_module = intval(Tools::getValue('id_module'));
        $id_hook = intval(Tools::getValue('id_hook'));
        if ($id_module and $id_hook and Tools::isSubmit('editGraft')) {
            $slModule = Module::getInstanceById($id_module);
            $exceptsList = $slModule->getExceptions($id_hook);
            $excepts = '';
            foreach ($exceptsList as $key => $except) {
                $excepts .= ($key ? ',' : '') . $except['file_name'];
            }
        }
        $excepts = strval(Tools::getValue('exceptions', (isset($slModule) and Validate::isLoadedObject($slModule)) ? $excepts : ''));
        $modules = Module::getModulesInstalled(0);
        $instances = array();
        foreach ($modules as $module) {
            if ($tmpInstance = Module::getInstanceById($module['id_module'])) {
                $instances[$tmpInstance->displayName] = $tmpInstance;
            }
        }
        ksort($instances);
        $modules = $instances;
        $hooks = Hook::getHooks(0);
        echo '
		<form action="' . $currentIndex . '&token=' . $this->token . '" method="post">';
        if ($this->displayKey) {
            echo '<input type="hidden" name="show_modules" value="' . $this->displayKey . '" />';
        }
        echo '<fieldset class="width3" style="width:700px;"><legend><img src="../img/t/AdminModulesPositions.gif" />' . $this->l('Transplant a module') . '</legend>
				<label>' . $this->l('Module') . ' :</label>
				<div class="margin-form">
					<select name="id_module"' . (Tools::isSubmit('editGraft') ? ' disabled="disabled"' : '') . '>';
        foreach ($modules as $module) {
            echo '
						<option value="' . $module->id . '" ' . ($id_module == $module->id ? 'selected="selected" ' : '') . '>' . stripslashes($module->displayName) . '</option>';
        }
        echo '
					</select><sup> *</sup>
				</div>
				<label>' . $this->l('Hook into') . ' :</label>
				<div class="margin-form">
					<select name="id_hook"' . (Tools::isSubmit('editGraft') ? ' disabled="disabled"' : '') . '>';
        foreach ($hooks as $hook) {
            echo '
						<option value="' . $hook['id_hook'] . '" ' . ($id_hook == $hook['id_hook'] ? 'selected="selected" ' : '') . '>' . $hook['title'] . '</option>';
        }
        echo '
					</select><sup> *</sup>
				</div>
				<label>' . $this->l('Exceptions') . ' :</label>
				<div class="margin-form">
					<input type="text" name="exceptions" size="40" ' . (!empty($excepts) ? 'value="' . $excepts . '"' : '') . '><br />Ex: identity.php, history.php, order.php, product.php<br /><br />
					' . $this->l('Please specify those files in which you do not want the module to be displayed') . '.<br />
					' . $this->l('These files are located in your base directory') . ', ' . $this->l('e.g., ') . ' <b>identity.php</b>.<br />
					' . $this->l('Please type each filename separated by a comma') . '.
					<br /><br />
				</div>
				<div class="margin-form">
				';
        if (Tools::isSubmit('editGraft')) {
            echo '
					<input type="hidden" name="id_module" value="' . $id_module . '" />
					<input type="hidden" name="id_hook" value="' . $id_hook . '" />';
        }
        echo '
					<input type="submit" value="' . $this->l('Save') . '" name="' . (Tools::isSubmit('editGraft') ? 'submitEditGraft' : 'submitAddToHook') . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }