Chapter 13: Tell-a-Friend System 455 . When the (Mac os x web server)

Chapter 13: Tell-a-Friend System 455 . When the $cmd is add or modify, it calls the addModifyDriver() method with the appropriate mode (add or modify). . And when the $cmd is delete, it calls the deleteForm() method to delete the form. authorize() This method checks whether the IP address (where the user is accessing the application from) is an authorized one. This is how it works: . This application allows everyone to add messages. So when the request $cmd is add, it directly returns true. . In case of modify and delete, the AccessControl object is used to verify whether the request IP is allowed to access the given message. It returns TRUE or FALSE depending on the verification result. addModifyDriver() This method is responsible for driving the add/modify procedure. Depending on the hidden form value $step, it decides whether to call the add/modify menu rendering method, displayAddModifyMenu(), or the add/modify method, addModifyMessage(). Both the methods are called with proper mode (add or modify). displayAddModifyMenu() This method is used to show the Web form for adding or modifying forms. It works as follows: . If the method is called with mode modify, it first checks whether the message ID has been supplied or not. In case of no message ID, the method shows an alert message and returns null. . Otherwise, all the previous information of the given message 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 IPs for the message. . Then a message setup template (TAF_MSG_SETUP_TEMPLATE) is loaded in a template object called $template. . The different form fields required for adding or modifying a message are prepared. . At the end, the template is parsed and printed to the user to give her a Web form to add or modify messages.

Leave a Reply