Allowed or Disallowed in Master/Detail

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
nadimsia
User
Posts: 31

Allowed or Disallowed in Master/Detail

Post by nadimsia »

How I can allow or disallow the user follow to their info, for add/edit Master/Details.
For example:
Table A (Master) have link to Table B (Detail). I want the user only can add/edit (Detail) Table B when current user info 'unit' are same with unit in Table A.

Table A
year
unit

Table B
sales
month
total

Table User
user : John
unit : KL

user : Samatha
unit : WS


arbei
User
Posts: 9288

Post by arbei »

You can grant the permission of the user to the table in TablePermission_Loaded Server Event.

Read the example in help file topic: "Server Events and Client Scripts" -> "TablePermission_Loaded" for your information.


nadimsia
User
Posts: 31

Post by nadimsia »

I already put this code :

function TablePermission_Loaded() {
if (CurrentUserInfo('unit') == "KL" && CurrentTable()->TableName = "Table A")
$this->setCanEdit(TRUE);
}

But username "Samatha" from unit "WS", still can access data on 'Table A'.


mobhar
User
Posts: 11660

Post by mobhar »

Then simply try this:

function TablePermission_Loaded() {
if (CurrentUserInfo('unit') == "KL" && CurrentTable()->TableName = "Table A") {
$this->setCanEdit(TRUE);
} elseif (CurrentUserInfo('unit') == "WS" && CurrentTable()->TableName = "Table A") {
$this->setCanEdit(FALSE);
}
}


nadimsia
User
Posts: 31

Post by nadimsia »

Thank to arbei and mobhar.

How about If we want to disallowed the user filter by the "unit", not to go next page "Detail".

Example:
Currently User John from unit 'KL' open table A (Master) and the data list as below:
Table A
year = '2017'
unit = 'WS'

So user John cannot go to next page (Cannot click the button Details to Table B), but only Samatha from unit 'WS' can go to next page (Can click the button Detail).
And also not only the user John but others user from unit 'KL' also cannot click the button details page, only unit 'WS' can do so.
.
Likewise, the opposite.


mobhar
User
Posts: 11660

Post by mobhar »

Then you may simply use "Row_Selected" server event. Just add your criteria that suits your needs, and if you don't want to access the next record/page for that current user based on that criteria, then you may simply redirect your user to your desired page by using the following code:

header("Location: yourpage.php");
exit;


Post Reply