function notifications_admin_subscriptions_settings_submit in Notifications 7
Same name and namespace in other branches
- 6.4 notifications.admin.inc \notifications_admin_subscriptions_settings_submit()
Subscription settings submit, disable all subscriptions not allowed
@todo d7update
1 string reference to 'notifications_admin_subscriptions_settings_submit'
- notifications_admin_subscriptions_settings in ./
notifications.admin.inc - Subscription settings
File
- ./
notifications.admin.inc, line 174
Code
function notifications_admin_subscriptions_settings_submit($form, &$form_state) {
$types_enabled = $form_state['values']['enabled'];
// Convert type name values to 1 for storage (instead of type name)
$enabled = array_filter($types_enabled);
$types_enabled = array_merge($types_enabled, array_combine($enabled, array_fill(0, count($enabled), 1)));
notifications_option_array_set('subscription_types', 'enabled', $types_enabled);
unset($form_state['values']['enabled']);
// Submission may have been Save or Reset to defaults, so we cannot really trust submitted values
// Instead we do a cache refresh and re-check enabled / disabled types
drupal_static_reset('notifications_subscription_type_enabled');
$types = notifications_subscription_type_enabled();
$sql_update = 'UPDATE {notifications_subscription} SET status = %d WHERE status = %d';
$enabled = $disabled = 0;
/*
if ($types) {
// Enable subscriptions of these types that were disabled before
$placeholders = db_placeholders($types, 'varchar');
$sql_where = ' AND type IN (' . $placeholders . ')';
$params = array_merge(array(Notifications_Subscription::STATUS_ACTIVE, Notifications_Subscription::STATUS_DISABLED), $types);
db_query($sql_update . $sql_where, $params);
$enabled = db_affected_rows();
$params = array_merge(array(Notifications_Subscription::STATUS_DISABLED, Notifications_Subscription::STATUS_ACTIVE), $types);
$sql_where = ' AND type NOT IN (' . $placeholders . ')';
}
else {
$params = array(Notifications_Subscription::STATUS_DISABLED, Notifications_Subscription::STATUS_ACTIVE);
$sql_where = '';
}
db_query($sql_update . $sql_where, $params);
$disabled = db_affected_rows();
if ($enabled) {
drupal_set_message(t('@count existing subscriptions have been enabled.', array('@count' => $enabled)), 'warning');
}
if ($disabled) {
drupal_set_message(t('@count existing subscriptions have been disabled.', array('@count' => $disabled)), 'warning');
// Delete rows from queue and do some clean up.
notifications_queue()->queue_clean(FALSE);
}
*/
}