Archive for November, 2007

Chapter 9: Intranet (Web server) Contact Manager 327 Figure 9-5:

Monday, November 26th, 2007

Chapter 9: Intranet Contact Manager 327 Figure 9-5: Adding a new category information. Figure 9-6: Adding a new subcategory (Communication Vendors) under a parent category (Vendors).

326 Part (Web hosting faq) II: Developing Intranet Solutions Because there

Sunday, November 25th, 2007

326 Part II: Developing Intranet Solutions Because there are no contacts entered into the system yet, searching will result in no matches. Before contacts can be added, categories and subcategories have to be created. As an administrative user, you can create categories by clicking on the Contact Manager Admin link in the upper-left of the search interface. The interface shown in Figure 9-4 displays. Figure 9-4: The contact manager administrative interface. From here you can add, modify, and delete categories and contacts. Adding categories To add a new category, click the Add Category link, which brings up an interface as shown in Figure 9-5. Filling out the new category information (name, description) and clicking the Add button creates the new category. Note that first you have to create a primary (parent) category to create a subcategory. Only subcategories hold contact information. The example in Figure 9-5 shows a category called Vendors being created. Create a new subcategory by clicking on the Add Category link from the administrative menu shown in Figure 9-4. Once again you will see a screen like Figure 9-5. Figure 9-6 shows that we are creating a sub-category called Communication Vendors as a sub-category of Vendors.

Chapter 9: Intranet Contact Manager 325 The default

Saturday, November 24th, 2007

Chapter 9: Intranet Contact Manager 325 The default theme template (std_blue) has links to the document publishing application. If you ve installed the document publishing applications anywhere other than %DocumentRoot%/contact_mngr/apps directory (default), you ll need to modify the %DocumentRoot%/themes/ std_blue/home_left_nav.html file. Similarly, you have to modify the other (std_aqua, std_wheat) themes. After you ve performed these steps, you re ready to test your contact manager applications. Testing Contract Manager Log in to your intranet via http://yourserver/index.php or http://yourserver/home/home.php using the user name and password you created in Chapter 6 and tested in Chapter 7. Click on the Contact Manager link in the left navigation bar of your intranet home page or point your web browser to http://yourserver/contact_mngr/ apps/contact_mngr.php after you re logged in to the intranet. This displays the contact search interface, as shown in Figure 9-3. Figure 9-3: Contact manager search interface.

324 Part II: Developing Intranet Solutions Here is

Saturday, November 24th, 2007

324 Part II: Developing Intranet Solutions Here is how you can get your contact manager applications up and running: 1. Install base intranet applications. If you haven t yet installed the base intranet user home application and the messaging system discussed in Chapter 7, you must do so before proceeding further. 2. Install intranet contact database tables. The ch9/sql/contact.sql file in the CDROM can be used to create the CONTACTS database. The quickest way to create this database is to run the following commands: mysqladmin u root p create CONTACTS mysql u root p D CONTACTS < contact.sql 3. Install intranet contact manager applications. From the ch9 directory of the CD-ROM, extract ch9.tar.gz in %DocumentRoot%. This will create contact_mngr in your document root. Configure %DocumentRoot%/ contact_mngr/apps/contact.conf for path and database settings. The applications are installed in the %DocumentRoot%/contact_mngr/apps directory and the templates are stored in %DocumentRoot%/contact_mngr/apps/templates. Your MySQL server is hosted on the intranet web server and, therefore, it can be accessed via localhost. However, if this is not the case, you can easily modify the database URLs in each application s configuration files. For example, the contact.conf file has a MySQL database access URLs such as: $INTRANET_DB_URL= mysql://root:foobar@localhost/INTRANET ; $CONTACT_DB_URL = mysql://root:foobar@localhost/CONTACTS ; $USER_DB_URL = mysql://root:foobar@localhost/auth ; Say your database server is called db.domain.com and the user name and password to access the INTRANET and auth databases (which you will create during this installation process) are admin and db123. You would modify the database access URLs throughout each configuration file as $INTRANET_DB_URL = mysql://admin:db123@db.domain.com/INTRANET ; $CONTACT_DB_URL= mysql://admin:db123@db.domain.com/CONTACTS ; $USER_DB_URL = mysql://admin:db123@db.domain.com auth ; 4. Set file/directory permissions. Make sure you have changed file and directory permissions so that your intranet web server can access all the files.

