Archive for October, 2007

Chapter 8: Intranet Simple Document Publisher 275 (Web server iis)

Wednesday, October 31st, 2007

Chapter 8: Intranet Simple Document Publisher 275 A category object called $catObj is created. If the user has supplied the category name using a query parameter ($cat), the selected category name is used to retrieve the category ID ($selCid) using getCategoryIDbyName() of the $catObj Category object. The list of categories stored in $categories is used to populate an HTML drop-down list, but the user is not allowed to change the chosen category, so the menu is disabled. The publication date is stored as the current date using date( m/d/Y ,mktime()). If the $nid query parameter, which is used to signify that the user is modifying an existing document (as $nid represent document ID), is not empty, the chosen document is loaded into the Web form using a document object called $docObj. Note that if multiple documents are selected by the user, an alert message is shown to inform the user that only a single document can be modified at any time. Unlike add, in case of modify the $categories list is used to create the HTML drop-down list, but this time the user is allowed to change the current category of the document. Therefore, the menu is not disabled. Finally, the user is presented with the filled out template with document data, which is embedded in the user s theme template. . displayAddModCategoryMenu(): This method is responsible for displaying the add or modify category Web form. It works as follows: It creates a theme template object called $themeTemplate and a template object called $template. These templates are populated with various template key=values. It creates a category object called $cObj and retrieves the order of the categories in $lastOrder using the getHighestOrder() method. If the method is called with a category ID ($cid), the method checks to see if more than one category is chosen. In case of more than one, it shows an alert message to state that only one category can be modified at any time and returns null. In case a single category ID is provided in $cid, a new category object, $catObj, is used to get the publishers ($publishers) and viewers ($viewers) using the getPublishers() and getViewers() methods, respectively. A DBI object called $authDBI is created to point to the central user database (USER_DB_URL). A user object called $userObj is created using the $authDBI object the database reference. A list of current users is retrieved in $users using the getUserList() method of the $ userObj object.

274 Part II: Developing Intranet Solutions . updateCategory(): (Web hosting company)

Wednesday, October 31st, 2007

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.

Chapter 8: Intranet Simple Document Publisher 273 list (Remote web server)

Tuesday, October 30th, 2007

Chapter 8: Intranet Simple Document Publisher 273 list for the new category in the database table. A status message is shown using showStatusMessage() to inform the administrator about the successful creation of the category. Because the new category needs to be added to the navigation file used by home.php application, generateCategoryNavigator() is called to generate a new version of this file that includes the new category. If the new category is not added, showStatusMessage() informs the administrative user about the failure. . updateDoc(): This method updates a document. Here s how it works: 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 the $curHr, $curSec, $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 modifyDoc() method to modify the document. If the modifyDoc() method of the document object returns TRUE status, the document is added, and a screen showing the success message is constructed using showStatusMessage(). To announce the document modification, a Message object is created. The addMessage() method of the Message class (from Chapter 7) is used to 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.

272 Part (Web server application) II: Developing Intranet Solutions . displayReorderMenu():

Tuesday, October 30th, 2007

272 Part II: Developing Intranet Solutions . displayReorderMenu(): This method is used to display the category reordering Web form. It works as follows: It creates a template object to display the Web form on the browser. A category object called $catObj is created to get the list of available categories using the getCategories() method. The current order of categories is obtained using getHighestOrder(). Using a loop, the template tags are replaced to populate the Web form to show the categories and allow the user to change the category order. . updateOrders(): This method is used to update the order of the categories. It works as follows: First, it checks to see if the order information passed as a query parameter from the Web form has no duplicates. It uses array_unique() to return a list of unique elements in the query parameter $order, which stores the category order given by the user. The result of array_unique() is passed to count() function to count the number of elements in the array. If the count is smaller than the count of the $order array (with possible duplication), an alert message is shown and the method returns null. If $order is a unique list of category order, a category object called $catObj is created. It calls updateCategoryOrders() to update the category order per user-supplied information. A status message is displayed using showStatusMessage(). Because category ordering has changed, the navigation file needed by home.php (used in Chapter 7 to display intranet home for each user) is updated using generateCategoryNavigator(). . storeCategory(): This method is used to store a category in the database. It works as follows: A new category object called $catObj is created. The new category must have the required information: name, order, list of users who can publish, and list of users who can view documents to be published in the 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. addCategory() adds the new category. If the new category is added successfully, addCategoryPublishers() is called to add the publisher user list to the appropriate category database table, and addCategoryViewers() is called to add the viewer user

