You are here

function flag_lists_block in Flag Lists 6

Implementation of hook_block().

A block of personal flags for the current user on the current node.

File

./flag_lists.module, line 365
The Flag Lists module.

Code

function flag_lists_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0]['info'] = t('Lists');
    $blocks[0]['cache'] = BLOCK_NO_CACHE;
    return $blocks;
  }
  else {
    if ($op == 'configure' && $delta == 0) {
      $form['create_lists'] = array(
        '#type' => 'checkbox',
        '#title' => t('Show link to add new list'),
        '#default_value' => variable_get('flag_lists_create_lists', 0),
        '#description' => t('Checking this adds a link to the create new list form.'),
      );
      $form['ops'] = array(
        '#type' => 'checkbox',
        '#title' => t('Show edit and delete links'),
        '#default_value' => variable_get('flag_lists_ops', 0),
        '#description' => t('Checking this appends edit and delete links to each list name for users with access.'),
      );
      $form['include_flags'] = array(
        '#type' => 'checkbox',
        '#title' => t('Include flag module flags'),
        '#default_value' => variable_get('flag_lists_include_flags', 0),
        '#description' => t('Checking this will append flag module flags to the list of lists.'),
      );
      return $form;
    }
    elseif ($op == 'save' && $delta == 0) {
      variable_set('flag_lists_create_lists', $edit['create_lists']);
      variable_set('flag_lists_ops', $edit['ops']);
      variable_set('flag_lists_include_flags', $edit['include_flags']);
    }
    elseif ($op == 'view' && user_access('create flag lists')) {
      $block['subject'] = t('My lists');
      $block['content'] = theme('flag_lists_list', NULL, variable_get('flag_lists_create_lists', 0), variable_get('flag_lists_ops', 0), variable_get('flag_lists_include_flags', 0));
      if (!is_null($block['content'])) {
        return $block;
      }
    }
  }
}