Commit 43f5a67934971112c3e4a7269ef0150bb5dd2ee2

Authored by Michael Joseph
1 parent 1fe8d066

(#2813) refactored and tidied

incorporated addGroup link


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2494 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/listGroupsBL.php
... ... @@ -8,78 +8,22 @@
8 8 *
9 9 */
10 10  
11   - require_once("../../../../../config/dmsDefaults.php");
12 11  
13   -if (checkSession()) {
14   - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
15   - require_once("listGroupsUI.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/lib/unitmanagement/Unit.inc");
27   - require_once("$default->fileSystemRoot/presentation/Html.inc");
28   -
29   -
30   - $oPatternCustom = & new PatternCustom();
31   -
32   -if(checkSession()) {
  12 +require_once("../../../../../config/dmsDefaults.php");
  13 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  14 +require_once("$default->fileSystemRoot/lib/security/permission.inc");
  15 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  16 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  17 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  18 +require_once("$default->fileSystemRoot/presentation/Html.inc");
  19 +require_once("listGroupsUI.inc");
33 20  
34   - $oPatternCustom->addHtml(renderHeading("Current System Groups")); // Create the Heading
35   - $oPatternCustom->addHtml("<table align='left' border=0><tr><td><b>Filter by Unit </b></td><td>"); //
36   -
37   - if (($fUnitID != "")) { // Check if should use the query string OR ...
38   - $oUnit = Unit::get($fUnitID);
39   - $oPatternCustom->addHtml(getFilterOptions($sFilterOptions) . "</td></tr></table>\n"); // Get Groups Dropdown for filter option
40   - } else { //if ($_SESSION['GroupUnitFilter'][0]->iSessionUnitID != ""){ // ... should use session variable
41   -
42   - $oPatternCustom->addHtml(getFilterOptions($sFilterOptions) . "</td></tr></table>"); // Get Groups Dropdown for filter option
43   - }
44   - $oPatternCustom->addHtml(getSubmit());
45   - $oPatternCustom->addHtml("<br><br>");
46   -
47   - if ($oUnit) {
48   - $oPatternCustom->addHtml("<font face=arial size=2><b>&nbsp;Active Unit filter: </b>" . $oUnit->getName() . "</font>");
49   - }
50   - $main->setFormAction($_SERVER['PHP_SELF']);
51   -
52   -
53   - if($fUnitID != "") { // Filter Option
54   - $sWhereStatement = "WHERE groups_units_link.unit_id =$fUnitID ";
55   - }
56   - $sQuery = "SELECT groups_lookup.id as groupID, units_lookup.name as UnitNameB4, groups_lookup.name as name, 'Edit' , 'Delete', 'Edit Units', " .
57   - "CASE WHEN units_lookup.name Is Null THEN '<font color=darkgrey>No Unit Assigned</font>' ELSE units_lookup.name END AS UnitName " .
58   - "FROM (groups_lookup LEFT join groups_units_link on groups_lookup.id = groups_units_link.group_id) " .
59   - "LEft join units_lookup on units_lookup.id = groups_units_link.unit_id " .
60   - $sWhereStatement . " " .
61   - "ORDER BY groups_lookup.name ";
62   -
63   - $aColumns = array("name", "UnitName", "Edit", "Delete", "Edit Units");
64   - $aColumnNames = array( "Name", "Unit Name", "Edit", "Delete", "Edit Units");
65   - $aColumnTypes = array(1,1,3,3,3);
66   - $aDBColumnArray = array("groupID");
67   - $aQueryStringVariableNames = array("fGroupID");
68   -
69   - $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editGroup",
70   - 3=> "$default->rootUrl/control.php?action=removeGroup",
71   - 4=> "$default->rootUrl/control.php?action=editGroupUnit");
72   -
73   - $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
74   -
75   - $oSearchResults->setDisplayColumnHeadings(true);
76   - $htmlTables = $oSearchResults->render() ;
77   -
78   - $oPatternCustom->addHtml($htmlTables);
79   -
80   - } // end of if checksession
81   -
  21 +if (checkSession()) {
  22 + $oPatternCustom = & new PatternCustom();
  23 + $oPatternCustom->setHtml(getPage($fUnitID));
  24 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
82 25 $main->setCentralPayload($oPatternCustom);
83   - $main->render();
  26 + $main->setFormAction($_SERVER['PHP_SELF']);
  27 + $main->render();
84 28 }
85 29 ?>
... ...
presentation/lookAndFeel/knowledgeTree/administration/groupmanagement/listGroupsUI.inc
... ... @@ -8,223 +8,59 @@
8 8 *
9 9 */
10 10  
11   -function getSubmit() {
  11 +function getAddGroupLink() {
12 12 global $default;
13   - $sToRender = "<input type=\"image\" src =\"$default->graphicsUrl/widgets/select.gif\" value=\"submit\" border=\"0\"/>\n";
14   - return $sToRender;
  13 + $sBGColor = $default->siteMap->getSectionColour("Administration", "td");
  14 + return "<table width=\"100%\"><tr><td bgcolor=\"$sBGColor\">" . generateControllerLink("addGroup", "", "<font color=\"#ffffff\">Add A Group</font>") . "</td></tr></table>\n";
15 15 }
16 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($oUnit){
47   - global $default;
48   -
49   - $sToRender .= getUnitDisplay($oUnit);
50   -
51   - return $sToRender ;
52   -}
53 17  
54 18 // display the listbox initially ..then just display the text
55   -function getUnitDisplay($oUnit) {
  19 +function getUnitDisplay($iUnitID) {
56 20 global $default;
57 21  
58 22 if (Permission::userIsUnitAdministrator()) {
59   - $oUnit = Unit::get(User::getUnitID($_SESSION["userID"]));
60   - }
61   - if (!isset($oUnit)) {
62   - $oPatternListBox = & new PatternListBox($default->owl_units_table, "name", "id", "fUnitID");
63   - return $oPatternListBox->render();
64   - } else {
65   - return "<input type=\"hidden\" name=\"fUnitID\" value=\"" . $oUnit->iId . "\">\n" .
66   - $oUnit->getName();
  23 + $iUnitID = User::getUnitID($_SESSION["userID"]);
67 24 }
68   -
  25 + $oPatternListBox = & new PatternListBox($default->owl_units_table, "name", "id", "fUnitID");
  26 + $oPatternListBox->setPostBackOnChange(true);
  27 + if ($iUnitID != 0) {
  28 + $oPatternListBox->setSelectedValue($iUnitID);
  29 + }
  30 + return "<table><tr><td><b>Filter by Unit </b></td><td>" . $oPatternListBox->render() . "</td></tr></table>";
69 31 }
70 32  
71   -
72   -function getPageButtons($oThread){
  33 +function getGroups($fUnitID) {
73 34 global $default;
74   -
75   - $sToRender .= "<table width=100%><tr>\n";
76   - $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";
77   - $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";
78   -
79   - $sToRender .= "</tr></table>\n";
80   -
81   - return $sToRender ;
  35 + $sQuery = "SELECT groups_lookup.id as groupID, units_lookup.name as UnitNameB4, groups_lookup.name as name, 'Edit' , 'Delete', 'Edit Units', " .
  36 + "CASE WHEN units_lookup.name Is Null THEN '<font color=darkgrey>No Unit Assigned</font>' ELSE units_lookup.name END AS UnitName " .
  37 + "FROM (groups_lookup LEFT join groups_units_link on groups_lookup.id = groups_units_link.group_id) " .
  38 + "LEft join units_lookup on units_lookup.id = groups_units_link.unit_id " .
  39 + ($fUnitID ? "WHERE groups_units_link.unit_id =$fUnitID " : "") .
  40 + "ORDER BY groups_lookup.name ";
  41 +
  42 + $aColumns = array("name", "UnitName", "Edit", "Delete", "Edit Units");
  43 + $aColumnNames = array( "Name", "Unit Name", "Edit", "Delete", "Edit Units");
  44 + $aColumnTypes = array(1,1,3,3,3);
  45 + $aDBColumnArray = array("groupID");
  46 + $aQueryStringVariableNames = array("fGroupID");
  47 +
  48 + $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editGroup",
  49 + 3=> "$default->rootUrl/control.php?action=removeGroup",
  50 + 4=> "$default->rootUrl/control.php?action=editGroupUnit");
  51 +
  52 + $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
  53 + $oSearchResults->setDisplayColumnHeadings(true);
  54 + return $oSearchResults->render() ;
82 55 }
83 56  
84   -// If there are no threads to view for a document
85   -function getViewFailPage($sMessage)
86   -{
  57 +function getPage($fUnitID) {
87 58 global $default;
88   -
89   - if (strlen($sMessage)>0){
90   - $sToRender = $sMessage;
91   - }
92   - else $sToRender = "Current document has no discussion. Press the ADD button to start a discussion.";
93   -
94   - return $sToRender;
95   -}
  59 + $sToRender .= renderHeading("Current System Groups");
96 60  
97   -/**
98   - * Page to create a new thread
99   - *
100   - * @param $fDocumentID -> a valid document ID
101   - */
102   -function getNewThreadOption($fDocumentID) {
103   - global $default;
104   -
105   - $sToRender .= "Would you like to create a new Discussion thread for this document?";
106   - $sToRender .= "&nbsp;&nbsp;&nbsp;";
107   - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $fDocumentID . "&fNewThread=1") . "\"><img src=\"$default->graphicsUrl/widgets/new.gif\" border=\"0\"></a>";
108   - $sToRender .= "<a href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $fDocumentID) . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>";
109   -
110   - return $sToRender;
111   -}
112   -
113   -/**
114   - * Renders the heading for the page
115   - *
116   - * @param $sHeading -> text heading for the page
117   - */
118   -function renderHeading1($sHeading) {
119   - global $default;
120   -
121   - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
122   - $sColor = $default->siteMap->getSectionColour($sSectionName, "th");
123   - $sToRender = "<table border=\"0\" width=\"600\">\n";
124   - $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\"><font color=\"ffffff\">$sHeading</font></th></tr>\n";
125   - $sToRender .= "<tr/>\n";
126   - $sToRender .= "<tr/>\n";
127   - $sToRender .= "</table>\n";
128   - return $sToRender;
129   -}
130   -
131   -/**
132   - * Renders the path for the document
133   - *
134   - * @param $fDocumentID -> a valid document ID
135   - */
136   -function renderDocumentPath($iDocumentID) {
137   - global $default;
138   -
139   - $oDocument = & Document::get($iDocumentID);
140   - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
141   - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
142   - $sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > ";
143   - $sDocumentPath .= "<a href=\"$default->rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $oDocument->getID() . "&fForInlineView=1\">" . $oDocument->getName() . "</a>";
144   - return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n";
145   -}
146   -
147   -/**
148   - * Views the list of comments for a document
149   - * Prints out 1 comment
150   - * User needs to call this function many times to list all comments
151   - *
152   - * @param $iNum -> its the iterative index of the current comment
153   - * @param $iThread -> a valid Thread Object
154   - * @param $oComment -> a valid Comment Object
155   - * @param $oUser -> a valid User Object (Logged in user)
156   - */
157   -function getViewComment($iNum,$oThread,$oComment,$oUser) {
158   - global $default;
159   -
160   - $iSubjectChars = 59;
161   - // If iNum is odd then highlight it
162   - if (($iNum%2) == 1) $BGcolor = "#F5F6EE";
163   - if (($iNum%2) == 0) $UserBGcolor = "#F5F6EE";
164   -
165   - // If the Subject string is too long
166   - if (strlen($oComment->getSubject())>$iSubjectChars ) $dotdot = " ...";
167   - if (strlen($oUser->getUserName())> 13 ) $Userdotdot = " ...";
168   -
169   - // If this is the first Subject line then create a table
170   - if ($iNum == 1) {
171   - $sHeading = "Document Discussion Comments";
172   -
173   - $sToRender .= renderHeading($sHeading );
174   - $sToRender .= renderDocumentPath($oThread->getDocumentID());
175   - $sToRender .= "<table border=0 width=100%><tr>";
176   - $sToRender .= "<td width=100><b>Views: </b> " . $oThread->getNumberOfViews() . "</td>";
177   - $sToRender .= "<td width=20></td>";
178   - $sToRender .= "<td><b>Replies: </b> " . $oThread->getNumberOfReplies() . "</td>";
179   - $sToRender .= "<td align=right><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a>";
180   - $sToRender .= "<img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" ></td>";
181   - $sToRender .= "</tr></table><br>\n";
182   - $sToRender .= "<table border=\"0\" width=\"100%\">\n";
183   - $sToRender .= "<tr><td></td>\n";
184   - $sToRender .= "<td><b>Subject</b></td>\n";
185   - $sToRender .= "<td><b>Author</b></td>\n";
186   - $sToRender .= "<td><b>Date</b></td>\n";
187   - $sToRender .= "</tr>\n";
188   - }
189   -
190   - $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";
191   - $sToRender .= "<td style=\"background-color:$UserBGcolor\" width=\"100\" title=\"$oUser->getUserName()\">" . substr($oUser->getUserName(),0,10) . $Userdotdot . "</td>\n";
192   - $sToRender .= "<td style=\"background-color:$BGcolor\" width=\"80\">" . $oComment->getDate() . "<td></tr>\n";
193   -
194   - // If this is the last subject line then close the table
195   - if ($iNum == ($oThread->getNumberOfReplies())) { $sToRender .= "\n</table>\n\n";}
196   - return $sToRender;
197   -}
198   -
199   -/**
200   - * Views a single thread comment with its text body
201   - *
202   - * @param $iDocumentID -> a valid Document ID
203   - * @param $oComment -> a valid Comment Object
204   - * @param $oUser -> a valid User Object (Logged in user)
205   - */
206   -function getCommentBody($oComment, $iDocumentID, $oUser) {
207   - global $default;
208   -
209   - $sHeading = "Document Comment";
210   -
211   - $sToRender .= renderHeading($sHeading);
212   - $sToRender .= renderDocumentPath($iDocumentID);
213   -
214   - $sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n";
215   - $sToRender .= "<td align=right>\n";
216   - $sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fReplyComment=1&fCommentID=" . $oComment->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/reply.gif\" border=\"0\" /></a>";
217   - $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";
218   - $sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">";
219   - $sToRender .= "<a>" . $oComment->getSubject() . "</a>";
220   - $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>";
221   - $sToRender .= "<DIV> ";
222   - $sToRender .= urldecode(str_replace("%0D%0A","<br>",str_replace("+", "&nbsp;",$oComment->getBody()))); // Div Views as HTML
223   - $sToRender .= "</DIV></td>";
224   -
225   - $sToRender .= "</tr></table> ";
226   -
227   - return $sToRender;
  61 + $sToRender .= getAddGroupLink();
  62 + $sToRender .= getUnitDisplay($fUnitID);
  63 + $sToRender .= getGroups($fUnitID);
  64 + return $sToRender;
228 65 }
229   -
230 66 ?>
231 67 \ No newline at end of file
... ...