Go to the documentation of this file.00001 <?php
00002
00009 class Article_Review extends oxAdminDetails
00010 {
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 = $this->getEditObjectId();
00027 $sRevoxId = oxRegistry::getConfig()->getRequestParameter('rev_oxid');
00028 if ($soxId != "-1" && isset($soxId)) {
00029
00030
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
00055 $this->_aViewData["blShowActBox"] = $myConfig->getConfigParam('blGBModerate');
00056
00057 }
00058
00059 return "article_review.tpl";
00060 }
00061
00069 protected function _getReviewList($oArticle)
00070 {
00071 $oDb = oxDb::getDb();
00072 $sSelect = "select oxreviews.* from oxreviews
00073 where oxreviews.OXOBJECTID = " . $oDb->quote($oArticle->oxarticles__oxid->value) . "
00074 and oxreviews.oxtype = 'oxarticle'";
00075
00076 $aVariantList = $oArticle->getVariants();
00077
00078 if ($this->getConfig()->getConfigParam('blShowVariantReviews') && count($aVariantList)) {
00079
00080
00081 foreach ($aVariantList as $oVariant) {
00082 $sSelect .= "or oxreviews.oxobjectid = " . $oDb->quote($oVariant->oxarticles__oxid->value) . " ";
00083 }
00084
00085 }
00086
00087
00088 $sSelect .= "and oxreviews.oxlang = '" . $this->_iEditLang . "'";
00089 $sSelect .= "and oxreviews.oxtext != '' ";
00090
00091
00092 $oRevs = oxNew("oxlist");
00093 $oRevs->init("oxreview");
00094 $oRevs->selectString($sSelect);
00095
00096 return $oRevs;
00097 }
00098
00102 public function save()
00103 {
00104 parent::save();
00105
00106 $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00107
00108 if ($this->getConfig()->getConfigParam('blGBModerate') && !isset($aParams['oxreviews__oxactive'])) {
00109 $aParams['oxreviews__oxactive'] = 0;
00110 }
00111
00112 $oReview = oxNew("oxreview");
00113 $oReview->load(oxRegistry::getConfig()->getRequestParameter("rev_oxid"));
00114 $oReview->assign($aParams);
00115 $oReview->save();
00116 }
00117
00121 public function delete()
00122 {
00123
00124 $sRevoxId = oxRegistry::getConfig()->getRequestParameter("rev_oxid");
00125 $oReview = oxNew("oxreview");
00126 $oReview->load($sRevoxId);
00127 $oReview->delete();
00128
00129
00130 $oRating = oxNew("oxRating");
00131 $sArticleId = $this->getEditObjectId();
00132
00133 $oArticle = oxNew('oxArticle');
00134 $oArticle->load($sArticleId);
00135
00136 $oArticle->setRatingAverage($oRating->getRatingAverage($sArticleId, 'oxarticle'));
00137 $oArticle->setRatingCount($oRating->getRatingCount($sArticleId, 'oxarticle'));
00138 $oArticle->save();
00139
00140 }
00141 }