Chapter 9: Intranet Contact Manager 323 Method Description

Friday, November 23rd, 2007

Chapter 9: Intranet Contact Manager 323 Method Description searchDriver() Controls how search operations are performed on contacts. If step is set to 1 or step is unset, it calls displaySearchMenu() to display the search contact Web form. If step is set to 2, it runs displaySearchResult() to display search output. showContents() Displays the given contents according to the theme preferences of the user. The user s preferred theme template is loaded in a template object called $themeTemplate. The template contains a contentBlock that is to be filled by the parameter to this method. After the passed content is set into the contentBlock, it is rendered to the user. Installing Intranet Contract Manager Here I assume the following: . You re using a Linux system with MySQL and Apache server installed. . You ve followed the instructions in Chapters 5, 6, and 7 to create a base intranet system with user home page applications. . Your intranet web server document root directory is /evoknow/ intranet/htdocs. Of course, if you have a different path, which is likely, you should change this path whenever you see it in a configuration file or instruction in this chapter. During the installation process, I refer to this directory as %DocumentRoot%. . You ve installed the PHPLIB and PEAR library. Normally, these get installed during PHP installation. For your convenience, I ve provided these in the lib/phplib.tar.gz and lib/pear.tar.gz directories on the CD-ROM. In these sample installation steps, I assume that these are installed in %DocumentRoot%/phplib and %DocumentRoot%/pear directories. Because your installation location for these libraries is likely to differ, make sure you replace these paths in the configuration files. . You have installed the INTRANET database (see Chapter 7 for details).

322 Part II: Developing Intranet Solutions Here are (Geocities web hosting)

Friday, November 23rd, 2007

322 Part II: Developing Intranet Solutions Here are the other methods used in this application: Method Description authorize() Authorizes the user access to this application. It authorizes all users only when the cmd value is search, detail, or null. (Other cmds (add/modify/delete) are available only to users with administrative privilege.) It returns TRUE if it finds the cmd to be one of the three. Otherwise, it depends on setUserType() to get the value of the isAdmin variable that identifies whether the user is an administrator or not and returns TRUE or FALSE depending on that value. setUserType() Sets $this->isAdmin to TRUE if the user is an administrator; otherwise, it sets it to FALSE. It checks whether the user has a valid user ID. If she does, it gets the type of the user using the getType() method of the User class. If the type of the user is the same as CONTACT_ADMIN_TYPE, which is taken from the conact.conf, then it sets the isAdmin to TRUE. Otherwise, it sets isAdmin to FALSE. mailDriver() Controls how e-mail operations are performed on contacts. If step is set to 1 or step is unset, it calls displayMailMenu() to show the e-mail input menu. If step is set to 2, it calls mailToContact() to send e-mail to the contact. If step is set to 3, it runs showMail() to display e-mail information. addDriver() Controls how new contacts are created. If step is set to 1 or step is unset, it calls displayAddModifyMenu() with mode as add to display the create contact Web form. If step is set to 2, it runs addContact() to do the contact-creation process. modifyDriver() Controls how modify operations are performed on contacts. If step is set to 1 or step is unset, it calls displayAddModifyMenu() with mode as modify to display the create contact Web form. If step is set to 2, it runs modifyContact() to do the contact creation process.

Jetty web server - Chapter 9: Intranet Contact Manager 321 . displaySearchResult():

Thursday, November 22nd, 2007

Chapter 9: Intranet Contact Manager 321 . displaySearchResult(): This method displays the result of the search performed according to the user s query. The result shows a list of contacts that matches the search criteria. This is how it works: A search result template (CONTACT_SEARCH_RESULT_TEMPLATE) is loaded in a template object called $template. The where clause of the search query is prepared using the information given by the user. The where clause is passed into the searchContact() method of the Contact class to search for the contact. searchContact() returns an array of contacts if it finds a match. The array of contacts is then fed into the contact block of the template. If no match is found, the array is empty, the contact block is set with a message indicating that no match was found. showContents() is called to render the template with the appropriate theme. . displaySearchMenu(): This method displays the contact search Web form as needed. It works as follows: A search input template (CONTACT_SEARCH_INPUT_TEMPLATE) is loaded in a template object called $template. The template includes a Web form to take input such as company name, contact name, subcategory, category, and keywords to search for contacts. The subcategory list is empty until the user chooses a category. showContents() is called to render this template with the appropriate theme. . displayMailMenu(): This method displays the e-mail menu where the user can write her e-mail to send to a contact. This is how it works: A mail template (CONTACT_MAIL_TEMPLATE) is loaded in a template object called $template. The template includes a Web form to take input (CC address, mail subject, mail body, and so forth). The ID of the contact that is the target of this mail is stored as hidden HTML field in this template for later use. showContents()is called to render this template with appropriate theme.

