I'm running Silverstripe 2.4.3 on a reasonable size site (around 500 pages) and we've just noticed a weird problem. We have several custom page typed (about 20 or so) and for only one of them, the Access settings no longer seem to work. Regardless of what it is set to it allows anyone to access the page (logged in or not). This doesn't happen on standard "Pages" or on the other custom page type pages that I have checked. We need this page type to be restricted to logged in users as it contains premium content.
Below is the code of the page:
<?php
/**
* Defines the Song of the Week page type
*/
class SongOfTheWeek extends Page {
static $icon = 'mysite/images/icons/songstory';
public static $db = array(
'Writer' => 'Varchar(250)',
'Show_UK' => 'Boolean',
'Show_US' => 'Boolean'
);
public static $has_one = array(
'Artist' => 'ArtistPage',
'MP3' => 'File',
'PDFSheet' => 'File'
);
public static $has_many = array(
'MediaPlayerTracks' => 'MediaPlayerTrack',
);
static $field_labels = array(
'Title' => 'Song Title',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root","Widgets");
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('Show_UK','Show on UK site?'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('Show_US','Show on US site?'), 'Content');
$fields->addFieldToTab("Root.Content.Main", new DropdownField('ArtistID', 'Artist', Dataobject::get('ArtistPage')->toDropdownMap('ID','Title')),'Content');
$fields->addFieldToTab("Root.Content.Main", new TextField('Writer', 'Writer'),'Content');
$fields->addFieldToTab('Root.Content.Main', new FileIFrameField('MP3','MP3 File for download'));
$fields->addFieldToTab('Root.Content.Main', new FileIFrameField('PDFSheet','PDF Music sheet for download'));
$MediaTable = new FileDataObjectManager(
$this, // Controller
'MediaPlayerTracks', // Source name
'MediaPlayerTrack', // Source class
'MP3', // File name on DataObject
array(
'Title' => 'Title',
'Artist' => 'Artist'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
//$MediaTable = new HasManyFileManager($this, 'MediaPlayerTracks', 'TrackFile');
$fields->addFieldToTab('Root.Content.MediaPlayer', $MediaTable);
return $fields;
}
}
class SongOfTheWeek_Controller extends Page_Controller {
}
?>
I don't know if it's connected, but I load these pages for display on the home page using the following code. I have been using this approach for well over a year and it never caused this issue before:
function FreeSong() {
$now = strtotime('now');
$country = Session::get('KWCountry');
if ($country == "US" || $country == "CA") {
$freesong = DataObject::get('SongOfTheWeek', '"SongOfTheWeek_Live"."Expiry" >= NOW() AND "SongOfTheWeek_Live"."Embargo" <= NOW() AND ParentID = 227 AND Show_US = True ','','',1);
}
else {
$freesong = DataObject::get('SongOfTheWeek', '"SongOfTheWeek_Live"."Expiry" >= NOW() AND "SongOfTheWeek_Live"."Embargo" <= NOW() AND ParentID = 227 AND Show_UK = True','','',1);
}
return $freesong;
}
I've drawn a blank so far - any help would be appreciated.