function vkxp_admin_main_settings in VK CrossPoster 6
Same name and namespace in other branches
- 6.3 vkxp.admin.inc \vkxp_admin_main_settings()
- 6.2 vkxp.admin.inc \vkxp_admin_main_settings()
- 7.2 vkxp.admin.inc \vkxp_admin_main_settings()
- 7 vkxp.admin.inc \vkxp_admin_main_settings()
Page callback Return form with main settings
1 string reference to 'vkxp_admin_main_settings'
- vkxp_menu in ./
vkxp.module - Implementation of hook_menu()
File
- ./
vkxp.admin.inc, line 12 - Contains vkxp settings forms
Code
function vkxp_admin_main_settings() {
// Process request from vk
if ($_GET['code']) {
$params = array();
$params['client_id'] = trim(variable_get('vkxp_app_id', 0));
$params['client_secret'] = trim(variable_get('vkxp_app_secret', 0));
$params['code'] = $_GET['code'];
$result = vkxp_query('', $params, 'https://api.vkontakte.ru/oauth/access_token');
if ($result['access_token']) {
variable_set('vkxp_access_token', $result['access_token']);
_vkxp_watchdog(array(
'text' => t('Access token was recieved from vkontakte. Now you may post your nodes there.'),
'severity' => 'status',
));
}
else {
_vkxp_watchdog(array(
'text' => t('Access token was not recieved from vkontakte. Error: !error (!error_description)', array(
'!error' => $result['error'],
'!error_description' => $result['error_description'],
)),
'severity' => 'error',
));
}
}
elseif ($_GET['error']) {
_vkxp_watchdog(array(
'text' => t('Access code was not recieved from vkontakte. Error: !error (!error_description)', array(
'!error' => $_GET['error'],
'!error_description' => $_GET['error_description'],
)),
'severity' => 'error',
));
}
$form = array();
$form['vkxp_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Enable VKontakte crossposter'),
'#default_value' => variable_get('vkxp_enable', 0),
);
$form['vkxp_main'] = array(
'#type' => 'fieldset',
'#title' => t('Main settings'),
);
$form['vkxp_main']['vkxp_group_id'] = array(
'#type' => 'textfield',
'#title' => t('Owner ID'),
'#required' => true,
'#default_value' => variable_get('vkxp_group_id', ''),
);
$form['vkxp_main']['vkxp_wall_owner'] = array(
'#type' => 'select',
'#title' => t('Select owner type'),
'#options' => array(
'group' => t('Group'),
'user' => t('User'),
),
'#default_value' => variable_get('vkxp_wall_owner', 'group'),
);
$form['vkxp_main']['vkxp_app_id'] = array(
'#type' => 'textfield',
'#title' => t('Application ID'),
'#required' => true,
'#default_value' => variable_get('vkxp_app_id', ''),
);
$form['vkxp_main']['vkxp_app_secret'] = array(
'#type' => 'textfield',
'#title' => t('Application secret code'),
'#required' => true,
'#default_value' => variable_get('vkxp_app_secret', ''),
);
$form['vkxp_main']['vkxp_enabled_default'] = array(
'#type' => 'checkbox',
'#title' => t('Checkbox "Post this node to vkontakte.ru" are checked by default'),
'#default_value' => variable_get('vkxp_enabled_default', 0),
'#description' => t('Check this if you want checkbox "Post this node to vkontakte.ru" in node form was checked by default'),
);
$form['vkxp_main']['vkxp_official'] = array(
'#type' => 'checkbox',
'#title' => t('Write from group name'),
'#default_value' => variable_get('vkxp_official', 1),
'#description' => t('Check this if you want to post messages from group name'),
);
$form['vkxp_main']['vkxp_add_link'] = array(
'#type' => 'checkbox',
'#title' => t('Add link on wall to posted page'),
'#default_value' => variable_get('vkxp_add_link', 0),
'#description' => t('Check this if you want to post node url on vk wall'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
);
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Recieve new access token'),
);
return $form;
}