public function zglosAction()
    {
        if (! $this->facebook->isPageFan()) {
            return $this->_forward('index', 'index', null, array('err' => 'no-fan'));
        }

        $config = new Application_Model_DbTable_Config();
        if ($config->getCanEnter() == false) {
            return;
        }

        $request = $this->getRequest();
        $form = new Application_Form_Zdjecie(
            $this->getInvokeArg('bootstrap')->getOption('zdjecie')
        );

        $form->populate(array('fbid' => $this->fbUserId));

        if ($this->getRequest()->isPost()) {
            if (! $form->isValid($this->getRequest()->getPost())) {
                $this->view->form = $form;
                return;
            }

            if (! $form->photo->receive()) {
                $form->photo->addErrorMessage('Dodanie zdjęcia nie powiodło się');
                $this->view->form = $form;
                return;
            }

            $fbUser = $this->facebook->api('/me');

            $zdjecia = new Application_Model_DbTable_Zdjecia();
            $zdjecieId = $zdjecia->insert(
                array(
                    'fbuserid' => $fbUser['id'],
                    'fbname' => $fbUser['name'],
                    'fblink' => $fbUser['link'],
                    'dodano' => new Zend_Db_Expr('NOW()'),
                )
            );

            if (! is_numeric($zdjecieId)) {
                throw new RuntimeException('Błąd systemu. Zdjęcie nie zostało zapisane');
            }

            $zdjecie = new Application_Model_Zdjecie(
                $form->photo->getFileName(),
                $this->getInvokeArg('bootstrap')->getOption('zdjecie')
            );

            $zdjecie->resize();
            $zdjecie->save($zdjecieId);
            $zdjecie->clear();

            $this->_redirect('/zdjecia?msg=photo-added');
        }

        $this->view->form = $form;
    }
    public function indexAction()
    {
        if (!$this->facebook->getUser() || is_null($this->_getParam('code'))) {
            return $this->_forward('redirect');
        }

        if (!is_null($this->_getParam('msg'))) {
            $this->view->messages = array($this->_getParam('msg'));
        }

        if (!is_null($this->_getParam('err'))) {
            $this->view->errors = array($this->_getParam('err'));
        }

        $this->view->isPageFan = $this->facebook->isPageFan();

        $config = new Application_Model_DbTable_Config();
        $this->view->canEnter = $config->getCanEnter();
    }