Security while executing Master Detail Page

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

Security while executing Master Detail Page

Post 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.


jmvf
User
Posts: 1

Post 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.


mobhar
User
Posts: 11727

Post 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.


dsingh
User
Posts: 166

Post 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


mobhar
User
Posts: 11727

Post by mobhar »

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


dsingh
User
Posts: 166

Post 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 } ?>
});


mobhar
User
Posts: 11727

Post 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";


Post Reply