class UserController extends Zend_Controller_Action
{
public function checkLogged()
{
if (!Application_Model_LoggedUser::isLogged())
{
Application_Message::getInstance()->addError('Użytkownik nie zalogowany');
$this->_redirect
($this->_helper
->url('index', 'index', null, array(), true)); }
}
public function getServerName()
{
return '78.46.51.139';
}
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
}
public function activateAction()
{
$userId = $this->_getParam('id', null);
$token = $this->_getParam('token', null);
{
Application_Message::getInstance()->addError('Nie poprawne parametry aktywacyjne');
$this->_redirect($this->_helper->url('index', 'index'));
}
$userModel = new Application_Model_User();
$result = $userModel->activate($userId, $token);
if ($result == true)
{
Application_Message::getInstance()->addSuccess('Twoje konto zostało aktywowane. Zaloguj się by korzystać z serwisu.');
$this->_redirect($this->_helper->url('index', 'index'));
} else
{
Application_Message::getInstance()->addError($result);
$this->_redirect($this->_helper->url('index', 'index'));
}
}
public function registerAction()
{
if ($this->getRequest()->isPost())
{
$postVars = $this->getRequest()->getPost();
if (isset($postVars['registersubmit'])) {
if empty($registerForm->isValid($postVars)) {
}
}
$this->view->rolldownRegister = true;
$this->_forward('index', 'index');
return;
$staticPageModel = new Application_Model_StaticPage();
$registerForm = new Application_Form_UserRegister();
$loginForm = new Application_Form_UserLogin();
$forgotPasswordForm = new Application_Form_UserForgotPassword();
if ($this->getRequest()->isPost())
{
$postVars = $this->getRequest()->getPost();
if (isset($postVars['registersubmit'])) {
if ($registerForm->isValid($postVars))
{
$userModel = new Application_Model_User();
if (( $result = $userModel->register($postVars) ) === true)
{
Application_Message::getInstance()->addSuccess('Konto zostało utworzone. Aby je aktywować postępuj według instrukcji z listu, który wysłaliśmy. Jeśli nie otrzymałeś listu sprawdź proszę folder SPAM');}
$this->_redirect($this->_helper->url('index', 'index'));
} else
{
Application_Message::getInstance()->addError($result);
}
} else {
}
}
if (isset($postVars['loginsubmit'])) {
if ($loginForm->isValid($postVars))
{
$userModel = new Application_Model_User();
if (( $result = $userModel->login($postVars['userName'], $postVars['password']) ) === true)
{
Application_Message::getInstance()->addSuccess('Zostałeś zalogowany');
$this->_redirect($this->_helper->url('index', 'index'));
} else
{
Application_Message::getInstance()->addError($result);
}
}
}
if (isset($postVars['forgotpasswordsubmit'])) if ($forgotPasswordForm->isValid($postVars))
{
$userModel = new Application_Model_User();
if (( $result = $userModel->recoverPassword($postVars['email']) ) === true)
{
Application_Message::getInstance()->addSuccess('Instrukcje dotyczące odzyskania hasła zostały wysłane na podany adres e-mail');
$this->_redirect($this->_helper->url('index', 'index'));
} else
{
Application_Message::getInstance()->addError($result);
}
}
}
}
$fragment = $staticPageModel->getStaticFragmentByFragmentName('rejestracja_kolumna');
$this->view->staticpagetitle = $fragment->title;
$this->view->staticpagecontent = $fragment->content;
$this->view->regform = $registerForm;
$this->view->loginform = $loginForm;
$this->view->forgotpasswordform = $forgotPasswordForm;
}
public function logoutAction()
{
$userModel = new Application_Model_User();
if ($userModel->logout())
{
Application_Message::getInstance()->addSuccess('Pomyślnie wylogowano');
} else
{
Application_Message::getInstance()->addError('Błąd podczas wylogowywania');
}
$this->_redirect($this->_helper->url('index', 'index'));
}
public function loginAction()
{
if ($this->getRequest()->isPost())
{
$postVars = $this->getRequest()->getPost();
$userModel = new Application_Model_User();
if (isset($postVars['remember'])) {
$rememberUser = true;
} else
{
$rememberUser = false;
}
if (( $result = $userModel->login($postVars['username'], $postVars['password'], $rememberUser) ) === true)
{
Application_Message::getInstance()->addSuccess('Zostałeś zalogowany');
$this->_redirect($this->_helper->url('index', 'index'));
} else
{
Application_Message::getInstance()->addError($result);
}
}
$this->_redirect($this->_helper->url('index', 'index'));
}
public function profileAction()
{
$this->checkLogged();
$this->view->rolldownProfile = true;
$this->_forward('index', 'index');
return;
$creditModel = new Application_Model_Credit();
$staticPageModel = new Application_Model_StaticPage();
$userChangePasswordForm = new Application_Form_UserChangePassword();
if ($this->getRequest()->isPost())
{
$formVars = $this->getRequest()->getPost();
if (isset($formVars['changepasswordnsubmit'])) {
if ($userChangePasswordForm->isValid($formVars))
{
$user = new Application_Model_User();
if (( $result = $user->changePassword($formVars) ) === true)
{
Application_Message::getInstance()->addSuccess('Hasło zostało zmienione');
$this->_redirect($this->_helper->url('profile', 'user'));
} else
{
Application_Message::getInstance()->addError($result);
}
}
}
$creditsFragment = $staticPageModel->getStaticFragmentByFragmentName('profil_kredyty');
$partnerFragment = $staticPageModel->getStaticFragmentByFragmentName('profil_partner');
$this->view->credits = $creditModel->getCreditsOptions();
$this->view->smscredits = $creditModel->getSmsCreditsOptions();
$this->view->changepasswordform = $userChangePasswordForm;
$this->view->staticcredits = $creditsFragment->content;
$this->view->staticpartnership = $partnerFragment->content;
// action body
}
public function creditsAction()
{
$this->checkLogged();
$creditModel = new Application_Model_Credit();
$this->view->credits = $creditModel->getCreditsOptions();
$this->view->yeticredits = $creditModel->getYetiCreditsOptions();
$this->view->smscredits = $creditModel->getSmsCreditsOptions();
}
public function templateremoveAction()
{
$this->checkLogged();
$entryId = $this->_getParam('entryId');
{
Application_Message::getInstance()->addError('Niepoprawne wywołanie');
$this->_redirect
($this->_helper
->url('template', 'user', null, array(), true)); }
$user = new Application_Model_User();
$result = $user->removeShowTemplateEntry($entryId);
if ($result !== true)
{
Application_Message::getInstance()->addError($result);
} else
{
Application_Message::getInstance()->addSuccess('Pozycja została usunięta');
}
$this->_redirect
($this->_helper
->url('template', 'user', null, array(), true)); }
public function templateupAction()
{
$this->checkLogged();
$entryId = $this->_getParam('entryId');