Inheritance: extends Zend_Form
 public function organizationConfirmAction()
 {
     // retrieve data saved in the first stage
     $sessionData = new Zend_Session_Namespace('data');
     if (null === $sessionData->postData) {
         return $this->_redirect('radio-application/organization-form');
     }
     $form = new Application_Form_Confirm();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid(filter_input_array(INPUT_POST))) {
             // add to database, etc.
             $organizationVals = $sessionData->postData['organizationForm'];
             $statementVals = $sessionData->postData['statementForm'];
             //$closingVals = $sessionData->postData['closing'];
             $this->insertOrganizationRecord($organizationVals, $statementVals);
             // don't need session namespace anymore so delete
             Zend_Session::namespaceUnset('data');
             // redirect to success confirmation page
             return $this->_redirect('radio-application/success?page=org');
         }
     }
     $this->view->form = $form;
 }
Example #2
0
 public function confirmAction()
 {
     $user = $this->_helper->service('user')->find($this->_getParam('user'));
     if (empty($user)) {
         $this->_helper->flashMessenger(array('error', "User not found"));
         $this->_helper->redirector('index', 'index', 'default');
     }
     if (!$user->isPending()) {
         $this->_helper->flashMessenger(array('error', "User has been activated"));
         $this->_helper->redirector('index', 'index', 'default');
     }
     $token = $this->_getParam('token', false);
     if (!$token) {
         $this->_helper->flashMessenger(array('error', "No token provided"));
         $this->_helper->redirector('index', 'index', 'default');
     }
     if (!$this->_helper->service('user.token')->checkToken($user, $token, 'email.confirm')) {
         $this->_helper->flashMessenger(array('error', "Invalid token"));
         $this->_helper->redirector('index', 'index', 'default');
     }
     $form = new Application_Form_Confirm();
     $form->setMethod('POST');
     $values = array();
     if ($user->getFirstName()) {
         $values['first_name'] = $user->getFirstName();
     }
     if ($user->getLastName()) {
         $values['last_name'] = $user->getLastName();
     }
     $form->populate($values);
     $this->view->terms = false;
     if ($user->getFirstName() || $user->getLastName()) {
         $form->addElement('checkbox', 'terms_of_use', array('label' => 'Accepting terms of use', 'required' => true, 'validators' => array(array('greaterThan', true, array('min' => 0))), 'errorMessages' => array("Sie können sich nur registrieren, wenn Sie unseren Nutzungsbedingungen zustimmen. Dies geschieht zu Ihrer und unserer Sicherheit. Bitten setzen Sie im entsprechenden Feld ein Häkchen.")));
         $this->view->terms = true;
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         try {
             $values = $form->getValues();
             $this->_helper->service('user')->savePending($values, $user);
             $this->_helper->service('user.token')->invalidateTokens($user, 'email.confirm');
             $this->_helper->service('dispatcher')->notify('user.register', new GenericEvent($this, array('user' => $user)));
             $auth = \Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 // show index
                 $this->_helper->flashMessenger('User registered successfully.');
                 $this->_helper->redirector('index', 'index', 'default');
             } else {
                 $adapter = $this->_helper->service('auth.adapter');
                 $adapter->setEmail($user->getEmail())->setPassword($values['password']);
                 $result = $auth->authenticate($adapter);
                 $this->_helper->redirector('index', 'dashboard', 'default', array('first' => 1));
             }
         } catch (\Exception $e) {
             switch ($e->getMessage()) {
                 case 'username_conflict':
                     $form->username->addError('Username is used. Please use another one.');
                     break;
                 default:
                     var_dump($e);
                     exit;
             }
         }
     }
     $this->view->form = $form;
 }
 /**
  * Remove profile
  */
 public function removeprofileAction()
 {
     $request = $this->getRequest();
     $profile_id = $request->getParam('id', null);
     $Profiles = new Application_Model_Profiles();
     $profile = $Profiles->getProfileByField('id', $profile_id);
     $this->view->sidebar_editprofile = $profile;
     // attach sidebar box
     Zend_Registry::get('hooks')->attach('hook_view_sidebar', 5, function () {
         echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/editprofile.phtml');
     });
     $request = $this->getRequest();
     $form = new Application_Form_Confirm();
     $this->view->form = $form;
     if ($request->isPost() && $form->isValid($_POST) && $profile) {
         $Profiles->removeProfile($profile_id);
         Application_Plugin_Alerts::success($this->view->translate('Profile updated'));
         // flush url
         $this->redirect('search/users');
     }
 }
 /**
  * Close account
  */
 public function closeaccountAction()
 {
     $this->buildMenu();
     $form = new Application_Form_Confirm();
     $this->view->form = $form;
     $request = $this->getRequest();
     // Form Submitted...
     if ($request->isPost() && $form->isValid($_POST)) {
         Application_Plugin_Common::redirectOnDemoAccount();
         $Profiles = new Application_Model_Profiles();
         $Profiles->updateField(Zend_Auth::getInstance()->getIdentity()->name, 'is_hidden', 1);
         Application_Plugin_Alerts::success($this->view->translate('Your account is now closed'), 'off');
         // redirect to logout
         $this->redirect('index/logout');
     }
 }