$siteID = $_GET['siteID']; } else { $siteID = null; } if (isset($_GET['status'])) { $status = $_GET['status']; } else { $status = null; } if ($action == "create") { $id = addContact($id, $sessionID, $userName, $siteID, $status); echo "{ \"id\": " . $id . "}"; return; } else { if ($action == "remove") { $num = removeContact($id); echo "{ \"num\": " . $num . "}"; return; } else { if ($action == "change") { changeContact($id, $sessionID, $userName, $siteID, $status); echo "{ \"message\": \"done\" }"; return; } else { if ($action == "load") { $d = loadContacts(); echo json_encode($d); return; } else { return; }
// restore the original list of sites with permission // OLD CODE: //$sites = $sitePermissions; // return ok message echo json_encode(array("message" => "participant added", "contactID" => $contactID, "ok" => 1)); return; } else { if ($action == "remove") { $contactID = ""; if (isset($_POST['contactID'])) { $contactID = urldecode($_POST['contactID']); } else { echo "Error: no contactID as argument"; return; } $num = removeContact($contactID); echo "{ \"num\": " . $num . "}"; return; } else { if ($action == "read") { $contactID = ""; if (isset($_POST['contactID'])) { $contactID = urldecode($_POST['contactID']); } else { echo json_encode(array("message" => "Error: no contactID argument")); return; } $site = ""; if (isset($_POST['site'])) { $site = urldecode($_POST['site']); $sites = array($site);
getIndivSubInfo($_POST['username'], $authuser, $authpw, $subID); break; case 'getAllSubInfo': getAllSubInfo($_POST['username'], $authuser, $authpw); break; case 'getContacts': getContacts($_POST['username'], $authuser, $authpw); break; case 'getContact': getContact($_POST['username'], $authuser, $authpw, $contactID); break; case 'addEditContact': addEditContact($_POST['username'], $authuser, $authpw, $contactName, $contactID); break; case 'removeContact': removeContact($_POST['username'], $authuser, $authpw, $contactID); break; case 'getContactAttributes': getContactAttributes($_POST['username'], $authuser, $authpw, $contactID); break; case 'getContactAttribute': getContactAttribute($_POST['username'], $authuser, $authpw, $attributeName); break; case 'updateAttribute': updateAttribute($_POST['username'], $authuser, $authpw, $contactName, $contactID); break; case 'deleteAttribute': deleteAttribute($_POST['username'], $authuser, $authpw, $attributeName); break; } }
/** * Displays current user's friend list */ function displayFriendList() { global $h, $db, $config; $userId = $h->session->id; if (!empty($_GET['id']) && is_numeric($_GET['id'])) { $userId = $_GET['id']; } if ($h->session->id != $userId && isset($_GET['addfriend'])) { if ($config['contacts']['friend_requests']) { if (!empty($_POST['type_id'])) { //sends a request to create a contact to user addFriendRequest($userId, $_POST['type_id'], $_POST['msg']); echo 'A request has been sent to the user to create a contact<br/>'; echo 'You will recieve a message when the user responds to the request.<br/><br/>'; return; } echo '<h1>Send friend request</h1>'; echo '<form method="post" action="">'; echo 'So you wish to send a friend request to ' . Users::link($userId) . '?<br/>'; echo 'First, you need to choose relation type: '; echo xhtmlSelectCategory(CATEGORY_CONTACT, 0, 'type_id') . '<br/>'; echo '(Optional) send a message:<br/>'; echo '<textarea name="msg" cols="40" rows="6"></textarea><br/>'; echo '<input type="submit" class="button" value="Send request"/>'; echo '</form>'; return; } else { //directly add contact to own contact list, dont send request setContact(CONTACT_FRIEND, $h->session->id, $userId); } } if ($h->session->id != $userId) { if (isset($_GET['removefriend'])) { removeContact(CONTACT_FRIEND, $userId); } if (hasPendingFriendRequest($userId)) { echo '<div class="item">'; echo 'You already have a pending relation request with this user.<br/><br/>'; echo 'You can remove your pending relation requests by clicking <a href="' . $_SERVER['PHP_SELF'] . '?request_stopwait=' . $userId . '">here</a>.'; echo '</div><br/>'; } else { if (!haveContact(CONTACT_FRIEND, $h->session->id, $userId)) { echo '<a href="?id=' . $userId . '&addfriend">Become friends</a><br/>'; } else { echo '<a href="?id=' . $userId . '&removefriend">Remove friend contact</a><br/>'; } } return; } if ($userId == $h->session->id) { if (!empty($_GET['request_stopwait'])) { removeSentFriendRequest($_GET['request_stopwait']); } if (isset($_GET['request_deny'])) { denyFriendRequest($_GET['request_deny']); } if (isset($_GET['request_accept'])) { acceptFriendRequest($_GET['request_accept']); } $list = getSentFriendRequests(); if (count($list)) { echo 'Your sent friend requests:<br/>'; foreach ($list as $row) { echo '<div class="item">'; echo Users::link($row['recieverId'], $row['recieverName']) . ' - '; echo '<a href="?request_stopwait=' . $row['recieverId'] . '">Remove</a><br/>'; echo '</div><br/>'; } } $list = getRecievedFriendRequests(); if (count($list)) { echo 'Your recieved friend requests:<br/>'; foreach ($list as $row) { echo '<div class="item">'; echo Users::link($row['senderId'], $row['senderName']) . ' wants to be ' . $row['categoryName'] . ' - Do you '; echo '<a href="?request_accept=' . $row['senderId'] . '">Accept</a> or '; echo '<a href="?request_deny=' . $row['senderId'] . '">Deny</a>?<br/>'; if ($row['msg']) { echo 'Personal message: ' . nl2br($row['msg']); } echo '</div><br/>'; } } } $list = getContactsFlat(CONTACT_FRIEND, $userId); if ($h->session->id != $userId) { echo 'Friends:' . Users::getName($userId) . '<br/>'; } else { echo 'Your friend list:<br/>'; } if (!count($list)) { echo 'No friends.'; return; } foreach ($list as $row) { echo '<div class="' . ($row['isOnline'] ? 'friend_online' : 'friend_offline') . '">'; echo Users::link($row['otherUserId'], $row['contactName']); echo '<a href="messages.php?id=' . $row['contactId'] . '"><img src="' . coredev_webroot() . 'gfx/icon_mail.png" alt="Send a message to ' . $row['contactName'] . '"/></a>'; echo '</div>'; } }
function removeUserContact($user, $userContactId) { // check if anyone else is tracking, delete from contacts if no one is $contactId = getContactIdFromUserContactId($userContactId); $trackers = countUsersTrackingContactId($contactId); // remove from user_contacts $query = "delete from user_contacts where id = {$userContactId}"; if (preparedStatement($query) !== true) { return "error deleting from user_contacts"; } if ($trackers < 1) { return removeContact($contactId); } return true; }