You are here

function faq_ask_block in FAQ_Ask 6

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

Implementation of hook_block(). This creates and populates the "unanswered questions" block.

File

./faq_ask.module, line 1016
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;
  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['content'] = _faq_ask_list_unanswered(variable_get('faq_unanswered_count', 3));
          break;
        case 1:

          // Ask a question block.
          if (user_access('ask question')) {
            $block['content'] = faq_ask_page(NULL);
          }
          break;
      }

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

          // Unanswered Questions.
          $form['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 $form;
    case 'save':
      switch ($delta) {
        case 0:
          variable_set('faq_unanswered_count', $edit['faq_unanswered_count']);
          break;
      }

      // end switch($delta)
      return;
  }

  // end switch($op)
}