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
This commit is contained in:
Sean Harvey 2008-12-15 03:08:15 +00:00 committed by Sam Minnee
parent 63f5421296
commit e0611be469

View File

@ -191,8 +191,9 @@ class MemberTableField extends ComplexTableField {
function addtogroup() { function addtogroup() {
$data = $_REQUEST; $data = $_REQUEST;
unset($data['ID']); unset($data['ID']);
$ctfID = isset($data['ctf']) ? $data['ctf']['ID'] : null;
if(!is_numeric($data['ctf']['ID'])) { if(!is_numeric($ctfID)) {
FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad'); FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
} }
@ -202,13 +203,10 @@ class MemberTableField extends ComplexTableField {
$record->update($data); $record->update($data);
$valid = $record->validate(); $valid = $record->validate();
if($valid->valid()) { if($valid->valid()) {
$record->write(); $record->write();
$record->Groups()->add($ctfID);
// 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'] );
$this->sourceItems(); $this->sourceItems();