public function addReviews() { $DbExt = new DbExt(); if (Yii::app()->functions->isClientLogin()) { $client_id = Yii::app()->functions->getClientId(); $params = array('merchant_id' => $this->data['merchant-id'], 'client_id' => $client_id, 'review' => $this->data['review_content'], 'date_created' => date('c'), 'rating' => $this->data['initial_review_rating']); /** check if user has bought from the merchant*/ if (Yii::app()->functions->getOptionAdmin('website_reviews_actual_purchase') == "yes") { $functionk = new FunctionsK(); if (!$functionk->checkIfUserCanRateMerchant($client_id, $this->data['merchant-id'])) { $this->msg = t("Reviews are only accepted from actual purchases!"); return; } } if ($DbExt->insertData("{{review}}", $params)) { $this->code = 1; $this->msg = Yii::t("default", "Your review has been published."); if (isset($this->data['initial_review_rating'])) { Yii::app()->functions->updateRatings($this->data['merchant-id'], $this->data['initial_review_rating'], $client_id); } } else { $this->msg = Yii::t("default", "ERROR: cannot insert records."); } } else { $this->msg = Yii::t("default", "Sorry but you need to login to write a review."); } }