Plog 1.0.1 > Class / Action / Admin / Adminmarkcommentaction.class.php

Questions? Need Help? Want to share? » PHP Forum
Script Name:
Plog 1.0.1

Download:
plog-1.0.1.zip

Category:
Blog

Archive Content:

Plog 1.0.1

Plog 1.0.1 > Class

Plog 1.0.1 > Class > Action

Plog 1.0.1 > Class > Action > Admin

Plog 1.0.1 > Class > Action

Plog 1.0.1 > Class > Bayesian

Plog 1.0.1 > Class > Config

Plog 1.0.1 > Class > Controller

Plog 1.0.1 > Class > Dao

Plog 1.0.1 > Class > Dao > Customfields

Plog 1.0.1 > Class > Dao

Plog 1.0.1 > Class > Dao > Status

Plog 1.0.1 > Class > Dao

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Date

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Forms

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Pager

Plog 1.0.1 > Class > Data

Plog 1.0.1 > Class > Data > Validator

Plog 1.0.1 > Class > Data > Validator > Rules

Plog 1.0.1 > Class > Data > Validator

Plog 1.0.1 > Class > Database

Plog 1.0.1 > Class > Database > Adodb

Plog 1.0.1 > Class > Database > Adodb > Datadict

Plog 1.0.1 > Class > Database > Adodb > Docs

Plog 1.0.1 > Class > Database > Adodb > Drivers

Plog 1.0.1 > Class > Database > Adodb > Lang

Plog 1.0.1 > Class > Database > Adodb

Plog 1.0.1 > Class > Database > Adodb > Perf

Plog 1.0.1 > Class > Database > Adodb

Plog 1.0.1 > Class > Database

Plog 1.0.1 > Class

Plog 1.0.1 > Class > File

Plog 1.0.1 > Class > File > Finder

Plog 1.0.1 > Class > File > Unpacker

Plog 1.0.1 > Class > Gallery

Plog 1.0.1 > Class > Gallery > Dao

Plog 1.0.1 > Class > Gallery > Data

Plog 1.0.1 > Class > Gallery

Plog 1.0.1 > Class > Gallery > Getid3

Plog 1.0.1 > Class > Gallery > Helperapps

Plog 1.0.1 > Class > Gallery > Resizers

Plog 1.0.1 > Class > Gallery > Template

Plog 1.0.1 > Class > Locale

Plog 1.0.1 > Class > Logger

Plog 1.0.1 > Class > Logger > Appender

Plog 1.0.1 > Class > Logger > Config

Plog 1.0.1 > Class > Logger > Layout

Plog 1.0.1 > Class > Logger > Logger

Plog 1.0.1 > Class > Logger

Plog 1.0.1 > Class > Mail

Plog 1.0.1 > Class > Mail > Phpmailer

Plog 1.0.1 > Class > Mail > Phpmailer > Language

Plog 1.0.1 > Class > Mail > Phpmailer

Plog 1.0.1 > Class > Misc

Plog 1.0.1 > Class > Net

Plog 1.0.1 > Class > Net > Http

Plog 1.0.1 > Class > Net > Http > Phpsniff

Plog 1.0.1 > Class > Net > Http > Session

Plog 1.0.1 > Class > Net > Http

Plog 1.0.1 > Class > Net

Plog 1.0.1 > Class > Net > Xmlrpc

Plog 1.0.1 > Class > Net

Plog 1.0.1 > Class > Object

Plog 1.0.1 > Class > Plugin

Plog 1.0.1 > Class > Security

Plog 1.0.1 > Class > Summary

Plog 1.0.1 > Class > Summary > Action

Plog 1.0.1 > Class > Summary > Dao

Plog 1.0.1 > Class > Summary > Data

Plog 1.0.1 > Class > Summary > Data > Validator

Plog 1.0.1 > Class > Summary > Mail

Plog 1.0.1 > Class > Summary > View

Plog 1.0.1 > Class > Template

Plog 1.0.1 > Class > Template > Menu

Plog 1.0.1 > Class > Template > Smarty

Plog 1.0.1 > Class > Template > Smarty > Core

Plog 1.0.1 > Class > Template > Smarty

Plog 1.0.1 > Class > Template > Smarty > Plugins

Plog 1.0.1 > Class > Template > Smarty

Plog 1.0.1 > Class > Template

Plog 1.0.1 > Class > Template > Templatesets

Plog 1.0.1 > Class > Template

Plog 1.0.1 > Class > View

Plog 1.0.1 > Class > View > Admin

Plog 1.0.1 > Class > View

Plog 1.0.1 > Class > Xml

Plog 1.0.1 > Class > Xml > Parser

Plog 1.0.1 > Class > Xml

Plog 1.0.1 > Class > Xml > Rssparser

Plog 1.0.1 > Class > Xml > Rssparser > Magpierss

Plog 1.0.1 > Class > Xml > Rssparser > Magpierss > Extlib

Plog 1.0.1 > Class > Xml > Rssparser > Magpierss

Plog 1.0.1 > Class > Xml > Rssparser

Plog 1.0.1 > Class > Xml > Tree

Plog 1.0.1 > Class > Xml

Plog 1.0.1

Plog 1.0.1 > Config

Plog 1.0.1

Plog 1.0.1 > Gallery

Plog 1.0.1

Plog 1.0.1 > Imgs

Plog 1.0.1 > Imgs > .xvpics

Plog 1.0.1 > Imgs > Admin

Plog 1.0.1 > Imgs

Plog 1.0.1

Plog 1.0.1 > Install

Plog 1.0.1 > Js

Plog 1.0.1 > Js > Calendar

Plog 1.0.1 > Js > Editor

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Htmlarea > Docs

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Htmlarea > Images

Plog 1.0.1 > Js > Htmlarea > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > CharacterMap > Popups

Plog 1.0.1 > Js > Htmlarea > Plugins > ContextMenu

Plog 1.0.1 > Js > Htmlarea > Plugins > ContextMenu > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > ContextMenu

Plog 1.0.1 > Js > Htmlarea > Plugins > CSS

Plog 1.0.1 > Js > Htmlarea > Plugins > CSS > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > DynamicCSS

Plog 1.0.1 > Js > Htmlarea > Plugins > DynamicCSS > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > EnterParagraphs

Plog 1.0.1 > Js > Htmlarea > Plugins > EnterParagraphs > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage > Popups

Plog 1.0.1 > Js > Htmlarea > Plugins > FullPage

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Emoticons

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > InsertSmiley > Popups

Plog 1.0.1 > Js > Htmlarea > Plugins > ListType

Plog 1.0.1 > Js > Htmlarea > Plugins > ListType > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > ListType

Plog 1.0.1 > Js > Htmlarea > Plugins

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations > Img

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations > Lang

Plog 1.0.1 > Js > Htmlarea > Plugins > TableOperations

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Htmlarea > Popups

Plog 1.0.1 > Js > Htmlarea

Plog 1.0.1 > Js > Ie7

Plog 1.0.1 > Js > Ie7 > Src

Plog 1.0.1 > Js

Plog 1.0.1 > Js > Ui

Plog 1.0.1

Plog 1.0.1 > Locale

Plog 1.0.1 > Locale > Unsupport

Plog 1.0.1 > Plugins

Plog 1.0.1

Plog 1.0.1 > Styles

Plog 1.0.1

Plog 1.0.1 > Templates

Plog 1.0.1 > Templates > Admin

Plog 1.0.1 > Templates > Admin > Xml

Plog 1.0.1 > Templates > Blueish

Plog 1.0.1 > Templates > Grey

Plog 1.0.1 > Templates > Misc

Plog 1.0.1 > Templates > Rss

Plog 1.0.1 > Templates > Standard

Plog 1.0.1 > Templates > Standard > Imgs

Plog 1.0.1 > Templates > Standard

Plog 1.0.1 > Templates > Summary

Plog 1.0.1 > Templates > Summary > Rss

Plog 1.0.1 > Templates > Summary

Plog 1.0.1 > Templates > Wizard

Plog 1.0.1 > Tmp

Plog 1.0.1

Adminmarkcommentaction.class.php:


<?php

    
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/dao/articles.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/view/admin/adminpostslistview.class.php" );
    include_once( 
PLOG_CLASS_PATH."class/view/admin/adminarticlecommentslistview.class.php" );
    
    
/**
     * \ingroup Action
     * @private
     *     * sets the spam status for a post
     */
    
class AdminMarkCommentAction extends AdminAction
    
{

        var 
$_commentId;
        var 
$_articleId;
        var 
$_mode;
        var 
$_article;
        var 
$_comment;

        
/**
         * Constructor. If nothing else,  it also has to call the constructor of the parent
         * class,  BlogAction with the same parameters
         */
        
function AdminMarkCommentAction$actionInfo,  $request )
        {
            
$this->AdminAction$actionInfo,  $request );
            
            
// data validation
            
$this->registerFieldValidator"commentId",  new IntegerValidator());
            
$this->registerFieldValidator"articleId",  new IntegerValidator());
            
