From 0b1392a6887bd68986e00f2dda9889ca41d00a6d Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 21 Nov 2008 04:48:51 +0000 Subject: [PATCH] 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 --- code/SecurityAdmin.php | 47 +++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 5037a67f..28ed5a50 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -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 { ""; 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 { } } -?> +?> \ No newline at end of file