first commit
This commit is contained in:
@@ -0,0 +1,249 @@
|
||||
<?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');
|
||||
|
||||
if($this->customer->getId()) {
|
||||
$activity_data = array(
|
||||
'customer_id' => $this->customer->getId(),
|
||||
'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
|
||||
);
|
||||
} else {
|
||||
$activity_data = array(
|
||||
'customer_id' => $args[0],
|
||||
'name' => $args[1]['firstname'] . ' ' . $args[1]['lastname']
|
||||
);
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
class ControllerEventTheme extends Controller {
|
||||
public function index(&$route, &$args, &$code) {
|
||||
|
||||
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') {
|
||||
$directory = $this->config->get('theme_default_directory');
|
||||
} else {
|
||||
$directory = $this->config->get('config_theme');
|
||||
}
|
||||
|
||||
if ($directory != 'default' && is_file(DIR_TEMPLATE . $directory . '/template/' . $route . '.twig')) {
|
||||
$this->config->set('template_directory', $directory . '/template/');
|
||||
} elseif (is_file(DIR_TEMPLATE . 'default/template/' . $route . '.twig')) {
|
||||
$this->config->set('template_directory', 'default/template/');
|
||||
}
|
||||
|
||||
// If there is a theme override we should get it
|
||||
$this->load->model('design/theme');
|
||||
|
||||
$theme_info = $this->model_design_theme->getTheme($route, $directory);
|
||||
|
||||
if ($theme_info && !is_file(DIR_MODIFICATION . 'store/view/theme/' .$directory.'/template/'. $route . '.twig')) {
|
||||
$code = html_entity_decode($theme_info['code'], ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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'], html_entity_decode( $result['value'], ENT_QUOTES, 'UTF-8'));
|
||||
} else {
|
||||
$this->language->get($key)->set($result['key'], html_entity_decode( $result['value'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user