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.22.2.11 2006/06/12 17:54:46 tokul Exp $
  11.  * @package squirrelmail
  12.  * @subpackage prefs
  13.  * @since 1.1.3
  14.  */
  15.  
  16. /**
  17.  * Path for SquirrelMail required files.
  18.  * @ignore
  19.  */
  20. define('SM_PATH','../');
  21.  
  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');
  28.  
  29. /* make sure that page is not available when $edit_identity is false */
  30. if (!$edit_identity{
  31.     error_box(_("Editing identities is disabled."),$color);
  32.     die('</body></html>');
  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.  
  42. // First lets see if there are any actions to perform //
  43. if (!empty($smaction&& is_array($smaction)) {
  44.  
  45.     $doaction '';
  46.     $identid 0;
  47.  
  48.     foreach($smaction as $action=>$row{
  49.         // we only need to extract the action and the identity we are
  50.         // altering
  51.  
  52.         
  53.         foreach($row as $iKey=>$data{
  54.             $identid $iKey;
  55.         }
  56.  
  57.         $doaction $action;
  58.     }
  59.  
  60.     $identities sqfixidentities$newidentities $identid $action );
  61.     save_identities($identities);
  62. }
  63.  
  64. if (!empty($return)) {
  65.     header('Location: ' get_location('/options_personal.php');
  66.     exit;
  67. }
  68.  
  69. displayPageHeader($color'None');
  70.  
  71. do_hook('options_identities_top');
  72.  
  73. $td_str '';
  74. $td_str .= '<form name="f" action="options_identities.php" method="post"><br />' "\n";
  75. $td_str .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">' "\n";
  76. $cnt count($identities);
  77. foreach$identities as $iKey=>$ident {
  78.  
  79.     if ($iKey == 0{
  80.         $hdr_str _("Default Identity");
  81.     else {
  82.         $hdr_str sprintf_("Alternate Identity %d")$iKey);
  83.     }
  84.  
  85.     $td_str .= ShowIdentityInfo$hdr_str$ident$iKey );
  86.  
  87. }
  88.  
  89. $td_str .= ShowIdentityInfo_("Add a New Identity")array('full_name'=>'','email_address'=>'','reply_to'=>'','signature'=>'')$cnt);
  90. $td_str .= '</table>' "\n";
  91. $td_str .= '</form>';
  92.  
  93. echo '<br /> ' "\n" .
  94.     html_tag('table'"\n" .
  95.         html_tag('tr'"\n" .
  96.             html_tag('td' "\n" .
  97.             '<b>' _("Options"' - ' _("Advanced Identities"'</b><br />' .
  98.             html_tag('table'"\n" .
  99.                 html_tag('tr'"\n" .
  100.                     html_tag('td'"\n" .
  101.                         html_tag('table' "\n" .
  102.                             html_tag('tr' "\n" .
  103.                                 html_tag('td'"\n" .  $td_str ,'','''style="text-align:center;"')
  104.                             ),
  105.                         '''''width="80%" cellpadding="2" cellspacing="0" border="0"' ,
  106.                     'center'$color[4])
  107.                 ),
  108.             '''''width="100%" border="0" cellpadding="1" cellspacing="1"' )) ,
  109.         'center'$color[0]),
  110.     'center''''width="95%" border="0" cellpadding="2" cellspacing="0"' '</body></html>';
  111.  
  112.  
  113. function ShowIdentityInfo($title$identity$id {
  114.     global $color;
  115.  
  116.     if (empty($identity['full_name']&& empty($identity['email_address']&& empty($identity['reply_to']&& empty($identity['signature'])) {
  117.         $bg '';
  118.         $empty true;
  119.     else {
  120.         $bg ' style="background-color:' $color[0';"';
  121.         $empty false;
  122.     }
  123.  
  124.     $name 'newidentities[%d][%s]';
  125.  
  126.  
  127.     $return_str '';
  128.  
  129.     $return_str .= '<tr>' "\n";
  130.     $return_str .= '  <th style="text-align:center;background-color:' $color[9';" colspan="2">' $title '</th> '"\n";
  131.     $return_str .= '</tr>' "\n";
  132.     $return_str .= sti_input_("Full Name"sprintf($name$id'full_name')$identity['full_name']$bg);
  133.     $return_str .= sti_input_("E-Mail Address"sprintf($name$id'email_address')$identity['email_address']$bg);
  134.     $return_str .= sti_input_("Reply To")sprintf($name$id'reply_to')$identity['reply_to']$bg);
  135.     $return_str .= sti_textarea_("Signature")sprintf($name$id'signature')$identity['signature']$bg);
  136.     $return_str .= concat_hook_function('options_identities_table'array($bg$empty$id));
  137.     $return_str .= '<tr' $bg '> ' "\n";
  138.     $return_str .= '  <td> &nbsp; </td>' "\n";
  139.     $return_str .= '  <td>' "\n";
  140.     $return_str .= '    <input type="submit" name="smaction[save][' $id ']" value="' _("Save / Update"'" />' "\n";
  141.  
  142.     if (!$empty && $id 0{
  143.         $return_str .= '    <input type="submit" name="smaction[makedefault][' $id ']" value="' _("Make Default"'" />' "\n";
  144.         $return_str .= '    <input type="submit" name="smaction[delete]['.$id.']" value="' _("Delete"'" />' "\n";
  145.  
  146.         if ($id 1{
  147.             $return_str .= '    <input type="submit" name="smaction[move]['.$id.']" value="' _("Move Up"'" />' "\n";
  148.         }
  149.  
  150.     }
  151.  
  152.     $return_str .= concat_hook_function('options_identities_buttons'array($empty$id));
  153.     $return_str .= '  </td>' "\n";
  154.     $return_str .= '</tr>' "\n";
  155.     $return_str .= '<tr>' "\n";
  156.     $return_str .= '  <td colspan="2"> &nbsp; </td>' "\n";
  157.     $return_str .= '</tr>';
  158.  
  159.     return $return_str;
  160.  
  161. }
  162.  
  163. function sti_input$title$name$data$bgcolor {
  164.     $str '';
  165.     $str .= '<tr' $bgcolor ">\n";
  166.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ' </td>' "\n";
  167.     $str .= '  <td> <input type="text" name="' $name '" size="50" value="'htmlspecialchars($data'"> </td>' "\n";
  168.     $str .= '</tr>';
  169.  
  170.     return $str;
  171.  
  172. }
  173.  
  174. function sti_textarea$title$name$data$bgcolor {
  175.     $str '';
  176.     $str .= '<tr' $bgcolor ">\n";
  177.     $str .= '  <td style="white-space: nowrap;text-align:right;">' $title ' </td>' "\n";
  178.     $str .= '  <td> <textarea name="' $name '" cols="50" rows="5">'htmlspecialchars($data'</textarea> </td>' "\n";
  179.     $str .= '</tr>';
  180.  
  181.     return $str;
  182.  
  183. }
  184.  
  185. ?>

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