summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-11-18 13:21:16 +0100
committerAndrew Dolgov <[email protected]>2005-11-18 13:21:16 +0100
commitfefa6ca3afec86c405b8df13386ed0cc43668a0a (patch)
treee5f993f9c5b36932a8972a1deee65014655f3b14 /functions.php
parent717f5e645b47a444bb0a2f524658e36ad1a4b74f (diff)
globalPurge rpc call
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php57
1 files changed, 47 insertions, 10 deletions
diff --git a/functions.php b/functions.php
index 730b1fedd..355226e8d 100644
--- a/functions.php
+++ b/functions.php
@@ -9,6 +9,52 @@
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
+ function purge_feed($link, $feed_id, $purge_interval) {
+
+ if (DB_TYPE == "pgsql") {
+ db_query($link, "DELETE FROM ttrss_entries WHERE
+ marked = false AND feed_id = '$feed_id' AND
+ date_entered < NOW() - INTERVAL '$purge_interval days'");
+ } else {
+ db_query($link, "DELETE FROM ttrss_entries WHERE
+ marked = false AND feed_id = '$feed_id' AND
+ date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
+ }
+ }
+
+ function global_purge_old_posts($link, $do_output = false) {
+
+ $result = db_query($link,
+ "SELECT id,purge_interval,owner_uid FROM ttrss_feeds");
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $feed_id = $line["id"];
+ $purge_interval = $line["purge_interval"];
+ $owner_uid = $line["owner_uid"];
+
+ if ($purge_interval == 0) {
+
+ $tmp_result = db_query($link,
+ "SELECT value FROM ttrss_user_prefs WHERE
+ pref_name = 'PURGE_OLD_DAYS' AND owner_uid = '$owner_uid'");
+
+ if (db_num_rows($tmp_result) != 0) {
+ $purge_interval = db_fetch_result($tmp_result, 0, "value");
+ }
+ }
+
+ if ($do_output) {
+ print "<feed id='$feed_id' p_intl='$purge_interval'/>";
+ }
+
+ if ($purge_interval > 0) {
+ purge_feed($link, $feed_id, $purge_interval);
+ }
+ }
+
+ }
+
function purge_old_posts($link) {
$user_id = $_SESSION["uid"];
@@ -24,16 +70,7 @@
if ($purge_interval == 0) $purge_interval = get_pref($link, 'PURGE_OLD_DAYS');
if ($purge_interval > 0) {
-
- if (DB_TYPE == "pgsql") {
- db_query($link, "DELETE FROM ttrss_entries WHERE
- marked = false AND feed_id = '$feed_id' AND
- date_entered < NOW() - INTERVAL '$purge_interval days'");
- } else {
- db_query($link, "DELETE FROM ttrss_entries WHERE
- marked = false AND feed_id = '$feed_id' AND
- date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
- }
+ purge_feed($link, $feed_id, $purge_interval);
}
}
}