Commit 1df2c4f8953e0041f1aafbe8aad129057d2eff92

Authored by Michael Joseph
1 parent f3b87829

(#2813) refactored and tidied

incorporated addUser link


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2492 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/listUsersBL.php
@@ -8,82 +8,26 @@ @@ -8,82 +8,26 @@
8 * 8 *
9 */ 9 */
10 10
11 - require_once("../../../../../config/dmsDefaults.php"); 11 +require_once("../../../../../config/dmsDefaults.php");
  12 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");
  13 +require_once("listUsersUI.inc");
  14 +require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc");
  15 +require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
  16 +require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
  17 +require_once("$default->fileSystemRoot/lib/users/User.inc");
  18 +require_once("$default->fileSystemRoot/lib/security/permission.inc");
  19 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
  20 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
  21 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternBrowsableSearchResults.inc");
  22 +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc");
  23 +require_once("$default->fileSystemRoot/presentation/Html.inc");
12 24
13 -if (checkSession()) {  
14 - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc");  
15 - require_once("listUsersUI.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 - 25 +if (checkSession()) {
29 $oPatternCustom = & new PatternCustom(); 26 $oPatternCustom = & new PatternCustom();
30 -  
31 -if(checkSession()) {  
32 -  
33 - $oPatternCustom->addHtml(renderHeading("Current System Users")); // Create the Heading  
34 - $oPatternCustom->addHtml("<table align='left' border=0><tr><td><b>Filter by group </b></td><td>"); //  
35 - if (isset($fGroupID)) { // Check if should use the query string OR ...  
36 - $sFilterOptions = getFilterOptions($fGroupID);  
37 - $oPatternCustom->addHtml($sFilterOptions . "</td></tr></table>\n"); // Get Groups Dropdown for filter option  
38 - } else { // ... should use session variable  
39 - $sFilterOptions = getFilterOptions($_SESSION['UserGroupFilter'][0]->iSessionGroupID);  
40 - $oPatternCustom->addHtml(getFilterOptions($sFilterOptions) . "</td></tr></table>"); // Get Groups Dropdown for filter option  
41 - }  
42 - $oPatternCustom->addHtml(getSubmit());  
43 - $oPatternCustom->addHtml("<br><br><br>");  
44 - $main->setFormAction($_SERVER['PHP_SELF']);  
45 -  
46 -  
47 - if($fGroupID == "") { // Used when user wants to filter by group  
48 - $sQuery = "SELECT users.id as userID, users.name as name, username, " .  
49 - "'Edit' , 'Delete', 'Edit Groups' " .  
50 - "FROM users " .  
51 - "ORDER BY users.name";  
52 - $_SESSION['UserGroupFilter'][0]->iSessionGroupID = "";  
53 -  
54 - } else { // List all users on the system  
55 - if (isset($fGroupID)) {  
56 - $_SESSION['UserGroupFilter'][0]->iSessionGroupID = $fGroupID ;  
57 - } else {  
58 - $fGroupID = $_SESSION['UserGroupFilter'][0]->iSessionGroupID;  
59 - }  
60 - $sQuery = "SELECT users.id as userID, users.name as name, username, " .  
61 - "'Edit' , 'Delete', 'Edit Groups' , users_groups_link.group_id " .  
62 - "FROM users inner JOIN users_groups_link ON users.id = users_groups_link.user_id " .  
63 - "WHERE users_groups_link.group_id = $fGroupID " .  
64 - "ORDER BY users.name";  
65 - }  
66 -  
67 - $aColumns = array("name", "username", "Edit", "Delete", "Edit Groups");  
68 - $aColumnNames = array("Name", "Username", "Edit", "Delete", "Edit Groups");  
69 - $aColumnTypes = array(1,1,3,3,3);  
70 - $aDBColumnArray = array("userID");  
71 - $aQueryStringVariableNames = array("fUserID");  
72 -  
73 - $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editUser",  
74 - 3=> "$default->rootUrl/control.php?action=removeUser",  
75 - 4=> "$default->rootUrl/control.php?action=editUserGroups"); //"$default->rootUrl/control.php?action=removeUserFromGroup");  
76 -  
77 - $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);  
78 -  
79 - $oSearchResults->setDisplayColumnHeadings(true);  
80 - $htmlTables = $oSearchResults->render() ;  
81 -  
82 - $oPatternCustom->addHtml($htmlTables);  
83 -  
84 - } // end of if checksession  
85 - 27 + $oPatternCustom->setHtml(getPage($fGroupID));
  28 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
86 $main->setCentralPayload($oPatternCustom); 29 $main->setCentralPayload($oPatternCustom);
87 - $main->render(); 30 + $main->setFormAction($_SERVER['PHP_SELF']);
  31 + $main->render();
88 } 32 }
89 -?> 33 -?>
  34 +?>
