Commit 9ccf6238911e613fc824ef3f051d37f5fdcfd62e

Authored by Michael Joseph
1 parent 80ebb234

(#2813) refactored and tidied

incorporated addDocType link


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2508 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/listDocTypesBL.php
1 1 <?php
2 2 /**
3   -* BL information for viewing a Discussion
  3 +* BL information for listing Document Types
4 4 *
5 5 * @author Omar Rahbeeni
6 6 * @date 19 May 2003
... ... @@ -8,57 +8,22 @@
8 8 *
9 9 */
10 10  
11   - require_once("../../../../../config/dmsDefaults.php");
  11 +require_once("../../../../../config/dmsDefaults.php");
  12 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  13 +require_once("$default->fileSystemRoot/lib/security/permission.inc");
  14 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  15 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  16 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  17 +require_once("$default->fileSystemRoot/presentation/Html.inc");
  18 +require_once("listDocTypesUI.inc");
  19 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/administration/adminUI.inc");
12 20  
13   -if (checkSession()) {
14   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
15   - require_once("listDocTypesUI.inc");
16   - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
17   - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
18   - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
19   - require_once("$default->fileSystemRoot/lib/users/User.inc");
20   - require_once("$default->fileSystemRoot/lib/security/permission.inc");
21   - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
22   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
23   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
24   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");
25   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
26   - require_once("$default->fileSystemRoot/presentation/Html.inc");
27   -
28   -
  21 +if (checkSession()) {
29 22 $oPatternCustom = & new PatternCustom();
30   -
31   -if(checkSession()) {
32   - global $default;
33   -
34   - $oPatternCustom->addHtml(renderHeading("Document Type Management")); // Create the Heading
35   -
36   - $main->setFormAction($_SERVER['PHP_SELF']);
37   -
38   - $sQuery = "SELECT id as DocTypeID, name as DocTypeName, " .
39   - "'Edit', 'Delete', 'Edit Fields' " .
40   - "FROM " . $default->owl_document_types_table . " " .
41   - "ORDER BY name";
42   -
43   - $aColumns = array("DocTypeName", "Edit", "Delete", "Edit Fields");
44   - $aColumnNames = array("Name", "Edit", "Delete", "Edit Fields");
45   - $aColumnTypes = array(1,3,3,3);
46   - $aDBColumnArray = array("DocTypeID");
47   - $aQueryStringVariableNames = array("fDocTypeID");
48   -
49   - $aHyperLinkURL = array( 1=> "$default->rootUrl/control.php?action=editDocType&fDocTypeSelected=1",
50   - 2=> "$default->rootUrl/control.php?action=removeDocType",
51   - 3=> "$default->rootUrl/control.php?action=editDocTypeFields&fDocTypeSelected=1");
52   -
53   - $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
54   - $oSearchResults->setDisplayColumnHeadings(true);
55   - $htmlTables = $oSearchResults->render() ;
56   -
57   - $oPatternCustom->addHtml($htmlTables);
58   -
59   - } // end of if checksession
60   -
  23 + $oPatternCustom->setHtml(getPage($fGroupID));
  24 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
61 25 $main->setCentralPayload($oPatternCustom);
62   - $main->render();
  26 + $main->setFormAction($_SERVER['PHP_SELF']);
  27 + $main->render();
63 28 }
64 29 -?>
  30 +?>
65 31 \ No newline at end of file
... ...
presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/listDocTypesUI.inc
1 1 <?php
2 2 /**
3   -* Presentation information for adding a unit
  3 +* Presentation information for listing Document Types
4 4 *
5 5 * @author Omar Rahbeeni
6 6 * @date 19 May 2003
... ... @@ -8,211 +8,36 @@
8 8 *
9 9 */
10 10  
11   -function getSubmit() {
  11 +function getDocumentTypes() {
12 12 global $default;
13   - $sToRender = "<input type=\"image\" src =\"$default->graphicsUrl/widgets/select.gif\" value=\"submit\" border=\"0\"/>\n";
14   - return $sToRender;
15   -}
16   -
17   -// display the listbox initially ..then just display the text
18   -function getGroupDisplay($oGroup, $iSelectedValue = 0) {
19   - global $default;
20   - if (!isset($oGroup)) {
21   - if (Permission::userIsSystemAdministrator()) {
22   - // if this is the system administrator, prepend group names with unit name
23   - $oPatternListBox = & new PatternListBox($default->owl_groups_table, "name", "id", "fGroupID");
24   - $oPatternListBox->setFromClause("LEFT OUTER JOIN groups_units_link GUL on ST.id=GUL.group_id " .
25   - "LEFT OUTER JOIN units_lookup UL on GUL.unit_id=UL.id");
26   - $oPatternListBox->setCompositeDisplayName("DISTINCT COALESCE(CONCAT(CONCAT(UL.name, '-'),ST.name),ST.name)");
27   - } else if (Permission::userIsUnitAdministrator()) {
28   - // else if this is a unit administrator, only display the groups in your unit
29   - $oPatternListBox = & new PatternListBox($default->owl_groups_table, "name", "id", "fGroupID");
30   - $oPatternListBox->setFromClause("INNER JOIN $default->owl_groups_units_table GUL on ST.id=GUL.group_id");
31   - $oPatternListBox->setWhereClause("GUL.unit_id=" . User::getUnitID($_SESSION["userID"]));
32   - }
33   - if ($iSelectedValue != 0) {
34   - $oPatternListBox->setSelectedValue($iSelectedValue);
35   - }
36   -
37   - return $oPatternListBox->render();
38   - } else {
39   - return "<input type=\"hidden\" name=\"fGroupID\" value=\"" . $oGroup->iId . "\">\n" .
40   - $oGroup->getName();
41   - }
42   -
43   -}
44   -
45   -
46   -function getFilterOptions($fGroupID = 0){
47   - global $default;
48   - $sToRender .= getGroupDisplay($aGroups, $fGroupID);
49   - /*
50   - $sToRender .= "<table width=100%><tr>\n";
51   - $sToRender .= "<td align=right width=100%><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a></td>\n";
52   - $sToRender .= "<td align=right width=10><img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" /></td>\n";
53   -
54   - $sToRender .= "</tr></table>\n";*/
55   - return $sToRender ;
56   -}
57   -
58   -function getPageButtons($oThread){
59   - global $default;
60   -
61   - $sToRender .= "<table width=100%><tr>\n";
62   - $sToRender .= "<td align=right width=100%><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a></td>\n";
63   - $sToRender .= "<td align=right width=10><img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" /></td>\n";
64   -
65   - $sToRender .= "</tr></table>\n";
66   - //$sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a>\n";
67   - //$sToRender .= "<img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" />\n";
68 13  
69   - return $sToRender ;
70   -}
71   -
72   -// If there are no threads to view for a document
73   -function getViewFailPage($sMessage)
74   -{
  14 + $sQuery = "SELECT id as DocTypeID, name as DocTypeName, " .
  15 + "'Edit', 'Delete', 'Edit Fields' " .
  16 + "FROM " . $default->owl_document_types_table . " " .
  17 + "ORDER BY name";
  18 +
  19 + $aColumns = array("DocTypeName", "Edit", "Delete", "Edit Fields");
  20 + $aColumnNames = array("Name", "Edit", "Delete", "Edit Fields");
  21 + $aColumnTypes = array(1,3,3,3);
  22 + $aDBColumnArray = array("DocTypeID");
  23 + $aQueryStringVariableNames = array("fDocTypeID");
  24 +
  25 + $aHyperLinkURL = array( 1=> "$default->rootUrl/control.php?action=editDocType&fDocTypeSelected=1",
  26 + 2=> "$default->rootUrl/control.php?action=removeDocType",
  27 + 3=> "$default->rootUrl/control.php?action=editDocTypeFields&fDocTypeSelected=1");
  28 +
  29 + $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
  30 + $oSearchResults->setDisplayColumnHeadings(true);
  31 + return $oSearchResults->render() ;
  32 +}
  33 +
  34 +function getPage() {
75 35 global $default;
76   -
77   - if (strlen($sMessage)>0){
78   - $sToRender = $sMessage;
79   - }
80   - else $sToRender = "Current document has no discussion. Press the ADD button to start a discussion.";
81   -
82   - return $sToRender;
83   -}
84   -
85   -/**
86   - * Page to create a new thread
87   - *
88   - * @param $fDocumentID -> a valid document ID
89   - */
90   -function getNewThreadOption($fDocumentID) {
91   - global $default;
92   -
93   - $sToRender .= "Would you like to create a new Discussion thread for this document?";
94   - $sToRender .= "&nbsp;&nbsp;&nbsp;";
95   - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $fDocumentID . "&fNewThread=1") . "\"><img src=\"$default->graphicsUrl/widgets/new.gif\" border=\"0\"></a>";
96   - $sToRender .= "<a href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $fDocumentID) . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>";
97   -
98   - return $sToRender;
99   -}
  36 + $sToRender .= renderHeading("Current Document Types");
100 37  
101   -/**
102   - * Renders the heading for the page
103   - *
104   - * @param $sHeading -> text heading for the page
105   - */
106   -function renderHeading1($sHeading) {
107   - global $default;
108   -
109   - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
110   - $sColor = $default->siteMap->getSectionColour($sSectionName, "th");
111   - $sToRender = "<table border=\"0\" width=\"600\">\n";
112   - $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\"><font color=\"ffffff\">$sHeading</font></th></tr>\n";
113   - $sToRender .= "<tr/>\n";
114   - $sToRender .= "<tr/>\n";
115   - $sToRender .= "</table>\n";
116   - return $sToRender;
117   -}
118   -
119   -/**
120   - * Renders the path for the document
121   - *
122   - * @param $fDocumentID -> a valid document ID
123   - */
124   -function renderDocumentPath($iDocumentID) {
125   - global $default;
126   -
127   - $oDocument = & Document::get($iDocumentID);
128   - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
129   - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
130   - $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > ";
131   - $sDocumentPath .= "<a href=\"$default->rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $oDocument->getID() . "&fForInlineView=1\">" . $oDocument->getName() . "</a>";
132   - return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n";
133   -}
134   -
135   -/**
136   - * Views the list of comments for a document
137   - * Prints out 1 comment
138   - * User needs to call this function many times to list all comments
139   - *
140   - * @param $iNum -> its the iterative index of the current comment
141   - * @param $iThread -> a valid Thread Object
142   - * @param $oComment -> a valid Comment Object
143   - * @param $oUser -> a valid User Object (Logged in user)
144   - */
145   -function getViewComment($iNum,$oThread,$oComment,$oUser) {
146   - global $default;
147   -
148   - $iSubjectChars = 59;
149   - // If iNum is odd then highlight it
150   - if (($iNum%2) == 1) $BGcolor = "#F5F6EE";
151   - if (($iNum%2) == 0) $UserBGcolor = "#F5F6EE";
152   -
153   - // If the Subject string is too long
154   - if (strlen($oComment->getSubject())>$iSubjectChars ) $dotdot = " ...";
155   - if (strlen($oUser->getUserName())> 13 ) $Userdotdot = " ...";
156   -
157   - // If this is the first Subject line then create a table
158   - if ($iNum == 1) {
159   - $sHeading = "Document Discussion Comments";
160   -
161   - $sToRender .= renderHeading($sHeading );
162   - $sToRender .= renderDocumentPath($oThread->getDocumentID());
163   - $sToRender .= "<table border=0 width=100%><tr>";
164   - $sToRender .= "<td width=100><b>Views: </b> " . $oThread->getNumberOfViews() . "</td>";
165   - $sToRender .= "<td width=20></td>";
166   - $sToRender .= "<td><b>Replies: </b> " . $oThread->getNumberOfReplies() . "</td>";
167   - $sToRender .= "<td align=right><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a>";
168   - $sToRender .= "<img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" ></td>";
169   - $sToRender .= "</tr></table><br>\n";
170   - $sToRender .= "<table border=\"0\" width=\"100%\">\n";
171   - $sToRender .= "<tr><td></td>\n";
172   - $sToRender .= "<td><b>Subject</b></td>\n";
173   - $sToRender .= "<td><b>Author</b></td>\n";
174   - $sToRender .= "<td><b>Date</b></td>\n";
175   - $sToRender .= "</tr>\n";
176   - }
177   -
178   - $sToRender .= "<tr><td>$iNum </td><td style=\"background-color:$BGcolor\" width=450><a style=\"width:94%\" href=\"" . $_SERVER['PHP_SELF'] . "?fViewComment=1&iCommentID=" . $oComment->getID() . "&iDocumentID=" . $oThread->getDocumentID() . "\" title=\"" . $oComment->getSubject() . "\">" . substr($oComment->getSubject(),0,$iSubjectChars ) . $dotdot . "</a></td>\n";
179   - $sToRender .= "<td style=\"background-color:$UserBGcolor\" width=\"100\" title=\"$oUser->getUserName()\">" . substr($oUser->getUserName(),0,10) . $Userdotdot . "</td>\n";
180   - $sToRender .= "<td style=\"background-color:$BGcolor\" width=\"80\">" . $oComment->getDate() . "<td></tr>\n";
181   -
182   - // If this is the last subject line then close the table
183   - if ($iNum == ($oThread->getNumberOfReplies())) { $sToRender .= "\n</table>\n\n";}
184   - return $sToRender;
185   -}
186   -
187   -/**
188   - * Views a single thread comment with its text body
189   - *
190   - * @param $iDocumentID -> a valid Document ID
191   - * @param $oComment -> a valid Comment Object
192   - * @param $oUser -> a valid User Object (Logged in user)
193   - */
194   -function getCommentBody($oComment, $iDocumentID, $oUser) {
195   - global $default;
196   -
197   - $sHeading = "Document Comment";
198   -
199   - $sToRender .= renderHeading($sHeading);
200   - $sToRender .= renderDocumentPath($iDocumentID);
201   -
202   - $sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n";
203   - $sToRender .= "<td align=right>\n";
204   - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fReplyComment=1&fCommentID=" . $oComment->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/reply.gif\" border=\"0\" /></a>";
205   - $sToRender .= "</td><td width=30><img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" ></td></tr>\n";
206   - $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">";
207   - $sToRender .= "<a>" . $oComment->getSubject() . "</a>";
208   - $sToRender .= "</td><td colspan=2><b>Date: </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font>&nbsp;&nbsp;&nbsp;</td></tr><tr><td colspan=4 valign=top>";
209   - $sToRender .= "<DIV> ";
210   - $sToRender .= urldecode(str_replace("%0D%0A","<br>",str_replace("+", "&nbsp;",$oComment->getBody()))); // Div Views as HTML
211   - $sToRender .= "</DIV></td>";
212   -
213   - $sToRender .= "</tr></table> ";
214   -
215   - return $sToRender;
  38 + // add user link
  39 + $sToRender .= getAddLink("addDocType", "Add A Document Type");
  40 + $sToRender .= getDocumentTypes();
  41 + return $sToRender;
216 42 }
217   -
218 43 ?>
219 44 \ No newline at end of file
... ...