function test_xml_import_to_update_fields_and_forms()
 {
     $args = self::_get_xml_update_args();
     $path = self::_generate_xml_for_all_fields_form($args);
     $message = FrmXMLHelper::import_xml($path);
     self::_check_xml_updated_forms_parent_id($args);
     self::_check_xml_updated_fields($args);
     self::_check_xml_updated_repeating_fields($args);
     self::_check_xml_updated_repeating_section($args);
     self::_check_the_imported_and_updated_numbers($message);
     // Delete the temp.XML file
     unlink($path);
 }
예제 #2
0
 public static function import_xml()
 {
     $errors = array();
     $message = '';
     $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
     if ($permission_error !== false) {
         $errors[] = $permission_error;
         self::form($errors);
         return;
     }
     if (!isset($_FILES) || !isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1) {
         $errors[] = __('Oops, you didn\'t select a file.', 'formidable');
         self::form($errors);
         return;
     }
     $file = $_FILES['frm_import_file']['tmp_name'];
     if (!is_uploaded_file($file)) {
         unset($file);
         $errors[] = __('The file does not exist, please try again.', 'formidable');
         self::form($errors);
         return;
     }
     //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
     $export_format = apply_filters('frm_export_formats', array('xml' => array('name' => 'XML', 'support' => 'forms', 'count' => 'multiple')));
     $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
     if ($file_type != 'xml' && isset($export_format[$file_type])) {
         // allow other file types to be imported
         do_action('frm_before_import_' . $file_type);
         return;
     }
     unset($file_type);
     //$media_id = FrmProAppHelper::upload_file('frm_import_file');
     if (!function_exists('libxml_disable_entity_loader')) {
         $errors[] = __('XML import is not enabled on your server.', 'formidable');
         self::form($errors);
         return;
     }
     $set_err = libxml_use_internal_errors(true);
     $loader = libxml_disable_entity_loader(true);
     $result = FrmXMLHelper::import_xml($file);
     FrmXMLHelper::parse_message($result, $message, $errors);
     unset($file);
     libxml_use_internal_errors($set_err);
     libxml_disable_entity_loader($loader);
     self::form($errors, $message);
 }
예제 #3
0
 /**
  * Migrate post and email notification settings into actions
  */
 private function migrate_to_16()
 {
     global $wpdb;
     $forms = FrmDb::get_results($this->forms, array(), 'id, options, is_template, default_template');
     /**
      * Old email settings format:
      * email_to: Email or field id
      * also_email_to: array of fields ids
      * reply_to: Email, field id, 'custom'
      * cust_reply_to: string
      * reply_to_name: field id, 'custom'
      * cust_reply_to_name: string
      * plain_text: 0|1
      * email_message: string or ''
      * email_subject: string or ''
      * inc_user_info: 0|1
      * update_email: 0, 1, 2
      *
      * Old autoresponder settings format:
      * auto_responder: 0|1
      * ar_email_message: string or ''
      * ar_email_to: field id
      * ar_plain_text: 0|1
      * ar_reply_to_name: string
      * ar_reply_to: string
      * ar_email_subject: string
      * ar_update_email: 0, 1, 2
      *
      * New email settings:
      * post_content: json settings
      * post_title: form id
      * post_excerpt: message
      *
      */
     foreach ($forms as $form) {
         if ($form->is_template && $form->default_template) {
             // don't migrate the default templates since the email will be added anyway
             continue;
         }
         // Format form options
         $form_options = maybe_unserialize($form->options);
         // Migrate settings to actions
         FrmXMLHelper::migrate_form_settings_to_actions($form_options, $form->id);
     }
 }
예제 #4
0
            ?>
</default_value>
            <field_order><?php 
            echo $field->field_order;
            ?>
</field_order>
            <form_id><?php 
            echo $field->form_id;
            ?>
</form_id>
            <required><?php 
            echo (bool) $field->required;
            ?>
</required>
            <options><?php 
            echo FrmXMLHelper::cdata($field->options);
            ?>
</options>
            <field_options><?php 
            echo FrmXMLHelper::cdata($field->field_options);
            ?>
</field_options>
		</field>
<?php 
        }
        ?>
	</form>
<?php 
        unset($fields);
    }
}
예제 #5
0
</parent_item_id>
        
<?php 
        $metas = $wpdb->get_results($wpdb->prepare("SELECT meta_value, field_id FROM {$wpdb->prefix}frm_item_metas WHERE item_id=%d", $entry->id));
        foreach ($metas as $meta) {
            ?>
		<item_meta>
		    <field_id><?php 
            echo $meta->field_id;
            ?>
</field_id>
		    <meta_value><?php 
            if (isset($fields[$meta->field_id])) {
                $meta->meta_value = FrmProFieldsHelper::get_export_val($meta->meta_value, $fields[$meta->field_id]);
            }
            echo FrmXMLHelper::cdata($meta->meta_value);
            unset($meta);
            ?>
</meta_value>
		</item_meta>
<?php 
        }
        ?>
	</item>
