if ($counter > 10) { break; } //double encode the value because the .submit() function will decode the first level. echo '<a href="javascript:void(0);" onclick="document.getElementById(\'search_friends\').value=\'' . htmlentities_utf8(printSocialNameForConnection($member_id, true)) . '\'; document.getElementById(\'search_friends_form\').submit();">' . printSocialNameForConnection($member_id, false) . '</a><br/>'; $counter++; } echo '</div>'; } exit; } //safe guard if (isset($_GET['id'])) { $id = intval($_GET['id']); if ($id > 0) { addFriendRequest($id); $msg->addFeedback('REQUEST_FRIEND_ADDED'); $sql_notify = "SELECT first_name, last_name, email FROM %smembers WHERE member_id=%d"; $row_notify = queryDB($sql_notify, array(TABLE_PREFIX, $id), TRUE); if ($row_notify['email'] != '') { require AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php'; $body = _AT('notification_new_contact', get_display_name($_SESSION['member_id']), $_base_href . AT_SOCIAL_BASENAME . 'index.php'); $sender = get_display_name($_SESSION['member_id']); $mail = new ATutorMailer(); $mail->AddAddress($row_notify['email'], $sender); $mail->FromName = $_config['site_name']; $mail->From = $_config['contact_email']; $mail->Subject = _AT('contact_request'); $mail->Body = $body; if (!$mail->Send()) { $msg->addError('SENDING_ERROR');
$_SESSION['config']->CURRENTUSER->login($_REQUEST['User'], $_REQUEST['Pw']); $userId = $_SESSION['config']->CURRENTUSER->USERID; switch ($command) { case "updateGpsKoords": if (strlen($_REQUEST['long']) > 0 && strlen($_REQUEST['lat']) > 0) { updateGpsKoords($userId, $_REQUEST['long'], $_REQUEST['lat']); } else { echo "Koordinaten müssen angegeben werden."; } break; case "getFriendKoords": echo getFriendKoords($userId); break; case "addFriendRequest": if (strlen($_REQUEST['addFriendId']) > 0) { addFriendRequest($userId, $_REQUEST['addFriendId']); } else { echo "Freund muss angegeben werden."; } break; case "getFriendSearchResult": if (strlen($_REQUEST['friendNameSearch']) > 0 || strlen($_REQUEST['friendOrtSearch']) > 0 || strlen($_REQUEST['friendMailSearch']) > 0) { echo getFriendSearchResultXml($userId, $_REQUEST['friendMailSearch'], $_REQUEST['friendNameSearch'], $_REQUEST['friendOrtSearch']); } else { echo "Gesuchte Email, Name oder Ort müssen angegeben werden."; } break; case "getFriendlist": echo getFriendlistXml($userId); break; case "getUnacceptedFriendlist":
/** * 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>'; } }
$getInsertFieldValue['friend_one'] = $userId; $getInsertFieldValue['friend_two'] = $friendId; $getInsertFieldValue['created_date_f'] = $createdDate; $lastInserted_friend_id = $rm->insert_record($getInsertFieldValue, 'friends_t'); if (!empty($lastInserted_friend_id)) { $deviceId = $rm->idToValue('device_id_f', 'user_details_t', 'user_id', $friendId); //getting deviceId if ($deviceId) { $message = "You have received a friend request in petbesties."; $rm->sendPushNotification($deviceId, $message); } $result = $rm->friendRequestSuccess(); return $result; } else { $result = $rm->friendRequestFail(); return $result; } } } // end of else first } else { $result = $rm->ssl_error(); return $result; } } else { $result = $rm->ssl_error(); return $result; } } echo addFriendRequest();