title; break; case 'comment': if (arg(1) == 'reply') { if (is_numeric(arg(3))) { // replying to a comment (e.g. comment/reply/NID/CID) $comment = comment_load(arg(3)); $subject = $comment->subject; } else { // replying to a node on a separated page (e.g. node/reply/NID) $node = node_load(arg(2)); $subject = $node->title; } } elseif (arg(2) == 'edit' && is_numeric(arg(1))) { // editing a comment (e.g. comment/CID/edit) // subject shouldn't be empty (how could it be?) // therefore this point wouldn't be reached // // but, if for some reason (e.g. DB edit) // the subject of the comment becomes empty // it would require fetching its parent's title // nevertheless, testing the comment->pid to decide // whether to load node's title or parent's subject // is too complicated logic for a case that shouldn't happen // therefore, only avoid: // - PHP "Notice: Undefined variable: subject" // - #default_value = "Re: " return; // take no action at all } break; } if (!preg_match('/^' . preg_quote(t('Re:')) . '/i', $subject)) { $subject = t('Re:') . ' ' . $subject; } // comment subjects can not be longer than 64 characters $subject = truncate_utf8($subject, 64, TRUE, TRUE); // when comment subject is disabled $form['subject']['#access'] = FALSE $form['subject']['#default_value'] = $subject; // use 'hidden' when testing for quick inspect DOM (next line must be commented) //if (!$form['subject']['#access']) $form['subject'] = array('#type' => 'hidden', '#access' => TRUE) + $form['subject']; } }