PHPMaker will generate a Copy inline-link when we enable Add permission action. Sometimes we do not want to allow users to copy the existing record for some reasons. Just like the similar trick how to prevent copying records in PHPMaker 9, this following trick below will show you how we can do the same purpose for web applications that generated by PHPMaker 10.
There are some difference between version 9 and 10 regarding the handling of Copy inline-link. Since PHPMaker 10, the Copy link is groupped into OtherOptions, whereas in version 9, it was not being groupped at all. This is the reason why I share this trick to you, so that you can implement it in your web applications that generated by PHPMaker 10.
[hidepost]
- Open your PHPMaker project (.pmp) file using PHPMaker application.
-
Click on your desired table/view, then click on Code (Server Events, Client Scripts and Custom Templates) tab. Expand the Server Events -> Table-Specific -> List Page, and then click on ListOptions_Rendered item/function. In the right pane, just insert the following code into the function:
$this->ListOptions->Items["copy"]->Visible = FALSE;
This will hide the Copy inline-link in the List page.
-
Still in the Server Events, expand the following: Server Events -> Table-Specific -> Common, and then click on the Row_Rendered item/function. In the right pane, just insert the following code into the function:
if (CurrentPageID()=="view") { $this->OtherOptions['action']->Items["copy"]->Body = ""; }This will hide the Copy link in the View page. As you can see, this is the main difference between version PHPMaker version 9 and version 10. Since the Copy link is categorized in OtherOptions group in version 10, then we have to adjust the code which we used in version 9 as follow:
$this->CopyUrl = "";
-
Still in the Server Events, expand the following: Server Events -> Table-Specific -> Add/Copy Page, and then click on the Page_Load item/function. In the right pane, just insert the following code into the function:
if (@$_GET["theparameter"] != "") { // Warning: You have to adjust "theparameter" with yours! $this->setFailureMessage("Sorry, data cannot be copied."); $this->Page_Terminate("yourtableorviewadd.php"); // Warning: You have to adjust "yourtableorviewadd.php" with your related normal add page }This will prevent user to perform Copy action by typing the URL directly. Hiding the Copy inline-link/icon cannot just solve the problem. That’s why you have to handle it also from the Page_Load function in Add/Copy page from the Server Events section. So, make sure you do not miss this step!
[/hidepost]
Leave a Reply
You must be logged in to post a comment.