diff --git a/config/siteMap.inc b/config/siteMap.inc index bccce15..b2a2c56 100644 --- a/config/siteMap.inc +++ b/config/siteMap.inc @@ -222,11 +222,11 @@ $default->siteMap->addSectionColour("Advanced Search", "th", "A1571B"); $default->siteMap->addSectionColour("Standard Search", "th", "A1571B"); // pages for prefs section -$default->siteMap->addDefaultPage("preferences", "/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsBL.php", "Preferences", User, _("Preferences")); -$default->siteMap->addPage("editPrefsSuccess", "/presentation/lookAndFeel/knowledgeTree/preferences/editPrefsSuccess.php", "Preferences", User, "Preferences", false); -$default->siteMap->addPage("changeUserPassword", "/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementBL.php", "Preferences", User, "Preferences", false); -$default->siteMap->addSectionColour("Preferences", "th", "F87308"); -$default->siteMap->addSectionColour("Preferences", "td", "FEE3CE"); +$default->siteMap->addDefaultPage("preferences", "/presentation/lookAndFeel/knowledgeTree/preferences/preferences.php", "Preferences", User, _("Preferences")); +//$default->siteMap->addPage("editPrefsSuccess", "/presentation/lookAndFeel/knowledgeTree/preferences/editPrefsSuccess.php", "Preferences", User, "Preferences", false); +//$default->siteMap->addPage("changeUserPassword", "/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementBL.php", "Preferences", User, "Preferences", false); +//$default->siteMap->addSectionColour("Preferences", "th", "F87308"); +//$default->siteMap->addSectionColour("Preferences", "td", "FEE3CE"); // pages for Help section $default->siteMap->addDefaultPage("help", "/presentation/lookAndFeel/knowledgeTree/help.php", "Help", Guest, _("Help")); diff --git a/lib/templating/kt3template.inc.php b/lib/templating/kt3template.inc.php index 63c4a31..b688b4b 100644 --- a/lib/templating/kt3template.inc.php +++ b/lib/templating/kt3template.inc.php @@ -177,10 +177,12 @@ class KTPage { } else if ($sSection == 'search') { $this->componentLabel = 'Search'; $this->componentClass = 'search'; - } else if ($sSection == 'browse') { + } else if ($sSection == 'preferences') { + $this->componentLabel = 'Preferences'; + $this->componentClass = 'preferences'; } else { - $this->componentLabel = 'DMS Administration'; - $this->componentClass = 'administration'; + $this->componentLabel = 'Dashboard'; + $this->componentClass = 'dashboard'; } } diff --git a/presentation/lookAndFeel/knowledgeTree/preferences/editPrefsSuccess.php b/presentation/lookAndFeel/knowledgeTree/preferences/editPrefsSuccess.php deleted file mode 100644 index d3eb147..0000000 --- a/presentation/lookAndFeel/knowledgeTree/preferences/editPrefsSuccess.php +++ /dev/null @@ -1,44 +0,0 @@ -fileSystemRoot/presentation/webpageTemplate.inc"); - - $oPatternCustom = & new PatternCustom(); - $oPatternCustom->setHtml(getEditPageSuccess()); - $main->setCentralPayload($oPatternCustom); - $main->render(); - -} -?> \ No newline at end of file diff --git a/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsBL.php b/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsBL.php deleted file mode 100644 index a97bde8..0000000 --- a/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsBL.php +++ /dev/null @@ -1,51 +0,0 @@ -fileSystemRoot/lib/visualpatterns/PatternListBox.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableListFromQuery.inc"); - require_once("editUserPrefsUI.inc"); - require_once("$default->fileSystemRoot/lib/security/Permission.inc"); - require_once("$default->fileSystemRoot/lib/users/User.inc"); - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); - require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/foldermanagement/folderUI.inc"); - require_once("$default->fileSystemRoot/presentation/Html.inc"); - - - $oPatternCustom = & new PatternCustom(); - - $oPatternCustom->setHtml(getUserDetailsPage($_SESSION['userID'])); - $_SESSION["pageAccess"][$default->rootUrl . '/presentation/lookAndFeel/knowledgeTree/store.php'] = true; - $main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/store.php?fReturnURL=" . urlencode("$default->rootUrl/control.php?action=editPrefsSuccess")); - - $main->setCentralPayload($oPatternCustom); - $main->render(); -} -?> diff --git a/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsUI.inc b/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsUI.inc deleted file mode 100644 index b5a6087..0000000 --- a/presentation/lookAndFeel/knowledgeTree/preferences/editUserPrefsUI.inc +++ /dev/null @@ -1,91 +0,0 @@ -users_table WHERE id = ?", $iUserID); - $aDisplayColumns = array("name", "email", "mobile", "email_notification"); - $aStoreColumns = array("name", "email", "mobile", "email_notification"); - $aColumnNames = array(_("Name") . ": ", _("Email Address") . ": ", _("Mobile Number") . ": ", _("Email Notification") . ": "); - $aDisplayColumnTypes = array(1, 1, 1, 2); - $aDatabaseColumnTypes = array(1, 1, 1, 2); - - // get list of User properties...name...text field...is_Sys_admin and is_unit_admin..checkboxes - $oPattern = & new PatternEditableListFromQuery($sQuery, $default -> users_table, $aDisplayColumns, $aStoreColumns, $aColumnNames, $aDisplayColumnTypes, $aDatabaseColumnTypes); - $oPattern -> setUniqueName("userEdit"); - $oPattern -> setColumnsRequired(array(1, 0, 0, 0)); - - $sToRender.= renderHeading(_("Preferences")); - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - - $sToRender.= "\n"; - } - $sToRender.= "
" . _("Edit User Properties") . ":
".$oPattern -> render()."
\n"; - if (strcmp($default -> authenticationClass, "DBAuthenticator") == 0) { - $sToRender.= "rootUrl/control.php?action=changeUserPassword\">
\n"; - return $sToRender; -} - -function getEditPageSuccess() { - global $default; - $sToRender.= renderHeading(_("Preferences")); - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "
" . _("Success") . "!
" . _("The User was successfully modified") . "
rootUrl/control.php?action=preferences\">
\n"; - return $sToRender; -} - -function getEditPageFail() { - global $default; - $sToRender.= renderHeading(_("Preferences")); - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "
" . _("User modification Failed!") . "
rootUrl/control.php?action=preferences\">
\n"; - return $sToRender; -} diff --git a/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementBL.php b/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementBL.php deleted file mode 100644 index 38cda32..0000000 --- a/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementBL.php +++ /dev/null @@ -1,87 +0,0 @@ -fileSystemRoot/lib/security/Permission.inc"); - require_once("$default->fileSystemRoot/lib/users/User.inc"); - require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); - require_once("$default->fileSystemRoot/presentation/Html.inc"); - require_once("passwordManagementUI.inc"); - - $oPatternCustom = & new PatternCustom(); - - if (strcmp($default->authenticationClass,"DBAuthenticator") == 0) { - //only update passwords if we are in db authentication mode - $oUser = User::get($_SESSION["userID"]); - if (isset($fForUpdate)) { - //execute the update and return to the edit page?? - if (strlen($fNewPassword) > 0 && strlen($fNewPasswordConfirm) > 0) { - //if passwords have been entered - if (strcmp($fNewPassword, $fNewPasswordConfirm) == 0) { - //if the password and its confirmation are the same - $oUser->setPassword($fNewPassword); - if ($oUser->update()) { - //successful update - $oPatternCustom->setHtml(getPasswordUpdateSuccessPage()); - } else { - //update failed - $oPatternCustom->setHtml(getPage($oUser->getName())); - $main->setErrorMessage(_("An error occured while attempting to update the user's password")); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); - } - } else { - $oPatternCustom->setHtml(getPage($oUser->getName())); - $main->setErrorMessage(_("The password and its confirmation do not match. Please try again.")); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); - } - } else { - $oPatternCustom->setHtml(getPage($oUser->getName())); - $main->setErrorMessage(_("Blank passwords are not valid. Please try again.")); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); - } - } else { - //show the form - $oPatternCustom->setHtml(getPage($oUser->getName())); - $main->setFormAction($_SERVER["PHP_SELF"] . "?fForUpdate=1"); - } - - } else { - $oPatternCustom->setHtml(getPage($oUser->getName())); - $main->setErrorMessage(_("Passwords can only be updated in Knowledge Tree when authentication is against the database, not against an LDAP server")); - $main->setFormAction($_SERVER["PHP_SELF"]); - } - //render the page - $main->setCentralPayload($oPatternCustom); - $main->render(); -} -?> diff --git a/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementUI.inc b/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementUI.inc deleted file mode 100644 index d4c2591..0000000 --- a/presentation/lookAndFeel/knowledgeTree/preferences/passwordManagementUI.inc +++ /dev/null @@ -1,71 +0,0 @@ -\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "
" . _("User name") . ": $sUserName
" . _("New password") . ":
" . _("Confirm password") . ":
"; - $sToRender.= ""; - $sToRender.= "rootUrl/control.php?action=preferences\">\n"; - $sToRender.= "
\n"; - return $sToRender; -} - -function getPasswordUpdateSuccessPage() { - global $default; - $sToRender.= renderHeading(_("Update user password")); - $sToRender.= "
\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "\n"; - $sToRender.= "
" . _("The user's password was successfully updated") . "
rootUrl/control.php?action=preferences\">
\n"; - return $sToRender; -} -?> diff --git a/presentation/lookAndFeel/knowledgeTree/preferences/preferences.php b/presentation/lookAndFeel/knowledgeTree/preferences/preferences.php new file mode 100644 index 0000000..4f9c208 --- /dev/null +++ b/presentation/lookAndFeel/knowledgeTree/preferences/preferences.php @@ -0,0 +1,147 @@ + 'preferences', 'name' => 'Preferences'), + ); + + function do_main() { + $this->oPage->setBreadcrumbDetails("Your Preferences"); + $this->oPage->title = "Dashboard"; // FIXME should this be a mutator? + + + $oUser =& $this->oUser; + + + $edit_fields = array(); + $edit_fields[] = new KTStringWidget('Name','Your full name. This is shown in reports and listings. e.g. John Smith', 'name', $oUser->getName(), $this->oPage, true); + $edit_fields[] = new KTStringWidget('Email Address','Your email address. Notifications and alerts are mailed to this address if email notifications is set below. e.g. jsmith@acme.com', 'email_address', $oUser->getEmail(), $this->oPage, false); + $edit_fields[] = new KTCheckboxWidget('Email Notifications','If this is specified then the you will receive certain notifications. If it isn\'t set, then you will only see notifications on the Dashboard', 'email_notifications', $oUser->getEmailNotification(), $this->oPage, false); + $edit_fields[] = new KTStringWidget('Mobile Number','Your mobile phone number. If the system is configured to send notifications to cellphones, then this number will be SMS\'d with notifications. e.g. +27 99 999 9999', 'mobile_number', $oUser->getMobile(), $this->oPage, false); + + + + $oTemplating = new KTTemplating; + $oTemplate = $oTemplating->loadTemplate("ktcore/principals/preferences"); + $aTemplateData = array( + "context" => $this, + 'edit_fields' => $edit_fields, + ); + return $oTemplate->render($aTemplateData); + } + + function do_setPassword() { + $this->oPage->setBreadcrumbDetails("Your Password"); + $this->oPage->title = "Dashboard"; // FIXME should this be a mutator? + + + $oUser =& $this->oUser; + + $edit_fields = array(); + $edit_fields[] = new KTPasswordWidget('Password','Specify your new password..', 'password', null, $this->oPage, true); + $edit_fields[] = new KTPasswordWidget('Confirm Password','Confirm the password specified above.', 'confirm_password', null, $this->oPage, true); + + + $oTemplating = new KTTemplating; + $oTemplate = $oTemplating->loadTemplate("ktcore/principals/password"); + $aTemplateData = array( + "context" => $this, + 'edit_fields' => $edit_fields, + ); + return $oTemplate->render($aTemplateData); + } + + + + function do_updatePassword() { + + $password = KTUtil::arrayGet($_REQUEST, 'password'); + $confirm_password = KTUtil::arrayGet($_REQUEST, 'confirm_password'); + + if (empty($password)) { + $this->errorRedirectToMain("You must specify a password for the user."); + } else if ($password !== $confirm_password) { + $this->errorRedirectToMain("The passwords you specified do not match."); + } + // FIXME more validation would be useful. + // validated and ready.. + $this->startTransaction(); + + $oUser =& $this->oUser; + + + // FIXME this almost certainly has side-effects. do we _really_ want + $oUser->setPassword(md5($password)); // + + $res = $oUser->update(); + //$res = $oUser->doLimitedUpdate(); // ignores a fix blacklist of items. + + + if (PEAR::isError($res) || ($res == false)) { + $this->errorRedirectoToMain('Failed to update user.'); + } + + $this->commitTransaction(); + $this->successRedirectToMain('Your password has been changed.'); + + } + + + function do_saveUser() { + $oUser =& $this->oUser; + + $name = KTUtil::arrayGet($_REQUEST, 'name'); + if (empty($name)) { + $this->errorRedirectToMain('You must specify your name.'); + } + + $email_address = KTUtil::arrayGet($_REQUEST, 'email_address'); + $email_notifications = KTUtil::arrayGet($_REQUEST, 'email_notifications', false); + if ($email_notifications !== false) $email_notifications = true; + $mobile_number = KTUtil::arrayGet($_REQUEST, 'mobile_number'); + + + $this->startTransaction(); + + $oUser->setName($name); + $oUser->setEmail($email_address); + $oUser->setEmailNotification($email_notifications); + $oUser->setMobile($mobile_number); + + + // old system used the very evil store.php. + // here we need to _force_ a limited update of the object, via a db statement. + // + // $res = $oUser->update(); + $res = $oUser->doLimitedUpdate(); // ignores a fix blacklist of items. + + if (PEAR::isError($res) || ($res == false)) { + $this->errorRedirectoToMain('Failed to update your details.'); + } + + $this->commitTransaction(); + $this->successRedirectToMain('Your details have been updated.'); + + } + + +} + +$oDispatcher = new DashboardDispatcher(); +$oDispatcher->dispatch(); + +?> \ No newline at end of file diff --git a/resources/css/kt-headings.css b/resources/css/kt-headings.css index a9fee9d..c502bff 100644 --- a/resources/css/kt-headings.css +++ b/resources/css/kt-headings.css @@ -12,6 +12,17 @@ #content h1.browse_collections .fahrner { display: none; } +#content h1.preferences { + border: 1px solid #565963; + height: 20px; + background: #a0a9b8 url(/resources/graphics/fahrner_preferences.png) center left no-repeat; + padding: 5px; + color: white; +} + +#content h1.preferences .fahrner { display: none; } + + #content h1.dashboard { border: 1px solid #565963; height: 40px; diff --git a/templates/ktcore/principals/password.smarty b/templates/ktcore/principals/password.smarty new file mode 100644 index 0000000..46b6207 --- /dev/null +++ b/templates/ktcore/principals/password.smarty @@ -0,0 +1,22 @@ +

Password

+ +

FIXME better helptext. Change your password.

+ +
+ + +
+ Your Details + + {foreach item=oWidget from=$edit_fields} + {$oWidget->render()} + {/foreach} + + +
+ +
\ No newline at end of file diff --git a/templates/ktcore/principals/preferences.smarty b/templates/ktcore/principals/preferences.smarty new file mode 100644 index 0000000..bd3fa00 --- /dev/null +++ b/templates/ktcore/principals/preferences.smarty @@ -0,0 +1,23 @@ +

Preferences

+ +

From here you can adjust certain basic preferences about +how you work with KnowledgeTree.

+ +
+ + +
+ Your Details + + {foreach item=oWidget from=$edit_fields} + {$oWidget->render()} + {/foreach} + + +
+ +
\ No newline at end of file