mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Update for security namespace
This commit is contained in:
parent
f03b0ab6c9
commit
ef723bb265
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
Member::add_extension('FrameworkTestRole');
|
Member::add_extension('FrameworkTestRole');
|
||||||
Member::add_extension('FileUploadRole');
|
Member::add_extension('FileUploadRole');
|
||||||
SiteTree::add_extension('FrameworkTestSiteTreeExtension');
|
SiteTree::add_extension('FrameworkTestSiteTreeExtension');
|
||||||
|
@ -3,14 +3,16 @@
|
|||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
|
|
||||||
class FrameworkTestRole extends DataExtension
|
class FrameworkTestRole extends DataExtension
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'FavouritePage' => 'SiteTree',
|
'FavouritePage' => 'SiteTree',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function updateCMSFields(FieldList $fields)
|
public function updateCMSFields(FieldList $fields)
|
||||||
{
|
{
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
@ -18,10 +20,10 @@ class FrameworkTestRole extends DataExtension
|
|||||||
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
|
new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requireDefaultRecords()
|
public function requireDefaultRecords()
|
||||||
{
|
{
|
||||||
$hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
|
$hasTestMembers = Member::get()->find('Email', 'hayley@test.com');
|
||||||
if (!$hasTestMembers) {
|
if (!$hasTestMembers) {
|
||||||
foreach ($this->data() as $name) {
|
foreach ($this->data() as $name) {
|
||||||
$member = new Member(array(
|
$member = new Member(array(
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a test session with various configurations set in session.
|
* Starts a test session with various configurations set in session.
|
||||||
* These configurations are assumed to be evaluated in mysite/_config.php,
|
* These configurations are assumed to be evaluated in mysite/_config.php,
|
||||||
@ -6,27 +10,27 @@
|
|||||||
*/
|
*/
|
||||||
class FrameworktestRegressSessionAdmin extends Controller
|
class FrameworktestRegressSessionAdmin extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $template = 'BlankPage';
|
protected $template = 'BlankPage';
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
if (!Permission::check('ADMIN')) {
|
if (!Permission::check('ADMIN')) {
|
||||||
return Security::permissionFailure($this);
|
return Security::permissionFailure($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Link($action = null)
|
public function Link($action = null)
|
||||||
{
|
{
|
||||||
return Controller::join_links('dev', 'regress', $action);
|
return Controller::join_links('dev', 'regress', $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Form()
|
public function Form()
|
||||||
{
|
{
|
||||||
$isRunning = (Session::get('db'));
|
$isRunning = (Session::get('db'));
|
||||||
|
|
||||||
if ($isRunning) {
|
if ($isRunning) {
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('endsession', 'End Session')
|
new FormAction('endsession', 'End Session')
|
||||||
@ -36,7 +40,7 @@ class FrameworktestRegressSessionAdmin extends Controller
|
|||||||
new FormAction('startsession', 'Start Session')
|
new FormAction('startsession', 'Start Session')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
@ -65,7 +69,7 @@ class FrameworktestRegressSessionAdmin extends Controller
|
|||||||
$actions
|
$actions
|
||||||
);
|
);
|
||||||
$dbField->setHasEmptyDefault(false);
|
$dbField->setHasEmptyDefault(false);
|
||||||
|
|
||||||
if ($isRunning) {
|
if ($isRunning) {
|
||||||
foreach ($form->Fields() as $field) {
|
foreach ($form->Fields() as $field) {
|
||||||
$form->Fields()->replaceField($field->Name(),
|
$form->Fields()->replaceField($field->Name(),
|
||||||
@ -73,7 +77,7 @@ class FrameworktestRegressSessionAdmin extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,15 +85,15 @@ class FrameworktestRegressSessionAdmin extends Controller
|
|||||||
{
|
{
|
||||||
Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null);
|
Session::set('enabletranslatable', (isset($data['enabletranslatable'])) ? $data['enabletranslatable'] : null);
|
||||||
Session::set('db', $data['db']);
|
Session::set('db', $data['db']);
|
||||||
|
|
||||||
return $this->redirect('dev/build/?BackURL=admin');
|
return $this->redirect('dev/build/?BackURL=admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function endsession()
|
public function endsession()
|
||||||
{
|
{
|
||||||
Session::set('enabletranslatable', null);
|
Session::set('enabletranslatable', null);
|
||||||
Session::set('db', null);
|
Session::set('db', null);
|
||||||
|
|
||||||
return $this->redirectBack();
|
return $this->redirectBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use SilverStripe\FrameworkTest\Model\TestPage;
|
use SilverStripe\FrameworkTest\Model\TestPage;
|
||||||
use SilverStripe\FrameworkTest\Model\TestPage_Controller;
|
use SilverStripe\FrameworkTest\Model\TestPage_Controller;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
class TestFileUploadPage extends TestPage
|
class TestFileUploadPage extends TestPage
|
||||||
{
|
{
|
||||||
@ -13,7 +14,7 @@ class TestFileUploadPage_Controller extends TestPage_Controller
|
|||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'Form'
|
'Form'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function Form()
|
public function Form()
|
||||||
{
|
{
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
@ -21,15 +22,15 @@ class TestFileUploadPage_Controller extends TestPage_Controller
|
|||||||
new FileField('AFile', 'FileField'),
|
new FileField('AFile', 'FileField'),
|
||||||
$aImage = new UploadField('AImage', 'SimpleImageField')
|
$aImage = new UploadField('AImage', 'SimpleImageField')
|
||||||
);
|
);
|
||||||
|
|
||||||
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
||||||
|
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('addMember', "Add a member with two Files uploaded")
|
new FormAction('addMember', "Add a member with two Files uploaded")
|
||||||
);
|
);
|
||||||
return new Form($this, "Form", $fields, $actions);
|
return new Form($this, "Form", $fields, $actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addMember($data, $form)
|
public function addMember($data, $form)
|
||||||
{
|
{
|
||||||
$member = new Member();
|
$member = new Member();
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
class Page2MultiForm extends MultiForm
|
class Page2MultiForm extends MultiForm
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $start_step = 'Page2PersonalDetailsFormStep';
|
public static $start_step = 'Page2PersonalDetailsFormStep';
|
||||||
|
|
||||||
public function finish($data, $form)
|
public function finish($data, $form)
|
||||||
{
|
{
|
||||||
parent::finish($data, $form);
|
parent::finish($data, $form);
|
||||||
@ -44,9 +45,9 @@ class Page2MultiForm extends MultiForm
|
|||||||
|
|
||||||
class Page2PersonalDetailsFormStep extends MultiFormStep
|
class Page2PersonalDetailsFormStep extends MultiFormStep
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
@ -58,7 +59,7 @@ class Page2PersonalDetailsFormStep extends MultiFormStep
|
|||||||
|
|
||||||
class Page2OrganisationDetailsFormStep extends MultiFormStep
|
class Page2OrganisationDetailsFormStep extends MultiFormStep
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
class Page3MultiForm extends MultiForm
|
class Page3MultiForm extends MultiForm
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $start_step = 'Page3StartFormStep';
|
public static $start_step = 'Page3StartFormStep';
|
||||||
|
|
||||||
public function finish($data, $form)
|
public function finish($data, $form)
|
||||||
{
|
{
|
||||||
parent::finish($data, $form);
|
parent::finish($data, $form);
|
||||||
@ -44,9 +45,9 @@ class Page3MultiForm extends MultiForm
|
|||||||
|
|
||||||
class Page3StartFormStep extends MultiFormStep
|
class Page3StartFormStep extends MultiFormStep
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
@ -63,9 +64,9 @@ class Page3StartFormStep extends MultiFormStep
|
|||||||
|
|
||||||
class Page3PersonalDetailsFormStep extends MultiFormStep
|
class Page3PersonalDetailsFormStep extends MultiFormStep
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
return new FieldList(
|
return new FieldList(
|
||||||
@ -77,7 +78,7 @@ class Page3PersonalDetailsFormStep extends MultiFormStep
|
|||||||
|
|
||||||
class Page3OrganisationDetailsFormStep extends MultiFormStep
|
class Page3OrganisationDetailsFormStep extends MultiFormStep
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
|
Loading…
Reference in New Issue
Block a user