Add PrivateShop module templates and initial setup files
- Created restricted.tpl for displaying restricted access messages with customizable background options. - Added index.php files in hook and main template directories to prevent direct access and ensure proper redirection. - Implemented info.tpl to provide module information and support links, enhancing user experience with promotional content. - Included necessary CSS styles for the new templates to ensure proper layout and responsiveness.
This commit is contained in:
133
modules/privateshoplite/classes/PrivateAcces.php
Normal file
133
modules/privateshoplite/classes/PrivateAcces.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* DISCLAIMER.
|
||||
*
|
||||
* Do not edit or add to this file.
|
||||
* You are not authorized to modify, copy or redistribute this file.
|
||||
* Permissions are reserved by FME Modules.
|
||||
*
|
||||
* @author FMM Modules
|
||||
* @copyright FME Modules 2021
|
||||
* @license Single domain
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
class PrivateAcces extends ObjectModel
|
||||
{
|
||||
public static function isActiveManufacturer($id_manufacturer)
|
||||
{
|
||||
$isActive = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT m.active FROM ' . _DB_PREFIX_ . 'manufacturer as m WHERE m.id_manufacturer = ' . $id_manufacturer);
|
||||
if (!empty($isActive) && isset($isActive[0]['active'])) {
|
||||
// Check if the 'active' field is equal to 1
|
||||
return $isActive[0]['active'] == 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getAssociatedSuppliers($id_product)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT ps.id_supplier FROM ' . _DB_PREFIX_ . 'product_supplier as ps WHERE ps.id_product = ' . $id_product);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all id_shop of private shops.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAssocShops()
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'privateshoplite_shop');
|
||||
$final = [];
|
||||
if (isset($result)) {
|
||||
foreach ($result as $res) {
|
||||
$final[] = $res['id_shop'];
|
||||
}
|
||||
}
|
||||
|
||||
return $final;
|
||||
}
|
||||
|
||||
/**
|
||||
* get customer email by id and token.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getCustomerEmail($id_customer, $token)
|
||||
{
|
||||
if (!$id_customer || empty($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Db::getInstance()->getValue('SELECT `email`
|
||||
FROM ' . _DB_PREFIX_ . 'customer c
|
||||
WHERE c.`secure_key` = \'' . pSQL($token) . '\'
|
||||
AND c.id_customer = ' . (int) $id_customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all shop customers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllCustomers()
|
||||
{
|
||||
$like = '';
|
||||
$context = Context::getContext();
|
||||
$search_n = ((int) Configuration::get('PRIVATESHOPLITE_FILTER_n', false, $context->shop->id_shop_group, $context->shop->id) <= 0) ? 10 : (int) Configuration::get('PRIVATESHOPLITE_FILTER_n', false, $context->shop->id_shop_group, $context->shop->id);
|
||||
$search_pos = (int) Configuration::get('PRIVATESHOPLITE_FILTER_pos', false, $context->shop->id_shop_group, $context->shop->id);
|
||||
$search_pos = ($search_pos <= 0) ? ' ORDER BY c.id_customer ASC ' : 'ORDER BY c.id_customer DESC ';
|
||||
$search_state = (int) Configuration::get('PRIVATESHOPLITE_FILTER_state', false, $context->shop->id_shop_group, $context->shop->id);
|
||||
$name = Configuration::get('PRIVATESHOPLITE_FILTER_name', false, $context->shop->id_shop_group, $context->shop->id);
|
||||
|
||||
$whereClause = ' WHERE c.id_shop = ' . $context->shop->id . ' ';
|
||||
|
||||
if (empty($name)) {
|
||||
$like = '';
|
||||
} elseif ($name && ($search_state == 1 || $search_state == 2)) {
|
||||
$like = 'AND (c.firstname LIKE "%' . pSQL($name) . '%" OR c.lastname LIKE "%' . pSQL($name) . '%") ';
|
||||
} elseif ($name && $search_state <= 0) {
|
||||
$like = 'AND (c.firstname LIKE "%' . pSQL($name) . '%" OR c.lastname LIKE "%' . pSQL($name) . '%") ';
|
||||
}
|
||||
|
||||
if ($search_state <= 0) {
|
||||
$search_state = '';
|
||||
} elseif ($search_state == 1) {
|
||||
$search_state = 'AND c.active = 1 ';
|
||||
} elseif ($search_state == 2) {
|
||||
$search_state = 'AND c.active = 0 ';
|
||||
}
|
||||
$sql = 'SELECT c.*, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, gl.`name` AS `title`,
|
||||
(SELECT co.`date_add` FROM ' . _DB_PREFIX_ . 'guest g
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'connections co ON co.id_guest = g.id_guest
|
||||
WHERE g.id_customer = c.id_customer
|
||||
ORDER BY co.date_add DESC
|
||||
LIMIT 1
|
||||
) as connect
|
||||
FROM ' . _DB_PREFIX_ . 'customer c
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'gender_lang gl ON (c.id_gender = gl.id_gender AND gl.id_lang = ' . (int) Context::getContext()->language->id . ')
|
||||
' . $whereClause . $search_state . $like . $search_pos . 'LIMIT ' . (int) $search_n;
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all metas.
|
||||
*
|
||||
* @param int $idLang
|
||||
*
|
||||
* @return array|false|mysqli_result|PDOStatement|resource|null
|
||||
*/
|
||||
public static function getAllMeta($idLang)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT *
|
||||
FROM ' . _DB_PREFIX_ . 'meta m
|
||||
LEFT JOIN ' . _DB_PREFIX_ . 'meta_lang ml ON m.id_meta = ml.id_meta
|
||||
AND ml.id_lang = ' . (int) $idLang . '
|
||||
' . Shop::addSqlRestrictionOnLang('ml'));
|
||||
}
|
||||
}
|
||||
32
modules/privateshoplite/classes/index.php
Normal file
32
modules/privateshoplite/classes/index.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 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/afl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
header('Location: ../');
|
||||
exit;
|
||||
Reference in New Issue
Block a user