Chapter 8: Intranet Simple (Web hosting ratings) Document Publisher 271 .
Chapter 8: Intranet Simple Document Publisher 271 . modifyCategory(): This method controls how categories are modified. It works as follows: If the step=NULL and cid (category ID) query parameter is not empty, displayAddModCategoryMenu() is called with the Modify parameter, which loads the category information referred by $cid and allows the user to modify it. If the method is called without a cid (category ID), an error alert is shown. If step=2 parameter is passed, the document is updated using the updateCategory() method. . storeDoc(): This method adds a document in the database. It works as follows: If the method is called with empty category ID ($cid) but a new category name ($cat), it creates the new category using a category object and retrieves the new category s ID using the getCategoryIDByName() method of the new category object. It creates a new document object called $docObj. It checks to see if there is a category ID ($cid) and whether or not the required document parts (subject called $heading and contents called $body) are provided. If any of this required information is missing, the method shows an alert message and returns null. It extracts the month, day, and year of the document s publish date ($pub_date), which has been supplied from the Web form. The publishing date is verified to be a future date using the checkDate() function. If it is not a future date, an alert message is shown to inform the user that documents cannot have a past publication date, and the method returns null. The current hour, second, and minutes are stored in $curHr, $curSec, and $curMin variables using the date() function. A parameter list array called $params is constructed using all the database fields needed to create the document, which is passed to the addDoc() method to create the document. If the addDoc() method of the document object returns TRUE, the document is added and a screen showing the success message is constructed using showStatusMessage(). To announce the new document, a Message object is created. The addMessage() method of the Message class (from Chapter 7) is used add the new document announcement message to appropriate viewers using the addViewer() of the Message object. If the document could not be added, a status message shows the failure notice.