public function install()
 {
     // install the module in the database
     $this->addModule('FormBuilderMailer');
     // install the locale, this is set here because we need the module for this
     $this->importLocale(dirname(__FILE__) . '/Data/locale.xml');
     $this->setModuleRights(1, 'FormBuilderMailer');
     $this->setActionRights(1, 'FormBuilderMailer', 'Settings');
     // settings navigation
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'FormBuilderMailer', 'form_builder_mailer/settings');
     BackendModel::setModuleSetting('FormBuilderMailer', 'enabled', true);
     BackendModel::subscribeToEvent('Formbuilder', 'after_submission', 'FormBuilderMailer', array('Backend\\Modules\\FormBuilderMailer\\Engine\\Model', 'afterFormSubmission'));
 }
 /**
  * Validates the settings form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         if ($this->frm->isCorrect()) {
             $enabled = (bool) $this->frm->getField('enabled')->getValue();
             BackendModel::setModuleSetting($this->URL->getModule(), 'enabled', $enabled);
             if ($enabled) {
                 BackendModel::subscribeToEvent('Formbuilder', 'after_submission', 'FormBuilderMailer', array('\\Backend\\Modules\\FormBuilderMailer\\Engine\\Model', 'afterFormSubmission'));
             } else {
                 BackendModel::unsubscribeFromEvent('Formbuilder', 'after_submission', 'FormBuilderMailer');
             }
             BackendModel::setModuleSetting($this->URL->getModule(), 'log', (bool) $this->frm->getField('log')->getValue());
             BackendModel::setModuleSetting($this->URL->getModule(), 'add_data', (bool) $this->frm->getField('add_data')->getValue());
             BackendModel::triggerEvent($this->getModule(), 'after_saved_settings');
             $this->redirect(BackendModel::createURLForAction('settings') . '&report=saved');
         }
     }
 }