2.3.x-and-above/upload/admin/controller/extension/module/facebook_business.php [235:298]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected function validate() {
        if (!$this->user->hasPermission('modify', 'extension/module/facebook_business')) {
            $this->error['warning'] = $this->language->get('error_permission');
        }

        return !$this->error;
    }

    public function updateSettings() {
        $json = array();

        $this->load->model('extension/module/facebook_business');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
            if (isset($this->request->post['facebook_pixel_id'])) {
                $this->request->post['facebook_use_s2s'] = true;
                $this->request->post['facebook_pixel_use_pii'] = $this->getPixelAAMSettings($this->request->post['facebook_pixel_id']);
                $this->request->post['facebook_pixel_enabled_aam_fields'] = $this->getPixelEnabledAAMFields($this->request->post['facebook_pixel_id']);
                $this->request->post['facebook_last_aam_check_time'] = time();
            }

            $this->model_extension_module_facebook_business->updateFacebookSettings($this->request->post);

            $json['success'] = true;
        }
    
        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }

    public function deleteSettings() {
        $json = array();

        $this->load->model('setting/setting');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
            $this->model_setting_setting->deleteSetting('facebook');

            $json['success'] = true;
        }

        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }

    private function getPixelAAMSettings($pixel_id) {
        $settings = AdsPixelSettings::buildFromPixelId($pixel_id);

        if ($settings !== null) {
          return $settings->getEnableAutomaticMatching() ? 'true' : 'false';
        }

        return 'false';
    }

    private function getPixelEnabledAAMFields($pixel_id) {
        $settings = AdsPixelSettings::buildFromPixelId($pixel_id);

        if ($settings !== null) {
          $enabled_aam_fileds = $settings->getEnabledAutomaticMatchingFields();
          return implode(',', $enabled_aam_fileds);
        }

        return '';
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



3.0.x-and-above/upload/admin/controller/extension/module/facebook_business.php [242:305]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected function validate() {
        if (!$this->user->hasPermission('modify', 'extension/module/facebook_business')) {
            $this->error['warning'] = $this->language->get('error_permission');
        }

        return !$this->error;
    }

    public function updateSettings() {
        $json = array();

        $this->load->model('extension/module/facebook_business');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
            if (isset($this->request->post['facebook_pixel_id'])) {
                $this->request->post['facebook_use_s2s'] = true;
                $this->request->post['facebook_pixel_use_pii'] = $this->getPixelAAMSettings($this->request->post['facebook_pixel_id']);
                $this->request->post['facebook_pixel_enabled_aam_fields'] = $this->getPixelEnabledAAMFields($this->request->post['facebook_pixel_id']);
                $this->request->post['facebook_last_aam_check_time'] = time();
            }

            $this->model_extension_module_facebook_business->updateFacebookSettings($this->request->post);

            $json['success'] = true;
        }
    
        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }

    public function deleteSettings() {
        $json = array();

        $this->load->model('setting/setting');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
            $this->model_setting_setting->deleteSetting('facebook');

            $json['success'] = true;
        }

        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }

    private function getPixelAAMSettings($pixel_id) {
        $settings = AdsPixelSettings::buildFromPixelId($pixel_id);

        if ($settings !== null) {
          return $settings->getEnableAutomaticMatching() ? 'true' : 'false';
        }

        return 'false';
    }

    private function getPixelEnabledAAMFields($pixel_id) {
        $settings = AdsPixelSettings::buildFromPixelId($pixel_id);

        if ($settings !== null) {
          $enabled_aam_fileds = $settings->getEnabledAutomaticMatchingFields();
          return implode(',', $enabled_aam_fileds);
        }

        return '';
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



