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 = $this->getEditObjectId();
00026 $sRevoxId = oxConfig::getParameter( 'rev_oxid' );
00027 if ( $soxId != "-1" && isset( $soxId)) {
00028
00029
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
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
00080 foreach ( $aVariantList as $oVariant ) {
00081 $sSelect .= "or oxreviews.oxobjectid = ".$oDb->quote( $oVariant->oxarticles__oxid->value )." ";
00082 }
00083
00084 }
00085
00086
00087 $sSelect .= "and oxreviews.oxlang = '" . $this->_iEditLang . "'";
00088 $sSelect .= "and oxreviews.oxtext != '' ";
00089
00090
00091 $oRevs = oxNew( "oxlist" );
00092 $oRevs->init( "oxreview" );
00093 $oRevs->selectString( $sSelect );
00094
00095 return $oRevs;
00096 }
00097
00103 public function save()
00104 {
00105 parent::save();
00106
00107 $aParams = oxConfig::getParameter( "editval");
00108
00109 if ( $this->getConfig()->getConfigParam( 'blGBModerate' ) && !isset( $aParams['oxreviews__oxactive'] ) ) {
00110 $aParams['oxreviews__oxactive'] = 0;
00111 }
00112
00113 $oReview = oxNew( "oxreview" );
00114 $oReview->load( oxConfig::getParameter( "rev_oxid" ) );
00115 $oReview->assign( $aParams );
00116 $oReview->save();
00117 }
00118
00124 public function delete()
00125 {
00126
00127 $sRevoxId = oxConfig::getParameter( "rev_oxid" );
00128 $oReview = oxNew( "oxreview" );
00129 $oReview->load( $sRevoxId);
00130 $oReview->delete();
00131 }
00132 }