Archive for November, 2007

Web hosting directory - Chapter 9: Intranet Contact Manager 317 Method Description

Wednesday, November 21st, 2007

Chapter 9: Intranet Contact Manager 317 Method Description addDriver() Controls how add operations are performed on contacts and categories. If step is set to 1 or is unset, it calls displayAddModifyMenu() with an add parameter to display the new category Web form. If step is set to 2, it runs addCategory() to start the category-creation process. deleteContactsByCatID() Deletes all contacts for the given category. All information related to the contacts is also deleted. It takes the category ID as the parameter and uses the getContactsByCatID() and deleteContact() methods of the Contact class to find and delete the contacts, respectively. The Contact Manager Application The application contact_mngr.php is responsible for managing contacts. This application is included on the CD-ROM in the ch9/apps directory. Let s take a look at its methods: . run(): When the application is run, this method is called. It decides which functionality is requested by the user and calls the appropriate driver method to perform the desired operations: Creates a theme object, $this->themeObj. The current user s theme choice is stored in $this->theme by calling the getUserTheme() method of the theme object created. Remembers, themes are part of the intranet as they allow users see the intranet pages in a certain look and feel. It decides which method to call depending on the value of cmd. If no cmd is specified, it calls searchDriver() to show the search menu. . mailToContact(): This method gets e-mail information for the given contact, such as e-mail address, CC To, subject, body, and so forth, and sends e-mail to the contact. This is how it works: It checks whether the e-mail body has been supplied or not. If not, it shows an alert message and takes the user back to the previous page.

Free web hosting services - 316 Part II: Developing Intranet Solutions It

Tuesday, November 20th, 2007

316 Part II: Developing Intranet Solutions It prepares an associative array with the necessary attribute name and the values to update the category table. The array is passed into the modifyCategory() method of the Category class. The status (success/failure) of the modify operation is shown to the user at the end. . showContents(): This method displays the given contents according to the theme preferences of the user. This is how it works: 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. The following are the other methods used by this application: Method Description authorize() Authorizes access to this application. It calls setUserType() to set the member variable isAdmin and returns the value of isAdmin. This means that only users only with administrative authority can access this application. deleteDriver() Controls how delete operations are performed on categories. If step is set to 1 or is not set, it calls displayDeleteOptions() to display delete options. If step is set to 2, it runs deleteCategory() to do the category-deletion process. modifyDriver() Controls how modify operations are performed on documents and categories. If step is set to 1 or is unset, it calls displayAddModifyMenu() with a modify parameter to display the modify category Web form. If step is set to 2, it runs modifyCategory() to start the category modification process.

Chapter 9: Intranet Contact Manager 315 . displayDeleteOptions(): (Msn web hosting)

Tuesday, November 20th, 2007

Chapter 9: Intranet Contact Manager 315 . displayDeleteOptions(): This method is used to display deletion options (a deletion options page that contains two radio buttons and a list box/combo box) to the user. This is how it works: It checks whether there is a category ID supplied to the method. If there is no category ID, it shows an alert message and returns to the previous page. A delete option menu template ($CONTACT_CAT_DEL_OPT_TEMPLATE) is loaded in a template object called $template. This template includes a Web form with two radio buttons. One of the buttons is to delete all subcategories and contacts under the selected category. The other button is to transfer all its subcategories and contacts to some other category (to be selected from a combo box). If the category to be deleted is a parent category, then the combo box is loaded with all of the other parent categories. If the category to be deleted is a subcategory, then the combo box is loaded with the subcategories that fall under the subcategory s parent. The contents of the $template object are inserted into the $themeTemplate object s content block, and the results are printed on user s browser screen. . displayAddModifyMenu(): This method displays the add or modify category Web form as needed. It works as follows: An add modify menu template ($CONTACT_CAT_ADD_MOD_TEMPLATE) is loaded in a template object called $template. The template includes a Web form that takes input such as category name, category description, and category hierarchy (parent/sub). The list of parent categories becomes enabled when the user chooses the category to be a parent category. Finally, the contents of the $template object are inserted into the $themeTemplate object s content block and the results are printed on the user s browser screen. . modifyCategory(): This method is used to modify a given category. It works as follows: It checks whether there is category ID supplied to the method. If there is no category ID, it shows an alert message and returns to the previous page. If the request is to change a parent category to a subcategory, this method denies that if the parent (main) category already has subcategories (we re limited to one level of subcategory). Under this circumstance, it shows an alert method and takes the administrator back to previous page.

314 Part II: Developing Intranet Solutions Creates (Professional web hosting)

Monday, November 19th, 2007

