function quote_form_alter in Quote 6.2
Same name and namespace in other branches
- 8.2 quote.module \quote_form_alter()
- 5 quote.module \quote_form_alter()
- 6 quote.module \quote_form_alter()
- 7.2 quote.module \quote_form_alter()
- 7 quote.module \quote_form_alter()
Implementation of hook_form_alter().
File
- ./
quote.module, line 93 - The quote module provides a filter and appropriate links that allow users to quote nodes and other comments in their own comments.
Code
function quote_form_alter(&$form, &$form_state, $form_id) {
// The explanation for the $_POST check is further below.
if ($form_id == 'comment_form' && (isset($_POST['quote']) || isset($_GET['quote']) && $_GET['quote'])) {
$nid = arg(2);
$cid = arg(3);
if ($cid || _quote_variable_get('node_link_display')) {
extract(_quote_get_quoted_data($nid, $cid));
// Add quoted text and preserve existing content (signature etc.).
$form['comment_filter']['comment']['#default_value'] = "[quote={$name}]" . trim($content) . "[/quote]\n" . $form['comment_filter']['comment']['#default_value'];
if (_quote_variable_get('subject_required')) {
$form['subject']['#required'] = TRUE;
}
// The Form API, by default, drops name-value pairs from the form's action
// URL (besides ?q=). Manually adding it back in as a hidden element.
$form['quote'] = array(
'#type' => 'hidden',
'#value' => 1,
);
if (_quote_variable_get('subject_required')) {
$form['subject']['#required'] = TRUE;
}
}
}
}