Attributes such as event ID, user ID, event title, event date, event description, reminder ID, and flag are passed as an associative array to this method.. This is how it works: ■ It tak
Trang 1■ A variable called $valuesis assigned a comma-separated list of all the parameter values
■ A SQL statement, $stmt, is created to insert the new event data into the event table using the member variable ‘fields’(contains attribute names) and $values
■ The SQL statement is executed using $this->dbi->query(), and the result of the query is stored in the $resultobject
■ If the $resultstatus is not okay, the method returns FALSEto indicate
an insert failure Otherwise, it returns the newly created event’s ID by executing a second query
◆ modifyEvent () : This method updates modified event information to the
database Attributes such as event ID, user ID, event title, event date, event description, reminder ID, and flag are passed as an associative array
to this method This is how it works:
■ From the given parameter, all the values that of texttype in the data-base are escaped for characters such as quotation marks and slashes using $this->dbi->quote(addslashes())
■ A SQL statement, $stmt, is created to update the event table using the parameter attributes and values
■ The SQL statement is executed using $this->dbi->query(), and the result of the query is stored in the $resultobject
■ If the $resultstatus is not okay, the method returns FALSEto indicate
an insert failure Otherwise, it returns the newly created event’s ID by executing a second query
◆ addViewer () : This method adds a viewer to a given event This is how it
works:
■ It takes the event ID and an array containing the viewer IDs (users ID)
as a parameter
■ setEventID()is called to set the given event ID
■ It checks whether there is an entry of zeroin the given array If there
is, it means that the event is viewable by all, and only a zero is added
to the viewer table with the given event ID
■ When the array has all the entries greater than zero, each of the array entries is added to the event viewer table with the given event ID
Trang 2◆ event This is how it works:
■ The given event ID is set using setEventID()
■ A statement is prepared to select the repeat mode for a given event from the repetitive event table The statement is stored in a variable named $stmt
■ Using the DBI object $this->dbi, the $stmtstatement is run via the
$this->dbi->query()method in the DBI object, and the result is stored in the $resultvariable
■ If the result set is not empty, the row is fetched using the fetchRow()
method of the DBI object, and REPEAT_MODEis returned from there Otherwise, it returns null
Here are the other methods of this class:
setEventID() Sets the event ID (eid) of the event object It takes the
event ID from the user and, after setting it to member variable ‘eid’, returns the same This setting is not done when the method is called without an event ID
In that case, the previously set event ID is returned
getEventTitle() Returns the title of the given event from the
CALENDAR_EVENTtable It uses loadEventInfo()
to set all the attribute members for the event, and returns the title of the event by getting the value from
$this->EVENT_TITLE This method takes the event
ID as a parameter
getEventDate() Returns the date of the given event from the
CALENDAR_EVENTtable It uses loadEventInfo()
to set all the attribute members for the event, and returns the date of the event by getting the value from $this->EVENT_DATE This method takes the event ID as a parameter
Trang 3Method Description
getEventDesc() Returns the description of the given event from the
CALENDAR_EVENTtable It uses loadEventInfo()
to set all the attribute members for the event, and returns the title of the event by getting the value from
$this->EVENT_DESC This method takes the event
ID as a parameter
getEventReminder() Returns the reminder (MOTD) ID of the given event
from the CALENDAR_EVENTtable It uses
loadEventInfo()to set all the attribute members for the event, and returns the title of the event by getting the value from $this->REMINDER_ID This method takes the event ID as a parameter
deleteEvent() Deletes the event from the CALENDAR_EVENTtable
It takes the event ID as a parameter and returns TRUE
or FALSE, depending on the status of the deletion operation
deleteViewers() Deletes all viewers for a given event It takes the event
ID as a parameter and returns TRUEor FALSE, depending on the status of the deletion operation
addRepeatMode() Adds repeat mode for a given event into the
CALENDAR_REPETITIVE_EVENTStable It takes the event ID and the event mode as parameters and returns TRUEor FALSEdepending on the status of the insertion operation
deleteRepeatMode() Deletes all repeat modes for a given event It takes the
event ID as a parameter and returns TRUEor FALSE
on the success or failure of the deletion operation
The Application Configuration Files
Like all other applications we’ve developed in this book, the intranet calendar man-ager applications also use a standard set of configuration, message, and error files
These files are discussed in the following sections
Trang 4The main configuration file
The primary configuration file for the entire intranet calendar manager is called
calendar.conf Table 10-2 discusses each configuration variable
T ABLE 10-2 CALENDAR.CONFVARIABLES Configuration Variable Purpose
$PEAR_DIR Set to the directory containing the PEAR package;
specifically the DB module needed for
class.DBI.phpin 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, $PHPLIB_DIR, and the
$APP_FRAMEWORK_DIR This path is used with
ini_set()to redefine the php.inientry for
include_pathto include $PATHahead 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 topmost 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-digit language code
$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
Trang 5Configuration Variable Purpose
$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
$EVENT_CLASS Name of the Eventclass file
$MESSAGE_CLASS Name of the Messageclass file This class is
developed for the MOTD application discussed in Chapter 9
$CALENDAR_DB_URL The fully qualified URL for the database used to store
the calendar events
$CALENDAR_EVENT_TBL Name of the calendar event table in the database
$CALENDAR_EVENT_VIEW_TBL Name of the event viewer table in the database
$CALENDAR_EVENT_REPEAT_TBL Name of the event repeat table in the database
$USER_PREFERENCE_TBL Name of the user preference table in the database
$MESSAGE_TBL Name of the MOTD message table in the intranet
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
$CALENDAR_HOME_TEMPLATE Name of the calendar index template file
$CALENDAR_EVENT_TEMPLATE Name of the calendar event details template file
Continued