■ The template file includes a Web form that takes the input for a new event to be added or an old event to be modified. ■ When the method is called with mode modify, it loads the Web form using the getEventTitle(), getEventDesc(), getViewers(), getRepeatMode(), and getEventReminder() methods of the Event class. ■ After setting appropriate blocks and variables of the template, showContents() is called to render the output using the proper theme for the user. ◆ deleteEvent(): This method is responsible for deleting events when requested. This works in the following manner: ■ It creates objects for the Event and Message classes. ■ The message ID (MOTD ID) for the event is retrieved using the getEventReminder() method of the Event class, and fed into the deleteMessage() and deleteViewers() methods of the Message class to delete the message. ■ All entries related to this event are eliminated from the CALENDAR_EVENT_VIEWER and CALENDAR_REPETITIVE_EVENTS tables using the deleteViewers() and deleteRepeatMode() methods of the Event class. ■ After deleting all the related data, the event itself is deleted using the deleteEvent() method of the Event class. ■ Depending on the outcome of the deletion process, a success or fail message is shown to the user. ◆ modifyEvent(): This event modifies a given event. Its functionalities are as follows: ■ It checks whether the option to show the event to other users is turned on. If it’s not, it takes only the current user’s ID to add to the viewer table. ■ It validates the user inputs by checking if the publish date and event title have been supplied. If not, it shows an alert message and returns null. ■ If the event’s reminder option is turned on, it checks for previous mes- sages related to the event ID. If it finds a message, the message is mod- ified using the modifyMessage() method of the Message class. Otherwise, the new message is added using addMessage() and addViewer(). Chapter 10: Intranet Calendar Manager 351 13 549669 ch10.qxd 4/4/03 9:25 AM Page 351 ■ If the event’s reminder option is turned off, all the messages and mes- sage viewers related to the event are deleted using deleteMessage() and deleteViewers(). ■ The event attributes are modified using the modifyEvent() method of the Event class. ■ If the status of the modifyEvent() is successful, the new viewers and repeat mode (if any) are added for the event after deleting the previous ones. ■ The user is shown the appropriate confirmation message on the basis of success or failure of the modification operation. ◆ addEvent(): This method adds a new event to the calendar. It works in the following way: ■ It checks whether the option to show the event to other users is turned on. If it’s not, it takes only the current user’s ID to add to the viewer table. ■ It validates the user inputs by checking if the publish date and event title have been supplied or not. If not, it shows an alert message and returns null. ■ If the event’s reminder option is turned on, a new message is added using the addMessage() and addViewer() methods of the Message class. ■ The event attributes are added into the event table using the addEvent() method of the Event class. ■ If the status of addEvent() is successful, the viewers and repeat mode (if any) are added for the event. ■ The user is shown an appropriate confirmation message on the basis of the success or failure of the insertion operation. ◆ 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 para- meter to this method. ■ After the passed content is set into the contentBlock, it is rendered to the user. 352 Part II: Developing Intranet Solutions 13 549669 ch10.qxd 4/4/03 9:25 AM Page 352 Installing the Event Calendar on Your Intranet The event calendar installation process assumes the following: ◆ You’re using a Linux system with MySQL and Apache server installed. ◆ 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 the example installation steps, I assume that these are installed in the /%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’ve installed the base intranet user home application, the messaging system, and the INTRANET database (see Chapter 7 for details). Here is how you can get your intranet calendar applications up and running: 1. Install intranet calendar database tables. You need to create the CALEN- DAR database. The ch10/sql/calendar.sql file in the CDROM has all the create table scripts needed for the CALENDAR database. The quickest way to create the database is to run the following commands: mysqladmin –u root –p create CALENDAR mysql –u root –p –D CALENDAR < calendar.sql 2. Install intranet calendar applications. Now from the ch10 directory of the CD-ROM, extract ch10.tar.gz in %DocumentRoot%. This will create calendar_mngr in your document root. Configure %DocumentRoot%/cal- endar_mngr/apps/calendar.conf for path and database settings. The applications are installed in the %DocumentRoot%/calendar_mngr/apps directory and the templates are stored in %DocumentRoot%/calendar_mngr/apps/templates. Chapter 10: Intranet Calendar Manager 353 13 549669 ch10.qxd 4/4/03 9:25 AM Page 353 Your MySQL server is hosted on the intranet web server and 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 home.conf file has MySQL database access URLs such as $INTRANET_DB_URL = ‘mysql://root:foobar@localhost/INTRANET’; $CALENDAR_DB_URL = ‘mysql://root:foobar@localhost/CALENDAR’; $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 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’; $CALENDAR_DB_URL = ‘mysql://admin:db123@db.domain.com/CALENDAR’; $USER_DB_URL = ‘mysql://admin:db123@db.domain.com/auth’; 3. Adding the calendar to theme navigation bar. You need to update your theme navigation bar files stored in %DocumentRoot%/themes/%theme%/ home_left_nav.html whenever you add a new application. For example, to update the std_blue theme, you need to update the %DocumentRoot%/ themes/std_blue/ home_left_nav.html file to include the following line in the HTML table: <tr><td width=”100%”><font size=2><a href=”/calendar_mngr/apps/calendar_mngr.php”>Calendar</a></fo nt></td> </tr> This creates a new HTML table row in the left navigation bar. 4. Set file/directory permissions. Make sure you’ve changed file and direc- tory permissions such that your intranet web server can access all the files. After you’ve performed these steps, you’re ready to test your calendar applications. Testing the Event Calendar 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. 354 Part II: Developing Intranet Solutions 13 549669 ch10.qxd 4/4/03 9:25 AM Page 354 Click on the Calendar link in the left navigation bar of your intranet home page or point your web browser to http://yourserver/calendar_mngr/apps/ calendar_mngr.php . This shows you the current month, like the example shown in Figure 10-3. Figure 10-3: The current month calendar. The current day (October 16, in my example) is shown is its own color (orange by default), weekends are shown in gray, and a global event (October 22) is shown in cream color. You can configure these colors using calendar.conf parameters such as define(‘TODAY_COLOR’, ‘FF8800’); define(‘WEEKEND_COLOR’, ‘CCCCCC’); define(‘HOLIDAY_COLOR’, ‘ABCDEF’); define(‘GLOBAL_EVENT_COLOR’, ‘FFCC99’); define(‘PERSONAL_EVENT_COLOR’, ‘dfefcf’); The colors are stored in standard RGB format in hex numbers ranging from 000000 (black) to FFFFFF (white). Adding a new event To add an event, find the appropriate month using the Next or Previous links on the top, and then click on the day of the event. For example, to add an event on July 7, 2003, move forward to July 2003 using the Next button and click on the day (7). After you’ve clicked on a date, a screen similar to the one in Figure 10-4 displays. Chapter 10: Intranet Calendar Manager 355 13 549669 ch10.qxd 4/4/03 9:25 AM Page 355 . 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. the CD-ROM. In the example installation steps, I assume that these are installed in the /%DocumentRoot%/phplib and / %DocumentRoot%/pear directories. Because your installation location for these libraries. the ch10 directory of the CD-ROM, extract ch10.tar.gz in %DocumentRoot%. This will create calendar_mngr in your document root. Configure %DocumentRoot%/cal- endar_mngr/apps/calendar.conf for path