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:
Sean Harvey 2008-11-21 04:48:51 +00:00 committed by Sam Minnee
parent 4a60bb53d9
commit 0b1392a688

View File

@ -65,7 +65,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
return $form;
}
public function AddRecordForm() {
$m = Object::create('MemberTableField',
$this,
@ -101,29 +100,29 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
public function MemberForm() {
$id = $_REQUEST['ID'] ? $_REQUEST['ID'] : Session::get('currentMember');
if($id)
return $this->getMemberForm($id);
if($id) return $this->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') {
$fields = new FieldSet(
new HiddenField('MemberListBaseGroup', '', $this->currentPageID() )
);
if( $extraFields = $record->getCMSFields() )
foreach( $extraFields as $extra )
if($extraFields = $record->getCMSFields()) {
foreach($extraFields as $extra) {
$fields->push( $extra );
}
}
$fields->push($idField = new HiddenField("ID"));
$fields->push($groupIDField = new HiddenField("GroupID"));
$fields->push($idField = new HiddenField('ID'));
$fields->push($groupIDField = new HiddenField('GroupID'));
$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);
$idField->setValue($id);
@ -135,17 +134,13 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
function savemember() {
$data = $_REQUEST;
$className = $this->stat('subitem_class');
$id = $_REQUEST['ID'];
if($id == 'new') $id = null;
if($id) {
$record = DataObject::get_one($className, "`$className`.ID = $id");
} else {
$record = new $className();
}
if($id) $record = DataObject::get_one($className, "`$className`.ID = $id");
else $record = new $className();
$record->update($data);
$record->ID = $id;
@ -153,7 +148,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$record->Groups()->add($data['GroupID']);
FormResponse::add("reloadMemberTableField();");
return FormResponse::respond();
@ -162,14 +156,14 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
function addmember($className=null) {
$data = $_REQUEST;
unset($data['ID']);
if($className == null)
$className = $this->stat('subitem_class');
if($className == null) $className = $this->stat('subitem_class');
$record = new $className();
$record->update($data);
$record->write();
if($data['GroupID'])
$record->Groups()->add($data['GroupID']);
if($data['GroupID']) $record->Groups()->add($data['GroupID']);
FormResponse::add("reloadMemberTableField();");
@ -180,10 +174,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$groupID = $this->urlParams['ID'];
$memberID = $this->urlParams['OtherID'];
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);
FormResponse::add("reloadMemberTableField();");
} else {
user_error("SecurityAdmin::removememberfromgroup: Bad parameters: Group=$groupID, Member=$memberID", E_USER_ERROR);
}
@ -211,7 +204,6 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
"</ul>";
return $siteTree;
}
public function addgroup() {
@ -225,8 +217,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
}
public function EditedMember() {
if(Session::get('currentMember'))
return DataObject::get_by_id("Member", Session::get('currentMember'));
if(Session::get('currentMember')) return DataObject::get_by_id('Member', (int) Session::get('currentMember'));
}
function providePermissions() {
@ -236,4 +227,4 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
}
}
?>
?>