function user_can_edit_check($entry, $form)
 {
     global $user_ID;
     if (!$user_ID) {
         return false;
     }
     if (is_numeric($form)) {
         $form = FrmForm::getOne($form);
     }
     $form->options = maybe_unserialize($form->options);
     //if editable and user can edit someone elses entry
     if ($form->editable and isset($form->options['open_editable']) and $form->options['open_editable'] and isset($form->options['open_editable_role']) and FrmAppHelper::user_has_permission($form->options['open_editable_role'])) {
         return true;
     }
     if (is_object($entry)) {
         if ($entry->user_id == $user_ID) {
             return true;
         } else {
             return false;
         }
     }
     $where = "user_id='{$user_ID}' and fr.id='{$form->id}'";
     if ($entry and !empty($entry)) {
         if (is_numeric($entry)) {
             $where .= ' and it.id=' . $entry;
         } else {
             $where .= " and item_key='" . $entry . "'";
         }
     }
     return FrmEntry::getAll($where, '', ' LIMIT 1', true);
 }
 public static function setup_edit_vars($post, $check_post = true)
 {
     if (!$post) {
         return false;
     }
     $values = (object) $post;
     $defaults = FrmProDisplaysHelper::get_default_opts();
     foreach (array('form_id', 'entry_id', 'post_id', 'dyncontent', 'param', 'type', 'show_count', 'insert_loc') as $var) {
         if ($check_post) {
             $values->{'frm_' . $var} = FrmAppHelper::get_param($var, get_post_meta($post->ID, 'frm_' . $var, true));
         } else {
             $values->{'frm_' . $var} = get_post_meta($post->ID, 'frm_' . $var, true);
         }
     }
     $options = get_post_meta($post->ID, 'frm_options', true);
     foreach ($defaults as $var => $default) {
         if (!isset($values->{'frm_' . $var})) {
             if ($check_post) {
                 $values->{'frm_' . $var} = FrmAppHelper::get_post_param('options[' . $var . ']', isset($options[$var]) ? $options[$var] : $default);
             } else {
                 $values->{'frm_' . $var} = isset($options[$var]) ? $options[$var] : $default;
             }
         } else {
             if ($var == 'param' and empty($values->{'frm_' . $var})) {
                 $values->{'frm_' . $var} = $default;
             }
         }
     }
     $values->frm_form_id = (int) $values->frm_form_id;
     $values->frm_order_by = empty($values->frm_order_by) ? array() : (array) $values->frm_order_by;
     $values->frm_order = empty($values->frm_order) ? array() : (array) $values->frm_order;
     return $values;
 }
