[pLog-svn] r956 - in plog/trunk: . class/dao class/plugin
templates/admin
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sat Feb 5 18:58:44 GMT 2005
Author: oscar
Date: 2005-02-05 18:58:43 +0000 (Sat, 05 Feb 2005)
New Revision: 956
Modified:
plog/trunk/class/dao/trackbacks.class.php
plog/trunk/class/plugin/eventlist.properties.php
plog/trunk/templates/admin/sendtrackbacks.template
plog/trunk/trackback.php
Log:
now the trackback.php script will throw PRE_TRACKBACK_ADD and POST_TRACKBACK_ADD as per issue 199 (http://bugs.plogworld.net/view.php?id=199) events every time a trackback is received.
Trackbacks::addTrackback() has been modified so that now it can only receive a Trackback object, plus renamed PRE_TRACKBACK_SAVE and POST_TRACKBACKB_SAVE to the new names so that all events follow a similar naming scheme.
The sendtrackbacks.template has also been modified so that the page follows our guidelines.
Modified: plog/trunk/class/dao/trackbacks.class.php
===================================================================
--- plog/trunk/class/dao/trackbacks.class.php 2005-02-05 18:39:30 UTC (rev 955)
+++ plog/trunk/class/dao/trackbacks.class.php 2005-02-05 18:58:43 UTC (rev 956)
@@ -39,15 +39,16 @@
/**
* Adds a trackback to the database.
*
- * @param artId The article to which we are adding the trackback.
- * @param title The title of the entry pinging us.
- * @param url Permalink for the entry.
- * @param blog The name of the blog where the entry is posted.
- * @param excerpt An excerpt of the entry.
- * @return Returns true if the entry was added successfully to the database.
+ * @param A Trackback object
*/
- function addTrackBack( $artId, $url, $title = "", $blog = "", $excerpt = "")
+ function addTrackback( $trackback )
{
+ $artId = $trackback->getArticleId();
+ $url = $trackback->getUrl();
+ $title = $trackback->getTitle();
+ $blog = $trackback->getBlogName();
+ $excerpt = $trackback->getExcerpt();
+
if( $title == "" )
$title = $url;
Modified: plog/trunk/class/plugin/eventlist.properties.php
===================================================================
--- plog/trunk/class/plugin/eventlist.properties.php 2005-02-05 18:39:30 UTC (rev 955)
+++ plog/trunk/class/plugin/eventlist.properties.php 2005-02-05 18:58:43 UTC (rev 956)
@@ -47,8 +47,8 @@
define( "EVENT_PRE_MARK_NO_SPAM_COMMENT", 26 );
define( "EVENT_POST_MARK_NO_SPAM_COMMENT", 27 );
// before and after a trackback is received
- define( "EVENT_PRE_TRACKBACK_SAVE", 28 );
- define( "EVENT_POST_TRACKBACK_SAVE", 29 );
+ define( "EVENT_PRE_TRACKBACK_ADD", 28 );
+ define( "EVENT_POST_TRACKBACK_ADD", 29 );
// load the post trackbacks
define( "EVENT_TRACKBACKS_LOADED", 30 );
// successful and unsuccessful login
Modified: plog/trunk/templates/admin/sendtrackbacks.template
===================================================================
--- plog/trunk/templates/admin/sendtrackbacks.template 2005-02-05 18:39:30 UTC (rev 955)
+++ plog/trunk/templates/admin/sendtrackbacks.template 2005-02-05 18:58:43 UTC (rev 956)
@@ -1,11 +1,12 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=newPost title=$locale->tr("send_trackback_pings")}
- {include file="$admintemplatepath/successmessage.template"}
- {include file="$admintemplatepath/errormessage.template"}
<form name="pingThese" method="post" action="admin.php">
<fieldset class="inputField">
- <label for="postLink">{$locale->tr("trackback_links")}</label>
- <div class="formHelp">{$locale->tr("trackback_links_help")}</div>
+ <legend>{$locale->tr("send_trackback_pings")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <label for="postLink">{$locale->tr("send_trackbacks")}</label>
+ <div class="formHelp">{$locale->tr("send_trackbacks_help")}</div>
{foreach from=$postlinks item=postlink}
<input class="checkbox" type="checkbox" id="postLink[{counter}]" name="postLink[{counter}]" value="{$postlink}" />
<a href="{$postlink}">{$postlink}</a><br/>
Modified: plog/trunk/trackback.php
===================================================================
--- plog/trunk/trackback.php 2005-02-05 18:39:30 UTC (rev 955)
+++ plog/trunk/trackback.php 2005-02-05 18:58:43 UTC (rev 956)
@@ -13,6 +13,7 @@
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
//
// set this to 'true' if you want this script to log whatever it is
@@ -112,7 +113,7 @@
$result = errorResponse( "Trackback feature has been disabled by the administrator." );
die( $result );
}
-
+
// for security, we will strip _ANY_ html tag from the tags
$tf = new TextFilter();
$blogName = $tf->filterAllHTML( $params->getValue( "blog_name" ));
@@ -134,13 +135,35 @@
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo( $article->getBlog());
+ // a bit of protection...
+ if( !$blogInfo ) {
+ trackbackLog( "ERROR: Article id ".$article->getId()." points to blog ".$article->getBlog()." that doesn't exist!" );
+ $result = errorResponse( "The blog does not exist" );
+ die( $result );
+ }
+
+ // if everything went fine, load the plugins so that we can throw some events...
+ $pm =& PluginManager::getPluginManager();
+ $pm->loadPlugins();
+ // and also configure the BlogInfo and UserInfo objects so that they know
+ // who threw the events...
+ $pm->setBlogInfo( $blogInfo );
+ $userInfo = $blogInfo->getOwnerInfo();
+ $pm->setUserInfo( $userInfo );
+
// receives the request and adds it to the database
$trackbacks = new TrackBacks();
- // and now add it to our database
- $result = $trackbacks->addTrackBack( $articleId, $url, $title, $blogName, $excerpt);
+ // create teh trackback object
+ $now = new Timestamp();
+ $trackback = new Trackback( $url, $title, $articleId, $excerpt, $blogName, $now->getTimestamp());
+ // throw the event in case somebody is listening to it!
+ $pm->notifyEvent( EVENT_PRE_TRACKBACK_ADD, Array( "trackback" => &$trackback ));
+ $result = $trackbacks->addTrackBack( $trackback );
if( !$result ) {
trackbackLog( "There was an error saving the trackback!" );
}
+ // throw the post event too...
+ $pm->notifyEvent( EVENT_POST_TRACKBACK_ADD, Array( "trackback" => &$trackback ));
// result
$result = '<?xml version="1.0" encoding="iso-8859-1"?>';
@@ -150,7 +173,6 @@
// notify the user that a new trackback has been received, if the article was
// configured to receive notifications
- trackbackLog( "Notification sent!" );
$notifier = new ArticleNotifications();
$notifier->notifyUsers( $article->getId(), $blogInfo);
More information about the pLog-svn
mailing list