Skip to content

Commit

Permalink
API Convert SecurityAdmin to be a ModelAdmin
Browse files Browse the repository at this point in the history
Co-authored-by: Maxime Rainville <[email protected]>
  • Loading branch information
emteknetnz and Maxime Rainville committed Sep 7, 2022
1 parent ec1111f commit 40f1124
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 312 deletions.
8 changes: 8 additions & 0 deletions _config/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ SilverStripe\Control\Director:
Permissions:
CMS_ACCESS: CMS_ACCESS
---
Name: member-import-routes
Before:
- '#adminroutes'
---
SilverStripe\Control\Director:
rules:
'admin/member-import//$Action/$ID/$OtherID': 'SilverStripe\Admin\MemberImportController'
---
Name: adminroutes
After:
- '#rootroutes'
Expand Down
59 changes: 59 additions & 0 deletions code/MemberImportController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace SilverStripe\Admin;

use SilverStripe\Control\Controller;
use SilverStripe\Security\Permission;
use SilverStripe\View\Requirements;

class MemberImportController extends Controller
{
private static $allowed_actions = [
'MemberImportForm',
'memberimport',
'GroupImportForm',
'groupimport',
];

private static $url_segment = 'admin/member-import';

public function memberimport()
{
Requirements::clear();
Requirements::javascript('silverstripe/admin: client/dist/js/vendor.js');
Requirements::javascript('silverstripe/admin: client/dist/js/MemberImportForm.js');
Requirements::css('silverstripe/admin: client/dist/styles/bundle.css');
return $this->renderWith('BlankPage', [
'Form' => $this->MemberImportForm()->forTemplate(),
'Content' => ' '
]);
}

public function MemberImportForm(): MemberImportForm
{
if (!Permission::check('ADMIN')) {
return null;
}
return new MemberImportForm($this, __FUNCTION__);
}

public function groupimport()
{
Requirements::clear();
Requirements::javascript('silverstripe/admin: client/dist/js/vendor.js');
Requirements::javascript('silverstripe/admin: client/dist/js/MemberImportForm.js');
Requirements::css('silverstripe/admin: client/dist/styles/bundle.css');
return $this->renderWith('BlankPage', [
'Content' => ' ',
'Form' => $this->GroupImportForm()->forTemplate()
]);
}

public function GroupImportForm(): GroupImportForm
{
if (!Permission::check('ADMIN')) {
return null;
}
return new GroupImportForm($this, __FUNCTION__);
}
}
Loading

0 comments on commit 40f1124

Please sign in to comment.