You are here

function hybridauth_admin_provider_settings in HybridAuth Social Login 6.2

Same name and namespace in other branches
  1. 7.2 hybridauth.admin.inc \hybridauth_admin_provider_settings()
  2. 7 hybridauth.admin.inc \hybridauth_admin_provider_settings()
1 string reference to 'hybridauth_admin_provider_settings'
hybridauth_menu in ./hybridauth.module
Implements hook_menu().

File

./hybridauth.admin.inc, line 366
Administrative pages forms and functions for the HybridAuth module.

Code

function hybridauth_admin_provider_settings(&$form_state, $provider_id = NULL) {
  $form = array();
  switch ($provider_id) {
    case 'Facebook':
      $help = t('
          <p>Enter your application ID and private key. You can get these by creating a new application at <a href="!apps_uri">!apps_uri</a>.</p>
          <p>You must set <strong>App Domain</strong> to something like <strong>example.com</strong> to cover <strong>*.example.com</strong>.</p>
          <p>You must set <strong>Site URL</strong> to <strong>%site_uri</strong>.</p>
        ', array(
        '!apps_uri' => 'https://developers.facebook.com/apps',
        '%site_uri' => url('<front>', array(
          'absolute' => TRUE,
        )),
      ));
      break;
    case 'Twitter':
      $help = t('
          <p>Enter your consumer key and private key. You can get these by creating a new application at <a href="!apps_uri">!apps_uri</a>.</p>
        ', array(
        '!apps_uri' => 'https://dev.twitter.com/apps',
      ));
      break;
    case 'Google':
      $origin_uri_parts = parse_url(url('<front>', array(
        'absolute' => TRUE,
      )));
      $help = t('
          <p>Enter your application ID and private key. You can get these by creating a new application at <a href="!apps_uri">!apps_uri</a>.</p>
          <p>You must set <strong>Authorized Redirect URIs</strong> to <strong>%redirect_uri</strong>.</p>
          <p>You must set <strong>Authorized JavaScript Origins</strong> to <strong>%origin_uri</strong>.</p>
        ', array(
        '!apps_uri' => 'https://code.google.com/apis/console#access',
        '%redirect_uri' => url('hybridauth/endpoint', array(
          'absolute' => TRUE,
          'query' => array(
            'hauth.done' => 'Google',
          ),
        )),
        '%origin_uri' => $origin_uri_parts['scheme'] . '://' . $origin_uri_parts['host'],
      ));
      break;
    default:
      $help = t('Enter the application ID, consumer key, and/or secret key as required.');
      break;
  }
  $form['keys'] = array(
    '#type' => 'fieldset',
    '#description' => $help,
  );
  $form['keys']['hybridauth_provider_' . $provider_id . '_keys_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Application ID'),
    '#description' => t('The application ID'),
    '#default_value' => variable_get('hybridauth_provider_' . $provider_id . '_keys_id', ''),
  );
  $form['keys']['hybridauth_provider_' . $provider_id . '_keys_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Application consumer key'),
    '#description' => t('The Application consumer key'),
    '#default_value' => variable_get('hybridauth_provider_' . $provider_id . '_keys_key', ''),
  );
  $form['keys']['hybridauth_provider_' . $provider_id . '_keys_secret'] = array(
    '#type' => 'textfield',
    '#title' => t('Application consumer secret'),
    '#description' => t('The application consumer secret key'),
    '#default_value' => variable_get('hybridauth_provider_' . $provider_id . '_keys_secret', ''),
  );
  if (in_array($provider_id, array(
    'LinkedIn',
    'MySpace',
    'Twitter',
    'Yahoo',
  ))) {
    unset($form['keys']['hybridauth_provider_' . $provider_id . '_keys_id']);
  }
  if (in_array($provider_id, array(
    'Facebook',
    'Google',
    'Live',
    'Vkontakte',
  ))) {
    unset($form['keys']['hybridauth_provider_' . $provider_id . '_keys_key']);
  }
  if ($provider_id == 'Facebook') {
    $form['advanced'] = array(
      '#type' => 'fieldset',
      '#title' => 'Advanced settings',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['advanced']['hybridauth_provider_' . $provider_id . '_scope'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Scope'),
      '#default_value' => variable_get('hybridauth_provider_' . $provider_id . '_scope', array(
        'email',
        'user_about_me',
        'user_birthday',
        'user_hometown',
        'user_website',
        'offline_access',
      )),
      '#options' => array(
        // See http://developers.facebook.com/docs/reference/api/permissions/
        // Regular permissions
        'user_about_me' => t('<strong>user_about_me</strong> -- Provides access to the "About Me" section of the profile in the about property'),
        'user_activities' => t('<strong>user_activities</strong> -- Provides access to the user\'s list of activities as the activities connection'),
        'user_birthday' => t('<strong>user_birthday</strong> -- Provides access to the birthday with year as the birthday_date property'),
        'user_checkins' => t('<strong>user_checkins</strong> -- Provides read access to the authorized user\'s check-ins that the user can see.'),
        'user_education_history' => t('<strong>user_education_history</strong> -- Provides access to education history as the education property'),
        'user_events' => t('<strong>user_events</strong> -- Provides access to the list of events the user is attending as the events connection'),
        'user_groups' => t('<strong>user_groups</strong> -- Provides access to the list of groups the user is a member of as the groups connection'),
        'user_hometown' => t('<strong>user_hometown</strong> -- Provides access to the user\'s hometown in the hometown property'),
        'user_interests' => t('<strong>user_interests</strong> -- Provides access to the user\'s list of interests as the interests connection'),
        'user_likes' => t('<strong>user_likes</strong> -- Provides access to the list of all of the pages the user has liked as the likes connection'),
        'user_location' => t('<strong>user_location</strong> -- Provides access to the user\'s current location as the location property'),
        'user_notes' => t('<strong>user_notes</strong> -- Provides access to the user\'s notes as the notes connection'),
        'user_online_presence' => t('<strong>user_online_presence</strong> -- Provides access to the user\'s online/offline presence'),
        'user_photos' => t('<strong>user_photos</strong> -- Provides access to the photos the user has uploaded, and photos the user has been tagged in'),
        'user_questions' => t('<strong>user_questions</strong> -- Provides access to the questions the user or friend has asked'),
        'user_relationships' => t('<strong>user_relationships</strong> -- Provides access to the user\'s family and personal relationships and relationship status'),
        'user_relationship_details' => t('<strong>user_relationship_details</strong> -- Provides access to the user\'s relationship preferences'),
        'user_religion_politics' => t('<strong>user_religion_politics</strong> -- Provides access to the user\'s religious and political affiliations'),
        'user_status' => t('<strong>user_status</strong> -- Provides access to the user\'s most recent status message'),
        'user_videos' => t('<strong>user_videos</strong> -- Provides access to the videos the user has uploaded, and videos the user has been tagged in'),
        'user_website' => t('<strong>user_website</strong> -- Provides access to the user\'s web site URL'),
        'user_work_history' => t('<strong>user_work_history</strong> -- Provides access to work history as the work property'),
        'email' => t('<strong>email</strong> -- Provides access to the user\'s primary email address in the email property. Do not spam users. Your use of email must comply both with Facebook policies and with the CAN-SPAM Act.'),
        // Extended permissions
        'read_friendlists' => t('<strong>read_friendlists</strong> -- Provides access to any friend lists the user created. All user\'s friends are provided as part of basic data, this extended permission grants access to the lists of friends a user has created, and should only be requested if your application utilizes lists of friends.'),
        'read_insights' => t('<strong>read_insights</strong> -- Provides read access to the Insights data for pages, applications, and domains the user owns.'),
        'read_mailbox' => t('<strong>read_mailbox</strong> -- Provides the ability to read from a user\'s Facebook Inbox.'),
        'read_requests' => t('<strong>read_requests</strong> -- Provides read access to the user\'s friend requests'),
        'read_stream' => t('<strong>read_stream</strong> -- Provides access to all the posts in the user\'s News Feed and enables your application to perform searches against the user\'s News Feed'),
        'xmpp_login' => t('<strong>xmpp_login</strong> -- Provides applications that integrate with Facebook Chat the ability to log in users.'),
        'ads_management' => t('<strong>ads_management</strong> -- Provides the ability to manage ads and call the Facebook Ads API on behalf of a user.'),
        'create_event' => t('<strong>create_event</strong> -- Enables your application to create and modify events on the user\'s behalf'),
        'manage_friendlists' => t('<strong>manage_friendlists</strong> -- Enables your app to create and edit the user\'s friend lists.'),
        'manage_notifications' => t('<strong>manage_notifications</strong> -- Enables your app to read notifications and mark them as read. This permission will be required to all access to notifications after October 22, 2011.'),
        'offline_access' => t('<strong>offline_access</strong> -- Enables your app to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.'),
        'publish_checkins' => t('<strong>publish_checkins</strong> -- Enables your app to perform checkins on behalf of the user.'),
        'publish_stream' => t('<strong>publish_stream</strong> -- Enables your app to post content, comments, and likes to a user\'s stream and to the streams of the user\'s friends. With this permission, you can publish content to a user\'s feed at any time, without requiring offline_access. However, please note that Facebook recommends a user-initiated sharing model.'),
        'rsvp_event' => t('<strong>rsvp_event</strong> -- Enables your application to RSVP to events on the user\'s behalf'),
        'sms' => t('<strong>sms</strong> -- Enables your application to send messages to the user and respond to messages from the user via text message'),
        'publish_actions' => t('<strong>publish_actions</strong> -- Enables your application to publish user scores and achievements.'),
      ),
    );
  }
  if ($provider_id == 'Google') {
    $form['advanced'] = array(
      '#type' => 'fieldset',
      '#title' => 'Advanced settings',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['advanced']['hybridauth_provider_' . $provider_id . '_scope'] = array(
      '#type' => 'textfield',
      '#title' => t('Scope'),
      '#default_value' => variable_get('hybridauth_provider_' . $provider_id . '_scope', 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'),
      '#size' => 150,
    );
  }
  return system_settings_form($form);
}