} $message = "Sent a cat fact to " . count($credentials) . " users."; } break; case 'insertSubscription': $message = subscribe_to_notifications($mirror_service, $_POST['subscriptionId'], $_SESSION['userid'], $base_url . "/notify.php"); break; case 'deleteSubscription': $message = $mirror_service->subscriptions->delete($_POST['subscriptionId']); break; case 'insertContact': insert_contact($mirror_service, $_POST['id'], $_POST['name'], $base_url . "/static/images/chipotle-tube-640x360.jpg"); $message = "Contact inserted. Enable it on MyGlass."; break; case 'deleteContact': delete_contact($mirror_service, $_POST['id']); $message = "Contact deleted."; break; case 'deleteTimelineItem': delete_timeline_item($mirror_service, $_POST['itemId']); $message = "A timeline item has been deleted."; break; } //Load cool stuff to show them. $timeline = $mirror_service->timeline->listTimeline(array('maxResults' => '3')); try { $contact = $mirror_service->contacts->get("php-quick-start"); } catch (Exception $e) { // no contact found. Meh $contact = null; }
<?php session_start(); require_once "../file-includes.php"; $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $contact_id = fix_string($request->contactID); $userID = (int) get_userID_session(); delete_contact($contact_id, $userID);
if (!$login_result) { echo "Error: Account id=" . $acct->id . " [" . $acct->name . "] is not a valid subaccount.\n"; } else { $orphan_count = 0; $matched_count = 0; $deleted_count = 0; $binding = $login_result['binding']; $contacts = get_listless_contacts($binding); foreach ($contacts as $contact) { $email = strtolower($contact->email); echo "ORPHAN: {$email} [id={$contact->id}]\n"; $orphan_count++; if (in_array($email, $addrs)) { echo "MATCHED: {$email} [id={$contact->id}]\n"; $matched_count++; if (!$dry_run) { if (delete_contact($binding, $contact->id)) { echo "DELETED: {$email} [id={$contact->id}]\n"; $deleted_count++; } else { echo "Error: Unable to delete {$email} [id={$contact->id}]\n"; } } } else { echo "IGNORED: {$email} [id={$contact->id}]\n"; } } echo "Finished account: {$acct->name} [id={$acct->id}]\n"; echo "Stats for account {$acct->name}: orphaned={$orphan_count}, matched={$matched_count}, deleted={$deleted_count}\n"; } }
function update_contacts_request($type_person, $id_of_person) { // This will be useful later, to check mandatory/optional contacts $all_contact_kwg = get_kwg_all('contact'); // // Update existing contacts // if (isset($_REQUEST['contact_value'])) { $contacts = $_REQUEST['contact_value']; $c_ids = $_REQUEST['contact_id']; $c_types = $_REQUEST['contact_type']; // // Check if the contacts provided are really attached to the person // or else the user can provide a form with false contacts. // $all_contacts = get_contacts($type_person, $id_of_person); for ($cpt = 0; isset($c_ids[$cpt]) && $c_ids[$cpt]; $cpt++) { $valid = false; foreach ($all_contacts as $c) { if ($c['id_contact'] == $c_ids[$cpt]) { $valid = true; } } if (!$valid) { lcm_panic("Invalid modification of existing contact detected."); } } for ($cpt = 0; isset($c_ids[$cpt]); $cpt++) { // Check first to see if the contact is mandatory $kwg = get_kwg_from_id($c_types[$cpt]); $delete_allowed = true; if ($kwg['policy'] == 'mandatory') { // XXX Having policy == 'mandatory' but quantity = many // really makes a mess, and is not handled. $delete_allowed = false; } if (_request('del_contact_' . $c_ids[$cpt])) { if ($delete_allowed) { lcm_debug("Contact DEL: {$type_person}, {$id_of_person}, " . $c_ids[$cpt], 1); delete_contact($c_ids[$cpt]); } else { $_SESSION['errors']['upd_contact_' . $cpt] = _T('warning_field_mandatory'); } } else { if (!$delete_allowed && !$contacts[$cpt]) { $_SESSION['errors']['upd_contact_' . $cpt] = _T('warning_field_mandatory'); } else { lcm_debug("Contact UPD: {$type_person}, {$id_of_person}, " . $c_ids[$cpt] . ' = ' . $contacts[$cpt], 1); $err = update_contact($c_ids[$cpt], $contacts[$cpt]); if ($err) { $_SESSION['errors']['upd_contact_' . $cpt] = $err; } } } } } // // New contacts // if (isset($_REQUEST['new_contact_value'])) { $cpt = 0; $new_contacts = $_REQUEST['new_contact_value']; $c_type_names = $_REQUEST['new_contact_type_name']; while (isset($new_contacts[$cpt])) { // Process only new contacts which have a value if ($new_contacts[$cpt]) { // And make sure that they have a "type of contact" if ($c_type_names[$cpt]) { lcm_debug("Contact NEW: {$type_person}, {$id_of_person}, Name = " . $c_type_names[$cpt] . ', ' . $new_contacts[$cpt], 1); $err = add_contact($type_person, $id_of_person, $c_type_names[$cpt], $new_contacts[$cpt]); if ($err) { $_SESSION['errors']['new_contact_' . $cpt] = $err; } } else { $_SESSION['errors']['new_contact_' . $cpt] = "Please specify the type of contact."; // TRAD } } $cpt++; } } // // Check if all mandatory contacts were provided // $all_contacts = get_contacts($type_person, $id_of_person); foreach ($all_contact_kwg as $c) { if ($c['policy'] == 'mandatory') { $found = false; foreach ($all_contacts as $a) { if ($a['name'] == $c['name'] && trim($a['value'])) { $found = true; } } if (!$found) { $_SESSION['errors']['contact_' . $c['name']] = _Ti($c['title']) . _T('warning_field_mandatory'); } } } }
if ($compname != "\"\"") { if (delete_company($db, $compname) == 1) { $state = "Access Denied. May not delete \"No Company\" company name."; } else { $state = "Company {$compname} deleted. - "; deletecompanycontacts($db, $compname); $state .= "All {$compname} contacts deleted."; } } else { $state = "No company chosen to be deleted - ignored"; } } if (isset($_POST['DeleteContactSubmit'])) { $contactname = "\"" . $_SESSION['contactname'] . "\""; if ($contactname != "\"\"") { if (delete_contact($db, $contactname) == 1) { $state = "Access Denied. May not delete \"No Contact\" contact name."; } else { $state = "{$contactname} deleted."; } } else { $state = "No contact chosen to be deleted - ignored"; } } if (isset($_POST['SearchIt'])) { $mainSearchKey = $_POST['SearchTerm']; } if (isset($_POST['SearchContact'])) { $contactSearchKey = $_POST['ContactSearchTerm']; } $_SESSION['compname'] = "";
print_editcontact_page(); break; case "editsave": update_contact(); header("Location: ./index.php?kat=addressbook&id=view"); break; case "addcontact": echo '<h2>Kontakty - dodaj nowy kontakt</h2>'; print_addcontact_page(); break; case "addcontactsave": add_contact(); header("Location: ./index.php?kat=addressbook&id=view"); break; case "delcontact": delete_contact(); header("Location: ./index.php?kat=addressbook&id=view"); break; } break; case "mytasks": echo '<h2>Historia zadań</h2>'; print_mytasks_page(); break; case "users": if ($_SESSION['access_level'] == 100) { switch ($id) { case "view": echo '<h2>Podgląd użytkowników</h2>'; print_users_view(); break;
$action = $_GET["action"]; $method = $_SERVER["REQUEST_METHOD"]; switch ($action) { case "list": contacts::listContacts(); break; case "add": if ($method === "GET") { contacts::displayAddContactForm(); } elseif ($method === "POST") { contacts::handleAddContact(); } break; case "delete": $id = $_GET["id"]; delete_contact($id); header("Location: /contacts.php?action=list"); break; case "edit": $id = $_GET["id"]; if ($method === "GET") { contacts::displayEditContactForm($id); } elseif ($method === "POST") { contacts::handleEditContact($id); } break; case "view": $id = $_GET["id"]; contacts::viewContact($id); break; }