diff options
Diffstat (limited to 'modules/forum')
-rw-r--r-- | modules/forum/forum-icon.tpl.php | 3 | ||||
-rw-r--r-- | modules/forum/forum-list.tpl.php | 1 | ||||
-rw-r--r-- | modules/forum/forum-rtl.css | 1 | ||||
-rw-r--r-- | modules/forum/forum-submitted.tpl.php | 1 | ||||
-rw-r--r-- | modules/forum/forum-topic-list.tpl.php | 1 | ||||
-rw-r--r-- | modules/forum/forum.admin.inc | 1 | ||||
-rw-r--r-- | modules/forum/forum.css | 1 | ||||
-rw-r--r-- | modules/forum/forum.info | 1 | ||||
-rw-r--r-- | modules/forum/forum.install | 103 | ||||
-rw-r--r-- | modules/forum/forum.module | 41 | ||||
-rw-r--r-- | modules/forum/forum.pages.inc | 1 | ||||
-rw-r--r-- | modules/forum/forum.test | 6 | ||||
-rw-r--r-- | modules/forum/forums.tpl.php | 1 |
13 files changed, 132 insertions, 30 deletions
diff --git a/modules/forum/forum-icon.tpl.php b/modules/forum/forum-icon.tpl.php index 2b2cf3c10..9cf2cd8d3 100644 --- a/modules/forum/forum-icon.tpl.php +++ b/modules/forum/forum-icon.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -7,7 +6,7 @@ * * Available variables: * - $new_posts: Indicates whether or not the topic contains new posts. - * - $icon: The icon to display. May be one of 'hot', 'hot-new', 'new', + * - $icon_class: The icon to display. May be one of 'hot', 'hot-new', 'new', * 'default', 'closed', or 'sticky'. * - $first_new: Indicates whether this is the first topic with new posts. * diff --git a/modules/forum/forum-list.tpl.php b/modules/forum/forum-list.tpl.php index 5d8f18cec..bc0935f88 100644 --- a/modules/forum/forum-list.tpl.php +++ b/modules/forum/forum-list.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/forum/forum-rtl.css b/modules/forum/forum-rtl.css index 4f81bde29..d31c9e7f3 100644 --- a/modules/forum/forum-rtl.css +++ b/modules/forum/forum-rtl.css @@ -1,4 +1,3 @@ -/* $Id$ */ #forum tr td.forum { padding-left: 0.5em; diff --git a/modules/forum/forum-submitted.tpl.php b/modules/forum/forum-submitted.tpl.php index c025a9862..d310448c7 100644 --- a/modules/forum/forum-submitted.tpl.php +++ b/modules/forum/forum-submitted.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/forum/forum-topic-list.tpl.php b/modules/forum/forum-topic-list.tpl.php index c223686a9..33907036f 100644 --- a/modules/forum/forum-topic-list.tpl.php +++ b/modules/forum/forum-topic-list.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/forum/forum.admin.inc b/modules/forum/forum.admin.inc index 02f1940b2..1e6b36551 100644 --- a/modules/forum/forum.admin.inc +++ b/modules/forum/forum.admin.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/forum/forum.css b/modules/forum/forum.css index adcf7aa70..3f3ed9848 100644 --- a/modules/forum/forum.css +++ b/modules/forum/forum.css @@ -1,4 +1,3 @@ -/* $Id$ */ #forum .description { font-size: 0.9em; diff --git a/modules/forum/forum.info b/modules/forum/forum.info index 3478e6637..b18a0e5dc 100644 --- a/modules/forum/forum.info +++ b/modules/forum/forum.info @@ -1,4 +1,3 @@ -; $Id$ name = Forum description = Provides discussion forums. dependencies[] = taxonomy diff --git a/modules/forum/forum.install b/modules/forum/forum.install index a5dbc3e10..60c408793 100644 --- a/modules/forum/forum.install +++ b/modules/forum/forum.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -47,7 +46,7 @@ function forum_enable() { // Create the 'taxonomy_forums' field if it doesn't already exist. if (!field_info_field('taxonomy_forums')) { $field = array( - 'field_name' => 'taxonomy_' . $vocabulary->machine_name, + 'field_name' => 'taxonomy_forums', 'type' => 'taxonomy_term_reference', 'settings' => array( 'allowed_values' => array( @@ -60,8 +59,6 @@ function forum_enable() { ); field_create_field($field); - variable_set('forum_nav_vocabulary', $vocabulary->vid); - // Create a default forum so forum posts can be created. $edit = array( 'name' => t('General discussion'), @@ -74,7 +71,7 @@ function forum_enable() { // Create the instance on the bundle. $instance = array( - 'field_name' => 'taxonomy_' . $vocabulary->machine_name, + 'field_name' => 'taxonomy_forums', 'entity_type' => 'node', 'label' => $vocabulary->name, 'bundle' => 'forum', @@ -216,7 +213,7 @@ function forum_schema() { ), ), 'indexes' => array( - 'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'), + 'forum_topics' => array('nid', 'tid', 'sticky', 'last_comment_timestamp'), ), 'foreign keys' => array( 'tracked_node' => array( @@ -331,3 +328,97 @@ function forum_update_7001() { ->from($select) ->execute(); } + +/** + * Add new index to forum_index table. + */ +function forum_update_7002() { + db_drop_index('forum_index', 'forum_topics'); + db_add_index('forum_index', 'forum_topics', array('nid', 'tid', 'sticky', 'last_comment_timestamp')); +} + +/** + * @addtogroup updates-7.x-extra + * @{ + */ + +/** + * Rename field to 'taxonomy_forums'. + */ +function forum_update_7003() { + $messages = array(); + + $new_field_name = 'taxonomy_forums'; + + // Test to see if the taxonomy_forums field exists. + $fields = _update_7000_field_read_fields(array('field_name' => $new_field_name)); + if ($fields) { + // Since the field exists, we're done. + return; + } + + // Calculate the old field name. + $vid = variable_get('forum_nav_vocabulary', 0); + $vocabulary_machine_name = db_select('taxonomy_vocabulary', 'tv') + ->fields('tv', array('machine_name')) + ->condition('vid', $vid) + ->execute() + ->fetchField(); + $old_field_name = 'taxonomy_' . $vocabulary_machine_name; + + // Read the old fields. + $old_fields = _update_7000_field_read_fields(array('field_name' => $old_field_name)); + foreach ($old_fields as $old_field) { + if ($old_field['storage']['type'] != 'field_sql_storage') { + $messages[] = t('Cannot rename field %id (%old_field_name) to %new_field_name because it does not use the field_sql_storage storage type.', array( + '%id' => $old_field['id'], + '%old_field_name' => $old_field_name, + '%new_field_name' => $new_field_name, + )); + continue; + } + + // Update {field_config}. + db_update('field_config') + ->fields(array('field_name' => $new_field_name)) + ->condition('id', $old_field['id']) + ->execute(); + + // Update {field_config_instance}. + db_update('field_config_instance') + ->fields(array('field_name' => $new_field_name)) + ->condition('field_id', $old_field['id']) + ->execute(); + + // The tables that need updating in the form 'old_name' => 'new_name'. + $tables = array( + 'field_data_' . $old_field_name => 'field_data_' . $new_field_name, + 'field_revision_' . $old_field_name => 'field_revision_' . $new_field_name, + ); + foreach ($tables as $old_table => $new_table) { + $old_column_name = $old_field_name . '_tid'; + $new_column_name = $new_field_name . '_tid'; + + // Rename the column. + db_drop_index($old_table, $old_column_name); + db_change_field($old_table, $old_column_name, $new_column_name, array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + )); + db_drop_index($old_table, $new_column_name); + db_add_index($old_table, $new_column_name, array($new_column_name)); + + // Rename the table. + db_rename_table($old_table, $new_table); + } + } + + cache_clear_all('*', 'cache_field', TRUE); + + return $messages; +} + +/** + * @} End of "addtogroup updates-7.x-extra" + */ diff --git a/modules/forum/forum.module b/modules/forum/forum.module index fffd0c76d..c58b5c905 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -170,12 +169,9 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) { $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0]->tid : 0); $forum_term = forum_forum_load($tid); if ($forum_term) { - $vid = variable_get('forum_nav_vocabulary', 0); - $vocabulary = taxonomy_vocabulary_load($vid); - $links = array(); // Loop through all bundles for forum taxonomy vocabulary field. - $field = field_info_field('taxonomy_' . $vocabulary->machine_name); + $field = field_info_field('taxonomy_forums'); foreach ($field['bundles']['node'] as $type) { if (node_access('create', $type)) { $links[$type] = array( @@ -611,7 +607,7 @@ function forum_form_alter(&$form, $form_state, $form_id) { // ID from the URL (e.g., if we are on a page like node/add/forum/2, we // expect "2" to be the ID of the forum that was requested). $requested_forum_id = arg(3); - $form['taxonomy_forums'][$langcode]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : NULL; + $form['taxonomy_forums'][$langcode]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : ''; } } } @@ -880,7 +876,6 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { ->addTag('node_access') ->orderBy('f.sticky', 'DESC') ->orderByHeader($forum_topic_list_header) - ->orderBy('f.last_comment_timestamp', 'DESC') ->limit($forum_per_page); $count_query = db_select('forum_index', 'f'); @@ -895,7 +890,29 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $nids[] = $record->nid; } if ($nids) { - $result = db_query("SELECT n.title, n.nid, n.type, n.sticky, n.created, n.uid, n.comment AS comment_mode, ncs.*, f.tid AS forum_tid, u.name, CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END AS last_comment_name FROM {node} n INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {forum} f ON n.vid = f.vid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {users} u2 ON ncs.last_comment_uid = u2.uid WHERE n.nid IN (:nids)", array(':nids' => $nids)); + $query = db_select('node', 'n')->extend('TableSort'); + $query->fields('n', array('title', 'nid', 'type', 'sticky', 'created', 'uid')); + $query->addField('n', 'comment', 'comment_mode'); + + $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid'); + $query->fields('ncs', array('cid', 'last_comment_uid', 'last_comment_timestamp', 'comment_count')); + + $query->join('forum_index', 'f', 'f.nid = ncs.nid'); + $query->addField('f', 'tid', 'forum_tid'); + + $query->join('users', 'u', 'n.uid = u.uid'); + $query->addField('u', 'name'); + + $query->join('users', 'u2', 'ncs.last_comment_uid = u2.uid'); + + $query->addExpression('CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END', 'last_comment_name'); + + $query + ->orderBy('f.sticky', 'DESC') + ->orderByHeader($forum_topic_list_header) + ->condition('n.nid', $nids); + + $result = $query->execute(); } else { $result = array(); @@ -1194,16 +1211,16 @@ function _forum_user_last_visit($nid) { function _forum_get_topic_order($sortby) { switch ($sortby) { case 1: - return array('field' => 'ncs.last_comment_timestamp', 'sort' => 'desc'); + return array('field' => 'f.last_comment_timestamp', 'sort' => 'desc'); break; case 2: - return array('field' => 'ncs.last_comment_timestamp', 'sort' => 'asc'); + return array('field' => 'f.last_comment_timestamp', 'sort' => 'asc'); break; case 3: - return array('field' => 'ncs.comment_count', 'sort' => 'desc'); + return array('field' => 'f.comment_count', 'sort' => 'desc'); break; case 4: - return array('field' => 'ncs.comment_count', 'sort' => 'asc'); + return array('field' => 'f.comment_count', 'sort' => 'asc'); break; } } diff --git a/modules/forum/forum.pages.inc b/modules/forum/forum.pages.inc index 02c780136..29307e719 100644 --- a/modules/forum/forum.pages.inc +++ b/modules/forum/forum.pages.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/forum/forum.test b/modules/forum/forum.test index d1fe188dd..1dc45c6fd 100644 --- a/modules/forum/forum.test +++ b/modules/forum/forum.test @@ -1,5 +1,9 @@ <?php -// $Id$ + +/** + * @file + * Tests for forum.module. + */ class ForumTestCase extends DrupalWebTestCase { protected $admin_user; diff --git a/modules/forum/forums.tpl.php b/modules/forum/forums.tpl.php index 2c9e2efa0..55a760f57 100644 --- a/modules/forum/forums.tpl.php +++ b/modules/forum/forums.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file |