function vkxp_admin_main_settings_submit in VK CrossPoster 7
Same name and namespace in other branches
- 6 vkxp.admin.inc \vkxp_admin_main_settings_submit()
- 6.2 vkxp.admin.inc \vkxp_admin_main_settings_submit()
Submit callback for vkxp main settings form.
File
- ./
vkxp.admin.inc, line 115 - Contains vkxp settings forms.
Code
function vkxp_admin_main_settings_submit($form, &$form_state) {
$values =& $form_state['values'];
// Trim values just in case.
$values['vkxp_app_id'] = trim($values['vkxp_app_id']);
$values['vkxp_app_secret'] = trim($values['vkxp_app_secret']);
// If application ID or application secret key was changed we should get new access token.
$app_id_changed = variable_get('vkxp_app_id', 0) != $values['vkxp_app_id'];
$secret_changed = variable_get('vkxp_app_secret', 0) != $values['vkxp_app_secret'];
$reset_clicked = $values['op'] == $values['reset'];
// Save form state values.
system_settings_form_submit($form, $form_state);
if ($app_id_changed || $secret_changed || $reset_clicked) {
// Build params for http://vk.com to get new access token.
$params = array();
$params['client_id'] = $form_state['values']['vkxp_app_id'];
$params['scope'] = VKXP_AUTHORIZE_SCOPE;
$params['redirect_uri'] = url(VKXP_AUTHORIZE_REDIRECT_URI, array(
'absolute' => TRUE,
));
$params['response_type'] = VKXP_AUTHORIZE_RESPONSE_TYPE;
$params['display'] = VKXP_AUTHORIZE_DISPLAY;
// Redirect user to authorize page.
drupal_goto(VKXP_AUTHORIZE_URI . '?' . drupal_http_build_query($params));
}
}