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 &copy; 1999-2006 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: options_identities.php,v 1.46 2006/08/25 23:09:07 stevetruckstuff Exp $
  11.  * @package squirrelmail
  12.  * @subpackage prefs
  13.  * @since 1.1.3
  14.  */
  15.  
  16. /**
  17.  * Include the SquirrelMail initialization file.
  18.  */
  19. require('../include/init.php');
  20.  
  21. /* SquirrelMail required files. */
  22. require_once(SM_PATH 'functions/identity.php');
  23.  
  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');
  28.     die();
  29. }
  30.  
  31. if (!sqgetGlobalVar('identities'$identitiesSQ_SESSION)) {
  32.     $identities get_identities();
  33. }
  34. sqgetGlobalVar('newidentities'$newidentitiesSQ_POST);
  35. sqgetGlobalVar('smaction'$smactionSQ_POST);
  36. sqgetGlobalVar('return'$returnSQ_POST);
  37.  
  38. // First lets see if there are any actions to perform //
  39. if (!empty($smaction&& is_array($smaction)) {
  40.  
  41.     $doaction '';
  42.     $identid 0;
  43.  
  44.     foreach($smaction as $action=>$row{
  45.         // we only need to extract the action and the identity we are
  46.         // altering
  47.  
  48.         
  49.         foreach($row as $iKey=>$data{
  50.             $identid $iKey;
  51.         }
  52.  
  53.         $doaction $action;
  54.     }
  55.  
  56.     $identities sqfixidentities$newidentities $identid $action );
  57.     save_identities($identities);
  58. }
  59.  
  60. if (!empty($return)) {
  61.     header('Location: ' get_location('/options_personal.php');
  62.     exit;
  63. }
  64.  
  65. displayPageHeader($color'None');
  66.  
  67. /* since 1.1.3 */
  68. do_hook('options_identities_top');
  69.  
  70. $i array();
  71. foreach ($identities as $key=>$ident{
  72.     $a array();
  73.     $a['Title'$key==_("Default Identity"sprintf(_("Alternate Identity %d")$key);
  74.     $a['New'false;
  75.     $a['Default'$key==0;
  76.     $a['FullName'htmlspecialchars($ident['full_name']);
  77.     $a['Email'htmlspecialchars($ident['email_address']);
  78.     $a['ReplyTo'htmlspecialchars($ident['reply_to']);
  79.     $a['Signature'htmlspecialchars($ident['signature']);
  80.     $i[$key$a;
  81. }
  82.  
  83. $a array();
  84. $a['Title'_("Add New Identity");
  85. $a['New'true;
  86. $a['Default'false;
  87. $a['FullName''';
  88. $a['Email''';
  89. $a['ReplyTo''';
  90. $a['Signature''';
  91. $i[count($i)$a;
  92.  
  93. echo '<form name="f" action="options_identities.php" method="post">' "\n";
  94.  
  95. $oTemplate->assign('identities'$i);
  96. $oTemplate->display('options_advidentity_list.tpl');
  97.  
  98. echo "</form>\n";
  99.  
  100. $oTemplate->display('footer.tpl');
  101.  
  102. /**
  103.  * The functions below should not be needed with the additions of templates,
  104.  * however they will remain in case plugins use them.
  105.  */
  106.  
  107. /**
  108.  * Returns html formated identity form fields
  109.  *
  110.  * Contains options_identities_buttons and option_identities_table hooks.
  111.  * Before 1.4.5/1.5.1 hooks were placed in ShowTableInfo() function.
  112.  * In 1.1.3-1.4.1 they were called in do_hook function with two or
  113.  * three arguments. Since 1.4.1 hooks are called in concat_hook_function.
  114.  * Arguments are moved to array.
  115.  *
  116.  * options_identities_buttons hook uses array with two keys. First array key is
  117.  * boolean variable used to indicate empty identity field. Second array key
  118.  * is integer variable used to indicate identity number
  119.  *
  120.  * options_identities_table hook uses array with three keys. First array key is
  121.  * a string containing background color style CSS (1.4.1-1.4.4/1.5.0 uses only
  122.  * html color code). Second array key is boolean variable used to indicate empty
  123.  * identity field. Third array key is integer variable used to indicate identity
  124.  * number
  125.  * @param string $title Name displayed in header row
  126.  * @param array $identity Identity information
  127.  * @param integer $id identity ID
  128.  * @return string html formatted table rows with form fields for identity management
  129.  * @since 1.5.1 and 1.4.5 (was called ShowTableInfo() in 1.1.3-1.4.4 and 1.5.0)
  130.  */
  131. function ShowIdentityInfo($title$identity$id {
  132.     global $color;
  133.  
  134.     if (empty($identity['full_name']&& empty($identity['email_address']&& empty($identity['reply_to']&& empty($identity['signature'])) {
  135.         $bg '';
  136.         $empty true;
  137.     else {
  138.         $bg ' style="background-color:' $color[0';"';
  139.         $empty false;
  140.     }
  141.  
  142.     $name 'newidentities[%d][%s]';
  143.  
  144.  
  145.     $return_str '';
  146.  
  147.     $return_str .= '<tr>' "\n";
  148.     $return_str .= '  <th style="text-align:center;background-color:' $color[9';" colspan="2">' $title '</th> '"\n";
  149.     $return_str .= '</tr>' "\n";
  150.     $return_str .= sti_input_("Full Name"sprintf($name$id'full_name')$identity['full_name']$bg);
  151.     $return_str .= sti_input_("E-Mail Address"sprintf($name$id'email_address')$identity['email_address']$bg);
  152.     $return_str .= sti_input_("Reply To")sprintf($name$id'reply_to')$identity['reply_to']$bg);
  153.     $return_str .= sti_textarea_("Signature")sprintf($name$id'signature')$identity['signature']$bg);
  154.     $return_str .= concat_hook_function('options_identities_table'array($bg$empty$id));
  155.     $return_str .= '<tr' $bg '> ' "\n";
  156.     $return_str .= '  <td> &nbsp; </td>' "\n";
  157.     $return_str .= '  <td>' "\n";
  158.     $return_str .= '    <input type="submit" name="smaction[save][' $id ']" value="' _("Save / Update"'" />' "\n";
  159.  
  160.     if (!$empty && $id 0{
  161.         $return_str .= '    <input type="submit" name="smaction[makedefault][' $id ']" value="' _("Make Default"'" />' "\n";
  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. /**
  182.  * Creates html formated table row with input field
  183.  * @param string $title Name displayed next to input field
  184.  * @param string $name Name of input field
  185.  * @param string $data Default value of input field (data is sanitized with htmlspecialchars)
  186.  * @param string $bgcolor html attributes added to row element (tr)
  187.  * @return string html formated table row with text input field
  188.  * @since 1.2.0 (arguments differ since 1.4.5/1.5.1)
  189.  * @todo check right-to-left language issues
  190.  * @access private
  191.  */
  192. function sti_input$title$name$data$bgcolor {
  193.     $str '';
  194.     $str .= '<tr' $bgcolor ">\n";
  195.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ' </td>' "\n";
  196.     $str .= '  <td> <input type="text" name="' $name '" size="50" value="'htmlspecialchars($data'"> </td>' "\n";
  197.     $str .= '</tr>';
  198.  
  199.     return $str;
  200.  
  201. }
  202.  
  203. /**
  204.  * Creates html formated table row with textarea field
  205.  * @param string $title Name displayed next to textarea field
  206.  * @param string $name Name of textarea field
  207.  * @param string $data Default value of textarea field  (data is sanitized with htmlspecialchars)
  208.  * @param string $bgcolor html attributes added to row element (tr)
  209.  * @return string html formated table row with textarea
  210.  * @since 1.2.5 (arguments differ since 1.4.5/1.5.1)
  211.  * @todo check right-to-left language issues
  212.  * @access private
  213.  */
  214. function sti_textarea$title$name$data$bgcolor {
  215.     $str '';
  216.     $str .= '<tr' $bgcolor ">\n";
  217.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ' </td>' "\n";
  218.     $str .= '  <td> <textarea name="' $name '" cols="50" rows="5">'htmlspecialchars($data'</textarea> </td>' "\n";
  219.     $str .= '</tr>';
  220.  
  221.     return $str;
  222.  
  223. }
  224.  
  225. ?>

Documentation generated on Sat, 07 Oct 2006 16:12:56 +0300 by phpDocumentor 1.3.0RC6