Exemple #3
0
 function update($id, $values)
 {
     global $wpdb, $frmprodb, $frm_field;
     $new_values = array();
     $values['display_key'] = isset($values['display_key']) ? $values['display_key'] : $values['name'];
     $new_values['display_key'] = FrmAppHelper::get_unique_key($values['display_key'], $frmprodb->displays, 'display_key', $id);
     $new_values['param'] = isset($values['param']) ? sanitize_title_with_dashes($values['param']) : '';
     $fields = array('name', 'description', 'content', 'dyncontent', 'insert_loc', 'type', 'show_count', 'form_id', 'entry_id', 'post_id');
     foreach ($fields as $field) {
         $new_values[$field] = $values[$field];
     }
     $new_values['entry_id'] = isset($values['entry_id']) ? (int) $values['entry_id'] : 0;
     if (isset($values['options'])) {
         $new_values['options'] = array();
         foreach ($values['options'] as $key => $value) {
             $new_values['options'][$key] = $value;
         }
         $new_values['options'] = maybe_serialize($new_values['options']);
     }
     $query_results = $wpdb->update($frmprodb->displays, $new_values, array('id' => $id));
     if ($query_results) {
         wp_cache_delete($id, 'frm_display');
         do_action('frm_update_display', $id, $values);
     }
     return $query_results;
 }
    public static function pro_tip($callback, $html = '')
    {
        if (FrmAppHelper::pro_is_installed()) {
            return;
        }
        $tips = self::$callback();
        $tip = self::get_random_tip($tips);
        if ($html == 'p') {
            echo '<p>';
        }
        ?>
		<a href="<?php 
        echo esc_url(FrmAppHelper::make_affiliate_url($tip['link']));
        ?>
" target="_blank" class="frm_pro_tip">
			<span><i class="frm_icon_font frm_check1_icon"></i>  Pro Tip:</span>
			<?php 
        echo esc_html($tip['tip']);
        ?>
			<?php 
        if (isset($tip['call'])) {
            ?>
				<span><?php 
            echo esc_html($tip['call']);
            ?>
</span>
			<?php 
        }
        ?>
		</a>
		<?php 
        if ($html == 'p') {
            echo '</p>';
        }
    }
 public static function enqueue_jquery_css()
 {
     $theme_css = FrmStylesController::get_style_val('theme_css');
     if ($theme_css != -1) {
         wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
     }
 }
 public static function destroy()
 {
     $id = FrmAppHelper::simple_get('id', 'absint');
     $frm_style = new FrmStyle();
     $frm_style->destroy($id);
     $message = __('Your styling settings have been deleted.', 'formidable');
     self::edit('default', $message);
 }
 public static function license_settings()
 {
     $plugins = apply_filters('frm_installed_addons', array());
     if (empty($plugins)) {
         _e('There are no plugins on your site that require a license', 'formidable');
         return;
     }
     include FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php';
 }
 public static function load_css()
 {
     global $frmpro_settings;
     if (!is_admin()) {
         $use_saved = true;
     }
     include FrmAppHelper::plugin_path() . '/pro/css/custom_theme.css.php';
     die;
 }
 function route()
 {
     $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
     $action = FrmAppHelper::get_param($action);
     if ($action == 'process-form') {
         return $this->process_form();
     } else {
         return $this->display_form();
     }
 }
 /**
  * @covers FrmAppController::load_wp_admin_style
  */
 public function test_load_wp_admin_style()
 {
     $this->set_admin_screen();
     ob_start();
     do_action('admin_enqueue_scripts');
     do_action('admin_print_styles');
     $styles = ob_get_contents();
     ob_end_clean();
     $this->assertNotEmpty($styles);
     $this->assertTrue(strpos($styles, FrmAppHelper::plugin_url() . '/css/frm_fonts.css') !== false, 'The frm_fonts stylesheet is missing');
 }
