-
-
Save esimonetti/831d0c7a8c94739040c91b943d0a6aa4 to your computer and use it in GitHub Desktop.
Allow Cases editing on portal. Test with: patch -p1 --dry-run < ../allow_cases_edit_portal.diff Install with: patch -p1 < ../allow_cases_edit_portal.diff
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 -auNwBr -x cache -x upload -x config.php -x config_override.php -x 'uk_UA*' -x 'tr_TR*' -x 'sv_SE*' -x 'sr_RS*' -x 'sq_AL*' -x 'sk_SK*' -x 'ru_RU*' -x 'ro_RO*' -x 'pt_PT*' -x 'pt_BR*' -x 'pl_PL*' -x 'nl_NL*' -x 'nb_NO*' -x 'lv_LV*' -x 'ko_KR*' -x 'ja_JP*' -x 'it_it*' -x 'hu_HU*' -x 'he_IL*' -x 'fr_FR*' -x 'fi_FI*' -x 'et_EE*' -x 'es_LA*' -x 'es_ES*' -x 'en_UK*' -x 'el_EL*' -x 'de_DE*' -x 'da_DK*' -x 'cs_CZ*' -x 'ca_ES*' -x 'bg_BG*' -x 'ar_SA*' -x 'lt_LT*' -x 'zh_TW*' -x 'zh_CN*' -x 'th_TH*' -x 'hr_HR*' '--ignore-matching-lines=// created: ' '--ignore-matching-lines=//created: ' -x '*.php_1*' -x '*.ext.php' -x '*blowfish*' -x .gitignore -x .gitattributes -x .htaccess -x '*.DS_Store' -x '*.git*' -x vendor -x '*.log' -x '*.zip' -x '*.sql' -x '*.tgz' -x '*.md' -x '*.filepart' -x config.js -x working -x modulebuilder sugarMango/custom/clients/portal/api/CustomCurrentUserPortalApi.php sugar/custom/clients/portal/api/CustomCurrentUserPortalApi.php | |
--- sugarMango/custom/clients/portal/api/CustomCurrentUserPortalApi.php 1970-01-01 10:00:00.000000000 +1000 | |
+++ sugar/custom/clients/portal/api/CustomCurrentUserPortalApi.php 2019-08-27 05:55:33.272765489 +1000 | |
@@ -0,0 +1,24 @@ | |
+<?php | |
+ | |
+class CustomCurrentUserPortalApi extends CurrentUserPortalApi | |
+{ | |
+ protected $modulesToAllowEdit = [ | |
+ 'Cases', | |
+ ]; | |
+ | |
+ protected function enforceModuleACLs(array $acls) | |
+ { | |
+ $parentAcls = parent::enforceModuleACLs($acls); | |
+ | |
+ foreach ($this->modulesToAllowEdit as $modName) { | |
+ // check the original ACL to see if edit of the module is allowed by the role | |
+ if ((empty($acls[$modName]['edit']) || $acls[$modName]['edit'] === 'yes') | |
+ && $parentAcls[$modName]['edit'] === 'no') { | |
+ // allow editing even if suppressed by the parent method | |
+ unset($parentAcls[$modName]['edit']); | |
+ } | |
+ } | |
+ | |
+ return $parentAcls; | |
+ } | |
+} | |
diff -auNwBr -x cache -x upload -x config.php -x config_override.php -x 'uk_UA*' -x 'tr_TR*' -x 'sv_SE*' -x 'sr_RS*' -x 'sq_AL*' -x 'sk_SK*' -x 'ru_RU*' -x 'ro_RO*' -x 'pt_PT*' -x 'pt_BR*' -x 'pl_PL*' -x 'nl_NL*' -x 'nb_NO*' -x 'lv_LV*' -x 'ko_KR*' -x 'ja_JP*' -x 'it_it*' -x 'hu_HU*' -x 'he_IL*' -x 'fr_FR*' -x 'fi_FI*' -x 'et_EE*' -x 'es_LA*' -x 'es_ES*' -x 'en_UK*' -x 'el_EL*' -x 'de_DE*' -x 'da_DK*' -x 'cs_CZ*' -x 'ca_ES*' -x 'bg_BG*' -x 'ar_SA*' -x 'lt_LT*' -x 'zh_TW*' -x 'zh_CN*' -x 'th_TH*' -x 'hr_HR*' '--ignore-matching-lines=// created: ' '--ignore-matching-lines=//created: ' -x '*.php_1*' -x '*.ext.php' -x '*blowfish*' -x .gitignore -x .gitattributes -x .htaccess -x '*.DS_Store' -x '*.git*' -x vendor -x '*.log' -x '*.zip' -x '*.sql' -x '*.tgz' -x '*.md' -x '*.filepart' -x config.js -x working -x modulebuilder sugarMango/custom/data/acl/SugarACLPortal.php sugar/custom/data/acl/SugarACLPortal.php | |
--- sugarMango/custom/data/acl/SugarACLPortal.php 1970-01-01 10:00:00.000000000 +1000 | |
+++ sugar/custom/data/acl/SugarACLPortal.php 2019-08-27 05:55:33.272765489 +1000 | |
@@ -0,0 +1,33 @@ | |
+<?php | |
+ | |
+use Sugarcrm\Sugarcrm\Portal\Factory as PortalFactory; | |
+ | |
+class CustomSugarACLPortal extends SugarACLPortal | |
+{ | |
+ protected $modulesToAllowEdit = [ | |
+ 'Cases', | |
+ ]; | |
+ | |
+ protected function portalAccess($module, $action, &$context) | |
+ { | |
+ $accessGranted = parent::portalAccess($module, $action, $context); | |
+ if (PortalFactory::getInstance('Session')->isActive()) { | |
+ | |
+ // get the bean or return false | |
+ $bean = $context['bean'] ?? BeanFactory::newBean($module); | |
+ if (!$bean) { | |
+ return false; | |
+ } | |
+ | |
+ // if it is on our list of modules, allow editing | |
+ if (in_array($bean->module_name, $this->modulesToAllowEdit)) { | |
+ // allow editing as well as create for this module, if the role allows it | |
+ if ($action === 'edit' || $action === 'save') { | |
+ return true; | |
+ } | |
+ } | |
+ } | |
+ | |
+ return $accessGranted; | |
+ } | |
+} | |
diff -auNwBr -x cache -x upload -x config.php -x config_override.php -x 'uk_UA*' -x 'tr_TR*' -x 'sv_SE*' -x 'sr_RS*' -x 'sq_AL*' -x 'sk_SK*' -x 'ru_RU*' -x 'ro_RO*' -x 'pt_PT*' -x 'pt_BR*' -x 'pl_PL*' -x 'nl_NL*' -x 'nb_NO*' -x 'lv_LV*' -x 'ko_KR*' -x 'ja_JP*' -x 'it_it*' -x 'hu_HU*' -x 'he_IL*' -x 'fr_FR*' -x 'fi_FI*' -x 'et_EE*' -x 'es_LA*' -x 'es_ES*' -x 'en_UK*' -x 'el_EL*' -x 'de_DE*' -x 'da_DK*' -x 'cs_CZ*' -x 'ca_ES*' -x 'bg_BG*' -x 'ar_SA*' -x 'lt_LT*' -x 'zh_TW*' -x 'zh_CN*' -x 'th_TH*' -x 'hr_HR*' '--ignore-matching-lines=// created: ' '--ignore-matching-lines=//created: ' -x '*.php_1*' -x '*.ext.php' -x '*blowfish*' -x .gitignore -x .gitattributes -x .htaccess -x '*.DS_Store' -x '*.git*' -x vendor -x '*.log' -x '*.zip' -x '*.sql' -x '*.tgz' -x '*.md' -x '*.filepart' -x config.js -x working -x modulebuilder sugarMango/custom/Extension/modules/Cases/Ext/clients/portal/views/record/edit_save_button.php sugar/custom/Extension/modules/Cases/Ext/clients/portal/views/record/edit_save_button.php | |
--- sugarMango/custom/Extension/modules/Cases/Ext/clients/portal/views/record/edit_save_button.php 1970-01-01 10:00:00.000000000 +1000 | |
+++ sugar/custom/Extension/modules/Cases/Ext/clients/portal/views/record/edit_save_button.php 2019-08-27 05:57:27.810010100 +1000 | |
@@ -0,0 +1,48 @@ | |
+<?php | |
+ | |
+$buttons = [ | |
+ [ | |
+ 'type' => 'button', | |
+ 'name' => 'cancel_button', | |
+ 'label' => 'LBL_CANCEL_BUTTON_LABEL', | |
+ 'css_class' => 'btn-invisible btn-link', | |
+ 'showOn' => 'edit', | |
+ 'events' => [ | |
+ 'click' => 'button:cancel_button:click', | |
+ ], | |
+ ], | |
+ [ | |
+ 'type' => 'rowaction', | |
+ 'event' => 'button:save_button:click', | |
+ 'name' => 'save_button', | |
+ 'label' => 'LBL_SAVE_BUTTON_LABEL', | |
+ 'css_class' => 'btn btn-primary', | |
+ 'showOn' => 'edit', | |
+ 'acl_action' => 'edit', | |
+ ], | |
+ [ | |
+ 'type' => 'actiondropdown', | |
+ 'name' => 'main_dropdown', | |
+ 'primary' => true, | |
+ 'showOn' => 'view', | |
+ 'buttons' => [ | |
+ [ | |
+ 'type' => 'rowaction', | |
+ 'event' => 'button:edit_button:click', | |
+ 'name' => 'edit_button', | |
+ 'label' => 'LBL_EDIT_BUTTON_LABEL', | |
+ 'primary' => true, | |
+ 'acl_action' => 'edit', | |
+ ], | |
+ ], | |
+ ], | |
+ [ | |
+ 'name' => 'sidebar_toggle', | |
+ 'type' => 'sidebartoggle', | |
+ ], | |
+]; | |
+ | |
+$module = 'Cases'; | |
+$targetView = 'record'; | |
+ | |
+$viewdefs[$module]['portal']['view'][$targetView]['buttons'] = $buttons; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment