Chapter 9: Intranet Contact Manager 319 (Web hosting providers) . displayContactMngrHome():
Chapter 9: Intranet Contact Manager 319 . displayContactMngrHome(): This method shows the administrator home page for the contact manager application. It shows all add, delete, and modify options for contacts and categories. This is how it works: A contact home template (CONTACT_HOME_TEMPLATE) is loaded in a template object called $template. The template includes combo boxes for category, subcategory, and contacts, and add, delete, modify links for both contacts and categories. When the user first comes to this page, she sees the subcategory and contact lists to be empty and the category list loaded with all the parent categories that are retrieved using the getParentCategories() method of category class. After she chooses a main category, the subcategory list loads with that category s subcategories, retrieved using the getSubCategories() method of the Category class. Similarly, all the contacts of a chosen subcategory are shown using the getContactsByCatID() method of the Contact class. Then showContents()is called to render the template with the appropriate theme. . deleteContact(): This method deletes the given contact and all related information such as: e-mails, reminders, keywords, and so on from the database. This is how it works: It checks whether the category ID has been supplied. If not, it returns to previous page and shows an alert message. It finds the MOTDs related to this contact using the getRelatedMOTDs() method of the Contact class, and then uses the deleteMessage() and deleteViewers() methods of the Message class to delete the messages and their viewers. It calls the deleteContact() method of the Contact class to delete the contact. It shows a confirmation message to the user depending on the status of the delete operation. . addContact(): This method s adds new contacts to the database. It works as follows: It creates an associative array with the given values such as first name, last name, phone, address, and so forth. It uses the addContact() method of the Contact class and passes the array as parameter to add the new contact to the contact table.