article_review.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Article_Review extends oxAdminDetails
00010 {
00017     public function render()
00018     {
00019         $myConfig = $this->getConfig();
00020 
00021         parent::render();
00022 
00023         $this->_aViewData["edit"] = $oArticle = oxNew( "oxarticle" );
00024 
00025         $soxId    = oxConfig::getParameter( 'oxid' );
00026         $sRevoxId = oxConfig::getParameter( 'rev_oxid' );
00027         if ( $soxId != "-1" && isset( $soxId)) {
00028 
00029             // load object
00030             $oArticle->load( $soxId);
00031 
00032 
00033             $oRevs = $this->_getReviewList($oArticle);
00034 
00035             foreach ( $oRevs as $oRev ) {
00036                 if ( $oRev->oxreviews__oxid->value == $sRevoxId ) {
00037                     $oRev->selected = 1;
00038                     break;
00039                 }
00040             }
00041             $this->_aViewData["allreviews"]   = $oRevs;
00042             $this->_aViewData["editlanguage"] = $this->_iEditLang;
00043 
00044             if ( isset( $sRevoxId ) ) {
00045                 $oReview = oxNew( "oxreview" );
00046                 $oReview->load( $sRevoxId );
00047                 $this->_aViewData["editreview"] = $oReview;
00048 
00049                 $oUser = oxNew( "oxuser" );
00050                 $oUser->load( $oReview->oxreviews__oxuserid->value);
00051                 $this->_aViewData["user"] = $oUser;
00052             }
00053             //show "active" checkbox if moderating is active
00054             $this->_aViewData["blShowActBox"] = $myConfig->getConfigParam( 'blGBModerate' );
00055 
00056         }
00057 
00058         return "article_review.tpl";
00059     }
00060 
00068     protected function _getReviewList($oArticle)
00069     {
00070         $oDb = oxDb::getDb();
00071         $sSelect  = "select oxreviews.* from oxreviews
00072                      where oxreviews.OXOBJECTID = ".$oDb->quote( $oArticle->oxarticles__oxid->value ) ."
00073                      and oxreviews.oxtype = 'oxarticle'";
00074 
00075         $aVariantList = $oArticle->getVariants();
00076 
00077         if ( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) && count( $aVariantList )) {
00078 
00079             // verifying rights
00080             foreach ( $aVariantList as $oVariant ) {
00081                 $sSelect .= "or oxreviews.oxobjectid = ".$oDb->quote( $oVariant->oxarticles__oxid->value )." ";
00082             }
00083 
00084         }
00085 
00086         //$sSelect .= "and oxreviews.oxtext".oxLang::getInstance()->getLanguageTag($this->_iEditLang)." != ''";
00087         $sSelect .= "and oxreviews.oxlang = '" . $this->_iEditLang . "'";
00088         $sSelect .= "and oxreviews.oxtext != '' ";
00089 
00090         // all reviews
00091         $oRevs = oxNew( "oxlist" );
00092         $oRevs->init( "oxreview" );
00093         $oRevs->selectString( $sSelect );
00094 
00095         return $oRevs;
00096     }
00097 
00103     public function save()
00104     {
00105 
00106         $aParams = oxConfig::getParameter( "editval");
00107         // checkbox handling
00108         if ( $this->getConfig()->getConfigParam( 'blGBModerate' ) && !isset( $aParams['oxreviews__oxactive'] ) ) {
00109             $aParams['oxreviews__oxactive'] = 0;
00110         }
00111 
00112         $oReview = oxNew( "oxreview" );
00113         $oReview->load( oxConfig::getParameter( "rev_oxid" ) );
00114         $oReview->assign( $aParams );
00115         $oReview->save();
00116     }
00117 
00123     public function delete()
00124     {
00125 
00126         $sRevoxId = oxConfig::getParameter( "rev_oxid" );
00127         $oReview  = oxNew( "oxreview" );
00128         $oReview->load( $sRevoxId);
00129         $oReview->delete();
00130     }
00131 }