/**
  * Creates the form.
  *
  * @return void
  *
  * @global array The configuration of the plugins.
  */
 public function execute()
 {
     global $plugin_cf;
     $pcf = $plugin_cf['advancedform'];
     $forms = Data::readDB();
     $forms[$this->id] = array('name' => '', 'title' => '', 'to_name' => $pcf['mail_to_name'], 'to' => $pcf['mail_to'], 'cc' => $pcf['mail_cc'], 'bcc' => $pcf['mail_bcc'], 'captcha' => (bool) $pcf['mail_captcha'], 'store' => false, 'thanks_page' => $pcf['mail_thanks_page'], 'fields' => array(array('field' => '', 'label' => '', 'type' => 'text', 'props' => "¦¦¦", 'required' => '0')));
     Data::writeDB($forms);
 }
 /**
  * Deletes the form.
  *
  * @return void
  *
  * @throws \InvalidArgumentException
  */
 public function execute()
 {
     $forms = Data::readDB();
     if (!isset($forms[$this->id])) {
         throw new \InvalidArgumentException();
     }
     unset($forms[$this->id]);
     Data::writeDB($forms);
 }
 /**
  * Copies the form.
  *
  * @return void
  *
  * @throws \InvalidArgumentException
  */
 public function execute()
 {
     $forms = Data::readDB();
     if (isset($forms[$this->from])) {
         $form = $forms[$this->from];
         $form['name'] = '';
         $forms[$this->to] = $form;
         Data::writeDB($forms);
     } else {
         throw new \InvalidArgumentException();
     }
 }
 /**
  * Imports the form definition from a *.frm file. Returns the mail form
  * administration.
  *
  * @param string $id A form ID.
  *
  * @return string (X)HTML.
  *
  * @global array  The localization of the plugins.
  * @global string The (X)HTML fragment containing error messages.
  * @global object The CSRF protector.
  */
 protected static function importForm($id)
 {
     global $plugin_tx, $e, $_XH_csrfProtection;
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         return Editor::renderFormsAdministration();
     }
     $_XH_csrfProtection->check();
     $ptx = $plugin_tx['advancedform'];
     $forms = Data::readDB();
     if (!isset($forms[$id])) {
         $fn = Data::folder() . $id . '.frm';
         if (($cnt = file_get_contents($fn)) !== false && ($form = unserialize($cnt)) !== false && isset($form['%VERSION%']) && count($form) == 2) {
             if ($form['%VERSION%'] < Data::DB_VERSION) {
                 $form = Data::updatedDb($form);
             }
             unset($form['%VERSION%']);
             foreach ($form as $f) {
                 $f['name'] = $id;
                 $forms[$id] = $f;
             }
             Data::writeDB($forms);
         } else {
             e('cntopen', 'file', $fn);
         }
     } else {
         $e .= '<li><b>' . $ptx['error_form_exists'] . '</b></li>';
     }
     return Editor::renderFormsAdministration();
 }