public function createAction() { $this->logger->entering(); $paramTerms = $this->_getParam('terms'); $paramUser = $this->_getParam('user'); $this->logger->info('Validating user from params'); $validity = User::isValid($paramUser); if ($paramTerms != 1 || !$validity) { $this->logger->notice('Invalid User'); $this->flash->notice = "Please complete all fields and agree to the terms and conditions"; if (!$validity) { foreach ($paramUser['errors'] as $k => $v) { $this->flash->notice = $this->flash->notice . ", {$k} {$v}"; } } $this->logger->info('Loading view parameters'); $this->view->assign(array('title' => "New User", 'user' => $paramUser, 'states' => $this->states, 'terms' => $paramTerms)); $this->logger->info('Render view'); /* echo $this->view->render('applicationTemplate.phtml'); */ $this->render(); $this->logger->info('Clearing flash notice'); $this->flash->keep = 1; unset($this->flash->notice); } else { $this->logger->info('Building a new user from request'); $users = new User(); $user = $users->fetchNew(); $paramUser = $users->filterColumns($paramUser); $user->setFromArray($paramUser); $this->logger->info('Inserting the user'); if ($user->save()) { $this->logger->notice('Crediting signup bonus'); $transactions = new Transaction(); $transactions->signupUser($user); $this->logger->notice('Sending welcome message'); $mail = new Zend_Mail(); $mail->setBodyText('Welcome to swaplady.'); $mail->setFrom('*****@*****.**', 'Some Sender'); $mail->addTo($user->email, $user->name); $mail->setSubject('Welcome to Swaplady'); $mail->send(); $this->logger->notice('Marking as logged in'); $this->session->user_id = $user->id; if (isset($this->flash->redirectedFrom)) { $intendedAction = $this->flash->redirectedFrom; $this->logger->info("Redirecting to intended action '{$intendedAction['controller']}::{$intendedAction['action']}'"); $this->_redirect('/' . $intendedAction['controller'] . '/' . $intendedAction['action']); } else { $this->logger->info("Redirecting to show user {$user->id}"); $this->_redirect("user/show/{$user->id}"); } } } $this->logger->exiting(); }