function swftools_profiles_profile_form_submit in SWF Tools 6.3
Implementation of hook_form_submit().
File
- profiles/
swftools_profiles.admin.inc, line 331 - Configuration settings for SWF Tools profiles.
Code
function swftools_profiles_profile_form_submit($form, &$form_state) {
// Register the operation being performed
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
// Initialise an array for convenience
$profile = $form_state['values'];
$profile['profile'] = trim($profile['profile']);
$profile['name'] = trim($profile['name']);
$profile['old_profile'] = trim($profile['old_profile']);
$profile['clone'] = trim($profile['clone']);
// If the profile is to be deleted handover to deletion function
if ($op == t('Delete profile')) {
$form_state['redirect'] = 'admin/settings/swftools/profile/' . str_replace('_', '-', $profile['old_profile']) . '/delete';
return;
}
// Execute the save
$status = swftools_profiles_profile_save($profile);
// Capture the profile name
$t_args = array(
'%name' => $profile['name'],
);
// Generate a message
if ($status == SAVED_UPDATED) {
drupal_set_message(t('The profile %name has been updated.', $t_args));
// Update any existing settings to the new profile name
foreach (swftools_profiles_settings() as $setting) {
if (($settings = variable_get(swftools_profiles_variable_name($setting, $profile['old_profile']), SWFTOOLS_UNDEFINED)) != SWFTOOLS_UNDEFINED) {
variable_set(swftools_profiles_variable_name($setting, $profile['profile']), $settings);
variable_del(swftools_profiles_variable_name($setting, $profile['old_profile']));
}
}
}
elseif ($status == SAVED_NEW) {
drupal_set_message(t('The profile %name has been added.', $t_args));
watchdog('swftools', 'Added profile %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/settings/swftools/profiles/list'));
}
// If we are cloning a profile, copy settings for each configured player
if ($profile['clone']) {
// Clone any settings that already exist
foreach (swftools_profiles_settings() as $setting) {
if (($settings = variable_get(swftools_profiles_variable_name($setting, $profile['clone']), SWFTOOLS_UNDEFINED)) != SWFTOOLS_UNDEFINED) {
variable_set(swftools_profiles_variable_name($setting, $profile['profile']), $settings);
}
}
}
// Redirect to profile listing page
$form_state['redirect'] = 'admin/settings/swftools/profiles';
// Rebuild profiles cache
swftools_profiles_get_profiles(TRUE);
// Rebuild theme registry
drupal_rebuild_theme_registry();
// Finished
return;
}