Page 1 of 1

Security while executing Master Detail Page

Posted: Sun Apr 28, 2019 6:31 pm
by dsingh

Hi, Friends

I am testing a demo by creating a Master Detail Relationship (PHPmaker).

Master Table (having these fields)
ID | Fruit_Name | Fruit_Code |

Detail Table (having these fields)
ID | Fruit_Name | Fruit_Code| Qty | Rate | Amount |

It is working too.

But i want that the detail table can be accessed only through master table. It cannot be accessed directly (i.e list page of the detail table cannot be accessed directly by url) it can only be accessed by master route.

Please suggest how to accomplish this.


Re: Security while executing Master Detail Page

Posted: Sun Apr 28, 2019 11:08 pm
by jmvf

Hi. You only need to disable the generation of code for the detail table. I mean that you can unmark in the menu editor the option of the menu corresponding to the detail table and thus you can only access it from the master table.


Re: Security while executing Master Detail Page

Posted: Tue Apr 30, 2019 10:27 am
by mobhar

Hiding the menu item that belongs to the detail table List page will not solve the security issue. Imagine when your end-users know the actual link of that single detail table List page.

So, the closest approach for this is by checking whether the List Page of your detail table contains the master table or not by using $this->getCurrentMasterTable() in "Page_Render" server event; if it does not contain its master table, then just redirect to the List Page of your master table.


Re: Security while executing Master Detail Page

Posted: Wed May 01, 2019 4:41 am
by dsingh

thanks, but when i tried using page_render server event, it didn't worked.

here is the code:

// Page Render event
function Page_Render() {
//echo "Page Render";
if ($this->getCurrentMasterTable()!=="MASTER_TABLE") {
$this->Page_Terminate("MASTER_TABLELIST.php");
}
}

here is the error when directly accessing the detail page:

PHP Fatal error: Uncaught Error: Call to undefined method PHPMaker2019\Salary\Detail_Page_list::Page_Terminate() in C:\inetpub\wwwroot\HR\classes\Detail_Page_list.php:7355
Stack trace:
#0 C:\inetpub\wwwroot\HR\Detail_Pagelist.php(32): PHPMaker2019\Salary\Detail_Page_list->Page_Render()
#1 {main}
thrown in C:\inetpub\wwwroot\HR\classes\Detail_Page_list.php on line 7355


Re: Security while executing Master Detail Page

Posted: Wed May 01, 2019 9:43 am
by mobhar

Because there is no more "Page_Terminate" again in v2019. Please use "terminate" instead.


Re: Security while executing Master Detail Page

Posted: Wed May 01, 2019 12:50 pm
by dsingh

It worked ..!! thanks

I have tried using client side also , it also worked nicely. here is the code:-

(document).ready(function() {
<?php if (CurrentPage()->getCurrentMasterTable()!=="MASTER_TABLE") {?>
$(location).attr("href","MASTER_TABLELIST.PHP");
<?php } ?>
});


Re: Security while executing Master Detail Page

Posted: Mon May 06, 2019 9:49 am
by mobhar

Alternatively, this code:
$(location).attr("href","MASTER_TABLELIST.PHP");

can also be like this (for safety reason; just in case someone-else overrode the location variable):
window.location.href = "MASTER_TABLELIST.PHP";