90 \ No newline at end of file 35 \ No newline at end of file
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/listUsersUI.inc
@@ -8,211 +8,65 @@ @@ -8,211 +8,65 @@
8 * 8 *
9 */ 9 */
10 10
11 -function getSubmit() { 11 +function getGroupDisplay($iGroupID) {
12 global $default; 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(); 13 + if (Permission::userIsSystemAdministrator()) {
  14 + // if this is the system administrator, prepend group names with unit name
  15 + $oPatternListBox = & new PatternListBox($default->owl_groups_table, "name", "id", "fGroupID");
  16 + $oPatternListBox->setFromClause("LEFT OUTER JOIN groups_units_link GUL on ST.id=GUL.group_id " .
  17 + "LEFT OUTER JOIN units_lookup UL on GUL.unit_id=UL.id");
  18 + $oPatternListBox->setCompositeDisplayName("DISTINCT COALESCE(CONCAT(CONCAT(UL.name, '-'),ST.name),ST.name)");
  19 + } else if (Permission::userIsUnitAdministrator()) {
  20 + // else if this is a unit administrator, only display the groups in your unit
  21 + $oPatternListBox = & new PatternListBox($default->owl_groups_table, "name", "id", "fGroupID");
  22 + $oPatternListBox->setFromClause("INNER JOIN $default->owl_groups_units_table GUL on ST.id=GUL.group_id");
  23 + $oPatternListBox->setWhereClause("GUL.unit_id=" . User::getUnitID($_SESSION["userID"]));
  24 + }
  25 + $oPatternListBox->setPostBackOnChange(true);
  26 + if ($iGroupID != 0) {
  27 + $oPatternListBox->setSelectedValue($iGroupID);
41 } 28 }
42 - 29 +
  30 + return "<table><tr><td><b>Filter by group </b></td><td>" . $oPatternListBox->render() . "</td></tr></table>";
43 } 31 }
44 32
45 -  
46 -function getFilterOptions($fGroupID = 0){ 33 +function getAddUserLink() {
47 global $default; 34 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 ; 35 + $sBGColor = $default->siteMap->getSectionColour("Administration", "td");
  36 + return "<table width=\"100%\"><tr><td bgcolor=\"$sBGColor\">" . generateControllerLink("addUser", "", "<font color=\"#ffffff\">Add A User</font>") . "</td></tr></table>\n";
56 } 37 }
57 38
58 -function getPageButtons($oThread){ 39 +function getUsers($fGroupID) {
59 global $default; 40 global $default;
  41 + $sQuery = "SELECT users.id as userID, users.name as name, username, " .
  42 + "'Edit' , 'Delete', 'Edit Groups' " .
  43 + "FROM users " .
  44 + ($fGroupID ? "INNER JOIN users_groups_link ON users.id = users_groups_link.user_id WHERE users_groups_link.group_id = $fGroupID " : "") .
  45 + "ORDER BY users.name";
60 46
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 -  
69 - return $sToRender ;  
70 -}  
71 -  
72 -// If there are no threads to view for a document  
73 -function getViewFailPage($sMessage)  
74 -{  
75 - 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 -}  
100 -  
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"; 47 + $aColumns = array("name", "username", "Edit", "Delete", "Edit Groups");
  48 + $aColumnNames = array("Name", "Username", "Edit", "Delete", "Edit Groups");
  49 + $aColumnTypes = array(1,1,3,3,3);
  50 + $aDBColumnArray = array("userID");
  51 + $aQueryStringVariableNames = array("fUserID");
  52 +
  53 + $aHyperLinkURL = array( 2=> "$default->rootUrl/control.php?action=editUser",
  54 + 3=> "$default->rootUrl/control.php?action=removeUser",
  55 + 4=> "$default->rootUrl/control.php?action=editUserGroups");
  56 +
  57 + $oSearchResults = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnNames, "100%", $aHyperLinkURL,$aDBColumnArray,$aQueryStringVariableNames);
  58 + $oSearchResults->setDisplayColumnHeadings(true);
  59 + return $oSearchResults->render() ;
133 } 60 }
134 61
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) { 62 +function getPage($fGroupID) {
146 global $default; 63 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 -} 64 + $sToRender .= renderHeading("Current System Users");
186 65
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; 66 + // add user link
  67 + $sToRender .= getAddUserLink();
  68 + $sToRender .= getGroupDisplay($fGroupID);
  69 + $sToRender .= getUsers($fGroupID);
  70 + return $sToRender;
216 } 71 }
217 -  
218 ?> 72 ?>
219 \ No newline at end of file 73 \ No newline at end of file