diff --git a/modules/comment/comment.install b/modules/comment/comment.install index 454d6e16af4761c574fa551ca2c7acb6d0721789..272c50944e3d076d8ba04a5a45a6b0c12dab744f 100644 --- a/modules/comment/comment.install +++ b/modules/comment/comment.install @@ -158,6 +158,22 @@ function comment_update_7007() { db_query('UPDATE {comment} SET created = changed'); } +/** + * Add language column to the {comment} table. + */ +function comment_update_7008() { + // Create a language column. + db_add_field('comment', 'language', array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + )); + + // Create the index. + db_add_index('comment', 'comment_nid_language', array('nid', 'language')); +} + /** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. @@ -263,12 +279,20 @@ function comment_schema() { 'length' => 255, 'not null' => FALSE, 'description' => "The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.", - ) + ), + 'language' => array( + 'description' => 'The {languages}.language of this comment.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), ), 'indexes' => array( 'comment_status_pid' => array('pid', 'status'), 'comment_num_new' => array('nid', 'changed', 'status'), 'comment_uid' => array('uid'), + 'comment_nid_language' => array('nid', 'language'), ), 'primary key' => array('cid'), 'foreign keys' => array( diff --git a/modules/comment/comment.module b/modules/comment/comment.module index db36e0a7a15f1d7815184b4ae9467e5c833523c3..266b35499b13e99e113152b9c1b4b203f8f0f0b9 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1289,6 +1289,7 @@ function comment_save($comment) { 'name' => $comment->name, 'mail' => $comment->mail, 'homepage' => $comment->homepage, + 'language' => $comment->language, )) ->condition('cid', $comment->cid) ->execute(); @@ -1368,6 +1369,7 @@ function comment_save($comment) { 'name' => $comment->name, 'mail' => $comment->mail, 'homepage' => $comment->homepage, + 'language' => $comment->language, )) ->execute(); @@ -1641,7 +1643,7 @@ function comment_get_display_page($cid, $node_type) { * @see comment_form_submit() */ function comment_form($form, &$form_state, $comment) { - global $user; + global $user, $language; $op = isset($_POST['op']) ? $_POST['op'] : ''; $node = node_load($comment->nid); @@ -1855,6 +1857,10 @@ function comment_form($form, &$form_state, $comment) { '#type' => 'value', '#value' => $comment->nid, ); + $form['language'] = array( + '#type' => 'value', + '#value' => isset($comment->language) ? $comment->language : $language->language, + ); $form['uid'] = array( '#type' => 'value', '#value' => !empty($comment->uid) ? $comment->uid : 0,