[Vtigercrm-developers] Vtiger 7 allow users to only edit some fields but not all
Alan Lord
alanslists at gmail.com
Thu Aug 30 12:24:08 GMT 2018
On 28/08/18 13:00, IT-Solutions4You wrote:
> But in Setting there is no possible set up this scenario:
>
> >In invoice module I want to allow userts to
> > insert products but after save the invoice I want to dissallow them
> > to delete or insert another product.
>
Sounds like you will need to create your own custom action which shows
up in the "Tools" section of the Profile where Import, Export, Merge
etc. are located.
Then you can enable or disable access to "Modify Inventory Post
Creation" (or whatever you want to call it) on a per Profile basis.
You'd obviously then need to implement some security checking in the
record model to determine if the user is able to do this action, then
modify the View/Layout to control the users' ability to actually modify
the line item part of the layout.
It's non-trivial, but doable.
I wrote a custom "Tool" for a Contract module to let certain users
create a "Renewal Contract" which is a bit like a duplication but has
some specific requirements to erase some fields, and modify dates of
others. This is a bit simpler in scope than yours but it required
Profile level control and works.
HTH
Al
This is the code I used to register this new Tool.
> $module = Vtiger_Module::getInstance('LSContracts');
>
> $actionName = 'RenewContract';
>
> echo "Registering $actionName Action..." . PHP_EOL;
>
> // Remove first if already there
> $module->disableTools($actionName);
> $adb->pquery('DELETE FROM vtiger_actionmapping
> WHERE actionname=?', array($actionName));
>
> // Now add
> $maxActionIdresult = $adb->pquery('SELECT max(actionid+1) AS actionid FROM vtiger_actionmapping',array());
> if($adb->num_rows($maxActionIdresult)) {
> $actionId = $adb->query_result($maxActionIdresult, 0, 'actionid');
> }
> $adb->pquery('INSERT INTO vtiger_actionmapping
> (actionid, actionname, securitycheck) VALUES(?,?,?)',array($actionId,$actionName,0));
> $module->enableTools($actionName);
>
> echo "Disable the Renew Contract action for all Profiles except Admin..." . PHP_EOL;
> $query = "UPDATE vtiger_profile2utility
> SET permission = 1
> WHERE profileid != 1
> AND activityid = $actionId";
> echo "Running Query: $query" . PHP_EOL;
> $adb->query($query);
>
> echo "Done." . PHP_EOL;
More information about the vtigercrm-developers
mailing list