### 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 07:47:18 -0000 @@ -186,6 +186,28 @@ // Make sure we know we came from here. $form['faq_ask'] = array('#type' => 'value', '#value' => TRUE); $form['#submit'][] = 'faq_ask_submit'; + + // 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 = end($form['taxonomy']['tags']); + $form['taxonomy']['tags'][key($tags)]['#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 +254,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 +917,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 +934,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).