svncommit
2005-10-26 43fa235da354c8b53aa69ba745c1d398a758fcaf
commit | author | age
4e17e6 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/settings/edit_identity.inc                              |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
30233b 9  | Licensed under the GNU GPL                                            |
4e17e6 10  |                                                                       |
T 11  | PURPOSE:                                                              |
12  |   Show edit form for a identity record or to add a new one            |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id$
19
20 */
21
22 if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
23   {
24   $id = $_POST['_iid'] ? $_POST['_iid'] : $_GET['_iid'];
d7cb77 25   $DB->query("SELECT * FROM ".get_table_name('identities')."
S 26               WHERE  identity_id=?
27               AND    user_id=?
28               AND    del<>'1'",
29               $id,
30               $_SESSION['user_id']);
4e17e6 31   
T 32   $IDENTITY_RECORD = $DB->fetch_assoc();
33   
34   if (is_array($IDENTITY_RECORD))
35     $OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $IDENTITY_RECORD['identity_id']));
36     
37   $PAGE_TITLE = rcube_label('edititem');
38   }
39 else
40   $PAGE_TITLE = rcube_label('newitem');
41
42
43
44 function rcube_identity_form($attrib)
45   {
46   global $IDENTITY_RECORD, $JS_OBJECT_NAME;
47
48   if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')
49     return rcube_label('notfound');
50
51   list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
52   unset($attrib['form']);
53
54
55   // list of available cols
56   $a_show_cols = array('name'         => array('type' => 'text'),
57                        'email'        => array('type' => 'text'),
58                        'organization' => array('type' => 'text'),
59                        'reply-to'     => array('type' => 'text', 'label' => 'replyto'),
60                        'bcc'          => array('type' => 'text'),
61                        'default'      => array('type' => 'checkbox', 'label' => 'setdefault'));
62
63
64   // a specific part is requested
65   if ($attrib['part'])
66     {
67     $colprop = $a_show_cols[$attrib['part']];
68     if (is_array($colprop))
69       {
70       $out = $form_start;
71       $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']); 
72       return $out;
73       }
74     else
75       return '';
76     }
77
78
79   // return the complete edit form as table
80   $out = "$form_start<table>\n\n";
81
82   foreach ($a_show_cols as $col => $colprop)
83     {
84     $attrib['id'] = 'rcmfd_'.$col;
85     $label = strlen($colprop['label']) ? $colprop['label'] : $col;
86     $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
87
88     $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
89                     $attrib['id'],
1038d5 90                     rep_specialchars_output(rcube_label($label)),
4e17e6 91                     $value);
T 92     }
93
94   $out .= "\n</table>$form_end";
95
96   return $out;  
97   }
98
99
100
101 if ($_action=='add-identity' && template_exists('addidentity'))
102   parse_template('addidentity');
103
104 parse_template('editidentity');
105 ?>