Exemple #11
0
 function getAll($where = '', $order_by = '', $limit = '')
 {
     global $wpdb;
     $query = "SELECT * FROM {$this->table_name} " . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
     if ($limit == ' LIMIT 1') {
         $results = $wpdb->get_row($query);
     } else {
         $results = $wpdb->get_results($query);
     }
     return $results;
 }
 function get_default_field_opts($type, $field, $limit = false)
 {
     $field_options = array('size' => '', 'max' => '', 'label' => '', 'blank' => '', 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', 'custom_html' => '');
     if ($limit) {
         return $field_options;
     }
     global $frmdb, $frm_app_helper, $frm_settings;
     $form_id = is_numeric($field) ? $field : $field->form_id;
     $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $frmdb->fields, 'field_key') : $field->field_key;
     $field_count = $frm_app_helper->getRecordCount("form_id='{$form_id}'", $frmdb->fields);
     return array('name' => __('Untitled', 'formidable'), 'description' => '', 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', 'field_order' => $field_count + 1, 'required' => false, 'blank' => __('This field cannot be blank', 'formidable'), 'invalid' => __('This field is invalid', 'formidable'), 'form_id' => $form_id, 'field_options' => $field_options);
 }
 public static function route($stop_load = false)
 {
     $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
     $action = FrmAppHelper::get_param($action, '', 'get', 'sanitize_title');
     if ($action == 'process-form') {
         return self::process_form($stop_load);
     } else {
         if ($stop_load != 'stop_load') {
             return self::display_form();
         }
     }
 }
 public function test_add_js()
 {
     $frm_settings = FrmAppHelper::get_settings();
     global $frm_vars;
     if ($frm_settings->jquery_css) {
         $this->assertNotEmpty($frm_vars['datepicker_loaded']);
     }
     if ($frm_settings->accordion_js) {
         $this->assertTrue(wp_script_is('jquery-ui-widget', 'enqueued'));
         $this->assertTrue(wp_script_is('jquery-ui-accordion', 'enqueued'));
     }
 }
 function setUp()
 {
     parent::setUp();
     FrmAppController::install();
     $this->import_xml();
     $this->factory->form = new Form_Factory($this);
     $this->factory->field = new Field_Factory($this);
     $this->factory->entry = new Entry_Factory($this);
     $this->is_pro_active = FrmAppHelper::pro_is_installed();
     $current_class_name = get_class($this);
     if (strpos($current_class_name, 'FrmPro') && !$this->is_pro_active) {
         $this->markTestSkipped('Pro is not active');
     }
 }
 function setup_edit_vars($values)
 {
     global $frm_form, $frmpro_settings;
     $record = $frm_form->getOne($values['id']);
     foreach (array('logged_in' => $record->logged_in, 'editable' => $record->editable) as $var => $default) {
         $values[$var] = FrmAppHelper::get_param($var, $default);
     }
     foreach (FrmProFormsHelper::get_default_opts() as $opt => $default) {
         if (!isset($values[$opt])) {
             $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $default;
         }
     }
     $values['also_email_to'] = (array) $values['also_email_to'];
     return $values;
 }
    public static function head()
    {
        FrmSettingsController::route('stop_load');
        wp_enqueue_script('jquery-frm-themepicker');
        ?>
<link type="text/css" rel="stylesheet" href="http<?php 
        echo is_ssl() ? 's' : '';
        ?>
://ajax.googleapis.com/ajax/libs/jqueryui/1.7.3/themes/base/ui.all.css" />
<link href="<?php 
        echo admin_url('admin-ajax.php');
        ?>
?action=frmpro_css" type="text/css" rel="Stylesheet" class="frm-custom-theme"/>
<?php 
        require FrmAppHelper::plugin_path() . '/classes/views/shared/head.php';
    }
Exemple #18
0
 function update($id, $values)
 {
     global $wpdb, $frmdb;
     if (isset($values['field_key'])) {
         $values['field_key'] = FrmAppHelper::get_unique_key($values['field_key'], $frmdb->fields, 'field_key', $id);
     }
     if (isset($values['field_options']) and is_array($values['field_options'])) {
         $values['field_options'] = serialize($values['field_options']);
     }
     $query_results = $wpdb->update($frmdb->fields, $values, array('id' => $id));
     unset($values);
     if ($query_results) {
         wp_cache_delete($id, 'frm_field');
     }
     return $query_results;
 }
 function setup_edit_vars($record)
 {
     if (!$record) {
         return false;
     }
     $values = array();
     $values['id'] = $record->id;
     foreach (array('name', 'description', 'display_key', 'form_id', 'entry_id', 'post_id', 'content', 'dyncontent', 'param', 'type', 'show_count', 'insert_loc') as $var) {
         $values[$var] = stripslashes(FrmAppHelper::get_param($var, $record->{$var}));
     }
     $options = maybe_unserialize($record->options);
     foreach (FrmProDisplaysHelper::get_default_opts() as $var => $default) {
         if (!isset($values[$var])) {
             $values[$var] = stripslashes_deep(FrmAppHelper::get_post_param('options[' . $var . ']', isset($options[$var]) ? $options[$var] : $default));
         }
     }
     return $values;
 }
 /**
  * Make sure the stylesheet is loaded at the right times
  */
 public function test_front_head()
 {
     $this->set_front_end();
     if (defined('DOING_AJAX') && DOING_AJAX) {
         $this->markTestSkipped('Run with --group styles');
     }
     ob_start();
     do_action('wp_head');
     $styles = ob_get_contents();
     ob_end_clean();
     $this->assertNotEmpty($styles);
     $frm_settings = FrmAppHelper::get_settings();
     $stylesheet_urls = $this->get_custom_stylesheet();
     $style_included = strpos($styles, $stylesheet_urls['formidable']);
     if ($frm_settings->load_style == 'all') {
         $this->assertTrue($style_included !== false, 'The formidablepro stylesheet is missing');
     } else {
         $this->assertFalse($style_included, 'The formidablepro stylesheet is included when it should not be');
     }
 }
Exemple #21
0
 public static function uninstall()
 {
     if (!current_user_can('administrator')) {
         $frm_settings = FrmAppHelper::get_settings();
         wp_die($frm_settings->admin_permission);
     }
     global $wpdb;
     $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'frm_display');
     delete_option('frmpro_options');
     delete_option('frmpro_db_version');
     //locations
     delete_option('frm_usloc_options');
     delete_option('frmpro_copies_db_version');
     delete_option('frmpro_copies_checked');
     // updating
     delete_site_option('frmpro-authorized');
     delete_site_option('frmpro-credentials');
     delete_site_option('frm_autoupdate');
     delete_site_option('frmpro-wpmu-sitewide');
 }
Exemple #22
0
 function FrmCptUpdate()
 {
     if (!class_exists('FrmUpdatesController') and !class_exists('FrmUpdate')) {
         return;
     }
     // Where all the vitals are defined for this plugin
     $this->plugin_nicename = 'formidable-math-captcha';
     $this->plugin_name = 'formidable-math-captcha/formidable-math-captcha.php';
     $this->pro_last_checked_store = 'frmcpt_last_check';
     $this->pro_check_interval = 60 * 60 * 24;
     // Checking every 24 hours
     add_filter('site_transient_update_plugins', array(&$this, 'queue_update'));
     if (method_exists('FrmAppHelper', 'plugin_version')) {
         $this->version = FrmAppHelper::plugin_version();
     } else {
         global $frm_version;
         $this->version = $frm_version;
     }
     if (version_compare($this->version, '1.07.0rc1', '<')) {
         add_filter('pre_set_site_transient_update_plugins', array(&$this, 'queue_old_update'));
     }
     //Deprecated
 }
 function allow_form_edit($action, $form)
 {
     global $user_ID;
     if (!$form or !$form->editable or !$user_ID) {
         return $action;
     }
     $form_options = maybe_unserialize($form->options);
     if (isset($form_options['single_entry']) and $form_options['single_entry'] and $form_options['single_entry_type'] == 'user' and $action != 'destroy') {
         if ($action == 'update' and $form->id == FrmAppHelper::get_param('form_id')) {
             //don't change the action is this is the wrong form
         } else {
             global $frmdb;
             $meta = $frmdb->get_var($frmdb->entries, array('user_id' => $user_ID, 'form_id' => $form->id));
             if ($meta) {
                 $action = 'edit';
             }
         }
     }
     if ($action == 'edit' and isset($form_options['editable_role']) and !FrmAppHelper::user_has_permission($form_options['editable_role'])) {
         $action = 'new';
     }
     return $action;
 }
            $fo->field_options = maybe_unserialize($fo->field_options);
            if (isset($fo->field_options['form_select'])) {
                $fo->form_select = $fo->field_options['form_select'];
            }
            $fo = (array) $fo;
        }
        if (in_array($fo['type'], array('checkbox', 'radio', 'select', 'tag')) || $fo['type'] == 'data' && isset($fo['form_select']) && $fo['form_select'] == 'taxonomy') {
            ?>
            <option value="<?php 
            echo $fo['id'];
            ?>
" <?php 
            selected($field_vars['field_id'], $fo['id']);
            ?>
><?php 
            echo FrmAppHelper::truncate($fo['name'], 50);
            ?>
</option>
        <?php 
            if ($field_vars['field_id'] == $fo['id']) {
                $selected_type = $fo['type'];
            }
        }
        unset($fo);
    }
}
?>
    </select>