Chapter 8: Intranet Simple (Web hosting ratings) Document Publisher 271 .

Tuesday, October 30th, 2007

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.

Web hosting compare - 270 Part II: Developing Intranet Solutions . addDriver():

Monday, October 29th, 2007

270 Part II: Developing Intranet Solutions . addDriver(): This method controls how add operations are performed on documents and categories. It works as follows: If the obj=doc query parameter is passed to this method when called, it calls addDoc() to start the document creation process. If the obj=category query parameter is passed, it runs addCategory() to start the category creation process. . modifyDriver(): This method controls how modify operations are performed on documents and categories. It works as follows: If the obj=doc query parameter is passed to this method when called, it calls modifyDoc() to start the document modification process. If the obj=category query parameter is passed, it runs modifyCategory() to start the category modification process. . addDoc(): This method controls how a new document is added. It works as follows: If the step=NULL query parameter is passed, it calls the displayAddModDocMenu() method with add parameter to display the new document Web form. If the step=2 query parameter is passed, storeDoc() is called to store the new document. . modifyDoc(): This method controls how documents are modified. It works as follows: If the step=NULL and nid (document ID) query parameter is not empty, displayAddModDocMenu() is called with a Modify parameter, which loads the document referred by $nid and allows the user to modify it. If the method is called without an nid (document ID), an error alert is shown. If step=2 parameter is passed, the document is updated using updateDoc(). . addCategory(): This method controls how a new category is added. It works as follows: If step=NULL query parameter is passed, it calls the displayAddMod CategoryMenu() method with the add parameter to display the new category Web form. If step=2 query parameter is passed, storeCategory() is called to store the new category.

Shared web hosting - Chapter 8: Intranet Simple Document Publisher 269 Here

Monday, October 29th, 2007

Chapter 8: Intranet Simple Document Publisher 269 Here are the methods in this application: . run(): When the application is run, this method is called. It decides which functionality is requested by the user and calls the appropriate driver method to perform the desired operations. Here s how it works: Creates a theme object, $this->themeObj. The current user s theme choice is stored in $this->theme by calling the getUserTheme() method of the theme object created. If the application is called with the cmd=del query parameter, deleteDriver() is run. Similarly, cmd=add calls addDriver(), cmd=mod calls modifyDriver(), and cmd=reo calls reorderDriver(). . reorderDriver(): This method is used to change the order of the categories in the system. Categories can be displayed in navigation displayed by the home.php (discussed in Chapter 7) in the given order set by this method. In addition, when the categories are listed in the document index page, the order of each category is determined by order information stored in the database. This method allows you to change the order. It is called when cmd=reo is passed as a query parameter to the application. Here is how it works: The method checks to see if the application is being run by an administrator. If it isn t, the method returns a null. The reordering of categories requires that first the user is given a chance to set the order and then apply the requested order. So the method uses the $step query parameter to control the application state. If step=1 is passed, the method displays the Web form that allows the user to reorder the categories. This Web form is created by calling displayReorderMenu(). If step=2 is passed, the method updates the order of the category because the step=2 is only passed from the Web form displayed by displayReorderMenu(), which is shown when step=1 is passed. . deleteDriver(): This method controls how delete operations are per formed on documents, responses, and categories. It works as follows: If the obj=doc query parameter is passed to this method when called, it calls deleteDoc() to start the document delete process. If the obj=response query parameter is passed, it runs deleteResponse() to start the delete process for response for a document. If the obj=category query parameter is passed, it runs deleteCategory() to start the category delete process.

Web host 4 life - 268 Part II: Developing Intranet Solutions TABLE 8-3

Sunday, October 28th, 2007

