Commit ff9e8427 authored by webchick's avatar webchick

#330983 by recidive and boombatower: Rename users/users_roles tables to...

#330983 by recidive and boombatower: Rename users/users_roles tables to user/user_role for consistency.
parent df591c8f
......@@ -13,7 +13,7 @@
*
* Fields on the file object:
* - fid - File ID
* - uid - The {users}.uid of the user who is associated with the file.
* - uid - The {user}.uid of the user who is associated with the file.
* - filename - Name of the file with no path components. This may differ from
* the basename of the filepath if the file is renamed to avoid overwriting
* an existing file.
......
......@@ -195,7 +195,7 @@ function user_hash_password($password, $count_log2 = 0) {
* @param $password
* A plain-text password
* @param $account
* A user object with at least the fields from the {users} table.
* A user object with at least the fields from the {user} table.
*
* @return
* TRUE or FALSE.
......@@ -227,7 +227,7 @@ function user_check_password($password, $account) {
* on the fields in $account.
*
* @param $account
* A user object with at least the fields from the {users} table.
* A user object with at least the fields from the {user} table.
*
* @return
* TRUE or FALSE.
......
......@@ -83,7 +83,7 @@ function _sess_read($key) {
// Otherwise, if the session is still active, we have a record of the
// client's session in the database.
$user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $key))->fetchObject();
$user = db_query("SELECT u.*, s.* FROM {user} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $key))->fetchObject();
// We found the client's session record and they are an authenticated user.
if ($user && $user->uid > 0) {
......@@ -93,7 +93,7 @@ function _sess_read($key) {
// Add roles element to $user.
$user->roles = array();
$user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
$user->roles += db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 1);
$user->roles += db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {user_role} ur ON ur.rid = r.rid WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 1);
}
// We didn't find the client's record (session has expired), or they
// are an anonymous user.
......@@ -146,7 +146,7 @@ function _sess_write($key, $value) {
// Last access time is updated no more frequently than once every 180 seconds.
// This reduces contention in the users table.
if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) {
db_update('users')
db_update('user')
->fields(array(
'access' => REQUEST_TIME
))
......
......@@ -117,7 +117,7 @@ function block_schema() {
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The user's role ID from {users_roles}.rid.",
'description' => "The user's role ID from {user_role}.rid.",
),
),
'primary key' => array('module', 'delta', 'rid'),
......
......@@ -30,7 +30,7 @@ function blogapi_schema() {
'type' => 'serial',
),
'uid' => array(
'description' => 'The {users}.uid of the user who is associated with the file.',
'description' => 'The {user}.uid of the user who is associated with the file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
......
......@@ -379,13 +379,13 @@ function blogapi_blogger_get_recent_posts($appkey, $blogid, $username, $password
}
if ($bodies) {
$result = db_query_range("SELECT n.nid, n.title, r.body, r.format, n.comment, n.created, u.name FROM {node} n, {node_revision} r, {users} u WHERE n.uid = u.uid AND n.vid = r.vid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array(
$result = db_query_range("SELECT n.nid, n.title, r.body, r.format, n.comment, n.created, u.name FROM {node} n, {node_revision} r, {user} u WHERE n.uid = u.uid AND n.vid = r.vid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array(
':type' => $blogid,
':uid' => $user->uid
), 0, $number_of_posts);
}
else {
$result = db_query_range("SELECT n.nid, n.title, n.created, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array(
$result = db_query_range("SELECT n.nid, n.title, n.created, u.name FROM {node} n, {user} u WHERE n.uid = u.uid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array(
':type' => $blogid,
':uid' => $user->uid
), 0, $number_of_posts);
......
......@@ -66,7 +66,7 @@ function comment_admin_overview($type = 'new', $arg) {
'operations' => array('data' => t('Operations')),
);
$result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comment} c INNER JOIN {users} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d' . tablesort_sql($header), 50, 0, NULL, $status);
$result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comment} c INNER JOIN {user} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d' . tablesort_sql($header), 50, 0, NULL, $status);
// Build a table listing the appropriate comments.
$options = array();
......@@ -205,7 +205,7 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
* The comment to be deleted.
*/
function comment_delete($cid = NULL) {
$comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid));
$comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {user} u ON u.uid = c.uid WHERE c.cid = %d', $cid));
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$output = '';
......@@ -272,7 +272,7 @@ function _comment_delete_thread($comment) {
comment_invoke_comment($comment, 'delete');
// Delete the comment's replies.
$result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid);
$result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comment} c INNER JOIN {user} u ON u.uid = c.uid WHERE pid = %d', $comment->cid);
while ($comment = db_fetch_object($result)) {
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
_comment_delete_thread($comment);
......
......@@ -181,7 +181,7 @@ function comment_schema() {
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.',
'description' => 'The {user}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.',
),
'subject' => array(
'type' => 'varchar',
......@@ -234,7 +234,7 @@ function comment_schema() {
'type' => 'varchar',
'length' => 60,
'not null' => FALSE,
'description' => "The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form.",
'description' => "The comment author's name. Uses {user}.name if the user is logged in, otherwise uses the value typed into the comment form.",
),
'mail' => array(
'type' => 'varchar',
......
......@@ -1058,7 +1058,7 @@ function comment_render($node, $cid = 0) {
$query->fields('c', array('cid', 'nid', 'pid', 'comment', 'subject', 'format', 'timestamp', 'name', 'mail', 'homepage', 'status') );
$query->fields('u', array( 'uid', 'signature', 'picture', 'data', 'status') );
$query->addField('u', 'name', 'registered_name');
$query->innerJoin('users', 'u', 'c.uid = u.uid');
$query->innerJoin('user', 'u', 'c.uid = u.uid');
$query->condition('c.cid', $cid);
if (!user_access('administer comments')) {
......@@ -1084,7 +1084,7 @@ function comment_render($node, $cid = 0) {
// Multiple comment view.
$query_count = 'SELECT COUNT(*) FROM {comment} c WHERE c.nid = %d';
$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comment} c INNER JOIN {user} u ON c.uid = u.uid WHERE c.nid = %d';
$query_args = array($nid);
if (!user_access('administer comments')) {
......@@ -1292,7 +1292,7 @@ function comment_validate($edit) {
$node = node_load($edit['nid']);
if (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) > COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
if ($edit['name']) {
$query = db_select('users', 'u');
$query = db_select('user', 'u');
$query->addField('u', 'uid', 'uid');
$taken = $query->where('LOWER(name) = :name', array(':name' => $edit['name']))
->countQuery()
......@@ -1635,7 +1635,7 @@ function comment_form_add_preview($form, &$form_state) {
$output = ''; // Isn't this line a duplication of the first $output above?
if ($edit['pid']) {
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comment} c INNER JOIN {user} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
':cid' => $edit['pid'],
':status' => COMMENT_PUBLISHED ))
->fetchObject();
......
......@@ -15,7 +15,7 @@
*/
function comment_edit($cid) {
global $user;
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid', array(':cid'=>$cid) )->fetchObject();
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comment} c INNER JOIN {user} u ON c.uid = u.uid WHERE c.cid = :cid', array(':cid'=>$cid) )->fetchObject();
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
......@@ -69,7 +69,7 @@ function comment_reply($node, $pid = NULL) {
// $pid indicates that this is a reply to a comment.
if ($pid) {
// Load the comment whose cid = $pid
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
$comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comment} c INNER JOIN {user} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
':cid'=>$pid,
':status'=>COMMENT_PUBLISHED))->fetchObject();
if ( $comment ) {
......
......@@ -63,7 +63,7 @@ function dblog_overview() {
array('data' => t('Operations')),
);
$sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.variables, w.link, u.name FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid";
$sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.variables, w.link, u.name FROM {watchdog} w INNER JOIN {user} u ON w.uid = u.uid";
$tablesort = tablesort_sql($header);
if (!empty($filter['where'])) {
$result = pager_query($sql . " WHERE " . $filter['where'] . $tablesort, 50, 0, NULL, $filter['args']);
......@@ -132,7 +132,7 @@ function dblog_top($type) {
function dblog_event($id) {
$severity = watchdog_severity_levels();
$output = '';
$result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = %d', $id);
$result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {user} u ON w.uid = u.uid WHERE w.wid = %d', $id);
if ($dblog = db_fetch_object($result)) {
$rows = array(
array(
......
......@@ -33,7 +33,7 @@ function dblog_schema() {
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the user who triggered the event.',
'description' => 'The {user}.uid of the user who triggered the event.',
),
'type' => array(
'type' => 'varchar',
......
......@@ -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 {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 = "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 {user} 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 {user} 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));
......@@ -659,7 +659,7 @@ 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 {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 = 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 {user} cu ON l.last_comment_uid = cu.uid INNER JOIN {taxonomy_term_node} r ON n.vid = r.vid INNER JOIN {user} 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.
......
......@@ -483,7 +483,7 @@ function node_admin_nodes() {
$filter = node_build_filter_query();
$sort = tablesort_sql($header, '', 'n.changed DESC');
$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']);
$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {user} u ON n.uid = u.uid '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']);
// Build the 'Update options' form.
$form['options'] = array(
......
......@@ -43,7 +43,7 @@ function node_schema() {
'default' => '',
),
'uid' => array(
'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
'description' => 'The {user}.uid that owns this node; initially, this is the user that created it.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
......@@ -227,7 +227,7 @@ function node_schema() {
'not null' => TRUE,
),
'uid' => array(
'description' => 'The {users}.uid that created this version.',
'description' => 'The {user}.uid that created this version.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
......
......@@ -855,7 +855,7 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
else {
$query->join('node_revision', 'r', 'r.vid = n.vid');
}
$query->join('users', 'u', 'u.uid = n.uid');
$query->join('user', 'u', 'u.uid = n.uid');
// Add fields from the {node} table.
$node_fields = drupal_schema_fields_sql('node');
......@@ -876,7 +876,7 @@ function node_load_multiple($nids = array(), $conditions = array(), $reset = FAL
$query->addField('r', 'timestamp', 'revision_timestamp');
$query->fields('r', $node_revision_fields);
// Add fields from the {users} table.
// Add fields from the {user} table.
$user_fields = array('name', 'picture', 'data');
$query->fields('u', $user_fields);
......@@ -1865,7 +1865,7 @@ function node_last_changed($nid) {
*/
function node_revision_list($node) {
$revisions = array();
$result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = %d ORDER BY r.timestamp DESC', $node->nid);
$result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {user} u ON u.uid = r.uid WHERE r.nid = %d ORDER BY r.timestamp DESC', $node->nid);
while ($revision = db_fetch_object($result)) {
$revisions[$revision->vid] = $revision;
}
......@@ -3008,22 +3008,22 @@ function node_save_action($node) {
*/
function node_assign_owner_action(&$node, $context) {
$node->uid = $context['owner_uid'];
$owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid']));
$owner_name = db_result(db_query("SELECT name FROM {user} WHERE uid = %d", $context['owner_uid']));
watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_get_types('type', $node), '%title' => $node->title, '%name' => $owner_name));
}
function node_assign_owner_action_form($context) {
$description = t('The username of the user to which you would like to assign ownership.');
$count = db_result(db_query("SELECT COUNT(*) FROM {users}"));
$count = db_result(db_query("SELECT COUNT(*) FROM {user}"));
$owner_name = '';
if (isset($context['owner_uid'])) {
$owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid']));
$owner_name = db_result(db_query("SELECT name FROM {user} WHERE uid = %d", $context['owner_uid']));
}
// Use dropdown for fewer than 200 users; textbox for more than that.
if (intval($count) < 200) {
$options = array();
$result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 ORDER BY name");
$result = db_query("SELECT uid, name FROM {user} WHERE uid > 0 ORDER BY name");
while ($data = db_fetch_object($result)) {
$options[$data->name] = $data->name;
}
......@@ -3050,7 +3050,7 @@ function node_assign_owner_action_form($context) {
}
function node_assign_owner_action_validate($form, $form_state) {
$count = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s'", $form_state['values']['owner_name']));
$count = db_result(db_query("SELECT COUNT(*) FROM {user} WHERE name = '%s'", $form_state['values']['owner_name']));
if (intval($count) != 1) {
form_set_error('owner_name', t('Please enter a valid username.'));
}
......@@ -3058,7 +3058,7 @@ function node_assign_owner_action_validate($form, $form_state) {
function node_assign_owner_action_submit($form, $form_state) {
// Username can change, so we need to store the ID, not the username.
$uid = db_result(db_query("SELECT uid from {users} WHERE name = '%s'", $form_state['values']['owner_name']));
$uid = db_result(db_query("SELECT uid from {user} WHERE name = '%s'", $form_state['values']['owner_name']));
return array('owner_uid' => $uid);
}
......
......@@ -92,13 +92,13 @@ function poll_schema() {
);
$schema['poll_vote'] = array(
'description' => 'Stores per-{users} votes for each {poll}.',
'description' => 'Stores per-{user} votes for each {poll}.',
'fields' => array(
'chid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The {users}'s vote for this poll.",
'description' => "The {user}'s vote for this poll.",
),
'nid' => array(
'type' => 'int',
......@@ -111,7 +111,7 @@ function poll_schema() {
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid this vote is from unless the voter was anonymous.',
'description' => 'The {user}.uid this vote is from unless the voter was anonymous.',
),
'hostname' => array(
'type' => 'varchar',
......
......@@ -35,7 +35,7 @@ function poll_votes($node) {
$header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
$header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc');
$result = pager_query("SELECT pv.chid, pv.uid, pv.hostname, pv.timestamp, pv.nid, pc.chtext, u.name FROM {poll_vote} pv INNER JOIN {poll_choice} pc ON pv.chid = pc.chid LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid);
$result = pager_query("SELECT pv.chid, pv.uid, pv.hostname, pv.timestamp, pv.nid, pc.chtext, u.name FROM {poll_vote} pv INNER JOIN {poll_choice} pc ON pv.chid = pc.chid LEFT JOIN {user} u ON pv.uid = u.uid WHERE pv.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid);
$rows = array();
while ($vote = db_fetch_object($result)) {
$rows[] = array(
......
......@@ -294,7 +294,7 @@ function profile_field_form_validate($form, &$form_state) {
form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.'));
}
$users_table = drupal_get_schema('users');
$users_table = drupal_get_schema('user');
if (!empty($users_table['fields'][$form_state['values']['name']])) {
form_set_error('name', t('The specified form name is reserved for use by Drupal.'));
}
......
......@@ -132,7 +132,7 @@ function profile_schema() {
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the profile user.',
'description' => 'The {user}.uid of the profile user.',
),
'value' => array(
'type' => 'text',
......
......@@ -55,7 +55,7 @@ function profile_browse() {
}
// Extract the affected users:
$result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_value} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments);
$result = pager_query("SELECT u.uid, u.access FROM {user} u INNER JOIN {profile_value} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments);
$content = '';
while ($account = db_fetch_object($result)) {
......@@ -88,7 +88,7 @@ function profile_browse() {
}
// Extract the affected users:
$result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL);
$result = pager_query('SELECT uid, access FROM {user} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL);
$content = '';
while ($account = db_fetch_object($result)) {
......
......@@ -1956,10 +1956,10 @@ class DatabaseTemporaryQueryTestCase extends DrupalWebTestCase {
// Now try to run two db_query_temporary() in the same request.
$table_name_system = db_query_temporary('SELECT status FROM {system}', array());
$table_name_users = db_query_temporary('SELECT uid FROM {users}', array());
$table_name_users = db_query_temporary('SELECT uid FROM {user}', array());
$this->assertEqual($this->countTableRows($table_name_system), $this->countTableRows("system"), t('A temporary table was created successfully in this request.'));
$this->assertEqual($this->countTableRows($table_name_users), $this->countTableRows("users"), t('A second temporary table was created successfully in this request.'));
$this->assertEqual($this->countTableRows($table_name_users), $this->countTableRows("user"), t('A second temporary table was created successfully in this request.'));
}
}
......
......@@ -17,7 +17,7 @@ function statistics_recent_hits() {
array('data' => t('Operations'))
);
$sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid' . tablesort_sql($header);
$sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {user} u ON u.uid = a.uid' . tablesort_sql($header);
$result = pager_query($sql, 30);
$rows = array();
......@@ -82,7 +82,7 @@ function statistics_top_visitors() {
array('data' => user_access('block IP addresses') ? t('Operations') : '', 'colspan' => 2),
);
$sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, bl.iid FROM {accesslog} a LEFT JOIN {blocked_ips} bl ON a.hostname = bl.ip LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, bl.iid" . tablesort_sql($header);
$sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, bl.iid FROM {accesslog} a LEFT JOIN {blocked_ips} bl ON a.hostname = bl.ip LEFT JOIN {user} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, bl.iid" . tablesort_sql($header);
$sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(CAST(uid AS char), hostname))) FROM {accesslog}";
$result = pager_query($sql, 30, 0, $sql_cnt);
......@@ -138,7 +138,7 @@ function statistics_top_referrers() {
* Menu callback; Displays recent page accesses.
*/
function statistics_access_log($aid) {
$result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid);
$result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {user} u ON a.uid = u.uid WHERE aid = %d', $aid);
if ($access = db_fetch_object($result)) {
$rows[] = array(
array('data' => t('URL'), 'header' => TRUE),
......
......@@ -91,7 +91,7 @@ function statistics_schema() {
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0,
'description' => 'User {users}.uid that visited the page.',
'description' => 'User {user}.uid that visited the page.',
),
'timer' => array(
'type' => 'int',
......
......@@ -232,7 +232,7 @@ function statistics_cron() {
*/
function statistics_title_list($dbfield, $dbrows) {
if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) {
return db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {node_counter} s ON n.nid = s.nid INNER JOIN {users} u ON n.uid = u.uid WHERE s." . $dbfield . " != 0 AND n.status = 1 ORDER BY s." . $dbfield . " DESC"), 0, $dbrows);
return db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {node_counter} s ON n.nid = s.nid INNER JOIN {user} u ON n.uid = u.uid WHERE s." . $dbfield . " != 0 AND n.status = 1 ORDER BY s." . $dbfield . " DESC"), 0, $dbrows);
}
return FALSE;
}
......
......@@ -15,7 +15,7 @@ function statistics_node_tracker() {
array('data' => t('User'), 'field' => 'u.name'),
array('data' => t('Operations')));
$result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\'' . tablesort_sql($header), 30, 0, NULL, $node->nid);
$result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {user} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\'' . tablesort_sql($header), 30, 0, NULL, $node->nid);
$rows = array();
while ($log = db_fetch_object($result)) {
$rows[] = array(
......
......@@ -1784,7 +1784,7 @@ function system_status($check = FALSE) {
}
// MySQL import might have set the uid of the anonymous user to autoincrement
// value. Let's try fixing it. See http://drupal.org/node/204411
db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0");
db_query("UPDATE {user} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0");
return theme('status_report', $requirements);
}
......
......@@ -1423,7 +1423,7 @@ function hook_schema() {
*/
function hook_schema_alter(&$schema) {
// Add field to existing schema.
$schema['users']['fields']['timezone_id'] = array(
$schema['user']['fields']['timezone_id'] = array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
......
......@@ -342,17 +342,17 @@ function system_install() {
// uid 2 which is not what we want. So we insert the first user here, the
// anonymous user. uid is 1 here for now, but very soon it will be changed
// to 0.
db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', '');
db_query("INSERT INTO {user} (name, mail) VALUES('%s', '%s')", '', '');
// We need some placeholders here as name and mail are uniques and data is
// presumed to be a serialized array. Install will change uid 1 immediately
// anyways. So we insert the superuser here, the uid is 2 here for now, but
// very soon it will be changed to 1.
db_query("INSERT INTO {users} (name, mail, created, status, data) VALUES('%s', '%s', %d, %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, 1, serialize(array()));
db_query("INSERT INTO {user} (name, mail, created, status, data) VALUES('%s', '%s', %d, %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, 1, serialize(array()));
// This sets the above two users uid 0 (anonymous). We avoid an explicit 0
// otherwise MySQL might insert the next auto_increment value.
db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", '');
db_query("UPDATE {user} SET uid = uid - uid WHERE name = '%s'", '');
// This sets uid 1 (superuser). We skip uid 2 but that's not a big problem.
db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1');
db_query("UPDATE {user} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1');
// Built-in roles.
db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user');
......@@ -608,7 +608,7 @@ function system_schema() {
'not null' => TRUE,
),
'uid' => array(
'description' => 'The {users}.uid of the user who is associated with the file.',
'description' => 'The {user}.uid of the user who is associated with the file.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
......@@ -700,10 +700,10 @@ function system_schema() {
);
$schema['history'] = array(
'description' => 'A record of which {users} have read which {node}s.',
'description' => 'A record of which {user} have read which {node}s.',
'fields' => array(
'uid' => array(
'description' => 'The {users}.uid that read the {node} nid.',
'description' => 'The {user}.uid that read the {node} nid.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
......@@ -1114,7 +1114,7 @@ function system_schema() {
'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
'fields' => array(
'uid' => array(
'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
'description' => 'The {user}.uid corresponding to a session, or 0 for anonymous user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
......@@ -1772,11 +1772,11 @@ function system_update_6019() {
db_change_field($ret, 'cache_form', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
// Remove default => 0, set auto increment.
$new_uid = 1 + db_result(db_query('SELECT MAX(uid) FROM {users}'));
$ret[] = update_sql('UPDATE {users} SET uid = ' . $new_uid . ' WHERE uid = 0');
db_drop_primary_key($ret, 'users');
db_change_field($ret, 'users', 'uid', 'uid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('uid')));
$ret[] = update_sql('UPDATE {users} SET uid = 0 WHERE uid = ' . $new_uid);
$new_uid = 1 + db_result(db_query('SELECT MAX(uid) FROM {user}'));
$ret[] = update_sql('UPDATE {user} SET uid = ' . $new_uid . ' WHERE uid = 0');
db_drop_primary_key($ret, 'user');
db_change_field($ret, 'user', 'uid', 'uid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('uid')));
$ret[] = update_sql('UPDATE {user} SET uid = 0 WHERE uid = ' . $new_uid);
// Special field names.
$map = array('node_revisions' => 'vid');
......@@ -2521,8 +2521,8 @@ function system_update_6043() {
db_drop_index($ret, 'node', 'status');
db_drop_unique_key($ret, 'node', 'nid_vid');
// Improve user module indices.
db_add_index($ret, 'users', 'mail', array('mail'));
db_add_index($ret, 'users_roles', 'rid', array('rid'));
db_add_index($ret, 'user', 'mail', array('mail'));
db_add_index($ret, 'user_role', 'rid', array('rid'));
// Optional modules - need to check if the tables exist.
// Alter aggregator module's tables primary keys to make them more useful.
......@@ -2610,8 +2610,8 @@ function system_update_6044() {
}
// User module indices.
db_drop_unique_key($ret, 'users', 'mail');
db_add_index($ret, 'users', 'mail', array('mail'));
db_drop_unique_key($ret, 'user', 'mail');
db_add_index($ret, 'user', 'mail', array('mail'));
// Optional modules - need to check if the tables exist.
// Alter taxonomy module's tables.
......@@ -2864,11 +2864,11 @@ function system_update_7004(&$sandbox) {
// Initialize batch update information.
$sandbox['progress'] = 0;
$sandbox['last_user_processed'] = -1;
$sandbox['max'] = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE data IS NOT NULL"));
$sandbox['max'] = db_result(db_query("SELECT COUNT(*) FROM {user} WHERE data IS NOT NULL"));
}
// Now do the batch update of the user-specific block visibility settings.
$limit = 100;
$result = db_query_range("SELECT uid, data FROM {users} WHERE uid > %d AND data IS NOT NULL", $sandbox['last_user_processed'], 0, $limit);
$result = db_query_range("SELECT uid, data FROM {user} WHERE uid > %d AND data IS NOT NULL", $sandbox['last_user_processed'], 0, $limit);
while ($row = db_fetch_object($result)) {
$data = unserialize($row->data);
$user_needs_update = FALSE;
......@@ -2885,7 +2885,7 @@ function system_update_7004(&$sandbox) {
}
// Update the current user.
if ($user_needs_update) {
db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", serialize($data), $row->uid);
db_query("UPDATE {user} SET data = '%s' WHERE uid = %d", serialize($data), $row->uid);
}
// Update our progress information for the batch update.
$sandbox['progress']++;
......
......@@ -22,14 +22,14 @@ function tracker_page($account = NULL, $set_title = FALSE) {
drupal_set_title($account->name);
}
// TODO: These queries are very expensive, see http://drupal.org/node/105639
$sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comment} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
$sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {user} u ON n.uid = u.uid LEFT JOIN {comment} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
$sql = db_rewrite_sql($sql);
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comment} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
$sql_count = db_rewrite_sql($sql_count);
$result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid);
}
else {
$sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_updated DESC';
$sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {user} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_updated DESC';
$sql = db_rewrite_sql($sql);
$sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
$sql_count = db_rewrite_sql($sql_count);
......
......@@ -144,9 +144,9 @@ function user_admin_account() {
t('Operations')
);
$sql = 'SELECT DISTINCT u.uid, u.name, u.status, u.created, u.access FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where'];
$sql = 'SELECT DISTINCT u.uid, u.name, u.status, u.created, u.access FROM {user} u LEFT JOIN {user_role} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where'];
$sql .= tablesort_sql($header);
$query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where'];
$query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {user} u LEFT JOIN {user_role} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where'];
$result = pager_query($sql, 50, 0, $query_count, $filter['args']);
$form['options'] = array(
......@@ -178,13 +178,13 @@ function user_admin_account() {
$accounts[$account->uid] = '';
$form['name'][$account->uid] = array('#markup' => theme('username', $account));
$form['status'][$account->uid] = array('#markup' => $status[$account->status]);
$users_roles = array();
$roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid);
$user_roles = array();
$roles_result = db_query('SELECT rid FROM {user_role} WHERE uid = %d', $account->uid);
while ($user_role = db_fetch_object($roles_result)) {
$users_roles[] = $roles[$user_role->rid];
$user_roles[] = $roles[$user_role->rid];
}
asort($users_roles);
$form['roles'][$account->uid][0] = array('#markup' => theme('item_list', $users_roles));
asort($user_roles);
$form['roles'][$account->uid][0] = array('#markup' => theme('item_list', $user_role));
$form['member_for'][$account->uid] = array('#markup' => format_interval(REQUEST_TIME - $account->created));
$form['last_access'][$account->uid] = array('#markup' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'));
$form['operations'][$account->uid] = array('#markup' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination)));
......@@ -736,7 +736,7 @@ function user_admin_role_submit($form, &$form_state) {
db_query('DELETE FROM {role} WHERE rid = %d', $form_state['values']['rid']);
db_query('DELETE FROM {role_permission} WHERE rid = %d', $form_state['values']['rid']);
// Update the users who have this role set:
db_query('DELETE FROM {users_roles} WHERE rid = %d', $form_state['values']['rid']);
db_query('DELETE FROM {user_role} WHERE rid = %d', $form_state['values']['rid']);
drupal_set_message(t('The role has been deleted.'));
}
......
......@@ -18,7 +18,7 @@ function user_schema() {
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "User's {users}.uid.",
'description' => "User's {user}.uid.",
),
'authname' => array(
'type' => 'varchar',
......@@ -87,7 +87,7 @@ function user_schema() {
'primary key' => array('rid'),
);
$schema['users'] = array(
$schema['user'] = array(
'description' => 'Stores user data.',
'fields' => array(
'uid' => array(
......@@ -201,7 +201,7 @@ function user_schema() {
'primary key' => array('uid'),
);
$schema['users_roles'] = array(
$schema['user_role'] = array(
'description' => 'Maps users to roles.',
'fields' => array(
'uid' => array(
......@@ -209,7 +209,7 @@ function user_schema() {