forked from OpenStackweb/openstack-org
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOSLogoProgramForm.php
More file actions
153 lines (127 loc) · 6.14 KB
/
Copy pathOSLogoProgramForm.php
File metadata and controls
153 lines (127 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/**
* Copyright 2014 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
/**
* Class OsLogoProgramForm
*/
class OsLogoProgramForm extends HoneyPotForm {
function __construct($controller, $name) {
Requirements::css(THEMES_DIR . "/openstack/css/OsLogoProgramForm.css");
Requirements::customScript("
jQuery(document).ready(function() {
if($('#OsLogoProgramForm_Form_CurrentSponsor').prop('checked') != true){
$('#openstack-companies').hide();
$('#non-sponsor-company').show();
} else {
$('#openstack-companies').show();
$('#non-sponsor-company').hide();
}
$('#OsLogoProgramForm_Form_CurrentSponsor').click(function () {
$('#openstack-companies').toggle();
$('#non-sponsor-company').toggle();
});
});
");
$companies = Company::get()->filter('MemberLevel:not','Mention')->where('MemberLevel IS NOT NULL')->sort('Name','ASC');
if($companies){
$companiesField = new DropdownField('CompanyID','Company',$companies->map('ID','Name','--Select Company--'));
}
$projects = Project::get();
if($projects){
$projectsField = new CheckboxSetField('Projects','Select the OpenStack projects your product uses:',$projects->map('Name','Name'));
}
$fields = new FieldList (
new TextField('FirstName','First Name'),
new TextField('Surname','Last Name'),
new EmailField('Email','Email Address'),
new TextField('Phone','Phone Number'),
new CheckboxSetField(
'Program',
'Which logo program best fits your product offering?',
OsLogoProgramResponse::$avialable_programs
),
new LiteralField('HR','<hr/>'),
new CheckboxField('CurrentSponsor','My company is a Corporate Sponsor or Gold/Platinum Member of the OpenStack Foundation.'),
new LiteralField('DIV','<div id="openstack-companies">'),
$companiesField,
new TextField('OtherCompany','Other Company (if not listed above)'),
new LiteralField('DIV','</div>'),
new LiteralField('DIV','<div id="non-sponsor-company">'),
new TextField('NonSponsorCompany','Company Name'),
new LiteralField('DIV','</div>'),
new TextField('Product','Product or Service Name'),
new LiteralField('ProductNote','If your proposed product name includes the OpenStack word mark, it will need to be approved as part of the licensing process.<br><br>'),
new LiteralField('HR','<hr/>'),
new TextAreaField('CompanyDetails','Product or Service Description'),
new CheckboxSetField(
'Category',
'Which of the following categories does your product fit into? This will help us recommend the approprite licensing and associated marketing programs and assets:',
OsLogoProgramResponse::$avialable_categories
),
new CheckboxSetField(
'Regions',
'In which regions does your company operate?',
OsLogoProgramResponse::$avialable_regions
),
$projectsField,
new CheckboxField('APIExposed','My product exposes the OpenStack API')
);
$actionButton = new FormAction('save', 'Request Information');
$actions = new FieldList(
$actionButton
);
$validator = new RequiredFields(
'FirstName',
'Surname',
'Email',
'Phone'
);
parent::__construct($controller, $name, $fields, $actions, $validator);
}
function forTemplate() {
return $this->renderWith(array(
$this->class,
'Form'
));
}
function save($data, $form) {
$response = new OSLogoProgramResponse();
$form->saveInto($response);
// Combine these two fields so we just store a manually typed name in
// $data[OtherCompany]
if($data['NonSponsorCompany']) {
$response->OtherCompany = $data['NonSponsorCompany'];
}
$response->write();
// Now set the official company name for the email
$data['CompanyName'] = 'Not Provided';
if($response->OtherCompany) {
$response->CompanyName = $response->OtherCompany;
} elseif ($response->CompanyID != 0) {
$company = Company::get()->byID($response->CompanyID);
if($company) {
$response->CompanyName = $company->Name;
}
}
// Email the logo email list
$Subject = "Contact Form for Commercial Logo Inquiries";
$email = EmailFactory::getInstance()->buildEmail($data['Email'], OS_LOGO_PROGRAM_FORM_TO_EMAIL, $Subject);
$email->setTemplate('OSLogoProgramResponseEmail');
$email->populateTemplate($response);
$email->send();
if($response->Program === 'Powered'){
Controller::curr()->setMessage('success', 'Thanks for your interest in licensing the OpenStack Powered logo. Please review the interoperability standards at <a href="http://www.openstack.org/interop" class="alert-link">openstack.org/interop</a> page and submit test results according to the instructions.');
}
return Controller::curr()->redirect(Controller::curr()->Link("thanks"));
}
}