home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / addressbook / members.inc < prev    next >
Text File  |  2004-03-08  |  8KB  |  201 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. //load user management class
  14. require($GO_CONFIG->class_path."users.class.inc");
  15. $users = new users();
  16.  
  17. if ($_SERVER['REQUEST_METHOD'] == "POST")
  18. {
  19.     if (isset($_POST['user']) && $addressbook = $ab->get_addressbook($_POST['addressbook_id']))
  20.     {
  21.  
  22.         for ($i=0;$i<sizeof($_POST['user']);$i++)
  23.         {
  24.             if (!$ab->user_is_in_addressbook($_POST['user'][$i], $_POST['addressbook_id']))
  25.             {
  26.                 $profile = $users->get_user($_POST['user'][$i]);
  27.  
  28.                 $first_name = addslashes($profile["first_name"]);
  29.                 $middle_name = addslashes($profile["middle_name"]);
  30.                 $last_name = addslashes($profile["last_name"]);
  31.                 $initials = addslashes($profile["initials"]);
  32.                 $title = addslashes($profile["title"]);
  33.                 $birthday = addslashes($profile["birthday"]);
  34.                 $email = addslashes($profile["email"]);
  35.                 $work_phone = addslashes($profile["work_phone"]);
  36.                 $home_phone = addslashes($profile["home_phone"]);
  37.                 $fax = addslashes($profile["fax"]);
  38.                 $cellular = addslashes($profile["cellular"]);
  39.                 $country = addslashes($profile["country"]);
  40.                 $state = addslashes($profile["state"]);
  41.                 $city = addslashes($profile["city"]);
  42.                 $zip = addslashes($profile["zip"]);
  43.                 $address = addslashes($profile["address"]);
  44.                 $company = addslashes($profile["company"]);
  45.                 $department = addslashes($profile["department"]);
  46.                 $function = addslashes($profile["function"]);
  47.                 $work_fax = addslashes($profile["work_fax"]);
  48.                 $work_country = addslashes($profile["work_country"]);
  49.                 $work_state = addslashes($profile["work_state"]);
  50.                 $work_city = addslashes($profile["work_city"]);
  51.                 $work_zip = addslashes($profile["work_zip"]);
  52.                 $work_address = addslashes($profile["work_address"]);
  53.                 $homepage = addslashes($profile["homepage"]);
  54.  
  55.                 $acl_read = $GO_SECURITY->get_new_acl('contact read');
  56.                 $acl_write = $GO_SECURITY->get_new_acl('contact write');
  57.                 if ($acl_read > 0 && $acl_write > 0)
  58.                 {
  59.                     $company_id = $ab->get_company_id_by_name($profile['company'], $_POST['addressbook_id']);
  60.  
  61.                     if ($ab->add_contact($_POST['user'][$i], $_POST['addressbook_id'], $first_name, $middle_name, $last_name, $initials, $title, $profile['sex'], $birthday, $email, $work_phone, $home_phone, $fax, $cellular, $country, $state, $city, $zip, $address, $company_id, $work_fax, $department, $function,'',$_POST['group'], '', $acl_read, $acl_write))
  62.                     {
  63.                         $GO_SECURITY->copy_acl($addressbook['acl_read'], $acl_read);
  64.                         $GO_SECURITY->copy_acl($addressbook['acl_write'], $acl_write);
  65.                     }else
  66.                     {
  67.                         $GO_SECURITY->delete_acl($acl_read);
  68.                         $GO_SECURITY->delete_acl($acl_write);
  69.                     }
  70.                 }
  71.             }
  72.         }
  73.     }
  74. }
  75.  
  76. if (!isset($_COOKIE['contact_sort']) || $_COOKIE['contact_sort'] == "source_id")
  77. {
  78.     $_COOKIE['contact_sort'] = 'name';
  79. }
  80.  
  81. if (!isset($_COOKIE['contact_direction']))
  82. {
  83.     $_COOKIE['contact_direction'] = 'ASC';
  84. }
  85.  
  86. if ($_COOKIE['contact_direction'] == "DESC")
  87. {
  88.     $image_string = ' <img src="'.$GO_THEME->images['arrow_down'].'" border="0" />';
  89.     $newdirection = "ASC";
  90. }else
  91. {
  92.     $image_string = ' <img src="'.$GO_THEME->images['arrow_up'].'" border="0" />';
  93.     $newdirection = "DESC";
  94. }
  95.  
  96.  
  97. echo '<input type="hidden" name="post_action" value="'.$post_action.'" />';
  98.  
  99. echo '<table border="0" width="700"><tr>';
  100. if ($ab->get_subscribed_addressbooks($GO_SECURITY->user_id) > 1)
  101. {
  102.     echo '<td>'.$ab_addressbook.':</td><td>';
  103.     $subscribed_addressbooks = new dropbox();
  104.     while ($ab->next_record())
  105.     {
  106.         $subscribed_addressbooks->add_value($ab->f('id'), $ab->f('name'));
  107.     }
  108.     $subscribed_addressbooks->print_dropbox('addressbook_id', $addressbook_id, 'onchange="javascript:document.forms[0].submit()"');
  109.     echo '</td>';
  110. }
  111.  
  112. echo '<td align="right" width="100%">';
  113. $group_count = $ab->get_groups($addressbook_id);
  114. if ($ab->get_groups($addressbook_id) > 0)
  115. {
  116.     $dropbox = new dropbox();
  117.     $dropbox->add_value('',$contacts_add_to_group);
  118.     $dropbox->add_value('0',$contacts_other);
  119.     $dropbox->add_sql_data('ab','id','name');
  120.     $dropbox->print_dropbox('group','','onchange="javascript:document.forms[0].submit()"');
  121. }else
  122. {
  123.     echo '<a href="javascript:document.forms[0].submit()" class="normal">'.$contacts_add_to.'</a><br /><br />';
  124.     echo '<input type="hidden" name="group" value="0" />';
  125. }
  126. echo '</td></tr></table>';
  127.  
  128.  
  129. $count = $users->get_authorized_users($GO_SECURITY->user_id, $_COOKIE['contact_sort'], $_COOKIE['contact_direction']);
  130. echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
  131. echo "<tr>";
  132. echo '<td class="TableHead2" width="16"><input type="checkbox" value="dummy" name="dummy" onclick="javascript:invert_selection()" /></td>';
  133. echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?post_action=members&newsort=name&newdirection=".$newdirection."\">".$strName;
  134. if ($_COOKIE['contact_sort'] == "name")
  135.         echo $image_string;
  136. echo "</a></td>\n";
  137. echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?post_action=members&newsort=email&newdirection=".$newdirection."\">".$strEmail;
  138. if ($_COOKIE['contact_sort'] == "email")
  139.         echo $image_string;
  140. echo "</a></td>\n";
  141. echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?post_action=members&newsort=company&newdirection=".$newdirection."\">".$strCompany;
  142. if ($_COOKIE['contact_sort'] == "company")
  143.         echo $image_string;
  144. echo "</a></td>\n";
  145. echo "<td class=\"TableHead2\"> </td>\n";
  146. echo "</tr>\n";
  147.  
  148.  
  149. while ($users->next_record())
  150. {
  151.     $middle_name = $users->f('middle_name') == '' ? '' : $users->f('middle_name').' ';
  152.     $name = $users->f('first_name').' '.$middle_name.$users->f('last_name');
  153.  
  154.     echo "<tr id=\"".$users->f("id")."\" height=\"18\" class=\"Table1\">\n";
  155.     echo "<td width=\"16\"><input type=\"checkbox\" name=\"user[]\" value=\"".$users->f("id")."\" onclick=\"item_click(this)\" /></td>";
  156.     echo "<td>".show_profile($users->f("id"), $name)." </a></td>\n";
  157.     echo "<td>".mail_to(empty_to_stripe($users->f("email")))." </td>\n";
  158.     echo "<td>".empty_to_stripe($users->f("company"))." </td>\n";
  159.     echo "<td><a href=\"contact.php?user_id=".$users->f("id")."\" title=\"".$contacts_add_member."\"><img src=\"".$GO_THEME->images['save']."\" border=\"0\" />";
  160.     echo "</tr>\n";
  161.     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  162. }
  163.  
  164.  
  165. if($count > 0)
  166. {
  167.     echo '<tr><td colspan="99" height="18">'.$count.' '.$contacts_members.'</td></tr>';
  168.     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  169. }else
  170. {
  171.         echo '<tr><td colspan="99" height="18">'.$contacts_no_contacts.'</td></tr>';
  172.     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  173. }
  174. echo "</table>";
  175. ?>
  176. <script language="javascript" type="text/javascript">
  177. function item_click(check_box)
  178. {
  179.     var item = get_object(check_box.value);
  180.     if (check_box.checked)
  181.     {
  182.         item.className = 'Table2';
  183.     }else
  184.     {
  185.         item.className = 'Table1';
  186.     }
  187. }
  188.  
  189. function invert_selection()
  190. {
  191.     for (var i=0;i<document.forms[0].elements.length;i++)
  192.     {
  193.         if(document.forms[0].elements[i].type == 'checkbox' && document.forms[0].elements[i].name != 'dummy')
  194.         {
  195.             document.forms[0].elements[i].checked = !(document.forms[0].elements[i].checked);
  196.             item_click(document.forms[0].elements[i]);
  197.         }
  198.     }
  199. }
  200.  
  201. </script>