<?php 
if ($selected_type == 'tag') {
 private static function migrate_email_settings_to_action($form_options, $form_id, $post_type, &$imported, $switch)
 {
     // No old notifications or autoresponders to carry over
     if (!isset($form_options['auto_responder']) && !isset($form_options['notification']) && !isset($form_options['email_to'])) {
         return;
     }
     // Initialize notifications array
     $notifications = array();
     // Migrate regular notifications
     self::migrate_notifications_to_action($form_options, $form_id, $notifications);
     // Migrate autoresponders
     self::migrate_autoresponder_to_action($form_options, $form_id, $notifications);
     if (empty($notifications)) {
         return;
     }
     foreach ($notifications as $new_notification) {
         $new_notification['post_type'] = $post_type;
         $new_notification['post_excerpt'] = 'email';
         $new_notification['post_title'] = __('Email Notification', 'formidable');
         $new_notification['menu_order'] = $form_id;
         $new_notification['post_status'] = 'publish';
         // Switch field IDs and keys, if needed
         if ($switch) {
             // Switch field IDs in email conditional logic
             self::switch_email_contition_field_ids($new_notification['post_content']);
             // Switch all other field IDs in email
             $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids($new_notification['post_content']);
         }
         $new_notification['post_content'] = FrmAppHelper::prepare_and_encode($new_notification['post_content']);
         $exists = get_posts(array('name' => $new_notification['post_name'], 'post_type' => $new_notification['post_type'], 'post_status' => $new_notification['post_status'], 'numberposts' => 1));
         if (empty($exists)) {
             FrmAppHelper::save_json_post($new_notification);
             $imported['imported']['actions']++;
         }
         unset($new_notification);
     }
 }
 public static function entry_array_to_string($values)
 {
     $content = '';
     foreach ($values['item_meta'] as $val) {
         if ($content != '') {
             $content .= "\n\n";
         }
         if (is_array($val)) {
             $val = FrmAppHelper::array_flatten($val);
             $val = implode(',', $val);
         }
         $content .= $val;
     }
     return $content;
 }
 public static function page_route($content)
 {
     global $post;
     $frm_settings = FrmAppHelper::get_settings();
     if ($post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form'])) {
         $content = FrmFormsController::page_preview();
     }
     return $content;
 }
Exemple #28
0
<div id="form_views_page" class="wrap">
    <div class="frmicon icon32"><br/></div>
    <h2>
        <?php 
_e('Views', 'formidable');
?>
        <a href="#" class="add-new-h2" style="visibility:hidden;"><?php 
_e('Add New', 'formidable');
?>
</a>
    </h2>

    <?php 
if ($form) {
    FrmAppController::get_form_nav($form);
}
require FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php';
FrmAppController::update_message('display collected data in lists, calendars, and other formats');
?>

    <img src="http://fp.strategy11.com/images/custom-display-settings.png" alt="Display" style="max-width:100%"/>

</div>
 /**
  * Load the JS file on non-Formidable pages in the admin area
  * @since 2.0
  */
 public static function load_admin_wide_js($load = true)
 {
     $version = FrmAppHelper::plugin_version();
     wp_register_script('formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array('jquery'), $version);
     wp_localize_script('formidable_admin_global', 'frmGlobal', array('updating_msg' => __('Please wait while your site updates.', 'formidable'), 'deauthorize' => __('Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable'), 'url' => FrmAppHelper::plugin_url(), 'loading' => __('Loading&hellip;'), 'nonce' => wp_create_nonce('frm_ajax')));
     if ($load) {
         wp_enqueue_script('formidable_admin_global');
     }
 }
Exemple #30
0
                                        ?>
" />
<?php 
                                        echo FrmProFieldsHelper::get_file_icon($field['value']);
                                    }
                                }
                                include_once FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-entries/loading.php';
                            } else {
                                if ($field['type'] == 'data') {
                                    ?>
<div id="frm_data_field_<?php 
                                    echo $field['id'];
                                    ?>
_container">
<?php 
                                    require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/data-options.php';
                                    ?>
</div>
<?php 
                                } else {
                                    if ($field['type'] == 'form') {
                                        echo 'FRONT FORM';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }