Guest User

Untitled

a guest
Jan 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.39 KB | None | 0 0
  1. public function addWatchAction()
  2.     {
  3.         $this->_helper->layout->setLayout('blank');
  4.        
  5.         $celebrityId = null;
  6.         $addWatchForm = new Form_AddCelebrityWatch();
  7.        
  8.         if ($this->_request->isPost()) {
  9.             $formData = $this->_request->getPost();
  10.            
  11.             $celebrityId = (int) $formData['celebrityId'];
  12.             $celebrity = new Magic_Model_Celebrity();
  13.             $celebrity->find($celebrityId);
  14.            
  15.             if (!empty($celebrity) && $celebrity instanceof Magic_Model_Celebrity && $celebrity->getIsPublic() &&
  16.                 isset($this->view->customer) && $this->view->customer instanceof Magic_Model_Customer) {
  17.                 try {
  18.                     if ($addWatchForm->isValid($formData)) {
  19.                         $formData = $addWatchForm->getValues();
  20.                     // TODO if (array_key_exists('watchHash', $formData) && !empty($formData['watchHash'])) { TODO //
  21.                         $celebrityWatch = new Magic_Model_CelebrityWatch();
  22.                         $celebrityWatch->addWatch($formData['celebrityId'], $formData['customerId']);
  23.                         $this->view->isOK = true;
  24.                     // TODO } TODO //
  25.                     } else {
  26.                         $this->view->isOK = false;
  27.                         throw new Exception('Unable to add your item Watch. Please try again later.');
  28.                     }
  29.                 } catch (Exception $e) {
  30.                     $this->view->isError = true;
  31.                     $this->view->errMessage = $e->getMessage();
  32.                 }
  33.             }
  34.            
  35.             unset($formData, $celebrityId, $celebrity);
  36.         } else {
  37.             $celebrityId = (int) $this->getRequest()->getParam('celebrityId');
  38.             $celebrity = new Magic_Model_Celebrity();
  39.             $celebrity->find($celebrityId);
  40.             if (!empty($celebrity) && $celebrity instanceof Magic_Model_Celebrity && $celebrity->getIsPublic() &&
  41.                 isset($this->view->customer) && $this->view->customer instanceof Magic_Model_Customer) {
  42.                 try {
  43.                     $this->view->hasWatch = Magic_Model_CelebrityWatch::hasWatch($celebrity->getId(), $this->view->customer->getId());
  44.                     $this->view->celebrityId = $celebrity->getId();
  45.                     $addWatchForm->getElement('celebrityId')->setValue($celebrity->getId());
  46.                     $addWatchForm->getElement('customerId')->setValue($this->view->customer->getId());
  47.                 } catch (Exception $e) {
  48.                     $this->view->isError = true;
  49.                     $this->view->errMessage = $e->getMessage();
  50.                 }
  51.             }
  52.            
  53.             unset($celebrityId, $celebrity);
  54.         }
  55.        
  56.         $this->view->form = $addWatchForm;
  57.     }
  58. }
  59.  
  60.  
  61. /// OR ->
  62.  
  63. public function addWatchAction()
  64.     {
  65.        if ($this->_request->isPost()) {
  66.            
  67.             $formData = $this->_request->getPost();
  68.            
  69.             if ($formData['customerId']) {
  70.                 $watch = new Magic_Model_AuctionWatch;
  71.                 $added = $watch->addWatch($formData['auctionId'],$formData['customerId']);
  72.                
  73.         echo "yes";
  74.             }
  75.        }
  76.        
  77.        exit;
  78.     }
  79.  
  80. (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