home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- Copyright Intermesh 2003
- Author: Merijn Schering <mschering@intermesh.nl>
- Version: 1.0 Release date: 08 July 2003
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
- */
-
- //load user management class
- require($GO_CONFIG->class_path."users.class.inc");
- $users = new users();
-
- if ($_SERVER['REQUEST_METHOD'] == "POST")
- {
- if (isset($_POST['user']) && $addressbook = $ab->get_addressbook($_POST['addressbook_id']))
- {
-
- for ($i=0;$i<sizeof($_POST['user']);$i++)
- {
- if (!$ab->user_is_in_addressbook($_POST['user'][$i], $_POST['addressbook_id']))
- {
- $profile = $users->get_user($_POST['user'][$i]);
-
- $first_name = addslashes($profile["first_name"]);
- $middle_name = addslashes($profile["middle_name"]);
- $last_name = addslashes($profile["last_name"]);
- $initials = addslashes($profile["initials"]);
- $title = addslashes($profile["title"]);
- $birthday = addslashes($profile["birthday"]);
- $email = addslashes($profile["email"]);
- $work_phone = addslashes($profile["work_phone"]);
- $home_phone = addslashes($profile["home_phone"]);
- $fax = addslashes($profile["fax"]);
- $cellular = addslashes($profile["cellular"]);
- $country = addslashes($profile["country"]);
- $state = addslashes($profile["state"]);
- $city = addslashes($profile["city"]);
- $zip = addslashes($profile["zip"]);
- $address = addslashes($profile["address"]);
- $company = addslashes($profile["company"]);
- $department = addslashes($profile["department"]);
- $function = addslashes($profile["function"]);
- $work_fax = addslashes($profile["work_fax"]);
- $work_country = addslashes($profile["work_country"]);
- $work_state = addslashes($profile["work_state"]);
- $work_city = addslashes($profile["work_city"]);
- $work_zip = addslashes($profile["work_zip"]);
- $work_address = addslashes($profile["work_address"]);
- $homepage = addslashes($profile["homepage"]);
-
- $acl_read = $GO_SECURITY->get_new_acl('contact read');
- $acl_write = $GO_SECURITY->get_new_acl('contact write');
- if ($acl_read > 0 && $acl_write > 0)
- {
- $company_id = $ab->get_company_id_by_name($profile['company'], $_POST['addressbook_id']);
-
- 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))
- {
- $GO_SECURITY->copy_acl($addressbook['acl_read'], $acl_read);
- $GO_SECURITY->copy_acl($addressbook['acl_write'], $acl_write);
- }else
- {
- $GO_SECURITY->delete_acl($acl_read);
- $GO_SECURITY->delete_acl($acl_write);
- }
- }
- }
- }
- }
- }
-
- if (!isset($_COOKIE['contact_sort']) || $_COOKIE['contact_sort'] == "source_id")
- {
- $_COOKIE['contact_sort'] = 'name';
- }
-
- if (!isset($_COOKIE['contact_direction']))
- {
- $_COOKIE['contact_direction'] = 'ASC';
- }
-
- if ($_COOKIE['contact_direction'] == "DESC")
- {
- $image_string = ' <img src="'.$GO_THEME->images['arrow_down'].'" border="0" />';
- $newdirection = "ASC";
- }else
- {
- $image_string = ' <img src="'.$GO_THEME->images['arrow_up'].'" border="0" />';
- $newdirection = "DESC";
- }
-
-
- echo '<input type="hidden" name="post_action" value="'.$post_action.'" />';
-
- echo '<table border="0" width="700"><tr>';
- if ($ab->get_subscribed_addressbooks($GO_SECURITY->user_id) > 1)
- {
- echo '<td>'.$ab_addressbook.':</td><td>';
- $subscribed_addressbooks = new dropbox();
- while ($ab->next_record())
- {
- $subscribed_addressbooks->add_value($ab->f('id'), $ab->f('name'));
- }
- $subscribed_addressbooks->print_dropbox('addressbook_id', $addressbook_id, 'onchange="javascript:document.forms[0].submit()"');
- echo '</td>';
- }
-
- echo '<td align="right" width="100%">';
- $group_count = $ab->get_groups($addressbook_id);
- if ($ab->get_groups($addressbook_id) > 0)
- {
- $dropbox = new dropbox();
- $dropbox->add_value('',$contacts_add_to_group);
- $dropbox->add_value('0',$contacts_other);
- $dropbox->add_sql_data('ab','id','name');
- $dropbox->print_dropbox('group','','onchange="javascript:document.forms[0].submit()"');
- }else
- {
- echo '<a href="javascript:document.forms[0].submit()" class="normal">'.$contacts_add_to.'</a><br /><br />';
- echo '<input type="hidden" name="group" value="0" />';
- }
- echo '</td></tr></table>';
-
-
- $count = $users->get_authorized_users($GO_SECURITY->user_id, $_COOKIE['contact_sort'], $_COOKIE['contact_direction']);
- echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
- echo "<tr>";
- echo '<td class="TableHead2" width="16"><input type="checkbox" value="dummy" name="dummy" onclick="javascript:invert_selection()" /></td>';
- echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?post_action=members&newsort=name&newdirection=".$newdirection."\">".$strName;
- if ($_COOKIE['contact_sort'] == "name")
- echo $image_string;
- echo "</a></td>\n";
- echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?post_action=members&newsort=email&newdirection=".$newdirection."\">".$strEmail;
- if ($_COOKIE['contact_sort'] == "email")
- echo $image_string;
- echo "</a></td>\n";
- echo "<td class=\"TableHead2\"><a class=\"TableHead2\" href=\"".$_SERVER['PHP_SELF']."?post_action=members&newsort=company&newdirection=".$newdirection."\">".$strCompany;
- if ($_COOKIE['contact_sort'] == "company")
- echo $image_string;
- echo "</a></td>\n";
- echo "<td class=\"TableHead2\"> </td>\n";
- echo "</tr>\n";
-
-
- while ($users->next_record())
- {
- $middle_name = $users->f('middle_name') == '' ? '' : $users->f('middle_name').' ';
- $name = $users->f('first_name').' '.$middle_name.$users->f('last_name');
-
- echo "<tr id=\"".$users->f("id")."\" height=\"18\" class=\"Table1\">\n";
- echo "<td width=\"16\"><input type=\"checkbox\" name=\"user[]\" value=\"".$users->f("id")."\" onclick=\"item_click(this)\" /></td>";
- echo "<td>".show_profile($users->f("id"), $name)." </a></td>\n";
- echo "<td>".mail_to(empty_to_stripe($users->f("email")))." </td>\n";
- echo "<td>".empty_to_stripe($users->f("company"))." </td>\n";
- echo "<td><a href=\"contact.php?user_id=".$users->f("id")."\" title=\"".$contacts_add_member."\"><img src=\"".$GO_THEME->images['save']."\" border=\"0\" />";
- echo "</tr>\n";
- echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
- }
-
-
- if($count > 0)
- {
- echo '<tr><td colspan="99" height="18">'.$count.' '.$contacts_members.'</td></tr>';
- echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
- }else
- {
- echo '<tr><td colspan="99" height="18">'.$contacts_no_contacts.'</td></tr>';
- echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
- }
- echo "</table>";
- ?>
- <script language="javascript" type="text/javascript">
- function item_click(check_box)
- {
- var item = get_object(check_box.value);
- if (check_box.checked)
- {
- item.className = 'Table2';
- }else
- {
- item.className = 'Table1';
- }
- }
-
- function invert_selection()
- {
- for (var i=0;i<document.forms[0].elements.length;i++)
- {
- if(document.forms[0].elements[i].type == 'checkbox' && document.forms[0].elements[i].name != 'dummy')
- {
- document.forms[0].elements[i].checked = !(document.forms[0].elements[i].checked);
- item_click(document.forms[0].elements[i]);
- }
- }
- }
-
- </script>