Hace unos días hablaba de un cliente de correo imap llamado RoundCube, pero le face falta una opción que aún no trae por defecto, es el cambiar la contraseña, el problema que cuando instalamos un servidor de correo con direcciones virtuales en Linux con MySQL generalmente se usa SALS por medio de PAM para los inicios de sesión, eso deja a Roundcube con un problema, donde la contraseña queda fuera de su control. Pero existe una forma de integrar esta funcionalidad en en RoundCube, yo he visto algunos tutoriales que hablan de versiones inferiores, yo he probado esta en la 0.2.2 y funciona perfectamente incluso con el skin de OutLook para RoundCube.
1. Abrir roundcube /index.php
========================================================== Busca [~ Linea 188 ] 'settings' => array( 'folders' => 'manage_folders.inc', 'create-folder' => 'manage_folders.inc', 'rename-folder' => 'manage_folders.inc', 'delete-folder' => 'manage_folders.inc', 'subscribe' => 'manage_folders.inc', 'unsubscribe' => 'manage_folders.inc', 'add-identity' => 'edit_identity.inc', ) ========================================================== Cambialo por: 'settings' => array( 'folders' => 'manage_folders.inc', 'create-folder' => 'manage_folders.inc', 'rename-folder' => 'manage_folders.inc', 'delete-folder' => 'manage_folders.inc', 'subscribe' => 'manage_folders.inc', 'unsubscribe' => 'manage_folders.inc', 'add-identity' => 'edit_identity.inc', 'password' => 'password.inc', 'save-password' => 'password.inc', )
2. Abrir roundcube /program/js/app.js
//Busca [ ~ Line 238 ] case 'settings': this.enable_command("preferences", "identities", "save", "folders", true); ========================================================== //editalo y que quede así: case 'settings': this.enable_command("preferences", "identities", "save", "folders", "password", true); ========================================================== //Ahora busca esta línea [ ~ Line 239 ] if(this.env.action=="identities"||this.env.action=="edit-identity"||this.env.action=="add-identity"){ this.enable_command("add",this.env.identities_level<2); this.enable_command("delete","edit",true); } ========================================================== //y agrega justo debajo if (this.env.action=='password' || this.env.action=='save-password') { var input_current_password = rcube_find_object('_current_password'); var input_new_password = rcube_find_object('_new_password'); var input_repeat_password = rcube_find_object('_repeat_password'); if (input_current_password && input_current_password.value=='') input_current_password.focus(); else if (input_repeat_password) input_repeat_password.focus(); this.enable_command('save-password', true); } ========================================================== //Busca esta línea [ ~ Line 904] case 'delete-folder': this.delete_folder(props); break; ========================================================== //Inserta esta línea debajo: case 'password': this.goto_url('password'); break; case 'save-password': var input_current_password = rcube_find_object('_current_password'); var input_new_password = rcube_find_object('_new_password'); var input_repeat_password = rcube_find_object('_repeat_password'); if ((input_new_password && input_new_password.value=='') && (input_repeat_password && input_repeat_password.value=='') || (input_current_password && input_current_password.value=='')) { alert(this.get_label('nopassword')); input_current_password.value=''; input_new_password.value=''; input_repeat_password.value=''; input_current_password.focus(); } else if ((input_new_password && input_repeat_password) && ( input_new_password.value != input_repeat_password.value)) { alert(this.get_label('passwordinconsistency')); input_new_password.value=''; input_repeat_password.value=''; input_new_password.focus(); } else this.gui_objects.editform.submit(); break;
3. Abrir program/localization/es_ES/labels.inc
//Agrega esto al final del archivo: $labels['changepassword'] = 'Cambiar Clave'; $labels['current_password'] = 'Clave Actual'; $labels['new_password'] = 'Nueva Clave'; $labels['repeat_password'] = 'Repetir Clave';
4. Abrir program/localization/es_ES/messages.inc
$messages['nopassword'] = "Porfavor, Introduzca Nueva Clave."; $messages['passwordinconsistency'] = "Inconsistencia en las claves, pruebe otra vez.";
5. Abrir skins/default/includes/settingstab.html
En el skin de OutLook, existe solo un span, pero en el default aparecen uno por cada tab, en cualquiera de los dos agregar el código de abajo, sino en el OutLook no funcionará.
<span id="settingstabpassword" class="tablink"><roundcube:button command="password" type="link" label="password" title="changepassword" class="tablink" /></span>
6. Crear /skins/default/templates/password.html
<!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" /> </head> <body> <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="changepassword" /></div> <div style="padding:15px"> <roundcube:object name="passwordform"> <p><br /><roundcube:button command="save-password" type="input" class="button" label="save" /></p> </div> </div> <roundcube:include file="/includes/settingscripts.html" /> </body> </html>
7. Crear /program/steps/settings/password.inc
Tal véz la parte más importante, cuando lleges a esta línea
$passwordquery = "UPDATE database.table SET password_field =ENCRYPT('".$new_password."') WHERE user_name = '".$emailuser."';";
Debes de modificar y agregar tu propio SQL para modificar la contraseña, asegurate que tus usuarios en la BD tengan los permisos suficientes para interactuar con las bases de datos de roundcube y tu bd virtual de usuarios.
<?PHP function rcube_password_form($attrib) { global $RCMAIL, $OUTPUT, $CONFIG; $a_show_cols = array( 'current_password' => array( 'type' => 'text'), 'new_password' => array( 'type' => 'text'), 'repeat_password' => array( 'type' => 'text')); list($form_start, $form_end) = get_form_tags($attrib, 'save-password', array() ); $out = "{$form_start}<table>\r\n\r\n"; foreach ($a_show_cols as $col => $colprop) { $label = strlen($colprop['label']) ? $colprop['label'] : $col; $value = rcmail_get_edit_field($col, '', $attrib + array('type' => 'password', 'size' => 30), $colprop['type']); $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", $attrib['id'], Q(rcube_label($label)), $value); } $out .= "\n</table>$form_end"; return $out; } function rcube_save_password($current_password,$new_password) { global $OUTPUT, $RCMAIL; $emailuser=$_SESSION['username']; $db = rcmail::get_instance()->get_dbh(); // IMPORTANTE DEBES CAMBIAR ESTE CODIGO SQL POR EL TUYO PROPIO !!!!! $passwordquery = "UPDATE database.table SET password_field =ENCRYPT('".$new_password."') WHERE user_name = '".$emailuser."';"; $db->query($passwordquery); $_SESSION['password'] = encrypt_password($new_password); $OUTPUT->show_message('successfullysaved', 'confirmation'); } function encrypt_password($pass) { if (function_exists('mcrypt_module_open') && ($td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""))) { $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, rcmail::get_instance()->config->get_des_key(), $iv); $cypher = mcrypt_generic($td, $pass); mcrypt_generic_deinit($td); mcrypt_module_close($td); } else if (function_exists('des')) { $cypher = des(rcmail::get_instance()->config->get_des_key(), $pass, 1, 0, NULL); } else { $cypher = $pass; raise_error(array( 'code' => 500, 'type' => 'php', 'file' => __FILE__, 'message' => "Could not convert encrypt password. Make sure Mcrypt is installed or lib/des.inc is available" ), true, false); } return base64_encode($cypher); } $OUTPUT->set_pagetitle(rcube_label("changepassword")); $OUTPUT->add_handler('passwordform', 'rcube_password_form'); $OUTPUT->add_label('passwordinconsistency', 'nopassword'); switch ($RCMAIL->action) { case "password": $OUTPUT->send("password"); break; case "save-password": $curpass = get_input_value('_current_password', RCUBE_INPUT_POST, false); $newpass = get_input_value('_new_password', RCUBE_INPUT_POST, false); $repeatpass = get_input_value('_repeat_password', RCUBE_INPUT_POST, false); if ($newpass == $repeatpass && $_SESSION['password'] == encrypt_password($curpass)) rcube_save_password($curpass,$newpass); else $OUTPUT->show_message('errorsaving', 'error'); rcmail_overwrite_action("password"); $OUTPUT->send("password"); break; } ?>
Fuente en Inglés.
Fuente en Francés.


