public function SocialContentLinkedin::globalSettingsForm in Social Content 7.2
The shared global settings form for all Linkedin instances.
Return value
array Global settings form.
Overrides SocialContent::globalSettingsForm
File
- modules/
linkedin/ social_content_linkedin.class.inc, line 66 - Social Content Linkedin class.
Class
- SocialContentLinkedin
- @file Social Content Linkedin class.
Code
public function globalSettingsForm() {
$settings = $this->settings['global'];
$token_generator_link = '';
if (!empty($settings['client_id'])) {
$token_generator_link = t('!token_link. You will need to add %site_url as an Authorized Redirect URL in your Linkedin app settings.', array(
'!token_link' => l(t('Click here to generate an Access Token'), $this
->getAccessTokenUrl()),
'%site_url' => url(current_path(), array(
'absolute' => TRUE,
)),
));
}
// Make the token request if it comes from Linkedin.
if (isset($_GET['code']) && empty($_POST['form_token'])) {
$access_token = $this
->getAccessToken($settings, $_GET['code']);
if ($access_token) {
drupal_set_message(t('Use %access_token as the Access Token.', array(
'%access_token' => $access_token,
)));
drupal_goto(url(current_path(), array(
'absolute' => TRUE,
)));
}
}
$form = parent::globalSettingsForm();
$form['description'] = array(
'#markup' => '<p>' . t('See !doc_url.', array(
'!doc_url' => l('linkedin.com/secure/developer', 'https://www.linkedin.com/secure/developer'),
)) . '</p>',
);
$form['access_token'] = array(
'#type' => 'textfield',
'#title' => t('Access Token'),
'#default_value' => isset($settings['access_token']) ? $settings['access_token'] : NULL,
'#description' => $token_generator_link ? $token_generator_link : t('To generate an Access Token, save this form first.'),
'#maxlength' => 2000,
);
$form['api_url'] = array(
'#type' => 'textfield',
'#title' => t('API URL'),
'#description' => t('Do not include trailing slash. Default is !url', array(
'!url' => 'https://api.linkedin.com',
)),
'#default_value' => isset($settings['api_url']) ? $settings['api_url'] : 'https://api.linkedin.com',
'#required' => TRUE,
);
$form['api_version'] = array(
'#type' => 'textfield',
'#title' => t('API version'),
'#description' => t("i.e. 'v1'."),
'#default_value' => isset($settings['api_version']) ? $settings['api_version'] : 'v1',
'#required' => TRUE,
);
$form['update_url'] = array(
'#type' => 'textfield',
'#title' => t('Update URL'),
'#description' => t('The base URL to a status update. Default is !url', array(
'!url' => 'https://www.linkedin.com/feed/update/urn:li:activity:',
)),
'#default_value' => isset($settings['update_url']) ? $settings['update_url'] : 'https://www.linkedin.com/feed/update/urn:li:activity:',
'#required' => TRUE,
);
$form['oauth_url'] = array(
'#type' => 'textfield',
'#title' => t('OAuth 2 URL'),
'#description' => t('Do not include trailing slash. Default is !url', array(
'!url' => 'https://www.linkedin.com/uas/oauth2',
)),
'#default_value' => isset($settings['oauth_url']) ? $settings['oauth_url'] : 'https://www.linkedin.com/uas/oauth2',
'#required' => TRUE,
);
$form['client_id'] = array(
'#type' => 'textfield',
'#title' => t('Client ID'),
'#default_value' => isset($settings['client_id']) ? $settings['client_id'] : NULL,
'#required' => TRUE,
);
$form['client_secret'] = array(
'#type' => 'textfield',
'#title' => t('Client secret'),
'#default_value' => isset($settings['client_secret']) ? $settings['client_secret'] : NULL,
'#required' => TRUE,
);
return $form;
}