function display_contacts($binding, $disp_fields) { if ($disp_fields) { $contacts = get_all_contacts($binding); } else { $contacts = get_all_contacts_no_fields($binding); } if ($contacts) { echo "<contacts count=\"" . count($contacts) . "\">\n"; foreach ($contacts as $contact) { echo "<contact id=\"" . $contact->id . "\" email=\"" . fix_value($contact->email) . "\" status=\"" . $contact->status . "\" msgPref=\"" . $contact->msgPref . "\" " . "source=\"" . $contact->source . "\" customSource=\"" . $contact->customSource . "\" " . "created=\"" . $contact->created . "\" modified=\"" . $contact->modified . "\">\n"; if (isset($contact->lists)) { $listids = make_array($contact->lists); if ($listids) { echo "<memberships count=\"" . count($listids) . "\">\n"; foreach ($listids as $listid) { echo "<memberof id=\"{$listid}\"/>\n"; } echo "</memberships>\n"; } } if (isset($contact->fields)) { $fields = make_array($contact->fields); echo "<fieldvals count=\"" . count($fields) . "\">\n"; foreach ($fields as $field) { echo "<fieldval id=\"" . $field->fieldId . "\">" . fix_value($field->value) . "</fieldval>\n"; } echo "</fieldvals>\n"; } echo "</contact>\n"; } echo "</contacts>\n"; } }
<?php require 'lib/database.php'; require 'lib/misc.php'; require 'lib/authentication.php'; redirect_if_not_logged_in("login.php"); $contacts = get_all_contacts(); if (isset($_GET['id'])) { $id = $_GET['id']; $event = get_event($_GET['id']); } else { if (isset($_POST['id'])) { if (!isset($_FILES['pdf']) || !file_exists($_FILES['pdf']['tmp_name']) || !is_uploaded_file($_FILES['pdf']['tmp_name'])) { update_event($_POST['id'], stripslashes($_POST['description'])); } else { $info = pathinfo($_FILES['pdf']['name']); $ext = $info['extension']; // get the extension of the file $newname = $_POST['id'] . "." . $ext; $target = 'pdfs/' . $newname; move_uploaded_file($_FILES['pdf']['tmp_name'], $target); update_event($_POST['id'], stripslashes($_POST['description']), $target); } $id = $_POST['id']; $contact_id1 = $_POST['contact_id1']; $contact_id2 = $_POST['contact_id2']; if ($contact_id1 == -1) { $contact_id1 = false; } if ($contact_id2 == -1) { $contact_id2 = false;
function get_listless_contacts($binding) { // I wish I could just use a filter, where "lists" is empty, but that does not work. // So I retrieve all contacts, then eliminate the ones that have no lists. $all_contacts = get_all_contacts($binding); $contacts = array(); foreach ($all_contacts as $contact) { if (!isset($contact->lists)) { $contacts[] = $contact; } } return $contacts; }