314 Part II: Developing Intranet Solutions Creates a theme object, $this->themeObj. The current user s theme choice is stored in $this->theme by calling the getUserTheme() method of the theme object created. Next, the appropriate driver is called according to the $cmd value. For example, if the $cmd is set to add , then addDriver() is called. . setUserType(): This method sets $this->isAdmin to TRUE if the user is administrator; otherwise, it sets it to FALSE. Here is how it works: It checks whether the user has a valid user ID. If she does, then 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 contact.conf, then it sets the isAdmin as TRUE. Otherwise, it sets isAdmin as False. . deleteCategory(): This method controls how categories are deleted. It works as follows: If del_opt is set to 1, it deletes the category and everything related to that category, including subcategories and contacts, from the database. If del_opt is set to 2, then siblings or children of this category are assigned to the new given parent and only the category information is deleted. Whatever del_opt is, this method shows the appropriate confirmation message at the end of the operation. . addCategory(): This method adds a new category or subcategory to the database. If it s adding a subcategory, it assigns a parent to the category. This is how it works: It checks whether the new category to be added is a parent or a subcategory. If it is chosen to be a subcategory, the method finds out the parent category for the category. Then it prepares an associative array with the necessary attribute name and the values to add the category to the CONTACT_CATEGORY table. The parent category ID is set to 0 if the new category is a parent; otherwise, the parent category ID that has been specified is set. The array is passed into the addCategory() method of the category class. The status (success/failure) of the add operation is shown to the user at the end.

Web hosting solutions - Chapter 9: Intranet Contact Manager 313 Configuration Variable

Monday, November 19th, 2007

Chapter 9: Intranet Contact Manager 313 Configuration Variable Template File Purpose $CONTACT_CAT_HOME_ contact_cat_home.html Category index template. TEMPLATE $CONTACT_INFO_ADD_ contact_info_add_ Web form template to MOD_TEMPLATE mod.html add or modify contacts. $CONTACT_CAT_ADD_ contact_cat_add_ Web form template to MOD_TEMPLATE mod.html add or modify categories. $CONTACT_DETAILS_ Contact_details.html Contact details template. TEMPLATE $CONTACT_SEARCH_ contact_search_ Shows the search INPUT_TEMPLATE input.html options. $CONTACT_SEARCH_ contact_search_ Shows the search output. RESULT_TEMPLATE result.html $REMINDER_MSG_TEMPLATE reminder_contents.html Shows the reminder. $CONTACT_MAIL_TEMPLATE contact_mail.html Takes input for the mail to contact. $CONTACT_MAIL_ contact_mail_ Shows details of each of DETAIL_TEMPLATE detail.html the sent mails. The Contact Category Manager Application The application contact_category_mngr.php is responsible for managing contact categories. This application is included on the CD-ROM in the ch9/apps directory. It implements the following functionality: . Allows administrative users to create, modify, and delete categories. . Does not allow non-administrative users to create, modify, or delete categories. This application has the following methods: . run(): When the application is run, this method is called. It decides which functionality is requested by the user and calls the appropriate driver method to perform the desired operations:

Web server logs - 312 Part II: Developing Intranet Solutions By changing

Sunday, November 18th, 2007

312 Part II: Developing Intranet Solutions By changing the following configuration parameters in contact.conf, you can modify the directory structure to fit your site requirements: $APP_FRAMEWORK_DIR=$_SERVER[ DOCUMENT_ROOT ] . /framework ; $PEAR =$_SERVER[ DOCUMENT_ROOT ] . /pear ; $PHPLIB =$_SERVER[ DOCUMENT_ROOT ] . /phplib ; $ROOT_PATH = $_SERVER[ DOCUMENT_ROOT ]; $REL_ROOT_PATH = /contact_mngr ; $REL_APP_PATH = $REL_ROOT_PATH . /apps ; $REL_PHOTO_DIR = /photos ; $PHOTO_DIR = $ROOT_PATH . $REL_PHOTO_DIR; $TEMPLATE_DIR = $ROOT_PATH . $REL_APP_PATH . /templates ; $THEME_TEMPLATE_DIR = $TEMPLATE_DIR . /themes ; $CLASS_DIR = $ROOT_PATH . $REL_APP_PATH . /class ; $REL_TEMPLATE_DIR = $REL_APP_PATH . /templates/ ; The messages file The messages displayed by the contact manager applications are stored in the ch9/apps/contact.messages file in the CDROM. You can change the messages using a text editor. The errors file The error messages displayed by the contact manager applications are stored in the ch9/apps/contact.errors file in the CDROM. You can modify the error messages using a text editor. The Application Templates The HTML interface templates needed for the contact manager system applications are included on the CD-ROM. These templates contain various template tags to display necessary information dynamically. They are named in the contact.conf file. These templates are discussed in Table 9-3. TABLE 9-3 HTML TEMPLATES Configuration Variable Template File Purpose $STATUS_TEMPLATE contact_status.html Shows status message. $CONTACT_HOME_TEMPLATE contact_home.html Contact index template.

Apache web server tutorial - Chapter 9: Intranet Contact Manager 311 Variable Purpose

Sunday, November 18th, 2007

