Make Copy button ACL dependent ?

lcollong

FabriKant d'applications web
Hi,

We'd like to allow the Form's copy button available only to some group of users (Access level dependent). There is nothing available in the form's setup AFAIK.

I've created a Button Element to overcome these situation as it is possible to make the element ACL dependent. But I had difficulties to find the right js to fire a copy event.

Reading the sources, I've found a "poor solution" : rename the button before fire it ! Here is my code in the js tab under the "click" event :

JavaScript:
var form = Fabrik.getBlock('form_2');
this.name="Copy";
form.mockSubmit('Copy');

It works. But is there any better/reliable solution ?
 
Well, that's one way to do it. The button must be named "Copy", as we have code in the form processing that checks to see if "Copy" is in the submitted form data, to trigger a copy.

The only other way would be to customize a form template, and modify default_buttons.php, around line 26, wrap some code around where we echo the copy button.

Code:
if (in_array(123, $this->user->getAuthorisedViewLevels())) :
                    echo $form->copyButton;
endif;


-- hugh
 
Indeed. I thought to such solution but it's moving some kind of "M/C" in the "V" of the MVC model :) . From a maintenance point of view, it sounds better to set all the ACL setup within the same place (Fabrik Back-end). One may forget the existence of such a condition in a view template usually dealing with already authorized "bits".
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top