268 Part II: Developing Intranet Solutions TABLE 8-3 HTML TEMPLATES (Continued) Configuration Variable Template File Purpose $ANNOUNCE_LD_ADDED_TEMPLATE ld_added_ Message template announcement.html is shown when a new document is added. $ANNOUNCE_LD_MOD_TEMPLATE ld_modified_ Message that is announcement.html shown when an existing document is modified. $LD_VISIT_LIST_TEMPLATE ld_visit_list.html Lists the complete document-tracking information. $LD_REORDER_CAT_TEMPLATE ld_order_cat.html Web form template that enables an administrator to modify the order of the categories. The Document Publisher Application The document publisher application, ld_admin_mngr.php, is responsible for managing documents and categories. This application is included on the CD-ROM in the ch8/apps directory. It implements the following functionality: . Enables administrative users to create, modify, and delete categories and documents. . Enables administrative users to assign viewers (users who can view documents in a category) and publishers (users who can create, modify, or delete documents in a category) to each category. . Enables users to create, modify, and delete documents. . Does not allow non-administrative users to create, modify, or delete categories. The ch8/apps/ld_admin_mngr.php in the CDROM an implementation of this application.

Chapter 8: (Best web site) Intranet Simple Document Publisher 267 The

Sunday, October 28th, 2007

Chapter 8: Intranet Simple Document Publisher 267 The errors file The error messages displayed by the document publishing applications are stored in the ch8/apps/ld.errors file in the CDROM. You can modify the error messages using a text editor. Setting Up the Application Templates The HTML interface templates needed for the applications are included on the CD-ROM. These templates contain various template tags to display necessary information dynamically. The templates are named in the ld.conf file. These templates are discussed in Table 8-3. TABLE 8-3 HTML TEMPLATES Configuration Variable Template File Purpose $STATUS_TEMPLATE ld_status.html Shows status message. $LD_HOME_TEMPLATE ld_brief.html Document index template. $LD_DETAILS_TEMPLATE ld_details.html Shows the contents of the document. $LD_RESPONSE_TEMPLATE ld_response_ Web form template to input.html enter response information. $LD_VIEW_RESPONSE_TEMPLATE ld_response_ Response viewer view.html template. $ADD_MOD_DOC_TEMPLATE ld_add_mod_doc.html Web form template to add or modify documents. $ADD_MOD_CATEGORY_TEMPLATE ld_add_mod_cat.html Web form template to add or modify category. Continued

Yahoo web hosting - 266 Part II: Developing Intranet Solutions | |

Saturday, October 27th, 2007

266 Part II: Developing Intranet Solutions | | +—ld_tools (Intranet Simple Document Publisher Application) | | | +—apps (publisher apps and configuration files) | | | +—class (publisher apps and configuration) | | | +—templates (publisher HTML templates) | | | +—themes ————symbolically linked————+ By changing the following configuration parameters in ld.conf, you can modify the directory structure to fit your site requirements. $ROOT_PATH = $_SERVER[ DOCUMENT_ROOT ]; $REL_PHOTO_DIR = /photos ; $PHOTO_DIR = $ROOT_PATH . $REL_PHOTO_DIR; $REL_ROOT_PATH = /ld_tool ; $REL_APP_PATH = $REL_ROOT_PATH . /apps ; $TEMPLATE_DIR = $ROOT_PATH . $REL_APP_PATH . /templates ; $CLASS_DIR = $ROOT_PATH . $REL_APP_PATH . /class ; $REL_TEMPLATE_DIR = $REL_APP_PATH . /templates/ ; $THEME_TEMPLATE_DIR = $TEMPLATE_DIR . /themes ; The themes directory within the ld_tools/apps/templates should be a symbolic link pointing to the themes directory of the Intranet home application themes. For the given directory structure the ld_tools/apps/templates/themes can be created using the following command: ln -s home/templates/themes ld_tools/apps/templates/themes The above command assumes that it is being run from the %DocumentRoot% (htdocs) directory of the intranet Web site. If you cannot make symbolic links between two directories, you can simply copy the home/templates/themes directory as ld_tools/apps/templates/themes. Also, you can set the $THEME_TEMPLATE_DIR to $ROOT_PATH . /home/templates/themes . The messages file The messages displayed by the publisher applications are stored in the ch8/apps/ld.messages file in the CDROM. You can change the messages using a text editor.