Commit 92f5a844 authored by webchick's avatar webchick

#605862 by andypost, peximo, sun: Store language for comments.

parent 087a47ba
...@@ -158,6 +158,22 @@ function comment_update_7007() { ...@@ -158,6 +158,22 @@ function comment_update_7007() {
db_query('UPDATE {comment} SET created = changed'); 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" * @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000. * The next series of updates should start at 8000.
...@@ -263,12 +279,20 @@ function comment_schema() { ...@@ -263,12 +279,20 @@ function comment_schema() {
'length' => 255, 'length' => 255,
'not null' => FALSE, '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.", '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( 'indexes' => array(
'comment_status_pid' => array('pid', 'status'), 'comment_status_pid' => array('pid', 'status'),
'comment_num_new' => array('nid', 'changed', 'status'), 'comment_num_new' => array('nid', 'changed', 'status'),
'comment_uid' => array('uid'), 'comment_uid' => array('uid'),
'comment_nid_language' => array('nid', 'language'),
), ),
'primary key' => array('cid'), 'primary key' => array('cid'),
'foreign keys' => array( 'foreign keys' => array(
......
...@@ -1289,6 +1289,7 @@ function comment_save($comment) { ...@@ -1289,6 +1289,7 @@ function comment_save($comment) {
'name' => $comment->name, 'name' => $comment->name,
'mail' => $comment->mail, 'mail' => $comment->mail,
'homepage' => $comment->homepage, 'homepage' => $comment->homepage,
'language' => $comment->language,
)) ))
->condition('cid', $comment->cid) ->condition('cid', $comment->cid)
->execute(); ->execute();
...@@ -1368,6 +1369,7 @@ function comment_save($comment) { ...@@ -1368,6 +1369,7 @@ function comment_save($comment) {
'name' => $comment->name, 'name' => $comment->name,
'mail' => $comment->mail, 'mail' => $comment->mail,
'homepage' => $comment->homepage, 'homepage' => $comment->homepage,
'language' => $comment->language,
)) ))
->execute(); ->execute();
...@@ -1641,7 +1643,7 @@ function comment_get_display_page($cid, $node_type) { ...@@ -1641,7 +1643,7 @@ function comment_get_display_page($cid, $node_type) {
* @see comment_form_submit() * @see comment_form_submit()
*/ */
function comment_form($form, &$form_state, $comment) { function comment_form($form, &$form_state, $comment) {
global $user; global $user, $language;
$op = isset($_POST['op']) ? $_POST['op'] : ''; $op = isset($_POST['op']) ? $_POST['op'] : '';
$node = node_load($comment->nid); $node = node_load($comment->nid);
...@@ -1855,6 +1857,10 @@ function comment_form($form, &$form_state, $comment) { ...@@ -1855,6 +1857,10 @@ function comment_form($form, &$form_state, $comment) {
'#type' => 'value', '#type' => 'value',
'#value' => $comment->nid, '#value' => $comment->nid,
); );
$form['language'] = array(
'#type' => 'value',
'#value' => isset($comment->language) ? $comment->language : $language->language,
);
$form['uid'] = array( $form['uid'] = array(
'#type' => 'value', '#type' => 'value',
'#value' => !empty($comment->uid) ? $comment->uid : 0, '#value' => !empty($comment->uid) ? $comment->uid : 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment