Skip to content

Commit 1bcc847

Browse files
committed
[spalenque] - #12930 * change sponsors model and add sponsorship type class
1 parent 98388ac commit 1bcc847

12 files changed

Lines changed: 407 additions & 328 deletions

File tree

migrations/migrations.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ migrations:
7171
- UpdateComponentReleasesMigration
7272
- GenerateComponentSlugMigration
7373
- PopulateMascotsMigration
74+
- SummitSponsorsMigration

openstack/_config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
$tinyMCE = HtmlEditorConfig::get('cms');
9797
$tinyMCE->setOption('extended_valid_elements', '@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,i,em,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align|name],address[class|align],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]');
9898

99+
$simple_tinyMCE = HtmlEditorConfig::get('simple');
100+
$simple_tinyMCE->setOption('extended_valid_elements', '@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,i,em,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align|name],address[class|align],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]');
101+
$simple_tinyMCE->disablePlugins(['table']);
102+
99103
if(defined('SERVER_TIME_ZONE')) {
100104
date_default_timezone_set(SERVER_TIME_ZONE);
101105
}

openstack/code/Company.php

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ public function getIdentifier() {
7777
private static $singular_name = 'Company';
7878
private static $plural_name = 'Companies';
7979

80-
//Administrators Security Groups
81-
private static $belongs_many_many = array(
82-
'SponsorsPages' => 'SponsorsPage'
83-
);
8480
private static $summary_fields = array(
8581
'Name' => 'Company',
8682
'MemberLevel' => 'MemberLevel'
@@ -390,81 +386,11 @@ function ShowLink()
390386
}
391387
}
392388

393-
//helper function to create Drop Down for Sponsorship type
394389
function IsExternalUrl()
395390
{
396391
return !$this->Description ? true : false;
397392
}
398393

399-
//helper function to create Drop Down for Logo Size
400-
401-
public function getInputSubmitPageUrl()
402-
{
403-
$type = null;
404-
$pageId = Convert::raw2sql($_REQUEST["PageId"]);
405-
if (isset($pageId)) {
406-
$sqlQuery = new SQLQuery();
407-
$sqlQuery->setSelect("SubmitPageUrl");
408-
$sqlQuery->setFrom("SummitSponsorPage_Companies");
409-
$sqlQuery->setWhere("CompanyID={$this->ID} AND SummitSponsorPageID={$pageId}");
410-
$type = $sqlQuery->execute()->value();
411-
}
412-
413-
return new TextField("SubmitPageUrl_{$this->ID}", "SubmitPageUrl_{$this->ID}", $type, 255);
414-
}
415-
416-
public function getDDLSponsorshipType()
417-
{
418-
$type = null;
419-
$pageId = Convert::raw2sql($_REQUEST["PageId"]);
420-
421-
if (isset($pageId)) {
422-
$sqlQuery = new SQLQuery();
423-
$sqlQuery->setSelect("SponsorshipType");
424-
$sqlQuery->setFrom("SummitSponsorPage_Companies");
425-
$sqlQuery->setWhere("CompanyID={$this->ID} AND SummitSponsorPageID={$pageId}");
426-
$type = $sqlQuery->execute()->value();
427-
}
428-
429-
return new DropdownField("SponsorshipType_{$this->ID}", "SponsorshipType_{$this->ID}", array(
430-
'Headline' => 'Headline',
431-
'Premier' => 'Premier',
432-
'Event' => 'Event',
433-
'Startup' => 'Startup',
434-
'InKind' => 'In Kind',
435-
'Spotlight' => 'Spotlight',
436-
'Media' => 'Media',
437-
'' => '--NONE--'
438-
), $type);
439-
}
440-
441-
public function getDDLLogoSize()
442-
{
443-
$size = null;
444-
$pageId = Convert::raw2sql($_REQUEST["PageId"]);
445-
446-
if (isset($pageId)) {
447-
$sqlQuery = new SQLQuery();
448-
$sqlQuery->setSelect("LogoSize");
449-
$sqlQuery->setFrom("SummitSponsorPage_Companies");
450-
$sqlQuery->setWhere("CompanyID={$this->ID} AND SummitSponsorPageID={$pageId}");
451-
$size = $sqlQuery->execute()->value();
452-
if (is_null($size)) {
453-
$size = 'None';
454-
}
455-
}
456-
457-
$sizes = array(
458-
'Small' => 'Small',
459-
'Medium' => 'Medium',
460-
'Large' => 'Large',
461-
'Big' => 'Big',
462-
'None' => '--NONE--'
463-
);
464-
465-
return new DropdownField("LogoSize_{$this->ID}", "LogoSize_{$this->ID}", $sizes, $size);
466-
}
467-
468394
public function SidebarLogoPreview()
469395
{
470396
$img = $this->Logo();
@@ -528,6 +454,7 @@ public function LargeLogoPreview()
528454
return 'missing';
529455
}
530456

