function notifications_content_form_submit in Notifications 5
Same name and namespace in other branches
- 6 notifications_content/notifications_content.pages.inc \notifications_content_form_submit()
- 6.2 notifications_content/notifications_content.pages.inc \notifications_content_form_submit()
- 6.3 notifications_content/notifications_content.pages.inc \notifications_content_form_submit()
Process generic form submission
File
- notifications_content/
notifications_content.module, line 657 - Subscriptions to content events
Code
function notifications_content_form_submit($form_id, $form_values) {
$account = $form_values['account'];
$current = $form_values['current'];
$defaults = $form_values['defaults'];
$defaults += array(
'type' => 'node',
'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);
}
}
drupal_set_message(t('Your subscriptions have been updated.'));
}