You are here

function comment_notify_variable_registry_get in Comment Notify 7

Helper function to centralize variable management and defaults.

All variables fall under the "comment_notify" pseudo namespace. This ensures consistency, and eliminates some verbosity in the calling code. In addition by storing all of the variables in one place, we avoid repeating duplicate defaults which are harder to maintain.

Parameters

string $name: The name of the variable to retrieve.

Return value

mixed A string or array or int depending on the variables.

7 calls to comment_notify_variable_registry_get()
CommentNotifyTestCase::testCommentNotifyAnonymousUserFunctionalTest in ./comment_notify.test
Test various behaviors for anonymous users.
comment_notify_field_extra_fields in ./comment_notify.module
Implements hook_field_extra_fields().
comment_notify_form_alter in ./comment_notify.module
Implements hook_form_alter().
comment_notify_get_default_notification_setting in ./comment_notify.inc
comment_notify_get_user_notification_setting in ./comment_notify.inc
Get the notification preferences for a specific user.

... See full list

File

./comment_notify.inc, line 336
Contains functions which utilize the database and other internal helpers.

Code

function comment_notify_variable_registry_get($name) {
  $variables = array();
  $variables['author_subject'] = t('[site:name] :: new comment for your post.');
  $variables['available_alerts'] = array(
    COMMENT_NOTIFY_NODE,
    COMMENT_NOTIFY_COMMENT,
  );
  $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'] = 0;
  $variables['watcher_subject'] = '[site:name] :: new comment on [comment:node:title]';
  $variables['comment_notify_default_mailtext'] = DEFAULT_MAILTEXT;
  $variables['node_types'] = array(
    'article' => 'article',
  );

  // Errors.
  $variables['error_anonymous_email_missing'] = 'If you want to subscribe to comments you must supply a valid e-mail address.';
  return variable_get("comment_notify_" . $name, $variables[$name]);
}