[geeklog-cvs] geeklog: Introduced PLG_itemDeleted and call it when deleting a ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Jan 25 03:29:44 EST 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/b75043713337
changeset: 6719:b75043713337
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Jan 25 09:28:56 2009 +0100
description:
Introduced PLG_itemDeleted and call it when deleting a story

diffstat:

2 files changed, 34 insertions(+), 4 deletions(-)
system/lib-plugins.php |   27 +++++++++++++++++++++++++++
system/lib-story.php   |   11 +++++++----

diffs (71 lines):

diff -r 07cb671a87f0 -r b75043713337 system/lib-plugins.php
--- a/system/lib-plugins.php	Sat Jan 24 21:10:21 2009 +0100
+++ b/system/lib-plugins.php	Sun Jan 25 09:28:56 2009 +0100
@@ -2089,6 +2089,33 @@
 }
 
 /**
+* "Generic" plugin API: Delete item
+*
+* To be called (eventually) whenever Geeklog removes an item from the database.
+* Plugins can define their own 'itemdeleted' function to be notified whenever
+* an item is deleted.
+*
+* @param    string  $id     ID of the item
+* @param    string  $type   type of the item, e.g. 'article'
+* @returns  void
+*
+*/
+function PLG_itemDeleted($id, $type)
+{
+    global $_PLUGINS;
+
+    $plugins = count($_PLUGINS);
+    for ($del = 0; $del < $plugins; $del++) {
+        if ($_PLUGINS[$del] != $type) {
+            $function = 'plugin_itemdeleted_' . $_PLUGINS[$del];
+            if (function_exists($function)) {
+                $function($id, $type);
+            }
+        }
+    }
+}
+
+/**
 * "Generic" plugin API: Display item
 *
 * To be called (eventually) whenever Geeklog displays an item.
diff -r 07cb671a87f0 -r b75043713337 system/lib-story.php
--- a/system/lib-story.php	Sat Jan 24 21:10:21 2009 +0100
+++ b/system/lib-story.php	Sun Jan 25 09:28:56 2009 +0100
@@ -2,13 +2,13 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Geeklog 1.5                                                               |
+// | Geeklog 1.6                                                               |
 // +---------------------------------------------------------------------------+
 // | lib-story.php                                                             |
 // |                                                                           |
 // | Story-related functions needed in more than one place.                    |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2008 by the following authors:                         |
+// | Copyright (C) 2000-2009 by the following authors:                         |
 // |                                                                           |
 // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
 // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
@@ -1327,9 +1327,12 @@
     // delete Trackbacks
     DB_query ("DELETE FROM {$_TABLES['trackback']} WHERE sid = '$sid' AND type = 'article';");
 
+    // notify plugins
+    PLG_itemDeleted($sid, 'article');
+
     // update RSS feed and Older Stories block
-    COM_rdfUpToDateCheck ();
-    COM_olderStuff ();
+    COM_rdfUpToDateCheck();
+    COM_olderStuff();
 
     $output = COM_refresh ($_CONF['site_admin_url'] . '/story.php?msg=10');
 



More information about the geeklog-cvs mailing list