Forums › Forums › OroCRM › OroCRM – Programming Questions › ACL On export of datagrid
This topic contains 5 replies, has 3 voices, and was last updated by golriz.nourani 6 years, 5 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- August 13, 2016 at 4:30 am #25252
Dear Sir
I set capacity of export false on role management but users with that role can export from data grid.
could you help me?
thanks
Golriz - CreatorTopic
- AuthorReplies
- August 16, 2016 at 2:55 am #25253
As I understand, you want export data from datagrid?
If true, you can use12options:export: truein config datagrid
August 20, 2016 at 12:37 am #25254Dear Abel
I set option of export true for all datagrid but I don’t want all user can get export so I set export capacity of some role false to prevent them get export .
is there any acl of Capabilities for export of datagrid?
thanksAugust 21, 2016 at 7:09 pm #25255Sorry nourani!
I do not have any idea for this problem.
May be someone in oro team can help you :)September 6, 2016 at 4:16 am #25256Hi,
By default capability Export Entities works with Export button at top-right angle of site. You must create new acl resource on your bundle depending on which version of platform you are using. For example <= 1.9 or >=1.10 with category option. My new datagrid export resource is:
YAML12345oro_datagrid_export:label: "Oro Datagrid Export"type: actiongroup_name: ""bindings: ~Further i have modified vendor/oro/platform/src/Oro/Bundle/DataGridBundle/Extension/Export/ExportExtension.php (you must extend this file in your bundle):
PHP12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758<?phpnamespace Oro\Bundle\DataGridBundle\Extension\Export;use Symfony\Component\Translation\TranslatorInterface;use Oro\Bundle\DataGridBundle\Extension\AbstractExtension;use Oro\Bundle\DataGridBundle\Datagrid\Common\MetadataObject;use Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration;use Oro\Bundle\DataGridBundle\Extension\Toolbar\ToolbarExtension;use Oro\Bundle\SecurityBundle\SecurityFacade;class ExportExtension extends AbstractExtension{const EXPORT_OPTION_PATH = '[options][export]';/** @var TranslatorInterface */protected $translator;/** @var SecurityFacade */protected $securityFacade;/*** Constructor** @param TranslatorInterface $translator* @param SecurityFacade $securityFacade*/public function __construct(TranslatorInterface $translator, SecurityFacade $securityFacade){$this->translator = $translator;$this->securityFacade = $securityFacade;}/*** {@inheritDoc}*/public function isApplicable(DatagridConfiguration $config){if ($this->securityFacade->isGranted('oro_datagrid_export') === false) {return false;}// validate configuration and fill default values$options = $this->validateConfiguration(new Configuration(),['export' => $config->offsetGetByPath(self::EXPORT_OPTION_PATH, false)]);// translate labelsforeach ($options as &$option) {$option['label'] = $this->translator->trans($option['label']);}// push options back to config$config->offsetSetByPath(self::EXPORT_OPTION_PATH, $options);return !empty($options);}}After that don’t forget run:
Shell1app/console cache:clear --env=[your environment]and add security facade to your extension:
YAML1- @oro_security.security_facadeNovember 7, 2017 at 5:50 am #25257Hi Mike
Today again I use your guild . I must say thanks a lot.
Golriz - AuthorReplies
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.