274 Part II: Developing Intranet Solutions . updateCategory(): (Web hosting company)
274 Part II: Developing Intranet Solutions . updateCategory(): This method is used to update a category in the database. It works as follows: A new category object called $catObj is created. The new category must have required information: name, order, list of users who can publish, and list of users who can view documents published in this category. If any of this information is missing, an alert message is shown and the method returns null. A parameter list, $params, is created with all the database fields for the category. modifyCategory() modifies the category. If the category is modified successfully, deleteCategoryPublishers() and deleteCategoryViewers() are called to remove the existing publisher and viewer user lists. Then addCategoryPublishers() is called to add the current publisher user list to the appropriate category database table, and addCategoryViewers() is called to add the viewer user list for the new category in the database table. showStatusMessage() informs the administrator about the successful creation of the category. Because the modified category needs to be updated in the navigation file used by the home.php application, generateCategoryNavigator() is called to generate a new version of this file that includes the new category. If the category is not modified, a status message informs the administrative user about the failure using the showStatusMessage() method. . generateCategoryNavigator(): This method is used to create the category navigation file needed by the home.php application (discussed in Chapter 7). It works as follows: It creates a new category object $catObj. getCategories() obtains a list of categories and stores it in $categories. The category navigation template is loaded in a template object called $template. If the number of categories is not zero, a maximum number of categories (configured in ld.conf file using CAT_PER_LINE) per line is written as an HTML table row by looping through the list of categories. Each category name is turned into a hyperlink that allows users to click on a category and view the documents available in that category. . displayAddModDocMenu(): This method displays the add or modify document Web form as needed. It works as follows: The user s theme template is loaded into the $themeTemplate object. The add or modify document template called $ADD_MOD_DOC_TEMPLATE (configurable via ld.conf) is loaded in the $template object.