Chapter 9: Intranet Contact Manager 311 Variable Purpose $DEFAULT_THEME The default theme index in the $THEME_TEMPLATE array. $USER_DEFAULTS A user s theme and auto tip default settings. $TIP_SCRIPT The name of the tip script. $TIP_URL The Web-relative path for the tip files. $MAX_AVAILABLE_TIP The maximum number of tips from which to display the tip. $THEME_TEMPLATE[x] The list of theme templates $PRINT_TEMPLATE[x] The list of print templates associated with the theme templates. The directory structure used in the contact.conf file (in the ch09 directory on the CD-ROM) may need to be tailored to your own system s requirements. Here is how the current directory structure looks: +—htdocs ($ROOT_PATH == %DocumentRoot%) | +—home (base intranet application discussed in chapter 7) | | | +–templates | | | +—themes (theme templates used by all intranet apps) | +—photos (user photos used by all intranet apps) | +—contact_mngr (Intranet Contact Manager Application) | +—apps (contact manager apps and configuration files) | +—class (contact manager apps and configuration) | +—templates (contact manager HTML templates) | +—themes (symbolic link to home/templates/themes)

310 Part II: Developing Intranet Solutions TABLE 9-2 (Web host)

Saturday, November 17th, 2007

310 Part II: Developing Intranet Solutions TABLE 9-2 THE CONTACT.CONF VARIABLES (Continued) Variable Purpose $CONTACT_CATEGORY_TBL Name of the category table in the database. $CONTACT_INFO_TBL Name of the contact info table in the database. $CONTACT_KEYWORD_TBL Name of the contact keyword table in the database. $USER_PREFERENCE_TBL Name of the user preference table in the intranet database. $MESSAGE_TBL Name of the MOTD message table in the intranet database. $CONTACT_MAIL_TBL Name of the contact mail table in the database. $MSG_VIEWER_TBL Name of the message viewer list table in the intranet database. $AUTH_DB_TBL Name of the user authentication table in the auth database. $STATUS_TEMPLATE Name of the status template file used to display status messages. $CONTACT_HOME_TEMPLATE Name of the contact index template file. $CONTACT_CAT_HOME_TEMPLATE Name of the contact category index template file. $CONTACT_INFO_ADD_MOD_TEMPLATE Name of the add/modify contact entry form template file. $CONTACT_CAT_ADD_MOD_TEMPLATE Name of the add/modify category entry form template file. $CONTACT_DETAILS_TEMPLATE Name of the contact details template file. ODD_COLOR Color defined for odd rows when displaying tabular data. EVEN_COLOR Color defined for even rows when displaying tabular data. USER_DB_URL The fully qualified authentication database URL.

Chapter 9: Intranet Contact Manager 309 Variable Purpose (Web design templates)

Friday, November 16th, 2007

Chapter 9: Intranet Contact Manager 309 Variable Purpose $ROOT_PATH Set to the root path of the application. $REL_ROOT_PATH Relative path to the root directory. $REL_APP_PATH Relative application path as seen from the web browser. $TEMPLATE_DIR The fully qualified path to the template directory. $THEME_TEMPLATE_DIR The fully qualified path to the theme template directory. $REL_PHOTO_DIR The Web-relative path to the photo directory used to store user photos. $PHOTO_DIR The fully qualified path to the photo directory. $DEFAULT_PHOTO Name of the default photo file, which is used when a user does not have a photo in the photo directory. $CLASS_DIR The fully qualified path to the class directory. $REL_TEMPLATE_DIR The Web-relative path to the template directory used. $CATEGORY_CLASS Name of the Category class file. $CONTACT_CLASS Name of the Contact class file. $MESSAGE_CLASS Name of the Message class file. This class was developed for the MOTD application discussed in Chapter 8. $CONTACT_MNGR Name of the application that shows the index page of the application with the contact search menu. $CONTACT_CAT_MNGR Name of the application that manipulates all functions related to contact category. $INTRANET_DB_URL The fully qualified URL for the database used to MOTD information. $CONTACT_DB_URL The fully qualified URL for the database used to store the contacts and categories. Continued

308 Part II: Developing Intranet Solutions The Application (Email web hosting)

Friday, November 16th, 2007

308 Part II: Developing Intranet Solutions The Application Configuration Files Like all other applications we ve developed in this book, the intranet contact manager applications also use a standard set of configuration, message, and error files. These files are discussed in the following sections. The main configuration file The primary configuration file for the contact manager is called contact.conf. Table 9-2 discusses each configuration variable. TABLE 9-2 THE CONTACT.CONF VARIABLES Variable Purpose $PEAR_DIR Set to the directory containing the PEAR package; specifically the DB module needed for class.DBI.php in our application framework. $PHPLIB_DIR Set to the PHPLIB directory, which contains the PHPLIB packages; specifically the template.inc package needed for template manipulation. $APP_FRAMEWORK_DIR Set to our application framework directory. $PATH Set to the combined directory path consisting of the $PEAR_DIR, the $PHPLIB_DIR, and the $APP_FRAMEWORK_DIR. This path is used with the ini_set() method to redefine the php.ini entry for include_path to include $PATH ahead of the default path. This allows PHP to find our application framework, PHPLIB, and PEAR-related files. $AUTHENTICATION_URL Set to the central login application URL. $LOGOUT_URL Set to the central logout application URL. $HOME_URL Set to the top-most URL of the site. If the URL redirection application does not find a valid URL in the e-campaign database to redirect to for a valid request, it uses this URL as a default. $APPLICATION_NAME Internal name of the application. $DEFAULT_LANGUAGE Set to the default two-character language code.