- Patch #225562 by Jody Lynn: change DB table names from eg. term_data to taxonomy_term_data.
parent
b986cc556d
commit
b86354c55c
|
@ -2539,7 +2539,7 @@ function db_affected_rows() {
|
|||
* @param $primary_table
|
||||
* Name or alias of the table which has the primary key field for this query.
|
||||
* Typical table names would be: {block}, {comment}, {forum}, {node},
|
||||
* {menu}, {term_data} or {vocabulary}. However, in most cases the usual
|
||||
* {menu}, {taxonomy_term_data} or {taxonomy_vocabulary}. However, in most cases the usual
|
||||
* table alias (b, c, f, n, m, t or v) is used instead of the table name.
|
||||
* @param $primary_field
|
||||
* Name of the primary field.
|
||||
|
@ -2586,7 +2586,7 @@ function _db_rewrite_sql($query = '', $primary_table = 'n', $primary_field = 'ni
|
|||
* @param $primary_table
|
||||
* Name or alias of the table which has the primary key field for this query.
|
||||
* Typical table names would be: {block}, {comment}, {forum}, {node},
|
||||
* {menu}, {term_data} or {vocabulary}. However, it is more common to use the
|
||||
* {menu}, {taxonomy_term_data} or {taxonomy_vocabulary}. However, it is more common to use the
|
||||
* the usual table aliases: b, c, f, n, m, t or v.
|
||||
* @param $primary_field
|
||||
* Name of the primary field.
|
||||
|
|
|
@ -584,7 +584,7 @@ function blogapi_mt_validate_terms($node) {
|
|||
$term_list = array_unique($node->taxonomy);
|
||||
$params = $term_list;
|
||||
$params[] = $node->type;
|
||||
$result = db_query(db_rewrite_sql("SELECT t.tid, t.vid FROM {term_data} t INNER JOIN {vocabulary_node_type} n ON t.vid = n.vid WHERE t.tid IN (". db_placeholders($term_list) .") AND n.type = '%s'", 't', 'tid'), $params);
|
||||
$result = db_query(db_rewrite_sql("SELECT t.tid, t.vid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_vocabulary_node_type} n ON t.vid = n.vid WHERE t.tid IN (". db_placeholders($term_list) .") AND n.type = '%s'", 't', 'tid'), $params);
|
||||
$found_terms = array();
|
||||
$found_count = 0;
|
||||
while ($term = db_fetch_object($result)) {
|
||||
|
@ -597,7 +597,7 @@ function blogapi_mt_validate_terms($node) {
|
|||
}
|
||||
}
|
||||
// Look up all the vocabularies for this node type.
|
||||
$result2 = db_query(db_rewrite_sql("SELECT v.vid, v.name, v.required, v.multiple FROM {vocabulary} v INNER JOIN {vocabulary_node_type} n ON v.vid = n.vid WHERE n.type = '%s'", 'v', 'vid'), $node->type);
|
||||
$result2 = db_query(db_rewrite_sql("SELECT v.vid, v.name, v.required, v.multiple FROM {taxonomy_vocabulary} v INNER JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid WHERE n.type = '%s'", 'v', 'vid'), $node->type);
|
||||
// Check each vocabulary associated with this node type.
|
||||
while ($vocabulary = db_fetch_object($result2)) {
|
||||
// Required vocabularies must have at least one term.
|
||||
|
|
|
@ -86,7 +86,7 @@ function forum_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {term_data}.tid of the forum term assigned to the node.',
|
||||
'description' => 'The {taxonomy_term_data}.tid of the forum term assigned to the node.',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
|
|
|
@ -74,7 +74,7 @@ function forum_theme() {
|
|||
* An associative array containing the term data or FALSE if the term cannot be loaded, or is not part of the forum vocabulary.
|
||||
*/
|
||||
function forum_term_load($tid) {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.vid, t.name, t.description, t.weight FROM {term_data} t WHERE t.tid = %d AND t.vid = %d', 't', 'tid'), $tid, variable_get('forum_nav_vocabulary', ''));
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.vid, t.name, t.description, t.weight FROM {taxonomy_term_data} t WHERE t.tid = %d AND t.vid = %d', 't', 'tid'), $tid, variable_get('forum_nav_vocabulary', ''));
|
||||
return db_fetch_array($result);
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ function forum_nodeapi_validate($node, $form) {
|
|||
$vocabulary = $vid;
|
||||
$containers = variable_get('forum_containers', array());
|
||||
foreach ($node->taxonomy as $term) {
|
||||
if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
|
||||
if (db_result(db_query('SELECT COUNT(*) FROM {taxonomy_term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
|
||||
if (in_array($term, $containers)) {
|
||||
$term = taxonomy_term_load($term);
|
||||
form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
|
||||
|
@ -283,7 +283,7 @@ function forum_nodeapi_presave($node) {
|
|||
$node->tid = $term_id;
|
||||
}
|
||||
}
|
||||
$old_tid = db_result(db_query_range("SELECT t.tid FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1));
|
||||
$old_tid = db_result(db_query_range("SELECT t.tid FROM {taxonomy_term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1));
|
||||
if ($old_tid && isset($node->tid) && ($node->tid != $old_tid) && !empty($node->shadow)) {
|
||||
// A shadow copy needs to be created. Retain new term and add old term.
|
||||
$node->taxonomy[] = $old_tid;
|
||||
|
@ -414,7 +414,7 @@ function forum_taxonomy($op, $type, $term = NULL) {
|
|||
if ($op == 'delete' && $term['vid'] == variable_get('forum_nav_vocabulary', '')) {
|
||||
switch ($type) {
|
||||
case 'term':
|
||||
$results = db_query('SELECT tn.nid FROM {term_node} tn WHERE tn.tid = %d', $term['tid']);
|
||||
$results = db_query('SELECT tn.nid FROM {taxonomy_term_node} tn WHERE tn.tid = %d', $term['tid']);
|
||||
while ($node = db_fetch_object($results)) {
|
||||
// node_delete will also remove any association with non-forum vocabularies.
|
||||
node_delete($node->nid);
|
||||
|
@ -503,8 +503,8 @@ function forum_block_view($delta = '') {
|
|||
case 'active':
|
||||
$title = t('Active forum topics');
|
||||
$query = db_select('node', 'n');
|
||||
$tn_alias = $query->join('term_node', 'tn', 'tn.vid = n.vid');
|
||||
$td_alias = $query->join('term_data', 'td', 'tn.tid = tn.tid');
|
||||
$tn_alias = $query->join('taxonomy_term_node', 'tn', 'tn.vid = n.vid');
|
||||
$td_alias = $query->join('taxonomy_term_data', 'td', 'tn.tid = tn.tid');
|
||||
$l_alias = $query->join('node_comment_statistics', 'l', 'n.nid = l.nid');
|
||||
$query->addField('n', 'nid', 'nid');
|
||||
$query->addField('n', 'title', 'title');
|
||||
|
@ -521,7 +521,7 @@ function forum_block_view($delta = '') {
|
|||
|
||||
case 'new':
|
||||
$title = t('New forum topics');
|
||||
$sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY n.nid DESC");
|
||||
$sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {taxonomy_term_node} tn ON tn.vid = n.vid INNER JOIN {taxonomy_term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY n.nid DESC");
|
||||
$result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_new', '5'));
|
||||
$content = node_title_list($result);
|
||||
break;
|
||||
|
@ -588,7 +588,7 @@ function forum_get_forums($tid = 0) {
|
|||
|
||||
$counts = array();
|
||||
|
||||
$sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.vid = r.vid WHERE n.status = 1 GROUP BY r.tid";
|
||||
$sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {taxonomy_term_node} r ON n.vid = r.vid WHERE n.status = 1 GROUP BY r.tid";
|
||||
$sql = db_rewrite_sql($sql);
|
||||
$_counts = db_query($sql);
|
||||
while ($count = db_fetch_object($_counts)) {
|
||||
|
@ -613,7 +613,7 @@ function forum_get_forums($tid = 0) {
|
|||
// This query does not use full ANSI syntax since MySQL 3.x does not support
|
||||
// table1 INNER JOIN table2 INNER JOIN table3 ON table2_criteria ON table3_criteria
|
||||
// used to join node_comment_statistics to users.
|
||||
$sql = "SELECT ncs.last_comment_timestamp, IF (ncs.last_comment_uid != 0, u2.name, ncs.last_comment_name) AS last_comment_name, ncs.last_comment_uid FROM {node} n INNER JOIN {users} u1 ON n.uid = u1.uid INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {users} u2 ON ncs.last_comment_uid=u2.uid WHERE n.status = 1 AND tn.tid = %d ORDER BY ncs.last_comment_timestamp DESC";
|
||||
$sql = "SELECT ncs.last_comment_timestamp, IF (ncs.last_comment_uid != 0, u2.name, ncs.last_comment_name) AS last_comment_name, ncs.last_comment_uid FROM {node} n INNER JOIN {users} u1 ON n.uid = u1.uid INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {users} u2 ON ncs.last_comment_uid=u2.uid WHERE n.status = 1 AND tn.tid = %d ORDER BY ncs.last_comment_timestamp DESC";
|
||||
$sql = db_rewrite_sql($sql);
|
||||
$topic = db_fetch_object(db_query_range($sql, $forum->tid, 0, 1));
|
||||
|
||||
|
@ -636,7 +636,7 @@ function forum_get_forums($tid = 0) {
|
|||
* than NODE_NEW_LIMIT.
|
||||
*/
|
||||
function _forum_topics_unread($term, $uid) {
|
||||
$sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid AND tn.tid = %d LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.created > %d AND h.nid IS NULL";
|
||||
$sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid AND tn.tid = %d LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.created > %d AND h.nid IS NULL";
|
||||
$sql = db_rewrite_sql($sql);
|
||||
return db_result(db_query($sql, $term, $uid, NODE_NEW_LIMIT));
|
||||
}
|
||||
|
@ -659,11 +659,11 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
|
|||
}
|
||||
}
|
||||
|
||||
$sql = db_rewrite_sql("SELECT n.nid, r.tid, n.title, n.type, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments, f.tid AS forum_tid FROM {node_comment_statistics} l INNER JOIN {node} n ON n.nid = l.nid INNER JOIN {users} cu ON l.last_comment_uid = cu.uid INNER JOIN {term_node} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {forum} f ON n.vid = f.vid WHERE n.status = 1 AND r.tid = %d");
|
||||
$sql = db_rewrite_sql("SELECT n.nid, r.tid, n.title, n.type, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments, f.tid AS forum_tid FROM {node_comment_statistics} l INNER JOIN {node} n ON n.nid = l.nid INNER JOIN {users} cu ON l.last_comment_uid = cu.uid INNER JOIN {taxonomy_term_node} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {forum} f ON n.vid = f.vid WHERE n.status = 1 AND r.tid = %d");
|
||||
$sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,');
|
||||
$sql .= ', n.created DESC'; // Always add a secondary sort order so that the news forum topics are on top.
|
||||
|
||||
$sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.vid = r.vid AND r.tid = %d WHERE n.status = 1");
|
||||
$sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {taxonomy_term_node} r ON n.vid = r.vid AND r.tid = %d WHERE n.status = 1");
|
||||
|
||||
$result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid);
|
||||
$topics = array();
|
||||
|
@ -954,7 +954,7 @@ function template_preprocess_forum_topic_navigation(&$variables) {
|
|||
$output = '';
|
||||
|
||||
// get previous and next topic
|
||||
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 ORDER BY n.sticky DESC, " . _forum_get_topic_order_sql(variable_get('forum_order', 1));
|
||||
$sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {taxonomy_term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 ORDER BY n.sticky DESC, " . _forum_get_topic_order_sql(variable_get('forum_order', 1));
|
||||
$result = db_query(db_rewrite_sql($sql), isset($variables['node']->tid) ? $variables['node']->tid : 0);
|
||||
|
||||
$stop = $variables['prev'] = $variables['next'] = 0;
|
||||
|
|
|
@ -149,7 +149,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
*
|
||||
* @param string $type Forum type (forum container or forum).
|
||||
* @param integer $parent Forum parent (default = 0 = a root forum; >0 = a forum container or another forum).
|
||||
* @return object Term_data created.
|
||||
* @return object Taxonomy_term_data created.
|
||||
*/
|
||||
function createForum($type, $parent = 0) {
|
||||
// Generate a random name/description.
|
||||
|
@ -170,12 +170,12 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
$this->assertRaw(t('Created new @type %term.', array('%term' => $name, '@type' => t($type))), t(ucfirst($type) . ' was created'));
|
||||
|
||||
// Verify forum.
|
||||
$term = db_fetch_array(db_query("SELECT * FROM {term_data} t WHERE t.vid = %d AND t.name = '%s' AND t.description = '%s'", variable_get('forum_nav_vocabulary', ''), $name, $description));
|
||||
$term = db_fetch_array(db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = %d AND t.name = '%s' AND t.description = '%s'", variable_get('forum_nav_vocabulary', ''), $name, $description));
|
||||
$this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');
|
||||
|
||||
// Verify forum hierarchy.
|
||||
$tid = $term['tid'];
|
||||
$parent_tid = db_result(db_query("SELECT t.parent FROM {term_hierarchy} t WHERE t.tid = %d", $tid));
|
||||
$parent_tid = db_result(db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = %d", $tid));
|
||||
$this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container');
|
||||
|
||||
return $term;
|
||||
|
@ -322,7 +322,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
/**
|
||||
* Verify display of forum page.
|
||||
*
|
||||
* @param array $forum Forum array (a row from term_data table).
|
||||
* @param array $forum Forum array (a row from taxonomy_term_data table).
|
||||
*/
|
||||
private function verifyForumView($forum, $parent = NULL) {
|
||||
$crumb = '›';
|
||||
|
@ -342,7 +342,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
|||
/**
|
||||
* Generate forum topics to test display of active forum block.
|
||||
*
|
||||
* @param array $forum Forum array (a row from term_data table).
|
||||
* @param array $forum Forum array (a row from taxonomy_term_data table).
|
||||
*/
|
||||
private function generateForumTopics($forum) {
|
||||
$this->nids = array();
|
||||
|
|
|
@ -184,7 +184,7 @@ function node_build_filter_query() {
|
|||
case 'term':
|
||||
$table = "tn$index";
|
||||
$where[] = "$table.tid = %d";
|
||||
$join .= "INNER JOIN {term_node} $table ON n.nid = $table.nid ";
|
||||
$join .= "INNER JOIN {taxonomy_term_node} $table ON n.nid = $table.nid ";
|
||||
break;
|
||||
case 'type':
|
||||
$where[] = "n.type = '%s'";
|
||||
|
|
|
@ -1373,7 +1373,7 @@ function node_search($op = 'search', $keys = NULL) {
|
|||
$arguments1[] = $c;
|
||||
}
|
||||
$conditions1 .= ' AND (' . implode(' OR ', $terms) . ')';
|
||||
$join1 .= ' INNER JOIN {term_node} tn ON n.vid = tn.vid';
|
||||
$join1 .= ' INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid';
|
||||
$keys = search_query_insert($keys, 'term');
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ function hook_search($op = 'search', $keys = null) {
|
|||
$arguments1[] = $c;
|
||||
}
|
||||
$conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
|
||||
$join1 .= ' INNER JOIN {term_node} tn ON n.vid = tn.vid';
|
||||
$join1 .= ' INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid';
|
||||
$keys = search_query_insert($keys, 'category');
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ function taxonomy_test_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {term_data}.tid of the term.',
|
||||
'description' => 'The {taxonomy_term_data}.tid of the term.',
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
|
|
|
@ -41,7 +41,7 @@ function hook_cron() {
|
|||
* shall be made DISTINCT. For node objects, primary field is always called nid.
|
||||
* For taxonomy terms, it is tid and for vocabularies it is vid. For comments,
|
||||
* it is cid. Primary table is the table where the primary object (node, file,
|
||||
* term_node etc.) is.
|
||||
* taxonomy_term_node etc.) is.
|
||||
*
|
||||
* You shall return an associative array. Possible keys are 'join', 'where' and
|
||||
* 'distinct'. The value of 'distinct' shall be 1 if you want that the
|
||||
|
@ -52,7 +52,7 @@ function hook_cron() {
|
|||
* @param $primary_table
|
||||
* Name or alias of the table which has the primary key field for this query.
|
||||
* Typical table names would be: {block}, {comment}, {forum}, {node},
|
||||
* {menu}, {term_data} or {vocabulary}. However, it is more common for
|
||||
* {menu}, {taxonomy_term_data} or {taxonomy_vocabulary}. However, it is more common for
|
||||
* $primary_table to contain the usual table alias: b, c, f, n, m, t or v.
|
||||
* @param $primary_field
|
||||
* Name of the primary field.
|
||||
|
|
|
@ -271,8 +271,8 @@ function taxonomy_overview_terms(&$form_state, $vocabulary) {
|
|||
if ($vocabulary->tags) {
|
||||
// We are not calling taxonomy_get_tree because that might fail with a big
|
||||
// number of tags in the freetagging vocabulary.
|
||||
$results = pager_query(db_rewrite_sql('SELECT t.*, h.parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $page_increment, 0, NULL, $vocabulary->vid);
|
||||
$total_entries = db_query(db_rewrite_sql('SELECT count(*) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = :vid'), array(':vid' => $vocabulary->vid));
|
||||
$results = pager_query(db_rewrite_sql('SELECT t.*, h.parent FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $page_increment, 0, NULL, $vocabulary->vid);
|
||||
$total_entries = db_query(db_rewrite_sql('SELECT count(*) FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE t.vid = :vid'), array(':vid' => $vocabulary->vid));
|
||||
while ($term = db_fetch_object($results)) {
|
||||
$key = 'tid:' . $term->tid . ':0';
|
||||
$current_page[$key] = $term;
|
||||
|
@ -909,7 +909,7 @@ function taxonomy_vocabulary_confirm_reset_alphabetical(&$form_state, $vid) {
|
|||
* @see taxonomy_vocabulary_confirm_reset_alphabetical()
|
||||
*/
|
||||
function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state) {
|
||||
db_query('UPDATE {term_data} SET weight = 0 WHERE vid = :vid', array(':vid' => $form_state['values']['vid']));
|
||||
db_query('UPDATE {taxonomy_term_data} SET weight = 0 WHERE vid = :vid', array(':vid' => $form_state['values']['vid']));
|
||||
drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name'])));
|
||||
watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
|
||||
$form_state['redirect'] = 'admin/content/taxonomy/' . $form_state['values']['vid'];
|
||||
|
|
|
@ -78,7 +78,7 @@ function hook_taxonomy_vocabulary_delete($vocabulary) {
|
|||
* loaded in a single query for all terms where possible.
|
||||
*
|
||||
* Since terms are stored and retrieved from cache during a page request, avoid
|
||||
* altering properties provided by the {term_data} table, since this may
|
||||
* altering properties provided by the {taxonomy_term_data} table, since this may
|
||||
* affect the way results are loaded from cache in subsequent calls.
|
||||
*
|
||||
* @param $terms
|
||||
|
@ -104,7 +104,7 @@ function hook_taxonomy_term_insert($term) {
|
|||
if (!empty($term->synonyms)) {
|
||||
foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
|
||||
if ($synonym) {
|
||||
db_insert('term_synonym')
|
||||
db_insert('taxonomy_term_synonym')
|
||||
->fields(array(
|
||||
'tid' => $term->tid,
|
||||
'name' => rtrim($synonym),
|
||||
|
@ -128,7 +128,7 @@ function hook_taxonomy_term_update($term) {
|
|||
if (!empty($term->synonyms)) {
|
||||
foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
|
||||
if ($synonym) {
|
||||
db_insert('term_synonym')
|
||||
db_insert('taxonomy_term_synonym')
|
||||
->fields(array(
|
||||
'tid' => $term->tid,
|
||||
'name' => rtrim($synonym),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Implementation of hook_schema().
|
||||
*/
|
||||
function taxonomy_schema() {
|
||||
$schema['term_data'] = array(
|
||||
$schema['taxonomy_term_data'] = array(
|
||||
'description' => 'Stores term information.',
|
||||
'fields' => array(
|
||||
'tid' => array(
|
||||
|
@ -19,7 +19,7 @@ function taxonomy_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {vocabulary}.vid of the vocabulary to which the term is assigned.',
|
||||
'description' => 'The {taxonomy_vocabulary}.vid of the vocabulary to which the term is assigned.',
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
|
@ -49,7 +49,7 @@ function taxonomy_schema() {
|
|||
),
|
||||
);
|
||||
|
||||
$schema['term_hierarchy'] = array(
|
||||
$schema['taxonomy_term_hierarchy'] = array(
|
||||
'description' => 'Stores the hierarchical relationship between terms.',
|
||||
'fields' => array(
|
||||
'tid' => array(
|
||||
|
@ -57,14 +57,14 @@ function taxonomy_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'Primary Key: The {term_data}.tid of the term.',
|
||||
'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.',
|
||||
),
|
||||
'parent' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => "Primary Key: The {term_data}.tid of the term's parent. 0 indicates no parent.",
|
||||
'description' => "Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0 indicates no parent.",
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
|
@ -73,7 +73,7 @@ function taxonomy_schema() {
|
|||
'primary key' => array('tid', 'parent'),
|
||||
);
|
||||
|
||||
$schema['term_node'] = array(
|
||||
$schema['taxonomy_term_node'] = array(
|
||||
'description' => 'Stores the relationship of terms to nodes.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
|
@ -95,7 +95,7 @@ function taxonomy_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'Primary Key: The {term_data}.tid of a term assigned to the node.',
|
||||
'description' => 'Primary Key: The {taxonomy_term_data}.tid of a term assigned to the node.',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
|
@ -105,7 +105,7 @@ function taxonomy_schema() {
|
|||
'primary key' => array('tid', 'vid'),
|
||||
);
|
||||
|
||||
$schema['term_relation'] = array(
|
||||
$schema['taxonomy_term_relation'] = array(
|
||||
'description' => 'Stores non-hierarchical relationships between terms.',
|
||||
'fields' => array(
|
||||
'trid' => array(
|
||||
|
@ -118,14 +118,14 @@ function taxonomy_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {term_data}.tid of the first term in a relationship.',
|
||||
'description' => 'The {taxonomy_term_data}.tid of the first term in a relationship.',
|
||||
),
|
||||
'tid2' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {term_data}.tid of the second term in a relationship.',
|
||||
'description' => 'The {taxonomy_term_data}.tid of the second term in a relationship.',
|
||||
),
|
||||
),
|
||||
'unique keys' => array(
|
||||
|
@ -137,7 +137,7 @@ function taxonomy_schema() {
|
|||
'primary key' => array('trid'),
|
||||
);
|
||||
|
||||
$schema['term_synonym'] = array(
|
||||
$schema['taxonomy_term_synonym'] = array(
|
||||
'description' => 'Stores term synonyms.',
|
||||
'fields' => array(
|
||||
'tsid' => array(
|
||||
|
@ -150,7 +150,7 @@ function taxonomy_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {term_data}.tid of the term.',
|
||||
'description' => 'The {taxonomy_term_data}.tid of the term.',
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
|
@ -167,7 +167,7 @@ function taxonomy_schema() {
|
|||
'primary key' => array('tsid'),
|
||||
);
|
||||
|
||||
$schema['vocabulary'] = array(
|
||||
$schema['taxonomy_vocabulary'] = array(
|
||||
'description' => 'Stores vocabulary information.',
|
||||
'fields' => array(
|
||||
'vid' => array(
|
||||
|
@ -257,7 +257,7 @@ function taxonomy_schema() {
|
|||
),
|
||||
);
|
||||
|
||||
$schema['vocabulary_node_type'] = array(
|
||||
$schema['taxonomy_vocabulary_node_type'] = array(
|
||||
'description' => 'Stores which node types vocabularies may be used with.',
|
||||
'fields' => array(
|
||||
'vid' => array(
|
||||
|
@ -265,7 +265,7 @@ function taxonomy_schema() {
|
|||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'Primary Key: the {vocabulary}.vid of the vocabulary.',
|
||||
'description' => 'Primary Key: the {taxonomy_vocabulary}.vid of the vocabulary.',
|
||||
),
|
||||
'type' => array(
|
||||
'type' => 'varchar',
|
||||
|
@ -285,10 +285,17 @@ function taxonomy_schema() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Rename {vocabulary_node_types} table to {vocabulary_node_type}.
|
||||
* Rename taxonomy tables.
|
||||
*/
|
||||
function taxonomy_update_7001() {
|
||||
$ret = array();
|
||||
db_rename_table($ret, 'vocabulary_node_types', 'vocabulary_node_type');
|
||||
db_rename_table($ret, 'term_data', 'taxonomy_term_data');
|
||||
db_rename_table($ret, 'term_hierarchy', 'taxonomy_term_hierarchy');
|
||||
db_rename_table($ret, 'term_node', 'taxonomy_term_node');
|
||||
db_rename_table($ret, 'term_relation', 'taxonomy_term_relation');
|
||||
db_rename_table($ret, 'term_synonym', 'taxonomy_term_synonym');
|
||||
db_rename_table($ret, 'vocabulary', 'taxonomy_vocabulary');
|
||||
db_rename_table($ret, 'vocabulary_node_types', 'taxonomy_vocabulary_node_type');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -214,17 +214,17 @@ function taxonomy_vocabulary_save($vocabulary) {
|
|||
}
|
||||
|
||||
if (!empty($vocabulary->vid) && !empty($vocabulary->name)) {
|
||||
$status = drupal_write_record('vocabulary', $vocabulary, 'vid');
|
||||
db_query("DELETE FROM {vocabulary_node_type} WHERE vid = %d", $vocabulary->vid);
|
||||
$status = drupal_write_record('taxonomy_vocabulary', $vocabulary, 'vid');
|
||||
db_query("DELETE FROM {taxonomy_vocabulary_node_type} WHERE vid = %d", $vocabulary->vid);
|
||||
foreach ($vocabulary->nodes as $type => $selected) {
|
||||
db_query("INSERT INTO {vocabulary_node_type} (vid, type) VALUES (%d, '%s')", $vocabulary->vid, $type);
|
||||
db_query("INSERT INTO {taxonomy_vocabulary_node_type} (vid, type) VALUES (%d, '%s')", $vocabulary->vid, $type);
|
||||
}
|
||||
module_invoke_all('taxonomy_vocabulary_update', $vocabulary);
|
||||
}
|
||||
elseif (empty($vocabulary->vid)) {
|
||||
$status = drupal_write_record('vocabulary', $vocabulary);
|
||||
$status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
|
||||
foreach ($vocabulary->nodes as $type => $selected) {
|
||||
db_query("INSERT INTO {vocabulary_node_type} (vid, type) VALUES (%d, '%s')", $vocabulary->vid, $type);
|
||||
db_query("INSERT INTO {taxonomy_vocabulary_node_type} (vid, type) VALUES (%d, '%s')", $vocabulary->vid, $type);
|
||||
}
|
||||
module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
|
||||
}
|
||||
|
@ -245,9 +245,9 @@ function taxonomy_vocabulary_save($vocabulary) {
|
|||
function taxonomy_vocabulary_delete($vid) {
|
||||
$vocabulary = (array) taxonomy_vocabulary_load($vid);
|
||||
|
||||
db_query('DELETE FROM {vocabulary} WHERE vid = %d', $vid);
|
||||
db_query('DELETE FROM {vocabulary_node_type} WHERE vid = %d', $vid);
|
||||
$result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid);
|
||||
db_query('DELETE FROM {taxonomy_vocabulary} WHERE vid = %d', $vid);
|
||||
db_query('DELETE FROM {taxonomy_vocabulary_node_type} WHERE vid = %d', $vid);
|
||||
$result = db_query('SELECT tid FROM {taxonomy_term_data} WHERE vid = %d', $vid);
|
||||
while ($term = db_fetch_object($result)) {
|
||||
taxonomy_term_delete($term->tid);
|
||||
}
|
||||
|
@ -315,25 +315,25 @@ function taxonomy_term_save($term) {
|
|||
}
|
||||
|
||||
if (!empty($term->tid) && $term->name) {
|
||||
$status = drupal_write_record('term_data', $term, 'tid');
|
||||
$status = drupal_write_record('taxonomy_term_data', $term, 'tid');
|
||||
module_invoke_all('taxonomy_term_insert', $term);
|
||||
}
|
||||
else {
|
||||
$status = drupal_write_record('term_data', $term);
|
||||
$status = drupal_write_record('taxonomy_term_data', $term);
|
||||
module_invoke_all('taxonomy_term_update', $term);
|
||||
}
|
||||
|
||||
$or = db_or()->condition('tid1', $term->tid)->condition('tid2', $term->tid);
|
||||
db_delete('term_relation')->condition($or)->execute();
|
||||
db_delete('taxonomy_term_relation')->condition($or)->execute();
|
||||
|
||||
if (!empty($term->relations)) {
|
||||
foreach ($term->relations as $related_id) {
|
||||
if ($related_id != 0) {
|
||||
db_insert('term_relation')->fields(array('tid1' => $term->tid, 'tid2' => $related_id))->execute();
|
||||
db_insert('taxonomy_term_relation')->fields(array('tid1' => $term->tid, 'tid2' => $related_id))->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
db_delete('term_hierarchy')->condition('tid', $term->tid)->execute();
|
||||
db_delete('taxonomy_term_hierarchy')->condition('tid', $term->tid)->execute();
|
||||
|
||||
if (!isset($term->parent) || empty($term->parent)) {
|
||||
$term->parent = array(0);
|
||||
|
@ -342,23 +342,23 @@ function taxonomy_term_save($term) {
|
|||
foreach ($term->parent as $parent) {
|
||||
if (is_array($parent)) {
|
||||
foreach ($parent as $tid) {
|
||||
db_insert('term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $tid))->execute();
|
||||
db_insert('taxonomy_term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $tid))->execute();
|
||||
}
|
||||
}
|
||||
else {
|
||||
db_insert('term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $parent))->execute();
|
||||
db_insert('taxonomy_term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $parent))->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
db_insert('term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $term->parent))->execute();
|
||||
db_insert('taxonomy_term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $term->parent))->execute();
|
||||
}
|
||||
|
||||
db_delete('term_synonym')->condition('tid', $term->tid)->execute();
|
||||
db_delete('taxonomy_term_synonym')->condition('tid', $term->tid)->execute();
|
||||
if (!empty($term->synonyms)) {
|
||||
foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
|
||||
if ($synonym) {
|
||||
db_insert('term_synonym')->fields(array('tid' => $term->tid, 'name' => rtrim($synonym)))->execute();
|
||||
db_insert('taxonomy_term_synonym')->fields(array('tid' => $term->tid, 'name' => rtrim($synonym)))->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,11 +394,11 @@ function taxonomy_term_delete($tid) {
|
|||
|
||||
$term = taxonomy_term_load($tid);
|
||||
|
||||
db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid);
|
||||
db_query('DELETE FROM {term_synonym} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {term_node} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {taxonomy_term_data} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {taxonomy_term_hierarchy} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {taxonomy_term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid);
|
||||
db_query('DELETE FROM {taxonomy_term_synonym} WHERE tid = %d', $tid);
|
||||
db_query('DELETE FROM {taxonomy_term_node} WHERE tid = %d', $tid);
|
||||
|
||||
module_invoke_all('taxonomy_term_delete', $term);
|
||||
}
|
||||
|
@ -457,10 +457,10 @@ function taxonomy_form_all($free_tags = 0) {
|
|||
*/
|
||||
function taxonomy_get_vocabularies($type = NULL) {
|
||||
if ($type) {
|
||||
$result = db_query(db_rewrite_sql("SELECT v.vid, v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_type} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $type);
|
||||
$result = db_query(db_rewrite_sql("SELECT v.vid, v.*, n.type FROM {taxonomy_vocabulary} v LEFT JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $type);
|
||||
}
|
||||
else {
|
||||
$result = db_query(db_rewrite_sql('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_type} n ON v.vid = n.vid ORDER BY v.weight, v.name', 'v', 'vid'));
|
||||
$result = db_query(db_rewrite_sql('SELECT v.*, n.type FROM {taxonomy_vocabulary} v LEFT JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid ORDER BY v.weight, v.name', 'v', 'vid'));
|
||||
}
|
||||
|
||||
$vocabularies = array();
|
||||
|
@ -504,7 +504,7 @@ function taxonomy_form_alter(&$form, $form_state, $form_id) {
|
|||
$terms = $node->taxonomy;
|
||||
}
|
||||
|
||||
$c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_type} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
|
||||
$c = db_query(db_rewrite_sql("SELECT v.* FROM {taxonomy_vocabulary} v INNER JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
|
||||
|
||||
while ($vocabulary = db_fetch_object($c)) {
|
||||
if ($vocabulary->tags) {
|
||||
|
@ -602,7 +602,7 @@ function taxonomy_preview_terms($node) {
|
|||
* Find all terms associated with the given node, within one vocabulary.
|
||||
*/
|
||||
function taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid') {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.vid = %d ORDER BY weight', 't', 'tid'), $vid, $node->vid);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.vid = %d ORDER BY weight', 't', 'tid'), $vid, $node->vid);
|
||||
$terms = array();
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$terms[$term->$key] = $term;
|
||||
|
@ -624,10 +624,10 @@ function taxonomy_get_tids_from_nodes($nodes) {
|
|||
foreach ($nodes as $node) {
|
||||
$node_vids[] = $node->vid;
|
||||
}
|
||||
$query = db_select('term_node', 'r');
|
||||
$query = db_select('taxonomy_term_node', 'r');
|
||||
$query->fields('r', array('tid', 'nid', 'vid'));
|
||||
$query->join('term_data', 't', 'r.tid = t.tid');
|
||||
$query->join('vocabulary', 'v', 't.vid = v.vid');
|
||||
$query->join('taxonomy_term_data', 't', 'r.tid = t.tid');
|
||||
$query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid');
|
||||
$query->condition('r.vid', $node_vids, 'IN');
|
||||
$query->orderBy('v.weight');
|
||||
$query->orderBy('t.weight');
|
||||
|
@ -644,7 +644,7 @@ function taxonomy_node_get_terms($node, $key = 'tid') {
|
|||
static $terms;
|
||||
|
||||
if (!isset($terms[$node->vid][$key])) {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->vid);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.* FROM {taxonomy_term_node} r INNER JOIN {taxonomy_term_data} t ON r.tid = t.tid INNER JOIN {taxonomy_vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->vid);
|
||||
$terms[$node->vid][$key] = array();
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$terms[$node->vid][$key][$term->$key] = $term;
|
||||
|
@ -690,7 +690,7 @@ function taxonomy_node_save($node, $terms) {
|
|||
|
||||
// Defend against duplicate, differently cased tags
|
||||
if (!isset($inserted[$typed_term_tid])) {
|
||||
db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $typed_term_tid);
|
||||
db_query('INSERT INTO {taxonomy_term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $typed_term_tid);
|
||||
$inserted[$typed_term_tid] = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -702,15 +702,15 @@ function taxonomy_node_save($node, $terms) {
|
|||
if (is_array($term)) {
|
||||
foreach ($term as $tid) {
|
||||
if ($tid) {
|
||||
db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $tid);
|
||||
db_query('INSERT INTO {taxonomy_term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (is_object($term)) {
|
||||
db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term->tid);
|
||||
db_query('INSERT INTO {taxonomy_term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term->tid);
|
||||
}
|
||||
elseif ($term) {
|
||||
db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term);
|
||||
db_query('INSERT INTO {taxonomy_term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -721,10 +721,10 @@ function taxonomy_node_save($node, $terms) {
|
|||
*/
|
||||
function taxonomy_node_type($op, $info) {
|
||||
if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
|
||||
db_query("UPDATE {vocabulary_node_type} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type);
|
||||
db_query("UPDATE {taxonomy_vocabulary_node_type} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type);
|
||||
}
|
||||
elseif ($op == 'delete') {
|
||||
db_query("DELETE FROM {vocabulary_node_type} WHERE type = '%s'", $info->type);
|
||||
db_query("DELETE FROM {taxonomy_vocabulary_node_type} WHERE type = '%s'", $info->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -733,7 +733,7 @@ function taxonomy_node_type($op, $info) {
|
|||
*/
|
||||
function taxonomy_get_related($tid, $key = 'tid') {
|
||||
if ($tid) {
|
||||
$result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
|
||||
$result = db_query('SELECT t.*, tid1, tid2 FROM {taxonomy_term_relation}, {taxonomy_term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
|
||||
$related = array();
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$related[$term->$key] = $term;
|
||||
|
@ -750,7 +750,7 @@ function taxonomy_get_related($tid, $key = 'tid') {
|
|||
*/
|
||||
function taxonomy_get_parents($tid, $key = 'tid') {
|
||||
if ($tid) {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid);
|
||||
$parents = array();
|
||||
while ($parent = db_fetch_object($result)) {
|
||||
$parents[$parent->$key] = $parent;
|
||||
|
@ -783,10 +783,10 @@ function taxonomy_get_parents_all($tid) {
|
|||
*/
|
||||
function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
|
||||
if ($vid) {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE t.vid = %d AND h.parent = %d ORDER BY weight, name', 't', 'tid'), $vid, $tid);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.* FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON h.tid = t.tid WHERE t.vid = %d AND h.parent = %d ORDER BY weight, name', 't', 'tid'), $vid, $tid);
|
||||
}
|
||||
else {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE parent = %d ORDER BY weight, name', 't', 'tid'), $tid);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.* FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON h.tid = t.tid WHERE parent = %d ORDER BY weight, name', 't', 'tid'), $tid);
|
||||
}
|
||||
$children = array();
|
||||
while ($term = db_fetch_object($result)) {
|
||||
|
@ -826,7 +826,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) {
|
|||
if (!isset($children[$vid])) {
|
||||
$children[$vid] = array();
|
||||
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.*, parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $vid);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.*, parent FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $vid);
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$children[$vid][$term->parent][] = $term->tid;
|
||||
$parents[$vid][$term->tid][] = $term->parent;
|
||||
|
@ -862,7 +862,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) {
|
|||
function taxonomy_get_synonyms($tid) {
|
||||
if ($tid) {
|
||||
$synonyms = array();
|
||||
$result = db_query('SELECT name FROM {term_synonym} WHERE tid = %d', $tid);
|
||||
$result = db_query('SELECT name FROM {taxonomy_term_synonym} WHERE tid = %d', $tid);
|
||||
while ($synonym = db_fetch_array($result)) {
|
||||
$synonyms[] = $synonym['name'];
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ function taxonomy_get_synonym_root($synonym, $reset = FALSE) {
|
|||
}
|
||||
|
||||
if (!isset($synonyms[$synonym])) {
|
||||
$synonyms[$synonym] = db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = :name", array(':name' => $synonym))->fetch();
|
||||
$synonyms[$synonym] = db_query("SELECT * FROM {taxonomy_term_synonym} s, {taxonomy_term_data} t WHERE t.tid = s.tid AND s.name = :name", array(':name' => $synonym))->fetch();
|
||||
}
|
||||
return $synonyms[$synonym];
|
||||
}
|
||||
|
@ -916,10 +916,10 @@ function taxonomy_term_count_nodes($tid, $type = 0) {
|
|||
if (!isset($count[$type])) {
|
||||
// $type == 0 always evaluates TRUE if $type is a string
|
||||
if (is_numeric($type)) {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {taxonomy_term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
|
||||
}
|
||||
else {
|
||||
$result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
|
||||
$result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {taxonomy_term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
|
||||
}
|
||||
$count[$type] = array();
|
||||
while ($term = db_fetch_object($result)) {
|
||||
|
@ -949,7 +949,7 @@ function _taxonomy_term_children($tid) {
|
|||
static $children;
|
||||
|
||||
if (!isset($children)) {
|
||||
$result = db_query('SELECT tid, parent FROM {term_hierarchy}');
|
||||
$result = db_query('SELECT tid, parent FROM {taxonomy_term_hierarchy}');
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$children[$term->parent][] = $term->tid;
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ function _taxonomy_term_children($tid) {
|
|||
* An array of matching term objects.
|
||||
*/
|
||||
function taxonomy_get_term_by_name($name) {
|
||||
$db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s')", 't', 'tid'), trim($name));
|
||||
$db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {taxonomy_term_data} t WHERE LOWER(t.name) = LOWER('%s')", 't', 'tid'), trim($name));
|
||||
$result = array();
|
||||
while ($term = db_fetch_object($db_result)) {
|
||||
$result[] = $term;
|
||||
|
@ -1004,7 +1004,7 @@ function taxonomy_vocabulary_load($vid, $reset = FALSE) {
|
|||
// that cached, and we will not try to load this later.
|
||||
$vocabularies[$vid] = FALSE;
|
||||
// Try to load the data and fill up the object.
|
||||
$result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_type} n ON v.vid = n.vid WHERE v.vid = %d', $vid);
|
||||
$result = db_query('SELECT v.*, n.type FROM {taxonomy_vocabulary} v LEFT JOIN {taxonomy_vocabulary_node_type} n ON v.vid = n.vid WHERE v.vid = %d', $vid);
|
||||
$node_types = array();
|
||||
while ($voc = db_fetch_object($result)) {
|
||||
if (!empty($voc->type)) {
|
||||
|
@ -1091,9 +1091,9 @@ function taxonomy_term_load_multiple($tids = array(), $conditions = array(), $re
|
|||
// Load any remaining terms from the database, this is necessary if we have
|
||||
// $tids still to load, or if $conditions was passed without $tids.
|
||||
if ($tids || ($conditions && !$passed_tids)) {
|
||||
$query = db_select('term_data', 't');
|
||||
$term_data = drupal_schema_fields_sql('term_data');
|
||||
$query->fields('t', $term_data);
|
||||
$query = db_select('taxonomy_term_data', 't');
|
||||
$taxonomy_term_data = drupal_schema_fields_sql('taxonomy_term_data');
|
||||
$query->fields('t', $taxonomy_term_data);
|
||||
|
||||
// If the $tids array is populated, add those to the query.
|
||||
if ($tids) {
|
||||
|
@ -1153,7 +1153,7 @@ function taxonomy_term_load($tid, $reset = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a term object from the term_data table.
|
||||
* Return a term object from the taxonomy_term_data table.
|
||||
* @param $tid
|
||||
* A term's ID
|
||||
* @return Object
|
||||
|
@ -1163,7 +1163,7 @@ function taxonomy_get_term_data($tid, $reset = FALSE) {
|
|||
static $terms = array();
|
||||
|
||||
if (!isset($terms[$tid]) || $reset) {
|
||||
$terms[$tid] = db_query('SELECT * FROM {term_data} WHERE tid = :tid', array(':tid' => $tid))->fetchObject();
|
||||
$terms[$tid] = db_query('SELECT * FROM {taxonomy_term_data} WHERE tid = :tid', array(':tid' => $tid))->fetchObject();
|
||||
}
|
||||
return $terms[$tid];
|
||||
}
|
||||
|
@ -1241,15 +1241,15 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p
|
|||
if ($operator == 'or') {
|
||||
$args = call_user_func_array('array_merge', $descendant_tids);
|
||||
$placeholders = db_placeholders($args, 'int');
|
||||
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1 ORDER BY ' . $order;
|
||||
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1';
|
||||
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1 ORDER BY ' . $order;
|
||||
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1';
|
||||
}
|
||||
else {
|
||||
$joins = '';
|
||||
$wheres = '';
|
||||
$args = array();
|
||||
foreach ($descendant_tids as $index => $tids) {
|
||||
$joins .= ' INNER JOIN {term_node} tn' . $index . ' ON n.vid = tn' . $index . '.vid';
|
||||
$joins .= ' INNER JOIN {taxonomy_term_node} tn' . $index . ' ON n.vid = tn' . $index . '.vid';
|
||||
$wheres .= ' AND tn' . $index . '.tid IN (' . db_placeholders($tids, 'int') . ')';
|
||||
$args = array_merge($args, $tids);
|
||||
}
|
||||
|
@ -1343,7 +1343,7 @@ function taxonomy_nodeapi_update($node) {
|
|||
* Remove associations of a node to its terms.
|
||||
*/
|
||||
function taxonomy_nodeapi_delete($node) {
|
||||
db_query('DELETE FROM {term_node} WHERE nid = %d', $node->nid);
|
||||
db_query('DELETE FROM {taxonomy_term_node} WHERE nid = %d', $node->nid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1352,7 +1352,7 @@ function taxonomy_nodeapi_delete($node) {
|
|||
* Remove associations of a node to its terms.
|
||||
*/
|
||||
function taxonomy_nodeapi_delete_revision($node) {
|
||||
db_query('DELETE FROM {term_node} WHERE vid = %d', $node->vid);
|
||||
db_query('DELETE FROM {taxonomy_term_node} WHERE vid = %d', $node->vid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@ function taxonomy_term_page($terms, $depth = 0, $op = 'page') {
|
|||
$str_tids = $terms['str_tids'];
|
||||
|
||||
if ($terms['tids']) {
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (' . db_placeholders($terms['tids']) . ')', 't', 'tid'), $terms['tids']);
|
||||
$result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {taxonomy_term_data} t WHERE t.tid IN (' . db_placeholders($terms['tids']) . ')', 't', 'tid'), $terms['tids']);
|
||||
$tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
|
||||
$names = array();
|
||||
while ($term = db_fetch_object($result)) {
|
||||
|
@ -131,7 +131,7 @@ function taxonomy_autocomplete($vid, $string = '') {
|
|||
$last_string = trim(array_pop($array));
|
||||
$matches = array();
|
||||
if ($last_string != '') {
|
||||
$result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = :vid AND LOWER(t.name) LIKE LOWER(:last_string)", 't', 'tid'), array(
|
||||
$result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {taxonomy_term_data} t WHERE t.vid = :vid AND LOWER(t.name) LIKE LOWER(:last_string)", 't', 'tid'), array(
|
||||
':vid' => $vid,
|
||||
':last_string' => '%'. $last_string .'%',
|
||||
), 0, 10);
|
||||
|
|
|
@ -360,7 +360,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
|
|||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertNoText($term2->name, t('Checking if node exists'));
|
||||
// Checking database fields.
|
||||
$result = db_query('SELECT * FROM {term_node} WHERE nid = :nid', array(':nid' => $node->nid))->fetch();
|
||||
$result = db_query('SELECT * FROM {taxonomy_term_node} WHERE nid = :nid', array(':nid' => $node->nid))->fetch();
|
||||
$this->assertTrue(empty($result), t('Term/node relationships are no longer in the database table.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ function default_profile_tasks(&$task, $url) {
|
|||
$description = st('Use tags to group articles on similar topics into categories.');
|
||||
$help = st('Enter a comma-separated list of words.');
|
||||
|
||||
$vid = db_insert('vocabulary')->fields(array(
|
||||
$vid = db_insert('taxonomy_vocabulary')->fields(array(
|
||||
'name' => 'Tags',
|
||||
'description' => $description,
|
||||
'help' => $help,
|
||||
|
@ -143,7 +143,7 @@ function default_profile_tasks(&$task, $url) {
|
|||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
))->execute();
|
||||
db_insert('vocabulary_node_type')->fields(array('vid' => $vid, 'type' => 'article'))->execute();
|
||||
db_insert('taxonomy_vocabulary_node_type')->fields(array('vid' => $vid, 'type' => 'article'))->execute();
|
||||
|
||||
// Update the menu router information.
|
||||
menu_rebuild();
|
||||
|
|
Loading…
Reference in New Issue