/[drupal]/contributions/modules/comment_subject/comment_subject.module
ViewVC logotype

Contents of /contributions/modules/comment_subject/comment_subject.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Fri Feb 22 09:33:25 2008 UTC (21 months ago) by ahoeben
Branch: MAIN
CVS Tags: DRUPAL-6--1-3
Branch point for: DRUPAL-6--1
Changes since 1.6: +3 -12 lines
File MIME type: text/x-php
compatible with 6.x branch
1 <?php
2 // $Id: comment_subject.module,v 1.6 2007/12/28 16:27:51 ahoeben Exp $
3
4 /**
5 * Implementation of hook_form_alter().
6 */
7 function comment_subject_form_alter(&$form, &$form_state, $form_id) {
8 if ($form_id == 'comment_form' && $form['subject']['#default_value']=='') {
9 switch (arg(0)) {
10 case 'node':
11 $node = node_load(array('nid' => arg(1)));
12 $subject = $node->title;
13 break;
14 case 'comment':
15 if (arg(1)=='reply') {
16 if (is_numeric(arg(3))) {
17 $comment = _comment_load(arg(3));
18 $subject = $comment->subject;
19 } else {
20 $node = node_load(arg(2));
21 $subject = $node->title;
22 }
23 } else if (arg(1)=='edit' && is_numeric(arg(2))) {
24 $comment = _comment_load(arg(2));
25 $subject = $comment->subject;
26 }
27 break;
28 }
29 if (!preg_match('/^' . preg_quote(t('Re:')) . '/i', $subject))
30 $subject = t('Re:') . ' ' . $subject;
31
32 if (variable_get('comment_subject_field', 1) == 1) {
33 $form['subject']['#default_value'] = $subject;
34 } else {
35 // comment subject disabled in comment settings
36 $form['subject'] = array('#type' => 'hidden', '#default_value' => $subject);
37 }
38 }
39
40 }
41
42 ?>

  ViewVC Help
Powered by ViewVC 1.1.2