You are here

function favorites_block in Favorites 6

Implements hook_block().

File

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

Code

function favorites_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('User Favorites block');
      $blocks[0]['cache'] = BLOCK_NO_CACHE;
      return $blocks;
    case 'view':
      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.
        $output = '<div id="favorites-list">' . favorites_list() . '</div>' . drupal_get_form('favorites_add_favorite_form');
        $block = array(
          'subject' => t('My Favorites'),
          'content' => $output,
        );
        return $block;
      }
      break;
  }
}