[geeklog-cvs] geeklog: When disabling a feed, delete the feed file
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat Aug 1 16:47:38 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/8c668abba68e
changeset: 7215:8c668abba68e
user: Dirk Haun <dirk at haun-online.de>
date: Sat Aug 01 18:37:21 2009 +0200
description:
When disabling a feed, delete the feed file
diffstat:
public_html/admin/syndication.php | 63 +++++++++++++++++++++++++------
public_html/docs/history | 3 +
2 files changed, 53 insertions(+), 13 deletions(-)
diffs (140 lines):
diff -r dcded8e32765 -r 8c668abba68e public_html/admin/syndication.php
--- a/public_html/admin/syndication.php Sat Aug 01 13:58:10 2009 +0200
+++ b/public_html/admin/syndication.php Sat Aug 01 18:37:21 2009 +0200
@@ -45,6 +45,23 @@
}
/**
+* Delete a feed's file
+*
+* @param string filename (without the path) of the feed
+* @return void
+*
+*/
+function deleteFeedFile($filename)
+{
+ if (! empty($filename)) {
+ $feedfile = SYND_getFeedPath($filename);
+ if (file_exists($feedfile)) {
+ @unlink($feedfile);
+ }
+ }
+}
+
+/**
* Toggle status of a feed from enabled to disabled and back
*
* @param int $fid ID of the feed
@@ -55,17 +72,29 @@
{
global $_TABLES;
+ $changes = false;
+
// first disable all
- DB_query ("UPDATE {$_TABLES['syndication']} SET is_enabled = '0'");
+ DB_query("UPDATE {$_TABLES['syndication']} SET is_enabled = 0");
if (isset($fid_arr)) {
foreach ($fid_arr as $fid) {
- $feed_id = addslashes (COM_applyFilter ($fid, true));
- if (!empty ($fid)) {
+ $feed_id = addslashes(COM_applyFilter($fid, true));
+ if (!empty($fid)) {
// now enable those in the array
- DB_query ("UPDATE {$_TABLES['syndication']} SET is_enabled = '1' WHERE fid = '$fid'");
+ DB_query("UPDATE {$_TABLES['syndication']} SET is_enabled = 1 WHERE fid = '$fid'");
+ $changes = true;
}
}
}
+
+ if ($changes) {
+ $result = DB_query("SELECT filename FROM {$_TABLES['syndication']} WHERE is_enabled = 0");
+ $num_feeds_off = DB_numRows($result);
+ for ($i = 0; $i < $num_feeds_off; $i++) {
+ list($feedfile) = DB_fetchArray($result);
+ deleteFeedFile($feedfile);
+ }
+ }
}
/**
@@ -92,7 +121,7 @@
/**
* Return list of types available for article feeds
*
-* @return string an array with id/name pairs for every feed
+* @return array an array with id/name pairs for every feed
*
*/
function get_articleFeeds()
@@ -123,6 +152,12 @@
return $options;
}
+/**
+* List all feeds
+*
+* @return string HTML with the list of all feeds
+*
+*/
function listfeeds()
{
global $_CONF, $_TABLES, $LANG_ADMIN, $LANG33, $_IMAGE_TYPE;
@@ -508,15 +543,19 @@
$A[$name] = addslashes ($value);
}
- DB_save ($_TABLES['syndication'], 'fid,type,topic,header_tid,format,limits,content_length,title,description,feedlogo,filename,charset,language,is_enabled,updated,update_info',
+ DB_save($_TABLES['syndication'], 'fid,type,topic,header_tid,format,limits,content_length,title,description,feedlogo,filename,charset,language,is_enabled,updated,update_info',
"{$A['fid']},'{$A['type']}','{$A['topic']}','{$A['header_tid']}','{$A['format']}','{$A['limits']}',{$A['content_length']},'{$A['title']}','{$A['description']}','{$A['feedlogo']}','{$A['filename']}','{$A['charset']}','{$A['language']}',{$A['is_enabled']},'0000-00-00 00:00:00',NULL");
if ($A['fid'] == 0) {
- $A['fid'] = DB_insertId ();
+ $A['fid'] = DB_insertId();
}
- SYND_updateFeed ($A['fid']);
+ if ($A['is_enabled'] == 1) {
+ SYND_updateFeed($A['fid']);
+ } else {
+ deleteFeedFile($A['filename']);
+ }
- return COM_refresh ($_CONF['site_admin_url'] . '/syndication.php?msg=58');
+ return COM_refresh($_CONF['site_admin_url'] . '/syndication.php?msg=58');
}
/**
@@ -533,9 +572,7 @@
if ($fid > 0) {
$feedfile = DB_getItem($_TABLES['syndication'], 'filename',
"fid = $fid");
- if (!empty($feedfile)) {
- @unlink(SYND_getFeedPath($feedfile));
- }
+ deleteFeedFile($feedfile);
DB_delete($_TABLES['syndication'], 'fid', $fid);
return COM_refresh($_CONF['site_admin_url']
@@ -569,7 +606,7 @@
. COM_siteFooter ();
}
}
-else if (($mode == $LANG33[1]) && !empty ($LANG33[1]))
+elseif (($mode == $LANG33[1]) && !empty ($LANG33[1]))
{
$display .= COM_siteHeader ('menu', $LANG33[24])
. editfeed (0, COM_applyFilter($_REQUEST['type']))
diff -r dcded8e32765 -r 8c668abba68e public_html/docs/history
--- a/public_html/docs/history Sat Aug 01 13:58:10 2009 +0200
+++ b/public_html/docs/history Sat Aug 01 18:37:21 2009 +0200
@@ -3,6 +3,9 @@
??? ??, 2009 (1.6.1)
------------
+- When disabling a feed, delete the feed file [Dirk]
+- Fixed an SQL error when the commentcode field was auto-updated (reported by
+ Jokke_K) [Dirk]
- Moved leftover hard-coded text from admin/sectest.php to the language files
[Dirk]
- When creating Pingback excerpts, convert the other site's content to our
More information about the geeklog-cvs
mailing list