[pLog-svn] r5724 - in plog/trunk: class/action/admin js/ui js/ui/pages templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Jul 25 16:44:56 EDT 2007
Author: oscar
Date: 2007-07-25 16:44:56 -0400 (Wed, 25 Jul 2007)
New Revision: 5724
Removed:
plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php
Modified:
plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php
plog/trunk/class/action/admin/adminchangelinkscategoryaction.class.php
plog/trunk/class/action/admin/adminchangepostscategoryaction.class.php
plog/trunk/class/action/admin/adminchangepostsstatusaction.class.php
plog/trunk/class/action/admin/admindeletearticlecategoryaction.class.php
plog/trunk/class/action/admin/admindeletecommentaction.class.php
plog/trunk/class/action/admin/admindeletecustomfieldsaction.class.php
plog/trunk/class/action/admin/admindeletelinkaction.class.php
plog/trunk/class/action/admin/admindeletelinkcategoryaction.class.php
plog/trunk/class/action/admin/admindeletepostaction.class.php
plog/trunk/class/action/admin/adminmarkcommentaction.class.php
plog/trunk/js/ui/forms.js
plog/trunk/js/ui/pages/comments.js
plog/trunk/js/ui/pages/links.js
plog/trunk/js/ui/pages/posts.js
plog/trunk/js/ui/plogui.js
plog/trunk/templates/admin/editcomments_table.template
plog/trunk/templates/admin/editlinks.template
Log:
Implemented background bulk editing for everything in the "content" section, background marking of comments as spam/no spam and adjusted some of the code checked out this afternoon.
Modified: plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/adminchangecommentsstatusaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -31,9 +31,12 @@
$this->registerFieldValidator( "articleId", new IntegerValidator());
$this->registerFieldValidator( "commentIds", new ArrayValidator( new IntegerValidator()));
$this->registerFieldValidator( "commentStatus", new IntegerValidator());
+
$view = new AdminArticleCommentsListView( $this->_blogInfo );
$view->setErrorMessage( $this->_locale->tr("error_updating_comments"));
$this->setValidationErrorView( $view );
+
+ $this->requirePermission( "update_comment" );
}
/**
@@ -41,15 +44,36 @@
*/
function perform()
{
- $this->_articleId = $this->_request->getValue( "articleId" );
- $this->_commentIds = $this->_request->getValue( "commentIds" );
- $this->_commentStatus = $this->_request->getValue( "commentStatus" );
- $this->_changeComments();
+ $results = $this->_changeComments();
+ // if everything fine, then display the same view again with the feedback
+ if( $this->_articleId == 0 )
+ $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => null ));
+ else
+ $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => $article ));
+
+ if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+ if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+
+ $this->setCommonData();
+
return true;
}
+
+ function performAjax()
+ {
+ $results = $this->_changeComments();
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
+ // better to return true if everything fine
+ return true;
+ }
+
/**
* changes comments status
* @private
@@ -61,16 +85,16 @@
$successMessage = "";
$totalOk = 0;
+ $this->_articleId = $this->_request->getValue( "articleId" );
+ $this->_commentIds = $this->_request->getValue( "commentIds" );
+ $this->_commentStatus = $this->_request->getValue( "commentStatus" );
+
if( $this->_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 AdminArticleCommentsListView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_article" ));
- $this->setCommonData();
-
- return false;
+ return( Array( "successMessage" => "", "errorMessage" => $this->_locale->tr("error_fetching_article" )));
}
}
else {
@@ -133,22 +157,11 @@
}
}
- // if everything fine, then display the same view again with the feedback
- if( $this->_articleId == 0 )
- $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => null ));
- else
- $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => $article ));
-
- if( $successMessage != "" ) {
- $this->_view->setSuccessMessage( $successMessage );
- // clear the cache
+ // clear the cache
+ if( $totalOk > 0 )
CacheControl::resetBlogCache( $this->_blogInfo->getId());
- }
- if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
- $this->setCommonData();
- // better to return true if everything fine
- return true;
+ return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
}
function _markCommentAsSpam( $comment )
Modified: plog/trunk/class/action/admin/adminchangelinkscategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangelinkscategoryaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/adminchangelinkscategoryaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -31,22 +31,45 @@
$view = new AdminLinksListView( $this->_blogInfo );
$view->setErrorMessage( $this->_locale->tr("error_no_links_selected"));
$this->setValidationErrorView( $view );
+
+ // permission checks
+ $this->requirePermission( "update_link" );
}
function perform()
{
- $this->_linkIds = $this->_request->getValue( "linkIds" );
- $this->_linkCategoryId = $this->_request->getValue( "linkCategoryId" );
-
- $this->_changeLinks();
+ $results = $this->_changeLinks();
+
+ $this->_view = new AdminLinksListView( $this->_blogInfo );
+ if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+ if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+ $this->setCommonData();
+
+ return( true );
}
+
+ function performAjax()
+ {
+ $results = $this->_changeLinks();
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
+ // better to return true if everything fine
+ return true;
+ }
+
/**
* Carries out the specified action
* @private
*/
function _changeLinks()
{
+ $this->_linkIds = $this->_request->getValue( "linkIds" );
+ $this->_linkCategoryId = $this->_request->getValue( "linkCategoryId" );
+
$errorMessage = "";
$successMessage = "";
$numOk = 0;
@@ -81,16 +104,11 @@
}
}
- $this->_view = new AdminLinksListView( $this->_blogInfo );
- if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
- if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
- $this->setCommonData();
-
// clear the cache
- CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+ if( $numOk > 0 )
+ CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
- // better to return true if everything fine
- return true;
+ return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
}
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminchangepostscategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangepostscategoryaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/adminchangepostscategoryaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -108,7 +108,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
Modified: plog/trunk/class/action/admin/adminchangepostsstatusaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangepostsstatusaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/adminchangepostsstatusaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -108,7 +108,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
Deleted: plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/adminchangetrackbacksstatusaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -1,214 +0,0 @@
-<?php
-
- lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
- lt_include( PLOG_CLASS_PATH."class/view/admin/adminarticletrackbackslistview.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
-
- /**
- * \ingroup Action
- * @private
- *
- * Allows to remove trackbacks from a certain article
- */
- class AdminChangeTrackbacksStatusAction extends AdminAction
- {
-
- var $_articleId;
- var $_trackbackIds;
- var $_trackbackStatus;
-
- /**
- * Constructor. If nothing else, it also has to call the constructor of the parent
- * class, BlogAction with the same parameters
- */
- function AdminChangeTrackbacksStatusAction( $actionInfo, $request )
- {
- $this->AdminAction( $actionInfo, $request );
- $this->registerFieldValidator( "articleId", new IntegerValidator());
- $this->registerFieldValidator( "trackbackIds", new ArrayValidator( new IntegerValidator()));
- $this->registerFieldValidator( "trackbackStatus", new IntegerValidator());
- $view = new AdminArticleTrackbacksListView( $this->_blogInfo );
- $view->setErrorMessage( $this->_locale->tr("error_updating_trackbacks"));
- $this->setValidationErrorView( $view );
- }
-
- /**
- * Carries out the specified action
- */
- function perform()
- {
- $this->_articleId = $this->_request->getValue( "articleId" );
- $this->_trackbackIds = $this->_request->getValue( "trackbackIds" );
- $this->_trackbackStatus = $this->_request->getValue( "trackbackStatus" );
-
- $this->_changeTrackbacks();
-
- return true;
- }
-
- /**
- * change trackbacks status
- * @private
- */
- function _changeTrackbacks()
- {
- $trackbacks = new Trackbacks();
- $errorMessage = "";
- $successMessage = "";
- $totalOk = 0;
-
- if( $this->_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_article" ));
- $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->getTrackBack( $trackbackId );
-
- if( !$trackback ) {
- $errorMessage .= $this->_locale->pr("error_updating_trackback2", $trackbackId)."<br/>";
- }
- else {
- // fire the pre-event
- $this->notifyEvent( EVENT_PRE_TRACKBACK_UPDATE, Array( "trackback" => &$trackback ));
-
- // 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_updating_trackback", $trackback->getExcerpt())."<br/>";
- }
- else
- {
- $preTrackbackStatus = $trackback->getStatus();
-
- if ( $preTrackbackStatus == $this->_trackbackStatus )
- {
- $errorMessage .= $this->_locale->pr("error_updating_trackback", $trackback->getExcerpt())."<br/>";
- continue;
-
- }
-
- $trackback->setStatus( $this->_trackbackStatus );
- if( !$trackbacks->updateComment( $trackback ))
- $errorMessage .= $this->_locale->pr("error_updating_trackback", $trackback->getExcerpt())."<br/>";
- else {
- if( $this->_trackbackStatus == COMMENT_STATUS_SPAM )
- {
- $this->_markTrackbackAsSpam($trackback);
- }
- elseif( $this->_trackbackStatus == COMMENT_STATUS_NONSPAM )
- {
- $this->_markTrackbackAsNonSpam($trackback);
- }
-
- $totalOk++;
- if( $totalOk < 2 )
- $successMessage .= $this->_locale->pr("trackback_updated_ok", $trackback->getExcerpt());
- else
- $successMessage = $this->_locale->pr("trackbacks_updated_ok", $totalOk );
-
- // fire the post-event
- $this->notifyEvent( EVENT_POST_TRACKBACK_UPDATE, Array( "trackback" => &$trackback ));
- }
- }
- }
- }
-
- // 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
- CacheControl::resetBlogCache( $this->_blogInfo->getId());
- }
- if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
- $this->setCommonData();
-
- // better to return true if everything fine
- return true;
- }
-
- function _markTrackbackAsSpam( $trackback )
- {
- // throw the pre-event
- $this->notifyEvent( EVENT_PRE_MARK_SPAM_TRACKBACK, Array( "trackbackId" => $trackback->getId() ));
-
- // We should get the trackback and train the filter to recognize this as spam...
- lt_include( PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );
- $bayesian = new BayesianFilterCore();
-
- $bayesian->untrain( $this->_blogInfo->getId(),
- $trackback->getTopic(),
- $trackback->getText(),
- $trackback->getUserName(),
- $trackback->getUserEmail(),
- $trackback->getUserUrl(),
- false );
-
- $bayesian->train( $this->_blogInfo->getId(),
- $trackback->getTopic(),
- $trackback->getText(),
- $trackback->getUserName(),
- $trackback->getUserEmail(),
- $trackback->getUserUrl(),
- true );
-
- // throw the post-event if everythign went fine
- $this->notifyEvent( EVENT_POST_MARK_SPAM_TRACKBACK, Array( "trackbackId" => $trackback->getId() ));
- }
-
- /**
- * @private
- */
- function _markTrackbackAsNonSpam( $trackback )
- {
- // throw the pre-event
- $this->notifyEvent( EVENT_PRE_MARK_NO_SPAM_TRACKBACK, Array( "trackbackId" => $trackback->getId() ));
-
- // we should get the trackback and train the filter
- lt_include( PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );
- $bayesian = new BayesianFilterCore();
-
- $bayesian->untrain( $this->_blogInfo->getId(),
- $trackback->getTopic(),
- $trackback->getText(),
- $trackback->getUserName(),
- $trackback->getUserEmail(),
- $trackback->getUserUrl(),
- true );
-
- $bayesian->train( $this->_blogInfo->getId(),
- $trackback->getTopic(),
- $trackback->getText(),
- $trackback->getUserName(),
- $trackback->getUserEmail(),
- $trackback->getUserUrl(),
- false );
-
- // throw the post-event if everythign went fine
- $this->notifyEvent( EVENT_POST_MARK_NO_SPAM_TRACKBACK, Array( "trackbackId" => $trackback->getId() ));
- }
- }
-?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/admindeletearticlecategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletearticlecategoryaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/admindeletearticlecategoryaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -129,7 +129,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
Modified: plog/trunk/class/action/admin/admindeletecommentaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletecommentaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/admindeletecommentaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -40,7 +40,7 @@
$view->setErrorMessage( $this->_locale->tr("error_deleting_comments"));
$this->setValidationErrorView( $view );
- $this->requirePermission( "update_comment" );
+ $this->requirePermission( "update_comment" );
}
/**
@@ -72,7 +72,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setResult( true );
// better to return true if everything fine
return true;
@@ -151,7 +152,6 @@
if( $totalOk > 0 )
CacheControl::resetBlogCache( $this->_blogInfo->getId());
-
// better to return true if everything fine
return( Array( "successMessage" => $successMessage, "errorMessage" => $errorMessage ));
Modified: plog/trunk/class/action/admin/admindeletecustomfieldsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletecustomfieldsaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/admindeletecustomfieldsaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -60,7 +60,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
Modified: plog/trunk/class/action/admin/admindeletelinkaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletelinkaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/admindeletelinkaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -40,9 +40,7 @@
$this->setValidationErrorView( $view );
// permission checks
- $this->requirePermission( "update_link" );
-
-
+ $this->requirePermission( "update_link" );
}
/**
@@ -54,7 +52,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
@@ -112,7 +111,7 @@
}
// clear the cache
- if( $totalOk > 0 )
+ if( $numOk > 0 )
CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
// return some feedback
Modified: plog/trunk/class/action/admin/admindeletelinkcategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletelinkcategoryaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/admindeletelinkcategoryaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -115,7 +115,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
Modified: plog/trunk/class/action/admin/admindeletepostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletepostaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/admindeletepostaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -137,7 +137,8 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
$this->_view = new AdminAjaxView( $this->_blogInfo );
- $this->_view->setResult( $results );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
// better to return true if everything fine
return true;
Modified: plog/trunk/class/action/admin/adminmarkcommentaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminmarkcommentaction.class.php 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/class/action/admin/adminmarkcommentaction.class.php 2007-07-25 20:44:56 UTC (rev 5724)
@@ -20,6 +20,8 @@
var $_mode;
var $_article;
var $_comment;
+ var $_errorMessage;
+ var $_message;
/**
* Constructor. If nothing else, it also has to call the constructor of the parent
@@ -73,28 +75,15 @@
// throw the pre-event
$this->notifyEvent( EVENT_PRE_MARK_SPAM_COMMENT, Array( "commentId" => $this->_commentId ));
- if( $this->_articleId == 0 )
- $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => null ));
- else
- $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => $this->_article ));
-
$comments = new CommentsCommon();
$comment = $comments->getComment( $this->_commentId );
if( $comment ) {
$comment->setStatus( COMMENT_STATUS_SPAM );
if(($comment->getBlogId() != $this->_blogInfo->getId()) ||
(!$comments->updateComment( $comment ))) {
- $this->_view->setErrorMessage( $this->_locale->tr("error_marking_comment_as_spam" ));
- $this->setCommonData();
-
$res = false;
}
- else {
- $this->_view->setSuccessMessage( $this->_locale->tr("comment_marked_as_spam_ok" ));
- $this->setCommonData();
-
- $res = true;
-
+ else {
// before exiting, we should get the comment and train the filter
// to recognize this as spam...
$comment = $comments->getComment( $this->_commentId );
@@ -117,7 +106,9 @@
true );
// throw the post-event if everythign went fine
- $this->notifyEvent( EVENT_POST_MARK_SPAM_COMMENT, Array( "commentId" => $this->_commentId ));
+ $this->notifyEvent( EVENT_POST_MARK_SPAM_COMMENT, Array( "commentId" => $this->_commentId ));
+
+ $res = $comment;
}
}
@@ -132,29 +123,15 @@
// throw the pre-event
$this->notifyEvent( EVENT_PRE_MARK_NO_SPAM_COMMENT, Array( "commentId" => $this->_commentId ));
- if( $this->_articleId == 0 )
- $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => null ));
- else
- $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => $this->_article ));
-
$comments = new CommentsCommon();
$comment = $comments->getComment( $this->_commentId );
if( $comment ) {
$comment->setStatus( COMMENT_STATUS_NONSPAM );
if(( $comment->getBlogId() != $this->_blogInfo->getId()) ||
(!$comments->updateComment( $comment ))) {
-
- $this->_view->setErrorMessage( $this->_locale->tr("error_marking_comment_as_nonspam" ));
- $this->setCommonData();
-
- $res = false;
+ $res = false;
}
else {
- $this->_view->setSuccessMessage( $this->_locale->tr("comment_marked_as_nonspam_ok" ));
- $this->setCommonData();
-
- $res = true;
-
// before exiting, we should get the comment and train the filter
// to recognize this as spam...
$comment = $comments->getComment( $this->_commentId );
@@ -178,44 +155,88 @@
// throw the post-event if everythign went fine
$this->notifyEvent( EVENT_POST_MARK_NO_SPAM_COMMENT, Array( "commentId" => $this->_commentId ));
+
+ $res = $comment;
}
}
return $res;
}
- /**
- * Carries out the specified action
- */
- function perform()
- {
+ private function _markComment()
+ {
// fetch the data
$this->_commentId = $this->_request->getValue( "commentId" );
$this->_articleId = $this->_request->getValue( "articleId" );
$this->_mode = $this->_request->getValue( "mode" );
-
- // first, let's make sure that the user is trying to edit the right
- // comment...
+
if( !$this->_checkComment( $this->_commentId, $this->_articleId, $this->_blogInfo->getId())) {
// if things don't match... (like trying to set the status of an article
// from another blog, then quit...)
- $this->_view = new AdminPostsListView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->tr("error_incorrect_comment_id"));
- $this->setCommonData();
return false;
}
+
// depending on the mode, we have to do one thing or another
- if( $this->_mode == 0 )
+ if( $this->_mode == 0 ) {
$result = $this->_markCommentAsNonSpam();
- else
+ if( $result )
+ $this->_message = $this->_locale->tr("comment_marked_as_nonspam_ok" );
+ else
+ $this->_message = $this->_locale->tr("error_marking_comment_as_nonspam" );
+ }
+ else {
$result = $this->_markCommentAsSpam();
+ if( $result )
+ $this->_message = $this->_locale->tr("comment_marked_as_spam_ok" );
+ else
+ $this->_message = $this->_locale->tr("error_marking_comment_as_spam" );
+ }
+
+ // clear the cache
+ if( $result )
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
- // clear the cache
- CacheControl::resetBlogCache( $this->_blogInfo->getId());
+ return( $result );
+ }
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $result = $this->_markComment();
+
+ if( $this->_articleId == 0 )
+ $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => null ));
+ else
+ $this->_view = new AdminArticleCommentsListView( $this->_blogInfo, Array( "article" => $this->_article ));
+
+ if( $result )
+ $this->_view->setSuccessMessage( $this->_message );
+ else
+ $this->_view->setErrorMessage( $this->_message );
+
+ $this->setCommonData();
+
// better to return true if everything fine
- return $result;
+ return( true );
}
+
+ function performAjax()
+ {
+ $result = $this->_markComment();
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ if( $result ) {
+ $this->_view->setSuccessMessage( $this->_message );
+ $this->_view->setResult( $result );
+ }
+ else
+ $this->_view->setErrorMessage( $this->_message );
+
+ return( true );
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/js/ui/forms.js
===================================================================
--- plog/trunk/js/ui/forms.js 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/js/ui/forms.js 2007-07-25 20:44:56 UTC (rev 5724)
@@ -331,25 +331,62 @@
YAHOO.util.Connect.asyncRequest('GET', url,
callback = {
success: function( o ) {
-
+
Lifetype.Dom.$( 'ViewError' ).style.display = 'none';
Lifetype.Dom.$( 'ViewInfo' ).style.display = 'none';
- var result = Lifetype.JSon.decode( o.responseText ).result;
- if( result.successMessage ) {
- Lifetype.Dom.$( 'ViewInfoMessage' ).innerHTML = result.successMessage;
- Lifetype.Dom.$( 'ViewInfo' ).style.display = 'block';
-
- // fire the success event
- Lifetype.Forms.Events.performRequestSuccessEvent.fire( o );
- }
- if( result.errorMessage ) {
- Lifetype.Dom.$( 'ViewErrorMessage' ).innerHTML = result.errorMessage;
+ var response = Lifetype.JSon.decode( o.responseText );
+
+ /**
+ * Here is when easy things get annoyingly awkward...
+ * Some ajax views return their succes status in the 'success'
+ * field and the error message in the 'message' field of the json
+ * response. So far, so good.
+ *
+ * But there are other views that need to return both a success
+ * and an error message: think of an operation to delete more than
+ * one item at the same time, where some of the items may be successfully
+ * deleted but other may not be. In those cases, 'result' is always
+ * set to 'true' and the error message and the success message are
+ * packed into the 'message' variable as 'message.successMessage' and
+ * 'message.errorMessage' so we have to take these combinations into
+ * account.
+ */
+ if( response.success == false ) {
+ // this is used for validation errors, where we have a form object
+ // containin the incorrect fields and a 'message' field containing
+ // the validation error string
+ Lifetype.Dom.$( 'ViewErrorMessage' ).innerHTML = response.message;
Lifetype.Dom.$( 'ViewError' ).style.display = 'block';
-
+
// fire the error event
- Lifetype.Forms.Events.performRequestFailureEvent.fire( o );
+ Lifetype.Forms.Events.performRequestFailureEvent.fire( o );
}
+ else {
+ if( response.message["successMessage"] || response.message["errorMessage"] ) {
+ if( response.message.successMessage ) {
+ Lifetype.Dom.$( 'ViewInfoMessage' ).innerHTML = response.message.successMessage;
+ Lifetype.Dom.$( 'ViewInfo' ).style.display = 'block';
+
+ // fire the success event
+ Lifetype.Forms.Events.performRequestSuccessEvent.fire( o );
+ }
+ if( response.message.errorMessage ) {
+ Lifetype.Dom.$( 'ViewErrorMessage' ).innerHTML = response.message.errorMessage;
+ Lifetype.Dom.$( 'ViewError' ).style.display = 'block';
+
+ // fire the error event
+ Lifetype.Forms.Events.performRequestFailureEvent.fire( o );
+ }
+ }
+ else {
+ Lifetype.Dom.$( 'ViewInfoMessage' ).innerHTML = response.message;
+ Lifetype.Dom.$( 'ViewInfo' ).style.display = 'block';
+
+ // fire the success event
+ Lifetype.Forms.Events.performRequestSuccessEvent.fire( o );
+ }
+ }
},
failure: function( o ) {
Lifetype.Dom.$( 'ViewErrorMessage' ).innerHTML = 'Error performing request';
@@ -362,7 +399,6 @@
);
}
-
//
// :TODO:
// Move the functions above to the Lifetype.Forms.List namespace
Modified: plog/trunk/js/ui/pages/comments.js
===================================================================
--- plog/trunk/js/ui/pages/comments.js 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/js/ui/pages/comments.js 2007-07-25 20:44:56 UTC (rev 5724)
@@ -2,26 +2,25 @@
Lifetype.UI.Pages.Comments.submitCommentsList = function(op)
{
- if ( op == 'changeCommentsStatus' )
- {
- if ( document.getElementById("postCommentsList").commentStatus.value == -1 )
- window.alert(errorCommentStatusMsg);
- else
- {
- document.getElementById("postCommentsList").op.value = op;
- document.getElementById("postCommentsList").submit();
- }
- }
- else
- {
+ if ( document.getElementById("postCommentsList").commentStatus.value == -1 )
+ window.alert(errorCommentStatusMsg);
+ else {
+ // save the old value of the "op" parameter
+ var oldOp = document.getElementById("postCommentsList").op.value;
document.getElementById("postCommentsList").op.value = op;
- document.getElementById("postCommentsList").submit();
+
+ Lifetype.Forms.performRequest(Lifetype.Dom.$( 'postCommentsList' ));
+
+ // restore the old value of the op parameter
+ document.getElementById("postCommentsList").op.value = oldOp;
+
+ return( false );
}
}
Lifetype.UI.Pages.Comments.submitHook = function( form )
{
- Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {formSuccessCallback:Lifetype.UI.AjaxPager.reload} );
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json' );
}
YAHOO.util.Event.addListener( window, "load", function() {
Modified: plog/trunk/js/ui/pages/links.js
===================================================================
--- plog/trunk/js/ui/pages/links.js 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/js/ui/pages/links.js 2007-07-25 20:44:56 UTC (rev 5724)
@@ -2,14 +2,25 @@
Lifetype.UI.Pages.Links.addSubmitHook = function( form )
{
- Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {resetAfterSuccess:true, formSuccessCallback:Lifetype.UI.AjaxPager.reload} );
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {resetAfterSuccess:true} );
}
Lifetype.UI.Pages.Links.updateSubmitHook = function( form )
{
- Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {formSuccessCallback:Lifetype.UI.AjaxPager.reload} );
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json' );
}
+Lifetype.UI.Pages.Links.submitLinksList = function( op )
+{
+ var oldOp = Lifetype.Dom.$( "editLinks" ).op.value;
+ Lifetype.Dom.$( "editLinks" ).op.value = op;
+ Lifetype.Forms.performRequest( Lifetype.Dom.$( 'editLinks' ));
+
+ Lifetype.Dom.$( "editLinks" ).op.value = oldOp;
+
+ return( false );
+}
+
YAHOO.util.Event.addListener( window, "load", function() {
var t = new Lifetype.UI.TableEffects( "links" );
t.stripe();
Modified: plog/trunk/js/ui/pages/posts.js
===================================================================
--- plog/trunk/js/ui/pages/posts.js 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/js/ui/pages/posts.js 2007-07-25 20:44:56 UTC (rev 5724)
@@ -8,6 +8,8 @@
*/
Lifetype.UI.Pages.Posts.submitPostsList = function(op)
{
+ var oldOp = document.getElementById("postsList").op.value;
+
if ( op == 'changePostsStatus' ) {
if ( document.getElementById("postsList").postStatus.value == -1 )
window.alert(errorPostStatusMsg);
@@ -19,7 +21,6 @@
// form's onSubmit event, so we'll have to do it
// manually
Lifetype.Forms.performRequest(Lifetype.Dom.$( 'postsList' ));
- return( false );
}
}
else if( op == 'changePostsLocation' ) {
@@ -31,7 +32,6 @@
// same thing here with the form submit
Lifetype.Forms.performRequest(Lifetype.Dom.$( 'postsList' ));
- return( false );
}
}
else if( op == 'changePostsCategory' ) {
@@ -44,9 +44,12 @@
// same thing here with the form submit
Lifetype.Forms.performRequest(Lifetype.Dom.$( 'postsList' ));
- return( false );
}
}
+
+ document.getElementById("postsList").op.value = oldOp;
+
+ return( false );
}
YAHOO.util.Event.addListener( window, "load", function() {
Modified: plog/trunk/js/ui/plogui.js
===================================================================
--- plog/trunk/js/ui/plogui.js 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/js/ui/plogui.js 2007-07-25 20:44:56 UTC (rev 5724)
@@ -1,9 +1,3 @@
-function submitLinksList(op)
-{
- document.getElementById("links").op.value = op;
- document.getElementById("links").submit();
-}
-
function submitBlogsList(op)
{
if ( document.getElementById("blogStatus").value == -1 )
Modified: plog/trunk/templates/admin/editcomments_table.template
===================================================================
--- plog/trunk/templates/admin/editcomments_table.template 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/templates/admin/editcomments_table.template 2007-07-25 20:44:56 UTC (rev 5724)
@@ -65,11 +65,11 @@
</a>
{if $bayesian_filter_enabled}
{if $comment->getStatus() == 0}
- <a href="?op=markComment&mode=1&articleId={if $post}{$comment->getArticleId()}{else}0{/if}&commentId={$comment->getId()}" title="{$locale->tr("mark_as_spam")}">
+ <a onClick="Lifetype.Forms.performRequest(this);return(false);" href="?op=markComment&mode=1&articleId={if $post}{$comment->getArticleId()}{else}0{/if}&commentId={$comment->getId()}" title="{$locale->tr("mark_as_spam")}">
<img src="imgs/admin/icon_spam-16.png" alt="{$locale->tr("mark_as_spam")}" />
</a>
{elseif $comment->getStatus() == 1}
- <a href="?op=markComment&mode=0&articleId={if $post}{$comment->getArticleId()}{else}0{/if}&commentId={$comment->getId()}" title="{$locale->tr("mark_as_no_spam")}">
+ <a onClick="Lifetype.Forms.performRequest(this);return(false);" href="?op=markComment&mode=0&articleId={if $post}{$comment->getArticleId()}{else}0{/if}&commentId={$comment->getId()}" title="{$locale->tr("mark_as_no_spam")}">
<img src="imgs/admin/icon_nospam-16.png" alt="{$locale->tr("mark_as_no_spam")}" />
</a>
{/if}
Modified: plog/trunk/templates/admin/editlinks.template
===================================================================
--- plog/trunk/templates/admin/editlinks.template 2007-07-25 14:25:18 UTC (rev 5723)
+++ plog/trunk/templates/admin/editlinks.template 2007-07-25 20:44:56 UTC (rev 5724)
@@ -59,7 +59,7 @@
<br style="clear:both" />
</div>
-<form id="links" action="admin.php" method="post" onSubmit="Lifetype.Forms.performRequest(this);return(false);">
+<form id="editLinks" action="admin.php" method="post" onSubmit="Lifetype.Forms.performRequest(this);return(false);">
{include file="$admintemplatepath/viewvalidateajax.template"}
<div id="list">
{include file="$admintemplatepath/editlinks_table.template"}
@@ -79,7 +79,7 @@
<option value="{$category->getId()}">{$category->getName()}</option>
{/foreach}
</select>
- <input type="button" name="changeLinksCategory" value="{$locale->tr("change_category")}" class="submit" onClick="javascript:submitLinksList('changeLinksCategory');" />
+ <input type="button" name="changeLinksCategory" value="{$locale->tr("change_category")}" class="submit" onClick="Lifetype.UI.Pages.Links.submitLinksList('changeLinksCategory');" />
</fieldset>
</div>
</div>
More information about the pLog-svn
mailing list