home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / email / add_contacts.php < prev    next >
PHP Script  |  2004-03-08  |  3KB  |  152 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. session_start();
  13.  
  14. $contacts = isset($_REQUEST['contacts']) ? $_REQUEST['contacts'] : array();
  15. $companies = isset($_REQUEST['companies']) ? $_REQUEST['companies'] : array();
  16. $users = isset($_REQUEST['users']) ? $_REQUEST['users'] : array();
  17.  
  18. if (isset($_REQUEST['clicked_value']) && $_REQUEST['clicked_value'] != '')
  19. {
  20.     switch($_REQUEST['clicked_type'])
  21.     {
  22.         case 'contact':
  23.             $contacts[] = $_REQUEST['clicked_value'];
  24.         break;
  25.  
  26.         case 'company':
  27.             $companies[] = $_REQUEST['clicked_value'];
  28.         break;
  29.  
  30.         case 'user':
  31.             $users[] = $_REQUEST['clicked_value'];
  32.         break;
  33.     }
  34. }
  35.  
  36. $string = '';
  37. if (isset($_REQUEST['addresses']))
  38. {
  39.     for ($i=0;$i<sizeof($_REQUEST['addresses']);$i++)
  40.     {
  41.         if ($i != 0)
  42.         {
  43.             $string .= ", ";
  44.         }
  45.         $string .= $_REQUEST['addresses'][$i];
  46.     }
  47. }
  48.  
  49. if ($string != "")
  50. {
  51.        $string .= ", ";
  52. }
  53.  
  54. if (isset($_REQUEST['email']))
  55. {
  56.     $string .= $_REQUEST['email'];
  57. }else
  58. {
  59.     if (isset($contacts))
  60.     {
  61.         for($i=0;$i<sizeof($contacts);$i++)
  62.         {
  63.             if (isset($_REQUEST['addresses']))
  64.             {
  65.                 if (!in_array($contacts[$i],$_REQUEST['addresses']))
  66.                 {
  67.                     if (isset($first))
  68.                         $string .= ", ";
  69.                     else
  70.                         $first = true;
  71.  
  72.                     $string .= $contacts[$i];
  73.                 }
  74.             }else
  75.             {
  76.                 if (isset($first))
  77.                     $string .= ", ";
  78.                 else
  79.                     $first = true;
  80.  
  81.                 $string .= $contacts[$i];
  82.  
  83.             }
  84.         }
  85.     }
  86.     if (isset($companies))
  87.     {
  88.         for($i=0;$i<sizeof($companies);$i++)
  89.         {
  90.             if (isset($_REQUEST['addresses']))
  91.             {
  92.                 if (!in_array($companies[$i],$_REQUEST['addresses']))
  93.                 {
  94.                     if (isset($first))
  95.                         $string .= ", ";
  96.                     else
  97.                         $first = true;
  98.  
  99.                     $string .= $companies[$i];
  100.                 }
  101.             }else
  102.             {
  103.                 if (isset($first))
  104.                     $string .= ", ";
  105.                 else
  106.                     $first = true;
  107.  
  108.                 $string .= $companies[$i];
  109.  
  110.             }
  111.         }
  112.     }
  113.     if (isset($users))
  114.     {
  115.         for($i=0;$i<sizeof($users);$i++)
  116.         {
  117.             if (isset($_REQUEST['addresses']))
  118.             {
  119.                 if (!in_array($users[$i],$_REQUEST['addresses']))
  120.                 {
  121.                     if (isset($first))
  122.                         $string .= ", ";
  123.                     else
  124.                         $first = true;
  125.  
  126.                     $string .= $users[$i];
  127.                 }
  128.             }else
  129.             {
  130.                 if (isset($first))
  131.                     $string .= ", ";
  132.                 else
  133.                     $first = true;
  134.  
  135.                 $string .= $users[$i];
  136.  
  137.             }
  138.         }
  139.     }
  140. }
  141.  
  142. unset($_SESSION['GO_HANDLER']);
  143. ?>
  144. <html>
  145. <body>
  146. <script language="javascript" type="text/javascript">
  147.         opener.<?php echo $_REQUEST['GO_FIELD']; ?>.value = '<?php echo $string; ?>';
  148.         window.close();
  149. </script>
  150. </body>
  151. </html>
  152.