Author: Merijn Schering <*****@*****.**>
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.
*/
require "../../Group-Office.php";
$post_action = isset($post_action) ? $post_action : '';
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('addressbook');
require $GO_LANGUAGE->get_language_file('addressbook');
//load contact management class
require $GO_MODULES->path . "classes/addressbook.class.inc";
$ab = new addressbook();
$return_to = isset($_REQUEST['return_to']) && $_REQUEST['return_to'] != '' ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
$link_back = isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '' ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
$addressbook_id = isset($_REQUEST['addressbook_id']) ? $_REQUEST['addressbook_id'] : 0;
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
switch ($task) {
    case 'copy_read_acl':
        if ($addressbook = $ab->get_addressbook($addressbook_id)) {
            if ($ab->get_user_contacts($GO_SECURITY->user_id, $addressbook_id) > 0) {
                while ($ab->next_record()) {
                    $GO_SECURITY->copy_acl($addressbook['acl_read'], $ab->f('acl_read'));
                }
            }
            if ($ab->get_user_companies($GO_SECURITY->user_id, $addressbook_id) > 0) {
                while ($ab->next_record()) {
                    $GO_SECURITY->copy_acl($addressbook['acl_read'], $ab->f('acl_read'));
			<td><?php 
echo empty_to_stripe(text_to_html($profile["homepage"]));
?>
</td>
		</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<br />
		<?php 
$ab_module = $GO_MODULES->get_module('addressbook');
if ($ab_module && ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_write']))) {
    require_once $ab_module['path'] . 'classes/addressbook.class.inc';
    $ab = new addressbook();
    if (!$ab->user_is_contact($GO_SECURITY->user_id, $_REQUEST['id'])) {
        $button = new button($cmdAdd, "document.location='" . $ab_module['url'] . "contact.php?user_id=" . $_REQUEST['id'] . "&return_to=" . urlencode($link_back) . "';");
        echo '&nbsp;&nbsp;';
    }
}
$button = new button($cmdClose, "javascript:document.location='" . $return_to . "'");
?>
		</td>
	</tr>
	</table>
	</td>
</tr>
</table>
<?php 
require $GO_THEME->theme_path . "footer.inc";
  Copyright Intermesh 2003
  Author: Merijn Schering <*****@*****.**>
  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.
*/
require "../../Group-Office.php";
$ab_module = $GO_MODULES->get_module('addressbook');
if (!$ab_module || !($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_write']))) {
    $ab_module = false;
} else {
    require_once $ab_module['path'] . 'classes/addressbook.class.inc';
    $ab = new addressbook();
}
//get the local times
$local_time = get_time();
$year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date("Y", $local_time);
$month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date("m", $local_time);
$day = isset($_REQUEST['day']) ? $_REQUEST['day'] : date("j", $local_time);
$hour = isset($_REQUEST['hour']) ? $_REQUEST['hour'] : date("H", $local_time);
$min = isset($_REQUEST['min']) ? $_REQUEST['min'] : date("i", $local_time);
if ($_SESSION['GO_SESSION']['DST'] > 0 && date('I') > 0) {
    $dst_offset = $_SESSION['GO_SESSION']['DST'];
} else {
    $dst_offset = 0;
}
$timezone_offset = $_SESSION['GO_SESSION']['timezone'] + $dst_offset;
$hours = array("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23");
  Author: Merijn Schering <*****@*****.**>
  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.
*/
require "../../Group-Office.php";
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('addressbook');
require $GO_LANGUAGE->get_language_file('addressbook');
$custom_fields_plugin = $GO_MODULES->get_plugin('custom_fields');
$page_title = $contact_profile;
require $GO_MODULES->class_path . "addressbook.class.inc";
$ab = new addressbook();
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$return_to = isset($_REQUEST['return_to']) && $_REQUEST['return_to'] != '' ? $_REQUEST['return_to'] : null;
$link_back = isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '' ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
$contact_id = isset($_REQUEST['contact_id']) ? $_REQUEST['contact_id'] : '0';
$company_id = isset($_REQUEST['company_id']) ? $_REQUEST['company_id'] : 0;
$addressbook_id = isset($_REQUEST['addressbook_id']) ? $_REQUEST['addressbook_id'] : $ab->get_default_addressbook($GO_SECURITY->user_id);
switch ($task) {
    case 'save':
        $require = 'edit_contact.inc';
        $first_name = smart_addslashes(trim($_POST['first_name']));
        $middle_name = smart_addslashes(trim($_POST['middle_name']));
        $last_name = smart_addslashes(trim($_POST['last_name']));
        $initials = smart_addslashes($_POST["initials"]);
        $title = smart_addslashes($_POST["title"]);
        $birthday = smart_addslashes($_POST["birthday"]);
Author: Merijn Schering <*****@*****.**>
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.
*/
require "../../Group-Office.php";
$post_action = isset($post_action) ? $post_action : '';
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('addressbook');
require $GO_LANGUAGE->get_language_file('addressbook');
//load contact management class
require $GO_MODULES->path . "classes/addressbook.class.inc";
$ab = new addressbook();
$addressbook_id = isset($_REQUEST['addressbook_id']) ? $_REQUEST['addressbook_id'] : 0;
$group_id = isset($_REQUEST['group_id']) ? $_REQUEST['group_id'] : 0;
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$return_to = isset($_REQUEST['return_to']) && $_REQUEST['return_to'] != '' ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
if ($addressbook_id > 0 && ($addressbook = $ab->get_addressbook($addressbook_id))) {
    if (!($write_permission = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $addressbook['acl_write']))) {
        $read_permission = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $addressbook['acl_read']);
    }
}
if (!$write_permission && !$read_permission) {
    header('Location: ' . $GO_CONFIG->host . 'error_docs/403.php');
    exit;
}
if ($task == 'save_group') {
    $name = smart_addslashes(trim($_POST['name']));
option) any later version.
*/
require "../../Group-Office.php";
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('notes');
require $GO_LANGUAGE->get_language_file('notes');
$page_title = $lang_modules['notes'];
require $GO_MODULES->class_path . "notes.class.inc";
$notes = new notes();
//check for the addressbook module
$ab_module = $GO_MODULES->get_module('addressbook');
if (!$ab_module || !($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_write']))) {
    $ab_module = false;
} else {
    require_once $ab_module['class_path'] . 'addressbook.class.inc';
    $ab = new addressbook();
}
$projects_module = $GO_MODULES->get_module('projects');
if ($projects_module) {
    require $projects_module['class_path'] . 'projects.class.inc';
}
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$note_id = isset($_REQUEST['note_id']) ? $_REQUEST['note_id'] : 0;
$return_to = isset($_REQUEST['return_to']) ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
$link_back = isset($_REQUEST['link_back']) ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
switch ($task) {
    case 'save_note':
        $due_date = date_to_unixtime($_POST['due_date']);
        $name = smart_addslashes(trim($_POST['name']));
        if ($note_id > 0) {
            if ($name == '') {
require $GO_CONFIG->class_path . "phpmailer/class.smtp.php";
require $GO_CONFIG->class_path . "html2text.class.inc";
require $GO_MODULES->class_path . "email.class.inc";
$email = new email();
$tp_plugin = $GO_MODULES->get_plugin('templates', 'addressbook');
if ($tp_plugin) {
    require $tp_plugin['class_path'] . 'templates.class.inc';
    $tp = new templates();
}
//check for the addressbook module
$ab_module = $GO_MODULES->get_module('addressbook');
if (!$ab_module || !($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_write']))) {
    $ab_module = false;
} else {
    require_once $ab_module['class_path'] . 'addressbook.class.inc';
    $ab = new addressbook();
}
$html_mail_head = '<html><head><meta content="HPT-OBM ' . $GO_CONFIG->version . '" name="GENERATOR"></head><body>';
$html_mail_foot = '</body></html>';
$_SESSION['num_attach'] = isset($_SESSION['num_attach']) ? $_SESSION['num_attach'] : 0;
$mail_subject = isset($_REQUEST['mail_subject']) ? smartstrip($_REQUEST['mail_subject']) : '';
$mail_body = isset($_REQUEST['mail_body']) ? smartstrip($_REQUEST['mail_body']) : '';
$mail_from = isset($_REQUEST['mail_from']) ? $_REQUEST['mail_from'] : 0;
$mail_to = isset($_REQUEST['mail_to']) ? $_REQUEST['mail_to'] : '';
$mail_cc = isset($_REQUEST['mail_cc']) ? $_REQUEST['mail_cc'] : '';
$mail_bcc = isset($_REQUEST['mail_bcc']) ? $_REQUEST['mail_bcc'] : '';
$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : 0;
$add_recievers = isset($_POST['add_recievers']) ? $_POST['add_recievers'] : '';
$mailing_group_id = isset($_REQUEST['mailing_group_id']) ? $_REQUEST['mailing_group_id'] : 0;
$htmlarea = new htmlarea();
if ($htmlarea->browser_is_supported()) {
/*
Copyright Intermesh 2003
Author: Merijn Schering <*****@*****.**>
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.
*/
require "../../Group-Office.php";
$ab_module = $GO_MODULES->get_module('addressbook');
//TODO: Check if user has access to addressbook.
require $ab_module['class_path'] . "addressbook.class.inc";
$ab = new addressbook();
if (isset($_REQUEST['clicked_contact'])) {
    $contact = $ab->get_contact($_REQUEST['clicked_contact']);
}
unset($_SESSION['GO_HANDLER']);
?>
<html>
<body>
<script language="javascript" type="text/javascript">
	//opener.document.forms[0].contact_id.value = '<?php 
echo $contact['id'];
?>
';
	//opener.document.forms[0].contact_name.value = "<?php 
echo $contact['name'];
?>
$tabtable->print_head();
?>

<table border="0" cellpadding="10">
<tr>
	<td>
	<table border="0" cellpadding="3" cellspacing="0">
	<?php 
if (isset($feedback)) {
    echo '<tr><td colspan="6" height="25">' . $feedback . '</td></tr>';
}
$default_ab = $ab->get_default_addressbook($GO_SECURITY->user_id);
echo '<tr height="30"><td colspan="6"><a href="addressbook.php?return_to=' . urlencode($link_back) . '" class="normal">' . $ab_new_ab . '</a></td></tr>';
echo '<tr><td><h3>' . $ab_default . '</h3></td><td><h3>' . $strName . '</h3></td><td><h3>' . $ab_owner . '</h3></td><td><h3>' . $ab_subscribed . '</h3></td><td>&nbsp;</td><td>&nbsp;</td></tr>';
$ab_count = $ab->get_user_addressbooks($GO_SECURITY->user_id);
$ab1 = new addressbook();
if ($ab_count > 0) {
    while ($ab->next_record()) {
        if ($ab1->is_subscribed($GO_SECURITY->user_id, $ab->f("id"))) {
            $checked = 'checked';
        } else {
            $checked = '';
        }
        $check = $ab->f('id') == $default_ab ? 'checked' : '';
        echo '<tr><td><input type="radio" name="default_addressbook_id" value="' . $ab->f("id") . '" ' . $check . ' /></td>';
        echo '<td nowrap><a href="index.php?post_action=browse&addressbook_id=' . $ab->f("id") . '" class="normal">' . htmlspecialchars($ab->f("name")) . '</a>&nbsp;</td>';
        echo '<td nowrap>' . show_profile($ab->f("user_id")) . '&nbsp;</td>';
        echo '<td align="center">&nbsp;<input type="checkbox" name="subscribed[]" value="' . $ab->f("id") . '" ' . $checked . ' /></td>';
        echo '<td>&nbsp;<a href="addressbook.php?addressbook_id=' . $ab->f("id") . '&return_to=' . urlencode($link_back) . '" title="' . $strEdit . ' \'' . htmlspecialchars($ab->f("name")) . '\'"><img src="' . $GO_THEME->images['edit'] . '" border="0" /></a></td>';
        if ($ab->f('user_id') == $GO_SECURITY->user_id) {
            echo "<td>&nbsp;<a href='javascript:delete_addressbook(\"" . $ab->f("id") . "\",\"" . div_confirm_id($strDeletePrefix . "'" . addslashes($ab->f("name")) . "'" . $strDeleteSuffix) . "\")' title=\"" . $strDeleteItem . " '" . htmlspecialchars($ab->f("name")) . "'\"><img src=\"" . $GO_THEME->images['delete'] . "\" border=\"0\"></a></td>";
 fgets($fp, 4096);
 while (!feof($fp)) {
     $record = fgetcsv($fp, 4096, ',', '"');
     if (is_array($record)) {
         foreach ($record as $i => $j) {
             $record[$i] = $vnconv->vnconv($record[$i]);
         }
     }
     if ($_POST['import_type'] == 'contacts') {
         if (isset($record[$_POST['first_name']]) && $record[$_POST['first_name']] != "" || isset($record[$_POST['last_name']]) && $record[$_POST['last_name']] != '') {
             if ($group_mode == 'file') {
                 $group_name = trim($record[$_POST['group_record']]);
                 if (isset($contact_groups[stripslashes($group_name)])) {
                     $group_id = $contact_groups[$group_name];
                 } else {
                     $ab2 = new addressbook();
                     $group_id = $ab2->add_group($_POST['addressbook_id'], $group_name);
                     $contact_groups[$group_name] = $group_id;
                 }
             }
             $title = isset($record[$_POST['title']]) ? addslashes(trim($record[$_POST['title']])) : '';
             $first_name = isset($record[$_POST['first_name']]) ? addslashes(trim($record[$_POST['first_name']])) : '';
             $middle_name = isset($record[$_POST['middle_name']]) ? addslashes(trim($record[$_POST['middle_name']])) : '';
             $last_name = isset($record[$_POST['last_name']]) ? addslashes(trim($record[$_POST['last_name']])) : '';
             $initials = isset($record[$_POST['initials']]) ? addslashes(trim($record[$_POST['initials']])) : '';
             $sex = isset($record[$_POST['sex']]) ? addslashes(trim($record[$_POST['sex']])) : 'M';
             $birthday = isset($record[$_POST['birthday']]) ? addslashes(trim($record[$_POST['birthday']])) : '';
             $email = isset($record[$_POST['email']]) ? addslashes(trim($record[$_POST['email']])) : '';
             if (preg_match("/(\\b)([\\w\\.\\-]+)(@)([\\w\\.-]+)([A-Za-z]{2,4})\\b/i", $email, $matches)) {
                 $email = $matches[0];
             }
    $company['address'] = isset($_REQUEST['address']) ? smartstrip($_REQUEST['address']) : '';
    $company['zip'] = isset($_REQUEST['zip']) ? smartstrip($_REQUEST['zip']) : '';
    $company['city'] = isset($_REQUEST['city']) ? smartstrip($_REQUEST['city']) : '';
    $company['state'] = isset($_REQUEST['state']) ? smartstrip($_REQUEST['state']) : '';
    $company['email'] = isset($_REQUEST['email']) ? smartstrip($_REQUEST['email']) : '';
    $company['country'] = isset($_REQUEST['country']) ? smartstrip($_REQUEST['country']) : '';
    $company['phone'] = isset($_REQUEST['phone']) ? smartstrip($_REQUEST['phone']) : '';
    $company['fax'] = isset($_REQUEST['fax']) ? smartstrip($_REQUEST['fax']) : '';
    $company['homepage'] = isset($_REQUEST['homepage']) ? smartstrip($_REQUEST['homepage']) : 'http://';
    $company['bank_no'] = isset($_REQUEST['bank_no']) ? smartstrip($_REQUEST['bank_no']) : '';
    $company['vat_no'] = isset($_REQUEST['vat_no']) ? smartstrip($_REQUEST['vat_no']) : '';
    $company['acl_write'] = 0;
}
$addressbook_id = isset($old_subscribed_addressbook_id) && $old_subscribed_addressbook_id > 0 ? $subscribed_addressbook_id : $company['addressbook_id'];
$subscribed_addressbook_id = $addressbook_id;
$cp = new addressbook();
$parent_dropbox = new dropbox();
$company['parent_id'] = 0;
if ($company_id) {
    $cp->get_company($company_id);
    $company['parent_id'] = $cp->f('parent');
}
$count = $cp->get_companies($addressbook_id);
$parent_dropbox->add_value(0, $strNone);
if ($count) {
    while ($cp->next_record()) {
        $id = $cp->f('id');
        if ($id == $company_id) {
            continue;
        }
        $name = $cp->f('name');
/*
Copyright Intermesh 2003
Author: Merijn Schering <*****@*****.**>
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.
*/
require "../../Group-Office.php";
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('addressbook');
require $GO_MODULES->class_path . "addressbook.class.inc";
$ab = new addressbook();
if (isset($_REQUEST['company_id']) && $_REQUEST['company_id'] > 0) {
    if (isset($_REQUEST['clicked_value']) && $_REQUEST['clicked_value'] != '') {
        $contacts[] = $_REQUEST['clicked_value'];
    } else {
        $contacts = isset($_REQUEST['contacts']) ? $_REQUEST['contacts'] : array();
    }
    if (isset($contacts)) {
        for ($i = 0; $i < sizeof($contacts); $i++) {
            $contact = $ab->get_contact($contacts[$i]);
            if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $contact['acl_write'])) {
                $ab->add_contact_to_company($contacts[$i], $_REQUEST['company_id']);
            }
        }
    }
}
require $GO_LANGUAGE->get_language_file('addressbook');
$GO_FIELD = isset($_REQUEST['GO_FIELD']) ? $_REQUEST['GO_FIELD'] : '';
$GO_HANDLER = isset($_REQUEST['GO_HANDLER']) ? $_REQUEST['GO_HANDLER'] : '';
$post_action = isset($_REQUEST['post_action']) ? $_REQUEST['post_action'] : 'search';
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
$pass_value = isset($_REQUEST['pass_value']) ? $_REQUEST['pass_value'] : 'email';
$multiselect = isset($_REQUEST['multiselect']) && $_REQUEST['multiselect'] == 'true' ? true : false;
$require_email_address = isset($_REQUEST['require_email_address']) && $_REQUEST['require_email_address'] == 'true' ? true : false;
$show_users = isset($_REQUEST['show_users']) && $_REQUEST['show_users'] == 'true' ? true : false;
$show_contacts = isset($_REQUEST['show_contacts']) && $_REQUEST['show_contacts'] == 'true' ? true : false;
$show_companies = isset($_REQUEST['show_companies']) && $_REQUEST['show_companies'] == 'true' ? true : false;
if ($show_contacts || $show_companies) {
    $GO_MODULES->authenticate('addressbook');
    require_once $ab_module['class_path'] . 'addressbook.class.inc';
    $ab1 = new addressbook();
    $ab2 = new addressbook();
    $custom_fields_plugin = $GO_MODULES->get_plugin('custom_fields');
    $ab_settings = $ab1->get_settings($GO_SECURITY->user_id);
    $search_type = $ab_settings['search_type'];
} else {
    $search_type = 'users';
}
$page_title = $contacts_select;
require $GO_THEME->theme_path . "header.inc";
?>
<script type="text/javascript" language="javascript">
var nav4 = window.Event ? true : false;
function processkeypress(e)
{
	if(nav4)
    {
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.
*/
require "../../Group-Office.php";
require "constants.php";
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('addressbook');
require $GO_LANGUAGE->get_language_file('addressbook');
$link_back = isset($_REQUEST['link_back']) && $_REQUEST['link_back'] != '' ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
$post_action = isset($_REQUEST['post_action']) ? $_REQUEST['post_action'] : '';
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
//load contact management class
require $GO_MODULES->path . "classes/addressbook.class.inc";
$ab = new addressbook();
$ab_settings = $ab->get_settings($GO_SECURITY->user_id);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    switch ($post_action) {
        case 'delete_addressbook':
            $delete_ab = $ab->get_addressbook($_POST['delete_addressbook_id']);
            if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $delete_ab['acl_write'])) {
                $default_id = $ab->get_default_addressbook($GO_SECURITY->user_id);
                if ($ab->delete_addressbook($_POST['delete_addressbook_id'])) {
                    $GO_SECURITY->delete_acl($delete_ab['acl_write']);
                    $GO_SECURITY->delete_acl($delete_ab['acl_read']);
                }
                $ab->get_subscribed_addressbooks($GO_SECURITY->user_id);
                if ($ab->next_record()) {
                    $next_id = $ab->f('id');
                    if ($_POST['delete_addressbook_id'] == $default_id) {