Commit 60352821 authored by Dries's avatar Dries

- Refactored the queue module: removed the queue module's field from the node table.  With help from Gerhard.

- Slight addition to INSTALL.txt with regard to PHP versions.

- Updated/reworded some node type descriptions as per Boris' suggestions.

- Adding missing {} around a table name in update.php.
parent 1365740f
......@@ -5,7 +5,8 @@ REQUIREMENTS
Drupal requires a web server, PHP4 (http://www.php.net/) and either
MySQL, PostgreSQL or a database server supported by the PHP PEAR API
(http://pear.php.net/).
(http://pear.php.net/). Drupal requires PHP 4.1.0 or greater on Unix
and PHP 4.2.3 or greater on Windows. PHP5 is not yet supported.
NOTE: The Apache web server and MySQL database are strongly recommended;
other web server and database combinations such as IIS and PostgreSQL
......
......@@ -394,8 +394,6 @@ CREATE TABLE node (
nid int(10) unsigned NOT NULL auto_increment,
type varchar(16) NOT NULL default '',
title varchar(128) NOT NULL default '',
score int(11) NOT NULL default '0',
votes int(11) NOT NULL default '0',
uid int(10) NOT NULL default '0',
status int(4) NOT NULL default '1',
created int(11) NOT NULL default '0',
......@@ -403,7 +401,6 @@ CREATE TABLE node (
comment int(2) NOT NULL default '0',
promote int(2) NOT NULL default '0',
moderate int(2) NOT NULL default '0',
users longtext NOT NULL,
teaser longtext NOT NULL,
body longtext NOT NULL,
revisions longtext NOT NULL,
......@@ -530,6 +527,17 @@ CREATE TABLE poll_choices (
KEY nid (nid)
) TYPE=MyISAM;
--
-- Table structure for table 'queue'
--
CREATE TABLE queue (
nid int(10) unsigned NOT NULL,
uid int(10) unsigned NOT NULL,
vote int(3) NOT NULL default '0',
PRIMARY KEY (nid, uid)
) TYPE=MyISAM;
--
-- Table structure for table 'role'
--
......
......@@ -395,15 +395,12 @@ CREATE TABLE node (
nid SERIAL,
type varchar(16) NOT NULL default '',
title varchar(128) NOT NULL default '',
score integer NOT NULL default '0',
votes integer NOT NULL default '0',
uid integer NOT NULL default '0',
status integer NOT NULL default '1',
created integer NOT NULL default '0',
comment integer NOT NULL default '0',
promote integer NOT NULL default '0',
moderate integer NOT NULL default '0',
users text NOT NULL default '',
teaser text NOT NULL default '',
body text NOT NULL default '',
changed integer NOT NULL default '0',
......@@ -543,6 +540,19 @@ CREATE TABLE poll_choices (
);
CREATE INDEX poll_choices_nid_idx ON poll_choices(nid);
--
-- Table structure for queue
--
CREATE TABLE queue (
nid integer NOT NULL default '0',
uid integer NOT NULL default '0',
vote integer NOT NULL default '0',
PRIMARY KEY (nid, uid)
)
CREATE INDEX queue_nid_idx ON queue(nid);
CREATE INDEX queue_uid_idx ON queue(uid);
--
-- Table structure for role
--
......
......@@ -89,7 +89,8 @@
"2004-10-31: first update since Drupal 4.5.0 release" => "update_110",
"2004-11-07" => "update_111",
"2004-11-15" => "update_112",
"2004-11-28" => "update_113"
"2004-11-28" => "update_113",
"2004-12-05" => "update_114"
);
function update_32() {
......@@ -1983,7 +1984,7 @@ function update_111() {
function update_112() {
$ret = array();
$ret[] = update_sql("CREATE TABLE flood (
$ret[] = update_sql("CREATE TABLE {flood} (
event varchar(64) NOT NULL default '',
hostname varchar(128) NOT NULL default '',
timestamp int(11) NOT NULL default '0'
......@@ -2015,6 +2016,56 @@ function update_113() {
return $ret;
}
function update_114() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("CREATE TABLE {queue} (
nid int(10) unsigned NOT NULL,
uid int(10) unsigned NOT NULL,
vote int(3) NOT NULL default '0',
PRIMARY KEY (nid, uid)
)");
}
else if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql("CREATE TABLE {queue} (
nid integer NOT NULL default '0',
uid integer NOT NULL default '0',
vote integer NOT NULL default '0'
)");
$ret[] = update_sql("CREATE INDEX queue_nid_idx ON queue(nid)");
$ret[] = update_sql("CREATE INDEX queue_uid_idx ON queue(uid)");
}
$result = db_query("SELECT nid, votes, score, users FROM {node}");
while ($node = db_fetch_object($result)) {
if (isset($node->users)) {
$arr = explode(',', $node->users);
unset($node->users);
foreach ($arr as $value) {
$arr2 = explode('=', trim($value));
if (isset($arr2[0]) && isset($arr2[1])) {
switch ($arr2[1]) {
case '+ 1':
db_query("INSERT INTO {queue} (nid, uid, vote) VALUES (%d, %d, %d)", $node->nid, (int)$arr2[0], 1);
break;
case '- 1':
db_query("INSERT INTO {queue} (nid, uid, vote) VALUES (%d, %d, %d)", $node->nid, (int)$arr2[0], -1);
break;
default:
db_query("INSERT INTO {queue} (nid, uid, vote) VALUES (%d, %d, %d)", $node->nid, (int)$arr2[0], 0);
}
}
}
}
}
$ret[] = update_sql("ALTER TABLE {node} DROP votes");
$ret[] = update_sql("ALTER TABLE {node} DROP score");
$ret[] = update_sql("ALTER TABLE {node} DROP users");
return $ret;
}
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);
......
......@@ -1508,19 +1508,6 @@ function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL,
return '<a href="'. url($path, $query, $fragment, $absolute) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
}
function field_get($string, $name) {
ereg(",$name=([^,]+)", ",$string", $regs);
return $regs[1];
}
function field_set($string, $name, $value) {
$rval = ereg_replace(",$name=[^,]+", "", ",$string");
if (isset($value)) {
$rval .= ($rval == ',' ? '' : ',') . $name .'='. $value;
}
return substr($rval, 1);
}
/**
* Perform end-of-request tasks.
*
......
......@@ -73,7 +73,7 @@ function blog_help($section) {
case 'node/add/blog':
return variable_get('blog_help', '');
case 'node/add#blog':
return t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
return t("A blog is a regularly updated journal or diary made up of individual posts shown in reversed chronological order. A blog is tightly coupled to the author so each user will have his 'own' blog.");
}
}
......
......@@ -73,7 +73,7 @@ function blog_help($section) {
case 'node/add/blog':
return variable_get('blog_help', '');
case 'node/add#blog':
return t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
return t("A blog is a regularly updated journal or diary made up of individual posts shown in reversed chronological order. A blog is tightly coupled to the author so each user will have his 'own' blog.");
}
}
......
......@@ -625,7 +625,7 @@ function comment_post($edit) {
// Clear the cache so an anonymous user can see his comment being added.
cache_clear_all();
// Explain the moderation queue if necessary, and then
// Explain the approval queue if necessary, and then
// redirect the user to the node he's commenting on.
if ($status == 1) {
drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
......
......@@ -625,7 +625,7 @@ function comment_post($edit) {
// Clear the cache so an anonymous user can see his comment being added.
cache_clear_all();
// Explain the moderation queue if necessary, and then
// Explain the approval queue if necessary, and then
// redirect the user to the node he's commenting on.
if ($status == 1) {
drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
......
......@@ -48,7 +48,6 @@ function help_main() {
<dt>Moderation</dt><dd>The activity of making sure a post to a Drupal site fits in with what is expected for that Drupal site.<dl>
<dt>Approved</dt><dd>A moderated post which has been accepted by the moderators for publication. (See published).</dd>
<dt>Waiting</dt><dd>A moderated post which is still being voted on to be accepted for publication. (See published.)</dd>
<dt>Moderators</dt><dd>The group of Drupal users that reviews posts before they are published. These users have the \"access submission queue\" permission. (See Published).</dd></dl></dd>
<dt>Node</dt><dd>The basic data unit in Drupal. Everything is a node or an extension of a node.</dd>
<dt>Public</dt><dd>See published.</dd>
<dt>Published</dt><dd>A node that is viewable by everyone. (See unpublished.)</dd>
......
......@@ -48,7 +48,6 @@ function help_main() {
<dt>Moderation</dt><dd>The activity of making sure a post to a Drupal site fits in with what is expected for that Drupal site.<dl>
<dt>Approved</dt><dd>A moderated post which has been accepted by the moderators for publication. (See published).</dd>
<dt>Waiting</dt><dd>A moderated post which is still being voted on to be accepted for publication. (See published.)</dd>
<dt>Moderators</dt><dd>The group of Drupal users that reviews posts before they are published. These users have the \"access submission queue\" permission. (See Published).</dd></dl></dd>
<dt>Node</dt><dd>The basic data unit in Drupal. Everything is a node or an extension of a node.</dd>
<dt>Public</dt><dd>See published.</dd>
<dt>Published</dt><dd>A node that is viewable by everyone. (See unpublished.)</dd>
......
......@@ -29,10 +29,6 @@ function node_help($section) {
<dt>Allow user comments</dt><dd>A node can have comments. These comments can be written by other users (Read-write), or only by admins (Read-only).</dd>
<dt>Revisions</dt><dd>Drupal has a revision system so that you can \"roll back\" to an older version of a post if the new version is not what you want.</dd>
<dt>Promote to front page</dt><dd>To get people to look at the new stuff on your site you can choose to move it to the front page. The front page is configured to show the teasers from only a few of the total nodes you have on your site (To configure how many teasers <a href=\"%teaser\">click here</a>).</dd>
<dt>In moderation queue</dt><dd>Drupal has a moderation system. If it is active, a node is in one of three states: approved and published, approved and unpublished, and awaiting approval. If you are moderating a node it should be in the moderation queue.</dd>
<dt>Votes</dt><dd>If you are moderating a node this counts how many votes the node has gotten. Once a node gets a certain number of vote it will either be approved or dropped.
<dt>Score</dt><dd>The score of the node is gotten by the votes it is given.</dd>
<dt>Users</dt><dd>The list of users who have voted on a moderated node.</dd>
<dt>Published</dt><dd>When using Drupal's moderation system a node remains unpublished -- unavailable to non-moderators -- until it is marked Published.</dd></dl>
<p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/node/configure/settings")));
......
......@@ -29,10 +29,6 @@ function node_help($section) {
<dt>Allow user comments</dt><dd>A node can have comments. These comments can be written by other users (Read-write), or only by admins (Read-only).</dd>
<dt>Revisions</dt><dd>Drupal has a revision system so that you can \"roll back\" to an older version of a post if the new version is not what you want.</dd>
<dt>Promote to front page</dt><dd>To get people to look at the new stuff on your site you can choose to move it to the front page. The front page is configured to show the teasers from only a few of the total nodes you have on your site (To configure how many teasers <a href=\"%teaser\">click here</a>).</dd>
<dt>In moderation queue</dt><dd>Drupal has a moderation system. If it is active, a node is in one of three states: approved and published, approved and unpublished, and awaiting approval. If you are moderating a node it should be in the moderation queue.</dd>
<dt>Votes</dt><dd>If you are moderating a node this counts how many votes the node has gotten. Once a node gets a certain number of vote it will either be approved or dropped.
<dt>Score</dt><dd>The score of the node is gotten by the votes it is given.</dd>
<dt>Users</dt><dd>The list of users who have voted on a moderated node.</dd>
<dt>Published</dt><dd>When using Drupal's moderation system a node remains unpublished -- unavailable to non-moderators -- until it is marked Published.</dd></dl>
<p>Now that you know what is in a node, here are some of the types of nodes available.</p>", array("%teaser" => url("admin/node/configure/settings")));
......
......@@ -21,7 +21,7 @@ function page_help($section) {
case 'admin/modules#description':
return t('Enables the creation of pages that can be added to the navigation system.');
case 'node/add#page':
return t('If you just want to add a page with a link in the menu to your site, this is the best choice. Unlike a story, a static page bypasses the submission queue.');
return t('If you want to add a static page, like an a contact page or an about page, use a page.');
}
}
......
......@@ -21,7 +21,7 @@ function page_help($section) {
case 'admin/modules#description':
return t('Enables the creation of pages that can be added to the navigation system.');
case 'node/add#page':
return t('If you just want to add a page with a link in the menu to your site, this is the best choice. Unlike a story, a static page bypasses the submission queue.');
return t('If you want to add a static page, like an a contact page or an about page, use a page.');
}
}
......
......@@ -58,20 +58,16 @@ function queue_count() {
return ($result) ? db_result($result, 0) : 0;
}
function queue_score($id) {
$result = db_query('SELECT score FROM {node} WHERE nid = %d', $id);
function queue_score($nid) {
$result = db_query('SELECT SUM(vote) FROM {queue} WHERE nid = %d', $nid);
return ($result) ? db_result($result, 0) : 0;
}
function queue_vote($node, $vote) {
global $user;
if (!field_get($node->users, $user->uid)) {
// Update submission's score- and votes-field:
db_query("UPDATE {node} SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = %d", $node->nid);
// Reload the updated node from the database:
$node = node_load(array('nid' => $node->nid));
if (!isset($node->voters[$user->uid])) {
db_query("INSERT INTO {queue} (nid, uid, vote) VALUES (%d, %d, %d)", $node->nid, $user->uid, $vote);
$terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
foreach ($terms as $term) {
......@@ -113,6 +109,9 @@ function queue_vote($node, $vote) {
drupal_set_message(t('The post has expired.'));
}
}
// Reload the updated node from the database:
$node = node_load(array('nid' => $node->nid), NULL, TRUE);
}
}
......@@ -124,11 +123,12 @@ function queue_overview() {
$header = array(array('data' => t('Subject')), array('data' => t('Author')), array('data' => t('Type')), array('data' => t('Score')));
$sresult = pager_query('SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.moderate = 1', 10, 0);
$sresult = pager_query('SELECT DISTINCT(n.nid), n.title, n.type, u.name, u.uid, SUM(IF(q.uid=%d,1,0)) AS voted, SUM(q.vote) AS score FROM {node} n '. node_access_join_sql() .' INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {queue} q ON n.nid = q.nid WHERE n.moderate = 1 AND '. node_access_where_sql(), 10, 0,
'SELECT DISTINCT(n.nid) FROM {node} n '. node_access_join_sql() .' WHERE n.moderate = 1 AND '. node_access_where_sql(), $user->uid);
while ($node = db_fetch_object($sresult)) {
if ($user->uid == $node->uid || field_get($node->users, $user->uid)) {
$rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => queue_score($node->nid), 'class' => 'score'));
if ($user->uid == $node->uid || $node->voted) {
$rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => $node->score, 'class' => 'score'));
}
else {
$rows[] = array(array('data' => l($node->title, 'queue/'. $node->nid), 'class' => 'title'), array('data' => format_name($node), 'class' => 'name'), array('data' => module_invoke($node->type, 'node_name', $node), 'class' => 'type'), array('data' => l(t('vote'), 'queue/'. $node->nid), 'class' => 'score'));
......@@ -168,7 +168,7 @@ function queue_view($nid) {
$node = node_load(array('nid' => $nid, 'moderate' => 1));
if ($node) {
if ($user->uid != $node->uid && !field_get($node->users, $user->uid)) {
if ($user->uid != $node->uid && !isset($node->voters[$user->uid])) {
if ($op == t('Vote') && $votes[$edit['vote']]) {
// If it is a valid vote, record it.
......@@ -234,13 +234,10 @@ function queue_block($op = 'list', $delta = 0) {
$id = arg(2);
}
$node = node_load(array('nid' => $id));
if (($user->uid == $node->uid || field_get($node->users, $user->uid)) && $node->moderate == 1) {
foreach (explode(',', $node->users) as $vote) {
if ($vote) {
$data = explode('=', $vote);
$account = user_load(array('uid' => $data[0]));
$output .= format_name($account) ." voted \"$data[1]\".<br />";
}
if (($user->uid == $node->uid || isset($node->voters[$user->uid])) && $node->moderate == 1) {
foreach ($node->voters as $uid => $vote) {
$account = user_load(array('uid' => $uid));
$output .= t('%user voted %vote', array('%user' => format_name($account), '%vote' => $vote)) .'<br />';
}
$block['subject'] = t('Moderation results');
......@@ -258,17 +255,27 @@ function queue_block($op = 'list', $delta = 0) {
*/
function queue_nodeapi(&$node, $op) {
switch ($op) {
case 'fields':
return array('score', 'users', 'votes');
case 'load':
$result = db_query("SELECT uid, vote FROM {queue} WHERE nid = %d", $node->nid);
$node->voters = array();
$node->score = 0;
while ($voter = db_fetch_object($result)) {
$node->voters[$voter->uid] = $voter->vote;
$node->score += $voter->vote;
}
break;
case 'validate':
if ($node->nid && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
$node->users = '';
$node->voters = array();
$node->votes = 0;
}
break;
case 'insert':
if ($node->moderate) {
db_query("INSERT INTO {queue} (nid, uid) VALUES (%d, %d)", $node->nid, $node->uid);
}
case 'update':
if ($node->moderate && user_access('access submission queue')) {
drupal_set_message(t('The post is queued for approval. You can check the votes in the <a href="%queue">submission queue</a>.', array('%queue' => url('queue'))));
......
......@@ -26,7 +26,7 @@ function story_help($section) {
case 'node/add/story':
return variable_get('story_help', '');
case 'node/add#story':
return t('A story is similar to an article and usually gets promoted to the front page after approval or moderation.');
return t('A story is similar to an article and usually gets promoted to the front page. If you want to post news items, articles or maintain a group blog, use stories.');
}
}
......
......@@ -26,7 +26,7 @@ function story_help($section) {
case 'node/add/story':
return variable_get('story_help', '');
case 'node/add#story':
return t('A story is similar to an article and usually gets promoted to the front page after approval or moderation.');
return t('A story is similar to an article and usually gets promoted to the front page. If you want to post news items, articles or maintain a group blog, use stories.');
}
}
......
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