TABLE 10-2 CALENDAR.CONF VARIABLES (Continued) Configuration Variable Purpose TODAY_COLOR Color defined for current day when displaying calendar. WEEKEND_COLOR Color defined for weekends when displaying calendar. HOLIDAY_COLOR Color defined for holidays when displaying calendar. GLOBAL_EVENT_COLOR Color defined for global events when displaying calendar. PERSONAL_EVENT_COLOR Color defined for personal events when displaying calendar. SECONDS_PER_DAY Defines amount of seconds per day. USER_DB_URL The fully qualified authentication database URL. $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 calendar.conf file supplied in ch10 direc- tory on the CD-ROM might need to be tailored to your own system’s requirements. Here’s how the current directory structure looks: htdocs ($ROOT_PATH same as %DocumentRoot%) | + home (base intranet application discussed in chapter 7) | | | + templates | | 346 Part II: Developing Intranet Solutions 13 549669 ch10.qxd 4/4/03 9:25 AM Page 346 | + themes (theme templates used by all intranet apps) | + photos (user photos used by all intranet apps) | + calendar_mngr (Intranet Calendar Applications) | + apps (calendar apps and configuration files) | + class (calendar classes) | + templates (publisher HTML templates) | + themes (symlink to %DocumentRoot%/home/templates/themes) By changing the following configuration parameters in calendar.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 = ‘/calendar_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 calendar manager applications are stored in the ch10/apps/calendar.messages file in the CDROM. You can change the messages using a text editor. The errors file The error messages displayed by the calendar manager applications are stored in the ch10/apps/calendar.errors file in the CDROM. You can modify the error messages using a text editor. Chapter 10: Intranet Calendar Manager 347 13 549669 ch10.qxd 4/4/03 9:25 AM Page 347 The Application Templates The HTML interface templates needed for the applications are included in the ch10/apps/templates directory in the CD-ROM. These templates contain various template tags to display necessary information dynamically. The templates are named in the calendar.conf file. These templates are listed in Table 10-3. TABLE 10-3 HTML TEMPLATES Configuration Variable Template File Purpose $STATUS_TEMPLATE calendar_status.html Used to show status message. $CALENDAR_HOME_TEMPLATE calendar_home.html The calendar index template. $CALENDAR_EVENT_TEMPLATE calendar_events.html The calendar event–related template. The Calendar Manager Application This calendar manager application is responsible for displaying an intranet calen- dar page to each user. The application, calendar_mngr.php, is included on the CD-ROM in the ch10/apps directory. It implements the following functionality: ◆ When the user logs in, he is shown a calendar of the current month. ◆ Dates of the month are highlighted and colored according to events scheduled for those days. ◆ The user can use the navigator buttons to browse forward and backward through different months. This application has the following methods: ◆ run(): This method is responsible for running this application. This is how it works: ■ It creates an object of the Theme class called $themeObj and sets it as a member variable. 348 Part II: Developing Intranet Solutions 13 549669 ch10.qxd 4/4/03 9:25 AM Page 348 ■ It finds out the preferred theme for the current user using the getUserTheme() method of the Theme class. ■ It calls displayCalendar() to render the calendar along with all the events and holidays. ◆ authorize(): This method authorizes everyone on the intranet to view the page and, therefore, always returns TRUE. ◆ displayCalendar(): This method displays the calendar to the user. This is how it works: ■ A calendar template ($CALENDAR_HOME_TEMPLATE) is loaded in a tem- plate object called $template. ■ The method checks whether a time stamp has been supplied; if not, the current time stamp is stored in $ts. An array named $date is filled with the information of the time stamp using the getDate() API. ■ A static array $weekDays is declared to store the weekdays and their indexes. ■ For each day of the given time stamp’s month, the events and holidays are retrieved from the database and the configuration file. Holidays and global events are loaded from the calendar.conf file. ■ Each day is also checked if it’s on weekend or not. (The weekend defin- ition is configurable in the calendar.conf file.) ■ Personal events are loaded into an array using the getEvents() method of the Event class. ■ After getting all information of each day, the day of the month is set with events, holidays, weekend, cell color, and so on. If the total num- ber of events to be shown for the day is less than or equal to four, they are set to the corners of the day cell. Otherwise, three corners are filled with the first three events and the fourth corner is set with a link to the other events. ■ After the template is set with all the information for each day of the month, the template is parsed and the output is fed into showContents() to render it to the user. ◆ showContents(): This method is used to display 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. Chapter 10: Intranet Calendar Manager 349 13 549669 ch10.qxd 4/4/03 9:25 AM Page 349 The Calendar Event Manager Application This application, calendar_event_mngr.php, is responsible for managing calendar events. This application is included on the CD-ROM in the ch10/apps directory. The application has the following methods: ◆ run(): This method is responsible for running the application. It works as follows: ■ It creates an object of the Theme class called $themeObj and sets it as a member variable. ■ It finds out the preferred theme for the current user using the getUserTheme() method of the Theme class. ■ It calls displayCalendarEventMngrHome() to show the event manager menu with the given mode (add/modify). ◆ authorize(): This method authorizes everyone on the intranet to view the page and, therefore, always returns TRUE. ◆ displayCalendarEventMngrHome(): This method displays the calendar event manager menu, enabling users to add, delete, and modify calendar events. This is how it works: ■ The mode passed to this method decides which operation to perform. If the mode is add and step is set to 1, it only has to show an empty Web form to take the input from the user. When the step is set to 2, it calls addEvent() to add a new event. ■ If the mode is set to modify with step set as 1, it preloads the Web form with the event’s previous information. When step is set to 2, it calls modifyEvent() to modify the event. ■ When the mode is delete, it calls deleteEvent() to delete the event. ■ It uses the getOwnEvents() method of the Event class to shows a list of the events created by the current user. Each event is followed by a delete link that allows the user to delete the event. There is also a radio button with each event that the user can select to start the modification process. ■ To show the contents of the event manager menu, a calendar event template (CALENDAR_EVENT_TEMPLATE) is loaded in a template object called $template. 350 Part II: Developing Intranet Solutions 13 549669 ch10.qxd 4/4/03 9:25 AM Page 350 . 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 = ‘/calendar_mngr’; $REL_APP_PATH. responsible for displaying an intranet calen- dar page to each user. The application, calendar_mngr .php, is included on the CD-ROM in the ch10/apps directory. It implements the following functionality: ◆ When. 4/4/03 9:25 AM Page 349 The Calendar Event Manager Application This application, calendar_event_mngr .php, is responsible for managing calendar events. This application is included on the CD-ROM in