You are here

function faq_ask_block in FAQ_Ask 6.2

Same name and namespace in other branches
  1. 6 faq_ask.module \faq_ask_block()

Implementation of hook_block().

This creates and populates the "unanswered questions" block.

File

./faq_ask.module, line 1495
This module is an add-on to the FAQ module that allows users with the 'ask question' permission to create a question which will be queued for an 'expert' to answer.

Code

function faq_ask_block($op = 'list', $delta = 0, $edit = array()) {
  global $user;
  $block = array();
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Unanswered Questions');
      $blocks[1]['info'] = t('Ask a Question');
      return $blocks;
    case 'view':
      switch ($delta) {
        case 0:

          // Unanswered Questions.
          $block['subject'] = t('Unanswered questions');
          $block['content'] = _faq_ask_list_unanswered(variable_get('faq_unanswered_count', 3));
          break;
        case 1:

          // Ask a question block.
          if (user_access('ask question')) {
            $block['subject'] = t('Ask a Question');
            $block['content'] = faq_ask_a_question_blockform();
          }
      }

      // end switch($delta).
      return $block;
    case 'configure':
      switch ($delta) {
        case 0:

          // Unanswered Questions.
          $block['faq_unanswered_count'] = array(
            '#type' => 'select',
            '#title' => t('Number of questions to show'),
            '#description' => t("This controls the number of questions that appear in the 'Unanswered Questions' block."),
            '#options' => array(
              1 => 1,
              2 => 2,
              3 => 3,
              4 => 4,
              5 => 5,
              6 => 6,
              7 => 7,
              8 => 8,
              9 => 9,
              10 => 10,
              15 => 15,
              20 => 20,
              25 => 25,
              50 => 50,
              100 => 100,
            ),
            '#default_value' => variable_get('faq_unanswered_count', 3),
          );
          break;
      }

      // end switch($delta)
      return $block;
    case 'save':
      switch ($delta) {
        case 0:
          variable_set('faq_unanswered_count', $edit['faq_unanswered_count']);
          break;
      }

      // end switch($delta)
      return;
  }

  // end switch($op)
}