PHPMaker by default will generate your list pages and view pages that contain a set of "Export to ..." feature for all of those pages (assuming: you selected "Print", "CSV", "HTML", "Excel", "Word", "XML", "PDF", and "Email" from PHP tab -> List/View Page Options (Global) sub-tab -> Export groupbox. Sometimes, you do not want those all pages contain the certain "Export to..." features, or sometimes you want to hide some of those features for the certain pages and or for the certain users.
For example, in the list of customer page, you only want to display the "Export to Excel" feature and you want to hide the others (Export to Word, Export to PDF, Export to HTML, Printer Friendly, Export to CSV, Export to XML, and Send to Email) for users with Operator level, whereas for users with Manager level (for example), only "Export to Excel", "Export to PDF", and "Send to Email", and then for Administrator level, all of those "Export to..." features are enabled or to be shown properly as usual.
So, the question is: How should you do that, so you can define the access permission for "Export to..." features dynamically? Well, now you don't have to worry anymore, as I have successfully created this feature by customizing the PHPMaker template. Now you can define the certain "Export to..." feature for the certain users you want in the generated list and view pages. You can define it from the User Levels page by giving the checked mark that related to its level and page.
Updated on February 28, 2012: Now it also has the ability to prevent users accessing the certain Export by entering URL directly via browser. For example, users which do not have permission to export record to Excel, they will not see the link "Export to Excel" (this is fine), but they still can export records by entering the related URL from the browser directly (this is bad). By implementing this update, then system will automatically prevent such users to access the forbidden export to Excel URL/page.
All we have to do is customizing PHPMaker template files. In other words, we will not customize the generated script files.
Please click on the following image to watch the demo:
[hidepost]
-
Open your C:\Program Files\PHPMaker8\languages\english.xml file, and find this code:
<phrase id="PermissionView" value="View"/>
after that line, insert this following code:
<phrase id="PermissionPrinterFriendly" value="Printer Friendly"/> <phrase id="PermissionExportToHTML" value="Export to HTML"/> <phrase id="PermissionExportToExcel" value="Export to Excel"/> <phrase id="PermissionExportToWord" value="Export to Word"/> <phrase id="PermissionExportToPDF" value="Export to PDF"/> <phrase id="PermissionExportToXML" value="Export to XML"/> <phrase id="PermissionExportToCSV" value="Export to CSV"/> <phrase id="PermissionExportToEmail" value="Export to Email"/>
Do the same way with your another .xml language file. For example, I am also using Indonesian language, so I add those phrases to my indonesian.xml file:
<phrase id="PermissionPrinterFriendly" value="Ramah Cetakan"/> <phrase id="PermissionExportToHTML" value="Ekspor ke HTML"/> <phrase id="PermissionExportToExcel" value="Ekspor ke Excel"/> <phrase id="PermissionExportToWord" value="Ekspor ke Word"/> <phrase id="PermissionExportToPDF" value="Ekspor ke PDF"/> <phrase id="PermissionExportToXML" value="Ekspor ke XML"/> <phrase id="PermissionExportToCSV" value="Ekspor ke CSV"/> <phrase id="PermissionExportToEmail" value="Ekspor ke Email"/>
after this line:
<phrase id="PermissionView" value="Tampilkan"/>
-
Open your /Script/ewcfg.php file that located in your unzip template files, and find this code:
@define("EW_ALLOW_ADMIN", 16, TRUE); // Admin
after that line of code, insert this following code:
// Begin of modification by Masino Sinaga, permission access for Export feature, August 31, 2011 define("EW_ALLOW_EXPORT_TO_PRINT", 128, TRUE); // Printer Friendly define("EW_ALLOW_EXPORT_TO_EXCEL", 256, TRUE); // Export to Excel define("EW_ALLOW_EXPORT_TO_WORD", 512, TRUE); // Export to Word define("EW_ALLOW_EXPORT_TO_HTML", 1024, TRUE); // Export to HTML define("EW_ALLOW_EXPORT_TO_XML", 2048, TRUE); // Export to XML define("EW_ALLOW_EXPORT_TO_CSV", 4096, TRUE); // Export to CSV define("EW_ALLOW_EXPORT_TO_PDF", 8192, TRUE); // Export to PDF define("EW_ALLOW_EXPORT_TO_EMAIL", 16384, TRUE); // Export to Email // End of modification by Masino Sinaga, permission access for Export feature, August 31, 2011
-
Open your /Script/phpfn.php file that located in your unzip template files, and find this code:
function setCanAdmin($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_ADMIN); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_ADMIN)); } }
after the last line of that code, insert this following code:
// Begin of modification by Masino Sinaga, for Restrict Access Permission to "Export" feature, August 31, 2011 // Can export to Print function CanExportToPrint() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_PRINT) == EW_ALLOW_EXPORT_TO_PRINT); } function setCanExportToPrint($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_PRINT); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_PRINT)); } } // Can export to HTML function CanExportToHTML() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_HTML) == EW_ALLOW_EXPORT_TO_HTML); } function setCanExportToHTML($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_HTML); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_HTML)); } } // Can export to Excel function CanExportToExcel() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_EXCEL) == EW_ALLOW_EXPORT_TO_EXCEL); } function setCanExportToExcel($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_EXCEL); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_EXCEL)); } } // Can export to Word function CanExportToWord() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_WORD) == EW_ALLOW_EXPORT_TO_WORD); } function setCanExportToWord($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_WORD); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_WORD)); } } // Can export to PDF function CanExportToPDF() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_PDF) == EW_ALLOW_EXPORT_TO_PDF); } function setCanExportToPDF($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_PDF); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_PDF)); } } // Can export to XML function CanExportToXML() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_XML) == EW_ALLOW_EXPORT_TO_XML); } function setCanExportToXML($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_XML); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_XML)); } } // Can export to CSV function CanExportToCSV() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_CSV) == EW_ALLOW_EXPORT_TO_CSV); } function setCanExportToCSV($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_CSV); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_CSV)); } } // Can export to Email function CanExportToEmail() { return (($this->CurrentUserLevel & EW_ALLOW_EXPORT_TO_EMAIL) == EW_ALLOW_EXPORT_TO_EMAIL); } function setCanExportToEmail($b) { if ($b) { $this->CurrentUserLevel = ($this->CurrentUserLevel | EW_ALLOW_EXPORT_TO_EMAIL); } else { $this->CurrentUserLevel = ($this->CurrentUserLevel & (~ EW_ALLOW_EXPORT_TO_EMAIL)); } } // End of modification by Masino Sinaga, for Restrict Access Permission to "Export" feature, August 31, 2011
-
Open your /Script/add-script.php file that located in your unzip template files, and find this code:
intval($AllowView) + intval($AllowSearch); }
after the last line of that code, insert this following code:
$AllowExportToPrint = @$_POST["x__AllowExportToPrint"]; if ($AllowExportToPrint == "") $AllowExportToPrint = 0; $AllowExportToHTML = @$_POST["x__AllowExportToHTML"]; if ($AllowExportToHTML == "") $AllowExportToHTML = 0; $AllowExportToExcel = @$_POST["x__AllowExportToExcel"]; if ($AllowExportToExcel == "") $AllowExportToExcel = 0; $AllowExportToWord = @$_POST["x__AllowExportToWord"]; if ($AllowExportToWord == "") $AllowExportToWord = 0; $AllowExportToPDF = @$_POST["x__AllowExportToPDF"]; if ($AllowExportToPDF == "") $AllowExportToPDF = 0; $AllowExportToXML = @$_POST["x__AllowExportToXML"]; if ($AllowExportToXML == "") $AllowExportToXML = 0; $AllowExportToCSV = @$_POST["x__AllowExportToCSV"]; if ($AllowExportToCSV == "") $AllowExportToCSV = 0; $AllowExportToEmail = @$_POST["x__AllowExportToEmail"]; if ($AllowExportToEmail == "") $AllowExportToEmail = 0; $this->Priv = $this->Priv + intval($AllowExportToPrint) + intval($AllowExportToHTML) + intval($AllowExportToExcel) + intval($AllowExportToWord) + intval($AllowExportToPDF) + intval($AllowExportToXML) + intval($AllowExportToCSV) + intval($AllowExportToEmail);
-
Still in the add-script.php file, find again this code:
<label><input type="checkbox" name="x__AllowAdd" id="Add" value="<?php echo EW_ALLOW_ADD ?>" /><!--##@PermissionAddCopy##--></label> <label><input type="checkbox" name="x__AllowDelete" id="Delete" value="<?php echo EW_ALLOW_DELETE ?>" /><!--##@PermissionDelete##--></label>> <label><input type="checkbox" name="x__AllowEdit" id="Edit" value="<?php echo EW_ALLOW_EDIT ?>" /><!--##@PermissionEdit##--></label> <?php if (defined("EW_USER_LEVEL_COMPAT")) { ?> <label><input type="checkbox" name="x__AllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>" /><!--##@PermissionListSearchView##--></label> <?php } else { ?> <label><input type="checkbox" name="x__AllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>" /><!--##@PermissionList##--></label> <label><input type="checkbox" name="x__AllowView" id="View" value="<?php echo EW_ALLOW_VIEW ?>" /><!--##@PermissionView##--></label> <label><input type="checkbox" name="x__AllowSearch" id="Search" value="<?php echo EW_ALLOW_SEARCH ?>" /><!--##@PermissionSearch##--></label>
then replace it with this following code:
<label><input type="checkbox" name="x__AllowAdd" id="Add" value="<?php echo EW_ALLOW_ADD ?>" /><!--##@PermissionAddCopy##--></label><br /> <label><input type="checkbox" name="x__AllowDelete" id="Delete" value="<?php echo EW_ALLOW_DELETE ?>" /><!--##@PermissionDelete##--></label><br /> <label><input type="checkbox" name="x__AllowEdit" id="Edit" value="<?php echo EW_ALLOW_EDIT ?>" /><!--##@PermissionEdit##--></label><br /> <?php if (defined("EW_USER_LEVEL_COMPAT")) { ?> <label><input type="checkbox" name="x__AllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>" /><!--##@PermissionListSearchView##--></label><br /> <?php } else { ?> <label><input type="checkbox" name="x__AllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>" /><!--##@PermissionList##--></label><br /> <label><input type="checkbox" name="x__AllowView" id="View" value="<?php echo EW_ALLOW_VIEW ?>" /><!--##@PermissionView##--></label><br /> <label><input type="checkbox" name="x__AllowSearch" id="Search" value="<?php echo EW_ALLOW_SEARCH ?>" /><!--##@PermissionSearch##--></label><br />
-
Still in the add-script.php file, find again this code:
<label><input type="checkbox" name="x__AllowSearch" id="Search" value="<?php echo EW_ALLOW_SEARCH ?>" /><!--##@PermissionSearch##--></label><br /> <?php } ?>
after the last line of that code, insert this following code:
<?php // Begin of modification by Masino Sinaga, for restric "Export", August 31, 2011 ?> <label><input type="checkbox" name="x__AllowExportToPrint" id="Print" value="<?php echo EW_ALLOW_EXPORT_TO_PRINT ?>" /><!--##@PermissionPrinterFriendly##--></label><br /> <label><input type="checkbox" name="x__AllowExportToExcel" id="Excel" value="<?php echo EW_ALLOW_EXPORT_TO_EXCEL ?>" /><!--##@PermissionExportToExcel##--></label><br /> <label><input type="checkbox" name="x__AllowExportToWord" id="Word" value="<?php echo EW_ALLOW_EXPORT_TO_WORD ?>" /><!--##@PermissionExportToWord##--></label><br /> <label><input type="checkbox" name="x__AllowExportToHTML" id="HTML" value="<?php echo EW_ALLOW_EXPORT_TO_HTML ?>" /><!--##@PermissionExportToHTML##--></label><br /> <label><input type="checkbox" name="x__AllowExportToXML" id="XML" value="<?php echo EW_ALLOW_EXPORT_TO_XML ?>" /><!--##@PermissionExportToXML##--></label><br /> <label><input type="checkbox" name="x__AllowExportToCSV" id="CSV" value="<?php echo EW_ALLOW_EXPORT_TO_CSV ?>" /><!--##@PermissionExportToCSV##--></label><br /> <label><input type="checkbox" name="x__AllowExportToPDF" id="PDF" value="<?php echo EW_ALLOW_EXPORT_TO_PDF ?>" /><!--##@PermissionExportToPDF##--></label><br /> <label><input type="checkbox" name="x__AllowExportToEmail" id="Email" value="<?php echo EW_ALLOW_EXPORT_TO_EMAIL ?>" /><!--##@PermissionExportToEmail##--></label><br /> <?php // Begin of modification by Masino Sinaga, for restric "Export", August 31, 2011 ?>
-
Open your /Script/share-script.php file that located in your unzip template files, and find this code:
global $Language, $<!--##=gsTblVar##-->; // Printer friendly $item =& $this->ExportOptions->Add("print"); $item->Body = <!--##=sExportPrintUrl##--> . <!--##=sPrinterFriendlyCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bPrinterFriendly)##-->; // Export to Excel $item =& $this->ExportOptions->Add("excel"); $item->Body = <!--##=sExportExcelUrl##--> . <!--##=sExportToExcelCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportExcel)##-->; // Export to Word $item =& $this->ExportOptions->Add("word"); $item->Body = <!--##=sExportWordUrl##--> . <!--##=sExportToWordCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportWord)##-->; <!--## If CTRL.CtrlID = "list" Or CTRL.CtrlID = "view" Then ##--> // Export to Html $item =& $this->ExportOptions->Add("html"); $item->Body = <!--##=sExportHtmlUrl##--> . <!--##=sExportToHtmlCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportHtml)##-->; // Export to Xml $item =& $this->ExportOptions->Add("xml"); $item->Body = <!--##=sExportXmlUrl##--> . <!--##=sExportToXmlCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportXml)##-->; // Export to Csv $item =& $this->ExportOptions->Add("csv"); $item->Body = <!--##=sExportCsvUrl##--> . <!--##=sExportToCsvCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportCsv)##-->; // Export to Pdf $item =& $this->ExportOptions->Add("pdf"); $item->Body = <!--##=sExportPdfUrl##--> . <!--##=sExportToPdfCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportPDF)##-->; // Export to Email $item =& $this->ExportOptions->Add("email"); <!--## If CTRL.CtrlID = "list" Then ##--> $item->Body = "<a name=\"emf_<!--##=gsTblVar##-->\" id=\"emf_<!--##=gsTblVar##-->\" href=\"javascript:void(0);\" onclick=\"ew_EmailDialogShow({lnk:'emf_<!--##=gsTblVar##-->',hdr:ewLanguage.Phrase('ExportToEmail'),f:<!--##=sJsFormName##-->,sel:<!--##=ew_JsVal(bExportSelectedOnly)##-->});\">" . <!--##=sExportToEmailCaption##--> . "</a>"; <!--## End If ##--> $item->Visible = <!--##=ew_Val(bExportEmail)##-->; <!--## End If ##-->
then replace it with this following code:
global $Language, $Security, $<!--##=gsTblVar##-->; // Printer friendly if ($Security->CanExportToPrint() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("print"); $item->Body = <!--##=sExportPrintUrl##--> . <!--##=sPrinterFriendlyCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bPrinterFriendly)##-->; } // Export to Excel if ($Security->CanExportToExcel() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("excel"); $item->Body = <!--##=sExportExcelUrl##--> . <!--##=sExportToExcelCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportExcel)##-->; } // Export to Word if ($Security->CanExportToWord() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("word"); $item->Body = <!--##=sExportWordUrl##--> . <!--##=sExportToWordCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportWord)##-->; } <!--## If CTRL.CtrlID = "list" Or CTRL.CtrlID = "view" Then ##--> // Export to Html if ($Security->CanExportToHTML() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("html"); $item->Body = <!--##=sExportHtmlUrl##--> . <!--##=sExportToHtmlCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportHtml)##-->; } // Export to Xml if ($Security->CanExportToXML() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("xml"); $item->Body = <!--##=sExportXmlUrl##--> . <!--##=sExportToXmlCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportXml)##-->; } // Export to Csv if ($Security->CanExportToCSV() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("csv"); $item->Body = <!--##=sExportCsvUrl##--> . <!--##=sExportToCsvCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportCsv)##-->; } // Export to Pdf if ($Security->CanExportToPDF() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("pdf"); $item->Body = <!--##=sExportPdfUrl##--> . <!--##=sExportToPdfCaption##--> . "</a>"; $item->Visible = <!--##=ew_Val(bExportPDF)##-->; } // Export to Email if ($Security->CanExportToEmail() || $Security->IsAdmin() ) { $item =& $this->ExportOptions->Add("email"); <!--## If CTRL.CtrlID = "list" Then ##--> $item->Body = "<a name=\"emf_<!--##=gsTblVar##-->\" id=\"emf_<!--##=gsTblVar##-->\" href=\"javascript:void(0);\" onclick=\"ew_EmailDialogShow({lnk:'emf_<!--##=gsTblVar##-->',hdr:ewLanguage.Phrase('ExportToEmail'),f:<!--##=sJsFormName##-->,sel:<!--##=ew_JsVal(bExportSelectedOnly)##-->});\">" . <!--##=sExportToEmailCaption##--> . "</a>"; <!--## ElseIf CTRL.CtrlID = "view" Then ##--> $item->Body = "<a name=\"emf_<!--##=gsTblVar##-->\" id=\"emf_<!--##=gsTblVar##-->\" href=\"javascript:void(0);\" onclick=\"ew_EmailDialogShow({lnk:'emf_<!--##=gsTblVar##-->',hdr:ewLanguage.Phrase('ExportToEmail'),key:" . ew_ArrayToJsonAttr($this->RecKey) . ",sel:false});\">" . <!--##=sExportToEmailCaption##--> . "</a>"; <!--## End If ##--> $item->Visible = <!--##=ew_Val(bExportEmail)##-->; } <!--## End If ##-->
-
Open your /Script/userpriv.php file that located in your unzip template files, and find this code:
for ($i = 0; $i < $this->TableNameCount; $i++) { if (defined("EW_USER_LEVEL_COMPAT")) { $this->Privileges[$i] = intval(@$_POST["Add_" . $i]) + intval(@$_POST["Delete_" . $i]) + intval(@$_POST["Edit_" . $i]) + intval(@$_POST["List_" . $i]); } else { $this->Privileges[$i] = intval(@$_POST["Add_" . $i]) + intval(@$_POST["Delete_" . $i]) + intval(@$_POST["Edit_" . $i]) + intval(@$_POST["List_" . $i]) + intval(@$_POST["View_" . $i]) + intval(@$_POST["Search_" . $i]); } }
then replace it with this following code:
for ($i = 0; $i < $this->TableNameCount; $i++) { if (defined("EW_USER_LEVEL_COMPAT")) { $this->Privileges[$i] = intval(@$_POST["Add_" . $i]) + intval(@$_POST["Delete_" . $i]) + intval(@$_POST["Edit_" . $i]) + intval(@$_POST["List_" . $i]) + intval(@$_POST["Printer_" . $i]) + intval(@$_POST["HTML_" . $i]) + intval(@$_POST["Excel_" . $i]) + intval(@$_POST["Word_" . $i]) + intval(@$_POST["PDF_" . $i]) + intval(@$_POST["XML_" . $i]) + intval(@$_POST["CSV_" . $i]) + intval(@$_POST["Email_" . $i]); } else { $this->Privileges[$i] = intval(@$_POST["Add_" . $i]) + intval(@$_POST["Delete_" . $i]) + intval(@$_POST["Edit_" . $i]) + intval(@$_POST["List_" . $i]) + intval(@$_POST["View_" . $i]) + intval(@$_POST["Search_" . $i]) + intval(@$_POST["Printer_" . $i]) + intval(@$_POST["HTML_" . $i]) + intval(@$_POST["Excel_" . $i]) + intval(@$_POST["Word_" . $i]) + intval(@$_POST["PDF_" . $i]) + intval(@$_POST["XML_" . $i]) + intval(@$_POST["CSV_" . $i]) + intval(@$_POST["Email_" . $i]); } }
-
Still in the userpriv.php file, find again this code:
<td><!--##@PermissionSearch##--><input type="checkbox" name="Search" id="Search" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->Disabled ?> /></td> <?php } ?>
after the last line of that code, insert this following code:
<?php // Begin of modification by Masino Sinaga, for permission "Export", August, 31, 2011 // ?> <td><!--##@PermissionPrinterFriendly##--><input type="checkbox" name="Printer" id="Printer" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToExcel##--><input type="checkbox" name="Excel" id="Excel" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToWord##--><input type="checkbox" name="Word" id="Word" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToHTML##--><input type="checkbox" name="HTML" id="HTML" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToXML##--><input type="checkbox" name="XML" id="XML" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToCSV##--><input type="checkbox" name="CSV" id="CSV" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToPDF##--><input type="checkbox" name="PDF" id="PDF" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@PermissionExportToEmail##--><input type="checkbox" name="Email" id="Email" onclick="ew_SelectAll(this);"<?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><!--##@TableOrView##--></td> <?php // End of modification by Masino Sinaga, for permission "Export", August, 31, 2011 // ?>
-
Still in the userpriv.php file, find again this code:
<td align="center"><input type="checkbox" name="Search_<?php echo $i ?>" id="Search_<?php echo $i ?>" value="64"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_SEARCH) == EW_ALLOW_SEARCH) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->Disabled ?> /></td> <?php } ?>
after the last line of that code, insert this following code:
<?php // Begin of modification by Masino Sinaga, for permission "Export", August, 31, 2011 // ?> <td align="center"><input type="checkbox" name="Printer_<?php echo $i ?>" id="Printer_<?php echo $i ?>" value="128"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_PRINT) == EW_ALLOW_EXPORT_TO_PRINT) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="Excel_<?php echo $i ?>" id="Excel_<?php echo $i ?>" value="256"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_EXCEL) == EW_ALLOW_EXPORT_TO_EXCEL) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="Word_<?php echo $i ?>" id="Word_<?php echo $i ?>" value="512"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_WORD) == EW_ALLOW_EXPORT_TO_WORD) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="HTML_<?php echo $i ?>" id="HTML_<?php echo $i ?>" value="1024"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_HTML) == EW_ALLOW_EXPORT_TO_HTML) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="XML_<?php echo $i ?>" id="XML_<?php echo $i ?>" value="2048"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_XML) == EW_ALLOW_EXPORT_TO_XML) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="CSV_<?php echo $i ?>" id="CSV_<?php echo $i ?>" value="4096"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_CSV) == EW_ALLOW_EXPORT_TO_CSV) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="PDF_<?php echo $i ?>" id="PDF_<?php echo $i ?>" value="8192"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_PDF) == EW_ALLOW_EXPORT_TO_PDF) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td align="center"><input type="checkbox" name="Email_<?php echo $i ?>" id="Email_<?php echo $i ?>" value="16384"<?php if (($<!--##=sPageObj##-->->TempPriv & EW_ALLOW_EXPORT_TO_EMAIL) == EW_ALLOW_EXPORT_TO_EMAIL) { ?> checked="checked"<?php } ?><?php echo $<!--##=sPageObj##-->->sDisabled ?> /></td> <td><span class="phpmaker"><?php echo $<!--##=sPageObj##-->->GetTableCaption($i) ?></span></td> <?php // End of modification by Masino Sinaga, for permission "Export", August, 31, 2011 // ?>
-
Open your /Script/phpcommon-scripts.php file, and find this code:
$Charset = (EW_CHARSET <> "") ? ";charset=" . EW_CHARSET : ""; // Charset used in header
after that line, please insert the following code:
// Begin of modification by Masino Sinaga, To prevent users entering from URL, February 28, 2012 if ($gsExport=="print") { if (!$Security->CanExportToPrint()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="excel") { if (!$Security->CanExportToExcel()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="word") { if (!$Security->CanExportToWord()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="html") { if (!$Security->CanExportToHTML()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="csv") { if (!$Security->CanExportToCSV()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="xml") { if (!$Security->CanExportToXML()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="pdf") { if (!$Security->CanExportToPDF()) { echo $Language->Phrase("nopermission"); exit(); } } elseif ($gsExport=="email") { if (!$Security->CanExportToEmail()) { echo $Language->Phrase("nopermission"); exit(); } } // End of modification by Masino Sinaga, To prevent users entering from URL, February 28, 2012
Make sure you don't miss this step, as this will prevent users that do not have permission for the certain "export" to enter the URL directly from the browser.
- Finally, re-generate your script files using PHPMaker application as usual.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.