[geeklog-cvs] geeklog: Simplified PLG_itemSaved and added an optional $old_id ...
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/07cb671a87f0
changeset: 6718:07cb671a87f0
user: Dirk Haun <dirk at haun-online.de>
date: Sat Jan 24 21:10:21 2009 +0100
description:
Simplified PLG_itemSaved and added an optional $old_id parameter; call PLG_itemSaved whenever a story is saved; drop in_transit column from the stories table
diffstat:
9 files changed, 35 insertions(+), 59 deletions(-)
public_html/admin/moderation.php | 7 ++---
public_html/index.php | 12 ++++-----
sql/mssql_tableanddata.php | 1
sql/mysql_tableanddata.php | 2 -
sql/updates/mssql_1.5.2_to_1.6.0.php | 2 +
sql/updates/mysql_1.5.2_to_1.6.0.php | 3 ++
system/classes/story.class.php | 8 ++----
system/lib-plugins.php | 42 +++++++++++-----------------------
system/lib-story.php | 17 ++++---------
diffs (293 lines):
diff -r 0fc898f2081e -r 07cb671a87f0 public_html/admin/moderation.php
--- a/public_html/admin/moderation.php Sat Jan 24 14:50:56 2009 +0100
+++ b/public_html/admin/moderation.php Sat Jan 24 21:10:21 2009 +0100
@@ -2,13 +2,13 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.5 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | moderation.php |
// | |
// | Geeklog main administration page. |
// +---------------------------------------------------------------------------+
-// | 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 |
@@ -31,8 +31,6 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: moderation.php,v 1.124 2008/09/04 19:03:29 mjervis Exp $
require_once '../lib-common.php';
require_once 'auth.inc.php';
@@ -536,6 +534,7 @@
"'{$A['sid']}',{$A['uid']},'{$A['tid']}','{$A['title']}','{$A['introtext']}','{$A['bodytext']}','{$A['related']}','{$A['date']}','{$_CONF['show_topic_icon']}','{$_CONF['comment_code']}','{$_CONF['trackback_code']}','{$A['postmode']}',$frontpage,{$A['owner_id']},{$T['group_id']},{$T['perm_owner']},{$T['perm_group']},{$T['perm_members']},{$T['perm_anon']}");
DB_delete($_TABLES['storysubmission'],"$id",$mid[$i]);
+ PLG_itemSaved($A['sid'], 'article');
COM_rdfUpToDateCheck ();
COM_olderStuff ();
} else if ($type == 'draft') {
diff -r 0fc898f2081e -r 07cb671a87f0 public_html/index.php
--- a/public_html/index.php Sat Jan 24 14:50:56 2009 +0100
+++ b/public_html/index.php Sat Jan 24 21:10:21 2009 +0100
@@ -2,13 +2,13 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.4 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | index.php |
// | |
// | Geeklog homepage. |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2007 by the following authors: |
+// | Copyright (C) 2000-2009 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony at tonybibbs.com |
// | Mark Limburg - mlimburg at users.sourceforge.net |
@@ -31,11 +31,9 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: index.php,v 1.99 2008/08/14 19:05:53 mjervis Exp $
-require_once ('lib-common.php');
-require_once ($_CONF['path_system'] . 'lib-story.php');
+require_once 'lib-common.php';
+require_once $_CONF['path_system'] . 'lib-story.php';
$newstories = false;
$displayall = false;
@@ -282,7 +280,7 @@
. "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND"
. $sql . "ORDER BY featured DESC, date DESC LIMIT $offset, $limit";
-$msql['mssql']="SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, cast(s.introtext as text) as introtext, cast(s.bodytext as text) as bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, "
+$msql['mssql']="SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, cast(s.introtext as text) as introtext, cast(s.bodytext as text) as bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, "
. " UNIX_TIMESTAMP(s.date) AS unixdate, "
. 'UNIX_TIMESTAMP(s.expire) as expireunix, '
. $userfields . ", t.topic, t.imageurl "
diff -r 0fc898f2081e -r 07cb671a87f0 sql/mssql_tableanddata.php
--- a/sql/mssql_tableanddata.php Sat Jan 24 14:50:56 2009 +0100
+++ b/sql/mssql_tableanddata.php Sat Jan 24 21:10:21 2009 +0100
@@ -260,7 +260,6 @@
[postmode] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[advanced_editor_mode] [tinyint] NOT NULL ,
[frontpage] [tinyint] NULL ,
- [in_transit] [tinyint] NULL ,
[owner_id] [int] NOT NULL ,
[group_id] [int] NOT NULL ,
[perm_owner] [tinyint] NOT NULL ,
diff -r 0fc898f2081e -r 07cb671a87f0 sql/mysql_tableanddata.php
--- a/sql/mysql_tableanddata.php Sat Jan 24 14:50:56 2009 +0100
+++ b/sql/mysql_tableanddata.php Sat Jan 24 21:10:21 2009 +0100
@@ -280,7 +280,6 @@
postmode varchar(10) NOT NULL default 'html',
advanced_editor_mode tinyint(1) unsigned default '0',
frontpage tinyint(3) unsigned default '1',
- in_transit tinyint(1) unsigned default '0',
owner_id mediumint(8) NOT NULL default '1',
group_id mediumint(8) NOT NULL default '2',
perm_owner tinyint(1) unsigned NOT NULL default '3',
@@ -296,7 +295,6 @@
INDEX stories_expire(expire),
INDEX stories_date(date),
INDEX stories_frontpage(frontpage),
- INDEX stories_in_transit(in_transit),
PRIMARY KEY (sid)
) TYPE=MyISAM
";
diff -r 0fc898f2081e -r 07cb671a87f0 sql/updates/mssql_1.5.2_to_1.6.0.php
--- a/sql/updates/mssql_1.5.2_to_1.6.0.php Sat Jan 24 14:50:56 2009 +0100
+++ b/sql/updates/mssql_1.5.2_to_1.6.0.php Sat Jan 24 21:10:21 2009 +0100
@@ -1,4 +1,6 @@
<?php
+
+$_SQL[] = "ALTER TABLE {$_TABLES['stories']} DROP COLUMN in_transit";
function update_ConfValues()
{
diff -r 0fc898f2081e -r 07cb671a87f0 sql/updates/mysql_1.5.2_to_1.6.0.php
--- a/sql/updates/mysql_1.5.2_to_1.6.0.php Sat Jan 24 14:50:56 2009 +0100
+++ b/sql/updates/mysql_1.5.2_to_1.6.0.php Sat Jan 24 21:10:21 2009 +0100
@@ -1,4 +1,7 @@
<?php
+
+$_SQL[] = "ALTER TABLE {$_TABLES['stories']} DROP INDEX stories_in_transit";
+$_SQL[] = "ALTER TABLE {$_TABLES['stories']} DROP COLUMN in_transit";
function update_ConfValues()
{
diff -r 0fc898f2081e -r 07cb671a87f0 system/classes/story.class.php
--- a/system/classes/story.class.php Sat Jan 24 14:50:56 2009 +0100
+++ b/system/classes/story.class.php Sat Jan 24 21:10:21 2009 +0100
@@ -2,7 +2,7 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.5 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | story.class.php |
// | |
@@ -126,7 +126,6 @@
var $_expire;
var $_advanced_editor_mode;
var $_frontpage;
- var $_in_transit;
var $_owner_id;
var $_group_id;
var $_perm_owner;
@@ -193,7 +192,6 @@
'postmode' => 1,
'advanced_editor_mode' => 1,
'frontpage' => 1,
- 'in_transit' => 1,
'owner_id' => 1,
'group_id' => 1,
'perm_owner' => 1,
@@ -404,7 +402,7 @@
. "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '$sid')";
$sql['mssql'] =
- "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '$sid')";
+ "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '$sid')";
} elseif (!empty($sid) && ($mode == 'editsubmission')) {
$sql = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, '
. 'u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
@@ -633,7 +631,6 @@
// Get the related URLs
$this->_related = implode("\n", STORY_extractLinks("{$this->_introtext} {$this->_bodytext}"));
- $this->_in_transit = 1;
$values = '';
$fields = '';
reset($this->_dbFields);
@@ -933,6 +930,7 @@
$this->saveToDatabase();
+ PLG_itemSaved($this->_sid, 'article');
COM_rdfUpToDateCheck();
COM_olderStuff();
diff -r 0fc898f2081e -r 07cb671a87f0 system/lib-plugins.php
--- a/system/lib-plugins.php Sat Jan 24 14:50:56 2009 +0100
+++ b/system/lib-plugins.php Sat Jan 24 21:10:21 2009 +0100
@@ -2,13 +2,13 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.5 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | lib-plugins.php |
// | |
// | This file implements plugin support in Geeklog. |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2008 by the following authors: |
+// | Copyright (C) 2000-2009 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
// | Blaine Lang - blaine AT portalparts DOT com |
@@ -2061,45 +2061,31 @@
* "Generic" plugin API: Save item
*
* To be called (eventually) whenever Geeklog saves an item into the database.
-* Plugins can hook into this and modify the item (which is already in the
-* database but not visible on the site yet).
-*
-* Plugins can signal an error by returning an error message (otherwise, they
-* should return 'false' to signal "no errors"). In case of an error, all the
-* plugins called up to that point will be invoked through an "abort" call to
-* undo their changes.
+* Plugins can define their own 'itemsaved' function to be notified whenever
+* an item is saved or modified.
*
* @param string $id unique ID of the item
* @param string $type type of the item, e.g. 'article'
-* @returns mixed Boolean false for "no error", or an error msg text
+* @param string $old_id (optional) old ID when the ID was changed
+* @returns void (actually: false, for backward compatibility)
+* @note The behaviour of this API function changed in Geeklog 1.6.0
*
*/
-function PLG_itemSaved($id, $type)
+function PLG_itemSaved($id, $type, $old_id = '')
{
global $_PLUGINS;
- $error = false;
-
- $plugins = count ($_PLUGINS);
+ $plugins = count($_PLUGINS);
for ($save = 0; $save < $plugins; $save++) {
- $function = 'plugin_itemsaved_' . $_PLUGINS[$save];
- if (function_exists($function)) {
- $error = $function($id, $type);
- if ($error !== false) {
- // plugin reported a problem - abort
-
- for ($abort = 0; $abort < $save; $abort++) {
- $function = 'plugin_abortsave_' . $_PLUGINS[$abort];
- if (function_exists($function)) {
- $function($id, $type);
- }
- }
- break; // out of for($save) loop
+ if ($_PLUGINS[$save] != $type) {
+ $function = 'plugin_itemsaved_' . $_PLUGINS[$save];
+ if (function_exists($function)) {
+ $function($id, $type, $old_id);
}
}
}
- return $error;
+ return false; // for backward compatibility
}
/**
diff -r 0fc898f2081e -r 07cb671a87f0 system/lib-story.php
--- a/system/lib-story.php Sat Jan 24 14:50:56 2009 +0100
+++ b/system/lib-story.php Sat Jan 24 21:10:21 2009 +0100
@@ -1259,17 +1259,10 @@
if ($result == STORY_SAVED) {
// see if any plugins want to act on that story
- $plugin_error = PLG_itemSaved ($sid, 'article');
-
- // always clear 'in_transit' flag
- DB_change ($_TABLES['stories'], 'in_transit', 0, 'sid', $sid);
-
- // in case of an error go back to the story editor
- if ($plugin_error !== false) {
- $output .= COM_siteHeader ('menu', $LANG24[5]);
- $output .= storyeditor ($sid, 'retry', $plugin_error);
- $output .= COM_siteFooter ();
- return PLG_RET_ERROR;
+ if ((! empty($args['old_sid'])) && ($args['old_sid'] != $sid)) {
+ PLG_itemSaved($sid, 'article', $args['old_sid']);
+ } else {
+ PLG_itemSaved($sid, 'article');
}
// update feed(s) and Older Stories block
@@ -1475,7 +1468,7 @@
. "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid)" . COM_getPermSQL('AND', $_USER['uid'], 2, 's') . $order . $limit;
$sql['mssql'] =
- "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.in_transit, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid)" . COM_getPermSQL('AND', $_USER['uid'], 2, 's') . $order . $limit;
+ "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid)" . COM_getPermSQL('AND', $_USER['uid'], 2, 's') . $order . $limit;
$result = DB_query($sql);
More information about the geeklog-cvs
mailing list