Created
December 25, 2020 05:38
-
-
Save ichaykin/f7a7dba6f85d78184f5330128daac860 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/vendor_communication/schemas/notifications/events.post.php b/app/addons/vendor_communication/schemas/notifications/events.post.php | |
index 5e79366c34..baeb85a62c 100644 | |
--- a/app/addons/vendor_communication/schemas/notifications/events.post.php | |
+++ b/app/addons/vendor_communication/schemas/notifications/events.post.php | |
@@ -22,6 +22,7 @@ use Tygh\Notifications\Transports\Internal\InternalTransport; | |
use Tygh\Notifications\Transports\Internal\InternalMessageSchema; | |
use Tygh\Enum\NotificationSeverity; | |
use Tygh\NotificationsCenter\NotificationsCenter; | |
+use Tygh\Registry; | |
defined('BOOTSTRAP') or die('Access denied'); | |
@@ -85,7 +86,7 @@ $schema['vendor_communication.message_received'] = [ | |
'area' => SiteArea::ADMIN_PANEL, | |
'section' => NotificationsCenter::SECTION_COMMUNICATION, | |
'to_company_id' => DataValue::create('to_company_id'), | |
- 'language_code' => DataValue::create('lang_code', CART_LANGUAGE), | |
+ 'language_code' => Registry::get('settings.Appearance.backend_default_language'), | |
'action_url' => DataValue::create('action_url'), | |
'severity' => NotificationSeverity::NOTICE, | |
'template_code' => 'vendor_communication_message_received', | |
@@ -132,7 +133,7 @@ $schema['vendor_communication.vendor_to_admin_message_received'] = [ | |
'area' => SiteArea::ADMIN_PANEL, | |
'section' => NotificationsCenter::SECTION_COMMUNICATION, | |
'to_company_id' => DataValue::create('to_company_id'), | |
- 'language_code' => DataValue::create('lang_code', CART_LANGUAGE), | |
+ 'language_code' => Registry::get('settings.Appearance.backend_default_language'), | |
'action_url' => DataValue::create('action_url'), | |
'severity' => NotificationSeverity::NOTICE, | |
'template_code' => 'vendor_communication_message_received', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/functions/fn.companies.php b/app/functions/fn.companies.php | |
index ee094a0f03..5ac59e6244 100644 | |
--- a/app/functions/fn.companies.php | |
+++ b/app/functions/fn.companies.php | |
@@ -526,6 +526,10 @@ function fn_get_company_data($company_id, $lang_code = DESCR_SL, $extra = array( | |
$cache_key = md5($company_id . $lang_code . serialize($extra)); | |
+ if (!empty($extra['reset_cache'])) { | |
+ $company_data_cache = []; | |
+ } | |
+ | |
if (empty($extra['skip_cache']) && isset($company_data_cache[$cache_key])) { | |
return $company_data_cache[$cache_key]; | |
} | |
@@ -843,12 +847,12 @@ function fn_update_company($company_data, $company_id = 0, $lang_code = CART_LAN | |
unset($company_data['company_id']); | |
$_data = $company_data; | |
- if (fn_allowed_for('MULTIVENDOR')) { | |
+ if (fn_allowed_for('MULTIVENDOR') && !empty($_data['email'])) { | |
// Check if company with same email already exists | |
- $is_exist = db_get_field("SELECT email FROM ?:companies WHERE company_id != ?i AND email = ?s", $company_id, $_data['email']); | |
+ $is_exist = db_get_field('SELECT email FROM ?:companies WHERE company_id != ?i AND email = ?s', $company_id, $_data['email']); | |
if (!empty($is_exist)) { | |
$_text = 'error_vendor_exists'; | |
- fn_set_notification('E', __('error'), __($_text)); | |
+ fn_set_notification(NotificationSeverity::ERROR, __('error'), __($_text)); | |
return false; | |
} | |
@@ -1321,7 +1325,7 @@ function fn_change_company_status($company_id, $status_to, $reason = '', &$statu | |
return false; | |
} | |
- $company_data = fn_get_company_data($company_id); | |
+ $company_data = fn_get_company_data($company_id, DESCR_SL, ['reset_cache' => true]); | |
$account = ''; | |
if ( | |
@@ -1423,19 +1427,19 @@ function fn_change_company_status($company_id, $status_to, $reason = '', &$statu | |
switch ($status_to) { | |
case VendorStatuses::DISABLED: | |
- $data['status'] = __('disabled'); | |
+ $data['status'] = 'disabled'; | |
$event_code = 'vendor_status_changed_disabled'; | |
break; | |
case VendorStatuses::PENDING: | |
- $data['status'] = __('pending'); | |
+ $data['status'] = 'pending'; | |
$event_code = 'vendor_status_changed_pending'; | |
break; | |
case VendorStatuses::ACTIVE: | |
- $data['status'] = __('active'); | |
+ $data['status'] = 'active'; | |
$event_code = 'vendor_status_changed_active'; | |
break; | |
case VendorStatuses::SUSPENDED: | |
- $data['status'] = __('suspended'); | |
+ $data['status'] = 'suspended'; | |
$event_code = 'vendor_status_changed_suspended'; | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/schemas/notifications/events_multivendor.php b/app/schemas/notifications/events_multivendor.php | |
index 89b5dbc211..568f796782 100644 | |
--- a/app/schemas/notifications/events_multivendor.php | |
+++ b/app/schemas/notifications/events_multivendor.php | |
@@ -204,17 +204,25 @@ $schema['vendor_status_changed_active'] = [ | |
'area' => SiteArea::ADMIN_PANEL, | |
'from' => 'default_company_support_department', | |
'to' => DataValue::create('user_data.email'), | |
- 'company_id' => DataValue::create('company_data.company_id'), | |
+ 'company_id' => DataValue::create('company.company_id'), | |
'template_code' => 'company_status_notification', | |
'legacy_template' => 'companies/status_notification.tpl', | |
- 'language_code' => DataValue::create('company_data.lang_code', CART_LANGUAGE), | |
+ 'language_code' => DataValue::create('user_data.lang_code', CART_LANGUAGE), | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['user_data']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['user_data']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
InternalTransport::getId() => InternalMessageSchema::create([ | |
'tag' => 'vendor_status', | |
'area' => SiteArea::VENDOR_PANEL, | |
'section' => NotificationsCenter::SECTION_ADMINISTRATION, | |
'to_company_id' => DataValue::create('to_company_id'), | |
- 'language_code' => DataValue::create('company_data.lang_code', CART_LANGUAGE), | |
+ 'language_code' => DataValue::create('company.lang_code', CART_LANGUAGE), | |
'severity' => NotificationSeverity::NOTICE, | |
'title' => [ | |
'template' => 'event.vendor_status_changed.title', | |
@@ -224,7 +232,15 @@ $schema['vendor_status_changed_active'] = [ | |
], | |
'message' => [ | |
'template' => 'event.vendor_status_changed.active.message', | |
- ] | |
+ ], | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['company']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['company']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
], | |
] | |
@@ -247,14 +263,22 @@ $schema['vendor_status_changed_pending'] = [ | |
'company_id' => DataValue::create('company.company_id'), | |
'template_code' => 'company_status_notification', | |
'legacy_template' => 'companies/status_notification.tpl', | |
- 'language_code' => DataValue::create('company_data.lang_code', CART_LANGUAGE), | |
+ 'language_code' => DataValue::create('user_data.lang_code', CART_LANGUAGE), | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['user_data']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['user_data']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
InternalTransport::getId() => InternalMessageSchema::create([ | |
'tag' => 'vendor_status', | |
'area' => SiteArea::VENDOR_PANEL, | |
'section' => NotificationsCenter::SECTION_ADMINISTRATION, | |
'to_company_id' => DataValue::create('to_company_id'), | |
- 'language_code' => DataValue::create('company_data.lang_code', CART_LANGUAGE), | |
+ 'language_code' => DataValue::create('company.lang_code', CART_LANGUAGE), | |
'severity' => NotificationSeverity::NOTICE, | |
'title' => [ | |
'template' => 'event.vendor_status_changed.title', | |
@@ -264,7 +288,15 @@ $schema['vendor_status_changed_pending'] = [ | |
], | |
'message' => [ | |
'template' => 'event.vendor_status_changed.pending.message', | |
- ] | |
+ ], | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['company']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['company']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
], | |
] | |
@@ -288,6 +320,14 @@ $schema['vendor_status_changed_disabled'] = [ | |
'template_code' => 'company_status_notification', | |
'legacy_template' => 'companies/status_notification.tpl', | |
'language_code' => DataValue::create('user_data.lang_code', CART_LANGUAGE), | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['user_data']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['user_data']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
], | |
], | |
@@ -310,6 +350,14 @@ $schema['vendor_status_changed_from_suspended'] = [ | |
'company_id' => DataValue::create('company.company_id'), | |
'template_code' => 'company_status_changed_from_suspended_notification', | |
'language_code' => DataValue::create('user_data.lang_code', CART_LANGUAGE), | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['user_data']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['user_data']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
], | |
], | |
@@ -332,6 +380,14 @@ $schema['vendor_status_changed_suspended'] = [ | |
'company_id' => DataValue::create('company.company_id'), | |
'template_code' => 'company_status_suspended_notification', | |
'language_code' => DataValue::create('user_data.lang_code', CART_LANGUAGE), | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['user_data']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['user_data']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
InternalTransport::getId() => InternalMessageSchema::create([ | |
'tag' => 'vendor_status', | |
@@ -348,7 +404,15 @@ $schema['vendor_status_changed_suspended'] = [ | |
], | |
'message' => [ | |
'template' => 'event.vendor_status_changed.suspended.message', | |
- ] | |
+ ], | |
+ 'data_modifier' => static function (array $data) { | |
+ if (empty($data['status']) || empty($data['company']['lang_code'])) { | |
+ return $data; | |
+ } | |
+ | |
+ $data['status'] = __($data['status'], [], $data['company']['lang_code']); | |
+ return $data; | |
+ } | |
]), | |
], | |
], | |
@@ -368,7 +432,7 @@ $schema['vendors_require_approval'] = [ | |
'section' => NotificationsCenter::SECTION_ADMINISTRATION, | |
'severity' => NotificationSeverity::WARNING, | |
'to_company_id' => 0, | |
- 'language_code' => DataValue::create('lang_code', CART_LANGUAGE), | |
+ 'language_code' => Registry::get('settings.Appearance.backend_default_language'), | |
'action_url' => 'companies.manage?status[]=' . VendorStatuses::NEW_ACCOUNT . '&status[]=' . VendorStatuses::PENDING, | |
'title' => [ | |
'template' => 'event.vendors_require_approval.title', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/Tygh/Notifications/Transports/Internal/InternalMessageSchema.php b/app/Tygh/Notifications/Transports/Internal/InternalMessageSchema.php | |
index 899611ad58..1db3676221 100644 | |
--- a/app/Tygh/Notifications/Transports/Internal/InternalMessageSchema.php | |
+++ b/app/Tygh/Notifications/Transports/Internal/InternalMessageSchema.php | |
@@ -84,6 +84,7 @@ class InternalMessageSchema extends BaseMessageSchema | |
public function init(Data $data) | |
{ | |
$self = parent::init($data); | |
+ $data = new Data($self->data); | |
if (is_array($self->title)) { | |
$self->title = $self->getText($data, $self->title); | |
@@ -135,6 +136,7 @@ class InternalMessageSchema extends BaseMessageSchema | |
$self->language_code = self::get($schema, 'language_code'); | |
$self->template_code = self::get($schema, 'template_code'); | |
$self->to_company_id = self::get($schema, 'to_company_id'); | |
+ $self->data_modifier = self::get($schema, 'data_modifier'); | |
return $self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment