article_review.php

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

Generated on Thu Feb 19 15:02:20 2009 for OXID eShop CE by  doxygen 1.5.5