4 * options_identities.php
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Display Identities Options
12 * @package squirrelmail
17 * Path for SquirrelMail required files.
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'include/validate.php');
24 include_once(SM_PATH
. 'functions/global.php');
25 include_once(SM_PATH
. 'functions/display_messages.php');
26 include_once(SM_PATH
. 'functions/html.php');
27 include_once(SM_PATH
. 'functions/identity.php');
29 if (!sqgetGlobalVar('identities', $identities, SQ_SESSION
)) {
30 $identities = get_identities();
32 sqgetGlobalVar('newidentities', $newidentities, SQ_POST
);
33 sqgetGlobalVar('smaction', $smaction, SQ_POST
);
34 sqgetGlobalVar('return', $return, SQ_POST
);
36 // First lets see if there are any actions to perform //
37 if (!empty($smaction) && is_array($smaction)) {
42 foreach($smaction as $action=>$row) {
43 // we only need to extract the action and the identity we are
46 foreach($row as $key=>$data) {
53 $identities = sqfixidentities( $newidentities , $identid , $action );
54 save_identities($identities);
57 if (!empty($return)) {
58 header('Location: ' . get_location() . '/options_personal.php');
62 displayPageHeader($color, 'None');
64 do_hook('options_identities_top');
67 $td_str .= '<form name="f" action="options_identities.php" method="post"><br />' . "\n";
68 $td_str .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n";
69 $cnt = count($identities);
70 foreach( $identities as $key=>$ident ) {
73 $hdr_str = _("Default Identity");
75 $hdr_str = sprintf( _("Alternate Identity %d"), $key);
78 $td_str .= ShowIdentityInfo( $hdr_str, $ident, $key );
82 $td_str .= ShowIdentityInfo( _("Add a New Identity"), array('full_name'=>'','email_address'=>'','reply_to'=>'','signature'=>''), $cnt);
83 $td_str .= '</table>' . "\n";
86 echo '<br /> ' . "\n" .
87 html_tag('table', "\n" .
89 html_tag('td' , "\n" .
90 '<b>' . _("Options") . ' - ' . _("Advanced Identities") . '</b><br />' .
91 html_tag('table', "\n" .
94 html_tag('table' , "\n" .
95 html_tag('tr' , "\n" .
96 html_tag('td', "\n" . $td_str ,'','', 'style="text-align:center;"')
98 '', '', 'width="80%" cellpadding="2" cellspacing="0" border="0"' ) ,
101 '', '', 'width="100%" border="0" cellpadding="1" cellspacing="1"' )) ,
102 'center', $color[0]),
103 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . '</body></html>';
106 function ShowIdentityInfo($title, $identity, $id ) {
109 if (empty($identity['full_name']) && empty($identity['email_address']) && empty($identity['reply_to']) && empty($identity['signature'])) {
113 $bg = ' style="background-color:' . $color[0] . ';"';
117 $name = 'newidentities[%d][%s]';
122 $return_str .= '<tr>' . "\n";
123 $return_str .= ' <th style="text-align:center;background-color:' . $color[9] . ';" colspan="2">' . $title . '</th> '. "\n";
124 $return_str .= '</tr>' . "\n";
125 $return_str .= sti_input( _("Full Name") , sprintf($name, $id, 'full_name'), $identity['full_name'], $bg);
126 $return_str .= sti_input( _("E-Mail Address") , sprintf($name, $id, 'email_address'), $identity['email_address'], $bg);
127 $return_str .= sti_input( _("Reply To"), sprintf($name, $id, 'reply_to'), $identity['reply_to'], $bg);
128 $return_str .= sti_textarea( _("Signature"), sprintf($name, $id, 'signature'), $identity['signature'], $bg);
129 $return_str .= concat_hook_function('options_identities_table', array($bg, $empty, $id));
130 $return_str .= '<tr' . $bg . '> ' . "\n";
131 $return_str .= ' <td> </td>' . "\n";
132 $return_str .= ' <td>' . "\n";
133 $return_str .= ' <input type="submit" name="smaction[save][' . $id . ']" value="' . _("Save / Update") . '" />' . "\n";
135 if (!$empty && $id > 0) {
136 $return_str .= ' <input type="submit" name="smaction[makedefault][' . $id . ']" value="' . _("Make Default") . '" />' . "\n";
137 $return_str .= ' <input type="submit" name="smaction[delete]['.$id.']" value="' . _("Delete") . '" />' . "\n";
140 $return_str .= ' <input type="submit" name="smaction[move]['.$id.']" value="' . _("Move Up") . '" />' . "\n";
145 $return_str .= concat_hook_function('options_identities_buttons', array($empty, $id));
146 $return_str .= ' </td>' . "\n";
147 $return_str .= '</tr>' . "\n";
148 $return_str .= '<tr>' . "\n";
149 $return_str .= ' <td colspan="2"> </td>' . "\n";
150 $return_str .= '</tr>';
156 function sti_input( $title, $name, $data, $bgcolor ) {
158 $str .= '<tr' . $bgcolor . ">\n";
159 $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n";
160 $str .= ' <td> <input type="text" name="' . $name . '" size="50" value="'. htmlspecialchars($data) . '"> </td>' . "\n";
167 function sti_textarea( $title, $name, $data, $bgcolor ) {
169 $str .= '<tr' . $bgcolor . ">\n";
170 $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n";
171 $str .= ' <td> <textarea name="' . $name . '" cols="50" rows="5">'. htmlspecialchars($data) . '</textarea> </td>' . "\n";