public function displayAddMember() { $user = $this->getUser(); $wikiplaces = null; if ($this->name != null) { $wikiplace = $this->checkWikiPlace($this->name); if (is_null($wikiplace)) { return; } if ($user->isAllowed(WP_ADMIN_RIGHT) && !$wikiplace->isOwner($user->getId())) { $wikiplaces = array($wikiplace); } } $wikiplaceSelect = $this->populateWikiPlaceSelect(array('type' => 'select', 'label-message' => 'wp-wikiplace-field', 'section' => 'addmember-section', 'help-message' => 'wp-addmember-wikiplace-help', 'validation-callback' => array($this, 'validateAddMemberWikiplaceID'), 'options' => array()), $wikiplaces, $this->name); if (count($wikiplaceSelect['options']) == 0) { $this->action = self::ACTION_LIST_WIKIPLACES; $this->msgKey = 'wp-create-wp-first'; $this->msgType = 'error'; $this->display(); return; } $usernameText = array('type' => 'text', 'label-message' => 'username', 'section' => 'addmember-section', 'help-message' => 'wp-addmember-username-help', 'validation-callback' => array($this, 'validateAddMemberUserName'), 'size' => 60, 'default' => ''); $htmlForm = new HTMLFormS(array('WpId' => $wikiplaceSelect, 'UserName' => $usernameText)); $htmlForm->addHeaderText(wfMessage('wp-addmember-header')->parse()); $htmlForm->setMessagePrefix('wp'); $htmlForm->setTitle($this->getTitleForCurrentRequest()); $htmlForm->setSubmitCallback(array($this, 'processAddMember')); $htmlForm->setSubmitText(wfMessage('wp-add')->text()); if ($htmlForm->show()) { $this->action = self::ACTION_LIST_MEMBERS; $this->msgKey = 'wp-addmember-success'; $this->msgType = 'success'; $this->display(); return; } }
protected function displayRenew() { // at this point, user is logged in $user_id = $this->getUser()->getId(); $sub = WpSubscription::newActiveByUserId($user_id); if ($sub == null) { // "need an active subscription" $this->action = self::ACTION_LIST; $this->msgType = 'error'; $this->msgKey = 'wp-no-active-sub'; $this->display(); return; } $renewal_plan_id = $sub->getRenewalPlanId(); $formDescriptor = array('Plan' => array('type' => 'select', 'section' => 'sub-renew-section', 'label-message' => 'wp-planfield', 'help-message' => 'wp-planfield-help', 'validation-callback' => array($this, 'validateRenewPlanId'), 'options' => array(), 'default' => $renewal_plan_id), 'Check' => array('type' => 'check', 'section' => 'sub-renew-section', 'label-message' => 'wp-checkfield', 'validation-callback' => array($this, 'validateSubscribeCheck'), 'required' => 'true')); $nb_wikiplaces = WpWikiplace::countWikiplacesOwnedByUser($user_id); $nb_wikiplace_pages = WpPage::countPagesOwnedByUser($user_id); $diskspace = WpPage::countDiskspaceUsageByUser($user_id); $when = $sub->getEnd(); $plans = WpPlan::factoryAvailableForRenewal($nb_wikiplaces, $nb_wikiplace_pages, $diskspace, $when); foreach ($plans as $plan) { $wpp_name = $plan->getName(); $price = $plan->getPrice(); $formDescriptor['Plan']['options'][wfMessage('wp-plan-desc-short', wfMessage('wpp-' . $wpp_name)->text(), $price['amount'])->text()] = $plan->getId(); } // add "do not renew" at the end; $formDescriptor['Plan']['options'][wfMessage('wp-do-not-renew')->text()] = '0'; $htmlForm = new HTMLFormS($formDescriptor); $htmlForm->setMessagePrefix('wp'); $htmlForm->addHeaderText(wfMessage('wp-sub-renew-header')->parse()); $htmlForm->setTitle($this->getTitleFor(self::TITLE_NAME, self::ACTION_RENEW)); $htmlForm->setSubmitCallback(array($this, 'processRenew')); $htmlForm->setSubmitText(wfMessage('wp-plan-renew-go')->text()); // validate and process the form is data sent if ($htmlForm->show()) { $this->action = self::ACTION_LIST; $this->msgKey = 'wp-renew-success'; $this->msgType = 'success'; $this->display(); } }
/** * * @return \HTMLFormS */ private function getInviteForm() { $user = $this->getUser(); $signature = $user->getRealName() == '' ? $user->getName() : $user->getRealName(); $formDesc = array('Category' => array('type' => 'select', 'label-message' => 'wp-inv-category-field', 'section' => 'create-section', 'help-message' => 'wp-inv-category-help', 'options' => array()), 'Email' => array('type' => 'text', 'label-message' => 'emailto', 'section' => 'mail-section', 'help-message' => 'wp-inv-email-help', 'validation-callback' => array($this, 'validateEmail')), 'Message' => array('type' => 'textarea', 'label-message' => 'emailmessage', 'section' => 'mail-section', 'help-message' => 'wp-inv-msg-help', 'default' => wfMessage('wp-inv-msg-default', $signature)->text(), 'validation-callback' => array($this, 'validateMessage'), 'rows' => 4), 'Language' => array('type' => 'select', 'label-message' => 'wp-inv-language-field', 'section' => 'mail-section', 'help-message' => 'wp-inv-language-help', 'options' => array())); global $wgLanguageSelectorLanguagesShorthand; $language = $this->getLanguage(); foreach ($wgLanguageSelectorLanguagesShorthand as $ln) { $formDesc['Language']['options'][$language->getLanguageName($ln)] = $ln; if ($ln == $language->getCode()) { $formDesc['Language']['default'] = $ln; } } if ($this->userIsAdmin) { $formDesc['Code'] = array('type' => 'text', 'label-message' => 'wp-inv-code-field', 'help-message' => 'wp-inv-code-help', 'section' => 'admin-section', 'default' => WpInvitation::generateCode($this->getUser()), 'validation-callback' => array($this, 'validateCode'), 'filter-callback' => array($this, 'filterCode')); $formDesc['Counter'] = array('type' => 'text', 'label-message' => 'wp-inv-counter-field', 'section' => 'admin-section', 'help-message' => 'wp-inv-counter-help', 'default' => 1, 'validation-callback' => array($this, 'validateCounter')); foreach ($this->userInvitationsCategories as $category_id => $category) { $formDesc['Category']['options'][wfMessage('wpi-' . $category->getDescription())->text()] = $category_id; if ($this->category_id == $category_id) { $formDesc['Category']['default'] = $category_id; } } } else { foreach ($this->userUsageLeftThisMonth as $category_id => $usageLeft) { $formDesc['Category']['options'][wfMessage('wp-inv-category-desc', wfMessage('wpi-' . $this->userInvitationsCategories[$category_id]->getDescription())->text(), $usageLeft, $this->userInvitationsCategories[$category_id]->getMonthlyLimit())->parse()] = $category_id; if ($this->category_id == $category_id) { $formDesc['Category']['default'] = $category_id; } } } $htmlForm = new HTMLFormS($formDesc); $htmlForm->setMessagePrefix('wp-inv'); $htmlForm->addHeaderText(wfMessage('wp-inv-create-header')->parse()); $htmlForm->setTitle($this->getTitle(self::ACTION_CREATE)); $htmlForm->setSubmitText(wfMessage('wp-create')->text()); $htmlForm->setSubmitCallback(array($this, 'processInvite')); return $htmlForm; }