public function get_data(HTMLForm $form, MemberExtendedField $member_extended_field)
 {
     $streams = array();
     foreach ($form->get_value($member_extended_field->get_field_name(), array()) as $field => $option) {
         $streams[] = $option->get_id();
     }
     if (is_array($streams)) {
         NewsletterService::update_subscriptions_member_registered($streams, $member_extended_field->get_user_id());
     }
     $field_name = $member_extended_field->get_field_name();
     $streams = $this->get_streams();
     if (!empty($streams)) {
         $array = array();
         foreach ($form->get_value($field_name) as $field => $option) {
             $array[] = $option->get_id();
         }
         return $this->serialise_value($array);
     }
     return '';
 }
 private function save()
 {
     $delete_all_streams = $this->form->get_value('delete_all_streams');
     if ($delete_all_streams) {
         if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
             NewsletterService::unsubscriber_all_streams_member(AppContext::get_current_user()->get_id());
         } else {
             NewsletterService::unsubscriber_all_streams_visitor($this->form->get_value('mail'));
         }
     } else {
         $streams = array();
         foreach ($this->form->get_value('choice') as $field => $option) {
             $streams[] = $option->get_id();
         }
         if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) && $streams !== '') {
             NewsletterService::update_subscriptions_member_registered($streams, AppContext::get_current_user()->get_id());
         } else {
             NewsletterService::update_subscriptions_visitor($streams, $this->form->get_value('mail'));
         }
     }
     NewsletterStreamsCache::invalidate();
 }
 private function save()
 {
     $streams = array();
     foreach ($this->form->get_value('newsletter_choice') as $field => $option) {
         $streams[] = $option->get_id();
     }
     if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         NewsletterService::update_subscriptions_member_registered($streams, AppContext::get_current_user()->get_id());
     } else {
         NewsletterService::update_subscriptions_visitor($streams, $this->form->get_value('mail'));
     }
 }