You are here

function heartbeat_user_templates in Heartbeat 7

Add the heartbeat template field to the user edit form.

1 call to heartbeat_user_templates()
heartbeat_form_user_profile_form_alter in ./heartbeat.module
Implements hook_form_FORM_ID_alter().
4 string references to 'heartbeat_user_templates'
HeartbeatActivityController::buildQuery in ./heartbeat.entity.inc
Implements buildQuery().
HeartbeatStream::createQuery in includes/heartbeatstream.inc
createQuery().
heartbeat_update_7014 in ./heartbeat.install
Add database table for the heartbeat user templates.
SingleActivity::createQuery in streams/singleactivity.inc
Override the createQuery method.

File

./heartbeat.module, line 497
Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.

Code

function heartbeat_user_templates(&$form, &$form_state) {
  $account = $form['#user'];

  // The heartbeat privacy settings.
  $form['heartbeat'] = array(
    '#type' => 'fieldset',
    '#title' => t('Activity settings'),
    '#weight' => 7,
    '#collapsible' => TRUE,
  );
  $templates = heartbeat_user_templates_load($account->uid);

  // Privacy settings for streams.
  $form['heartbeat']['privacy'] = array(
    '#tree' => TRUE,
  );
  $form['heartbeat']['privacy']['default_template'] = array(
    '#type' => 'radios',
    '#title' => t("Privacy settings"),
    '#description' => t("This setting will apply to status updates to the profile when no access restriction is known (E.g. activity being logged from external sources)."),
    '#options' => _heartbeat_perms_options(),
    '#default_value' => isset($templates['0']) ? $templates['0']->status : HEARTBEAT_PRIVATE,
  );

  // Privacy settings on Heartbeat Templates.
  $form['heartbeat']['templates'] = array(
    '#tree' => TRUE,
  );
  foreach ($form_state['heartbeat_templates'] as $template_id => $description) {
    $template = heartbeat_message_template_load($template_id);
    $form['heartbeat']['templates'][$template_id] = array(
      '#type' => 'select',
      '#title' => $description,
      '#default_value' => isset($templates[$template_id]) ? $templates[$template_id]->status : HEARTBEAT_PUBLIC_TO_ALL,
      '#options' => _heartbeat_perms_options(TRUE, $template->perms),
    );
  }
  $hook = 'heartbeat_user_settings';
  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;
    $function($form, $form_state);
  }
  $form['#submit'][] = 'heartbeat_user_templates_submit';
}