### Eclipse Workspace Patch 1.0
#P faq_ask
Index: faq_ask.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq_ask/faq_ask.module,v
retrieving revision 1.17.2.23.2.14
diff -u -r1.17.2.23.2.14 faq_ask.module
--- faq_ask.module	22 Oct 2009 04:11:46 -0000	1.17.2.23.2.14
+++ faq_ask.module	24 Feb 2010 12:32:45 -0000
@@ -158,11 +158,11 @@
 }
 
 /**
- * Implementation of hook_form_alter().
+ * Implementation of hook_form_FORM_ID_alter().
  *  This is how we build the "ask question" form.
  */
-function faq_ask_form_alter(&$form, $form_state, $form_id) {
-  if ($form_id != 'faq_node_form' || !isset($_GET['ask'])) {
+function faq_ask_form_faq_node_form_alter(&$form, $form_state) {
+  if (!isset($_GET['ask'])) {
       return;
     }
   if ($_GET['ask'] != 1 && $_GET['ask'] != 'true') {
@@ -186,6 +186,34 @@
   // Make sure we know we came from here.
   $form['faq_ask'] = array('#type' => 'value', '#value' => TRUE);
   $form['#submit'][] = 'faq_ask_submit';
+
+  // Sean Corales: Redirect to faq page if user is anonymous or cannot edit own faq nodes
+  global $user;
+  if ((!user_access('edit own faq') && !user_access('edit faq')) || ($user->uid == 0)) {
+    $form['#redirect'] = 'faq';
+  }
+
+  // Handle special cases if this is a block form
+  if (isset($_GET['block'])) {
+    if($_GET['block']) {
+
+      // Shorten the description text on taxonomy field
+      if (!variable_get('faq_ask_categorize', FALSE) && isset($form['taxonomy']['tags'])) {
+        $tags = array_keys($form['taxonomy']['tags']);
+        $form['taxonomy']['tags'][$tags[0]]['#description'] = t('A comma-separated list of terms.');
+      }
+
+      // Shorter description on Qestion field + move it higher
+      $form['title']['#description'] = t('Question to be answered.');
+      $form['title']['#weight'] = '-5';
+
+      // Shorter description on detailed question field
+      $form['detailed_question']['#description'] = t('Longer question text.');
+
+    }
+  }
+
+
 }
 
 function faq_ask_submit($form, &$form_state) {
@@ -232,6 +260,52 @@
 }
 
 /**
+ * Block "Ask a Question" form implementation
+ * This implements the form displayed in a block where the user may ask a question
+ *
+ */
+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);
+
+    // Restore the $_GET['ask'] variable status
+    if ($saved_get != '') {
+      $_GET['ask'] = $saved_get;
+    }
+    else {
+      unset($_GET['ask']);
+    }
+    unset($_GET['block']);
+
+    return $form;
+  }
+  else {
+    return '';
+  }
+
+}
+
+
+/**
  * Implementation of hook_mail().
  * This function completes the email, allowing for placeholder substitution.
  * @TODO: notify_asker.
@@ -849,6 +923,7 @@
  */
 function faq_ask_block($op = 'list', $delta = 0, $edit = array()) {
   global $user;
+  $block = array();
   switch ($op) {
     case 'list':
       $blocks[0]['info'] = t('Unanswered Questions');
@@ -865,7 +940,8 @@
         case 1:
           // Ask a question block.
           if (user_access('ask question')) {
-            $block['content'] = faq_ask_page(NULL);
+            $block['title']= t('Ask a Question');
+            $block['content'] = faq_ask_a_question_blockform();
           }
 
       } // end switch($delta).
