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 14845 2020-01-07 08:09:34Z 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.  * Include the SquirrelMail initialization file.
  21.  */
  22. require('../include/init.php');
  23.  
  24. /* SquirrelMail required files. */
  25. require_once(SM_PATH 'functions/identity.php');
  26. require_once(SM_PATH 'functions/forms.php');
  27.  
  28. /* make sure that page is not available when $edit_identity is false */
  29. if (!$edit_identity{
  30.     error_box(_("Editing identities is disabled."));
  31.     $oTemplate->display('footer.tpl');
  32.     die();
  33. }
  34.  
  35. if (!sqgetGlobalVar('identities'$identitiesSQ_SESSION)) {
  36.     $identities get_identities();
  37. }
  38. sqgetGlobalVar('newidentities'$newidentitiesSQ_POST);
  39. sqgetGlobalVar('smaction'$smactionSQ_POST);
  40. sqgetGlobalVar('return'$returnSQ_POST);
  41. sqgetGlobalVar('smtoken'$submitted_tokenSQ_POST'');
  42.  
  43. // First lets see if there are any actions to perform //
  44. if (!empty($smaction&& is_array($smaction)) {
  45.  
  46.     // first do a security check
  47.     sm_validate_security_token($submitted_token-1TRUE);
  48.  
  49.     $doaction '';
  50.     $identid 0;
  51.  
  52.     foreach($smaction as $action=>$row{
  53.         // we only need to extract the action and the identity we are
  54.         // altering
  55.  
  56.         foreach($row as $iKey=>$data{
  57.             $identid $iKey;
  58.         }
  59.  
  60.         $doaction $action;
  61.     }
  62.  
  63.     $identities sqfixidentities$newidentities $identid $action );
  64.     save_identities($identities);
  65. }
  66.  
  67. if (!empty($return)) {
  68.     header('Location: ' get_location('/options_personal.php');
  69.     exit;
  70. }
  71.  
  72.  
  73. /* since 1.1.3 */
  74. do_hook('options_identities_top'$null);
  75.  
  76. $i array();
  77. foreach ($identities as $key=>$ident{
  78.     $a array();
  79.     $a['Title'$key==_("Default Identity"sprintf(_("Alternate Identity %d")$key);
  80.     $a['New'false;
  81.     $a['Default'$key==0;
  82.     $a['FullName'sm_encode_html_special_chars($ident['full_name']);
  83.     $a['Email'sm_encode_html_special_chars($ident['email_address']);
  84.     $a['ReplyTo'sm_encode_html_special_chars($ident['reply_to']);
  85.     $a['Signature'sm_encode_html_special_chars($ident['signature']);
  86.     $i[$key$a;
  87. }
  88.  
  89. $a array();
  90. $a['Title'_("Add New Identity");
  91. $a['New'true;
  92. $a['Default'false;
  93. $a['FullName''';
  94. $a['Email''';
  95. $a['ReplyTo''';
  96. $a['Signature''';
  97. $i[count($i)$a;
  98.  
  99. //FIXME: NO HTML IN THE CORE
  100. echo '<form name="f" action="options_identities.php" method="post">' "\n"
  101.    . addHidden('smtoken'sm_generate_security_token()) "\n";
  102.  
  103. $oTemplate->assign('identities'$i);
  104. $oTemplate->display('options_advidentity_list.tpl');
  105.  
  106. //FIXME: NO HTML IN THE CORE
  107. echo "</form>\n";
  108.  
  109. $oTemplate->display('footer.tpl');
  110.  
  111. /**
  112.  * The functions below should not be needed with the additions of templates,
  113.  * however they will remain in case plugins use them.
  114.  */
  115.  
  116. /**
  117.  * Returns html formated identity form fields
  118.  *
  119.  * Contains options_identities_buttons and options_identities_table hooks.
  120.  * Before 1.4.5/1.5.1 hooks were placed in ShowTableInfo() function.
  121.  * In 1.1.3-1.4.1 they were called in do_hook function with two or
  122.  * three arguments. Since 1.4.1 hooks are called in concat_hook_function.
  123.  * Arguments are moved to array.
  124.  *
  125.  * options_identities_buttons hook uses array with two keys. First array key is
  126.  * boolean variable used to indicate empty identity field. Second array key
  127.  * is integer variable used to indicate identity number
  128.  *
  129.  * options_identities_table hook uses array with three keys. First array key is
  130.  * a string containing background color style CSS (1.4.1-1.4.4/1.5.0 uses only
  131.  * html color code). Second array key is boolean variable used to indicate empty
  132.  * identity field. Third array key is integer variable used to indicate identity
  133.  * number
  134.  * @param string $title Name displayed in header row
  135.  * @param array $identity Identity information
  136.  * @param integer $id identity ID
  137.  * @return string html formatted table rows with form fields for identity management
  138.  * @since 1.5.1 and 1.4.5 (was called ShowTableInfo() in 1.1.3-1.4.4 and 1.5.0)
  139.  */
  140. function ShowIdentityInfo($title$identity$id {
  141.     global $color;
  142.  
  143.     if (empty($identity['full_name']&& empty($identity['email_address']&& empty($identity['reply_to']&& empty($identity['signature'])) {
  144.         $bg '';
  145.         $empty true;
  146.     else {
  147.         $bg ' style="background-color:' $color[0';"';
  148.         $empty false;
  149.     }
  150.  
  151.     $name 'newidentities[%d][%s]';
  152.  
  153.  
  154.     $return_str '';
  155.  
  156. //FIXME: NO HTML IN THE CORE
  157.     $return_str .= '<tr>' "\n";
  158.     $return_str .= '  <th style="text-align:center;background-color:' $color[9';" colspan="2">' $title '</th> '"\n";
  159.     $return_str .= '</tr>' "\n";
  160.     $return_str .= sti_input_("Full Name"sprintf($name$id'full_name')$identity['full_name']$bg);
  161.     $return_str .= sti_input_("E-Mail Address"sprintf($name$id'email_address')$identity['email_address']$bg);
  162.     $return_str .= sti_input_("Reply To")sprintf($name$id'reply_to')$identity['reply_to']$bg);
  163.     $return_str .= sti_textarea_("Signature")sprintf($name$id'signature')$identity['signature']$bg);
  164.     $temp array(&$bg&$empty&$id);
  165.     $return_str .= concat_hook_function('options_identities_table'$temp);
  166.     $return_str .= '<tr' $bg '> ' "\n";
  167.     $return_str .= '  <td> &nbsp; </td>' "\n";
  168.     $return_str .= '  <td>' "\n";
  169.     $return_str .= '    <input type="submit" name="smaction[save][' $id ']" value="' _("Save / Update"'" />' "\n";
  170.  
  171.     if (!$empty && $id 0{
  172.         $return_str .= '    <input type="submit" name="smaction[makedefault][' $id ']" value="' _("Make Default"'" />' "\n";
  173.         $return_str .= '    <input type="submit" name="smaction[delete]['.$id.']" value="' _("Delete"'" />' "\n";
  174.  
  175.         if ($id 1{
  176.             $return_str .= '    <input type="submit" name="smaction[move]['.$id.']" value="' _("Move Up"'" />' "\n";
  177.         }
  178.  
  179.     }
  180.  
  181.     $temp array(&$empty&$id);
  182.     $return_str .= concat_hook_function('options_identities_buttons'$temp);
  183.     $return_str .= '  </td>' "\n";
  184.     $return_str .= '</tr>' "\n";
  185.     $return_str .= '<tr>' "\n";
  186.     $return_str .= '  <td colspan="2"> &nbsp; </td>' "\n";
  187.     $return_str .= '</tr>';
  188.  
  189.     return $return_str;
  190.  
  191. }
  192.  
  193. /**
  194.  * Creates html formated table row with input field
  195.  * @param string $title Name displayed next to input field
  196.  * @param string $name Name of input field
  197.  * @param string $data Default value of input field (data is sanitized with sm_encode_html_special_chars)
  198.  * @param string $bgcolor html attributes added to row element (tr)
  199.  * @return string html formated table row with text input field
  200.  * @since 1.2.0 (arguments differ since 1.4.5/1.5.1)
  201.  * @todo check right-to-left language issues
  202.  * @access private
  203.  */
  204. function sti_input$title$name$data$bgcolor {
  205. //FIXME: NO HTML IN THE CORE
  206.     $str '';
  207.     $str .= '<tr' $bgcolor ">\n";
  208.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ' </td>' "\n";
  209.     $str .= '  <td> <input type="text" name="' $name '" size="50" value="'sm_encode_html_special_chars($data'" /> </td>' "\n";
  210.     $str .= '</tr>';
  211.  
  212.     return $str;
  213.  
  214. }
  215.  
  216. /**
  217.  * Creates html formated table row with textarea field
  218.  * @param string $title Name displayed next to textarea field
  219.  * @param string $name Name of textarea field
  220.  * @param string $data Default value of textarea field  (data is sanitized with sm_encode_html_special_chars)
  221.  * @param string $bgcolor html attributes added to row element (tr)
  222.  * @return string html formated table row with textarea
  223.  * @since 1.2.5 (arguments differ since 1.4.5/1.5.1)
  224.  * @todo check right-to-left language issues
  225.  * @access private
  226.  */
  227. function sti_textarea$title$name$data$bgcolor {
  228. //FIXME: NO HTML IN THE CORE
  229.     $str '';
  230.     $str .= '<tr' $bgcolor ">\n";
  231.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ' </td>' "\n";
  232.     $str .= '  <td> <textarea name="' $name '" cols="50" rows="5">'"\n" sm_encode_html_special_chars($data'</textarea> </td>' "\n";
  233.     $str .= '</tr>';
  234.  
  235.     return $str;
  236.  
  237. }

Documentation generated on Mon, 13 Jan 2020 04:23:18 +0100 by phpDocumentor 1.4.3