diff -Naur roundcubemail-0.2.1/plugins/changepasswd/changepasswd.php webmailtest/plugins/changepasswd/changepasswd.php
--- roundcubemail-0.2.1/plugins/changepasswd/changepasswd.php	1970-01-01 01:00:00.000000000 +0100
+++ webmailtest/plugins/changepasswd/changepasswd.php	2009-04-07 00:19:01.557601796 +0200
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/changepasswd/chnagepasswd.php                                 |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Provide functionality for user's password modification via sql      |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir                                                   |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+class changepasswd extends rcube_plugin
+{
+	function init()
+	{
+		// preperation for Plugin API
+		// not used yet
+	}
+}
+
+?>
\ No newline at end of file
diff -Naur roundcubemail-0.2.1/plugins/changepasswd/config.inc.php webmailtest/plugins/changepasswd/config.inc.php
--- roundcubemail-0.2.1/plugins/changepasswd/config.inc.php	1970-01-01 01:00:00.000000000 +0100
+++ webmailtest/plugins/changepasswd/config.inc.php	2009-04-07 01:08:06.579558440 +0200
@@ -0,0 +1,42 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | Changepasswd configuration file                                       |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+
+*/
+
+$changepasswd_config = array();
+
+// User database settings
+$changepasswd_config['db_dsnw'] = 'mysql://dbuser:dbpassword@localhost/ispcp';
+
+// PEAR database DSN for read only operations (if empty write database will be used)
+// useful for database replication
+$changepasswd_config['db_dsnr'] = '';
+
+// use persistent db-connections
+// beware this will not "always" work as expected
+// see: http://www.php.net/manual/en/features.persistent-connections.php
+$changepasswd_config['db_persistent'] = FALSE;
+
+// query to verify current password
+// this query should return 1 result - the data returned is not used, the number of rows is counted to verify success
+// %u will be replaced with the users username (from RC session)
+// %o will be replaced with the users current password
+// %n will be replaced with the users new password
+$changepasswd_config['sql_select'] = "SELECT mail_addr FROM mail_users WHERE mail_addr='%u' AND mail_pass='%o';";
+
+// query to update password
+// %u will be replaced with the users username (from RC session)
+// %o will be replaced with the users current password
+// %n will be replaced with the users new password
+$changepasswd_config['sql_update'] = "UPDATE mail_users SET mail_pass = '%n', status='change' WHERE mail_addr='%u' AND mail_pass='%o';";
+
+?>
diff -Naur roundcubemail-0.2.1/program/js/app.js webmailtest/program/js/app.js
--- roundcubemail-0.2.1/program/js/app.js	2009-02-27 12:06:29.000000000 +0100
+++ webmailtest/program/js/app.js	2009-04-07 00:19:01.757504589 +0200
@@ -288,6 +288,7 @@
 
       case 'settings':
         this.enable_command('preferences', 'identities', 'save', 'folders', true);
