uid == $account->uid && user_access($perm)); } /** * Which permissions can we prompt for? * * @TODO - update this list and/or make it customizable. */ function fb_permission_map($fb) { static $perms; // http://developers.facebook.com/docs/reference/fql/permissions_info $result = fb_fql_query($fb, "SELECT permission_name, header, summary FROM permissions_info WHERE 1"); // FQL, no {curly_brackets} dpm($result, __FUNCTION__); if (!isset($perms)) { foreach ($result as $data) { $perms[$data['permission_name']] = 'Allow %application to ' . $data['summary']; } } return $perms; } /** * Implements hook_fb_required_perms_alter(). * * fb_connect.module can calls this to learn when perms to add to login-button. */ function fb_permission_fb_required_perms_alter(&$perms) { global $_fb, $_fb_app; $fb_app_data = fb_get_app_data($_fb_app); if (isset($fb_app_data['fb_permission'])) { $fb_permission_data = $fb_app_data['fb_permission']; foreach ($fb_permission_data['prompt'] as $key => $value) { if ($value) { $perms[$key] = $key; } } } } /** * Implementation of hook_user. */ function fb_permission_user($op, &$edit, &$account, $category = NULL) { global $user; if ($op == 'categories') { $items = array(); // A tab for each application foreach (fb_get_all_apps() as $fb_app) { // TODO: limit only to apps which can be added to a user's account. $items[] = array( 'name' => $fb_app->label, 'title' => $fb_app->title, 'access callback' => 'fb_permission_access_own', 'access arguments' => array(1, 'edit own extended permissions'), 'weight' => 2); } return $items; } elseif ($op == 'form') { // See if the category corresponds to a facebook app. $fb_app = fb_get_app(array('label' => $category)); if ($fb_app) { $fb = fb_api_init($fb_app); $map = fb_permission_map($fb); // All known permissions. // Show only permissions we've configured for this app. $fb_app_data = fb_get_app_data($fb_app); $fb_permission_data = $fb_app_data['fb_permission']; if (is_array($fb_permission_data['map'])) { foreach ($fb_permission_data['map'] as $key => $value) { if (!$value) unset($map[$key]); } } /* Should not be necessary to wrap in serverfbml, as prompt-permission is documented as XFBML. $form = array( 'perms' => array( '#prefix' => '