457+
// this is only used for SponsorPage (not SummitSponsorPage) which is used only in old summits
531458
public function SubmitLandPageUrl()
532459
{
533460
$url = $this->URL;

sangria/code/SangriaPageExportDataExtension.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,16 +964,17 @@ function exportCompanyData()
964964
switch($report_name) {
965965
case 'sponsorship_type' :
966966
$query->setFrom('Company');
967-
$query->addLeftJoin('SummitSponsorPage_Companies', 'SummitSponsorPage_Companies.CompanyID = Company.ID');
968-
$query->addLeftJoin('Summit', 'Summit.ID = SummitSponsorPage_Companies.SummitID');
967+
$query->addLeftJoin('Sponsor', 'Sponsor.CompanyID = Company.ID');
968+
$query->addLeftJoin('SponsorshipType', 'Sponsor.SponsorshipTypeID = SponsorshipType.ID');
969+
$query->addLeftJoin('Summit', 'Summit.ID = Sponsor.SummitID');
969970
$query->addLeftJoin('Countries', 'Company.Country = Countries.Code');
970971
$query->addLeftJoin('Continent_Countries', 'Continent_Countries.CountryCode = Company.Country');
971972
$query->addLeftJoin('Continent', 'Continent.ID = Continent_Countries.ContinentID');
972973
$query->addWhere('Summit.Active','1');
973-
$fields = array_merge($fields,array('Sponsorship'=>'SummitSponsorPage_Companies.SponsorshipType','Summit ID'=>'Summit.ID'));
974+
$fields = array_merge($fields,array('Sponsorship'=>'SponsorshipType.Name','Summit ID'=>'Summit.ID'));
974975

975976
$query->setSelect($fields);
976-
$query->addOrderBy('SummitSponsorPage_Companies.SponsorshipType');
977+
$query->addOrderBy('SponsorshipType.Name');
977978

978979
$filename = "Sponsorship_Levels_" . date('Ymd') . "." . $ext;
979980
break;
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2015 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
class SponsorsGridFieldAddExistingAutocompleter extends GridFieldAddExistingAutocompleter
16+
{
17+
protected $summit_id;
18+
19+
public function doSearch($gridField, $request) {
20+
$dataClass = $gridField->getList()->dataClass();
21+
$allList = $this->searchList;
22+
23+
if ($this->getCompanyList($gridField))
24+
$allList = $allList->subtract($this->getCompanyList($gridField));
25+
26+
$searchFields = ($this->getSearchFields())
27+
? $this->getSearchFields()
28+
: $this->scaffoldSearchFields($dataClass);
29+
if(!$searchFields) {
30+
throw new LogicException(
31+
sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"',
32+
$dataClass));
33+
}
34+
35+
$params = array();
36+
foreach($searchFields as $searchField) {
37+
$name = (strpos($searchField, ':') !== FALSE) ? $searchField : "$searchField:StartsWith";
38+
$params[$name] = $request->getVar('gridfield_relationsearch');
39+
}
40+
41+
$results = $allList
42+
->filterAny($params)
43+
->sort(strtok($searchFields[0], ':'), 'ASC')
44+
->limit($this->getResultsLimit());
45+
46+
$json = array();
47+
$originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
48+
Config::inst()->update('SSViewer', 'source_file_comments', false);
49+
foreach($results as $result) {
50+
$json[$result->ID] = html_entity_decode(SSViewer::fromString($this->resultsFormat)->process($result));
51+
}
52+
Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
53+
54+
return Convert::array2json($json);
55+
}
56+
57+
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
58+
if(!$gridField->State->GridFieldAddRelation) {
59+
return $dataList;
60+
}
61+
$objectID = Convert::raw2sql($gridField->State->GridFieldAddRelation);
62+
if($objectID) {
63+
$object = DataObject::get_by_id('Company', $objectID);
64+
if($object) {
65+
$sponsor = new Sponsor();
66+
$sponsor->CompanyID = $objectID;
67+
$sponsor->SummitID = $this->getSummitID();
68+
$sponsor->write();
69+
$dataList->add($sponsor);
70+
}
71+
}
72+
$gridField->State->GridFieldAddRelation = null;
73+
return $dataList;
74+
}
75+
76+
public function getCompanyList($gridField) {
77+
$company_ids = $gridField->getList()->column('CompanyID');
78+
$companies = null;
79+
80+
if (count($company_ids))
81+
$companies = Company::get()->byIDs($company_ids);
82+
83+
return $companies;
84+
}
85+
86+
public function getSummitID() {
87+
return $this->summit_id;
88+
}
89+
90+
public function setSummitID ($summit_id) {
91+
$this->summit_id = (int)$summit_id;
92+
}
93+
94+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014 Openstack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
class Sponsor extends DataObject implements ISponsor
16+
{
17+
18+
private static $create_table_options = array('MySQLDatabase' => 'ENGINE=MyISAM');
19+
20+
static $db = array
21+
(
22+
'SubmitPageUrl' => 'Text',
23+
);
24+
25+
static $has_one = array
26+
(
27+
'Company' => 'Company',
28+
'SponsorshipType' => 'SponsorshipType',
29+
'SponsorPage' => 'SummitSponsorPage',
30+
'Summit' => 'Summit'
31+
);
32+
33+
private static $searchable_fields = array
34+
(
35+
'Company.Name'
36+
);
37+
38+
/**
39+
* @return int
40+
*/
41+
public function getIdentifier()
42+
{
43+
return (int)$this->getField('ID');
44+
}
45+
46+
//helper function to create Drop Down for Sponsorship type
47+
public function getDDLSponsorshipType()
48+
{
49+
$types = SponsorshipType::get()->map();
50+
$type = $this->SponsorshipTypeID;
51+
return new DropdownField("SponsorshipType_{$this->ID}", "SponsorshipType_{$this->ID}", $types, $type);
52+
}
53+
54+
public function getInputSubmitPageUrl()
55+
{
56+
return new TextField("SubmitPageUrl_{$this->ID}", "SubmitPageUrl_{$this->ID}", $this->SubmitPageUrl, 255);
57+
}
58+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014 Openstack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
class SponsorshipType extends DataObject implements ISponsorshipType
16+
{
17+
18+
private static $create_table_options = array('MySQLDatabase' => 'ENGINE=MyISAM');
19+
20+
static $db = array
21+
(
22+
'Name' => 'Varchar',
23+
'Label' => 'Varchar',
24+
'Order' => 'Int'
25+
);
26+
27+
/**
28+
* @return int
29+
*/
30+
public function getIdentifier()
31+
{
32+
return (int)$this->getField('ID');
33+
}
34+
}

0 commit comments

Comments
 (0)