Source for file options_identities.php

Documentation is available at options_identities.php

  1. <?php
  2.  
  3. /**
  4.  * options_identities.php
  5.  *
  6.  * Display Identities Options
  7.  *
  8.  * @copyright 1999-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: options_identities.php 14840 2020-01-07 07:42:38Z pdontthink $
  11.  * @package squirrelmail
  12.  * @subpackage prefs
  13.  * @since 1.1.3
  14.  */
  15.  
  16. /** This is the options_identities page */
  17. define('PAGE_NAME''options_identities');
  18.  
  19. /**
  20.  * Path for SquirrelMail required files.
  21.  * @ignore
  22.  */
  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. if (!sqgetGlobalVar('identities'$identitiesSQ_SESSION)) {
  34.     $identities get_identities();
  35. }
  36.  
  37. /* make sure that page is not available when $edit_identity is false */
  38. $cnt count($identities);
  39. if ($cnt && !$edit_identity{
  40.     error_box(_("Editing identities is disabled."),$color);
  41.     die('</body></html>');
  42. }
  43.  
  44. sqgetGlobalVar('newidentities'$newidentitiesSQ_POST);
  45. sqgetGlobalVar('smaction'$smactionSQ_POST);
  46. sqgetGlobalVar('return'$returnSQ_POST);
  47.  
  48. if (!sqgetGlobalVar('smtoken',$submitted_tokenSQ_POST)) {
  49.     $submitted_token '';
  50. }
  51.  
  52. // First lets see if there are any actions to perform //
  53. if (!empty($smaction&& is_array($smaction)) {
  54.  
  55.     // first do a security check
  56.     sm_validate_security_token($submitted_token-1TRUE);
  57.  
  58.     $doaction '';
  59.     $identid 0;
  60.  
  61.     foreach($smaction as $action=>$row{
  62.         // we only need to extract the action and the identity we are
  63.         // altering
  64.  
  65.         foreach($row as $iKey=>$data{
  66.             $identid $iKey;
  67.         }
  68.  
  69.         $doaction $action;
  70.     }
  71.  
  72.     $identities sqfixidentities$newidentities $identid $action );
  73.     save_identities($identities);
  74.     // save_identities() can also alter the identities, so:
  75.     $identities get_identities();
  76. }
  77.  
  78. if (!empty($return)) {
  79.     header('Location: ' get_location('/options_personal.php');
  80.     exit;
  81. }
  82.  
  83. displayPageHeader($color'None');
  84.  
  85. do_hook('options_identities_top');
  86.  
  87. $td_str '<form name="f" action="options_identities.php" method="post"><br />' "\n"
  88.         . addHidden('smtoken'sm_generate_security_token()) "\n"
  89.         . '<table border="0" cellspacing="0" cellpadding="2" width="100%">' "\n";
  90. $cnt count($identities)// $identities may have changed, so we need to count again
  91. foreach$identities as $iKey=>$ident {
  92.  
  93.     if ($iKey == 0{
  94.         $hdr_str _("Default Identity");
  95.     else {
  96.         $hdr_str sprintf_("Alternate Identity %d")$iKey);
  97.     }
  98.  
  99.     $td_str .= ShowIdentityInfo$hdr_str$ident$iKey );
  100.  
  101. }
  102.  
  103. if ($edit_identity)
  104.     $td_str .= ShowIdentityInfo_("Add a New Identity")array('full_name'=>'','email_address'=>'','reply_to'=>'','signature'=>'')$cnt);
  105. $td_str .= '</table>' "\n";
  106. $td_str .= '</form>';
  107.  
  108. echo '<br /> ' "\n" .
  109.     html_tag('table'"\n" .
  110.         html_tag('tr'"\n" .
  111.             html_tag('td' "\n" .
  112.             '<b>' _("Options"' - ' _("Advanced Identities"'</b><br />' .
  113.             html_tag('table'"\n" .
  114.                 html_tag('tr'"\n" .
  115.                     html_tag('td'"\n" .
  116.                         html_tag('table' "\n" .
  117.                             html_tag('tr' "\n" .
  118.                                 html_tag('td'"\n" .  $td_str ,'','''style="text-align:center;"')
  119.                             ),
  120.                         '''''width="80%" cellpadding="2" cellspacing="0" border="0"' ,
  121.                     'center'$color[4])
  122.                 ),
  123.             '''''width="100%" border="0" cellpadding="1" cellspacing="1"' )) ,
  124.         'center'$color[0]),
  125.     'center''''width="95%" border="0" cellpadding="2" cellspacing="0"' '</body></html>';
  126.  
  127.  
  128. function ShowIdentityInfo($title$identity$id {
  129.     global $color$edit_identity$edit_name$edit_reply_to$cnt;
  130.  
  131.     if (empty($identity['full_name']&& empty($identity['email_address']&& empty($identity['reply_to']&& empty($identity['signature'])) {
  132.         $bg '';
  133.         $empty true;
  134.     else {
  135.         $bg ' style="background-color:' $color[0';"';
  136.         $empty false;
  137.     }
  138.  
  139.     $name 'newidentities[%d][%s]';
  140.  
  141.  
  142.     $return_str '';
  143.  
  144.     $return_str .= '<tr>' "\n";
  145.     $return_str .= '  <th style="text-align:center;background-color:' $color[9';" colspan="2">' $title '</th> '"\n";
  146.     $return_str .= '</tr>' "\n";
  147.     $return_str .= sti_input_("Full Name"sprintf($name$id'full_name')$identity['full_name']$bg($edit_identity || ($cnt && $edit_name)));
  148.     $return_str .= sti_input_("E-Mail Address"sprintf($name$id'email_address')$identity['email_address']$bg$edit_identity);
  149.     // don't show reply-to AT ALL if it's not editable
  150.     if ($edit_identity || ($cnt && $edit_reply_to))
  151.         $return_str .= sti_input_("Reply To")sprintf($name$id'reply_to')$identity['reply_to']$bg($edit_identity || ($cnt && $edit_reply_to)));
  152.     $return_str .= sti_textarea_("Signature")sprintf($name$id'signature')$identity['signature']$bg);
  153.     $return_str .= concat_hook_function('options_identities_table'array($bg$empty$id));
  154.     $return_str .= '<tr' $bg '> ' "\n";
  155.     $return_str .= '  <td> &nbsp; </td>' "\n";
  156.     $return_str .= '  <td>' "\n";
  157.     $return_str .= '    <input type="submit" name="smaction[save][' $id ']" value="' _("Save / Update"'" />' "\n";
  158.  
  159.     if (!$empty && $id 0{
  160.         $return_str .= '    <input type="submit" name="smaction[makedefault][' $id ']" value="' _("Make Default"'" />' "\n";
  161.         if ($edit_identity)
  162.             $return_str .= '    <input type="submit" name="smaction[delete]['.$id.']" value="' _("Delete"'" />' "\n";
  163.  
  164.         if ($id 1{
  165.             $return_str .= '    <input type="submit" name="smaction[move]['.$id.']" value="' _("Move Up"'" />' "\n";
  166.         }
  167.  
  168.     }
  169.  
  170.     $return_str .= concat_hook_function('options_identities_buttons'array($empty$id));
  171.     $return_str .= '  </td>' "\n";
  172.     $return_str .= '</tr>' "\n";
  173.     $return_str .= '<tr>' "\n";
  174.     $return_str .= '  <td colspan="2"> &nbsp; </td>' "\n";
  175.     $return_str .= '</tr>';
  176.  
  177.     return $return_str;
  178.  
  179. }
  180.  
  181. function sti_input$title$name$data$bgcolor$can_edit {
  182.     $str '';
  183.     $str .= '<tr' $bgcolor ">\n";
  184.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ': </td>' "\n";
  185.     if ($can_edit)
  186.         $str .= '  <td> <input type="text" name="' $name '" size="50" value="'sm_encode_html_special_chars($data'"> </td>' "\n";
  187.     else
  188.         $str .= '  <td>&nbsp;' sm_encode_html_special_chars($data' </td>' "\n";
  189.     $str .= '</tr>';
  190.  
  191.     return $str;
  192.  
  193. }
  194.  
  195. function sti_textarea$title$name$data$bgcolor {
  196.     $str '';
  197.     $str .= '<tr' $bgcolor ">\n";
  198.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ': </td>' "\n";
  199.     $str .= '  <td> <textarea name="' $name '" cols="50" rows="5">'"\n" sm_encode_html_special_chars($data'</textarea> </td>' "\n";
  200.     $str .= '</tr>';
  201.  
  202.     return $str;
  203.  
  204. }

Documentation generated on Mon, 13 Jan 2020 04:25:09 +0100 by phpDocumentor 1.4.3