Chapter 13: Tell-a-Friend System 453 displayAddModifyMenu() This method (Web hosting faq)
Chapter 13: Tell-a-Friend System 453 displayAddModifyMenu() This method is used to show the menu for adding or modifying forms. It works as follows: . If the method is called with mode modify, it first checks whether the form ID has been supplied or not. In case of no form ID, the method shows an alert message and returns null. . Otherwise, all the previous information of the given form is retrieved and loaded in variables for later usage, to preload the modification Web form while showing to the user. In this case, the AccessControl object is used to retrieve the authorized and banned IPs for the form. . Then a form setup template (TAF_FRM_SETUP_TEMPLATE) is loaded in a template object called $template. . For loading different message lists in the Web form, the Message object s getAllMessages() is used and then filtered using the AccessControl object s isAccessAllowed() method. . At the end, the template is parsed and printed to the user to give her a Web form to add or modify forms. addModifyForm() This method is used to add or modify forms. It works as follows: . First, it checks whether the date range given for the form (the activation and termination date) is a valid one or not. If not, the method shows an alert message and returns null. . Then it prepares the $params array with all the form field values from the user request. . Then it creates an object of AccessControl to add or modify the access to the form. . When the mode for the method is add the params array is fed into the addForm() method of the Form class to add the new form. If the addition fails, the method shows a failure message and returns. . If the addition operation is successful, the authorized and denied IPs are added to the database using the addAccessIPs() and addDeniedIPs() methods of the AccessControl class. Then a successful addition message is shown to the user. . When the mode for the method is modify, the $params array is fed into the modifyForm() method of the Form class to update the given form. If the update fails, the method shows a failure message.