You are here

function fb_permission_form_alter in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 contrib/fb_permission.module \fb_permission_form_alter()
  2. 7.3 contrib/fb_permission.module \fb_permission_form_alter()

File

contrib/fb_permission.module, line 147
Code pertaining to Facebook's extended permissions. see http://wiki.developers.facebook.com/index.php/Extended_permissions

Code

function fb_permission_form_alter(&$form, $state, $id) {

  //dpm(func_get_args(), 'fb_permission_form_alter');
  if ($id == 'user_profile_form' && isset($form['_fb_permission'])) {
    unset($form['submit']);
    unset($form['delete']);
  }

  // Add settings to fb_app form
  if (isset($form['fb_app_data'])) {
    $fb_app = $form['#fb_app'];
    $fb_app_data = fb_get_app_data($fb_app);
    $fb_permission_data = $fb_app_data['fb_permission'];
    $form['fb_app_data']['fb_permission'] = array(
      '#type' => 'fieldset',
      '#title' => t('Facebook Extended Permissions'),
      '#tree' => TRUE,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    foreach (fb_permission_map() as $key => $desc) {
      $options[$key] = $key;
    }

    // defaults
    if (!isset($fb_permission_data['map'])) {
      $fb_permission_data['map'] = array();
    }
    $form['fb_app_data']['fb_permission']['map'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Extended Permissions'),
      '#options' => $options,
      '#default_value' => $fb_permission_data['map'],
      '#description' => t('Which extended permissions does this application use?  Users will be able to grant these permissions on their user edit pages.'),
    );
    if (!isset($fb_permission_data['prompt'])) {
      $fb_permission_data['prompt'] = array();
    }
    $form['fb_app_data']['fb_permission']['prompt'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Prompt New Users for Permission'),
      '#options' => $options,
      '#default_value' => $fb_permission_data['prompt'],
      '#description' => t('Prompt users when they first authorize the application.  Select only the most important features.'),
    );
  }
}