Created
April 9, 2019 11:28
-
-
Save torunar/d62cacf3fd135586b27199e63a542530 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/discussion/controllers/backend/categories.post.php b/app/addons/discussion/controllers/backend/categories.post.php | |
index e2b73833f0..8bf3f86b0b 100644 | |
--- a/app/addons/discussion/controllers/backend/categories.post.php | |
+++ b/app/addons/discussion/controllers/backend/categories.post.php | |
@@ -12,6 +12,8 @@ | |
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
****************************************************************************/ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+use Tygh\Enum\Addons\Discussion\DiscussionTypes; | |
use Tygh\Registry; | |
if (!defined('BOOTSTRAP')) { die('Access denied'); } | |
@@ -28,16 +30,18 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if ($mode == 'update') { | |
- $discussion = fn_get_discussion($_REQUEST['category_id'], 'C', true, $_REQUEST); | |
- if (!empty($discussion) && $discussion['type'] != 'D') { | |
- if (fn_allowed_for('MULTIVENDOR') || fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { | |
- Registry::set('navigation.tabs.discussion', array ( | |
- 'title' => __('discussion_title_category'), | |
- 'js' => true | |
- )); | |
+ $discussion = fn_get_discussion($_REQUEST['category_id'], DiscussionObjectTypes::CATEGORY, true, $_REQUEST); | |
- Tygh::$app['view']->assign('discussion', $discussion); | |
- } | |
+ if (!empty($discussion) && | |
+ $discussion['type'] !== DiscussionTypes::TYPE_DISABLED && | |
+ fn_check_permissions('discussion', 'view', 'admin') | |
+ ) { | |
+ Registry::set('navigation.tabs.discussion', [ | |
+ 'title' => __('discussion_title_category'), | |
+ 'js' => true, | |
+ ]); | |
+ | |
+ Tygh::$app['view']->assign('discussion', $discussion); | |
} | |
} elseif ($mode == 'm_update') { |
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/discussion/controllers/backend/companies.post.php b/app/addons/discussion/controllers/backend/companies.post.php | |
index 313372b6cd..86570d8dd4 100644 | |
--- a/app/addons/discussion/controllers/backend/companies.post.php | |
+++ b/app/addons/discussion/controllers/backend/companies.post.php | |
@@ -12,6 +12,8 @@ | |
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
****************************************************************************/ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+use Tygh\Enum\Addons\Discussion\DiscussionTypes; | |
use Tygh\Registry; | |
if (!defined('BOOTSTRAP')) { die('Access denied'); } | |
@@ -28,12 +30,17 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if ($mode == 'update') { | |
if (!fn_allowed_for('ULTIMATE')) { | |
- $discussion = fn_get_discussion($_REQUEST['company_id'], 'M', true, $_REQUEST); | |
- if (!empty($discussion) && $discussion['type'] != 'D') { | |
- Registry::set('navigation.tabs.discussion', array ( | |
+ | |
+ $discussion = fn_get_discussion($_REQUEST['company_id'], DiscussionObjectTypes::COMPANY, true, $_REQUEST); | |
+ | |
+ if (!empty($discussion) && | |
+ $discussion['type'] !== DiscussionTypes::TYPE_DISABLED && | |
+ fn_check_permissions('discussion', 'view', 'admin') | |
+ ) { | |
+ Registry::set('navigation.tabs.discussion', [ | |
'title' => __('discussion_title_company'), | |
- 'js' => true | |
- )); | |
+ 'js' => true, | |
+ ]); | |
Tygh::$app['view']->assign('discussion', $discussion); | |
} |
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/discussion/controllers/backend/discussion_manager.php b/app/addons/discussion/controllers/backend/discussion_manager.php | |
index 2b3a9eacda..5fa42f6d20 100644 | |
--- a/app/addons/discussion/controllers/backend/discussion_manager.php | |
+++ b/app/addons/discussion/controllers/backend/discussion_manager.php | |
@@ -1,47 +1,53 @@ | |
<?php | |
/*************************************************************************** | |
-* * | |
-* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * | |
-* * | |
-* This is commercial software, only users who have purchased a valid * | |
-* license and accept to the terms of the License Agreement can install * | |
-* and use this program. * | |
-* * | |
-**************************************************************************** | |
-* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * | |
-* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
-****************************************************************************/ | |
- | |
+ * * | |
+ * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * | |
+ * * | |
+ * This is commercial software, only users who have purchased a valid * | |
+ * license and accept to the terms of the License Agreement can install * | |
+ * and use this program. * | |
+ * * | |
+ **************************************************************************** | |
+ * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * | |
+ * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
+ ****************************************************************************/ | |
+ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+use Tygh\Enum\Addons\Discussion\DiscussionTypes; | |
use Tygh\Registry; | |
-if (!defined('BOOTSTRAP')) { die('Access denied'); } | |
+if (!defined('BOOTSTRAP')) { | |
+ die('Access denied'); | |
+} | |
if ($mode == 'manage') { | |
$discussion_object_types = fn_get_discussion_objects(); | |
$discussion_object_titles = fn_get_discussion_titles(); | |
- if (empty($_REQUEST['object_type'])) { | |
- reset($discussion_object_types); | |
- $_REQUEST['object_type'] = key($discussion_object_types); // FIXME: bad style | |
- } | |
+ $params = array_merge([ | |
+ 'object_type' => key($discussion_object_types), | |
+ ], $_REQUEST); | |
+ | |
+ $runtime_company_id = fn_get_runtime_company_id(); | |
+ | |
+ $discussion_manager_url = fn_query_remove(Registry::get('config.current_url'), 'object_type', 'page'); | |
+ $are_testimonials_enabled = Registry::ifGet('addons.discussion.home_page_testimonials', DiscussionTypes::TYPE_DISABLED) !== DiscussionTypes::TYPE_DISABLED; | |
- $_url = fn_query_remove(Registry::get('config.current_url'), 'object_type', 'page'); | |
foreach ($discussion_object_types as $obj_type => $obj) { | |
- if ($obj_type == 'E' && Registry::ifGet('addons.discussion.home_page_testimonials', 'D') == 'D') { | |
+ if ($obj_type === DiscussionObjectTypes::TESTIMONIALS_AND_LAYOUT && !$are_testimonials_enabled) { | |
continue; | |
} | |
$_name = __($discussion_object_titles[$obj_type]); | |
- Registry::set('navigation.tabs.' . $obj, array ( | |
+ Registry::set('navigation.tabs.' . $obj, [ | |
'title' => $_name, | |
- 'href' => $_url . '&object_type=' . $obj_type, | |
- )); | |
- | |
+ 'href' => $discussion_manager_url . '&object_type=' . $obj_type, | |
+ ]); | |
} | |
- list($posts, $search) = fn_get_discussions($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page')); | |
+ list($posts, $search) = fn_get_discussions($params, Registry::get('settings.Appearance.admin_elements_per_page')); | |
if (!empty($posts)) { | |
foreach ($posts as $k => $v) { | |
@@ -51,6 +57,6 @@ if ($mode == 'manage') { | |
Tygh::$app['view']->assign('posts', $posts); | |
Tygh::$app['view']->assign('search', $search); | |
- Tygh::$app['view']->assign('discussion_object_type', $_REQUEST['object_type']); | |
+ Tygh::$app['view']->assign('discussion_object_type', $params['object_type']); | |
Tygh::$app['view']->assign('discussion_object_types', $discussion_object_types); | |
} |
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/discussion/controllers/backend/orders.post.php b/app/addons/discussion/controllers/backend/orders.post.php | |
index 329da7df16..deba597037 100644 | |
--- a/app/addons/discussion/controllers/backend/orders.post.php | |
+++ b/app/addons/discussion/controllers/backend/orders.post.php | |
@@ -12,6 +12,8 @@ | |
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
****************************************************************************/ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+use Tygh\Enum\Addons\Discussion\DiscussionTypes; | |
use Tygh\Registry; | |
if (!defined('BOOTSTRAP')) { die('Access denied'); } | |
@@ -58,15 +60,16 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if ($mode == 'details') { | |
- $discussion = fn_get_discussion($_REQUEST['order_id'], 'O', true, $_REQUEST); | |
- if (!empty($discussion) && $discussion['type'] != 'D') { | |
- if (fn_allowed_for('MULTIVENDOR') || (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) || Registry::get('runtime.simple_ultimate')) { | |
- Registry::set('navigation.tabs.discussion', array ( | |
- 'title' => __('communication'), | |
- 'js' => true | |
- )); | |
+ $discussion = fn_get_discussion($_REQUEST['order_id'], DiscussionObjectTypes::ORDER, true, $_REQUEST); | |
+ if (!empty($discussion) && | |
+ $discussion['type'] !== DiscussionTypes::TYPE_DISABLED && | |
+ fn_check_permissions('discussion', 'view', 'admin') | |
+ ) { | |
+ Registry::set('navigation.tabs.discussion', [ | |
+ 'title' => __('communication'), | |
+ 'js' => true, | |
+ ]); | |
- Tygh::$app['view']->assign('discussion', $discussion); | |
- } | |
+ Tygh::$app['view']->assign('discussion', $discussion); | |
} | |
} |
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/discussion/controllers/backend/pages.post.php b/app/addons/discussion/controllers/backend/pages.post.php | |
index 821a84ddfb..0bc548cc24 100644 | |
--- a/app/addons/discussion/controllers/backend/pages.post.php | |
+++ b/app/addons/discussion/controllers/backend/pages.post.php | |
@@ -12,6 +12,8 @@ | |
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
****************************************************************************/ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+use Tygh\Enum\Addons\Discussion\DiscussionTypes; | |
use Tygh\Registry; | |
if (!defined('BOOTSTRAP')) { die('Access denied'); } | |
@@ -27,17 +29,19 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
} | |
if ($mode == 'update') { | |
$page = Tygh::$app['view']->getTemplateVars('page_data'); | |
- $discussion = fn_get_discussion($_REQUEST['page_id'], 'A', true, $_REQUEST); | |
+ $discussion = fn_get_discussion($_REQUEST['page_id'], DiscussionObjectTypes::PAGE, true, $_REQUEST); | |
- if (!empty($discussion) && $discussion['type'] != 'D' && $page['page_type'] != PAGE_TYPE_LINK) { | |
- if (fn_allowed_for('MULTIVENDOR') || fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { | |
- Registry::set('navigation.tabs.discussion', array ( | |
- 'title' => __('discussion_title_page'), | |
- 'js' => true | |
- )); | |
+ if (!empty($discussion) && | |
+ $discussion['type'] !== DiscussionTypes::TYPE_DISABLED && | |
+ fn_check_permissions('discussion', 'view', 'admin') && | |
+ $page['page_type'] !== PAGE_TYPE_LINK | |
+ ) { | |
+ Registry::set('navigation.tabs.discussion', [ | |
+ 'title' => __('discussion_title_page'), | |
+ 'js' => true, | |
+ ]); | |
- Tygh::$app['view']->assign('discussion', $discussion); | |
- } | |
+ Tygh::$app['view']->assign('discussion', $discussion); | |
} | |
} elseif ($mode == 'm_update') { |
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/discussion/controllers/backend/products.post.php b/app/addons/discussion/controllers/backend/products.post.php | |
index c823ad98ae..2c18b15ee4 100644 | |
--- a/app/addons/discussion/controllers/backend/products.post.php | |
+++ b/app/addons/discussion/controllers/backend/products.post.php | |
@@ -12,6 +12,8 @@ | |
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
****************************************************************************/ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+use Tygh\Enum\Addons\Discussion\DiscussionTypes; | |
use Tygh\Registry; | |
if (!defined('BOOTSTRAP')) { die('Access denied'); } | |
@@ -28,17 +30,18 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if ($mode == 'update') { | |
- $discussion = fn_get_discussion($_REQUEST['product_id'], 'P', true, $_REQUEST); | |
+ $discussion = fn_get_discussion($_REQUEST['product_id'], DiscussionObjectTypes::PRODUCT, true, $_REQUEST); | |
- if (!empty($discussion) && $discussion['type'] != 'D') { | |
- if (fn_allowed_for('MULTIVENDOR') || fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { | |
- Registry::set('navigation.tabs.discussion', array ( | |
- 'title' => __('discussion_title_product'), | |
- 'js' => true | |
- )); | |
+ if (!empty($discussion) && | |
+ $discussion['type'] !== DiscussionTypes::TYPE_DISABLED && | |
+ fn_check_permissions('discussion', 'view', 'admin') | |
+ ) { | |
+ Registry::set('navigation.tabs.discussion', [ | |
+ 'title' => __('discussion_title_product'), | |
+ 'js' => true, | |
+ ]); | |
- Tygh::$app['view']->assign('discussion', $discussion); | |
- } | |
+ Tygh::$app['view']->assign('discussion', $discussion); | |
} | |
} elseif ($mode == 'manage') { |
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/discussion/schemas/permissions/admin.post.php b/app/addons/discussion/schemas/permissions/admin.post.php | |
index 22673daade..da48bb9632 100644 | |
--- a/app/addons/discussion/schemas/permissions/admin.post.php | |
+++ b/app/addons/discussion/schemas/permissions/admin.post.php | |
@@ -1,27 +1,65 @@ | |
<?php | |
/*************************************************************************** | |
-* * | |
-* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * | |
-* * | |
-* This is commercial software, only users who have purchased a valid * | |
-* license and accept to the terms of the License Agreement can install * | |
-* and use this program. * | |
-* * | |
-**************************************************************************** | |
-* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * | |
-* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
-****************************************************************************/ | |
- | |
-$schema['discussion_manager'] = array ( | |
- 'permissions' => array ('GET' => 'view_discussions', 'POST' => 'manage_discussions'), | |
-); | |
-$schema['discussion'] = array ( | |
- 'permissions' => array ('GET' => 'view_discussions', 'POST' => 'manage_discussions'), | |
-); | |
- | |
-$schema['index']['modes']['delete_post'] = array ( | |
- 'permissions' => 'manage_discussions' | |
-); | |
+ * * | |
+ * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * | |
+ * * | |
+ * This is commercial software, only users who have purchased a valid * | |
+ * license and accept to the terms of the License Agreement can install * | |
+ * and use this program. * | |
+ * * | |
+ **************************************************************************** | |
+ * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * | |
+ * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
+ ****************************************************************************/ | |
+ | |
+use Tygh\Enum\Addons\Discussion\DiscussionObjectTypes; | |
+ | |
+defined('BOOTSTRAP') or die('Access denied'); | |
+ | |
+$schema['discussion'] = [ | |
+ 'modes' => [ | |
+ 'add' => [ | |
+ 'permissions' => 'manage_discussions', | |
+ ], | |
+ /** | |
+ * discussion.view is not used in the administration panel, | |
+ * but this action is required for proper permissions check of vendors | |
+ */ | |
+ 'view' => [ | |
+ 'permissions' => 'view_discussions', | |
+ ], | |
+ 'update' => [ | |
+ 'param_permissions' => [ | |
+ 'discussion_type' => [ | |
+ DiscussionObjectTypes::TESTIMONIALS_AND_LAYOUT => 'view_discussions', | |
+ ], | |
+ ], | |
+ ], | |
+ 'delete' => [ | |
+ 'permissions' => 'manage_discussions', | |
+ ], | |
+ 'm_delete' => [ | |
+ 'permissions' => 'manage_discussions', | |
+ ], | |
+ ], | |
+ 'permissions' => 'manage_discussions', | |
+]; | |
+ | |
+$schema['discussion_manager'] = [ | |
+ 'modes' => [ | |
+ 'manage' => [ | |
+ 'permissions' => 'view_discussions', | |
+ ], | |
+ ], | |
+]; | |
+ | |
+$schema['index']['modes']['set_post_status'] = [ | |
+ 'permissions' => 'manage_discussions', | |
+]; | |
+ | |
+$schema['index']['modes']['delete_post'] = [ | |
+ 'permissions' => 'manage_discussions', | |
+]; | |
$schema['tools']['modes']['update_status']['param_permissions']['table']['discussion_posts'] = 'manage_discussions'; | |
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/discussion/schemas/permissions/vendor_multivendor.post.php b/app/addons/discussion/schemas/permissions/vendor_multivendor.post.php | |
index cf262c6a36..b41df1e34d 100644 | |
--- a/app/addons/discussion/schemas/permissions/vendor_multivendor.post.php | |
+++ b/app/addons/discussion/schemas/permissions/vendor_multivendor.post.php | |
@@ -1,43 +1,59 @@ | |
<?php | |
/*************************************************************************** | |
-* * | |
-* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * | |
-* * | |
-* This is commercial software, only users who have purchased a valid * | |
-* license and accept to the terms of the License Agreement can install * | |
-* and use this program. * | |
-* * | |
-**************************************************************************** | |
-* PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * | |
-* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
-****************************************************************************/ | |
+ * * | |
+ * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * | |
+ * * | |
+ * This is commercial software, only users who have purchased a valid * | |
+ * license and accept to the terms of the License Agreement can install * | |
+ * and use this program. * | |
+ * * | |
+ **************************************************************************** | |
+ * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * | |
+ * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * | |
+ ****************************************************************************/ | |
-$schema['controllers']['discussion'] = array ( | |
- 'modes' => array( | |
- 'add' => array( | |
- 'permissions' => true | |
- ), | |
- 'update' => array( | |
- 'permissions' => false | |
- ), | |
- 'delete' => array( | |
- 'permissions' => false | |
- ), | |
- 'm_delete' => array( | |
- 'permissions' => false | |
- ), | |
- ), | |
+defined('BOOTSTRAP') or die('Access denied'); | |
+ | |
+$schema['controllers']['discussion'] = [ | |
+ 'modes' => [ | |
+ 'add' => [ | |
+ 'permissions' => true, | |
+ ], | |
+ /** | |
+ * discussion.view is not used in the administration panel, | |
+ * but this action is required for proper permissions check of vendors | |
+ */ | |
+ 'view' => [ | |
+ 'permissions' => true, | |
+ ], | |
+ 'update' => [ | |
+ 'permissions' => false, | |
+ ], | |
+ 'delete' => [ | |
+ 'permissions' => false, | |
+ ], | |
+ 'm_delete' => [ | |
+ 'permissions' => false, | |
+ ], | |
+ ], | |
+]; | |
+ | |
+$schema['controllers']['discussion_manager'] = [ | |
+ 'modes' => [ | |
+ 'manage' => [ | |
+ 'permissions' => false, | |
+ ], | |
+ ], | |
+]; | |
+ | |
+$schema['index']['modes']['set_post_status'] = [ | |
+ 'permissions' => false, | |
+]; | |
+ | |
+$schema['index']['modes']['delete_post'] = [ | |
'permissions' => false, | |
-); | |
+]; | |
-$schema['controllers']['discussion_manager'] = array ( | |
- 'modes' => array( | |
- 'manage' => array( | |
- 'permissions' => false | |
- ), | |
- ), | |
- 'permissions' => true, | |
- //'permissions' => false, | |
-); | |
+$schema['tools']['modes']['update_status']['param_permissions']['table']['discussion_posts'] = false; | |
return $schema; |
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/design/backend/templates/addons/discussion/views/discussion_manager/components/discussion.tpl b/design/backend/templates/addons/discussion/views/discussion_manager/components/discussion.tpl | |
index 61a360f84d..1e20f02b12 100644 | |
--- a/design/backend/templates/addons/discussion/views/discussion_manager/components/discussion.tpl | |
+++ b/design/backend/templates/addons/discussion/views/discussion_manager/components/discussion.tpl | |
@@ -1,12 +1,16 @@ | |
{if $discussion && $discussion.object_type && !$discussion.is_empty} | |
- {$allow_save = ($discussion.object_type != "M" || !$runtime.company_id) && "discussion.update"|fn_check_view_permissions} | |
+ {$is_allowed_to_add_posts = "discussion.add"|fn_check_view_permissions} | |
+ {$is_allowed_to_update_posts = "discussion.update"|fn_check_view_permissions} | |
+ {$is_owned_object = $runtime.company_id == $object_company_id} | |
+ {$is_company_reviews = $discussion.object_type == "Addons\Discussion\DiscussionObjectTypes::COMPANY"|enum} | |
+ {$allow_save = $is_allowed_to_update_posts && !($runtime.company_id && (!$is_owned_object || $is_company_reviews))} | |
<div id="content_discussion"> | |
<div class="clearfix"> | |
<div class="buttons-container buttons-bg pull-right"> | |
- {if "discussion.add"|fn_check_view_permissions && !("MULTIVENDOR"|fn_allowed_for && $runtime.company_id && ($runtime.company_id != $object_company_id || $discussion.object_type == 'M'))} | |
- {if $discussion.object_type == "E"} | |
+ {if $is_allowed_to_add_posts && !($runtime.company_id && (!$is_owned_object || $is_company_reviews))} | |
+ {if $discussion.object_type == "Addons\Discussion\DiscussionObjectTypes::TESTIMONIALS_AND_LAYOUT"|enum} | |
{capture name="adv_buttons"} | |
{include file="common/popupbox.tpl" id="add_new_post" title=__("add_post") icon="icon-plus" act="general" link_class="cm-dialog-switch-avail"} | |
{/capture} | |
@@ -16,7 +20,7 @@ | |
{/if} | |
{if $discussion.posts && "discussion_manager"|fn_check_view_permissions} | |
{$show_save_btn = true scope = root} | |
- {if $discussion.object_type == "E"} | |
+ {if $discussion.object_type == "Addons\Discussion\DiscussionObjectTypes::TESTIMONIALS_AND_LAYOUT"|enum} | |
{capture name="buttons_insert"} | |
{/if} | |
{if "discussion.m_delete"|fn_check_view_permissions} | |
@@ -25,7 +29,7 @@ | |
{/capture} | |
{dropdown content=$smarty.capture.tools_list} | |
{/if} | |
- {if $discussion.object_type == "E"} | |
+ {if $discussion.object_type == "Addons\Discussion\DiscussionObjectTypes::TESTIMONIALS_AND_LAYOUT"|enum} | |
{/capture} | |
{/if} | |
{/if} | |
@@ -39,7 +43,7 @@ | |
<div class="posts-container {if $allow_save}cm-no-hide-input{else}cm-hide-inputs{/if}"> | |
{foreach from=$discussion.posts item="post"} | |
- <div class="post-item {if $discussion.object_type == "O"}{if $post.user_id == $user_id}incoming{else}outgoing{/if}{/if}"> | |
+ <div class="post-item {if $discussion.object_type == "Addons\Discussion\DiscussionObjectTypes::ORDER"|enum}{if $post.user_id == $user_id}incoming{else}outgoing{/if}{/if}"> | |
{hook name="discussion:items_list_row"} | |
{include file="addons/discussion/views/discussion_manager/components/post.tpl" post=$post type=$discussion.type} | |
{/hook} | |
@@ -58,4 +62,4 @@ | |
{__("text_enabled_testimonials_notice", ["[link]" => "addons.manage#groupdiscussion"|fn_url])} | |
-{/if} | |
\ No newline at end of file | |
+{/if} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment