function cpn_settings_submit in Code per Node 7
Same name and namespace in other branches
- 6 cpn.admin.inc \cpn_settings_submit()
Settings form - submit callback.
1 string reference to 'cpn_settings_submit'
- cpn_settings in ./
cpn.admin.inc - Settings form.
File
- ./
cpn.admin.inc, line 260 - Manage the CPN settings page.
Code
function cpn_settings_submit($form, &$form_state) {
// Trim slashes from the path.
$form_state['values']['cpn_path'] = trim($form_state['values']['cpn_path'], '/');
// If the path changed, notify that the folder must be moved.
$old_path = variable_get('cpn_path', 'public://cpn');
if ($form_state['values']['cpn_path'] != $old_path and file_exists(drupal_realpath($old_path))) {
$base_path = variable_get('file_' . file_default_scheme() . '_path', conf_path() . '/files') . '/';
drupal_set_message(t('The file storage path has changed; thus, the contents of %old_path must manually be moved to %new_path.', array(
'%old_path' => $base_path . file_uri_target($old_path),
'%new_path' => $base_path . file_uri_target($form_state['values']['cpn_path']),
)), 'warning', FALSE);
}
// Save the global files.
foreach (array(
'css',
'js',
) as $type) {
// Remove the existing file, if present.
cpn_delete_file('global.' . $type);
// If data was submitted, export it.
if (!empty($form_state['values']['cpn_global_' . $type . '_agree']) && !empty($form_state['values']['cpn_global_' . $type])) {
if (!empty($form_state['values']['cpn_global_' . $type])) {
cpn_save_file($form_state['values']['cpn_global_' . $type], 'global.' . $type);
}
}
else {
$form_state['values']['cpn_global_' . $type] = '';
}
}
}