home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / email / accounts.php < prev    next >
Encoding:
PHP Script  |  2004-03-08  |  5.7 KB  |  161 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14. require($GO_CONFIG->class_path."imap.class.inc");
  15. require($GO_CONFIG->class_path."email.class.inc");
  16. require($GO_LANGUAGE->get_language_file('email'));
  17. $mail = new imap();
  18. $email = new email();
  19.  
  20. $GO_SECURITY->authenticate();
  21. $GO_MODULES->authenticate('email');
  22.  
  23. $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
  24. $return_to = (isset($_REQUEST['return_to']) && $_REQUEST['return_to'] != '') ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
  25. $link_back = (isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '') ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
  26.  
  27. //delete accounts if requested
  28. if ($task == 'save_account')
  29. {
  30.     $task = 'account';
  31.     $mbroot = isset($_POST['mbroot']) ? $_POST['mbroot'] : '';
  32.     if ($_POST['name'] == "" || $_POST['mail_address'] == "" || $_POST['port'] == "" || $_POST['user'] == "" || $_POST['pass'] == "" || $_POST['host'] == "")
  33.     {
  34.         $feedback = $error_missing_field;
  35.     }else
  36.     {
  37.         $sent = $_POST['type'] == 'pop3' ? '' : $_POST['sent'];
  38.         $spam = $_POST['type'] == 'pop3' ? '' : $_POST['spam'];
  39.         $trash = $_POST['type'] == 'pop3' ? '' : $_POST['trash'];
  40.  
  41.         $auto_check = isset($_POST['auto_check']) ? '1' : '0';
  42.         if (isset($_POST['account_id']))
  43.         {
  44.             if(!$email->update_account($_POST['account_id'], $_POST['type'], $_POST['host'], $_POST['port'], $mbroot, $_POST['user'], $_POST['pass'], $_POST['name'], $_POST['mail_address'], $_POST['signature'], $sent, $spam, $trash, $auto_check))
  45.             {
  46.                 $feedback = '<p class="Error">'.$ml_connect_failed.' \''.$_POST['host'].'\' '.$ml_at_port.': '.$_POST['port'].'</p>';
  47.                 $feedback .= '<p class="Error">'.$email->last_error.'</p>';
  48.             }
  49.         }else
  50.         {
  51.             if(!$email_id = $email->add_account($GO_SECURITY->user_id, $_POST['type'], $_POST['host'], $_POST['port'], $mbroot, $_POST['user'], $_POST['pass'], $_POST['name'], $_POST['mail_address'], $_POST['signature'], $sent, $spam, $trash, $auto_check))
  52.             {
  53.                 $feedback = '<p class="Error">'.$ml_connect_failed.' \''.$_POST['host'].'\' '.$ml_at_port.': '.$_POST['port'].'</p>';
  54.                 $feedback .= '<p class="Error">'.$email->last_error.'</p>';
  55.             }
  56.         }
  57.     }
  58. }
  59.  
  60. require($GO_THEME->theme_path."header.inc");
  61.  
  62. echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="email_client">';
  63. echo '<input type="hidden" name="task" value="" />';
  64. echo '<input type="hidden" name="close" value="false" />';
  65. echo '<input type="hidden" name="return_to" value="'.$return_to.'" />';
  66. echo '<input type="hidden" name="link_back" value="'.$link_back.'" />';
  67. echo '<input type="hidden" name="delete_account_id" />';
  68.  
  69. $tabtable = new tabtable('accounts_list', $ml_your_accounts, '600', '300', '100', '', true);
  70. $tabtable->print_head();
  71.  
  72.  
  73. if (!function_exists('imap_open'))
  74. {
  75.     echo 'Error: the imap extension for PHP is not installed';
  76. }else
  77. {
  78.     if(isset($_REQUEST['delete_account_id']) && $_REQUEST['delete_account_id'] > 0)
  79.     {
  80.         if (!$email->delete_account($GO_SECURITY->user_id, $_REQUEST['delete_account_id']))
  81.         {
  82.             echo $strDeleteError;
  83.         }elseif(isset($_SESSION['email_id']) && $_REQUEST['delete_account_id'] == $_SESSION['email_id'])
  84.         {
  85.             unset($_SESSION['email_id']);
  86.         }
  87.     }
  88.  
  89.     if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['account_id']))
  90.     {
  91.         $email->set_as_default($_POST['account_id'], $GO_SECURITY->user_id);
  92.     }
  93.     ?>
  94.     <br />
  95.     <a href="account.php?return_to=<?php echo urlencode($link_back); ?>" class="normal"><?php echo $ml_new_account; ?></a>
  96.     <br />
  97.     <br />
  98.     <table border="0" cellpadding="10" cellspacing="0">
  99.     <tr>
  100.         <td>
  101.         <table border="0" cellpadding="4" cellspacing="0" width="100%">
  102.         <?php
  103.         $count = $email->get_accounts($GO_SECURITY->user_id);
  104.  
  105.         if ($count > 0)
  106.         {
  107.             echo '<tr><td align="right"><h3>'.$strDefault.'</h3></td>';
  108.             echo '<td><h3>'.$strHost.'</h3></td>';
  109.             echo '<td><h3>'.$strEmail.'</h3></td>';
  110.             echo '<td> </td></tr>';
  111.  
  112.             while ($email->next_record())
  113.             {
  114.                 if ($email->f("standard") == "1")
  115.                 {
  116.                     $checked = "checked";
  117.                 }else
  118.                 {
  119.                     $checked = "";
  120.                 }
  121.                 echo '<tr>';
  122.                 echo '<td align="right"><input type="radio" onclick="javascript:document.forms[0].submit()" name="account_id" value="'.$email->f("id").'" '.$checked.' /></td>';
  123.                 echo '<td>'.$email->f("host").'</a></td>';
  124.                 echo '<td>'.$email->f('email').'</td>';
  125.                 echo '<td><a href="account.php?account_id='.$email->f('id').'&return_to='.urlencode($link_back).'" title="'.$strEdit.' '.$email->f('host').'"><img src="'.$GO_THEME->images['edit'].'" border="0" /></a></td>';
  126.                 echo "<td><a href='javascript:delete_account(\"".$email->f("id")."\",\"".rawurlencode($strDeletePrefix."'".$email->f("host")."'".$strDeleteSuffix)."\")' title=\"".$strDeleteItem." '".$email->f("host")."'\"><img src=\"".$GO_THEME->images['delete']."\" border=\"0\"></a></td>\n";
  127.                 echo '</tr>';
  128.             }
  129.         }else
  130.         {
  131.             echo "<tr><td>".$ml_no_accounts."</td></tr>";
  132.         }
  133.         ?>
  134.         </table>
  135.         <br />
  136.         <?php
  137.         $button = new button($cmdClose, "javascript:document.location='".$return_to."'");
  138.         ?>
  139.         </td>
  140.     </tr>
  141.     </table>
  142.  
  143. <?php
  144.     $tabtable->print_foot();
  145.     echo '</form>';
  146. }
  147. ?>
  148. <script type="text/javascript" language="javascript">
  149. function delete_account(account_id, message)
  150. {
  151.     if (confirm(unescape(message)))
  152.     {
  153.         document.forms[0].delete_account_id.value = account_id;
  154.         document.forms[0].submit();
  155.     }
  156. }
  157. </script>
  158.  
  159. <?php
  160. require($GO_THEME->theme_path."footer.inc");
  161. ?>