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
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
00067 protected function _getReviewList($oArticle)
00068 {
00069 $oDb = oxDb::getDb();
00070 $sSelect = "select oxreviews.* from oxreviews
00071 where oxreviews.OXOBJECTID = ".$oDb->quote( $oArticle->oxarticles__oxid->value ) ."
00072 and oxreviews.oxtype = 'oxarticle'";
00073
00074 $aVariantList = $oArticle->getVariants();
00075
00076 if ( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) && count( $aVariantList )) {
00077
00078
00079 foreach ( $aVariantList as $oVariant ) {
00080 $sSelect .= "or oxreviews.oxobjectid = ".$oDb->quote( $oVariant->oxarticles__oxid->value )." ";
00081 }
00082
00083 }
00084
00085
00086 $sSelect .= "and oxreviews.oxlang = '" . $this->_iEditLang . "'";
00087 $sSelect .= "and oxreviews.oxtext != '' ";
00088
00089
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
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
00118 $oReview->oxreviews__oxshopid->value = oxSession::getVar( "actshop");
00119
00120 $oReview->assign( $aParams);
00121 $oReview->save();
00122 }
00123
00129 public function delete()
00130 {
00131
00132 $sRevoxId = oxConfig::getParameter( "rev_oxid" );
00133 $oReview = oxNew( "oxreview" );
00134 $oReview->load( $sRevoxId);
00135 $oReview->delete();
00136 }
00137 }