squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

options_identities.php
Go to the documentation of this file.
1 <?php
2 
17 define('PAGE_NAME', 'options_identities');
18 
23 define('SM_PATH','../');
24 
25 /* SquirrelMail required files. */
26 require_once(SM_PATH . 'include/validate.php');
27 include_once(SM_PATH . 'functions/global.php');
28 include_once(SM_PATH . 'functions/display_messages.php');
29 include_once(SM_PATH . 'functions/html.php');
30 include_once(SM_PATH . 'functions/forms.php');
31 include_once(SM_PATH . 'functions/identity.php');
32 
33 /* make sure that page is not available when $edit_identity is false */
34 if (!$edit_identity) {
35  error_box(_("Editing identities is disabled."),$color);
36  die('</body></html>');
37 }
38 
39 if (!sqgetGlobalVar('identities', $identities, SQ_SESSION)) {
40  $identities = get_identities();
41 }
42 sqgetGlobalVar('newidentities', $newidentities, SQ_POST);
43 sqgetGlobalVar('smaction', $smaction, SQ_POST);
44 sqgetGlobalVar('return', $return, SQ_POST);
45 
46 if (!sqgetGlobalVar('smtoken',$submitted_token, SQ_POST)) {
47  $submitted_token = '';
48 }
49 
50 // First lets see if there are any actions to perform //
51 if (!empty($smaction) && is_array($smaction)) {
52 
53  // first do a security check
54  sm_validate_security_token($submitted_token, 3600, TRUE);
55 
56  $doaction = '';
57  $identid = 0;
58 
59  foreach($smaction as $action=>$row) {
60  // we only need to extract the action and the identity we are
61  // altering
62 
63  foreach($row as $iKey=>$data) {
64  $identid = $iKey;
65  }
66 
67  $doaction = $action;
68  }
69 
70  $identities = sqfixidentities( $newidentities , $identid , $action );
71  save_identities($identities);
72 }
73 
74 if (!empty($return)) {
75  header('Location: ' . get_location() . '/options_personal.php');
76  exit;
77 }
78 
79 displayPageHeader($color, 'None');
80 
81 do_hook('options_identities_top');
82 
83 $td_str = '<form name="f" action="options_identities.php" method="post"><br />' . "\n"
84  . addHidden('smtoken', sm_generate_security_token()) . "\n"
85  . '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n";
86 $cnt = count($identities);
87 foreach( $identities as $iKey=>$ident ) {
88 
89  if ($iKey == 0) {
90  $hdr_str = _("Default Identity");
91  } else {
92  $hdr_str = sprintf( _("Alternate Identity %d"), $iKey);
93  }
94 
95  $td_str .= ShowIdentityInfo( $hdr_str, $ident, $iKey );
96 
97 }
98 
99 $td_str .= ShowIdentityInfo( _("Add a New Identity"), array('full_name'=>'','email_address'=>'','reply_to'=>'','signature'=>''), $cnt);
100 $td_str .= '</table>' . "\n";
101 $td_str .= '</form>';
102 
103 echo '<br /> ' . "\n" .
104  html_tag('table', "\n" .
105  html_tag('tr', "\n" .
106  html_tag('td' , "\n" .
107  '<b>' . _("Options") . ' - ' . _("Advanced Identities") . '</b><br />' .
108  html_tag('table', "\n" .
109  html_tag('tr', "\n" .
110  html_tag('td', "\n" .
111  html_tag('table' , "\n" .
112  html_tag('tr' , "\n" .
113  html_tag('td', "\n" . $td_str ,'','', 'style="text-align:center;"')
114  ),
115  '', '', 'width="80%" cellpadding="2" cellspacing="0" border="0"' ) ,
116  'center', $color[4])
117  ),
118  '', '', 'width="100%" border="0" cellpadding="1" cellspacing="1"' )) ,
119  'center', $color[0]),
120  'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . '</body></html>';
121 
122 
123 function ShowIdentityInfo($title, $identity, $id ) {
124  global $color;
125 
126  if (empty($identity['full_name']) && empty($identity['email_address']) && empty($identity['reply_to']) && empty($identity['signature'])) {
127  $bg = '';
128  $empty = true;
129  } else {
130  $bg = ' style="background-color:' . $color[0] . ';"';
131  $empty = false;
132  }
133 
134  $name = 'newidentities[%d][%s]';
135 
136 
137  $return_str = '';
138 
139  $return_str .= '<tr>' . "\n";
140  $return_str .= ' <th style="text-align:center;background-color:' . $color[9] . ';" colspan="2">' . $title . '</th> '. "\n";
141  $return_str .= '</tr>' . "\n";
142  $return_str .= sti_input( _("Full Name") , sprintf($name, $id, 'full_name'), $identity['full_name'], $bg);
143  $return_str .= sti_input( _("E-Mail Address") , sprintf($name, $id, 'email_address'), $identity['email_address'], $bg);
144  $return_str .= sti_input( _("Reply To"), sprintf($name, $id, 'reply_to'), $identity['reply_to'], $bg);
145  $return_str .= sti_textarea( _("Signature"), sprintf($name, $id, 'signature'), $identity['signature'], $bg);
146  $return_str .= concat_hook_function('options_identities_table', array($bg, $empty, $id));
147  $return_str .= '<tr' . $bg . '> ' . "\n";
148  $return_str .= ' <td> &nbsp; </td>' . "\n";
149  $return_str .= ' <td>' . "\n";
150  $return_str .= ' <input type="submit" name="smaction[save][' . $id . ']" value="' . _("Save / Update") . '" />' . "\n";
151 
152  if (!$empty && $id > 0) {
153  $return_str .= ' <input type="submit" name="smaction[makedefault][' . $id . ']" value="' . _("Make Default") . '" />' . "\n";
154  $return_str .= ' <input type="submit" name="smaction[delete]['.$id.']" value="' . _("Delete") . '" />' . "\n";
155 
156  if ($id > 1) {
157  $return_str .= ' <input type="submit" name="smaction[move]['.$id.']" value="' . _("Move Up") . '" />' . "\n";
158  }
159 
160  }
161 
162  $return_str .= concat_hook_function('options_identities_buttons', array($empty, $id));
163  $return_str .= ' </td>' . "\n";
164  $return_str .= '</tr>' . "\n";
165  $return_str .= '<tr>' . "\n";
166  $return_str .= ' <td colspan="2"> &nbsp; </td>' . "\n";
167  $return_str .= '</tr>';
168 
169  return $return_str;
170 
171 }
172 
173 function sti_input( $title, $name, $data, $bgcolor ) {
174  $str = '';
175  $str .= '<tr' . $bgcolor . ">\n";
176  $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n";
177  $str .= ' <td> <input type="text" name="' . $name . '" size="50" value="'. htmlspecialchars($data) . '"> </td>' . "\n";
178  $str .= '</tr>';
179 
180  return $str;
181 
182 }
183 
184 function sti_textarea( $title, $name, $data, $bgcolor ) {
185  $str = '';
186  $str .= '<tr' . $bgcolor . ">\n";
187  $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n";
188  $str .= ' <td> <textarea name="' . $name . '" cols="50" rows="5">'. htmlspecialchars($data) . '</textarea> </td>' . "\n";
189  $str .= '</tr>';
190 
191  return $str;
192 
193 }
194 
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
sti_input
sti_input( $title, $name, $data, $bgcolor)
Definition: options_identities.php:173
$cnt
$cnt
Definition: options_identities.php:86
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
$edit_identity
$edit_identity
Definition: config_default.php:588
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
$id
$id
Definition: move_messages.php:190
$td_str
$td_str
Definition: options_identities.php:83
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
concat_hook_function
concat_hook_function($name, $parm=NULL)
Definition: plugin.php:96
sprintf
powered by Systran sprintf(_("Number of supported language pairs: %s"), '36').' '
Definition: options.php:107
do_hook
do_hook($name)
Definition: plugin.php:42
get_identities
get_identities()
Definition: identity.php:27
sm_validate_security_token
sm_validate_security_token($token, $validity_period=0, $show_error=FALSE)
Definition: strings.php:1405
sm_generate_security_token
sm_generate_security_token()
Definition: strings.php:1340
sti_textarea
sti_textarea( $title, $name, $data, $bgcolor)
Definition: options_identities.php:184
sqfixidentities
sqfixidentities( $identities, $id, $action)
Definition: identity.php:116
addHidden
addHidden($name, $value)
Definition: forms.php:58
SQ_POST
const SQ_POST
Definition: global.php:17
$data
$data
Definition: mailto.php:83
SM_PATH
const SM_PATH
Definition: options_identities.php:23
exit
exit
Definition: help.php:128
$action
$action
Definition: options.php:34
_
_($str)
Definition: gettext.php:160
save_identities
save_identities($identities)
Definition: identity.php:67
$color
$color
Definition: load_prefs.php:28
get_location
get_location()
Definition: strings.php:340
$bg
$bg
Definition: monostochastic.php:22
ShowIdentityInfo
ShowIdentityInfo($title, $identity, $id)
Definition: options_identities.php:123
error_box
error_box($string, $color)
Definition: display_messages.php:116