Commit 1ad9afb8 authored by Dries's avatar Dries

parent a158eca1
......@@ -6,6 +6,8 @@ Drupal x.x.x, xxxx-xx-xx
* made it possible to browse the profiles by field.
- menu module:
* made it possible to customize menus.
- user management:
* added support for multiple roles per user.
- refactored 403 (forbidden) handling and added support for custom 403 pages.
- syndication:
* added support for RSS ping-notifications of http://technorati.com/.
......
......@@ -597,6 +597,16 @@ CREATE TABLE users (
KEY changed (changed)
) TYPE=MyISAM;
--
-- Table structure for table 'users_roles'
--
CREATE TABLE users_roles (
uid int(10) unsigned NOT NULL default '0',
rid int(10) unsigned NOT NULL default '0',
PRIMARY KEY (uid, rid)
) TYPE=MyISAM;
--
-- Table structure for table 'variable'
--
......
......@@ -592,6 +592,16 @@ CREATE INDEX users_changed_idx ON users(changed);
CREATE SEQUENCE users_uid_seq INCREMENT 1 START 1;
--
-- Table structure for users_roles
--
CREATE TABLE users_roles (
uid integer NOT NULL default '0',
rid integer NOT NULL default '0',
PRIMARY KEY (uid, rid)
);
--
-- Table structure for variable
--
......
......@@ -56,7 +56,8 @@
"2004-02-27" => "update_82",
"2004-04-15" => "update_83",
"2004-04-21" => "update_84",
"2004-04-27" => "update_85"
"2004-04-27" => "update_85",
"2004-05-10" => "update_86"
);
function update_32() {
......@@ -1075,6 +1076,13 @@ function update_85() {
return $ret;
}
function update_86() {
$ret = array();
$ret[] = update_sql("INSERT INTO {users_roles} (uid, rid) SELECT uid, rid FROM {users}");
// TODO: should we verify the insert above worked before dropping rid?
$ret[] = update_sql("ALTER TABLE {users} DROP rid");
}
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);
......
......@@ -17,15 +17,22 @@ function sess_close() {
function sess_read($key) {
global $user;
$result = db_query_range("SELECT u.*, s.*, r.name AS role FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid LEFT JOIN {role} r ON u.rid = r.rid WHERE s.sid = '%s' AND u.status < 3", $key, 0, 1);
$result = db_query_range("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s' AND u.status < 3", $key, 0, 1);
if (!db_num_rows($result)) {
$result = db_query("SELECT u.*, r.name AS role FROM {users} u INNER JOIN {role} r ON u.rid = r.rid WHERE u.uid = 0");
$result = db_query("SELECT u.* FROM {users} u WHERE u.uid = 0");
db_query("INSERT INTO {sessions} (uid, sid, hostname, timestamp) values(%d, '%s', '%s', %d)", $user->uid, $key, $_SERVER["REMOTE_ADDR"], time());
}
$user = db_fetch_object($result);
$user = drupal_unpack($user);
$user->roles = array();
$result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $user->uid);
while ($role = db_fetch_object($result)) {
$user->roles[$role->rid] = $role->name;
}
return !empty($user->session) ? $user->session : '';
}
......
......@@ -322,7 +322,12 @@ function comment_post($edit) {
$status = user_access("post comments without approval") ? 0 : 1;
$roles = variable_get("comment_roles", array());
$score = $roles[$user->rid] ? $roles[$user->rid] : 0;
$score = 0;
foreach (array_intersect(array_keys($roles), array_keys($user->roles)) as $rid) {
$score = max($roles[$rid], $score);
}
$users = serialize(array(0 => $score));
/*
......@@ -371,13 +376,13 @@ function comment_post($edit) {
*/
// Get the parent comment:
$parent = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = '%d'", $edit["pid"]));
$parent = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = %d", $edit['pid']));
// Strip the "/" from the end of the parent thread:
$parent->thread = (string)rtrim((string)$parent->thread, "/");
// Get the max value in _this_ thread:
$max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = '%d'", $parent->thread, $edit["nid"]));
$max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $edit['nid']));
if ($max == "") {
// First child of this parent
......@@ -1342,7 +1347,7 @@ function theme_comment_moderation_form($comment) {
// comment hasn't been moderated yet:
if (!isset($votes)) {
$result = db_query("SELECT v.mid, v.vote, r.value FROM {moderation_votes} v, {moderation_roles} r WHERE v.mid = r.mid AND r.rid = %d ORDER BY weight", $user->rid);
$result = db_query("SELECT v.mid, v.vote, MAX(r.value) AS value FROM {moderation_votes} v INNER JOIN {moderation_roles} r ON r.mid = v.mid WHERE r.rid IN (%s) GROUP BY v.mid, v.vote ORDER BY weight", implode(", ", array_keys($user->roles)));
$votes = array();
while ($vote = db_fetch_object($result)) {
if ($vote->value != 0) {
......@@ -1452,7 +1457,7 @@ function comment_moderate() {
$moderation = $_POST["moderation"];
if ($moderation) {
$result = db_query("SELECT mid, value FROM {moderation_roles} WHERE rid = %d", $user->rid);
$result = db_query("SELECT mid, MAX(value) AS value FROM {moderation_roles} WHERE rid IN (%s) GROUP BY mid", implode(", ", array_keys($user->roles)));
while ($mod = db_fetch_object($result)) {
$votes[$mod->mid] = $mod->value;
}
......
......@@ -322,7 +322,12 @@ function comment_post($edit) {
$status = user_access("post comments without approval") ? 0 : 1;
$roles = variable_get("comment_roles", array());
$score = $roles[$user->rid] ? $roles[$user->rid] : 0;
$score = 0;
foreach (array_intersect(array_keys($roles), array_keys($user->roles)) as $rid) {
$score = max($roles[$rid], $score);
}
$users = serialize(array(0 => $score));
/*
......@@ -371,13 +376,13 @@ function comment_post($edit) {
*/
// Get the parent comment:
$parent = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = '%d'", $edit["pid"]));
$parent = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = %d", $edit['pid']));
// Strip the "/" from the end of the parent thread:
$parent->thread = (string)rtrim((string)$parent->thread, "/");
// Get the max value in _this_ thread:
$max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = '%d'", $parent->thread, $edit["nid"]));
$max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $edit['nid']));
if ($max == "") {
// First child of this parent
......@@ -1342,7 +1347,7 @@ function theme_comment_moderation_form($comment) {
// comment hasn't been moderated yet:
if (!isset($votes)) {
$result = db_query("SELECT v.mid, v.vote, r.value FROM {moderation_votes} v, {moderation_roles} r WHERE v.mid = r.mid AND r.rid = %d ORDER BY weight", $user->rid);
$result = db_query("SELECT v.mid, v.vote, MAX(r.value) AS value FROM {moderation_votes} v INNER JOIN {moderation_roles} r ON r.mid = v.mid WHERE r.rid IN (%s) GROUP BY v.mid, v.vote ORDER BY weight", implode(", ", array_keys($user->roles)));
$votes = array();
while ($vote = db_fetch_object($result)) {
if ($vote->value != 0) {
......@@ -1452,7 +1457,7 @@ function comment_moderate() {
$moderation = $_POST["moderation"];
if ($moderation) {
$result = db_query("SELECT mid, value FROM {moderation_roles} WHERE rid = %d", $user->rid);
$result = db_query("SELECT mid, MAX(value) AS value FROM {moderation_roles} WHERE rid IN (%s) GROUP BY mid", implode(", ", array_keys($user->roles)));
while ($mod = db_fetch_object($result)) {
$votes[$mod->mid] = $mod->value;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -109,7 +109,29 @@ function update_info() {
print "</ol>";
print "Notes:";
print "<ol>";
print " <li>If you <strong>upgrade from Drupal 4.3.x</strong>, you have will need to add the <code>bootstrap</code> and <code>throttle</code> fields to the <code>system</code> table manually before upgrading. To add the required fields, issue the following SQL commands:
print " <li>If you <strong>upgrade from Drupal 4.4.x</strong>, you will need to create the <code>users_roles</code> table manually before upgrading. To create the <code>users_roles</code> table, issue the following SQL commands:
<p>MySQL specific example:
<pre>
CREATE TABLE users_roles (
uid int(10) unsigned NOT NULL default '0',
rid int(10) unsigned NOT NULL default '0',
PRIMARY KEY (uid, rid)
);
</pre>
</p>
<p>PostgreSQL specific example:
<pre>
CREATE TABLE users_roles (
uid integer NOT NULL default '0',
rid integer NOT NULL default '0',
PRIMARY KEY (uid, rid)
);
</pre>
</p>
</li>";
print " <li>If you <strong>upgrade from Drupal 4.3.x</strong>, you will need to add the <code>bootstrap</code> and <code>throttle</code> fields to the <code>system</code> table manually before upgrading. To add the required fields, issue the following SQL commands:
<p>MySQL specific example:
<pre>
......@@ -128,7 +150,11 @@ function update_info() {
</pre>
</p>
</li>";
print " <li>If you <strong>upgrade from Drupal 4.2.0</strong>, you have to create the <code>sessions</code> table manually before upgrading. After you created the table, you'll want to log in and immediately continue the upgrade. To create the <code>sessions</code> table, issue the following SQL command (MySQL specific example):<pre>CREATE TABLE sessions (
print " <li>If you <strong>upgrade from Drupal 4.2.0</strong>, you will need to create the <code>sessions</code> table manually before upgrading. After creating the table, you will want to log in and immediately continue the upgrade. To create the <code>sessions</code> table, issue the following SQL command:
<p>MySQL specific example:
<pre>
CREATE TABLE sessions (
uid int(10) unsigned NOT NULL,
sid varchar(32) NOT NULL default '',
hostname varchar(128) NOT NULL default '',
......@@ -136,7 +162,10 @@ function update_info() {
session text,
KEY uid (uid),
KEY sid (sid(4)),
KEY timestamp (timestamp));</pre></li>";
KEY timestamp (timestamp));
</pre>
</p>
</li>";
print "</ol>";
print update_page_footer();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment