public function indexAction() { $table = new Application_Model_DbTable_Zdjecia(); $zdjecia = $table->getAllForAdmin(); $zdjecia->setCurrentPageNumber($this->_getParam('page', 1)); $zdjecia->setItemCountPerPage(50); $this->view->zdjecia = $zdjecia; $options = $this->getInvokeArg('bootstrap')->getOption('zdjecie'); $this->view->path = $options['dir']; }
public function glosujAction() { if (! $this->getRequest()->isPost() || !is_numeric($this->_getParam('zdjecie'))) { return $this->_forward('zdjecia', 'index', null, array('err' => 'voting-error')); } if (! $this->facebook->isPageFan()) { return $this->_forward('index', 'index', null, array('err' => 'no-fan')); } $glosy = new Application_Model_DbTable_Glosy(); if ($glosy->hasVoted($this->fbUserId, $this->_getParam('zdjecie'))) { return $this->_forward('index', 'zdjecia', null, array('err' => 'voted')); } $zdjecia = new Application_Model_DbTable_Zdjecia(); $rowset = $zdjecia->find($this->_getParam('zdjecie')); $zdjecie = $rowset->current(); $zdjecie->glosy += 1; $zdjecie->save(); $glosy->insert( array( 'fbuserid' => $this->fbUserId, 'dodano' => new Zend_Db_Expr('NOW()'), 'zdjecie' => $this->_getParam('zdjecie') ) ); $this->_redirect('/zdjecia?msg=vote-added'); }