Example #1
0
 public static function import_xml_views($views, $imported)
 {
     $imported['posts'] = array();
     $form_action_type = FrmFormActionsController::$action_post_type;
     $post_types = array('frm_display' => 'views', $form_action_type => 'actions', 'frm_styles' => 'styles');
     foreach ($views as $item) {
         $post = array('post_title' => (string) $item->title, 'post_name' => (string) $item->post_name, 'post_type' => (string) $item->post_type, 'post_password' => (string) $item->post_password, 'guid' => (string) $item->guid, 'post_status' => (string) $item->status, 'post_author' => FrmAppHelper::get_user_id_param((string) $item->post_author), 'post_id' => (int) $item->post_id, 'post_parent' => (int) $item->post_parent, 'menu_order' => (int) $item->menu_order, 'post_content' => FrmFieldsHelper::switch_field_ids((string) $item->content), 'post_excerpt' => FrmFieldsHelper::switch_field_ids((string) $item->excerpt), 'is_sticky' => (string) $item->is_sticky, 'comment_status' => (string) $item->comment_status, 'post_date' => (string) $item->post_date, 'post_date_gmt' => (string) $item->post_date_gmt, 'ping_status' => (string) $item->ping_status, 'postmeta' => array(), 'tax_input' => array());
         $old_id = $post['post_id'];
         self::populate_post($post, $item, $imported);
         unset($item);
         $post_id = false;
         if ($post['post_type'] == $form_action_type) {
             $action_control = FrmFormActionsController::get_form_actions($post['post_excerpt']);
             if ($action_control) {
                 $post_id = $action_control->maybe_create_action($post, $imported['form_status']);
             }
             unset($action_control);
         } else {
             if ($post['post_type'] == 'frm_styles') {
                 // Properly encode post content before inserting the post
                 $post['post_content'] = FrmAppHelper::maybe_json_decode($post['post_content']);
                 $post['post_content'] = FrmAppHelper::prepare_and_encode($post['post_content']);
                 // Create/update post now
                 $post_id = wp_insert_post($post);
             } else {
                 // Create/update post now
                 $post_id = wp_insert_post($post);
             }
         }
         if (!is_numeric($post_id)) {
             continue;
         }
         self::update_postmeta($post, $post_id);
         $this_type = 'posts';
         if (isset($post_types[$post['post_type']])) {
             $this_type = $post_types[$post['post_type']];
         }
         if (isset($post['ID']) && $post_id == $post['ID']) {
             $imported['updated'][$this_type]++;
         } else {
             $imported['imported'][$this_type]++;
         }
         unset($post);
         $imported['posts'][(int) $old_id] = $post_id;
     }
     return $imported;
 }
 /**
  * @param int $action_id
  */
 public static function get_single_action_type($action_id, $type)
 {
     $action_control = FrmFormActionsController::get_form_actions($type);
     return $action_control->get_single_action($action_id);
 }
Example #3
0
 public static function get_action_for_form($form_id, $type = 'all', $limit = 99)
 {
     $action_controls = FrmFormActionsController::get_form_actions($type);
     if (empty($action_controls)) {
         // don't continue if there are no available actions
         return array();
     }
     if ('all' != $type) {
         return $action_controls->get_all($form_id, $limit);
     }
     $args = self::action_args($form_id, $limit);
     $actions = FrmAppHelper::check_cache(serialize($args), 'frm_actions', $args, 'get_posts');
     if (!$actions) {
         return array();
     }
     $settings = array();
     foreach ($actions as $action) {
         // some plugins/themes are formatting the post_excerpt
         $action->post_excerpt = sanitize_title($action->post_excerpt);
         if (!isset($action_controls[$action->post_excerpt])) {
             continue;
         }
         $action = $action_controls[$action->post_excerpt]->prepare_action($action);
         $settings[$action->ID] = $action;
         if (count($settings) >= $limit) {
             break;
         }
     }
     if (1 === $limit) {
         $settings = reset($settings);
     }
     return $settings;
 }
 public static function get_settings_vars($id, $errors = array(), $message = '')
 {
     FrmAppHelper::permission_check('frm_edit_forms');
     global $frm_vars;
     $form = FrmForm::getOne($id);
     $fields = FrmField::get_all_for_form($id);
     $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
     if (isset($values['default_template']) && $values['default_template']) {
         wp_die(__('That template cannot be edited', 'formidable'));
     }
     $action_controls = FrmFormActionsController::get_form_actions();
     $sections = apply_filters('frm_add_form_settings_section', array(), $values);
     $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
     $styles = apply_filters('frm_get_style_opts', array());
     require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
 }
Example #5
0
 /**
  * @return int|boolean
  */
 public static function destroy($id)
 {
     global $wpdb;
     $form = self::getOne($id);
     if (!$form) {
         return false;
     }
     // Disconnect the entries from this form
     $entries = FrmDb::get_col($wpdb->prefix . 'frm_items', array('form_id' => $id));
     foreach ($entries as $entry_id) {
         FrmEntry::destroy($entry_id);
         unset($entry_id);
     }
     // Disconnect the fields from this form
     $wpdb->query($wpdb->prepare('DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id));
     $query_results = $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id));
     if ($query_results) {
         // Delete all form actions linked to this form
         $action_control = FrmFormActionsController::get_form_actions('email');
         $action_control->destroy($id, 'all');
         // Clear form caching
         self::clear_form_cache();
         do_action('frm_destroy_form', $id);
         do_action('frm_destroy_form_' . $id);
     }
     return $query_results;
 }
 public static function _posttax_row()
 {
     check_ajax_referer('frm_ajax', 'nonce');
     if (isset($_POST['field_id'])) {
         $field_vars = array('meta_name' => $_POST['meta_name'], 'field_id' => $_POST['field_id'], 'show_exclude' => (int) $_POST['show_exclude'], 'exclude_cat' => (int) $_POST['show_exclude'] ? '-1' : 0);
     } else {
         $field_vars = array('meta_name' => '', 'field_id' => '', 'show_exclude' => 0, 'exclude_cat' => 0);
     }
     $tax_meta = (int) $_POST['tax_key'];
     $post_type = sanitize_text_field($_POST['post_type']);
     $action_key = (int) $_POST['action_key'];
     $action_control = FrmFormActionsController::get_form_actions('wppost');
     $action_control->_set($action_key);
     if ($post_type) {
         $taxonomies = get_object_taxonomies($post_type);
     }
     $values = array();
     if (isset($_POST['form_id'])) {
         $values['fields'] = FrmField::getAll(array('fi.form_id' => (int) $_POST['form_id'], 'fi.type' => array('checkbox', 'radio', 'select', 'tag', 'data')), 'field_order');
         $values['id'] = (int) $_POST['form_id'];
     }
     $echo = false;
     include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-form-actions/_post_taxonomy_row.php';
     wp_die();
 }