home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / edit_contact.php < prev    next >
Encoding:
PHP Script  |  2003-06-29  |  8.4 KB  |  255 lines

  1. <?php
  2. /////////////////////////////////////////////////////////
  3. //    
  4. //    source/edit_contact.php
  5. //
  6. //    (C)Copyright 2001-2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
  7. //
  8. //        This file is part of IlohaMail.
  9. //        IlohaMail is free software released under the GPL 
  10. //        license.  See enclosed file COPYING for details,
  11. //        or see http://www.fsf.org/copyleft/gpl.html
  12. //
  13. /////////////////////////////////////////////////////////
  14.  
  15. /********************************************************
  16.  
  17.     AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
  18.     FILE: source/edit_contact.php
  19.     PURPOSE:
  20.         Provide an interface for viewing/adding/updating contact info.
  21.     PRE-CONDITIONS:
  22.         $user - Session ID
  23.         [$edit] - $id of item to modify or update (-1 means "new")
  24.     POST-CONDITIONS:
  25.         POST's data to contacts.php, which makes the requested changes.
  26.     COMMENTS:
  27.  
  28. ********************************************************/
  29. include("../include/super2global.inc");
  30. include("../include/header_main.inc");
  31. include("../lang/".$my_prefs["lang"]."/contacts.inc");
  32. include("../lang/".$my_prefs["lang"]."/edit_contact.inc");
  33. include("../include/contacts_commons.inc");
  34. include("../include/data_manager.inc");
  35.  
  36. //authenticate
  37. include_once("../include/icl.inc");
  38. $conn=iil_Connect($host, $loginID, $password, $AUTH_MODE);
  39. if ($conn){
  40.     iil_Close($conn);
  41. }else{
  42.     echo "Authentication failed.";
  43.     echo "</html>\n";
  44.     exit;
  45. }
  46.  
  47. //get data source name
  48. $source_name = $DB_CONTACTS_TABLE;
  49. if (empty($source_name)) $source_name = "contacts";
  50.  
  51. //open data manager connection
  52. $dm = new DataManager_obj;
  53. if ($dm->initialize($loginID, $host, $source_name, $backend)){
  54. }else{
  55.     echo "Data Manager initialization failed:<br>\n";
  56.     $dm->showError();
  57. }
  58.  
  59. //get groups
  60. if (!isset($groups)){
  61.     $contacts = $dm->read();
  62.     $groups = GetGroups($contacts);
  63. }
  64.  
  65. //if edit mode, fill in default values
  66. if (isset($edit)){
  67.     if (!isset($contacts)){
  68.         $contacts = $dm->read();
  69.     }
  70.     if (is_array($contacts)){
  71.         reset($contacts);
  72.         while ( list($k, $foobar) = each($contacts)){
  73.             if ($contacts[$k]["id"]==$edit){
  74.                 $name=$contacts[$k]["name"];
  75.                 $email=$contacts[$k]["email"];
  76.                 $email2=$contacts[$k]["email2"];
  77.                 $group=$contacts[$k]["grp"];
  78.                 $aim=$contacts[$k]["aim"];
  79.                 $icq=$contacts[$k]["icq"];
  80.                 $yahoo=$contacts[$k]["yahoo"];
  81.                 $msn=$contacts[$k]["msn"];
  82.                 $jabber=$contacts[$k]["jabber"];
  83.                 $phone=$contacts[$k]["phone"];
  84.                 $work=$contacts[$k]["work"];
  85.                 $cell=$contacts[$k]["cell"];
  86.                 $address=$contacts[$k]["address"];
  87.                 $url=$contacts[$k]["url"];
  88.                 $comments=$contacts[$k]["comments"];
  89.             }
  90.         }
  91.     }
  92. }else{
  93.     $edit=-1;
  94. }
  95.  
  96. ?>
  97.  
  98. <FORM ACTION="contacts.php" METHOD=POST>
  99.     <input type="hidden" name="user" value="<?php echo $user; ?>">
  100.     <input type="hidden" name="delete_item" value="<?php echo $edit; ?>">    
  101.     <input type="hidden" name="edit" value="<?php echo $edit; ?>">
  102.     
  103.     <table width="100%" cellpadding=2 cellspacing=0>
  104.            <tr bgcolor="<?php echo $my_colors["main_head_bg"]?>">
  105.           <td align=left valign=bottom>
  106.              <span class="bigTitle"><?php echo $cStrings[1]; ?></span>
  107.           </td>
  108.            </tr>
  109.         </table>
  110.  
  111. <table cellpadding="2" cellspacing="2" border="0"><!-- Global form width -->
  112.     <tr>
  113.       <td valign="top"><!-- Left Colum -->
  114.          <table width="100%">
  115.             <tr>
  116.           <td valign="top">
  117.                  <table width="100%" border="0">
  118.                     <tr>
  119.                        <td class=mainLight>
  120.                           <?php echo $ecStrings[3]; ?>:
  121.                        </td>
  122.                        <td align=right>
  123.                           <input type="text" name="name" value="<?php echo $name?>">
  124.                        </td>
  125.                     </tr>
  126.                     <tr>
  127.                        <td class=mainLight>
  128.                           <?php echo $ecStrings[4];?>:
  129.                        </td>   
  130.                        <td align=right>
  131.                           <input type="text" name="email" value="<?php echo $email; ?>">
  132.                        </td>
  133.                     </tr>
  134.                     <tr>
  135.                        <td class=mainLight>
  136.                 <?php echo $ecStrings[12];?>:
  137.                        </td>
  138.                        <td align=right>
  139.                            <input type="text" name="email2" value="<?php echo $email2; ?>">
  140.                        </td>
  141.                     <tr>
  142.                     </tr>
  143.                        <td class=mainLight>
  144.                           <?php echo $ecStrings[5];?>:
  145.                        </td>
  146.                        <td align=right>
  147.                           <input type="text" name="url" value="<?php echo $url; ?>">
  148.                        </td>
  149.                     </tr>
  150.                     <tr>
  151.                        <td class=mainLight>
  152.                           <?php echo $ecStrings[8];?>:</b>
  153.                        </td>
  154.                        <td align=right>
  155.                           <input type="text" name="phone" value="<?php echo $phone; ?>"  size=20>
  156.                        </td>
  157.                     </tr>
  158.                     <tr>
  159.                        <td class=mainLight>
  160.                  <?php echo $ecStrings[9];?>:
  161.                        </td>
  162.                        <td align=right>
  163.                           <input type="text" name="work" value="<?php echo $work; ?>" size=20>
  164.                        </td>
  165.                     </tr>
  166.                     <tr>
  167.                        <td class=mainLight>
  168.                           <?php echo $ecStrings[10];?>:
  169.                        </td>
  170.                        <td align=right>
  171.                           <input type="text" name="cell" value="<?php echo $cell; ?>" size=20>
  172.                        </td>
  173.                     </tr>
  174.                     <tr>
  175.                        <td colspan=2 class=mainLight>
  176.                   <br><?php echo $ecStrings[7];?>:
  177.                           <br><textarea name="comments" rows=4 cols=30><?php echo $comments;?></textarea>
  178.                        </td>
  179.                     </tr>
  180.                  </table>
  181.           </td>
  182.  
  183.             </tr>
  184.          </table>
  185.       </td>
  186.  
  187.       <td valign="top"><!-- Right colum -->
  188.          <table width="100%">
  189.             <tr>
  190.           <td valign="top">
  191.                  <table border="0" width="100%">
  192.                     <tr>
  193.                    <td class=mainLight valign="top"><?php echo $ecStrings[6]; ?>:
  194.                       <select name="group">
  195.                <option value="_otr_"><?php echo $ecStrings[14]?>
  196.                <?php
  197.                 $groups=base64_decode($groups);
  198.                 $groups_a=explode(",", $groups);
  199.                 
  200.                 if (is_array($groups_a)){
  201.                     while (list($key,$val)=each($groups_a)){
  202.                         if (!empty($val)) echo "<option ".(strcmp($val,$group)==0?"SELECTED":"").">$val\n";
  203.                     }
  204.                 }
  205.                ?>
  206.                </select>
  207.                        </td>
  208.                        <td class=mainLight align=right>
  209.                <input type="text" name="other_group" value="<?php echo $other_group; ?>">
  210.                      </td>
  211.                </tr>
  212.                     <tr>
  213.                        <td class=mainLight>
  214.                           <br>AIM:<input type="text" name="aim" value="<?php echo $aim; ?>" size=12>
  215.                        </td>
  216.                        <td class=mainLight align=right>
  217.                           <br>Yahoo:<input type="text" name="yahoo" value="<?php echo $yahoo; ?>" size=12>
  218.                        </td>
  219.                     </tr>
  220.                     <tr>
  221.                        <td class=mainLight>
  222.                   ICQ:<input type="text" name="icq" value="<?php echo $icq; ?>" size=12>
  223.                        </td>
  224.                        <td class=mainLight align=right>
  225.                           MSN:<input type="text" name="msn" value="<?php echo $msn; ?>" size=12>
  226.                        </td>
  227.                     </tr>
  228.                     <tr>
  229.                        <td class=mainLight colspan=2>
  230.                           Jabber:
  231.                           <input type="text" name="jabber" value="<?php echo $jabber; ?>" size=20>
  232.                        </td>
  233.                     </tr>
  234.                     <tr>
  235.                      <td colspan=2 class=mainLight valign="top">
  236.                       <br><br><?php echo $ecStrings[11];?>:
  237.                           <br><textarea name="address" rows=7 cols=30><?php echo $address;?></textarea>
  238.                      </td>
  239.                 </tr>
  240.                  </table>
  241.               </td>
  242.             </tr>
  243.          </table>
  244.       </td>
  245.  
  246.     </tr>
  247.     <tr>
  248.        <td align=left><input type="submit" name="add" value="<?php echo $cStrings[8]; ?>"></td>
  249.        <td align=right><input type="submit" name="remove" value="<?php echo $ecStrings[13]; ?>"></td>
  250.     </tr>
  251. </table>
  252.  
  253.      </FORM>
  254.    </body>
  255. </html>