function fb_friend_request_accept_page in Drupal for Facebook 6.3
Same name and namespace in other branches
- 7.3 contrib/fb_friend.module \fb_friend_request_accept_page()
1 string reference to 'fb_friend_request_accept_page'
- fb_friend_menu in contrib/
fb_friend.module
File
- contrib/
fb_friend.module, line 80 - This module implements several features specific to Facebook friend networks.
Code
function fb_friend_request_accept_page() {
// Parse args
$params = array();
$i = FB_FRIEND_PATH_REQUEST_SUBMIT_ARGS;
while (($key = arg($i)) && ($value = arg($i + 1))) {
$params[$key] = $value;
$i += 2;
}
if ($fbu = fb_facebook_user()) {
// Confirm invitation is in the fb_friend table.
$where = array(
'fbf.status > %d',
'fbf.fbu_target = %d',
);
$args = array(
0,
$fbu,
);
foreach (array(
'ref_id' => '%s',
'module' => "'%s'",
) as $key => $pattern) {
if (isset($params[$key])) {
$where[] = "fbf.{$key} = {$pattern}";
$args[] = $params[$key];
}
}
$result = db_query("SELECT * FROM {fb_friend} AS fbf WHERE " . implode(' AND ', $where), $args);
$rows = array();
while ($row = db_fetch_array($result)) {
// Update fb_friend.status to indicate accepted.
$row['status'] = FB_FRIEND_STATUS_REQUEST_ACCEPTED;
if (fb_friend_write_record($row, 'fb_friend_id')) {
$rows[] = $row;
}
}
$params['fb_friend'] = $rows;
}
// Notify third parties
$redirect = fb_invoke(FB_FRIEND_OP_REQUEST_ACCEPT, $params, NULL, 'fb_friend');
if ($redirect) {
if (FALSE && function_exists('fb_canvas_goto')) {
fb_canvas_goto($redirect);
}
else {
drupal_goto($redirect);
}
}
return "fb_friend_request_accept_page";
}