aboutsummaryrefslogtreecommitdiffstats
path: root/public/catalog/controller/event
diff options
context:
space:
mode:
Diffstat (limited to 'public/catalog/controller/event')
-rw-r--r--public/catalog/controller/event/activity.php242
-rw-r--r--public/catalog/controller/event/debug.php21
-rw-r--r--public/catalog/controller/event/language.php26
-rw-r--r--public/catalog/controller/event/statistics.php57
-rw-r--r--public/catalog/controller/event/theme.php52
-rw-r--r--public/catalog/controller/event/translation.php16
6 files changed, 414 insertions, 0 deletions
diff --git a/public/catalog/controller/event/activity.php b/public/catalog/controller/event/activity.php
new file mode 100644
index 0000000..99c668e
--- /dev/null
+++ b/public/catalog/controller/event/activity.php
@@ -0,0 +1,242 @@
+<?php
+class ControllerEventActivity extends Controller {
+ // model/account/customer/addCustomer/after
+ public function addCustomer(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $output,
+ 'name' => $args[0]['firstname'] . ' ' . $args[0]['lastname']
+ );
+
+ $this->model_account_activity->addActivity('register', $activity_data);
+ }
+ }
+
+ // model/account/customer/editCustomer/after
+ public function editCustomer(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
+ );
+
+ $this->model_account_activity->addActivity('edit', $activity_data);
+ }
+ }
+
+ // model/account/customer/editPassword/after
+ public function editPassword(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ if ($this->customer->isLogged()) {
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
+ );
+
+ $this->model_account_activity->addActivity('password', $activity_data);
+ } else {
+ $customer_info = $this->model_account_customer->getCustomerByEmail($args[0]);
+
+ if ($customer_info) {
+ $activity_data = array(
+ 'customer_id' => $customer_info['customer_id'],
+ 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']
+ );
+
+ $this->model_account_activity->addActivity('reset', $activity_data);
+ }
+ }
+ }
+ }
+
+
+ // model/account/customer/deleteLoginAttempts/after
+ public function login(&$route, &$args, &$output) {
+ if (isset($this->request->get['route']) && ($this->request->get['route'] == 'account/login' || $this->request->get['route'] == 'checkout/login/save') && $this->config->get('config_customer_activity')) {
+ $customer_info = $this->model_account_customer->getCustomerByEmail($args[0]);
+
+ if ($customer_info) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $customer_info['customer_id'],
+ 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']
+ );
+
+ $this->model_account_activity->addActivity('login', $activity_data);
+ }
+ }
+ }
+
+ // model/account/customer/editCode/after
+ public function forgotten(&$route, &$args, &$output) {
+ if (isset($this->request->get['route']) && $this->request->get['route'] == 'account/forgotten' && $this->config->get('config_customer_activity')) {
+ $this->load->model('account/customer');
+
+ $customer_info = $this->model_account_customer->getCustomerByEmail($args[0]);
+
+ if ($customer_info) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $customer_info['customer_id'],
+ 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']
+ );
+
+ $this->model_account_activity->addActivity('forgotten', $activity_data);
+ }
+ }
+ }
+
+ // model/account/customer/addTransaction/after
+ public function addTransaction(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/customer');
+
+ $customer_info = $this->model_account_customer->getCustomer($args[0]);
+
+ if ($customer_info) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $customer_info['customer_id'],
+ 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname'],
+ 'order_id' => $args[3]
+ );
+
+ $this->model_account_activity->addActivity('transaction', $activity_data);
+ }
+ }
+ }
+
+ // model/account/customer/addAffiliate/after
+ public function addAffiliate(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $output,
+ 'name' => $args[1]['firstname'] . ' ' . $args[1]['lastname']
+ );
+
+ $this->model_account_activity->addActivity('affiliate_add', $activity_data);
+ }
+ }
+
+ // model/account/customer/editAffiliate/after
+ public function editAffiliate(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity') && $output) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
+ );
+
+ $this->model_account_activity->addActivity('affiliate_edit', $activity_data);
+ }
+ }
+
+ // model/account/address/addAddress/after
+ public function addAddress(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
+ );
+
+ $this->model_account_activity->addActivity('address_add', $activity_data);
+ }
+ }
+
+ // model/account/address/editAddress/after
+ public function editAddress(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
+ );
+
+ $this->model_account_activity->addActivity('address_edit', $activity_data);
+ }
+ }
+
+ // model/account/address/deleteAddress/after
+ public function deleteAddress(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity')) {
+ $this->load->model('account/activity');
+
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
+ );
+
+ $this->model_account_activity->addActivity('address_delete', $activity_data);
+ }
+ }
+
+ // model/account/return/addReturn/after
+ public function addReturn(&$route, &$args, &$output) {
+ if ($this->config->get('config_customer_activity') && $output) {
+ $this->load->model('account/activity');
+
+ if ($this->customer->isLogged()) {
+ $activity_data = array(
+ 'customer_id' => $this->customer->getId(),
+ 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName(),
+ 'return_id' => $output
+ );
+
+ $this->model_account_activity->addActivity('return_account', $activity_data);
+ } else {
+ $activity_data = array(
+ 'name' => $args[0]['firstname'] . ' ' . $args[0]['lastname'],
+ 'return_id' => $output
+ );
+
+ $this->model_account_activity->addActivity('return_guest', $activity_data);
+ }
+ }
+ }
+
+ // model/checkout/order/addOrderHistory/before
+ public function addOrderHistory(&$route, &$args) {
+ if ($this->config->get('config_customer_activity')) {
+ // If last order status id is 0 and new order status is not then record as new order
+ $this->load->model('checkout/order');
+
+ $order_info = $this->model_checkout_order->getOrder($args[0]);
+
+ if ($order_info && !$order_info['order_status_id'] && $args[1]) {
+ $this->load->model('account/activity');
+
+ if ($order_info['customer_id']) {
+ $activity_data = array(
+ 'customer_id' => $order_info['customer_id'],
+ 'name' => $order_info['firstname'] . ' ' . $order_info['lastname'],
+ 'order_id' => $args[0]
+ );
+
+ $this->model_account_activity->addActivity('order_account', $activity_data);
+ } else {
+ $activity_data = array(
+ 'name' => $order_info['firstname'] . ' ' . $order_info['lastname'],
+ 'order_id' => $args[0]
+ );
+
+ $this->model_account_activity->addActivity('order_guest', $activity_data);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/public/catalog/controller/event/debug.php b/public/catalog/controller/event/debug.php
new file mode 100644
index 0000000..fa66f1b
--- /dev/null
+++ b/public/catalog/controller/event/debug.php
@@ -0,0 +1,21 @@
+<?php
+class ControllerEventDebug extends Controller {
+ public function before(&$route, &$args) {
+ if ($route == 'common/home') { // add the route you want to test
+ $this->session->data['debug'][$route] = microtime();
+ }
+ }
+
+ public function after($route, &$args, &$output) {
+ if ($route == 'common/home') { // add the route you want to test
+ if (isset($this->session->data['debug'][$route])) {
+ $log_data = array(
+ 'route' => $route,
+ 'time' => microtime() - $this->session->data['debug'][$route]
+ );
+
+ $this->log->write($log_data);
+ }
+ }
+ }
+}
diff --git a/public/catalog/controller/event/language.php b/public/catalog/controller/event/language.php
new file mode 100644
index 0000000..5049b7d
--- /dev/null
+++ b/public/catalog/controller/event/language.php
@@ -0,0 +1,26 @@
+<?php
+class ControllerEventLanguage extends Controller {
+ public function index(&$route, &$args) {
+ foreach ($this->language->all() as $key => $value) {
+ if (!isset($args[$key])) {
+ $args[$key] = $value;
+ }
+ }
+ }
+
+ // 1. Before controller load store all current loaded language data
+ public function before(&$route, &$output) {
+ $this->language->set('backup', $this->language->all());
+ }
+
+ // 2. After contoller load restore old language data
+ public function after(&$route, &$args, &$output) {
+ $data = $this->language->get('backup');
+
+ if (is_array($data)) {
+ foreach ($data as $key => $value) {
+ $this->language->set($key, $value);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/public/catalog/controller/event/statistics.php b/public/catalog/controller/event/statistics.php
new file mode 100644
index 0000000..1dc3502
--- /dev/null
+++ b/public/catalog/controller/event/statistics.php
@@ -0,0 +1,57 @@
+<?php
+class ControllerEventStatistics extends Controller {
+ // model/catalog/review/addReview/after
+ public function addReview(&$route, &$args, &$output) {
+ $this->load->model('report/statistics');
+
+ $this->model_report_statistics->addValue('review', 1);
+ }
+
+ // model/account/return/addReturn/after
+ public function addReturn(&$route, &$args, &$output) {
+ $this->load->model('report/statistics');
+
+ $this->model_report_statistics->addValue('return', 1);
+ }
+
+ // model/checkout/order/addOrderHistory/before
+ public function addOrderHistory(&$route, &$args, &$output) {
+ $this->load->model('checkout/order');
+
+ $order_info = $this->model_checkout_order->getOrder($args[0]);
+
+ if ($order_info) {
+ $this->load->model('report/statistics');
+
+ // If order status in complete or proccessing add value to sale total
+ if (in_array($args[1], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
+ $this->model_report_statistics->addValue('order_sale', $order_info['total']);
+ }
+
+ // If order status not in complete or proccessing remove value to sale total
+ if (!in_array($args[1], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) {
+ $this->model_report_statistics->removeValue('order_sale', $order_info['total']);
+ }
+
+ // Remove from processing status if new status is not array
+ if (in_array($order_info['order_status_id'], $this->config->get('config_processing_status')) && !in_array($args[1], $this->config->get('config_processing_status'))) {
+ $this->model_report_statistics->removeValue('order_processing', 1);
+ }
+
+ // Add to processing status if new status is not array
+ if (!in_array($order_info['order_status_id'], $this->config->get('config_processing_status')) && in_array($args[1], $this->config->get('config_processing_status'))) {
+ $this->model_report_statistics->addValue('order_processing', 1);
+ }
+
+ // Remove from complete status if new status is not array
+ if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status')) && !in_array($args[1], $this->config->get('config_complete_status'))) {
+ $this->model_report_statistics->removeValue('order_complete', 1);
+ }
+
+ // Add to complete status if new status is not array
+ if (!in_array($order_info['order_status_id'], $this->config->get('config_complete_status')) && in_array($args[1], $this->config->get('config_complete_status'))) {
+ $this->model_report_statistics->addValue('order_complete', 1);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/public/catalog/controller/event/theme.php b/public/catalog/controller/event/theme.php
new file mode 100644
index 0000000..59cc8e2
--- /dev/null
+++ b/public/catalog/controller/event/theme.php
@@ -0,0 +1,52 @@
+<?php
+class ControllerEventTheme extends Controller {
+ public function index(&$route, &$args, &$template) {
+ // If there is a template file we render
+ if ($template) {
+ // include and register Twig auto-loader
+ include_once(DIR_SYSTEM . 'library/template/Twig/Autoloader.php');
+
+ Twig_Autoloader::register();
+
+ // specify where to look for templates
+ $loader = new \Twig_Loader_Filesystem(DIR_TEMPLATE);
+
+ $config = array('autoescape' => false);
+
+ if ($this->config->get('template_cache')) {
+ $config['cache'] = DIR_CACHE;
+ }
+
+ // initialize Twig environment
+ $twig = new \Twig_Environment($loader, $config);
+
+ return $twig->createTemplate($template)->render($args);
+ }
+ }
+
+ public function override(&$route, &$args, &$template) {
+ if (!$this->config->get('theme_' . $this->config->get('config_theme') . '_status')) {
+ exit('Error: A theme has not been assigned to this store!');
+ }
+
+ // If the default theme is selected we need to know which directory its pointing to
+ if ($this->config->get('config_theme') == 'default') {
+ $theme = $this->config->get('theme_default_directory');
+ } else {
+ $theme = $this->config->get('config_theme');
+ }
+
+ // If there is a theme override we should get it
+ $this->load->model('design/theme');
+
+ $theme_info = $this->model_design_theme->getTheme($route, $theme);
+
+ if ($theme_info) {
+ $template = html_entity_decode($theme_info['code'], ENT_QUOTES, 'UTF-8');
+ } elseif (is_file(DIR_TEMPLATE . $theme . '/template/' . $route . '.twig')) {
+ $this->config->set('template_directory', $theme . '/template/');
+ } elseif (is_file(DIR_TEMPLATE . 'default/template/' . $route . '.twig')) {
+ $this->config->set('template_directory', 'default/template/');
+ }
+ }
+} \ No newline at end of file
diff --git a/public/catalog/controller/event/translation.php b/public/catalog/controller/event/translation.php
new file mode 100644
index 0000000..96201b1
--- /dev/null
+++ b/public/catalog/controller/event/translation.php
@@ -0,0 +1,16 @@
+<?php
+class ControllerEventTranslation extends Controller {
+ public function index(&$route, &$key) {
+ $this->load->model('design/translation');
+
+ $results = $this->model_design_translation->getTranslations($route);
+
+ foreach ($results as $result) {
+ if (!$key) {
+ $this->language->set($result['key'], $result['value']);
+ } else {
+ $this->language->get($key)->set($result['key'], $result['value']);
+ }
+ }
+ }
+}