function process(array $vars, $name, HTML_QuickForm2_Controller_Page $page) { $this->vars = $vars; $em = $page->getController()->getSessionContainer()->getOpaque('EmailCode'); // do actions here $this->user = $this->getDi()->auth->getUser(); if (!$this->user) { $this->user = $this->getDi()->userRecord; $this->user->setForInsert($this->vars); // vars are filtered by the form ! if (empty($this->user->login)) { $this->user->generateLogin(); } if (empty($this->vars['pass'])) { $this->user->generatePassword(); } else { $this->user->setPass($this->vars['pass']); } if ($this->getDi()->config->get('aff.signup_type') == 2) { $this->user->is_approved = 0; } if (empty($this->user->lang)) { $this->user->lang = $this->getDi()->locale->getLanguage(); } $this->user->is_affiliate = 1; $this->user->insert(); $this->getDi()->hook->call(Am_Event::SIGNUP_USER_ADDED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form)); } else { unset($this->vars['pass']); unset($this->vars['login']); unset($this->vars['email']); $this->user->setForUpdate($this->vars)->update(); $this->user->is_affiliate = $this->getModule()->getConfig('signup_type') == 2 ? 0 : 1; $this->user->save(); // user updated $this->getDi()->hook->call(Am_Event::SIGNUP_USER_UPDATED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form, 'savedForm' => $this->record)); } // remove verification record if (!empty($em)) { $this->getDi()->store->delete(Am_Form_Signup_Action_SendEmailCode::STORE_PREFIX . $em); } $page->getController()->destroySessionContainer(); $this->getDi()->hook->call(Am_Event::SIGNUP_AFF_ADDED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form)); if ($this->user->isApproved() && !$this->getDi()->auth->getUserId()) { $this->getDi()->auth->setUser($this->user, $_SERVER['REMOTE_ADDR']); } if ($this->getDi()->config->get('aff.registration_mail') && $this->user->isApproved()) { $this->getDi()->modules->get('aff')->sendAffRegistrationEmail($this->user); } if (!$this->user->isApproved() || !$this->user->is_affiliate) { $this->getModule()->sendNotApprovedEmail($this->user); $this->view->content = '<div class="am-info">' . $this->msg . '</div>'; $this->view->display('layout.phtml'); } else { $this->_redirect('aff/aff'); } return true; }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { $page->storeValues(!$page->getController()->isWizard()); // go to the previous page if one is available // we don't check validation status here, 'jump' handler should if ($previous = $page->getController()->previousPage($page)) { return $previous->handle('jump'); } else { return $page->handle('jump'); } }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { $validate = false; $datasources = $page->getForm()->getDataSources(); $container = $page->getController()->getSessionContainer(); list(, $oldName) = $page->getController()->getActionName(); // Check the original action name, we need to do additional processing // if it was 'display' if ('display' == $oldName) { // In case of wizard-type controller we should not allow access to // a page unless all previous pages are valid (see also bug #2323) if ($page->getController()->isWizard() && !$page->getController()->isValid($page)) { return $page->getController()->getFirstInvalidPage()->handle('jump'); } // If we have values in container then we should inject the Session // DataSource, if page was invalid previously we should later call // validate() to get the errors if (count($container->getValues($page->getForm()->getId()))) { array_unshift($datasources, new HTML_QuickForm2_DataSource_Session($container->getValues($page->getForm()->getId()))); $validate = false === $container->getValidationStatus($page->getForm()->getId()); } } // Add "defaults" datasources stored in session $page->getForm()->setDataSources(array_merge($datasources, $container->getDatasources())); $page->populateFormOnce(); if ($validate) { $page->getForm()->validate(); } return $this->renderForm($page->getForm()); }
function process(array $vars, $name, HTML_QuickForm2_Controller_Page $page) { $this->vars = $vars; $em = $page->getController()->getSessionContainer()->getOpaque('EmailCode'); // do actions here $this->user = $this->getDi()->userRecord; $this->user->setForInsert($this->vars); // vars are filtered by the form ! $this->user->is_affiliate = 1; if ($this->getDi()->config->get('aff.signup_type') == 2) { $this->user->is_approved = 0; } if (empty($this->user->login)) { $this->user->generateLogin(); } if (empty($this->vars['pass'])) { $this->user->generatePassword(); } else { $this->user->setPass($this->vars['pass']); } $this->user->insert(); // remove verification record if (!empty($em)) { $this->getDi()->store->delete(Am_Form_Signup_Action_SendEmailCode::STORE_PREFIX . $em); } $page->getController()->destroySessionContainer(); $this->getDi()->hook->call(Am_Event::SIGNUP_USER_ADDED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form)); $this->getDi()->hook->call(Am_Event::SIGNUP_AFF_ADDED, array('vars' => $this->vars, 'user' => $this->user, 'form' => $this->form)); if ($this->user->isApproved()) { $this->getDi()->auth->setUser($this->user, $_SERVER['REMOTE_ADDR']); } if ($this->getDi()->config->get('aff.registration_mail') && $this->user->isApproved()) { $this->getDi()->modules->get('aff')->sendAffRegistrationEmail($this->user); } if (!$this->user->isApproved()) { $this->user->sendNotApprovedEmail(); } $this->_redirect('aff/aff'); return true; }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { $valid = $page->storeValues(); // Wizard and page is invalid: don't go further if ($page->getController()->isWizard() && !$valid) { return $page->handle('display'); } // More pages? if (null !== ($next = $page->getController()->nextPage($page))) { return $next->handle('jump'); // Consider this a 'finish' button, if there is no explicit one } elseif ($page->getController()->isWizard()) { if ($page->getController()->isValid()) { return $page->handle('process'); } else { // redirect to the first invalid page return $page->getController()->getFirstInvalidPage()->handle('jump'); } } else { return $page->handle('display'); } }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { $valid = $page->storeValues(); // All pages are valid, process if ($page->getController()->isValid()) { return $page->handle('process'); // Current page is invalid, display it } elseif (!$valid) { return $page->handle('display'); // Some other page is invalid, redirect to it } else { return $page->getController()->getFirstInvalidPage()->handle('jump'); } }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { // we check whether *all* pages up to current are valid // if there is an invalid page we go to it, instead of the // requested one if ($page->getController()->isWizard() && !$page->getController()->isValid($page)) { $page = $page->getController()->getFirstInvalidPage(); } // generate the URL for the page 'display' event and redirect to it $action = $page->getForm()->getAttribute('action'); // Bug #13087: RFC 2616 requires an absolute URI in Location header if (!preg_match('@^([a-z][a-z0-9.+-]*):@i', $action)) { $action = self::resolveRelativeURL($action); } if (!$page->getController()->propagateId()) { $controllerId = ''; } else { $controllerId = '&' . HTML_QuickForm2_Controller::KEY_ID . '=' . $page->getController()->getId(); } if (!defined('SID') || '' == SID || ini_get('session.use_only_cookies')) { $sessionId = ''; } else { $sessionId = '&' . SID; } return $this->doRedirect($action . (false === strpos($action, '?') ? '?' : '&') . $page->getButtonName('display') . '=true' . $controllerId . $sessionId); }
/** * Adds a new page to the form * * @param HTML_QuickForm2_Controller_Page $page */ public function addPage(HTML_QuickForm2_Controller_Page $page) { $pageId = $page->getForm()->getId(); if (!empty($this->pages[$pageId])) { throw new HTML_QuickForm2_InvalidArgumentException("Duplicate page ID '{$pageId}'"); } $page->setController($this); $this->pages[$pageId] = $page; }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { $page->storeValues(); return $page->getController()->getPage($name)->handle('jump'); }
/** * Sets the default action invoked on page-form submit * * This is necessary as the user may just press Enter instead of * clicking one of the named submit buttons and thn no action name will * be passed to the script. * * @param string Default action name * @param string Path to a 1x1 transparent GIF image * @return object Returns the image input used for default action */ public function setDefaultAction($actionName, $imageSrc = '') { parent::setDefaultAction($actionName, $imageSrc); $image = $this->form->getElementById('_qf_default'); if (!$image) { return; } $image->setAttribute('style', 'display: none;'); }
public function perform(HTML_QuickForm2_Controller_Page $page, $name) { echo "Submit successful!<br>\n<pre>\n"; var_dump($page->getController()->getValue()); echo "\n</pre>\n"; }