<?php 
        unset($metas);
        if (!empty($entry->post_id)) {
            $old_ids = $item_ids;
            $item_ids = array($entry->post_id);
            include dirname(__FILE__) . '/views_xml.php';
            $item_ids = $old_ids;
예제 #6
0
foreach ((array) $terms as $term) {
    if (in_array($term->term_id, $frm_inc_tax)) {
        return;
    }
    $frm_inc_tax[] = $term->term_id;
    $label = $term->taxonomy == 'category' || $term->taxonomy == 'tag' ? $term->taxonomy : 'term';
    ?>
	<term><term_id><?php 
    echo esc_html($term->term_id);
    ?>
</term_id><term_taxonomy><?php 
    echo esc_html($term->taxonomy);
    ?>
</term_taxonomy><?php 
    if (!empty($term->name)) {
        echo '<term_name>' . FrmXMLHelper::cdata($term->name) . '</term_name>';
    }
    if (!empty($term->description)) {
        ?>
<term_description><?php 
        echo FrmXMLHelper::cdata($term->description);
        ?>
</term_description><?php 
    }
    ?>
<term_slug><?php 
    echo esc_html($term->slug);
    ?>
</term_slug></term>
<?php 
}
예제 #7
0
 public static function import_xml()
 {
     $errors = array();
     $message = '';
     if (!current_user_can('frm_edit_forms') || !isset($_POST['import-xml']) || !wp_verify_nonce($_POST['import-xml'], 'import-xml-nonce')) {
         global $frm_settings;
         $errors[] = $frm_settings->admin_permission;
         self::form($errors);
         return;
     }
     if (!isset($_FILES) || !isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1) {
         $errors[] = __('Oops, you didn\'t select a file.', 'formidable');
         self::form($errors);
         return;
     }
     $file = $_FILES['frm_import_file']['tmp_name'];
     if (!is_uploaded_file($file)) {
         unset($file);
         $errors[] = __('The file does not exist, please try again.', 'formidable');
         self::form($errors);
         return;
     }
     //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
     $export_format = apply_filters('frm_export_formats', array('xml' => array('name' => 'XML', 'support' => 'forms', 'count' => 'multiple')));
     $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
     if ($file_type != 'xml' && isset($export_format[$file_type])) {
         // allow other file types to be imported
         do_action('frm_before_import_' . $file_type);
         return;
     }
     unset($file_type);
     //$media_id = FrmProAppHelper::upload_file('frm_import_file');
     //if(is_numeric($media_id)){
     if (!function_exists('libxml_disable_entity_loader')) {
         $errors[] = __('XML import is not enabled on your server.', 'formidable');
         self::form($errors);
         return;
     }
     include_once FrmAppHelper::plugin_path() . '/classes/helpers/FrmXMLHelper.php';
     $set_err = libxml_use_internal_errors(true);
     $loader = libxml_disable_entity_loader(true);
     $result = FrmXMLHelper::import_xml($file);
     if (is_wp_error($result)) {
         $errors[] = $result->get_error_message();
     } else {
         if ($result) {
             if (is_array($result)) {
                 $t_strings = array('imported' => __('Imported', 'formidable'), 'updated' => __('Updated', 'formidable'));
                 $message = '<ul>';
                 foreach ($result as $type => $results) {
                     if (!isset($t_strings[$type])) {
                         // only print imported and updated
                         continue;
                     }
                     $s_message = array();
                     foreach ($results as $k => $m) {
                         if ($m) {
                             $strings = array('forms' => sprintf(_n('%1$s Form', '%1$s Forms', $m, 'formidable'), $m), 'fields' => sprintf(_n('%1$s Field', '%1$s Fields', $m, 'formidable'), $m), 'items' => sprintf(_n('%1$s Entry', '%1$s Entries', $m, 'formidable'), $m), 'views' => sprintf(_n('%1$s View', '%1$s Views', $m, 'formidable'), $m), 'posts' => sprintf(_n('%1$s Post', '%1$s Posts', $m, 'formidable'), $m), 'terms' => sprintf(_n('%1$s Term', '%1$s Terms', $m, 'formidable'), $m));
                             $s_message[] = isset($strings[$k]) ? $strings[$k] : $t_strings[$type] . ' ' . $m . ' ' . ucfirst($k);
                         }
                         unset($k);
                         unset($m);
                     }
                     if (!empty($s_message)) {
                         $message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
                         $message .= implode(', ', $s_message);
                         $message .= '</li>';
                     }
                 }
                 if ($message == '<ul>') {
                     $message = '';
                     $errors[] = __('Nothing was imported or updated', 'formidable');
                 } else {
                     $message .= '</ul>';
                 }
             } else {
                 $message = $result;
             }
         }
     }
     unset($file);
     libxml_use_internal_errors($set_err);
     libxml_disable_entity_loader($loader);
     //}else{
     //    foreach ($media_id->errors as $error)
     //        echo $error[0];
     //}
     self::form($errors, $message);
 }