Skip to content

Commit

Permalink
[smarcet] - #14555
Browse files Browse the repository at this point in the history
* fixed error on object deletion
* refactoring
  • Loading branch information
smarcet committed Jan 23, 2019
1 parent 26f033d commit 0ef6acf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions registration/code/ui/forms/EditSpeakerProfileForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,14 @@ function addAction($data, $form) {
// remove missing
foreach($speaker->AreasOfExpertise() as $exp){
if (!in_array($exp->Expertise, $expertise)) {
if(!$exp->exists()) continue;
$exp->delete();
}
}
} else {
// remove all
foreach($speaker->AreasOfExpertise() as $exp){
if(!$exp->exists()) continue;
$exp->delete();
}
}
Expand All @@ -310,6 +312,7 @@ function addAction($data, $form) {
// remove missing
foreach($speaker->OtherPresentationLinks() as $pl){
if (!in_array($pl->LinkUrl, $data['PresentationLink'])) {
if(!$pl->exists()) continue;
$pl->delete();
}
}
Expand All @@ -332,12 +335,14 @@ function addAction($data, $form) {
// remove missing
foreach($speaker->TravelPreferences() as $tp){
if (!in_array($tp->Country, $countries)) {
if(!$tp->exists()) continue;
$tp->delete();
}
}
} else {
// remove all
foreach($speaker->TravelPreferences() as $tp){
if(!$tp->exists()) continue;
$tp->delete();
}
}
Expand All @@ -351,8 +356,6 @@ function addAction($data, $form) {
return $this->controller()->redirectBack();

}
else {
return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
}
return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
}
}

0 comments on commit 0ef6acf

Please sign in to comment.