You are here

function favorites_block_view in Favorites 7

Same name and namespace in other branches
  1. 7.2 favorites.module \favorites_block_view()

Implements hook_block_view().

File

./favorites.module, line 116
The favorites module allows users to bookmark any path within a site.

Code

function favorites_block_view($delta = 0) {
  if ($delta == 0 && user_access('manage own favorites')) {

    // Add Ajax support.
    drupal_add_js(drupal_get_path('module', 'favorites') . '/favorites.js');

    // Create the block content.
    // @todo: Return a render array instead.
    $form_id = drupal_get_form('favorites_add_favorite_form');
    $output = '<div id="favorites-list">' . favorites_list() . '</div>' . drupal_render($form_id);
    return array(
      'subject' => t('My Favorites'),
      'content' => $output,
    );
  }
}