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 $sSelect = "select oxreviews.* from oxreviews
00070 where oxreviews.OXOBJECTID = '".$oArticle->oxarticles__oxid->value
00071 ."' and oxreviews.oxtype = 'oxarticle'";
00072
00073 $aVariantList = $oArticle->getVariants();
00074
00075 if ( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) && count( $aVariantList )) {
00076
00077
00078 foreach ( $aVariantList as $oVariant ) {
00079 $sSelect .= "or oxreviews.oxobjectid = '".$oVariant->oxarticles__oxid->value."' ";
00080 }
00081
00082 }
00083
00084
00085 $sSelect .= "and oxreviews.oxlang = '" . $this->_iEditLang . "'";
00086 $sSelect .= "and oxreviews.oxtext != '' ";
00087
00088
00089 $oRevs = oxNew( "oxlist" );
00090 $oRevs->init( "oxreview" );
00091 $oRevs->selectString( $sSelect );
00092
00093 return $oRevs;
00094 }
00095
00101 public function save()
00102 {
00103 $myConfig = $this->getConfig();
00104
00105
00106 $aParams = oxConfig::getParameter( "editval");
00107
00108 if ( $myConfig->getConfigParam( 'blGBModerate' ) && !isset( $aParams['oxreviews__oxactive'] ) ) {
00109 $aParams['oxreviews__oxactive'] = 0;
00110 }
00111
00112 $sRevoxId = oxConfig::getParameter( "rev_oxid" );
00113 $oReview = oxNew( "oxreview" );
00114 $oReview->load( $sRevoxId );
00115
00116
00117 $oReview->oxreviews__oxshopid->value = oxSession::getVar( "actshop");
00118
00119 $oReview->assign( $aParams);
00120 $oReview->save();
00121 }
00122
00128 public function delete()
00129 {
00130
00131 $sRevoxId = oxConfig::getParameter( "rev_oxid" );
00132 $oReview = oxNew( "oxreview" );
00133 $oReview->load( $sRevoxId);
00134 $oReview->delete();
00135 }
00136 }