cvs: phpweb /bin user-notes.php /manual admin-notes.php
| From: | Jim Winstead | Date: | Tue, 28 Aug 2001 06:10:28 +0000 |
| Subject: | cvs: phpweb /bin user-notes.php /manual admin-notes.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-6154@lists.php.net to get a copy of this message | ||
jimw Tue Aug 28 02:10:28 2001 EDT
Modified files:
/phpweb/manual admin-notes.php
/phpweb/bin user-notes.php
Log:
entries just get flagged for deletion and purged later, so sections with deleted notes get updated
properly
Index: phpweb/manual/admin-notes.php
diff -u phpweb/manual/admin-notes.php:1.38 phpweb/manual/admin-notes.php:1.39
--- phpweb/manual/admin-notes.php:1.38 Sun Jul 8 17:07:50 2001
+++ phpweb/manual/admin-notes.php Tue Aug 28 02:10:28 2001
@@ -102,7 +102,7 @@
if ($result = mysql_query($query)) {
$row = mysql_fetch_array($result);
mail("php-notes@lists.php.net","note ".$row['id']." deleted
from ".$row['sect']." by
$u",stripslashes($row['note']),"From: ".$u."@php.net");
- $query = 'DELETE FROM note WHERE id=' . $id;
+ $query = 'UPDATE note SET removed=1 WHERE id=' . $id;
if (mysql_query($query)) {
echo '<P><B>Note deleted.</B>';
if ($popup) {?>
@@ -144,7 +144,7 @@
//mail($submitter,"note ".$row['id']." rejected and deleted from
".$row['sect']." by notes editor $u",$reject_text."----- Copy of your
note below -----\n\n".stripslashes($row['note']),"From:
php-notes@lists.php.net");
// email to the php-notes list
mail("php-notes@lists.php.net","note ".$row['id']." rejected
and deleted from ".$row['sect']." by
$u",stripslashes($row['note']),"From: ".$u."@php.net");
- $query = 'DELETE FROM note WHERE id=' . $id;
+ $query = 'UPDATE note SET removed=1 WHERE id=' . $id;
if (mysql_query($query)) {
echo '<B>rejected and deleted.</B></p>';
}
@@ -180,7 +180,7 @@
$row = mysql_fetch_array($result);
}
$add_url = "\n\nhttp://www.php.net/manual/en/".sect_to_file($row['sect'])."\n";
- $query = "UPDATE note SET user='$nuser',note='$note' WHERE id=$id";
+ $query = "UPDATE note SET user='$nuser',note='$note',updated=NOW() WHERE
id=$id";
if (mysql_query($query)) {
echo "<P><B>Record modified.</B>";
mail("php-notes@lists.php.net","note ".$row['id']." modified
in ".$row['sect']." by $u",stripslashes($note).$add_url,"From:
".$u."@php.net");
@@ -205,7 +205,7 @@
// Aparently using "xwhen" does not contend w/ the MySQL namespace
// I could not find docs in which there was a "WHEN" keyword for MySQL
- $query = 'SELECT *,UNIX_TIMESTAMP(ts) AS xwhen FROM note ORDER BY sect,ts'.$limit;
+ $query = 'SELECT *,UNIX_TIMESTAMP(ts) AS xwhen FROM note WHERE NOT removed ORDER BY
sect,ts'.$limit;
$result = mysql_query($query);
if ($error = mysql_error()) {
echo "<br>ERROR in MySQL: ".mysql_error()."<br>";
Index: phpweb/bin/user-notes.php
diff -u phpweb/bin/user-notes.php:1.2 phpweb/bin/user-notes.php:1.3
--- phpweb/bin/user-notes.php:1.2 Tue Aug 28 00:44:01 2001
+++ phpweb/bin/user-notes.php Tue Aug 28 02:10:28 2001
@@ -11,18 +11,23 @@
mysql_connect("localhost","nobody","") or die("unable to connect
to db");
mysql_select_db("php3") or die("unable to select database");
+if ($since) {
+ mysql_query("CREATE TEMPORARY TABLE updated TYPE = HEAP SELECT DISTINCT sect FROM note WHERE
ts > FROM_UNIXTIME($since) OR updated > FROM_UNIXTIME($since)")
+ or die("failed to create temporary table");
+ # purge entries marked for removal
+ mysql_query("DELETE FROM note WHERE removed");
+}
+
$query = "SELECT DISTINCT id,note.sect,user,note,UNIX_TIMESTAMP(ts) AS ts,";
$query .= "IF(votes=0, 10, rating/votes) AS rate";
$query .= " FROM note";
if ($since) {
- $query .= ",updated WHERE note.sect=updated.sect";
+ $query .= ",updated WHERE note.sect=updated.sect AND NOT removed";
}
-$query .= " ORDER BY sect,rate DESC,ts";
-
-if ($since) {
- mysql_query("CREATE TEMPORARY TABLE updated TYPE = HEAP SELECT DISTINCT sect FROM note WHERE
ts > FROM_UNIXTIME($since) OR updated > FROM_UNIXTIME($since)")
- or die("failed to create temporary table");
+else {
+ $query .= " WHERE NOT removed";
}
+$query .= " ORDER BY sect,rate DESC,ts";
$res = mysql_query($query) or die("query failed");