This is how it works: ■ A search result template CONTACT_SEARCH_RESULT_TEMPLATE is loaded in a template object called $template.. It works as follows: ■ A search input template CONTACT_S
Trang 1◆ displaySearchResult() : This method displays the result of the search
performed according to the user’s query The result shows a list of con-tacts 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 informa-tion given by the user
■ The ‘where’clause is passed into the searchContact()method of the
Contactclass 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 sub-ject, 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
Trang 2Here are the other methods used in this application:
authorize() Authorizes the user access to this application It
authorizes all users only when the cmdvalue is search, detail, or null (Other cmds (add/modify/delete) are available only to users with administrative privilege.) It returns TRUEif it finds the cmdto be one of the three Otherwise, it depends on setUserType()to get the value of the isAdminvariable that identifies whether the user is an administrator or not and returns TRUEor FALSEdepending on that value
setUserType() Sets $this->isAdminto TRUEif 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 isAdminto TRUE Otherwise, it sets isAdminto FALSE
mailDriver() Controls how e-mail operations are performed on
contacts If stepis set to 1or stepis unset, it calls displayMailMenu()to show the e-mail input menu If stepis set to 2, it calls mailToContact()to send e-mail to the contact If stepis set to 3, it runs showMail()to display e-mail information
addDriver() Controls how new contacts are created If stepis set to
1or stepis unset, it calls displayAddModifyMenu() with mode as ‘add’to display the create contact Web form If stepis set to 2, it runs addContact()to do the contact-creation process
modifyDriver() Controls how modify operations are performed on
contacts If stepis set to 1or stepis 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
Trang 3Method Description
searchDriver() Controls how search operations are performed on
contacts If step is set to 1or step is unset, it calls displaySearchMenu() to display the search contact Web form If stepis 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 contentBlockthat 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.gzand lib/pear.tar.gzdirectories on the CD-ROM In these sample installation steps, I assume that these are installed in %DocumentRoot%/phpliband %DocumentRoot%/pear directo-ries 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)
Trang 4Here 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 ch9directory of the CD-ROM, extract ch9.tar.gzin %DocumentRoot% This will create
contact_mngrin your document root Configure %DocumentRoot%/ contact_mngr/apps/contact.conffor 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.conffile 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.comand the user name and password to access the INTRANET and auth databases (which you will cre-ate 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
Trang 5The default theme template ( std_blue ) has links to the document publish-ing application If you’ve installed the document publishpublish-ing 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://yours-erver/home/home.phpusing 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.phpafter 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.