cvs: pearweb /include/Damblan Trackback.php
| From: | Tobias Schlitt | Date: | Tue, 01 Mar 2005 15:41:48 +0000 |
| Subject: | cvs: pearweb /include/Damblan Trackback.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-29952@lists.php.net to get a copy of this message | ||
toby Tue Mar 1 10:41:48 2005 EDT
Modified files:
/pearweb/include/Damblan Trackback.php
Log:
* Added count function, needed for stats.
http://cvs.php.net/diff.php/pearweb/include/Damblan/Trackback.php?r1=1.7&r2=1.8&ty=u
Index: pearweb/include/Damblan/Trackback.php
diff -u pearweb/include/Damblan/Trackback.php:1.7 pearweb/include/Damblan/Trackback.php:1.8
--- pearweb/include/Damblan/Trackback.php:1.7 Tue Mar 1 05:15:40 2005
+++ pearweb/include/Damblan/Trackback.php Tue Mar 1 10:41:48 2005
@@ -65,6 +65,25 @@
}
/**
+ * Get number of all in all available trackbacks.
+ *
+ *
+ * @param object(DB) $dbh The database connection.
+ * @param bool $approvedOnly Only show approved trackbacks? (!$isAdmin)
+ * @param bool $unapprovedOnly Only show unapproved trackbacks?
+ */
+ function getCount(&$dbh, $approvedOnly = true, $unapprovedOnly = false)
+ {
+ $sql = 'SELECT COUNT(*) FROM trackbacks';
+ if ($approvedOnly) {
+ $sql .= ' WHERE approved = '.$dbh->quoteSmart('true');
+ } else if ($unapprovedOnly) {
+ $sql .= ' WHERE approved = '.$dbh->quoteSmart('false');
+ }
+ return $dbh->getOne($sql);
+ }
+
+ /**
* Check for possible spam
* Checks the database for recent trackbacks from the same IP.
* Every IP is allows to post $this->_repostCount times in
@@ -323,7 +342,7 @@
* @return array Array of PEAR_Trackback objects.
* @throws Exception If no results are received.
*/
- function recentTrackbacks(&$dbh, $offset = 0, $number = 10, $approvedOnly = true)
+ function recentTrackbacks(&$dbh, $offset = 0, $number = 10, $approvedOnly = true,
$unapprovedOnly = false)
{
if ($offset < 0) {
return PEAR::raiseError('Offset out of range. Offset must be integer >=
0.');
@@ -335,6 +354,8 @@
FROM trackbacks';
if ($approvedOnly) {
$sql .= ' WHERE approved = '.$dbh->quoteSmart('true');
+ } else if ($unapprovedOnly) {
+ $sql .= ' WHERE approved = '.$dbh->quoteSmart('false');
}
$sql .= ' ORDER BY timestamp DESC LIMIT ' . $offset . ',' . $number;
$res = $dbh->getAll($sql, null, DB_FETCHMODE_ASSOC);