You are here

function notifications_ui_block_view in Notifications 7

Implementation of hook_block_view

File

notifications_ui/notifications_ui.module, line 289
User Interface for subscriptions modules

Code

function notifications_ui_block_view($delta = '') {

  // user has now permission to create subscriptions. exit early.
  if (!user_access('create subscriptions')) {
    return array();
  }

  // This example comes from node.module. Note that you can also return a
  // renderable array rather than rendered HTML for 'content'.
  $block = array();
  switch ($delta) {
    case 'subscriptions':
      $list = notifications_subscription_list('page subscriptions')
        ->filter_option('subscriptions_block');
      if ($list
        ->count()) {
        $block['subject'] = t('Subscriptions');
        $display = variable_get('notifications_ui_block_display', 'links');
        if ($display == 'links') {
          $block['content'] = theme('item_list', array(
            'items' => $list
              ->get_links(),
          ));
        }
        elseif ($display == 'checkboxes') {
          $block['content'] = drupal_get_form('notifications_subscription_list_form', 'checkboxes', $list);
        }
      }
      break;
  }
  return $block;
}