[pLog-svn] r2922 - plog/trunk/class/action/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Feb 7 10:07:01 GMT 2006
Author: mark
Date: 2006-02-07 10:07:01 +0000 (Tue, 07 Feb 2006)
New Revision: 2922
Modified:
plog/trunk/class/action/admin/admindeletetrackbackaction.class.php
Log:
A lot of fix of this action to make the deleteTrackBack works again.
Modified: plog/trunk/class/action/admin/admindeletetrackbackaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletetrackbackaction.class.php 2006-02-07 10:05:08 UTC (rev 2921)
+++ plog/trunk/class/action/admin/admindeletetrackbackaction.class.php 2006-02-07 10:07:01 UTC (rev 2922)
@@ -1,11 +1,11 @@
<?php
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminarticletrackbackslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminpostslistview.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminarticletrackbackslistview.class.php" );
/**
* \ingroup Action
@@ -18,7 +18,6 @@
var $_articleId;
var $_trackbackIds;
- var $_trackbackId;
var $_mode;
/**
@@ -30,14 +29,13 @@
$this->AdminAction( $actionInfo, $request );
$this->_mode = $actionInfo->getActionParamValue();
-
- // data validation
$this->registerFieldValidator( "articleId", new IntegerValidator());
if( $this->_mode == "deleteTrackback" )
$this->registerFieldValidator( "trackbackId", new IntegerValidator());
else
$this->registerFieldValidator( "trackbackIds", new ArrayValidator());
- $view = new AdminPostsListView( $this->_blogInfo );
+
+ $view = new AdminArticleTrackbacksListView( $this->_blogInfo );
$view->setErrorMessage( $this->_locale->tr("error_deleting_trackbacks"));
$this->setValidationErrorView( $view );
}
@@ -49,9 +47,9 @@
{
$this->_articleId = $this->_request->getValue( "articleId" );
if( $this->_mode == "deleteTrackback" ) {
- $this->_trackbackId = $this->_request->getValue( "trackbackId" );
+ $trackbackId = $this->_request->getValue( "trackbackId" );
$this->_trackbackIds = Array();
- $this->_trackbackIds[] = $this->_trackbackId;
+ $this->_trackbackIds[] = $trackbackId;
}
else
$this->_trackbackIds = $this->_request->getValue( "trackbackIds" );
@@ -59,10 +57,10 @@
$this->_deleteTrackbacks();
return true;
-
}
/**
+ * deletes trackbacks
* @private
*/
function _deleteTrackbacks()
@@ -72,20 +70,27 @@
$successMessage = "";
$totalOk = 0;
- // check if we can really load the article or not...
- $articles = new Articles();
- $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId());
- if( !$article ) {
- $this->_view = new AdminPostsListView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_post"));
- $this->setCommonData();
-
- return false;
+ if( $articleId > 0 ) {
+ // if we can't even load the article, then forget it...
+ $articles = new Articles();
+ $article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId());
+ if( !$article ) {
+ $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_post" ));
+ $this->setCommonData();
+
+ return false;
+ }
}
+ else {
+ // there was no article, so this probably was the view that shows all trackbacks...
+ $article = null;
+ }
+ // loop through the trackbacks and remove them
foreach( $this->_trackbackIds as $trackbackId ) {
// fetch the trackback
- $trackback = $trackbacks->getArticleTrackback( $trackbackId, $this->_articleId );
+ $trackback = $trackbacks->getTrackBack( $trackbackId );
if( !$trackback ) {
$errorMessage .= $this->_locale->pr("error_deleting_trackback2", $trackbackId)."<br/>";
@@ -94,21 +99,35 @@
// fire the pre-event
$this->notifyEvent( EVENT_PRE_TRACKBACK_DELETE, Array( "trackback" => &$trackback ));
- if( !$trackbacks->deletePostTrackback( $trackbackId, $this->_articleId ))
+ // check if the trackback really belongs to this blog...
+ $article = $trackback->getArticle();
+ if( $article->getBlogId() != $this->_blogInfo->getId()) {
+ // if not, then we shouldn't be allowed to remove anything!
$errorMessage .= $this->_locale->pr("error_deleting_trackback", $trackback->getExcerpt())."<br/>";
+ }
else {
- $totalOk++;
- if( $totalOk < 2 )
- $successMessage .= $this->_locale->pr("trackback_deleted_ok", $trackback->getExcerpt());
- else
- $successMessage = $this->_locale->pr("trackbacks_deleted_ok", $totalOk );
- // fire the post-event
- $this->notifyEvent( EVENT_POST_TRACKBACK_DELETE, Array( "trackback" => &$trackback ));
+ if( !$trackbacks->deleteTrackBack( $trackbackId ))
+ $errorMessage .= $this->_locale->pr("error_deleting_trackback", $trackback->getExcerpt())."<br/>";
+ else {
+ $totalOk++;
+ if( $totalOk < 2 )
+ $successMessage .= $this->_locale->pr("trackback_deleted_ok", $trackback->getExcerpt());
+ else
+ $successMessage = $this->_locale->pr("trackbacks_deleted_ok", $totalOk );
+
+ // fire the post-event
+ $this->notifyEvent( EVENT_POST_TRACKBACK_DELETE, Array( "trackback" => &$trackback ));
+ }
}
}
}
- $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo, Array( "article" => $article ));
+ // if everything fine, then display the same view again with the feedback
+ if( $this->_articleId == 0 )
+ $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo, Array( "article" => null ));
+ else
+ $this->_view = new AdminArticleTrackbacksListView( $this->_blogInfo, Array( "article" => $article ));
+
if( $successMessage != "" ) {
$this->_view->setSuccessMessage( $successMessage );
// clear the cache
More information about the pLog-svn
mailing list