+        this.enable_command('changepasswd', true);
         
         if (this.env.action=='identities' || this.env.action=='edit-identity' || this.env.action=='add-identity') {
           this.enable_command('add', this.env.identities_level < 2);
@@ -300,6 +301,9 @@
         if (this.env.action=='folders')
           this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', 'delete-folder', true);
 
+        if (this.env.action=='changepasswd')
+          this.enable_command('save-changepasswd', true);
+
         if (this.gui_objects.identitieslist)
           {
           this.identity_list = new rcube_list_widget(this.gui_objects.identitieslist, {multiselect:false, draggable:false, keyboard:false});
@@ -1035,6 +1039,15 @@
         this.goto_url('identities');
         break;
           
+      case 'changepasswd':
+        this.goto_url('changepasswd');
+        break;
+
+      case 'save-changepasswd':
+        if (changepasswd_check_input())
+          this.gui_objects.editform.submit();
+        break;
+
       case 'delete-identity':
         this.delete_identity();
         
diff -Naur roundcubemail-0.2.1/program/js/changepasswd.js webmailtest/program/js/changepasswd.js
--- roundcubemail-0.2.1/program/js/changepasswd.js	1970-01-01 01:00:00.000000000 +0100
+++ webmailtest/program/js/changepasswd.js	2009-04-07 00:19:01.757504589 +0200
@@ -0,0 +1,43 @@
+/*
+ +-----------------------------------------------------------------------+
+ | RoundCube Webmail Client Script                                       |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2008, RoundCube Dev, - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir                                                   |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+function changepasswd_check_input() {
+	var input_curpasswd = rcube_find_object('_curpasswd');
+	var input_newpasswd = rcube_find_object('_newpasswd');
+	var input_confpasswd = rcube_find_object('_confpasswd');
+	
+	if (input_curpasswd && input_curpasswd.value == '') {
+		alert(rcmail.get_label('nocurpassword'));
+		input_curpasswd.focus();
+	}        
+	else if (input_newpasswd && input_newpasswd.value == '' && input_confpasswd && input_confpasswd.value == '') {
+		alert(rcmail.get_label('nopassword'));
+		input_newpasswd.value = '';
+		input_confpasswd.value = '';
+		input_newpasswd.focus();
+	}
+	else if (input_newpasswd && input_confpasswd && input_newpasswd.value != input_confpasswd.value) {
+		alert(rcmail.get_label('passwordinconsistency'));
+		input_newpasswd.value = '';
+		input_confpasswd.value = '';
+		input_newpasswd.focus();
+	}
+	else {
+		return true;
+	}
+	
+	return false;
+}
diff -Naur roundcubemail-0.2.1/program/localization/de_DE/labels.inc webmailtest/program/localization/de_DE/labels.inc
--- roundcubemail-0.2.1/program/localization/de_DE/labels.inc	2009-02-27 11:54:17.000000000 +0100
+++ webmailtest/program/localization/de_DE/labels.inc	2009-04-07 01:21:22.060811688 +0200
@@ -264,4 +264,8 @@
 $labels['MB'] = 'MB';
 $labels['GB'] = 'GB';
 
+$labels['changepasswd']  = 'Passwort ändern';
+$labels['curpasswd']  = 'Aktuelles Passwort';
+$labels['newpasswd']  = 'Neues Passwort';
+$labels['confpasswd']  = 'Neues Passowrt wiederholen';
 ?>
diff -Naur roundcubemail-0.2.1/program/localization/de_DE/messages.inc webmailtest/program/localization/de_DE/messages.inc
--- roundcubemail-0.2.1/program/localization/de_DE/messages.inc	2009-01-17 02:55:39.000000000 +0100
+++ webmailtest/program/localization/de_DE/messages.inc	2009-04-07 01:19:53.439557881 +0200
@@ -95,4 +95,11 @@
 $messages['nofromaddress'] = 'Fehlende E-Mail-Adresse in ausgewählter Identität';
 $messages['editorwarning'] = 'Beim Wechseln in den Texteditor gehen alle Textformatierungen verloren. Möchten Sie fortfahren?';
 
+$messages['nocurpassword'] = 'Bitte geben Sie Ihr aktuelles Passwort ein';
+$messages['nopassword'] = 'Bitte geben Sie Ihr neues Passwort ein';
+$messages['passwordinconsistency'] = 'Die Passwörter stimmen nicht überein';
+$messages['passwordconnerror'] = 'Fehler: Kann nicht mit Server verbinden';
+$messages['passwordsrverror'] = 'Fehler: Unbekannter Serverfehler';
+$messages['passwordfailed'] = 'Fehler: Aktuelles Passwort nicht korrekt';
+$messages['passwordchanged'] = 'Das Passwort wurde erfolgreich geändert, bitte jetzt abmelden um die Änderung zu übernehmen';
 ?>
diff -Naur roundcubemail-0.2.1/program/localization/en_US/labels.inc webmailtest/program/localization/en_US/labels.inc
--- roundcubemail-0.2.1/program/localization/en_US/labels.inc	2009-01-17 02:55:39.000000000 +0100
+++ webmailtest/program/localization/en_US/labels.inc	2009-04-07 00:19:01.767499589 +0200
@@ -323,4 +323,9 @@
 $labels['MB'] = 'MB';
 $labels['GB'] = 'GB';
 
+$labels['changepasswd']  = 'Change password';
+$labels['curpasswd']  = 'Current password';
+$labels['newpasswd']  = 'New password';
+$labels['confpasswd']  = 'Confirm new password';
+
 ?>
diff -Naur roundcubemail-0.2.1/program/localization/en_US/messages.inc webmailtest/program/localization/en_US/messages.inc
--- roundcubemail-0.2.1/program/localization/en_US/messages.inc	2009-01-17 02:55:39.000000000 +0100
+++ webmailtest/program/localization/en_US/messages.inc	2009-04-07 01:17:08.387222918 +0200
@@ -95,4 +95,12 @@
 $messages['nofromaddress'] = 'Missing e-mail address in selected identity';
 $messages['editorwarning'] = 'Switching to the plain text editor will cause all text formatting to be lost. Do you wish to continue?';
 
+$messages['nocurpassword'] = 'Please enter your current password';
+$messages['nopassword'] = 'Please enter your new password';
+$messages['passwordinconsistency'] = 'Inconsistency in new password, please try again';
+$messages['passwordconnerror'] = 'Error: Cannot connect to server';
+$messages['passwordsrverror'] = 'Error: Unknown server error';
+$messages['passwordfailed'] = 'Error: Current password incorrect';
+$messages['passwordchanged'] = 'Successfully changed password, please logout now to activate the new password.';
+
 ?>
diff -Naur roundcubemail-0.2.1/program/steps/settings/changepasswd.inc webmailtest/program/steps/settings/changepasswd.inc
--- roundcubemail-0.2.1/program/steps/settings/changepasswd.inc	1970-01-01 01:00:00.000000000 +0100
+++ webmailtest/program/steps/settings/changepasswd.inc	2009-04-07 00:19:01.767499589 +0200
@@ -0,0 +1,72 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/changepasswd/changepasswd.inc                                 |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Provide functionality for user password modification                |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir                                                   |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+$OUTPUT->set_pagetitle(rcube_label('changepasswd'));
+$OUTPUT->add_handler('changepasswd', 'rcmail_changepasswd_form');
+$OUTPUT->include_script('changepasswd.js');
+$OUTPUT->add_label('nocurpassword', 'nopassword', 'passwordinconsistency');
+$OUTPUT->send('changepasswd');
+
+function rcmail_changepasswd_form($attrib) {
+	list($form_start, $form_end) = get_form_tags($attrib, 'save-changepasswd');
+	unset($attrib['form']);
+	
+	// return the complete edit form as table
+	$out = $form_start;
+	$table = new html_table(array('cols' => 2));
+
+	// show old password field
+	if (!isset($no_override['curpasswd']))
+	{
+		$field_id = 'rcmfd_curpwd';
+		$input_curpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id));
+		
+		$table->add('title', html::label($field_id, Q(rcube_label('curpasswd'))));
+		$table->add(null, $input_curpasswd->show());
+	}
+	  
+	// show new password field
+	if (!isset($no_override['newpasswd']))
+	{
+		$field_id = 'rcmfd_newpwd';
+		$input_newpasswd = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id,));
+		
+		$table->add('title', html::label($field_id, Q(rcube_label('newpasswd'))));
+		$table->add(null, $input_newpasswd->show());
+	}
+	
+	// show new password confirm field
+	if (!isset($no_override['confpasswd']))
+	{
+		$field_id = 'rcmfd_cnfpwd';
+		$input_confpasswd = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id));
+		
+		$table->add('title', html::label($field_id, Q(rcube_label('confpasswd'))));
+		$table->add(null, $input_confpasswd->show());
+	}
+	
+	$out .= $table->show($attrib);
+	$out .= $form_end;
+	
+	return $out;  
+}
+
+?>
\ No newline at end of file
diff -Naur roundcubemail-0.2.1/program/steps/settings/save_changepasswd.inc webmailtest/program/steps/settings/save_changepasswd.inc
--- roundcubemail-0.2.1/program/steps/settings/save_changepasswd.inc	1970-01-01 01:00:00.000000000 +0100
+++ webmailtest/program/steps/settings/save_changepasswd.inc	2009-04-07 01:16:04.166314691 +0200
@@ -0,0 +1,75 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/changepasswd/save_changepasswd.inc                            |
+ |                                                                       |
+ | This file is part of the RoundCube Webmail client                     |
+ | Copyright (C) 2008, RoundCube Dev. - Switzerland                      |
+ | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | PURPOSE:                                                              |
+ |   Save user account password                                          |
+ |                                                                       |
+ +-----------------------------------------------------------------------+
+ | Author: Philip Weir                                                   |
+ +-----------------------------------------------------------------------+
+ | Requires: plugins/changepasswd/config.inc.php                         |
+ +-----------------------------------------------------------------------+
+
+ $Id: $
+
+*/
+
+require_once('plugins/changepasswd/config.inc.php');
+
+define('INCLUDEPATH', '../../include');
+require_once(INCLUDEPATH . '/ispcp-config.php');
+require_once(INCLUDEPATH . '/ispcp-db-keys.php');
+require_once(INCLUDEPATH . '/ispcp-functions.php');
+
+$old_pw = encrypt_db_password($_POST['_curpasswd']);
+$new_pw = encrypt_db_password($_POST['_newpasswd']);
+
+$sql_select = str_replace(array('%u', '%o', '%n'),
+				array($_SESSION['username'], $old_pw, $new_pw),
+				$changepasswd_config['sql_select']);
+
+$sql_update = str_replace(array('%u', '%o', '%n'),
+				array($_SESSION['username'], $old_pw, $new_pw),
+				$changepasswd_config['sql_update']);
+
+$user_db = new rcube_mdb2($changepasswd_config['db_dsnw'], $changepasswd_config['db_dsnr'], $changepasswd_config['db_persistent']);
+$user_db->db_connect('w');
+
+// check DB connections and exit on failure
+if ($err_str = $user_db->is_error()) {
+  raise_error(array(
+    'code' => 603,
+    'type' => 'db',
+    'message' => $err_str), FALSE, TRUE);
+}
+$user_db->query($sql_select);
+
+if ($user_db->num_rows() == 1) {
+	$updated = false;
+	$updated = $user_db->query($sql_update);
+
+	if ($updated) {
+		// notify ISPCP to update the newly set password
+		send_request();
+		$_SESSION['password'] = $RCMAIL->encrypt_passwd($new_pw);
+		$OUTPUT->show_message('passwordchanged', 'confirmation');
+	}
+	else {
+		$OUTPUT->show_message('passwordfailed', 'error');
+	}
+}
+else {
+  	$OUTPUT->show_message('passwordfailed', 'error');
+}
+
+// go to next step
+rcmail_overwrite_action('changepasswd');
+
+?>
diff -Naur roundcubemail-0.2.1/skins/default/includes/settingstabs.html webmailtest/skins/default/includes/settingstabs.html
--- roundcubemail-0.2.1/skins/default/includes/settingstabs.html	2008-05-20 15:33:47.000000000 +0200
+++ webmailtest/skins/default/includes/settingstabs.html	2009-04-07 00:19:01.917426823 +0200
@@ -2,4 +2,5 @@
 <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
 <span id="settingstabfolders" class="tablink"><roundcube:button command="folders" type="link" label="folders" title="managefolders" class="tablink" /></span>
 <span id="settingstabidentities" class="tablink"><roundcube:button command="identities" type="link" label="identities" title="manageidentities" class="tablink" /></span>
+<span id="settingstabchangepasswd" class="tablink"><roundcube:button command="changepasswd" type="link" label="password" title="changepasswd" class="tablink" /></span>
 </div>
diff -Naur roundcubemail-0.2.1/skins/default/templates/changepasswd.html webmailtest/skins/default/templates/changepasswd.html
--- roundcubemail-0.2.1/skins/default/templates/changepasswd.html	1970-01-01 01:00:00.000000000 +0100
+++ webmailtest/skins/default/templates/changepasswd.html	2009-04-07 00:19:01.917426823 +0200
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title><roundcube:object name="pagetitle" /></title>
+<roundcube:include file="/includes/links.html" />
+<link rel="stylesheet" type="text/css" href="/settings.css" />
+<script type="text/javascript" src="/functions.js"></script>
+</head>
+<body onload="rcube_init_settings_tabs()">
+
+<roundcube:include file="/includes/taskbar.html" />
+<roundcube:include file="/includes/header.html" />
+<roundcube:include file="/includes/settingstabs.html" />
+
+<div id="userprefs-box">
+<div id="userprefs-title"><roundcube:label name="changepasswd" /></div>
+
+<div style="padding:15px 0 15px 15px">
+<roundcube:object name="changepasswd" />
+<div style="clear:left"></div>			
+</div>
+</div>
+
+<p id="listbuttons"><roundcube:button command="save-changepasswd" type="input" class="button mainaction" label="save" /></p>
+		
+</body>
+</html>