320 Part II: Developing Intranet Solutions It (Web site domain)

Thursday, November 22nd, 2007

320 Part II: Developing Intranet Solutions It adds the keywords for this contact using the addKeywords() method of Contact class. It adds reminder messages in the MOTD table, using the addMessage() and addViewer() methods of the Message class, if there are any reminders for this contact. A reminder entry is also added in the reminder table in this case using addReminder() method of the Contact class. . modifyContact(): This method updates the database with the modified information. It works as follows: It creates an associative array with the given values like contact ID, first name, last name, phone, address, and so on. The array contains all the attributes of the contact table as index and the modified contact information as values to those indexes. It uses the modifyContact() method of the Contact class with this array to add the new contact to the CONTACT_INFO table. It modifies the keywords for this contact using the modifyKeywords() method of the Contact class. It deletes the previous messages from the MESSAGE table in the INTRANET database and previous reminders from the CONTACT_REMINDER table in the CONTACT database using deleteMessage(), deleteViewers(), and deleteRemindersByContactID(). It adds the new reminder messages using the addMessage() and addViewer() methods of the Message class, if there are any reminders for this contact. The new reminder is also added in the CONTACT_REMINDER table in this case using the addReminder() method of the Contact class. . displayAddModifyMenu(): This method displays the add or modify contact Web form, as needed. It works as follows: A contact add/modify template (CONTACT_INFO_ADD_MOD_TEMPLATE) is loaded in a template object called $template. The template includes a Web form to take personal information of the contact, the keywords for the contact, and the reminders for this contact. The template also includes category and subcategory lists from which the user has to choose the appropriate category and subcategory for this contact. The lists are loaded using the getParentCategories() and getSubCategories() methods of the Category class. Then the showContents() method is called to render the template with appropriate theme.

Chapter 9: Intranet Contact Manager 319 (Web hosting providers) . displayContactMngrHome():

Wednesday, November 21st, 2007

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.

Sex offenders web site - 318 Part II: Developing Intranet Solutions The

Wednesday, November 21st, 2007

318 Part II: Developing Intranet Solutions The storeMail() method of the Contact class is used to store the e-mail information that includes the contact ID, CC address, subject of the mail, and mail send time. The PHP s mail API is used to send the e-mail with appropriate headers. The user receives a confirmation after the e-mail is sent successfully. . showMail(): This method displays e-mail information of a previously sent e-mail. This is how it works: A mail content template (CONTACT_MAIL_DETAIL_TEMPLATE) is loaded in a template object called $template. The template contains different blocks for date, mail to, mail CC to, mail subject, mail body, and so forth. These blocks are set with appropriate values retrieved using the getMailDetails() method of the Contact class. The template is parsed and printed to the user. . showDetail(): This method shows detailed information of the given contact. This is how it works: It checks whether the contact ID has been provided. If not, it shows an alert message and returns to previous page. A contact detail template (CONTACT_DETAILS_TEMPLATE) is loaded in a template object called $template. A new contact object is created and stored in $contactObj. The getKeywords() method of the Contact object is used to retrieve the keywords for the given contact and all keywords are stored into an array named $keywordArr. The values of $keywordArr are taken into a string after separating them with commas. This string is set into appropriate blocks in the template later. Reminders for the contact are also retrieved and set in the template. All the attribute values of the CONTACT_INFO table are retrieved using the getColumnValue() method of the Contact object, and are rendered in the template file. The sent e-mails are retrieved using getMails(). Sent e-mails are shown only to users having admin privilege. For non administrative users, this mail block is set to null to hide it from her. showContents() is called to show the output of this template in the preferred theme template of the user.