示例#1
0
 function PrepaidSignupForm()
 {
     $cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
     $monthArray = array();
     for ($i = 1; $i <= 12; $i++) {
         $monthArray[$i] = date('F', mktime(0, 0, 0, $i));
     }
     $yearArray = array();
     $currentYear = date('Y');
     for ($i = 0; $i <= 10; $i++) {
         $yearArray[$currentYear + $i] = $currentYear + $i;
     }
     $trialExpiryDate = date('F-j-Y', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
     $price = Product::get()->byID(7)->Price;
     $shoppingCart = $this->renderWith('PrepaidShoppingCart', array('Price' => $price));
     $whatsThis = '<span id="WhatsThis"><a id="WhatsThisImage" href="themes/attwiz/images/cvv.jpg" title="What\'s this?">What\'s this?</a></span>';
     $fields = new FieldList(new LiteralField('SignupTitle', '<h2>Create Your Account</h2>'), new EmailField('Email', 'Email'), new ConfirmedPasswordField('Password', 'Password'), new LiteralField('BillingInfoTitle', '<h2>Billing Information</h2>'), new TextField('FirstName', 'First Name'), new TextField('LastName', 'Last Name'), new TextField('Company', 'Company(optional)'), new TextField('StreetAddress1', 'Street Address1'), new TextField('StreetAddress2', 'Street Address2(optional)'), new TextField('City', 'City'), new TextField('State', 'State/Province'), new TextField('PostalCode', 'Zip/Poatal Code'), new CountryDropdownField('Country'), new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, 'visa'), new TextField('NameOnCard', 'Name On Card'), new TextField('CreditCardNumber', 'Credit Card Number'), new PasswordField('CVVCode', 'Security/CVV Code'), new LiteralField('WhatIsThis', $whatsThis), new DropdownField('ExpirationMonth', 'Expiration Date', $monthArray), new DropdownField('ExpirationYear', '', $yearArray), new LiteralField('ShoppingCart', $shoppingCart), new HiddenField('Price', '', $price), new HiddenField('Quantity', '', 1));
     // Create action
     $actions = new FieldList($submit = new FormAction('doPrepaidSignup', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_purchase.png');
     // Create action
     $validator = new RequiredFields('Email', 'Password', 'FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'OrderTotal');
     $validator = null;
     return new Form($this, 'PrepaidSignupForm', $fields, $actions, $validator);
 }
 public function testGetField()
 {
     $formAction = new FormAction('test');
     $this->assertContains('type="submit"', $formAction->getAttributesHTML());
     $formAction->setAttribute('src', 'file.png');
     $this->assertContains('type="image"', $formAction->getAttributesHTML());
 }
 function MemberNonExpiringHeatmapsForm()
 {
     // Get current member
     $member = Member::currentUser();
     $isContactID = $member->ISContactID;
     $subscription = $this->getCurrentSubscription($member->ID);
     switch ($subscription->Product()->ID) {
         case 1:
             $productID = 4;
             break;
         case 2:
             $productID = 5;
             break;
         case 3:
             $productID = 6;
             break;
     }
     $price = Product::get()->byID($productID)->Price;
     $shoppingCart = $this->renderWith('PrepaidShoppingCart', array('Price' => $price));
     // Get existing credit card ID
     $creditCard = $this->getCurrentCreditCard($member->ID);
     if (!$creditCard) {
         $this->setMessage('Error', 'Please update your credit card first.');
         return $this->redirect('/account-settings/#tabs-2');
     }
     $fields = new FieldList(new HiddenField('FirstName', 'First Name', $member->FirstName), new HiddenField('LastName', 'Last Name', $member->Surname), new HiddenField('Company', 'Company(optional)', $creditCard->Company), new HiddenField('StreetAddress1', 'Street Address1', $creditCard->StreetAddress1), new HiddenField('StreetAddress2', 'Street Address2(optional)', $creditCard->StreetAddress2), new HiddenField('City', 'City', $creditCard->City), new HiddenField('State', 'State/Province', $creditCard->State), new HiddenField('PostalCode', 'Zip/Poatal Code', $creditCard->PostalCode), new HiddenField('Country', 'Country', $creditCard->Country), new HiddenField('CreditCardType', 'Credit Card Type', $creditCard->CreditCardType), new HiddenField('NameOnCard', 'Name On Card', $creditCard->NameOnCard), new HiddenField('CreditCardNumber', 'Credit Card Number', $creditCard->CreditCardNumber), new HiddenField('CVVCode', 'Security/CVV Code', $creditCard->CreditCardCVV), new HiddenField('ExpirationMonth', 'Expiration Date', $creditCard->ExpiryMonth), new HiddenField('ExpirationYear', '', $creditCard->ExpiryYear), new LiteralField('ShoppingCart', $shoppingCart), new HiddenField('ProductID', '', $productID), new HiddenField('Price', '', $price), new HiddenField('Quantity', '', 1));
     // Create action
     $actions = new FieldList($submit = new FormAction('doPurchase', 'Purchase Heatmaps'));
     $submit->setAttribute('src', 'themes/attwiz/images/button_purchase.png');
     // Create action
     $validator = new RequiredFields('FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear');
     return new Form($this, 'MemberNonExpiringHeatmapsForm', $fields, $actions, $validator);
 }
示例#4
0
 function TrialSignupForm()
 {
     $cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
     $monthArray = array();
     for ($i = 1; $i <= 12; $i++) {
         $monthArray[$i] = date('F', mktime(0, 0, 0, $i));
     }
     $yearArray = array();
     $currentYear = date('Y');
     for ($i = 0; $i <= 10; $i++) {
         $yearArray[$currentYear + $i] = $currentYear + $i;
     }
     $trialExpiryDate = date('F-j-Y', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
     $subscriptionInfo = "<div id='SubscriptionInfo'><h2>Post-Trial Subscription Selection</h2>\n\t    <p>Your 10 heatmaps will expire on {$trialExpiryDate}, at which time your account \n\t    will be replenished with a new allocation of heatmap credits according to the \n\t    subscription level you choose below. You may cancel your subscription any time \n\t    before your trial period ends and your  credit card will only be charged 1 dollar.</p></div>";
     $subscriptionType = array("1" => "Bronze - (10 heatmaps for \$27.00 / month)", "2" => "Silver - (50 heatmaps for \$97.00 / month)", "3" => "Gold - (200 heatmaps for \$197.00 / month)");
     $whatsThis = '<span id="WhatsThis"><a id="WhatsThisImage" href="themes/attwiz/images/cvv.jpg" title="What\'s this?">What\'s this?</a></span>';
     $fields = new FieldList(new TextField('FirstName', 'First Name'), new TextField('LastName', 'Last Name'), new TextField('Company', 'Company(optional)'), new TextField('StreetAddress1', 'Street Address1'), new TextField('StreetAddress2', 'Street Address2(optional)'), new TextField('City', 'City'), new TextField('State', 'State/Province'), new TextField('PostalCode', 'Zip/Poatal Code'), new CountryDropdownField('Country'), new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, 'visa'), new TextField('NameOnCard', 'Name On Card'), new NumericField('CreditCardNumber', 'Credit Card Number'), new PasswordField('CVVCode', 'Security/CVV Code'), new LiteralField('WhatIsThis', $whatsThis), new DropdownField('ExpirationMonth', 'Expiration Date', $monthArray), new DropdownField('ExpirationYear', '', $yearArray), new LiteralField('SubscriptionInfo', $subscriptionInfo), new OptionsetField('SubscriptionType', '', $subscriptionType, '1'), new CheckboxField('Agreement', ' I understand that this is a recurring subscription and I will be billed monthly unless I cancel.'));
     // Create action
     $actions = new FieldList($submit = new FormAction('doSignup', 'Start Trial'));
     $submit->setAttribute('src', 'themes/attwiz/images/button_startmytrialnow.gif');
     // Create action
     $validator = new RequiredFields('FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'SubscriptionInfo', 'SubscriptionType');
     $validator = null;
     $form = new Form($this, 'TrialSignupForm', $fields, $actions, $validator);
     $data = Session::get("FormInfo.Form_TrialSignupForm.data");
     if (is_array($data)) {
         $form->loadDataFrom($data);
     }
     return $form;
 }
 /**
  * This form is exactly like the CMS form.  It gives us an opportunity to test the fields outside of the CMS context
  */
 function Form()
 {
     $fields = $this->getCMSFields();
     $actions = new FieldList(new FormAction("save", "Save"), $gohome = new FormAction("gohome", "Go home"));
     $gohome->setAttribute('src', 'frameworktest/images/test-button.png');
     $form = new Form($this, "Form", $fields, $actions);
     $form->loadDataFrom($this->dataRecord);
     return $form;
 }
示例#6
0
 function RegistrationForm()
 {
     $fields = new FieldList(new EmailField('Email', 'Email'), new ConfirmedPasswordField('Password', 'Password'), new CheckboxField('Terms', 'I agree to the <a href="/customer-login/terms-of-use/" target="_blank">AttentionWizard Terms of Use</a>', 1));
     // Create action
     $actions = new FieldList($submit = new FormAction('doRegister', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_continue.gif');
     // Create action
     $validator = new RequiredFields('Email', 'Password');
     $form = new Form($this, 'RegistrationForm', $fields, $actions);
     //$form->setTemplate('RegistrationForm');
     return $form;
 }
示例#7
0
    function CancelSubscriptionForm()
    {
        $reasons = array("I didn't use the product as much as I anticipated" => "I didn't use the product as much as I anticipated", "The cost was too high" => "The cost was too high", "I had technical problems generating heatmaps" => "I had technical problems generating heatmaps", "I have changed jobs/careers" => "I have changed jobs/careers", "I had problems with customer service" => "I had problems with customer service", "I didn't find the heatmaps helpful" => "I didn't find the heatmaps helpful", "Other (you may contact us support@attentionwizard.com with additional feedback)" => "Other (you may contact us support@attentionwizard.com with additional feedback)");
        $info = '<p>Please remember, you can continue to purchase non-expiring heatmaps and access your heatmap inventory. Your account will remain open and available to you even after your subscription is cancelled.</p>
				<p>&nbsp;</p>
<p style="font-style:italic;">Note: accounts with no activity for a 60-day period may be closed, and heatmaps associated with the account purged.If you wish to completely close your account please email <a href="mailto:support@attentionwizard.com">support@attentionwizard.com</a></p>
				';
        $fields = new FieldList(new CheckboxSetField('Reasons', '', $reasons), new LiteralField('Info', $info));
        // Create action
        $actions = new FieldList($submit = new FormAction('cancelSubscription', ''));
        $submit->setAttribute('src', 'themes/attwiz/images/button_cancel_sub.png');
        // Create action
        $validator = new RequiredFields('Reasons');
        return new Form($this, 'CancelSubscriptionForm', $fields, $actions, $validator);
    }
示例#8
0
 public function CreateHeatmapForm()
 {
     $includeWatermark = array("1" => "Yes,Include Watermark", "0" => "No,Remove Watermark");
     $fields = new FieldList($imageField = new FileField('OriginalImage', 'Upload an Image File'), new LiteralField('UploadInfo', 'Acceptable images are jpg or png, 500-1600 pixels wide by 500-1200 pixels height.<hr>'), new OptionsetField('IncludeWatermark', 'Include Watermark?', $includeWatermark, 1));
     $imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
     $imageField->setAttribute('class', 'jfilestyle');
     $imageField->setAttribute('data-buttonText', "<img src='themes/attwiz/images/button-create-heatmap-browse.jpg'></img>");
     $imageField->setAttribute('data-placeholder', 'No file selected..');
     // Create action
     $actions = new FieldList($submit = new FormAction('processCreateHeatmap', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button-create-heatmap-blue-bg.jpg');
     // Create action
     $validator = new RequiredFields('OriginalImage', 'IncludeWatermark');
     return new Form($this, 'CreateHeatmapForm', $fields, $actions, $validator);
 }
示例#9
0
 function EditProfileForm()
 {
     //Create our fields
     $fields = new FieldList(new TextField('FirstName', 'First Name'), new TextField('Surname', 'Last Name'), new TextField('Email', 'Email'), new ConfirmedPasswordField('Password', 'New Password'));
     // Create action
     $actions = new FieldList($saveProfileAction = new FormAction('SaveProfile', ''));
     $saveProfileAction->setAttribute('src', 'themes/attwiz/images/button_submit.gif');
     // Create action
     $validator = new RequiredFields('FirstName', 'Surname', 'Email');
     $validator = null;
     //Create form
     $Form = new Form($this, 'EditProfileForm', $fields, $actions, $validator);
     //Populate the form with the current members data
     $Member = Member::currentUser();
     $Form->loadDataFrom($Member->data());
     //Return the form
     return $Form;
 }
示例#10
0
 function ContactUsForm()
 {
     $name = null;
     $email = null;
     $member = Member::currentUser();
     if ($member) {
         $name = $member->Name;
         $email = $member->Email;
     }
     $fields = new FieldList(new TextField('Name', 'Name<span>(*)</span>', $name), new TextField('Email', 'Email<span>(*)</span>', $email), new TextField('Phone', 'Phone'), new TextField('Topic', 'Subject<span>(*)</span>'), $message = new TextareaField('Message', 'Message<span>(*)</span>'), new LiteralField('MessageLimit', '<span style="font-size:9px;margin-left:143px;position:relative;top:-15px;">Enter not more than 500 characters.</span>'), new RecaptchaField('MyCaptcha'));
     $message->setAttribute('maxlength', '500');
     // Create action
     $actions = new FieldList($submit = new FormAction('doContact', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_send.gif');
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Topic', 'Message');
     $validator = null;
     return new Form($this, 'ContactUsForm', $fields, $actions, $validator);
 }
 public function updateCMSActions(FieldList $actions)
 {
     $active = $this->workflowService->getWorkflowFor($this->owner);
     if (Controller::curr() && Controller::curr()->hasExtension('AdvancedWorkflowExtension')) {
         if ($active) {
             if ($this->canEditWorkflow()) {
                 $action = new FormAction('updateworkflow', $active->CurrentAction() ? $active->CurrentAction()->Title : _t('WorkflowApplicable.UPDATE_WORKFLOW', 'Update Workflow'));
                 $action->setAttribute('data-icon', 'navigation');
                 $actions->push($action);
             }
         } else {
             $effective = $this->workflowService->getDefinitionFor($this->owner);
             if ($effective && $effective->getInitialAction()) {
                 // we can add an action for starting off the workflow at least
                 $action = new FormAction('startworkflow', $effective->getInitialAction()->Title);
                 $action->setAttribute('data-icon', 'navigation');
                 $actions->push($action);
             }
         }
     }
 }
 /**
  * @param ISurveyStep $step
  * @param string $action
  * @param string $form_name
  * @return Form
  */
 public function build(ISurveyStep $step, $action, $form_name = 'SurveyStepForm')
 {
     $form = parent::build($step, $action, $form_name);
     $entity_survey = $step->survey();
     if ($entity_survey instanceof IEntitySurvey) {
         $fields = $form->Fields();
         $first = $fields->first();
         if ($entity_survey->isTeamEditionAllowed() && $entity_survey->createdBy()->getIdentifier() === Member::currentUserID() && $entity_survey->isFirstStep()) {
             $fields->insertBefore($team_field = new EntitySurveyEditorTeamField('EditorTeam', '', $entity_survey), $first->getName());
             $team_field->setForm($form);
             $first = $team_field;
         }
         $edition_info_panel = '<div class="container editor-info-panel"><div class="row">Created by <b>' . $entity_survey->createdBy()->getEmail() . '</b></div>';
         $edition_info_panel .= '<div class="row">Edited by <b>' . $entity_survey->EditedBy()->getEmail() . '</b></div></div>';
         $fields->insertBefore(new LiteralField('owner_label', $edition_info_panel), $first->getName());
         $previous_step = $entity_survey->getPreviousStep($step->template()->title());
         if (!is_null($previous_step)) {
             $request = Controller::curr()->getRequest();
             $step = $request->param('STEP_SLUG');
             if (empty($step)) {
                 $step = $request->requestVar('STEP_SLUG');
             }
             if (empty($step)) {
                 throw new LogicException('step empty! - member_id %s', Member::currentUserID());
             }
             $entity_survey_id = intval($request->param('ENTITY_SURVEY_ID'));
             $prev_step_url = Controller::join_links(Director::absoluteBaseURL(), Controller::curr()->Link(), $step, 'edit', $entity_survey_id, $previous_step->template()->title());
             // add prev button
             $actions = $form->Actions();
             $btn = $actions->offsetGet(0);
             $actions->insertBefore($prev_action = new FormAction('PrevStep', 'Prev Step'), $btn->name);
             $prev_action->addExtraClass('entity-survey-prev-action');
             $prev_action->setAttribute('data-prev-url', $prev_step_url);
         }
     }
     return $form;
 }
 public function Form()
 {
     $form = parent::Form();
     if (!$form) {
         return;
     }
     if ($this->ShowButtonsOnTop) {
         $form->ShowButtonsOnTop = true;
     }
     $form->setTemplate('EditableUserDefinedFormControl');
     // now add an action for "Save"
     $fields = $form->Fields();
     // first, lets add any custom Note text that is needed
     foreach ($this->Fields() as $editableField) {
         if ($editableField instanceof EditableFileField) {
             $fields->removeByName($editableField->Name);
             continue;
         }
         $formField = $fields->fieldByName($editableField->Name);
         if ($formField && $editableField->getSetting('Note')) {
             $title = $formField->Title() . '<span class="userformFieldNote">' . Convert::raw2xml($editableField->getSetting('Note')) . '</span>';
             $formField->setTitle($title);
         }
     }
     // lets see if there's a submission that we should be loading into the form
     if ($this->submission && $this->submission->ID) {
         $this->submission->exposeDataFields();
         $form->loadDataFrom($this->submission);
         $fields->push(new HiddenField('ResumeID', '', $this->submission->ID));
         $workflowState = $this->submission->getWorkflowState();
         if ($workflowState !== false) {
             $form->addExtraClass("workflow-review");
             if ($workflowState == 'Readonly') {
                 $fields->unshift(LiteralField::create('workflow_warning', '<p class="message warning">Currently under review</p>'));
                 $this->readonly = true;
             } else {
                 $fields->unshift(LiteralField::create('workflow_warning', '<p class="message warning">Review via ' . Convert::raw2xml($workflowState) . ' </p>'));
             }
         }
     }
     if ($this->readonly) {
         $form->makeReadonly();
     }
     $actions = $form->Actions();
     if (!$this->ShowSubmitButton) {
         $actions->removeByName('action_process');
     } else {
         if (strlen($this->SubmitWarning)) {
             $submitName = $actions->fieldByName('action_process');
             $submitName->setAttribute('data-submitwarning', Convert::raw2att($this->SubmitWarning));
             $submitName->addExtraClass('submitwarning');
         }
     }
     if (!$this->readonly) {
         if (Member::currentUserID()) {
             $actions->push($action = new FormAction('storesubmission', 'Save'));
             $action->setAttribute('formnovalidate', 'formnovalidate');
             // $actions->push(new FormAction('cancelsubmission', 'Cancel', null, null, 'cancel'));
             if ($this->ShowPreviewButton) {
                 $actions->push($action = new FormAction('previewsubmission', 'Preview'));
                 $action->setAttribute('formnovalidate', 'formnovalidate');
                 $actions->push($action = new FormAction('previewpdfsubmission', 'PDF / Print'));
                 $action->setAttribute('formnovalidate', 'formnovalidate');
             }
             if ($this->submission && $this->ShowDeleteButton) {
                 $actions->push($action = new FormAction('cancelsubmission', 'Delete'));
                 $action->setAttribute('formnovalidate', 'formnovalidate');
             }
         }
     } else {
         $form->setActions(ArrayList::create());
     }
     if ($this->submission && $this->readonly) {
         $actions->push(new LiteralField("PrintLink", '<a class="editableFormPDFLink" href="' . $this->submission->PDFLink() . '">Download PDF</a>'));
     }
     // finally - we want to check if this request is trying to do an action that doesn't care about validation.
     // IF we are, then we want to clear the validation for this form
     if (!isset($_REQUEST['action_process'])) {
         $form->unsetValidator();
     }
     return $form;
 }
示例#14
0
    /**
     * @return FieldList
     */
    public function getCMSFields()
    {
        $fields = new FieldList(new TabSet('Root'));
        $project = $this->Project();
        if ($project && $project->exists()) {
            $viewerGroups = $project->Viewers();
            $groups = $viewerGroups->sort('Title')->map()->toArray();
            $members = array();
            foreach ($viewerGroups as $group) {
                foreach ($group->Members()->map() as $k => $v) {
                    $members[$k] = $v;
                }
            }
            asort($members);
        } else {
            $groups = array();
            $members = array();
        }
        // Main tab
        $fields->addFieldsToTab('Root.Main', array(TextField::create('ProjectName', 'Project')->setValue(($project = $this->Project()) ? $project->Name : null)->performReadonlyTransformation(), TextField::create('Name', 'Environment name')->setDescription('A descriptive name for this environment, e.g. staging, uat, production'), $this->obj('Usage')->scaffoldFormField('Environment usage'), TextField::create('URL', 'Server URL')->setDescription('This url will be used to provide the front-end with a link to this environment'), TextField::create('Filename')->setDescription('The capistrano environment file name')->performReadonlyTransformation()));
        // Backend identifier - pick from a named list of configurations specified in YML config
        $backends = $this->config()->get('allowed_backends', Config::FIRST_SET);
        // If there's only 1 backend, then user selection isn't needed
        if (sizeof($backends) > 1) {
            $fields->addFieldToTab('Root.Main', DropdownField::create('BackendIdentifier', 'Deployment backend')->setSource($backends)->setDescription('What kind of deployment system should be used to deploy to this environment'));
        }
        $fields->addFieldsToTab('Root.UserPermissions', array($this->buildPermissionField('ViewerGroups', 'Viewers', $groups, $members)->setTitle('Who can view this environment?')->setDescription('Groups or Users who can view this environment'), $this->buildPermissionField('DeployerGroups', 'Deployers', $groups, $members)->setTitle('Who can deploy?')->setDescription('Groups or Users who can deploy to this environment'), $this->buildPermissionField('TickAllSnapshotGroups', 'TickAllSnapshot', $groups, $members)->setTitle("<em>All snapshot permissions</em>")->addExtraClass('tickall')->setDescription('UI shortcut to select all snapshot-related options - not written to the database.'), $this->buildPermissionField('CanRestoreGroups', 'CanRestoreMembers', $groups, $members)->setTitle('Who can restore?')->setDescription('Groups or Users who can restore archives from Deploynaut into this environment'), $this->buildPermissionField('CanBackupGroups', 'CanBackupMembers', $groups, $members)->setTitle('Who can backup?')->setDescription('Groups or Users who can backup archives from this environment into Deploynaut'), $this->buildPermissionField('ArchiveDeleterGroups', 'ArchiveDeleters', $groups, $members)->setTitle('Who can delete?')->setDescription("Groups or Users who can delete archives from this environment's staging area."), $this->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members)->setTitle('Who can upload?')->setDescription('Users who can upload archives linked to this environment into Deploynaut.<br />' . 'Linking them to an environment allows limiting download permissions (see below).'), $this->buildPermissionField('ArchiveDownloaderGroups', 'ArchiveDownloaders', $groups, $members)->setTitle('Who can download?')->setDescription(<<<PHP
Users who can download archives from this environment to their computer.<br />
Since this implies access to the snapshot, it is also a prerequisite for restores
to other environments, alongside the "Who can restore" permission.<br>
Should include all users with upload permissions, otherwise they can't download
their own uploads.
PHP
), $this->buildPermissionField('PipelineApproverGroups', 'PipelineApprovers', $groups, $members)->setTitle('Who can approve pipelines?')->setDescription('Users who can approve waiting deployment pipelines.'), $this->buildPermissionField('PipelineCancellerGroups', 'PipelineCancellers', $groups, $members)->setTitle('Who can cancel pipelines?')->setDescription('Users who can cancel in-progess deployment pipelines.')));
        // The Main.DeployConfig
        if ($this->Project()->exists()) {
            $this->setDeployConfigurationFields($fields);
        }
        // The DataArchives
        $dataArchiveConfig = GridFieldConfig_RecordViewer::create();
        $dataArchiveConfig->removeComponentsByType('GridFieldAddNewButton');
        if (class_exists('GridFieldBulkManager')) {
            $dataArchiveConfig->addComponent(new GridFieldBulkManager());
        }
        $dataArchive = GridField::create('DataArchives', 'Data Archives', $this->DataArchives(), $dataArchiveConfig);
        $fields->addFieldToTab('Root.DataArchive', $dataArchive);
        // Pipeline templates
        $this->setPipelineConfigurationFields($fields);
        // Pipelines
        if ($this->Pipelines()->Count()) {
            $pipelinesConfig = GridFieldConfig_RecordEditor::create();
            $pipelinesConfig->removeComponentsByType('GridFieldAddNewButton');
            if (class_exists('GridFieldBulkManager')) {
                $pipelinesConfig->addComponent(new GridFieldBulkManager());
            }
            $pipelines = GridField::create('Pipelines', 'Pipelines', $this->Pipelines(), $pipelinesConfig);
            $fields->addFieldToTab('Root.Pipelines', $pipelines);
        }
        // Deployments
        $deploymentsConfig = GridFieldConfig_RecordEditor::create();
        $deploymentsConfig->removeComponentsByType('GridFieldAddNewButton');
        if (class_exists('GridFieldBulkManager')) {
            $deploymentsConfig->addComponent(new GridFieldBulkManager());
        }
        $deployments = GridField::create('Deployments', 'Deployments', $this->Deployments(), $deploymentsConfig);
        $fields->addFieldToTab('Root.Deployments', $deployments);
        Requirements::javascript('deploynaut/javascript/environment.js');
        // Add actions
        $action = new FormAction('check', 'Check Connection');
        $action->setUseButtonTag(true);
        $dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping';
        $action->setAttribute('data-url', $dataURL);
        $fields->insertBefore($action, 'Name');
        // Allow extensions
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
示例#15
0
 /**
  * Form for collecting gateway data.
  */
 public function GatewayDataForm()
 {
     $payment = $this->getCurrentPayment();
     if (!$payment) {
         //redirect if there is no payment object available
         return $this->redirect($this->Link());
     }
     $factory = new GatewayFieldsFactory($payment->Gateway);
     $fields = $factory->getFields();
     //TODO: never let CC details be stored in session (e.g. validation)
     //TODO: force requirement of SSL on live sites
     $actions = new FieldList($cancelaction = new FormAction("cancel", _t("PaymentController.DIFFERENTMETHOD", "Choose Different Method")), $payaction = new FormAction("pay", _t("PaymentController.DIFFERENTMETHOD", "Make Payment")));
     $cancelaction->setAttribute("formnovalidate", "formnovalidate");
     $validator = new RequiredFields(GatewayInfo::required_fields($payment->Gateway));
     $form = new Form($this, "GatewayDataForm", $fields, $actions, $validator);
     $this->extend('updateGatewayDataForm', $form);
     //allow cancel action to run without validation
     if (!empty($_REQUEST['action_cancel'])) {
         $form->unsetValidator();
     }
     return $form;
 }
示例#16
0
 public function __construct($controller, $name)
 {
     $member = Member::currentUser();
     $isConID = $member->ISContactID;
     //Get the member current credit card
     $creditCard = Controller::curr()->getCurrentCreditCard($member->ID);
     //Get InfusionSoft Api
     //$app = Controller::curr()->getInfusionSoftApi();
     //$returnFields = array('FirstName','LastName','Company','StreetAddress1','StreetAddress2','City','State','PostalCode','Country');
     //$conDat = $app->loadCon($isConID, $returnFields);
     $cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
     $monthArray = array();
     for ($i = 1; $i <= 12; $i++) {
         $monthArray[$i] = date('F', mktime(0, 0, 0, $i));
     }
     $yearArray = array();
     $currentYear = date('Y');
     for ($i = 0; $i <= 10; $i++) {
         $yearArray[$currentYear + $i] = $currentYear + $i;
     }
     if ($creditCard) {
         $yearArray[$creditCard->ExpiryYear] = $creditCard->ExpiryYear;
     }
     // Format and hide the credit card number
     $creditCardLast4 = '';
     if ($creditCard) {
         $creditCardLast4 = substr($creditCard->CreditCardNumber, -4);
     }
     $creditCardMask = "XXXX-XXXX-XXXX-{$creditCardLast4}";
     $fields = new FieldList(new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, $creditCard ? $creditCard->CreditCardType : ''), new TextField('NameOnCard', 'Name On Card', $creditCard ? $creditCard->NameOnCard : ''), new TextField('CreditCardNumber', 'Credit Card Number', $creditCardMask), new HiddenField('CreditCardNumberCopy', null, $creditCardMask), new HiddenField('CreditCardNumberCur', null, $creditCard ? $creditCard->CreditCardNumber : ''), new PasswordField('CreditCardCVV', 'Security/CVV Code', $creditCard ? $creditCard->CreditCardCVV : ''), new DropdownField('ExpiryMonth', 'Expiry Date', $monthArray, $creditCard ? $creditCard->ExpiryMonth : null), new DropdownField('ExpiryYear', '', $yearArray, $creditCard ? $creditCard->ExpiryYear : null), new TextField('FirstName', 'First Name', $member->FirstName), new TextField('LastName', 'Last Name', $member->Surname), new TextField('Company', 'Company(optional)', $creditCard ? $creditCard->Company : ''), new TextField('StreetAddress1', 'Street Address1', $creditCard ? $creditCard->StreetAddress1 : ''), new TextField('StreetAddress2', 'Street Address2(optional)', $creditCard ? $creditCard->StreetAddress2 : ''), new TextField('City', 'City', $creditCard ? $creditCard->City : ''), new TextField('State', 'State', $creditCard ? $creditCard->State : ''), new TextField('PostalCode', 'Zip/Postal Code', $creditCard ? $creditCard->PostalCode : ''), new CountryDropdownField('Country', null, null, $creditCard ? $creditCard->Country : null));
     // Create action
     $actions = new FieldList($submit = new FormAction('UpdateBillingAddress', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_update_billing.png');
     // Create action
     $validator = new RequiredFields('CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PostalCode', 'Country');
     $validator = null;
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
示例#17
0
 /**
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $members = array();
     foreach ($this->Project()->Viewers() as $group) {
         foreach ($group->Members()->map() as $k => $v) {
             $members[$k] = $v;
         }
     }
     asort($members);
     $fields->fieldByName("Root")->removeByName("Deployers");
     $fields->fieldByName("Root")->removeByName("CanRestoreMembers");
     $fields->fieldByName("Root")->removeByName("CanBackupMembers");
     $fields->fieldByName("Root")->removeByName("ArchiveUploaders");
     $fields->fieldByName("Root")->removeByName("ArchiveDownloaders");
     $fields->fieldByName("Root")->removeByName("ArchiveDeleters");
     // The Main.ProjectID
     $projectField = $fields->fieldByName('Root.Main.ProjectID')->performReadonlyTransformation();
     $fields->insertBefore($projectField, 'Name');
     // The Main.Name
     $nameField = $fields->fieldByName('Root.Main.Name');
     $nameField->setTitle('Environment name');
     $nameField->setDescription('A descriptive name for this environment, e.g. staging, uat, production');
     $fields->insertAfter($nameField, 'ProjectID');
     // The Main.Filename
     $fileNameField = $fields->fieldByName('Root.Main.Filename')->performReadonlyTransformation();
     $fileNameField->setTitle('Filename');
     $fileNameField->setDescription('The capistrano environment file name');
     $fields->insertAfter($fileNameField, 'Name');
     // The Main.Deployers
     $deployers = new CheckboxSetField("Deployers", "Who can deploy?", $members);
     $deployers->setDescription('Users who can deploy to this environment');
     $fields->insertAfter($deployers, 'URL');
     // A box to tick all snapshot boxes.
     $tickAll = new CheckboxSetField("TickAllSnapshot", "<em>All snapshot permissions</em>", $members);
     $tickAll->setDescription('UI shortcut to tick all snapshot-related boxes - not written to the database.');
     $fields->insertAfter($tickAll, 'Deployers');
     // The Main.CanRestoreMembers
     $canRestoreMembers = new CheckboxSetField('CanRestoreMembers', 'Who can restore?', $members);
     $canRestoreMembers->setDescription('Users who can restore archives from Deploynaut into this environment');
     $fields->insertAfter($canRestoreMembers, 'TickAllSnapshot');
     // The Main.CanBackupMembers
     $canBackupMembers = new CheckboxSetField('CanBackupMembers', 'Who can backup?', $members);
     $canBackupMembers->setDescription('Users who can backup archives from this environment into Deploynaut');
     $fields->insertAfter($canBackupMembers, 'CanRestoreMembers');
     // The Main.ArchiveDeleters
     $archiveDeleters = new CheckboxSetField('ArchiveDeleters', 'Who can delete?', $members);
     $archiveDeleters->setDescription('Users who can delete archives from this environment\'s staging area.');
     $fields->insertAfter($archiveDeleters, 'CanBackupMembers');
     // The Main.ArchiveUploaders
     $archiveUploaders = new CheckboxSetField('ArchiveUploaders', 'Who can upload?', $members);
     $archiveUploaders->setDescription('Users who can upload archives linked to this environment into Deploynaut.<br>' . 'Linking them to an environment allows limiting download permissions (see below).');
     $fields->insertAfter($archiveUploaders, 'ArchiveDeleters');
     // The Main.ArchiveDownloaders
     $archiveDownloaders = new CheckboxSetField('ArchiveDownloaders', 'Who can download?', $members);
     $archiveDownloaders->setDescription('Users who can download archives from this environment to their computer.<br>' . 'Since this implies access to the snapshot, it is also a prerequisite for restores to other environments,' . ' alongside the "Who can restore" permission.<br>' . 'Should include all users with upload permissions, otherwise they can\'t download their own uploads.');
     $fields->insertAfter($archiveDownloaders, 'ArchiveUploaders');
     // The Main.DeployConfig
     if ($this->Project()->exists()) {
         $this->setDeployConfigurationFields($fields);
     }
     // The Main.URL field
     $urlField = $fields->fieldByName('Root.Main.URL');
     $urlField->setTitle('Server URL');
     $fields->removeByName('Root.Main.URL');
     $urlField->setDescription('This url will be used to provide the front-end with a link to this environment');
     $fields->insertAfter($urlField, 'Name');
     // The Extra.GraphiteServers
     $graphiteServerField = $fields->fieldByName('Root.Main.GraphiteServers');
     $fields->removeByName('Root.Main.GraphiteServers');
     $graphiteServerField->setDescription('Find the relevant graphite servers at ' . '<a href="http://graphite.silverstripe.com/" target="_blank">graphite.silverstripe.com</a>' . ' and enter them one per line, e.g. "server.wgtn.oscar"');
     $fields->addFieldToTab('Root.Extra', $graphiteServerField);
     Requirements::javascript('deploynaut/javascript/environment.js');
     // Add actions
     $action = new FormAction('check', 'Check Connection');
     $action->setUseButtonTag(true);
     $action->setAttribute('data-url', Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping');
     $fields->insertBefore($action, 'Name');
     return $fields;
 }
 /**
  * Build a FieldList of the FormAction fields for the given step.
  *
  * If the current step is the final step, we push in a submit button, which
  * calls the action {@link finish()} to finalise the submission. Otherwise,
  * we push in a next button which calls the action {@link next()} to determine
  * where to go next in our step process, and save any form data collected.
  *
  * If there's a previous step (a step that has the current step as it's next
  * step class), then we allow a previous button, which calls the previous action
  * to determine which step to go back to.
  *
  * If there are any extra actions defined in MultiFormStep->getExtraActions()
  * then that set of actions is appended to the end of the actions FieldSet we
  * have created in this method.
  *
  * @param $currentStep Subclass of MultiFormStep
  * @return FieldList of FormAction objects
  */
 function actionsFor($step)
 {
     // Create default multi step actions (next, prev), and merge with extra actions, if any
     $actions = class_exists('FieldList') ? new FieldList() : new FieldSet();
     // If the form is at final step, create a submit button to perform final actions
     // The last step doesn't have a next button, so add that action to any step that isn't the final one
     if ($step->isFinalStep()) {
         $actions->push(new FormAction('finish', $step->getSubmitText()));
     } else {
         $actions->push(new FormAction('next', $step->getNextText()));
     }
     // If there is a previous step defined, add the back button
     if ($step->getPreviousStep() && $step->canGoBack()) {
         // If there is a next step, insert the action before the next action
         if ($step->getNextStep()) {
             $actions->insertBefore($prev = new FormAction('prev', $step->getPrevText()), 'action_next');
             // Assume that this is the last step, insert the action before the finish action
         } else {
             $actions->insertBefore($prev = new FormAction('prev', $step->getPrevText()), 'action_finish');
         }
         //remove browser validation from prev action
         $prev->setAttribute("formnovalidate", "formnovalidate");
     }
     // Merge any extra action fields defined on the step
     $actions->merge($step->getExtraActions());
     return $actions;
 }