function radioactivity_admin_profile_form_submit in Radioactivity 5
Same name and namespace in other branches
- 6 radioactivity-admin-ui.inc \radioactivity_admin_profile_form_submit()
File
- ./
radioactivity.module, line 346
Code
function radioactivity_admin_profile_form_submit($form_id, $form) {
$dpid = (int) $form['decay_profile_id'];
if ($dpid == 0) {
// internal error
drupal_set_message(t('Internal error: decay_profile_id=@dpid', array(
'@dpid' => $dpid,
)), 'error');
return FALSE;
}
$decay_profiles = _radioactivity_get_decay_profiles();
if ($dpid < 0) {
// get new $dpid
$dpids = array_keys($decay_profiles);
if (count($dpids) > 0) {
$dpid = 1 + max($dpids);
}
else {
$dpid = 1;
}
}
// build profile array
$decay_profile = array();
$decay_profile['label'] = $form['label'];
$decay_profile['description'] = $form['description'];
$half_life = (int) $form['half_life'];
if ($half_life <= 0) {
$half_life = 6 * 3600;
}
$decay_profile['half_life'] = $half_life;
$decay_profile['cut_off_energy'] = (double) $form['cut_off_energy'];
$decay_profile['energy'] = _radioactivity_prune_array($form['energy']);
$decay_profiles[$dpid] = $decay_profile;
_radioactivity_set_decay_profiles($decay_profiles);
drupal_set_message(t('Profile @dpid saved.', array(
'@dpid' => $dpid,
)));
}