/** * User wants to take a new subscription */ protected function displayInvitation() { $check = WpSubscription::canSubscribe($this->getUser()); if ($check !== true) { $this->action = self::ACTION_LIST; $this->msgKey = $check; $this->msgType = 'error'; $this->display(); return; } $invitationForm = array('InvitationCode' => array('type' => 'text', 'default' => $this->invitationCode != null ? $this->invitationCode : '', 'section' => 'use-section', 'label-message' => 'wp-inv-code-field', 'help-message' => 'wp-use-inv-help', 'validation-callback' => array($this, 'validateInvitationCode'), 'filter-callback' => array($this, 'filterInvitationCode'))); $invitationHtml = new HTMLFormS($invitationForm); $invitationHtml->addHeaderText(wfMessage('wp-use-inv-header')->parse()); $invitationHtml->setMessagePrefix('wp-inv'); $invitationHtml->setTitle($this->getTitleFor(self::TITLE_NAME, self::ACTION_USE_INVITATION)); $invitationHtml->setSubmitCallback(array($this, 'processInvitation')); $invitationHtml->setSubmitText(wfMessage('wp-use-inv-go')->text()); if ($this->invitationCode != null) { // handle invitation code from url $invitationHtml->prepareForm(); // fill form with default value specified in descriptor $result = $invitationHtml->trySubmit(); // validate and process if ($result === true) { // code ok $this->action = self::ACTION_NEW; $this->msgKey = 'wp-use-inv-ok'; $this->msgType = 'success'; $this->display(); } else { $invitationHtml->displayForm($result); } } else { // or display and process form from post if ($invitationHtml->show()) { $this->action = self::ACTION_NEW; $this->msgKey = 'wp-use-inv-ok'; $this->msgType = 'success'; $this->display(); } } }