add($contactgroup);
$contacts->write();
$gid = 0;
}
elseif($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($action =="editcontact" && $cid) {
$contact = $contacts->getContact($cid);
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($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();
$contact->show();
}
elseif($cid) {
$contact = $contacts->getContact($cid);
$contact->show();
}
elseif($gid) {
$contactgroup = $contacts->getContactGroup($gid);
$contactgroup->show();
form($contacts->getNextCID(),
"?mode=addressbook&action=addcontact&gid=".$gid,
"Add contact");
} else {
$contacts->show();
if($current_user->uid == 0) {
?>