Commit 79692c1c120c028e3bb04cd0b6d01ef313ec7f44
1 parent
5fdc0976
Remove extraneous copy-and-paste stuff about users and groups from here,
and reduce includes to only the required ones. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3406 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
15 additions
and
271 deletions
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/editDocFieldLookupsBL.php
| ... | ... | @@ -27,22 +27,13 @@ |
| 27 | 27 | |
| 28 | 28 | require_once("../../../../../config/dmsDefaults.php"); |
| 29 | 29 | |
| 30 | -KTUtil::extractGPC('fDeleteConfirmed', 'fDocFieldID', 'fGroupID', 'fGroupSet', 'fOtherGroupID', 'fUserID', 'faGroupID'); | |
| 30 | +KTUtil::extractGPC('fDocFieldID'); | |
| 31 | 31 | |
| 32 | 32 | if (checkSession()) { |
| 33 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); | |
| 34 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCreate.inc"); | |
| 35 | 33 | require_once("editDocFieldLookupsUI.inc"); |
| 36 | 34 | require_once("$default->fileSystemRoot/lib/documentmanagement/DocumentField.inc"); |
| 37 | - require_once("$default->fileSystemRoot/lib/documentmanagement/MetaData.inc"); | |
| 38 | - require_once("$default->fileSystemRoot/lib/users/User.inc"); | |
| 39 | - require_once("$default->fileSystemRoot/lib/groups/GroupUserLink.inc"); | |
| 40 | - require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | |
| 41 | - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 42 | 35 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 43 | - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | |
| 44 | - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); | |
| 45 | - require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 36 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 46 | 37 | |
| 47 | 38 | $oPatternCustom = & new PatternCustom(); |
| 48 | 39 | |
| ... | ... | @@ -50,41 +41,14 @@ if (checkSession()) { |
| 50 | 41 | $oDocField = DocumentField::get($fDocFieldID); |
| 51 | 42 | if ($oDocField->getHasLookup()){ |
| 52 | 43 | // do a check to see both drop downs selected |
| 53 | - if($fDocFieldID == -1) { | |
| 54 | - $oPatternCustom->setHtml(getPageNotSelected()); | |
| 55 | - } else { | |
| 56 | - //$oMetaData = new MetaData(); | |
| 57 | - //$faGroupID = GroupUserLink::getGroups($fUserID); | |
| 58 | - $oPatternCustom->setHtml(getGroupPage($fDocFieldID)); | |
| 59 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fUserSet=1&fGroupSet=1"); | |
| 60 | - } | |
| 44 | + $oPatternCustom->setHtml(getPage($oDocField)); | |
| 61 | 45 | } else { |
| 62 | - $oPatternCustom->setHtml(getLookupNotSet()); | |
| 46 | + $_SESSION["KTErrorMessage"][] = _("Document Field is not Lookup enabled."); | |
| 47 | + exit(controllerRedirect("listDocFields")); | |
| 63 | 48 | } |
| 64 | 49 | } else { |
| 65 | - // build first page | |
| 66 | - $oPatternCustom->setHtml(getPage(null,null)); | |
| 67 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fUserSet=1"); | |
| 68 | - } | |
| 69 | - | |
| 70 | - if(isset($fGroupSet)) { | |
| 71 | - if($fOtherGroupID) { | |
| 72 | - $oPatternCustom->setHtml("Add"); | |
| 73 | - } else { | |
| 74 | - $oPatternCustom->setHtml("Delete"); | |
| 75 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fDeleteConfirmed=1&fGroupID=$fGroupID"); | |
| 76 | - } | |
| 77 | - } | |
| 78 | - | |
| 79 | - if (isset($fDeleteConfirmed)) { | |
| 80 | - // else add to db and then goto page succes | |
| 81 | - $oUserGroup = new GroupUserLink($fGroupID, $fUserID); | |
| 82 | - $oUserGroup->setUserGroupID($fGroupID,$fUserID); | |
| 83 | - if($oUserGroup->delete()) { | |
| 84 | - $oPatternCustom->setHtml(getPageSuccess()); | |
| 85 | - } else { | |
| 86 | - $oPatternCustom->setHtml(getPageFail()); | |
| 87 | - } | |
| 50 | + $_SESSION["KTErrorMessage"][] = _("No document field lookup selected"); | |
| 51 | + exit(controllerRedirect("listDocFields")); | |
| 88 | 52 | } |
| 89 | 53 | |
| 90 | 54 | // render page | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/editDocFieldLookupsUI.inc
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | * |
| 5 | 5 | * Edit document field lookups UI functions |
| 6 | 6 | * |
| 7 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 7 | + * Copyright (c) 2003, 2005 Jam Warehouse http://www.jamwarehouse.com | |
| 8 | 8 | * |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | 10 | * it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -24,68 +24,18 @@ |
| 24 | 24 | * @author Mukhtar Dharsey, Jam Warehouse (Pty) Ltd, South Africa |
| 25 | 25 | * @package administration.docfieldmanagement |
| 26 | 26 | */ |
| 27 | - | |
| 28 | -function getLookupNotSet() { | |
| 29 | - global $default; | |
| 30 | - | |
| 31 | - $sToRender .= renderHeading(_("Edit User Groups")); | |
| 32 | - $sToRender .= "<table>\n"; | |
| 33 | - $sToRender .= "<tr>\n"; | |
| 34 | - $sToRender .= "<td>\n"; | |
| 35 | - $sToRender .= _("Document Field is not Lookup enabled."); | |
| 36 | - $sToRender .= "</td>\n"; | |
| 37 | - $sToRender .= "</tr>\n"; | |
| 38 | - $sToRender .= "<td></td>\n"; | |
| 39 | - $sToRender .= "<td>\n"; | |
| 40 | - $sToRender .= "<a href=\"$default->rootUrl/control.php?action=listDocFields\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a>"; | |
| 41 | - $sToRender .= "</td>\n"; | |
| 42 | - $sToRender .= "</table>\n"; | |
| 43 | - | |
| 44 | - return $sToRender ; | |
| 45 | -} | |
| 46 | 27 | |
| 47 | -// get page for removal | |
| 48 | -function getPage($iUserID) { | |
| 28 | +require_once("$default->fileSystemRoot/presentation/Html.inc"); | |
| 29 | + | |
| 30 | +function getPage($oDocField) { | |
| 49 | 31 | global $default; |
| 50 | - $oUser = null; | |
| 51 | - $oGroup = null; | |
| 52 | 32 | |
| 53 | - // change headings if User selected | |
| 54 | - if (isset($iUserID)) { | |
| 55 | - $oUser = User::get($iUserID); | |
| 56 | - } else { | |
| 57 | - $heading = "<tr><td>" . _("Please select a User") . ":</td></tr>\n"; | |
| 58 | - } | |
| 59 | - | |
| 60 | - $sToRender .= renderHeading(_("Edit User Groups")); | |
| 61 | - $sToRender .= "<table>\n"; | |
| 62 | - $sToRender .= $heading; | |
| 63 | - $sToRender .= "<tr>\n"; | |
| 64 | - $sToRender .= "</tr>\n"; | |
| 65 | - $sToRender .= "<td>" . _("User Name") . ": " . getUserDisplay($oUser) . "</td>\n"; | |
| 66 | - $sToRender .= "<tr>\n"; | |
| 67 | - $sToRender .= "</tr>\n"; | |
| 68 | - $sToRender .= "<tr>\n"; | |
| 69 | - $sToRender .= "</tr>\n"; | |
| 70 | - $sToRender .= "<tr>\n"; | |
| 71 | - $sToRender .= "</tr>\n"; | |
| 72 | - $sToRender .= "</td></table>\n"; | |
| 73 | - | |
| 74 | - return $sToRender; | |
| 75 | -} | |
| 76 | - | |
| 77 | - | |
| 78 | - | |
| 79 | -// get page for removal | |
| 80 | -function getGroupPage($iDocFieldID) { | |
| 81 | - global $default; | |
| 33 | + $iDocFieldID = $oDocField->getID(); | |
| 82 | 34 | |
| 83 | - $oDocField = DocumentField::get($iDocFieldID); | |
| 84 | - | |
| 85 | 35 | $LookupDisplay .= "<b>" . _("Current Lookups") . "</b><br>\n"; |
| 86 | - $sQuery = " Select * " . | |
| 87 | - " From " . $default->metadata_table . | |
| 88 | - " WHERE document_field_id=" . $iDocFieldID; | |
| 36 | + $sQuery = array("SELECT * FROM " . $default->metadata_table . | |
| 37 | + " WHERE document_field_id = ?", | |
| 38 | + array($iDocFieldID)); | |
| 89 | 39 | |
| 90 | 40 | $aColumns = array("name"); |
| 91 | 41 | $aColumnNames = array(_("Lookup name")); |
| ... | ... | @@ -147,174 +97,4 @@ function getGroupPage($iDocFieldID) { |
| 147 | 97 | return $sToRender; |
| 148 | 98 | } |
| 149 | 99 | |
| 150 | -// get page for removal | |
| 151 | -function getDeleteConfirmedPage($iUserID,$iGroupID) { | |
| 152 | - global $default; | |
| 153 | - $oUser = null; | |
| 154 | - $oGroup = null; | |
| 155 | - | |
| 156 | - // change headings if User selected | |
| 157 | - if (isset($iUserID)) { | |
| 158 | - $oUser = User::get($iUserID); | |
| 159 | - $heading = "<tr><td>" . _("Are you sure you wish to remove this user from the Group?") . "</td></tr>"; | |
| 160 | - } | |
| 161 | - | |
| 162 | - // change headings if User selected | |
| 163 | - if (isset($iGroupID)) { | |
| 164 | - $oGroup = Group::get($iGroupID); | |
| 165 | - $Groupdisplay = "<td>" . _("Group Name") . ": " . $oGroup->getName() . "</td>\n"; | |
| 166 | - } | |
| 167 | - | |
| 168 | - $sToRender .= "<table width=\"600\">" . renderHeading(_("Edit User Groups")) . "</table>"; | |
| 169 | - $sToRender .= "<table>\n"; | |
| 170 | - $sToRender .= "<tr>\n"; | |
| 171 | - $sToRender .= $heading; | |
| 172 | - $sToRender .= "</tr>\n"; | |
| 173 | - $sToRender .= "<td>". _("User Name") . ": " . getUserDisplay($oUser) . "</td>\n"; | |
| 174 | - $sToRender .= "<tr>\n"; | |
| 175 | - $sToRender .= "</tr>\n"; | |
| 176 | - $sToRender .= "<tr>\n"; | |
| 177 | - $sToRender .= $Groupdisplay; | |
| 178 | - $sToRender .= "</tr>\n"; | |
| 179 | - $sToRender .= "<tr>\n"; | |
| 180 | - $sToRender .= "</tr>\n"; | |
| 181 | - $sToRender .= "<tr>\n"; | |
| 182 | - $sToRender .= "</tr>\n"; | |
| 183 | - $sToRender .= "<td></td><td>" . getDeleteButton($oUser); | |
| 184 | - $sToRender .= "<td></td><td>" . getCancelButton($oUser); | |
| 185 | - $sToRender .= "</td></table>\n"; | |
| 186 | - | |
| 187 | - | |
| 188 | - return $sToRender; | |
| 189 | -} | |
| 190 | - | |
| 191 | -// show paig if deletion fails | |
| 192 | -function getPageFail() { | |
| 193 | - global $default; | |
| 194 | - | |
| 195 | - $sToRender .= "<table width=\"600\">" . renderHeading(_("Edit User Groups")) . "</table>"; | |
| 196 | - $sToRender .= "<table>\n"; | |
| 197 | - $sToRender .= "<tr><td><b>" . _("Sorry, Removal Failed") . "</b></td></tr>\n"; | |
| 198 | - $sToRender .= "<tr></tr>\n"; | |
| 199 | - $sToRender .= "</tr>\n"; | |
| 200 | - $sToRender .= "<tr>\n"; | |
| 201 | - $sToRender .= "</tr>\n"; | |
| 202 | - $sToRender .= "<tr>\n"; | |
| 203 | - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=removeUserFromGroup\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n"; | |
| 204 | - $sToRender .= "</tr>\n"; | |
| 205 | - | |
| 206 | - $sToRender .= "</table>\n"; | |
| 207 | - | |
| 208 | - | |
| 209 | - return $sToRender; | |
| 210 | -} | |
| 211 | - | |
| 212 | -// show success page if removed from Group successfully | |
| 213 | -function getPageSuccess() { | |
| 214 | - global $default; | |
| 215 | - | |
| 216 | - $sToRender .= "<table width=\"600\">" . renderHeading(_("Edit User Groups")) . "</table>"; | |
| 217 | - $sToRender .= "<table>\n"; | |
| 218 | - $sToRender .= "<tr><td><b>" . _("Success") . "!</b></td></tr>\n"; | |
| 219 | - $sToRender .= "<tr></tr>\n"; | |
| 220 | - $sToRender .= "<tr><td>" . _("The User was successfully removed from the Group") . "</td></tr>\n"; | |
| 221 | - $sToRender .= "<tr></tr>\n"; | |
| 222 | - $sToRender .= "<tr></tr>\n"; | |
| 223 | - $sToRender .= "<tr>\n"; | |
| 224 | - $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=listUsers\"><img src =\"" . KTHtml::getBackButton() . "\" border = \"0\" /></a></td>\n"; | |
| 225 | - $sToRender .= "</tr>\n"; | |
| 226 | - $sToRender .= "</table>\n"; | |
| 227 | - | |
| 228 | - | |
| 229 | - return $sToRender; | |
| 230 | -} | |
| 231 | -// show listbox of Users belonging to Users_Groups_link table | |
| 232 | -function getUserDisplay($oUser) { | |
| 233 | - global $default; | |
| 234 | - if (!isset($oUser)) { | |
| 235 | - $oPatternListBox = & new PatternListBox($default->users_table, "username", "id", "fUserID"); | |
| 236 | - if (Permission::userIsUnitAdministrator()) { | |
| 237 | - $oPatternListBox->setFromClause("INNER JOIN $default->users_groups_table UGL on ST.id=UGL.user_id " . | |
| 238 | - "INNER JOIN $default->groups_units_table GUL on UGL.group_id=GUL.group_id"); | |
| 239 | - $oPatternListBox->setWhereClause("GUL.unit_id=" . User::getUnitID($_SESSION["userID"])); | |
| 240 | - } | |
| 241 | - $oPatternListBox->setPostBackOnChange(true); | |
| 242 | - return $oPatternListBox->render(); | |
| 243 | - } else { | |
| 244 | - return "<input type=\"hidden\" name=\"fUserID\" value=\"" . $oUser->iId . "\">\n" . | |
| 245 | - $oUser->getUserName(); | |
| 246 | - } | |
| 247 | -} | |
| 248 | - | |
| 249 | -// display the listbox initially ..then just display the text | |
| 250 | -function getOtherGroupDisplay($oGroup) { | |
| 251 | - global $default; | |
| 252 | - if (!isset($oGroup)) { | |
| 253 | - if (Permission::userIsSystemAdministrator()) { | |
| 254 | - // if this is the system administrator, prepend group names with unit name | |
| 255 | - $oPatternListBox = & new PatternListBox($default->groups_table, "name", "id", "fOtherGroupID"); | |
| 256 | - $oPatternListBox->setFromClause("LEFT OUTER JOIN groups_units_link GUL on ST.id=GUL.group_id " . | |
| 257 | - "LEFT OUTER JOIN units_lookup UL on GUL.unit_id=UL.id"); | |
| 258 | - $oPatternListBox->setCompositeDisplayName("DISTINCT COALESCE(CONCAT(CONCAT(UL.name, '-'),ST.name),ST.name)"); | |
| 259 | - } else if (Permission::userIsUnitAdministrator()) { | |
| 260 | - // else if this is a unit administrator, only display the groups in your unit | |
| 261 | - $oPatternListBox = & new PatternListBox($default->groups_table, "name", "id", "fOtherGroupID"); | |
| 262 | - $oPatternListBox->setFromClause("INNER JOIN $default->groups_units_table GUL on ST.id=GUL.group_id"); | |
| 263 | - $oPatternListBox->setWhereClause("GUL.unit_id=" . User::getUnitID($_SESSION["userID"])); | |
| 264 | - } | |
| 265 | - return $oPatternListBox->render(); | |
| 266 | - } else { | |
| 267 | - return "<input type=\"hidden\" name=\"fOtherGroupID\" value=\"" . $oGroup->iId . "\">\n" . | |
| 268 | - $oGroup->getName(); | |
| 269 | - } | |
| 270 | -} | |
| 271 | -// show Group details on confirm deletion page | |
| 272 | -function getGroupDisplay($aGroup) { | |
| 273 | - global $default; | |
| 274 | - | |
| 275 | - $sBgColor = "#F5F6EE"; | |
| 276 | - $oGroup= null; | |
| 277 | - $sGroup = "<table cellspacing=1 border=0>"; | |
| 278 | - for ($i=0;$i < count($aGroup);$i++) { | |
| 279 | - $oGroup= Group::get($aGroup[$i]); | |
| 280 | - $Options .= "<tr><td>" . ($i+1) . "</td><td bgcolor=$sBgColor>". $oGroup->getName() ."</td></tr>\n"; | |
| 281 | - } | |
| 282 | - $sGroup .= $Options . "</table>"; | |
| 283 | - return $sGroup; | |
| 284 | - | |
| 285 | -} | |
| 286 | - | |
| 287 | - | |
| 288 | -// show delete button or select button | |
| 289 | -function getDeleteButton($oUser) { | |
| 290 | - global $default; | |
| 291 | - if (!isset($oUser)) { | |
| 292 | - return "<td align = right><input type=\"image\" src =\"" . KTHtml::getSelectButton() . "\" value=\"submit\" border=\"0\"/></td>\n"; | |
| 293 | - } else { | |
| 294 | - return "<td align = right><input type=\"image\" src =\"" . KTHtml::getDeleteButton() . "\" value=\"submit\" border=\"0\"/></td>\n"; | |
| 295 | - } | |
| 296 | -} | |
| 297 | - | |
| 298 | - | |
| 299 | -// show delete button or select button | |
| 300 | -function getSelectButton($oUser) { | |
| 301 | - global $default; | |
| 302 | - if (!isset($oUser)) { | |
| 303 | - return "<input type=\"image\" src =\"" . KTHtml::getSelectButton() . "\" value=\"submit\" border=\"0\"/>\n"; | |
| 304 | - } else { | |
| 305 | - return "<input type=\"image\" src =\"" . KTHtml::getSelectButton() . "\" value=\"submit\" border=\"0\"/>\n"; | |
| 306 | - } | |
| 307 | -} | |
| 308 | -// show cancel button | |
| 309 | -function getCancelButton($oUser) { | |
| 310 | - global $default; | |
| 311 | - if (!isset($oUser)) { | |
| 312 | - //return "<td align = right><a href=\"$default->rootUrl/control.php?action=UserManagement\"><img src =\"" . KTHtml::getCancelButton() . "\" value=\"cancel\" /></a></td>\n"; | |
| 313 | - } | |
| 314 | - else { | |
| 315 | - return "<a href=\"$default->rootUrl/control.php?action=listUsers\"><img src =\"" . KTHtml::getCancelButton() . "\" border = \"0\" /></a>\n"; | |
| 316 | - } | |
| 317 | -} | |
| 318 | - | |
| 319 | - | |
| 320 | 100 | ?> | ... | ... |