public function execute()
 {
     $product = $this->getProduct();
     $data = $this->getData($product['id']);
     $errors = $this->model->validate($data);
     $this->errors += $errors;
     if ($this->errors) {
         return false;
     }
     $id = $this->model->add($data, $data['parent_id']);
     if (!$id) {
         throw new waException("Error in adding review");
     } else {
         $this->logAction('product_review_add', $product['id']);
     }
     $count = waRequest::post('count', 0, waRequest::TYPE_INT) + 1;
     $this->response = array('id' => $id, 'parent_id' => $this->getParentId(), 'count' => $count, 'html' => $this->renderTemplate(array('review' => $this->model->getReview($id, true), 'reply_allowed' => true, 'ajax_append' => true), 'file:review.html'), 'review_count_str' => _w('%d review for ', '%d reviews for ', $count) . $product['name']);
 }
예제 #2
0
 public function execute()
 {
     $data = $this->getReqiestData();
     if ($this->errors = $this->product_reviews_model->validate($data)) {
         return false;
     }
     $id = $this->product_reviews_model->add($data, $data['parent_id']);
     if (!$id) {
         throw new waException("Error in adding review");
     }
     $data['id'] = $id;
     $data['author'] = $this->getResponseAuthorData();
     $this->view->assign('review', $data);
     $this->view->assign('reply_allowed', true);
     $this->response['id'] = $data['id'];
     $this->response['parent_id'] = $data['parent_id'];
     $this->response['html'] = $this->view->fetch('templates/actions/product/include.review.html');
 }