Changeset 3933 in subversion


Ignore:
Timestamp:
Sep 2, 2010 6:51:23 AM (3 years ago)
Author:
alec
Message:
  • Added fieldsets in Identity form, added 'identity_form' hook
Location:
trunk/roundcubemail
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r3920 r3933  
    1818- Fix timezone string in sent mail (#1486961) 
    1919- Show disabled checkboxes for protected folders instead of dots (#1485498) 
     20- Added fieldsets in Identity form, added 'identity_form' hook 
    2021 
    2122RELEASE 0.4 
  • trunk/roundcubemail/program/steps/settings/edit_identity.inc

    r3780 r3933  
    2525if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') { 
    2626  $IDENTITY_RECORD = $USER->get_identity(get_input_value('_iid', RCUBE_INPUT_GPC)); 
    27    
     27 
    2828  if (is_array($IDENTITY_RECORD)) 
    2929    $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); 
     
    4949 
    5050function rcube_identity_form($attrib) 
    51   { 
     51{ 
    5252  global $IDENTITY_RECORD, $RCMAIL, $OUTPUT; 
    5353 
     54  // Add HTML editor script(s) 
    5455  rcube_html_editor('identity'); 
    5556 
     
    6162  $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; 
    6263 
    63   list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', intval($IDENTITY_RECORD['identity_id']), array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); 
    64   unset($attrib['form']); 
     64  // list of available cols 
     65  $form = array( 
     66    'addressing' => array( 
     67      'name'    => rcube_label('settings'), 
     68      'content' => array( 
     69        'name'         => array('type' => 'text', 'size' => $i_size), 
     70        'email'        => array('type' => 'text', 'size' => $i_size), 
     71        'organization' => array('type' => 'text', 'size' => $i_size), 
     72        'reply-to'     => array('type' => 'text', 'size' => $i_size), 
     73        'bcc'          => array('type' => 'text', 'size' => $i_size), 
     74        'standard'       => array('type' => 'checkbox', 'label' => rcube_label('setdefault')), 
     75      )), 
     76    'signature' => array( 
     77      'name' => rcube_label('signature'), 
     78      'content' => array( 
     79        'signature'          => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows, 
     80            'spellcheck' => true), 
     81        'html_signature' => array('type' => 'checkbox', 'label' => rcube_label('htmlsignature'), 
     82            'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'), 
     83    )) 
     84  ); 
    6585 
    66   // list of available cols 
    67   $a_show_cols = array('name'         => array('type' => 'text', 'size' => $i_size), 
    68                        'email'        => array('type' => 'text', 'size' => $i_size), 
    69                        'organization' => array('type' => 'text', 'size' => $i_size), 
    70                        'reply-to'     => array('type' => 'text', 'label' => 'reply-to', 'size' => $i_size), 
    71                        'bcc'          => array('type' => 'text', 'size' => $i_size), 
    72                        'signature'        => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows), 
    73                        'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'), 
    74                        'standard'     => array('type' => 'checkbox', 'label' => 'setdefault')); 
     86  // Enable TinyMCE editor 
     87  if ($IDENTITY_RECORD['html_signature']) { 
     88    $form['signature']['content']['signature']['class'] = 'mce_editor'; 
     89  } 
    7590 
    7691  // disable some field according to access level 
    7792  if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) { 
    78     $a_show_cols['email']['disabled'] = true; 
    79     $a_show_cols['email']['class'] = 'disabled'; 
     93    $form['adressing']['content']['email']['disabled'] = true; 
     94    $form['adressing']['content']['email']['class'] = 'disabled'; 
    8095  } 
    81    
    82   // a specific part is requested 
    83   if ($attrib['part']) 
    84     { 
    85     $colprop = $a_show_cols[$attrib['part']]; 
    86     if (is_array($colprop)) 
    87       { 
    88       $out = $form_start; 
    89       $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']);  
    90       return $out; 
     96 
     97  // Allow plugins to modify identity form content 
     98  $plugin = $RCMAIL->plugins->exec_hook('identity_form', array( 
     99    'form' => $form, 'record' => $IDENTITY_RECORD)); 
     100 
     101  $form = $plugin['form']; 
     102  $IDENTITY_RECORD = $plugin['record']; 
     103 
     104  // Set form tags and hidden fields 
     105  list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', 
     106    intval($IDENTITY_RECORD['identity_id']), 
     107    array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); 
     108 
     109  unset($plugin); 
     110  unset($attrib['form']); 
     111 
     112  // return the complete edit form as table 
     113  $out = "$form_start\n"; 
     114 
     115  foreach ($form as $fieldset) { 
     116    if (empty($fieldset['content'])) 
     117      continue; 
     118 
     119    $content = ''; 
     120    if (is_array($fieldset['content'])) { 
     121      $table = new html_table(array('cols' => 2)); 
     122      foreach ($fieldset['content'] as $col => $colprop) { 
     123        $colprop['id'] = 'rcmfd_'.$col; 
     124 
     125        $label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col); 
     126        $value = !empty($colprop['value']) ? $colprop['value'] : 
     127            rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']); 
     128 
     129        $table->add('title', sprintf('<label for="%s">%s</label>', $colprop['id'], Q($label))); 
     130        $table->add(null, $value); 
    91131      } 
    92     else 
    93       return ''; 
     132      $content = $table->show(); 
     133    } 
     134    else { 
     135      $content = $fieldset['content']; 
    94136    } 
    95137 
     138    $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n"; 
     139  } 
    96140 
    97   // return the complete edit form as table 
    98   $out = "$form_start<table>\n\n"; 
     141  $out .= $form_end; 
    99142 
    100   foreach ($a_show_cols as $col => $colprop) 
    101     { 
    102     $colprop['id'] = 'rcmfd_'.$col; 
    103  
    104     if ($col == 'signature') 
    105       { 
    106       $colprop['spellcheck'] = true; 
    107       if ($IDENTITY_RECORD['html_signature']) 
    108         { 
    109         $colprop['class'] = 'mce_editor'; 
    110         } 
    111       } 
    112  
    113     $label = strlen($colprop['label']) ? $colprop['label'] : $col; 
    114     $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']); 
    115  
    116     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n", 
    117                     $colprop['id'], 
    118                     Q(rcube_label($label)), 
    119                     $value); 
    120     } 
    121  
    122   $out .= "\n</table>$form_end"; 
    123  
    124   return $out;   
    125   } 
     143  return $out; 
     144} 
    126145 
    127146$OUTPUT->include_script('list.js'); 
  • trunk/roundcubemail/program/steps/settings/func.inc

    r3840 r3933  
    2626// similar function as /steps/settings/identities.inc::rcmail_identity_frame() 
    2727function rcmail_preferences_frame($attrib) 
    28   { 
     28{ 
    2929  global $OUTPUT; 
    3030 
     
    3838   
    3939  return html::iframe($attrib); 
    40   } 
     40} 
    4141 
    4242 
    4343function rcmail_sections_list($attrib) 
    44   { 
     44{ 
    4545  global $RCMAIL; 
    4646   
     
    5959 
    6060  return $out; 
    61   } 
     61} 
    6262 
    6363 
    6464function rcmail_identities_list($attrib) 
    65   { 
     65{ 
    6666  global $OUTPUT, $USER, $RCMAIL; 
    6767 
     
    8888 
    8989  return $out; 
    90   } 
     90} 
    9191 
    9292 
    9393// similar function as in /steps/addressbook/edit.inc 
    9494function get_form_tags($attrib, $action, $id = null, $hidden = null) 
    95   { 
     95{ 
    9696  global $EDIT_FORM, $RCMAIL; 
    9797 
     
    101101    $request_key = $action . (isset($id) ? '.'.$id : ''); 
    102102    $form_start = $RCMAIL->output->request_form(array( 
    103         'name' => 'form', 'method' => 'post', 
    104         'task' => $RCMAIL->task, 'action' => $action, 
    105         'request' => $request_key, 'noclose' => true) + $attrib); 
     103          'name'    => 'form', 
     104          'method'  => 'post', 
     105          'task'    => $RCMAIL->task, 
     106          'action'  => $action, 
     107          'request' => $request_key, 
     108          'noclose' => true 
     109        ) + $attrib); 
    106110     
    107111    if (is_array($hidden)) { 
     
    117121 
    118122  return array($form_start, $form_end); 
    119   } 
     123} 
    120124 
    121125 
Note: See TracChangeset for help on using the changeset viewer.