function comment_notify_get_user_notification_setting in Comment Notify 7
Get the notification preferences for a specific user.
Parameters
int $uid:
Return value
mixed StdClass if found, else NULL
Throws
\Exception
4 calls to comment_notify_get_user_notification_setting()
- comment_notify_get_user_comment_notify_preference in ./
comment_notify.inc - Get a user's default preference for comment notification.
- comment_notify_get_user_node_notify_preference in ./
comment_notify.inc - Get a user's default preference for node update notification.
- comment_notify_set_user_notification_setting in ./
comment_notify.inc - Sets the notification preferences for a specific user.
- comment_notify_user_load in ./
comment_notify.module
File
- ./
comment_notify.inc, line 18 - Contains functions which utilize the database and other internal helpers.
Code
function comment_notify_get_user_notification_setting($uid) {
$users =& drupal_static(__FUNCTION__);
if (!isset($users[$uid])) {
if (is_null($uid)) {
throw new Exception('Cannot get user preference, uid missing');
}
// Handle anonymous users with defaults.
if ($uid == 0) {
$users[0] = new stdClass();
$users[0]->comment_notify = comment_notify_variable_registry_get('default_anon_mailalert');
$users[0]->node_notify = comment_notify_variable_registry_get('node_notify_default_mailalert');
}
else {
$setting = db_select('comment_notify_user_settings', 'cnus')
->fields('cnus')
->condition('uid', $uid)
->execute()
->fetchObject();
if (!$setting) {
return NULL;
}
else {
$users[$uid] = $setting;
}
}
}
return $users[$uid];
}