$this->registerFieldValidator"mode",  new IntegerValidator());
            
$view = new AdminPostsListView$this->_blogInfo );
            
$view->setErrorMessage$this->_locale->tr("error_incorrect_comment_id"));
            
$this->setValidationErrorView$view );
        }

        
/**
         * @private
         * Returns true wether the comment whose status we're trying to change
         * really belongs to this blog,  just in case somebody's trying to mess
         * around with that...
         */
        
function _checkComment$commentId,  $articleId,  $blogId )
        {
            
$articleComments = new ArticleComments();
            
$articles = new Articles();

            
// fetch the comment
            
$this->_comment $articleComments->getPostComment$articleId,  $commentId );
            if( !
$this->_comment )
                return 
false;

            
// fetch the article
            
$this->_article $articles->getBlogArticle$this->_comment->getArticleId(),  $blogId );
            if( !
$this->_article )
                return 
false;

            return 
true;
        }

        
/**
         * @private
         */
        
function _markCommentAsSpam()
        {
            
// throw the pre-event
            
$this->notifyEventEVENT_PRE_MARK_SPAM_COMMENT,  Array( "commentId" => $this->_commentId ));
            
               
$this->_view = new AdminArticleCommentsListView$this->_blogInfo,  Array( "article" => $this->_article ));
            
            
$comments = new ArticleComments();
            if( !
$comments->updateCommentStatus$this->_commentId,  COMMENT_STATUS_SPAM )) {
                
$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;

                
// before exiting,  we should get the comment and train the filter
                // to recognize this as spam...
                
$comment $comments->getPostComment$this->_articleId,  $this->_commentId );
                
$bayesian = new BayesianFilterCore();

                
$bayesian->untrain$this->_blogInfo->getId(),
                                    
$comment->getTopic(),
                                    
$comment->getText(),
                                    
$comment->getUserName(),
                                    
$comment->getUserEmail(),
                                    
$comment->getUserUrl(),
                                    
false );
                                  
                
$bayesian->train$this->_blogInfo->getId(),
                                  
$comment->getTopic(),
                                  
$comment->getText(),
                                  
$comment->getUserName(),
                                  
$comment->getUserEmail(),
                                  
$comment->getUserUrl(),
                                  
true );
                                  
                
// throw the post-event if everythign went fine
                
$this->notifyEventEVENT_POST_MARK_SPAM_COMMENT,  Array( "commentId" => $this->_commentId ));                                  
            }

            return 
$res;
        }

        
/**
         * @private
         */
        
function _markCommentAsNonSpam()
        {
            
// throw the pre-event
            
$this->notifyEventEVENT_PRE_MARK_NO_SPAM_COMMENT,  Array( "commentId" => $this->_commentId ));
        
               
$this->_view = new AdminArticleCommentsListView$this->_blogInfo,  Array( "article" => $this->_article ));
        
            
$comments = new ArticleComments();
            if( !
$comments->updateCommentStatus$this->_commentId,  COMMENT_STATUS_NONSPAM )) {
                
$this->_view->setErrorMessage$this->_locale->tr("error_marking_comment_as_nonspam" ));
                
$this->setCommonData();
                
                
$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->getPostComment$this->_articleId,  $this->_commentId );
                
$bayesian = new BayesianFilterCore();
                
                
$bayesian->untrain$this->_blogInfo->getId(),
                                    
$comment->getTopic(),
                                    
$comment->getText(),
                                    
$comment->getUserName(),
                                    
$comment->getUserEmail(),
                                    
$comment->getUserUrl(),
                                    
true );
                                  
                
$bayesian->train$this->_blogInfo->getId(),
                                  
$comment->getTopic(),
                                  
$comment->getText(),
                                  
$comment->getUserName(),
                                  
$comment->getUserEmail(),
                                  
$comment->getUserUrl(),
                                  
false );
                                  
                
// throw the post-event if everythign went fine
                
$this->notifyEventEVENT_POST_MARK_NO_SPAM_COMMENT,  Array( "commentId" => $this->_commentId ));
            }

            return 
$res;
        }

        
/**
         * Carries out the specified action
         */
        
function perform()
        {
            
// 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 == )
                
$result $this->_markCommentAsNonSpam();
            else
                
$result $this->_markCommentAsSpam();
                
            
// clear the cache
            
CacheControl::resetBlogCache$this->_blogInfo->getId());

            
// better to return true if everything fine
            
return $result;
        }
    }
?>



Other Blog Scripts:

WebMaster Resources Home

©RingsWorld.com