public function addAction() { $auth = Zend_Auth::getInstance(); $authStorage = $auth->getStorage(); $userInfo = $authStorage->read(); $userID = $userInfo->id; $id = $this->_getParam('id', 0); $dir = $this->_getParam('dir', 0); $dishes = new Model_DbTable_Dishes(); $itemsRowset = $dishes->find($id); $thisDish = $itemsRowset->current(); $dishName = $thisDish['name']; $restaurants = new Model_DbTable_Restaurants(); $itemsRowset = $restaurants->find($thisDish['restaurant_id']); $thisRest = $itemsRowset->current(); $restName = $thisRest['name']; $this->view->title = "Add Review for " . $dishName . " at " . $restName; $this->view->headTitle($this->view->title, 'PREPEND'); $form = new Form_Review(); $form->getElement('dish_id')->setValue($id); $form->getElement('user_id')->setValue($userID); if ($dir != '0') { $form->getElement('rating')->setValue($dir); } $form->submit->setLabel('Add'); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $userID = $form->getValue('user_id'); $dishID = $form->getValue('dish_id'); $rating = $form->getValue('rating'); $ratVal = 0; if ($rating == 'pos' ? $ratVal = 1 : ($ratVal = -1)) { } $comments = $form->getValue('comments'); $reviews = new Model_DbTable_Reviews(); $reviews->addReview($userID, $dishID, $ratVal, $comments); $this->_redirect('/dish/detail/id/' . $id); } else { $form->populate($formData); } } }
public function detailAction() { $id = $this->_getParam('id', 0); if ($id > 0) { //show detailed view of this dish, its rating, and restaurant $dishesC = new Model_DbTable_DishesComplete(); $itemsRowset = $dishesC->find($id); $thisDishC = $itemsRowset->current(); $this->view->dish = $thisDishC; $restaurants = new Model_DbTable_Restaurants(); $itemsRowset = $restaurants->find($thisDishC['rest_id']); $thisRest = $itemsRowset->current(); $this->view->restaurant = $thisRest; $dishName = $thisDishC['dish_name']; $categoryID = $thisDishC['fooditem_id']; $fooditems = new Model_DbTable_FoodItems(); $itemsRowset = $fooditems->find($categoryID); $thisCategory = $itemsRowset->current(); $cuisineID = $thisCategory['cuisine_id']; $cuisines = new Model_DbTable_Cuisines(); $itemsRowset = $cuisines->find($cuisineID); $thisCuisine = $itemsRowset->current(); $categoryName = $thisCategory['name']; $cuisineName = $thisCuisine['name']; $this->view->title = "{$cuisineName}: {$categoryName}: {$dishName}"; $this->view->headTitle("{$dishName}", 'PREPEND'); $dishes = new Model_DbTable_Dishes(); $itemsRowset = $dishes->find($id); $thisDish = $itemsRowset->current(); $foundReviews = $thisDish->findDependentRowset('Model_DbTable_ReviewsComplete', 'Dish'); $this->view->reviews = $foundReviews; } }