Commit 892c5338 authored by greggles's avatar greggles

bug #761888 by greggles: Preference retrieval functions not returning proper...

bug #761888 by greggles: Preference retrieval functions not returning proper defaults and removing dead code cruft in user_load
parent df76b598
......@@ -30,7 +30,15 @@ function comment_notify_get_user_notification_setting($uid) {
->fields('cnus')
->condition('uid', $uid)
->execute();
$users[$uid] = $result->fetchObject();
// Use defaults if they have no value (e.g. created before comment_notify).
if (!isset($result->comment_notify)) {
$users[$uid] = (object) array(
'comment_notify' => comment_notify_variable_registry_get('default_registered_mailalert'),
'node_notify' => comment_notify_variable_registry_get('node_notify_default_mailalert'));
}
else {
$users[$uid] = $result->fetchObject();
}
}
}
return $users[$uid];
......@@ -56,7 +64,7 @@ function comment_notify_delete_user_notification_setting($uid) {
*/
function comment_notify_get_user_comment_notify_preference($uid) {
$setting = comment_notify_get_user_notification_setting($uid);
return is_null($setting->comment_notify) ? comment_notify_variable_registry_get('node_notify_default_mailalert') : $setting->comment_notify;
return !isset($setting->comment_notify) ? comment_notify_variable_registry_get('default_registered_mailalert') : $setting->comment_notify;
}
/**
......@@ -69,7 +77,7 @@ function comment_notify_get_user_comment_notify_preference($uid) {
*/
function comment_notify_get_user_node_notify_preference($uid) {
$setting = comment_notify_get_user_notification_setting($uid);
return is_null($setting->node_notify) ? comment_notify_variable_registry_get('default_registered_mailalert') : $setting->node_notify;
return !isset($setting->node_notify) ? comment_notify_variable_registry_get('node_notify_default_mailalert') : $setting->node_notify;
}
/**
......@@ -317,7 +325,7 @@ function comment_notify_variable_registry_get($name) {
$variables['default_anon_mailalert'] = COMMENT_NOTIFY_NODE;
$variables['node_notify_default_mailtext'] = AUTHOR_MAILTEXT;
$variables['default_registered_mailalert'] = COMMENT_NOTIFY_DISABLED;
$variables['node_notify_default_mailalert'] = FALSE;
$variables['node_notify_default_mailalert'] = 0;
$variables['comment_notify_default_registered_mailalert'] = COMMENT_NOTIFY_DISABLED;
$variables['watcher_subject'] = '[site:name] :: new comment on [node:title]';
$variables['comment_notify_default_mailtext'] = DEFAULT_MAILTEXT;
......
......@@ -121,7 +121,7 @@ function comment_notify_form_comment_form_alter(&$form, &$form_state, $form_id)
$form['notify_settings']['notify'] = array(
'#type' => 'checkbox',
'#title' => t('Notify me when new comments are posted'),
'#default_value' => $preference,
'#default_value' => (bool) $preference,
);
if (count($available_options) > 1) {
......@@ -373,20 +373,12 @@ function comment_notify_user_update(&$edit, $account, $category) {
function comment_notify_user_load(&$users) {
module_load_include('inc', 'comment_notify', 'comment_notify');
// Why would we want to load this on every user load?
// @todo: Why would we want to load this on every user load?
foreach ($users as &$user) {
$user->comment_notify_settings = comment_notify_get_user_notification_setting($user->uid);
}
return;
// @todo: Fix this naming weirdness.
foreach ($users as $user) {
$result = db_select('comment_notify_user_settings', 'cnus')
->fields('cnus', array('node_notify' => 'node_notify_mailalert', 'comment_notify' => 'comment_notify_mailalert'))
->condition('uid', $user->uid)
->execute();
}
}
function comment_notify_user_cancel(&$edit, $account, $method) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment