Commit fed5ab9393681e8278217073dbcd6657f8ca149a
1 parent
c95ec4c2
Update functionality so that admin can change user passwords when db
authentication mode is used. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2738 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
172 additions
and
1 deletions
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/editUserUI.inc
| @@ -74,7 +74,12 @@ function getUserDetailsPage($iUserID) { | @@ -74,7 +74,12 @@ function getUserDetailsPage($iUserID) { | ||
| 74 | $sToRender .= "<tr>\n"; | 74 | $sToRender .= "<tr>\n"; |
| 75 | $sToRender .= "</tr>\n"; | 75 | $sToRender .= "</tr>\n"; |
| 76 | $sToRender .= "<tr><td align = right><input type=\"image\" src =\"$default->graphicsUrl/widgets/update.gif\" value=\"Update\" border=\"0\"/>\n"; | 76 | $sToRender .= "<tr><td align = right><input type=\"image\" src =\"$default->graphicsUrl/widgets/update.gif\" value=\"Update\" border=\"0\"/>\n"; |
| 77 | - $sToRender .= getCancelButton(User::get($iUserID)) . "</td></tr>"; | 77 | + //$sToRender .= getCancelButton(User::get($iUserID)) . "</td></tr>"; |
| 78 | + $sToRender .= getCancelButton(User::get($iUserID)); | ||
| 79 | + if (strcmp($default->authenticationClass,"DBAuthenticator") == 0) { | ||
| 80 | + //only update password if we are using the db | ||
| 81 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=userPasswordManagement&fUserID=$iUserID\">Update password</td></tr>\n"; | ||
| 82 | + } | ||
| 78 | $sToRender .= "</table>\n"; | 83 | $sToRender .= "</table>\n"; |
| 79 | 84 | ||
| 80 | return $sToRender; | 85 | return $sToRender; |
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/passwordManagementBL.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * $Id$ | ||
| 4 | + * | ||
| 5 | + * Change a user's password | ||
| 6 | + * | ||
| 7 | + * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 8 | + * | ||
| 9 | + * This program is free software; you can redistribute it and/or modify | ||
| 10 | + * it under the terms of the GNU General Public License as published by | ||
| 11 | + * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | + * (at your option) any later version. | ||
| 13 | + * | ||
| 14 | + * This program is distributed in the hope that it will be useful, | ||
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | + * GNU General Public License for more details. | ||
| 18 | + * | ||
| 19 | + * You should have received a copy of the GNU General Public License | ||
| 20 | + * along with this program; if not, write to the Free Software | ||
| 21 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | + * | ||
| 23 | + * @version $Revision$ | ||
| 24 | + * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 25 | + * @package administration.usermanagement | ||
| 26 | + */ | ||
| 27 | + | ||
| 28 | +require_once("../../../../../config/dmsDefaults.php"); | ||
| 29 | + | ||
| 30 | +if (checkSession()) { | ||
| 31 | + require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | ||
| 32 | + require_once("$default->fileSystemRoot/lib/users/User.inc"); | ||
| 33 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | ||
| 34 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 35 | + require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 36 | + require_once("passwordManagementUI.inc"); | ||
| 37 | + | ||
| 38 | + $oPatternCustom = & new PatternCustom(); | ||
| 39 | + | ||
| 40 | + if (strcmp($default->authenticationClass,"DBAuthenticator") == 0) { | ||
| 41 | + //only update passwords if we are in db authentication mode | ||
| 42 | + if (isset($fUserID)){ | ||
| 43 | + if (Permission::userIsSystemAdministrator()) { | ||
| 44 | + $oUser = User::get($fUserID); | ||
| 45 | + //only the administrator is allowed to change passwords here | ||
| 46 | + if (isset($fForUpdate)) { | ||
| 47 | + //execute the update and return to the edit page?? | ||
| 48 | + if (strlen($fNewPassword) > 0 && strlen($fNewPasswordConfirm) > 0) { | ||
| 49 | + //if passwords have been entered | ||
| 50 | + if (strcmp($fNewPassword, $fNewPasswordConfirm) == 0) { | ||
| 51 | + //if the password and its confirmation are the same | ||
| 52 | + $oUser->setPassword($fNewPassword); | ||
| 53 | + if ($oUser->update()) { | ||
| 54 | + //successful update | ||
| 55 | + $oPatternCustom->setHtml(getPasswordUpdateSuccessPage()); | ||
| 56 | + } else { | ||
| 57 | + //update failed | ||
| 58 | + $oPatternCustom->setHtml(getPage($oUser->getName())); | ||
| 59 | + $main->setErrorMessage("An error occured while attempting to update the user's password"); | ||
| 60 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fUserID=$fUserID"); | ||
| 61 | + } | ||
| 62 | + } else { | ||
| 63 | + $oPatternCustom->setHtml(getPage($oUser->getName())); | ||
| 64 | + $main->setErrorMessage("The password and its confirmation do not match. Please try again."); | ||
| 65 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fUserID=$fUserID"); | ||
| 66 | + } | ||
| 67 | + } else { | ||
| 68 | + $oPatternCustom->setHtml(getPage($oUser->getName())); | ||
| 69 | + $main->setErrorMessage("Blank passwords are not valid. Please try again."); | ||
| 70 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fUserID=$fUserID"); | ||
| 71 | + } | ||
| 72 | + } else { | ||
| 73 | + //show the page | ||
| 74 | + $oPatternCustom->setHtml(getPage($oUser->getName())); | ||
| 75 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1&fUserID=$fUserID"); | ||
| 76 | + } | ||
| 77 | + } else { | ||
| 78 | + $main->setErrorMessage("Only an administrator can update a user password from here"); | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + } else { | ||
| 82 | + $oPatternCustom->setHtml(getPage($oUser->getName())); | ||
| 83 | + $main->setErrorMessage("Passwords can only be update in Knowledgew Tree when authentication is against the MySQL database, not against an LDAP server"); | ||
| 84 | + $main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 85 | + } | ||
| 86 | + //render the page | ||
| 87 | + $main->setCentralPayload($oPatternCustom); | ||
| 88 | + $main->render(); | ||
| 89 | +} | ||
| 90 | +?> |
presentation/lookAndFeel/knowledgeTree/administration/usermanagement/passwordManagementUI.inc
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * $Id$ | ||
| 4 | + * | ||
| 5 | + * Updaate user password | ||
| 6 | + * | ||
| 7 | + * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 8 | + * | ||
| 9 | + * This program is free software; you can redistribute it and/or modify | ||
| 10 | + * it under the terms of the GNU General Public License as published by | ||
| 11 | + * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | + * (at your option) any later version. | ||
| 13 | + * | ||
| 14 | + * This program is distributed in the hope that it will be useful, | ||
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | + * GNU General Public License for more details. | ||
| 18 | + * | ||
| 19 | + * You should have received a copy of the GNU General Public License | ||
| 20 | + * along with this program; if not, write to the Free Software | ||
| 21 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | + * | ||
| 23 | + * @version $Revision$ | ||
| 24 | + * @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa | ||
| 25 | + * @package administration.usermanagement | ||
| 26 | + */ | ||
| 27 | + | ||
| 28 | +function getPage($sUserName) { | ||
| 29 | + global $default; | ||
| 30 | + $sToRender = renderHeading("Update user password"); | ||
| 31 | + $sToRender .= "<br>\n"; | ||
| 32 | + $sToRender .= "<table cellpadding=\"5\">\n"; | ||
| 33 | + $sToRender .= "<tr>\n"; | ||
| 34 | + $sToRender .= "<td bgcolor=\"6699FF\">User name: </td>\n"; | ||
| 35 | + $sToRender .= "<td bgcolor=\"F5F6EE\">$sUserName</td>\n"; | ||
| 36 | + $sToRender .= "</tr>\n"; | ||
| 37 | + $sToRender .= "<tr>\n"; | ||
| 38 | + $sToRender .= "<td bgcolor=\"6699FF\">New password: </td>\n"; | ||
| 39 | + $sToRender .= "<td><input type=\"password\" name=\"fNewPassword\"></td>\n"; | ||
| 40 | + $sToRender .= "</tr>\n"; | ||
| 41 | + $sToRender .= "<tr>\n"; | ||
| 42 | + $sToRender .= "<td bgcolor=\"6699FF\">Confirm password: </td>\n"; | ||
| 43 | + $sToRender .= "<td bgcolor=\"F5F6EE\"><input type=\"password\" name=\"fNewPasswordConfirm\"></td>\n"; | ||
| 44 | + $sToRender .= "</tr>\n"; | ||
| 45 | + $sToRender .= "<tr>\n"; | ||
| 46 | + $sToRender .= "</tr>\n"; | ||
| 47 | + $sToRender .= "<tr>\n"; | ||
| 48 | + $sToRender .= "<td colspan=\"2\" align=\"right\">"; | ||
| 49 | + $sToRender .= "<td align = right><input type=\"image\" src =\"$default->graphicsUrl/widgets/update.gif\" value=\"Update\" border=\"0\"/>"; | ||
| 50 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=userManagement\"><img src =\"$default->graphicsUrl/widgets/cancel.gif\" value=\"cancel\" border=\"0\"/></a>\n"; | ||
| 51 | + $sToRender .= "</tr>\n"; | ||
| 52 | + $sToRender .= "</table>\n"; | ||
| 53 | + | ||
| 54 | + return $sToRender; | ||
| 55 | + | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +function getPasswordUpdateSuccessPage() { | ||
| 59 | + global $default; | ||
| 60 | + | ||
| 61 | + $sToRender .= renderHeading("Update user password"); | ||
| 62 | + $sToRender .= "<br>\n"; | ||
| 63 | + $sToRender .= "<table>\n"; | ||
| 64 | + $sToRender .= "<tr><td>The user's password was successfully updated</td></tr>\n"; | ||
| 65 | + $sToRender .= "<tr></tr>\n"; | ||
| 66 | + $sToRender .= "<tr></tr>\n"; | ||
| 67 | + $sToRender .= "<tr>\n"; | ||
| 68 | + $sToRender .= "<td></td><td align = right><a href=\"$default->rootUrl/control.php?action=userManagement\"><img src =\"$default->graphicsUrl/widgets/back.gif\" border = \"0\" /></a></td>\n"; | ||
| 69 | + $sToRender .= "</tr>\n"; | ||
| 70 | + $sToRender .= "</table>\n"; | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + return $sToRender; | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +?> | ||
| 0 | \ No newline at end of file | 77 | \ No newline at end of file |