Changeset 2687 in subversion


Ignore:
Timestamp:
Jun 30, 2009 1:12:45 PM (4 years ago)
Author:
thomasb
Message:

Use html_table class to build password form + add german localizations + codestyle (no tabs, just spaces)

Location:
trunk/roundcubemail/plugins/password
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/plugins/password/config.inc.php

    r2679 r2687  
    1919// The SQL query used to change the password. 
    2020// The query can contain the following macros that will be expanded as follows: 
    21 //      %p is replaced with the plaintext new password 
     21//      %p is replaced with the plaintext new password 
    2222//      %c is replaced with the crypt version of the new password, MD5 if available 
    23 //         otherwise DES. 
     23//         otherwise DES. 
    2424//      %u is replaced with the username (from the session info) 
    2525//      %o is replaced with the password before the change 
  • trunk/roundcubemail/plugins/password/drivers/sasl.php

    r2664 r2687  
    2323 
    2424    if ($fh = popen("$curdir/chgsaslpasswd -p $username", 'w')) { 
    25         fwrite($fh, $newpass."\n"); 
     25        fwrite($fh, $newpass."\n"); 
    2626        $code = pclose($fh); 
    2727 
    28         if($code == 0) 
    29             return PASSWORD_SUCCESS; 
    30     } else  
    31         raise_error(array( 
     28        if ($code == 0) 
     29            return PASSWORD_SUCCESS; 
     30    } 
     31    else { 
     32        raise_error(array( 
    3233            'code' => 600, 
    33             'type' => 'php', 
    34             'file' = __FILE__, 
    35             'message' => "Password plugin: Unable to execute $curdir/chgsaslpasswd" 
    36         ), true, false);                                     
     34            'type' => 'php', 
     35            'file' => __FILE__, 
     36            'message' => "Password plugin: Unable to execute $curdir/chgsaslpasswd" 
     37            ), true, false); 
     38    } 
    3739 
    3840    return PASSWORD_ERROR; 
  • trunk/roundcubemail/plugins/password/password.js

    r2492 r2687  
    1313    rcmail.register_command('plugin.password', function() { rcmail.goto_url('plugin.password') }, true); 
    1414    rcmail.register_command('plugin.password-save', function() {  
    15         var input_curpasswd = rcube_find_object('_curpasswd'); 
    16         var input_newpasswd = rcube_find_object('_newpasswd'); 
    17         var input_confpasswd = rcube_find_object('_confpasswd'); 
    18          
    19         if (input_curpasswd && input_curpasswd.value=='') { 
    20             alert(rcmail.gettext('nocurpassword', 'password')); 
    21             input_curpasswd.focus(); 
    22         } else if (input_newpasswd && input_newpasswd.value=='') { 
    23             alert(rcmail.gettext('nopassword', 'password')); 
    24             input_newpasswd.focus(); 
    25         } else if (input_confpasswd && input_confpasswd.value=='') { 
    26             alert(rcmail.gettext('nopassword', 'password')); 
    27             input_confpasswd.focus(); 
    28         } else if ((input_newpasswd && input_confpasswd) && (input_newpasswd.value != input_confpasswd.value)) { 
    29             alert(rcmail.gettext('passwordinconsistency', 'password')); 
    30             input_newpasswd.focus(); 
    31         } else { 
    32             rcmail.gui_objects.passform.submit(); 
    33         } 
     15      var input_curpasswd = rcube_find_object('_curpasswd'); 
     16      var input_newpasswd = rcube_find_object('_newpasswd'); 
     17          var input_confpasswd = rcube_find_object('_confpasswd'); 
     18     
     19      if (input_curpasswd && input_curpasswd.value=='') { 
     20          alert(rcmail.gettext('nocurpassword', 'password')); 
     21          input_curpasswd.focus(); 
     22      } else if (input_newpasswd && input_newpasswd.value=='') { 
     23          alert(rcmail.gettext('nopassword', 'password')); 
     24          input_newpasswd.focus(); 
     25      } else if (input_confpasswd && input_confpasswd.value=='') { 
     26          alert(rcmail.gettext('nopassword', 'password')); 
     27          input_confpasswd.focus(); 
     28      } else if ((input_newpasswd && input_confpasswd) && (input_newpasswd.value != input_confpasswd.value)) { 
     29          alert(rcmail.gettext('passwordinconsistency', 'password')); 
     30          input_newpasswd.focus(); 
     31      } else { 
     32          rcmail.gui_objects.passform.submit(); 
     33      } 
    3434    }, true); 
    3535  }) 
  • trunk/roundcubemail/plugins/password/password.php

    r2668 r2687  
    44 +-------------------------------------------------------------------------+ 
    55 | Password Plugin for Roundcube                                           | 
    6  | Version 1.3                                                             | 
    7  |                                                                         | 
    8  | Copyright (C) 2009, RoundCube Dev. - Switzerland                        | 
     6 | Version 1.3.1                                                           | 
     7 |                                                                         | 
     8 | Copyright (C) 2009, RoundCube Dev.                                      | 
    99 |                                                                         | 
    1010 | This program is free software; you can redistribute it and/or modify    | 
     
    3434define('PASSWORD_SUCCESS', 0); 
    3535 
     36/** 
     37 * Change password plugin 
     38 * 
     39 * Plugin that adds functionality to change a users password. 
     40 * It provides common functionality and user interface and supports 
     41 * several backends to finally update the password. 
     42 * 
     43 * For installation and configuration instructions please read the README file. 
     44 * 
     45 * @version 1.3.1 
     46 * @author Aleksander Machniak 
     47 */ 
    3648class password extends rcube_plugin 
    3749{ 
     
    6981    $confirm = $rcmail->config->get('password_confirm_current'); 
    7082 
    71     if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd'])) 
     83    if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd'])) { 
    7284      $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error'); 
     85    } 
    7386    else { 
    7487      $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST); 
     
    95108    // add some labels to client 
    96109    $rcmail->output->add_label( 
    97         'password.nopassword', 
    98         'password.nocurpassword', 
    99         'password.passwordinconsistency' 
     110      'password.nopassword', 
     111      'password.nocurpassword', 
     112      'password.passwordinconsistency' 
    100113    ); 
    101114 
    102115    $rcmail->output->set_env('product_name', $rcmail->config->get('product_name')); 
    103116 
    104     // allow the following attributes to be added to the <table> tag 
    105     $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
    106  
    107     // return the complete edit form as table 
    108     $out = '<table' . $attrib_str . ">\n\n"; 
     117    $table = new html_table(array('cols' => 2)); 
    109118 
    110119    if ($rcmail->config->get('password_confirm_current')) { 
    111120      // show current password selection 
    112121      $field_id = 'curpasswd'; 
    113       $input_newpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 
    114             'size' => 20, 'autocomplete' => 'off')); 
     122      $input_curpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 
     123        'size' => 20, 'autocomplete' => 'off')); 
    115124   
    116       $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    117                   $field_id, 
    118                   rep_specialchars_output($this->gettext('curpasswd')), 
    119                   $input_newpasswd->show($rcmail->config->get('curpasswd'))); 
     125      $table->add('title', html::label($field_id, Q($this->gettext('curpasswd')))); 
     126      $table->add(null, $input_curpasswd->show()); 
    120127    } 
    121128 
     
    123130    $field_id = 'newpasswd'; 
    124131    $input_newpasswd = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id, 
    125             'size' => 20, 'autocomplete' => 'off')); 
    126  
    127     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    128                 $field_id, 
    129                 rep_specialchars_output($this->gettext('newpasswd')), 
    130                 $input_newpasswd->show($rcmail->config->get('newpasswd'))); 
     132      'size' => 20, 'autocomplete' => 'off')); 
     133 
     134    $table->add('title', html::label($field_id, Q($this->gettext('newpasswd')))); 
     135    $table->add(null, $input_newpasswd->show()); 
    131136 
    132137    // show confirm password selection 
    133138    $field_id = 'confpasswd'; 
    134139    $input_confpasswd = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id, 
    135             'size' => 20, 'autocomplete' => 'off')); 
    136  
    137     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    138                 $field_id, 
    139                 rep_specialchars_output($this->gettext('confpasswd')), 
    140                 $input_confpasswd->show($rcmail->config->get('confpasswd'))); 
    141  
    142     $out .= "\n</table>"; 
    143  
    144     $out .= '<br />'; 
    145      
    146     $out .= $rcmail->output->button(array( 
    147             'command' => 'plugin.password-save', 
    148             'type' => 'input', 
    149             'class' => 'button mainaction', 
    150             'label' => 'save' 
    151     )); 
     140      'size' => 20, 'autocomplete' => 'off')); 
     141 
     142    $table->add('title', html::label($field_id, Q($this->gettext('confpasswd')))); 
     143    $table->add(null, $input_confpasswd->show()); 
     144 
     145    $out = html::div(array('class' => "settingsbox", 'style' => "margin:0"), 
     146      html::div(array('id' => "userprefs-title"), $this->gettext('changepasswd')) . 
     147      html::div(array('style' => "padding:15px"), $table->show() . 
     148        html::p(null, 
     149          $rcmail->output->button(array( 
     150            'command' => 'plugin.password-save', 
     151            'type' => 'input', 
     152            'class' => 'button mainaction', 
     153            'label' => 'save' 
     154        ))) 
     155      ) 
     156    ); 
    152157 
    153158    $rcmail->output->add_gui_object('passform', 'password-form'); 
    154159 
    155160    return $rcmail->output->form_tag(array( 
    156         'id' => 'password-form', 
    157         'name' => 'password-form', 
    158         'method' => 'post', 
    159         'action' => './?_task=settings&_action=plugin.password-save', 
    160         ), $out); 
     161      'id' => 'password-form', 
     162      'name' => 'password-form', 
     163      'method' => 'post', 
     164      'action' => './?_task=settings&_action=plugin.password-save', 
     165      ), $out); 
    161166  } 
    162167 
     
    169174      raise_error(array( 
    170175        'code' => 600, 
    171         'type' => 'php', 
    172         'file' => __FILE__, 
    173         'message' => "Password plugin: Unable to open driver file $driver" 
    174         ), true, false); 
     176        'type' => 'php', 
     177        'file' => __FILE__, 
     178        'message' => "Password plugin: Unable to open driver file $driver" 
     179        ), true, false); 
    175180      return $this->gettext('internalerror'); 
    176181    } 
     
    181186      raise_error(array( 
    182187        'code' => 600, 
    183         'type' => 'php', 
    184         'file' => __FILE__, 
    185         'message' => "Password plugin: Broken driver: $driver" 
    186         ), true, false); 
     188        'type' => 'php', 
     189        'file' => __FILE__, 
     190        'message' => "Password plugin: Broken driver: $driver" 
     191        ), true, false); 
    187192      return $this->gettext('internalerror'); 
    188193    } 
Note: See TracChangeset for help on using the changeset viewer.