mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
MINOR SecurityAdmin code formatting cleanup
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@66386 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4a60bb53d9
commit
0b1392a688
@ -65,7 +65,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function AddRecordForm() {
|
public function AddRecordForm() {
|
||||||
$m = Object::create('MemberTableField',
|
$m = Object::create('MemberTableField',
|
||||||
$this,
|
$this,
|
||||||
@ -101,29 +100,29 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
public function MemberForm() {
|
public function MemberForm() {
|
||||||
$id = $_REQUEST['ID'] ? $_REQUEST['ID'] : Session::get('currentMember');
|
$id = $_REQUEST['ID'] ? $_REQUEST['ID'] : Session::get('currentMember');
|
||||||
if($id)
|
if($id) return $this->getMemberForm($id);
|
||||||
return $this->getMemberForm($id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMemberForm($id) {
|
public function getMemberForm($id) {
|
||||||
if($id && $id != 'new') $record = DataObject::get_by_id("Member",$id);
|
if($id && $id != 'new') $record = DataObject::get_by_id('Member', (int) $id);
|
||||||
if($record || $id == 'new') {
|
if($record || $id == 'new') {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldSet(
|
||||||
new HiddenField('MemberListBaseGroup', '', $this->currentPageID() )
|
new HiddenField('MemberListBaseGroup', '', $this->currentPageID() )
|
||||||
);
|
);
|
||||||
|
|
||||||
if( $extraFields = $record->getCMSFields() )
|
if($extraFields = $record->getCMSFields()) {
|
||||||
foreach( $extraFields as $extra )
|
foreach($extraFields as $extra) {
|
||||||
$fields->push( $extra );
|
$fields->push( $extra );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$fields->push($idField = new HiddenField("ID"));
|
$fields->push($idField = new HiddenField('ID'));
|
||||||
$fields->push($groupIDField = new HiddenField("GroupID"));
|
$fields->push($groupIDField = new HiddenField('GroupID'));
|
||||||
|
|
||||||
|
|
||||||
$actions = new FieldSet();
|
$actions = new FieldSet();
|
||||||
$actions->push(new FormAction('savemember', _t('SecurityAdmin.SAVE')));
|
$actions->push(new FormAction('savemember', _t('SecurityAdmin.SAVE')));
|
||||||
|
|
||||||
$form = new Form($this, "MemberForm", $fields, $actions);
|
$form = new Form($this, 'MemberForm', $fields, $actions);
|
||||||
if($record) $form->loadDataFrom($record);
|
if($record) $form->loadDataFrom($record);
|
||||||
|
|
||||||
$idField->setValue($id);
|
$idField->setValue($id);
|
||||||
@ -135,17 +134,13 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
function savemember() {
|
function savemember() {
|
||||||
$data = $_REQUEST;
|
$data = $_REQUEST;
|
||||||
|
|
||||||
$className = $this->stat('subitem_class');
|
$className = $this->stat('subitem_class');
|
||||||
|
|
||||||
$id = $_REQUEST['ID'];
|
$id = $_REQUEST['ID'];
|
||||||
if($id == 'new') $id = null;
|
if($id == 'new') $id = null;
|
||||||
|
|
||||||
if($id) {
|
if($id) $record = DataObject::get_one($className, "`$className`.ID = $id");
|
||||||
$record = DataObject::get_one($className, "`$className`.ID = $id");
|
else $record = new $className();
|
||||||
} else {
|
|
||||||
$record = new $className();
|
|
||||||
}
|
|
||||||
|
|
||||||
$record->update($data);
|
$record->update($data);
|
||||||
$record->ID = $id;
|
$record->ID = $id;
|
||||||
@ -153,7 +148,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
$record->Groups()->add($data['GroupID']);
|
$record->Groups()->add($data['GroupID']);
|
||||||
|
|
||||||
|
|
||||||
FormResponse::add("reloadMemberTableField();");
|
FormResponse::add("reloadMemberTableField();");
|
||||||
|
|
||||||
return FormResponse::respond();
|
return FormResponse::respond();
|
||||||
@ -162,14 +156,14 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
function addmember($className=null) {
|
function addmember($className=null) {
|
||||||
$data = $_REQUEST;
|
$data = $_REQUEST;
|
||||||
unset($data['ID']);
|
unset($data['ID']);
|
||||||
if($className == null)
|
if($className == null) $className = $this->stat('subitem_class');
|
||||||
$className = $this->stat('subitem_class');
|
|
||||||
$record = new $className();
|
$record = new $className();
|
||||||
|
|
||||||
$record->update($data);
|
$record->update($data);
|
||||||
$record->write();
|
$record->write();
|
||||||
if($data['GroupID'])
|
|
||||||
$record->Groups()->add($data['GroupID']);
|
if($data['GroupID']) $record->Groups()->add($data['GroupID']);
|
||||||
|
|
||||||
FormResponse::add("reloadMemberTableField();");
|
FormResponse::add("reloadMemberTableField();");
|
||||||
|
|
||||||
@ -180,10 +174,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
$groupID = $this->urlParams['ID'];
|
$groupID = $this->urlParams['ID'];
|
||||||
$memberID = $this->urlParams['OtherID'];
|
$memberID = $this->urlParams['OtherID'];
|
||||||
if(is_numeric($groupID) && is_numeric($memberID)) {
|
if(is_numeric($groupID) && is_numeric($memberID)) {
|
||||||
$member = DataObject::get_by_id('Member', $memberID);
|
$member = DataObject::get_by_id('Member', (int) $memberID);
|
||||||
$member->Groups()->remove($groupID);
|
$member->Groups()->remove($groupID);
|
||||||
FormResponse::add("reloadMemberTableField();");
|
FormResponse::add("reloadMemberTableField();");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
user_error("SecurityAdmin::removememberfromgroup: Bad parameters: Group=$groupID, Member=$memberID", E_USER_ERROR);
|
user_error("SecurityAdmin::removememberfromgroup: Bad parameters: Group=$groupID, Member=$memberID", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
@ -211,7 +204,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
"</ul>";
|
"</ul>";
|
||||||
|
|
||||||
return $siteTree;
|
return $siteTree;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addgroup() {
|
public function addgroup() {
|
||||||
@ -225,8 +217,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function EditedMember() {
|
public function EditedMember() {
|
||||||
if(Session::get('currentMember'))
|
if(Session::get('currentMember')) return DataObject::get_by_id('Member', (int) Session::get('currentMember'));
|
||||||
return DataObject::get_by_id("Member", Session::get('currentMember'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function providePermissions() {
|
function providePermissions() {
|
||||||
|
Loading…
Reference in New Issue
Block a user