private function getData($product_id) { $parent_id = $this->getParentId(); $rate = waRequest::post('rate', null, waRequest::TYPE_INT); if (!$product_id) { $parent_comment = $this->model->getById($parent_id); $product_id = $parent_comment['product_id']; } $text = waRequest::post('text', null, waRequest::TYPE_STRING_TRIM); $title = waRequest::post('title', null, waRequest::TYPE_STRING_TRIM); return array('product_id' => $product_id, 'parent_id' => $parent_id, 'text' => $text, 'title' => $title, 'rate' => $rate && !$parent_id ? $rate : null, 'datetime' => date('Y-m-d H:i:s'), 'status' => shopProductReviewsModel::STATUS_PUBLISHED) + $this->getContactData(); }
protected function getReqiestData() { $product_id = waRequest::post('product_id', null, waRequest::TYPE_INT); $parent_id = waRequest::post('parent_id', 0, waRequest::TYPE_INT); $rate = 0; if (wa()->getEnv() == 'backend' && !$parent_id) { throw new waException(_w("Writing a review to product is available just on frontend")); } if (!$product_id && !$parent_id) { throw new waException("Can't add comment: unknown product for review or review for reply"); } if (!$product_id) { $parent_comment = $this->product_reviews_model->getById($parent_id); $product_id = $parent_comment['product_id']; $rate = waRequest::post('rate', 0, waRequest::TYPE_INT); } $text = waRequest::post('text', null, waRequest::TYPE_STRING_TRIM); $title = waRequest::post('title', null, waRequest::TYPE_STRING_TRIM); return array('product_id' => $product_id, 'parent_id' => $parent_id, 'title' => $title, 'text' => $text, 'rate' => $rate, 'contact_id' => $this->author->getId(), 'auth_provider' => shopProductReviewsModel::AUTH_USER, 'datetime' => date('Y-m-d H:i:s'), 'status' => shopProductReviewsModel::STATUS_PUBLISHED); }