mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
setByIDList function update( notices and ajax problem solving )
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41165 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
cb40b7e28a
commit
b5c83d3513
@ -159,35 +159,32 @@ class ComponentSet extends DataObjectSet {
|
|||||||
* @param array $idList List of IDs.
|
* @param array $idList List of IDs.
|
||||||
*/
|
*/
|
||||||
function setByIDList($idList) {
|
function setByIDList($idList) {
|
||||||
$has = array();
|
|
||||||
|
|
||||||
// Index current data
|
// Index current data
|
||||||
if($this->items) {
|
if($this->items) {
|
||||||
foreach($this->items as $item) {
|
foreach( $this->items as $item )
|
||||||
$has[$item->ID] = true;
|
$has[$item->ID] = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of items to delete
|
// Keep track of items to delete
|
||||||
$itemsToDelete = $has;
|
if( isset( $has ) )
|
||||||
|
$itemsToDelete = $has;
|
||||||
|
|
||||||
if($idList){
|
if($idList){
|
||||||
foreach($idList as $id) {
|
foreach($idList as $id) {
|
||||||
$itemsToDelete[$id] = false;
|
if( isset( $itemsToDelete ) )
|
||||||
if(!isset($has[$id]) && $id) {
|
$itemsToDelete[$id] = false;
|
||||||
|
if( ! isset( $has ) || ( $id && ! isset( $has[$id] ) ) )
|
||||||
$this->add($id);
|
$this->add($id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Delete any unmentionedItems
|
// Delete any unmentionedItems
|
||||||
if($itemsToDelete) {
|
if( isset( $itemsToDelete ) ) {
|
||||||
$removeList = array();
|
|
||||||
foreach($itemsToDelete as $id => $actuallyDelete) {
|
foreach($itemsToDelete as $id => $actuallyDelete) {
|
||||||
if($actuallyDelete) $removeList[] = $id;
|
if($actuallyDelete) $removeList[] = $id;
|
||||||
}
|
}
|
||||||
if($removeList) {
|
|
||||||
|
if( isset( $removeList ) )
|
||||||
$this->removeMany($removeList);
|
$this->removeMany($removeList);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user