From e0611be46921dadc9c689650c27d4c271796f3bf Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 15 Dec 2008 03:08:15 +0000 Subject: [PATCH] BUGFIX Fixed PHP notice potential error in MemberTableField->addtogroup() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@68935 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/MemberTableField.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/code/MemberTableField.php b/code/MemberTableField.php index b7c92566..17d940eb 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -54,7 +54,7 @@ class MemberTableField extends ComplexTableField { } function __construct($controller, $name, $group, $members = null, $hidePassword = true, $pageLimit = 10) { - + if($group) { if(is_object($group)) { $this->group = $group; @@ -191,9 +191,10 @@ class MemberTableField extends ComplexTableField { function addtogroup() { $data = $_REQUEST; unset($data['ID']); + $ctfID = isset($data['ctf']) ? $data['ctf']['ID'] : null; - if(!is_numeric($data['ctf']['ID'])) { - FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad'); + if(!is_numeric($ctfID)) { + FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad'); } $className = Object::getCustomClass($this->stat('data_class')); @@ -202,13 +203,10 @@ class MemberTableField extends ComplexTableField { $record->update($data); $valid = $record->validate(); + if($valid->valid()) { $record->write(); - - // To Avoid duplication in the Group_Members table if the ComponentSet.php is not modified just uncomment le line below - - //if( ! $record->inGroup( $data['ctf']['ID'] ) ) - $record->Groups()->add( $data['ctf']['ID'] ); + $record->Groups()->add($ctfID); $this->sourceItems();