4 * options_identities.php
6 * Display Identities Options
8 * @copyright © 1999-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
17 * Include the SquirrelMail initialization file.
19 require('../include/init.php');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'functions/identity.php');
24 /* make sure that page is not available when $edit_identity is false */
25 if (!$edit_identity) {
26 error_box(_("Editing identities is disabled."));
27 $oTemplate->display('footer.tpl');
31 if (!sqgetGlobalVar('identities', $identities, SQ_SESSION
)) {
32 $identities = get_identities();
34 sqgetGlobalVar('newidentities', $newidentities, SQ_POST
);
35 sqgetGlobalVar('smaction', $smaction, SQ_POST
);
36 sqgetGlobalVar('return', $return, SQ_POST
);
38 // First lets see if there are any actions to perform //
39 if (!empty($smaction) && is_array($smaction)) {
44 foreach($smaction as $action=>$row) {
45 // we only need to extract the action and the identity we are
48 foreach($row as $iKey=>$data) {
55 $identities = sqfixidentities( $newidentities , $identid , $action );
56 save_identities($identities);
59 if (!empty($return)) {
60 header('Location: ' . get_location() . '/options_personal.php');
64 displayPageHeader($color);
67 do_hook('options_identities_top', $null);
70 foreach ($identities as $key=>$ident) {
72 $a['Title'] = $key==0 ?
_("Default Identity") : sprintf(_("Alternate Identity %d"), $key);
74 $a['Default'] = $key==0;
75 $a['FullName'] = htmlspecialchars($ident['full_name']);
76 $a['Email'] = htmlspecialchars($ident['email_address']);
77 $a['ReplyTo'] = htmlspecialchars($ident['reply_to']);
78 $a['Signature'] = htmlspecialchars($ident['signature']);
83 $a['Title'] = _("Add New Identity");
85 $a['Default'] = false;
92 //FIXME: NO HTML IN THE CORE
93 echo '<form name="f" action="options_identities.php" method="post">' . "\n";
95 $oTemplate->assign('identities', $i);
96 $oTemplate->display('options_advidentity_list.tpl');
98 //FIXME: NO HTML IN THE CORE
101 $oTemplate->display('footer.tpl');
104 * The functions below should not be needed with the additions of templates,
105 * however they will remain in case plugins use them.
109 * Returns html formated identity form fields
111 * Contains options_identities_buttons and option_identities_table hooks.
112 * Before 1.4.5/1.5.1 hooks were placed in ShowTableInfo() function.
113 * In 1.1.3-1.4.1 they were called in do_hook function with two or
114 * three arguments. Since 1.4.1 hooks are called in concat_hook_function.
115 * Arguments are moved to array.
117 * options_identities_buttons hook uses array with two keys. First array key is
118 * boolean variable used to indicate empty identity field. Second array key
119 * is integer variable used to indicate identity number
121 * options_identities_table hook uses array with three keys. First array key is
122 * a string containing background color style CSS (1.4.1-1.4.4/1.5.0 uses only
123 * html color code). Second array key is boolean variable used to indicate empty
124 * identity field. Third array key is integer variable used to indicate identity
126 * @param string $title Name displayed in header row
127 * @param array $identity Identity information
128 * @param integer $id identity ID
129 * @return string html formatted table rows with form fields for identity management
130 * @since 1.5.1 and 1.4.5 (was called ShowTableInfo() in 1.1.3-1.4.4 and 1.5.0)
132 function ShowIdentityInfo($title, $identity, $id ) {
135 if (empty($identity['full_name']) && empty($identity['email_address']) && empty($identity['reply_to']) && empty($identity['signature'])) {
139 $bg = ' style="background-color:' . $color[0] . ';"';
143 $name = 'newidentities[%d][%s]';
148 //FIXME: NO HTML IN THE CORE
149 $return_str .= '<tr>' . "\n";
150 $return_str .= ' <th style="text-align:center;background-color:' . $color[9] . ';" colspan="2">' . $title . '</th> '. "\n";
151 $return_str .= '</tr>' . "\n";
152 $return_str .= sti_input( _("Full Name") , sprintf($name, $id, 'full_name'), $identity['full_name'], $bg);
153 $return_str .= sti_input( _("E-Mail Address") , sprintf($name, $id, 'email_address'), $identity['email_address'], $bg);
154 $return_str .= sti_input( _("Reply To"), sprintf($name, $id, 'reply_to'), $identity['reply_to'], $bg);
155 $return_str .= sti_textarea( _("Signature"), sprintf($name, $id, 'signature'), $identity['signature'], $bg);
156 $return_str .= concat_hook_function('options_identities_table', $temp=array(&$bg, &$empty, &$id));
157 $return_str .= '<tr' . $bg . '> ' . "\n";
158 $return_str .= ' <td> </td>' . "\n";
159 $return_str .= ' <td>' . "\n";
160 $return_str .= ' <input type="submit" name="smaction[save][' . $id . ']" value="' . _("Save / Update") . '" />' . "\n";
162 if (!$empty && $id > 0) {
163 $return_str .= ' <input type="submit" name="smaction[makedefault][' . $id . ']" value="' . _("Make Default") . '" />' . "\n";
164 $return_str .= ' <input type="submit" name="smaction[delete]['.$id.']" value="' . _("Delete") . '" />' . "\n";
167 $return_str .= ' <input type="submit" name="smaction[move]['.$id.']" value="' . _("Move Up") . '" />' . "\n";
172 $return_str .= concat_hook_function('options_identities_buttons', $temp=array(&$empty, &$id));
173 $return_str .= ' </td>' . "\n";
174 $return_str .= '</tr>' . "\n";
175 $return_str .= '<tr>' . "\n";
176 $return_str .= ' <td colspan="2"> </td>' . "\n";
177 $return_str .= '</tr>';
184 * Creates html formated table row with input field
185 * @param string $title Name displayed next to input field
186 * @param string $name Name of input field
187 * @param string $data Default value of input field (data is sanitized with htmlspecialchars)
188 * @param string $bgcolor html attributes added to row element (tr)
189 * @return string html formated table row with text input field
190 * @since 1.2.0 (arguments differ since 1.4.5/1.5.1)
191 * @todo check right-to-left language issues
194 function sti_input( $title, $name, $data, $bgcolor ) {
195 //FIXME: NO HTML IN THE CORE
197 $str .= '<tr' . $bgcolor . ">\n";
198 $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n";
199 $str .= ' <td> <input type="text" name="' . $name . '" size="50" value="'. htmlspecialchars($data) . '" /> </td>' . "\n";
207 * Creates html formated table row with textarea field
208 * @param string $title Name displayed next to textarea field
209 * @param string $name Name of textarea field
210 * @param string $data Default value of textarea field (data is sanitized with htmlspecialchars)
211 * @param string $bgcolor html attributes added to row element (tr)
212 * @return string html formated table row with textarea
213 * @since 1.2.5 (arguments differ since 1.4.5/1.5.1)
214 * @todo check right-to-left language issues
217 function sti_textarea( $title, $name, $data, $bgcolor ) {
218 //FIXME: NO HTML IN THE CORE
220 $str .= '<tr' . $bgcolor . ">\n";
221 $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n";
222 $str .= ' <td> <textarea name="' . $name . '" cols="50" rows="5">'. htmlspecialchars($data) . '</textarea> </td>' . "\n";