mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
ENHANCEMENT Saving MemberTableField through new 'Groups' field added in Member->getCMSFields().
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@98882 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ecab219100
commit
fc8f4130c2
@ -305,13 +305,18 @@ class MemberTableField extends ComplexTableField {
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function saveComplexTableField($data, $form, $params) {
|
function saveComplexTableField($data, $form, $params) {
|
||||||
$className = $this->sourceClass();
|
$className = $this->sourceClass();
|
||||||
$childData = new $className();
|
$childData = new $className();
|
||||||
$form->saveInto($childData);
|
$form->saveInto($childData);
|
||||||
$childData->write();
|
$childData->write();
|
||||||
|
|
||||||
$childData->Groups()->add($data['GroupID']);
|
// Only write group if no specific assignments have been set
|
||||||
|
if(isset($data['Groups']) && $data['Groups']) {
|
||||||
|
$childData->Groups()->setByIDList(explode(',', $data['Groups']));
|
||||||
|
} else {
|
||||||
|
$childData->Groups()->add($data['GroupID']);
|
||||||
|
}
|
||||||
|
|
||||||
$closeLink = sprintf(
|
$closeLink = sprintf(
|
||||||
'<small><a href="' . $_SERVER['HTTP_REFERER'] . '" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>',
|
'<small><a href="' . $_SERVER['HTTP_REFERER'] . '" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>',
|
||||||
@ -395,6 +400,16 @@ class MemberTableField extends ComplexTableField {
|
|||||||
* @subpackage security
|
* @subpackage security
|
||||||
*/
|
*/
|
||||||
class MemberTableField_Popup extends ComplexTableField_Popup {
|
class MemberTableField_Popup extends ComplexTableField_Popup {
|
||||||
|
|
||||||
|
function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
|
||||||
|
$group = ($controller instanceof MemberTableField) ? $controller->getGroup() : $controller->getParent()->getGroup();
|
||||||
|
if($group) {
|
||||||
|
$groupsField = $fields->dataFieldByName('Groups');
|
||||||
|
if($groupsField) $groupsField->setValue($group->ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($controller, $name, $fields, $validator, $readonly, $dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
function forTemplate() {
|
function forTemplate() {
|
||||||
$ret = parent::forTemplate();
|
$ret = parent::forTemplate();
|
||||||
@ -435,6 +450,20 @@ class MemberTableField_Item extends ComplexTableField_Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MemberTableField_ItemRequest extends ComplexTableField_ItemRequest {
|
class MemberTableField_ItemRequest extends ComplexTableField_ItemRequest {
|
||||||
|
|
||||||
|
function saveComplexTableField($data, $form, $request) {
|
||||||
|
parent::saveComplexTableField($data, $form, $request);
|
||||||
|
|
||||||
|
$childData = $this->dataObj();
|
||||||
|
|
||||||
|
// Only write group if no specific assignments have been set
|
||||||
|
if(isset($data['Groups']) && $data['Groups']) {
|
||||||
|
$childData->Groups()->setByIDList(explode(',', $data['Groups']));
|
||||||
|
} else {
|
||||||
|
$childData->Groups()->add($data['GroupID']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deleting an item from a member table field should just remove that member from the group
|
* Deleting an item from a member table field should just remove that member from the group
|
||||||
*/
|
*/
|
||||||
@ -452,6 +481,10 @@ class MemberTableField_ItemRequest extends ComplexTableField_ItemRequest {
|
|||||||
$this->dataObj()->delete();
|
$this->dataObj()->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParent() {
|
||||||
|
return $this->ctf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user