Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Fixed site_id and id duplicate

givanzb45c9f487862
diff --git a/admin/controller/user/reset.php b/admin/controller/user/reset.php
index 4a0b073..34f1823 100755
--- a/admin/controller/user/reset.php
+++ b/admin/controller/user/reset.php
@@ -95,7 +95,7 @@ class Reset {
$os = 'UnKnown';
}
- $site = Sites :: getSiteData();
+ $site = Sites :: getSiteData($this->global['site_id']);
$reset_url = url(['module' => 'user/reset', 'action' => 'reset', 'token' => $token, 'user' => $adminData['username'], 'host' => $site['host'] ?? false]);
diff --git a/admin/template/components/sites.tpl b/admin/template/components/sites.tpl
index 2faba5b..036493e 100755
--- a/admin/template/components/sites.tpl
+++ b/admin/template/components/sites.tpl
@@ -17,13 +17,13 @@ if(isset($this->_component['sites']) && $this->_component['sites'][$_sites_idx])
$state = $site['state'] ?? 'live';
?>
- @site .dropdown-item|addClass = <?php if (isset($site['id']) && ($site['id'] == $sites['site_id'])) echo 'active'?>
+ @site .dropdown-item|addClass = <?php if (isset($site['site_id']) && ($site['site_id'] == $sites['site_id'])) echo 'active'?>
@site [data-v-site-name] = $site['name']
@site [data-v-site-icon]|addClass = <?php echo $sites['states'][$state]['icon'];?>
@site a[data-v-site-url]|href = <?php echo '//' . $site['url'];?>
- @site button[data-v-site-site_id]|value = $site['id']
+ @site button[data-v-site-site_id]|value = $site['site_id']
@site|after = <?php
}
diff --git a/admin/template/settings/site.tpl b/admin/template/settings/site.tpl
old mode 100755
new mode 100644
index 1861f1f..bb1d325
--- a/admin/template/settings/site.tpl
+++ b/admin/template/settings/site.tpl
@@ -197,13 +197,12 @@ select[data-v-setting]|before =
} ?>
*/
-input[type="checkbox"][data-v-*]|addNewAttribute = <?php
+input[type="checkbox"][data-v-setting]|addNewAttribute = <?php
if (isset($this->setting[$_setting])) echo 'checked';
?>
-
/* language tabs */
[data-v-languages]|before = <?php $_lang_instance = '@@__data-v-languages__@@';$_i = 0;?>
@@ -243,4 +242,47 @@ $_i++;
$desc = '@@__data-v-site-description-(*)__@@';
if (isset($this->site['description'][$language['language_id']][$desc]))
echo htmlspecialchars($this->site['description'][$language['language_id']][$desc]);
-?>
\ No newline at end of file
+?>
+
+
+/* Languages */
+
+#all-languages-check|addNewAttribute = <?php if (!isset($this->site['languages']) || empty($this->site['languages'])) echo 'checked';?>
+
+[data-v-language-list] [data-v-language]|deleteAllButFirstChild
+
+[data-v-language-list] [data-v-language]|before = <?php
+$this->site['languages'] = (array)($this->site['languages'] ?? []);
+foreach ($this->languagesList as $lang) { ?>
+
+ [data-v-language-list] [data-v-language] [data-v-*]|innerText = $lang['@@__data-v-(*)__@@']
+ [data-v-language-list] [data-v-language] input[type="checkbox"]|addNewAttribute = <?php if (isset($this->site['languages']) && in_array($lang['language_id'], $this->site['languages'])) echo 'checked';?>
+
+ [data-v-language-list] [data-v-language] input[type="checkbox"]|name = <?php echo 'settings[languages]['. $lang['slug'] . ']';?>
+ [data-v-language-list] [data-v-language] input[type="checkbox"]|id = <?php echo 'lang-'. $lang['language_id'];?>
+ [data-v-language-list] [data-v-language] label|for = <?php echo 'lang-'. $lang['language_id'];?>
+
+
+ [data-v-language-list] [data-v-language]|after = <?php
+}?>
+
+/* Currencies */
+
+#all-currencies-check|addNewAttribute = <?php if (!isset($this->site['currencies']) || empty($this->site['currencies'])) echo 'checked';?>
+
+[data-v-currency-list] [data-v-currency]|deleteAllButFirstChild
+
+[data-v-currency-list] [data-v-currency]|before = <?php
+$this->site['currencies'] = (array)($this->site['currencies'] ?? []);
+foreach ($this->currenciesList as $code => $currency) { ?>
+
+ [data-v-currency-list] [data-v-currency] [data-v-*]|innerText = $currency['@@__data-v-(*)__@@']
+ [data-v-currency-list] [data-v-currency] input[type="checkbox"]|addNewAttribute = <?php if (isset($this->site['currencies']) && in_array($currency['currency_id'], $this->site['currencies'])) echo 'checked';?>
+
+ [data-v-currency-list] [data-v-currency] input[type="checkbox"]|name = <?php echo 'settings[currencies]['. $code . ']';?>
+ [data-v-currency-list] [data-v-currency] input[type="checkbox"]|id = <?php echo 'currency-'. $currency['currency_id'];?>
+ [data-v-currency-list] [data-v-currency] label|for = <?php echo 'currency-'. $currency['currency_id'];?>
+
+
+ [data-v-currency-list] [data-v-currency]|after = <?php
+}?>
diff --git a/app/component/order.php b/app/component/order.php
old mode 100755
new mode 100644
index a28e580..2f65382
--- a/app/component/order.php
+++ b/app/component/order.php
@@ -48,11 +48,11 @@ class Order extends ComponentBase {
$request = Request::getInstance();
- if ($this->options['order_id'] || $this->options['customer_order_id']) {
+ if (isset($this->options['order_id']) || isset($this->options['customer_order_id'])) {
$orders = new \Vvveb\Sql\OrderSQL();
$results = $orders->get($this->options);
- $site = Sites :: getSiteData();
+ $site = Sites :: getSiteData(SITE_ID);
$scheme = $_SERVER['REQUEST_SCHEME'] ?? 'http';
$url = ['host' => SITE_URL, 'scheme' => $scheme];
$host = $scheme . '://' . SITE_URL;
diff --git a/app/controller/cart/cart.php b/app/controller/cart/cart.php
index fc4279e..474108c 100755
--- a/app/controller/cart/cart.php
+++ b/app/controller/cart/cart.php
@@ -40,7 +40,7 @@ class Cart extends Base {
parent::init();
$options = array_intersect_key($this->global['site'],
- array_flip(['weight_type_id', 'length_type_id', 'currency_id', 'country_id']));
+ array_flip(['weight_type_id', 'length_type_id', 'currency_id', 'country_id']));
$cart_id = false;
@@ -59,8 +59,9 @@ class Cart extends Base {
$payment = Payment::getInstance();
$shipping = Shipping::getInstance();
- $this->view->payment = $payment->getMethods([]);
- $this->view->shipping = $shipping->getMethods([]);
+ $checkoutInfo = [];
+ $this->view->payment = $payment->getMethods($checkoutInfo);
+ $this->view->shipping = $shipping->getMethods($checkoutInfo);
$product_id = $this->request->post['product_id'] ?? $this->request->get['product_id'] ?? false;
$module = $this->request->get['module'] ?? $this->request->post['module'] ?? '';
@@ -103,17 +104,17 @@ class Cart extends Base {
case 'add':
$this->cart->add($productId, $quantity, $option, $productVariantId, $subscriptionPlanId);
- break;
+ break;
case 'update':
$this->cart->update($key, $quantity);
- break;
+ break;
case 'remove':
$this->cart->remove($key);
- break;
+ break;
}
//$this->view->success = $this->cart->$action($productId, $quantity);
}
diff --git a/app/controller/checkout/checkout.php b/app/controller/checkout/checkout.php
index 87829ae..4ad971f 100755
--- a/app/controller/checkout/checkout.php
+++ b/app/controller/checkout/checkout.php
@@ -65,7 +65,7 @@ class Checkout extends Base {
parent::init();
$options = array_intersect_key($this->global['site'],
- array_flip(['weight_type_id', 'length_type_id', 'currency_id', 'country_id']));
+ array_flip(['weight_type_id', 'length_type_id', 'currency_id', 'country_id']));
$cart_id = false;
@@ -123,8 +123,8 @@ class Checkout extends Base {
function index() {
//buy now product
- if (isset($this->request->get['product_id'])) {
- $productId = $this->request->get['product_id'];
+ if (isset($this->request->request['product_id'])) {
+ $productId = $this->request->request['product_id'];
$quantity = $this->request->post['quantity'] ?? 1;
$option = $this->request->post['option'] ?? [];
$subscriptionPlanId = $this->request->post['subscription_plan_id'] ?? false;
@@ -142,9 +142,10 @@ class Checkout extends Base {
$order = Order::getInstance();
- $checkoutInfo = $this->session->get('checkout') ?? [];
+ $checkoutInfo = $this->session->get('checkout') ?? ['user' => $this->global['user']];
$grandTotal = $this->cart->getGrandTotal();
$hasShipping = $this->cart->hasShipping();
+ $subscription = $this->cart->getSubscription();
$hasPayment = ($grandTotal > 0);
$this->view->hasShipping = $hasShipping;
$this->view->hasPayment = $hasPayment;
@@ -295,6 +296,7 @@ class Checkout extends Base {
//check if user was added before automatic login
if ($userInfo) {
\Vvveb\session(['user' => $userInfo]);
+ $checkoutInfo['user'] = $userInfo;
$this->view->global['user_id'] = $userInfo['user_id'];
}
} else {
@@ -341,7 +343,7 @@ class Checkout extends Base {
//default order status
$checkoutInfo['order_status_id'] = 1;
- $site = Sites :: getSiteData();
+ $site = Sites :: getSiteData(SITE_ID);
$order_url = url('user/orders', [
'host' => $site['host'] ?? false,
diff --git a/app/controller/user/reset.php b/app/controller/user/reset.php
index 3662e2b..0259bdd 100644
--- a/app/controller/user/reset.php
+++ b/app/controller/user/reset.php
@@ -97,7 +97,7 @@ class Reset extends Base {
$os = 'UnKnown';
}
- $site = Sites :: getSiteData();
+ $site = Sites :: getSiteData(SITE_ID);
$reset_url = url('user/reset/reset', [
'token' => $token,
diff --git a/app/controller/user/signup.php b/app/controller/user/signup.php
index b754839..0913911 100755
--- a/app/controller/user/signup.php
+++ b/app/controller/user/signup.php
@@ -75,7 +75,7 @@ class Signup extends \Vvveb\Controller\Base {
$this->request->request['user_id'] = $user_id;
$site = siteSettings();
- $siteData = Sites :: getSiteData();
+ $siteData = Sites :: getSiteData(SITE_ID);
$userInfo['website'] = url('user/index', [
'host' => $siteData['host'] ?? false,
@@ -85,7 +85,7 @@ class Signup extends \Vvveb\Controller\Base {
try {
$error = __('Error sending account creation mail!');
- if (! email([$userInfo['email'], $site['admin-email']], __('Your account has been created!'), 'user/signup', $userInfo)) {
+ if (! email([$userInfo['email'], $site['admin-email']], __('Your account has been created!'), 'user/signup', ['user' => $userInfo] + $this->global)) {
$this->session->set('errors', ['login' => $error]);
$this->view->errors[] = $error;
}
diff --git a/config/sites.php b/config/sites.php
index 7220cb9..420cf7d 100755
--- a/config/sites.php
+++ b/config/sites.php
@@ -27,7 +27,6 @@
'theme' => 'landing',
'state' => 'live',
'template' => '',
- 'id' => 1,
'site_id' => 1,
],
];
diff --git a/system/sites.php b/system/sites.php
old mode 100755
new mode 100644
index 61cae13..cec1a8a
--- a/system/sites.php
+++ b/system/sites.php
@@ -90,7 +90,7 @@ class Sites {
$sites = self :: getSites();
foreach ($sites as $site_key => $site) {
- if ($site['id'] == $site_id) {
+ if ($site['site_id'] == $site_id) {
$site['key'] = $site_key;
return $site;
@@ -195,7 +195,7 @@ class Sites {
public static function setSiteDataById($site_id, $name, $value) {
$site = self :: getSiteById($site_id);
- if ($site && ($site['id'] == $site_id)) {
+ if ($site && ($site['site_id'] == $site_id)) {
$key = "sites.{$site['key']}";
//key has changed replace site
@@ -213,6 +213,7 @@ class Sites {
$key .= ".$name";
}
+ self :: $sites = null;
return \Vvveb\setConfig($key, $value);
}
@@ -231,6 +232,7 @@ class Sites {
$key .= ".$name";
}
+ self :: $sites = null;
return \Vvveb\setConfig($key, $value);
}
@@ -252,12 +254,12 @@ class Sites {
}
public static function getSiteData($site_url = false) {
- if (is_int($site_url)) {
+ if (is_numeric($site_url)) {
return self :: getSiteById($site_url);
}
if (! $site_url) {
- $host = $_SERVER['HTTP_HOST'] ?? 'localhost';
+ $host = self :: getHost();
}
$cacheDriver = Cache :: getInstance();
@@ -272,7 +274,7 @@ class Sites {
$subdomain_wildcard = '* ' . substr($host, $first);
$tld_wildcard = substr($host, 0, $last) . ' *';
- $domain_wildcard = substr($host, 0, $first) . ' *';
+ $domain_wildcard = substr($host, 0, $first) . ' * *';
$full_wildcard = '* ' . trim(substr($host, $first, $last - $first)) . ' *';
$result = \Vvveb\config("sites.$host", null) ??
@@ -291,7 +293,7 @@ class Sites {
'host' => 'localhost',
'theme' => 'landing',
'template' => '',
- 'id' => 1,
+ 'site_id' => 1,
'state' => 'live',
];
}