You are here

friendlist_activity.module in Heartbeat 6.3

Same filename and directory in other branches
  1. 6.4 modules/friendlist_activity/friendlist_activity.module

File

modules/friendlist_activity/friendlist_activity.module
View source
<?php

// by Jochen Stals - ONE-agency - www.one-agency.be

/**
 * Implementation of hook_views_api()
 *
 * This hook will tell views2 that friendlist_activiy is available
 */
function friendlist_activiy_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'friendlist_activiy'),
  );
}

/**
 * Implementation of hook_heartbeat_message_info()
 */
function friendlist_activity_heartbeat_message_info() {
  $info = array(
    1 => array(
      'message' => '!user1 is now !relation_type with !user2.',
      'message_concat' => '!user1 is now !relation_type with %others%',
      'message_id' => 'heartbeat_become_friends',
      'message_type' => 'normal',
      'concat_args' => array(
        'type' => 'summary',
        'group_by' => 'user-user',
        'group_target' => 'others',
        'merge_separator' => ', ',
        'merge_end_separator' => ' and ',
      ),
      'module' => 'friendlist_api',
      'description' => 'one user becomes friends with another.',
      'variables' => array(
        '@user1' => '[user2:user-name-url]',
        '#relation_type' => '[rtid:name]',
        '@user2' => '[user1:user-name-url]',
      ),
    ),
  );
  return $info;
}

/**
 * Implementation of hook_heartbeat_related_uid_info()
 */
function friendlist_activity_heartbeat_related_uid_info($uid) {
  if (variable_get('heartbeat_add_friends_to_personal', 1)) {
    $friends_uids = friendlist_activity_get_friends($uid);
    return $friends_uids;
  }
  else {
    return array(
      $uid,
    );
  }
}

/**
 * Implementation of hook_heartbeat_messages_alter()
 */
function friendlist_activity_heartbeat_messages_alter(&$raw_messages, HeartbeatAccess $state) {
  $duplicates = array();
  return $duplicates;
}

/**
 *  Implementation of hook_form_alter().
 */
function friendlist_activity_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'heartbeat_activity_admin_settings') {
    $form['fl_fields'] = array(
      '#type' => 'fieldset',
      '#weight' => 0,
      '#title' => t('Friendlist settings'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['fl_fields']['heartbeat_add_friends_to_personal'] = array(
      '#title' => t('Do you want to show activity by friendlist friends to the personal heartbeat?'),
      '#type' => 'checkbox',
      '#default_value' => variable_get('heartbeat_add_friends_to_personal', 1),
    );
  }
}

/**
 * Generate the view of people that a user is following
 */
function friendlist_activity_get_friends($uid) {
  $uids = array();
  if (variable_get('heartbeat_add_friends_to_personal', TRUE)) {
    $sql = "SELECT fr.requestee_id as 'uid' FROM {friendlist_relations} as fr\n\t  INNER JOIN {friendlist_statuses} fs ON fs.rid = fr.rid\n\t  WHERE fr.requester_id = %d AND fs.status = '%s' ORDER BY fs.last_update_time DESC, fr.rid DESC";
    $result = db_query($sql, $uid, 'TW_BOTH');
    while ($row = db_fetch_object($result)) {
      $uids[] = $row->uid;
    }
  }
  return $uids;
}

Functions

Namesort descending Description
friendlist_activity_form_alter Implementation of hook_form_alter().
friendlist_activity_get_friends Generate the view of people that a user is following
friendlist_activity_heartbeat_messages_alter Implementation of hook_heartbeat_messages_alter()
friendlist_activity_heartbeat_message_info Implementation of hook_heartbeat_message_info()
friendlist_activity_heartbeat_related_uid_info Implementation of hook_heartbeat_related_uid_info()
friendlist_activiy_views_api Implementation of hook_views_api()