Допълнителни настройки за roundcube

от ILuxWiki

Направо към: навигация, търсене

В този документ са изложени промените направени на roundcube mail за ползването му към sistechnology. Изходния код е взет от CVS сървъра на rundcube към дата 15.05.2006.

Съдържание

Автоматично добавяне на домейн ако не е въведен към потребителското име

program/include/main.inc

Около ред 380 след } добавяте следната фунцкия

 function  parse_domain($url) {
   $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)';
   // Followed by one or max 63 domain characters (dot separated).
   // Must be followed by one set consisting a period of two
   $regex = '^(' . $domain . '\.)+((' . $domain . '{1,63}\.)'.
     $domain . '{2,63}'.
     ')$';
   if (ereg( $regex, strtolower($url), $regs)) {
     return $regs[4];
   }
   return false;
 }

Около ред 402, след него

     401   if (!$host)
     402     $host = $CONFIG['default_host'];

добавяте:

 // parse username for syntax like username@domain
 $have_at = explode("@", $user);
 if ($CONFIG['add_domain2username'] && sizeof($have_at) == 1) {
   if ($domain = parse_domain($_SERVER[HTTP_HOST])) {
      $user = $user . '@' . $domain; // add domain from hostname                                               
   }
 }

Около ред 1670 и след

 $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('loginform', '$form_name');");

добавяте:

 $domain = strtoupper (parse_domain($_SERVER[HTTP_HOST])) ;

няколко ред по надолу, след:

 $out = <<<EOF
 $form_start
 $SESS_HIDDEN_FIELD
 $fields[action]
се добавя: <td class="title">Domain</td> <td class="title">$domain</td> </tr><tr>

Смяна на парола към POSTFIX mySQL Courier IMAP

Необходими условия:

  1. потребителите/паролите се намират в SQL база данни
  2. rouncube трябва да има права "UPDATE" на съответните полета в SQL таблицата.

Промени

Списък на файловете които трябва да се променят или създадат, за да работи смяната на парола през roundcube

index.php

Някъде около ред 344

    include('program/steps/settings/manage_folders.inc');
 }

след края на '}' да се добави:

 if ($_action=='password') {
   include('program/steps/settings/change_password.inc');
 }


config/db.inc.php

Необходимо е да се добавят следните редове:

// required settings for change password
$rcmail_config['db_passwd_tables_users'] = 'users';
$rcmail_config['db_passwd_columnt_username'] = 'email';
$rcmail_config['db_passwd_columnt_password' = 'password';

program/include/main.inc

Някъде около ред 1194 след

 // USER SETTINGS
 'createfolder' => 'rcube_create_folder_form',

да се добави

 'changepassword' => 'rcube_changepassword_form',

program/steps/settings/func.inc

program/js/app.js

Някъде около ред 200, добавяте 'password' в enable_command();. Активира действието на settingstab

 197       case 'settings':
 198         this.enable_command('preferences', 'identities', 'save', 'folders', 'password' , true);


Някъде около ред 214 веднага след блока:

         if (identities_list)                          
           this.init_identitieslist(identities_list);  

добавяте

 if (this.env.action=='password') {
   var input_p0 = rcube_find_object('_password0');
   var input_p1 = rcube_find_object('_password1');
   var input_p2 = rcube_find_object('_password2');
   if (input_p0 && input_p0.value== )
     input_p0.focus();
   else if (input_p1 && input_p1.value==)
     input_p1.focus();
   else if (input_p2)                                   
     input_p2.focus();
   this.enable_command('save-password', true);
 }

Около ред 743, преди

case 'delete':

Добавяте следния код:

 case 'save-password':                                           
   var min_pwd_size = 5;
   var input_pass0 = rcube_find_object('_password0');
   var input_pass1 = rcube_find_object('_password1');
   var input_pass2 = rcube_find_object('_password2');
   if (input_pass1.value.length < min_pwd_size || input_pass1.value != input_pass2.value ) {
      this.display_message('Input fields must be equals and not empty!', 'error');
      input_pass1.value = ;
      input_pass2.value = ;
      input_pass1.focus();
   } else if (input_pass0_value.length < min_pwd_size ) {
      this.display_message('Please enter your current password!', 'error');
      input_pass0.focus();
   } else {
     location.href = this.env.comm_path+'&_action=password' +'&_newpassword=' + input_pass1.value + &_curpassword=' + input_pass0.value;
   }
   break;


Малко преди края на switch-а. (този код не се ползва)

 978 
 979       case 'password':
 980         location.href = this.env.comm_path+'&_action=password';
 981         break;

program/steps/settings: change_password.inc


skins/default/includes/settingstabs.html

Добавя се още един ред със следното съдържание:

<span id="settingstabpassword" class="tablink"><roundcube:button command="password" type="link" label="password" title="changepassword" class="tablink" /></span>

skins/default/templates/changepassword.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" /> <form name="changepasswordform" action="./" onsubmit="rcmail.command('change-password');return false;"> <div id="folder-manager"> <div class="settingsbox"> <div class="boxtitle"><roundcube:label name="changepassword" /></div> <div class="settingspart"> <table> <roundcube:object name="changepassword"/> </table> <p><br /><roundcube:button command="save-password" type="input" class="button" label="save" /></p> </div> </div> </form> <roundcube:include file="/includes/settingscripts.html" /> </body> </html>

MySQL

Необходим е достъп на roundcube потребителя към базата с паролите.

grant update(password),select(email,password) on vmailsystem.users to roundcube@localhost;
flush privileges;
  • не съм сигурен дали е нужно да има select права за password. Достъпа е риск в сигурноста ако някой успее да прокара select username,password...
Лични инструменти