Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function addWatchAction()
- {
- $this->_helper->layout->setLayout('blank');
- $celebrityId = null;
- $addWatchForm = new Form_AddCelebrityWatch();
- if ($this->_request->isPost()) {
- $formData = $this->_request->getPost();
- $celebrityId = (int) $formData['celebrityId'];
- $celebrity = new Magic_Model_Celebrity();
- $celebrity->find($celebrityId);
- if (!empty($celebrity) && $celebrity instanceof Magic_Model_Celebrity && $celebrity->getIsPublic() &&
- isset($this->view->customer) && $this->view->customer instanceof Magic_Model_Customer) {
- try {
- if ($addWatchForm->isValid($formData)) {
- $formData = $addWatchForm->getValues();
- // TODO if (array_key_exists('watchHash', $formData) && !empty($formData['watchHash'])) { TODO //
- $celebrityWatch = new Magic_Model_CelebrityWatch();
- $celebrityWatch->addWatch($formData['celebrityId'], $formData['customerId']);
- $this->view->isOK = true;
- // TODO } TODO //
- } else {
- $this->view->isOK = false;
- throw new Exception('Unable to add your item Watch. Please try again later.');
- }
- } catch (Exception $e) {
- $this->view->isError = true;
- $this->view->errMessage = $e->getMessage();
- }
- }
- unset($formData, $celebrityId, $celebrity);
- } else {
- $celebrityId = (int) $this->getRequest()->getParam('celebrityId');
- $celebrity = new Magic_Model_Celebrity();
- $celebrity->find($celebrityId);
- if (!empty($celebrity) && $celebrity instanceof Magic_Model_Celebrity && $celebrity->getIsPublic() &&
- isset($this->view->customer) && $this->view->customer instanceof Magic_Model_Customer) {
- try {
- $this->view->hasWatch = Magic_Model_CelebrityWatch::hasWatch($celebrity->getId(), $this->view->customer->getId());
- $this->view->celebrityId = $celebrity->getId();
- $addWatchForm->getElement('celebrityId')->setValue($celebrity->getId());
- $addWatchForm->getElement('customerId')->setValue($this->view->customer->getId());
- } catch (Exception $e) {
- $this->view->isError = true;
- $this->view->errMessage = $e->getMessage();
- }
- }
- unset($celebrityId, $celebrity);
- }
- $this->view->form = $addWatchForm;
- }
- }
- /// OR ->
- public function addWatchAction()
- {
- if ($this->_request->isPost()) {
- $formData = $this->_request->getPost();
- if ($formData['customerId']) {
- $watch = new Magic_Model_AuctionWatch;
- $added = $watch->addWatch($formData['auctionId'],$formData['customerId']);
- echo "yes";
- }
- }
- exit;
- }
- (because if you havent got customerId, or AuctionId, you cant ACTUALLY get to this fucking thing in the first place)
Add Comment
Please, Sign In to add comment