\n";
$str .= " \n";
$str .= " Name:
\n";
$str .= " c/o:
\n";
$str .= " Address:
\n";
$str .= " City:
\n";
$str .= " Country:
\n";
$str .= " Phone:
\n";
$str .= " Phone2:
\n";
$str .= " Email:
\n";
$str .= " Email2:
\n";
$str .= " URL:
\n";
$str .= " URL2:
\n";
$ess = "";
if($essential == "on") $ess = " checked";
$str .= " Essential: (show on frontpage)
\n";
$str .= " Notes:
\n";
$str .= "
\n";
$str .= " \n";
$str .= "\n";
return $str;
}
function addressbook()
{
global $UTIL_DIR, $DATA_DIR, $GLOBALS, $gid, $cid, $smileys;
include_once($UTIL_DIR . "/contacts.php");
$str = "";
$name = stripslashes($GLOBALS['name']);
$co = stripslashes($GLOBALS['co']);
$address = stripslashes($GLOBALS['address']);
$city = stripslashes($GLOBALS['city']);
$country = stripslashes($GLOBALS['country']);
$phone = stripslashes($GLOBALS['phone']);
$phone2 = stripslashes($GLOBALS['phone2']);
$email = stripslashes($GLOBALS['email']);
$email2 = stripslashes($GLOBALS['email2']);
$url = stripslashes($GLOBALS['url']);
$url2 = stripslashes($GLOBALS['url2']);
$notes = stripslashes($GLOBALS['notes']);
$contacts = new Contacts($DATA_DIR . "/contacts.xml");
if($GLOBALS['action'] == "addgroup" && $gid) {
$contactgroup = new ContactGroup($gid, $name);
$contacts->add($contactgroup);
$contacts->write();
$gid = 0;
}
elseif($GLOBALS['action'] == "addcontact" && $gid && $cid) {
$contact = new Contact($cid,
$name,
$co,
$address,
$city,
$country,
$phone,
$phone2,
$email,
$email2,
$url,
$url2,
$essential,
$notes);
$contactgroup = $contacts->getContactGroup($gid);
$contactgroup->add($contact);
$contacts->write();
$cid = 0;
}
elseif($GLOBALS['action'] =="editcontact" && $cid) {
$contact = $contacts->getContact($cid);
$str .= form($contact->cid,
"?mode=addressbook&action=updatecontact".$gid,
"Update contact",
$contact->name,
$contact->co,
$contact->address,
$contact->city,
$contact->country,
$contact->phone,
$contact->phone2,
$contact->email,
$contact->email2,
$contact->url,
$contact->url2,
$contact->essential,
$contact->notes);
}
elseif($GLOBALS['action'] == "updatecontact" && $cid) {
$contact = $contacts->getContact($cid);
$contact->name = $name;
$contact->co = $co;
$contact->address = $address;
$contact->city = $city;
$contact->country = $country;
$contact->phone = $phone;
$contact->phone2 = $phone2;
$contact->email = $email;
$contact->email2 = $email2;
$contact->url = $url;
$contact->url2 = $url2;
$contact->essential = $essential;
$contact->notes = $notes;
$contacts->write();
$str .= $contact->show();
}
elseif($cid) {
$contact = $contacts->getContact($cid);
$str .= $contact->show();
}
elseif($gid) {
$contactgroup = $contacts->getContactGroup($gid);
$str .= $contactgroup->show();
$str .= form($contacts->getNextCID(),
"?mode=addressbook&action=addcontact&gid=".$gid,
"Add contact");
} else {
$str .= $contacts->show();
if($current_user->uid == 0) {
$str .= "