function notifications_user_form_submit in Notifications 6.2
Same name and namespace in other branches
- 5 notifications.admin.inc \notifications_user_form_submit()
- 6.4 notifications.module \notifications_user_form_submit()
- 6 notifications.module \notifications_user_form_submit()
- 6.3 notifications.module \notifications_user_form_submit()
Process generic form submission
File
- ./
notifications.module, line 1695 - Notifications module
Code
function notifications_user_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
$account = $form_values['account'];
$current = $form_values['current'];
$defaults = $form_values['defaults'];
$defaults += array(
'uid' => $account->uid,
);
$fields = $form_values['subscription_fields'];
$values = $form_values['subscriptions'];
$check = 'checkbox';
foreach ($values[$check] as $index => $value) {
$subscription = NULL;
if ($value) {
// Checked, save only if new or changed
if (!isset($current[$index])) {
$subscription = $defaults;
}
elseif ($current[$index]->send_interval != $values['send_interval'][$index] || $current[$index]->send_method != $values['send_method'][$index]) {
$subscription = (array) $current[$index];
}
// Complete and save
if ($subscription) {
$subscription['send_interval'] = $values['send_interval'][$index];
$subscription['send_method'] = $values['send_method'][$index];
$subscription['fields'] = $fields[$index];
notifications_save_subscription($subscription);
}
}
elseif (isset($current[$index])) {
notifications_delete_subscription($current[$index]->sid);
}
}
}