function faq_ask_a_question_blockform in FAQ_Ask 7
Same name and namespace in other branches
- 6.2 faq_ask.module \faq_ask_a_question_blockform()
 
Block "Ask a Question" form implementation
This implements the form displayed in a block where the user may ask a question
Return value
array Block content
1 call to faq_ask_a_question_blockform()
- faq_ask_block_view in ./
faq_ask.module  - Implements hook_block_view().
 
File
- ./
faq_ask.module, line 794  - 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_a_question_blockform() {
  // Include page handler for node_add()
  module_load_include('inc', 'node', 'node.pages');
  // If user is allowed to create a faq content type
  if (node_access('create', 'faq')) {
    // Fool the hook_form_alter function to think we're in an faq-ask page
    $saved_get = '';
    if (isset($_GET['ask'])) {
      $saved_get = $_GET['ask'];
    }
    $_GET['ask'] = '1';
    $_GET['block'] = 'TRUE';
    // Note title before rendering of form.
    $title = drupal_get_title();
    // Create the form
    $form = node_add('faq');
    // Restore title, which will have been overridden.
    drupal_set_title($title, PASS_THROUGH);
    // Issue #1811600 by TBarina: Giving permission to Ask a Question causes all node titles to display &;#039; instead of apostrophe.
    // Adding param const PASS_THROUGH tp the drupal_set_title() function to avoid check_plain()
    // Restore the $_GET['ask'] variable status
    if ($saved_get != '') {
      $_GET['ask'] = $saved_get;
    }
    else {
      unset($_GET['ask']);
    }
    unset($_GET['block']);
    return $form;
  }
  else {
    return '';
  }
}