コード例 #1
1
 /**
  * @since 2.0.11
  */
 public static function update_single_field($atts)
 {
     if (empty($atts['entry_id'])) {
         return;
     }
     $field = $atts['field_id'];
     FrmField::maybe_get_field($field);
     if (!$field) {
         return;
     }
     if (isset($field->field_options['post_field']) && !empty($field->field_options['post_field'])) {
         $post_id = FrmDb::get_var('frm_items', array('id' => $atts['entry_id']), 'post_id');
     } else {
         $post_id = false;
     }
     global $wpdb;
     if (!$post_id) {
         $updated = FrmEntryMeta::update_entry_meta($atts['entry_id'], $field->id, null, $atts['value']);
         if (!$updated) {
             $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE item_id = %d and field_id = %d", $atts['entry_id'], $field->id));
             $updated = FrmEntryMeta::add_entry_meta($atts['entry_id'], $field->id, '', $atts['value']);
         }
         wp_cache_delete($atts['entry_id'], 'frm_entry');
     } else {
         switch ($field->field_options['post_field']) {
             case 'post_custom':
                 $updated = update_post_meta($post_id, $field->field_options['custom_field'], maybe_serialize($atts['value']));
                 break;
             case 'post_category':
                 $taxonomy = !FrmField::is_option_empty($field, 'taxonomy') ? $field->field_options['taxonomy'] : 'category';
                 $updated = wp_set_post_terms($post_id, $atts['value'], $taxonomy);
                 break;
             default:
                 $post = get_post($post_id, ARRAY_A);
                 $post[$field->field_options['post_field']] = maybe_serialize($atts['value']);
                 $updated = wp_insert_post($post);
                 break;
         }
     }
     if ($updated) {
         // set updated_at time
         $wpdb->update($wpdb->prefix . 'frm_items', array('updated_at' => current_time('mysql', 1), 'updated_by' => get_current_user_id()), array('id' => $atts['entry_id']));
     }
     $atts['field_id'] = $field->id;
     $atts['field'] = $field;
     do_action('frm_after_update_field', $atts);
     return $updated;
 }
コード例 #2
0
 public static function formidable_shortcode_atts($atts, $all_atts)
 {
     global $frm_vars, $wpdb;
     // reset globals
     $frm_vars['readonly'] = $atts['readonly'];
     $frm_vars['editing_entry'] = false;
     $frm_vars['show_fields'] = array();
     $frm_vars['editing_entry'] = false;
     if (!is_array($atts['fields'])) {
         $frm_vars['show_fields'] = explode(',', $atts['fields']);
     }
     if (!empty($atts['exclude_fields'])) {
         if (!is_array($atts['exclude_fields'])) {
             $atts['exclude_fields'] = explode(',', $atts['exclude_fields']);
         }
         $query = array('form_id' => (int) $atts['id'], 'id NOT' => $atts['exclude_fields'], 'field_key NOT' => $atts['exclude_fields']);
         $frm_vars['show_fields'] = FrmDb::get_col($wpdb->prefix . 'frm_fields', $query);
     }
     if ($atts['entry_id'] && $atts['entry_id'] == 'last') {
         $user_ID = get_current_user_id();
         if ($user_ID) {
             $frm_vars['editing_entry'] = FrmDb::get_var($wpdb->prefix . 'frm_items', array('form_id' => $atts['id'], 'user_id' => $user_ID), 'id', array('order_by' => 'created_at DESC'));
         }
     } else {
         if ($atts['entry_id']) {
             $frm_vars['editing_entry'] = $atts['entry_id'];
         }
     }
     foreach ($atts as $unset => $val) {
         if (is_array($all_atts) && isset($all_atts[$unset])) {
             unset($all_atts[$unset]);
         }
         unset($unset, $val);
     }
     if (is_array($all_atts)) {
         foreach ($all_atts as $att => $val) {
             $_GET[$att] = urlencode($val);
             unset($att, $val);
         }
     }
 }
コード例 #3
0
    public static function get_shortcode_select($form_id, $target_id = 'content', $type = 'all')
    {
        $field_list = array();
        $exclude = FrmField::no_save_fields();
        if (is_numeric($form_id)) {
            if ($type == 'field_opt') {
                $exclude[] = 'data';
                $exclude[] = 'checkbox';
            }
            $field_list = FrmField::get_all_for_form($form_id, '', 'include');
        }
        $linked_forms = array();
        ?>
        <select class="frm_shortcode_select frm_insert_val" data-target="<?php 
        echo esc_attr($target_id);
        ?>
">
            <option value="">&mdash; <?php 
        _e('Select a value to insert into the box below', 'formidable');
        ?>
 &mdash;</option>
            <?php 
        if ($type != 'field_opt' && $type != 'calc') {
            ?>
            <option value="id"><?php 
            _e('Entry ID', 'formidable');
            ?>
</option>
            <option value="key"><?php 
            _e('Entry Key', 'formidable');
            ?>
</option>
            <option value="post_id"><?php 
            _e('Post ID', 'formidable');
            ?>
</option>
            <option value="ip"><?php 
            _e('User IP', 'formidable');
            ?>
</option>
            <option value="created-at"><?php 
            _e('Entry creation date', 'formidable');
            ?>
</option>
            <option value="updated-at"><?php 
            _e('Entry update date', 'formidable');
            ?>
</option>

			<optgroup label="<?php 
            esc_attr_e('Form Fields', 'formidable');
            ?>
">
            <?php 
        }
        if (!empty($field_list)) {
            foreach ($field_list as $field) {
                if (in_array($field->type, $exclude)) {
                    continue;
                }
                if ($type != 'calc' && FrmProField::is_list_field($field)) {
                    continue;
                }
                ?>
                <option value="<?php 
                echo esc_attr($field->id);
                ?>
"><?php 
                echo $field_name = esc_html(FrmAppHelper::truncate($field->name, 60));
                ?>
 (<?php 
                _e('ID', 'formidable');
                ?>
)</option>
                <option value="<?php 
                echo esc_attr($field->field_key);
                ?>
"><?php 
                echo $field_name;
                ?>
 (<?php 
                _e('Key', 'formidable');
                ?>
)</option>
                <?php 
                if ($field->type == 'file' && $type != 'field_opt' && $type != 'calc') {
                    ?>
                    <option class="frm_subopt" value="<?php 
                    echo esc_attr($field->field_key);
                    ?>
 size=thumbnail"><?php 
                    _e('Thumbnail', 'formidable');
                    ?>
</option>
                    <option class="frm_subopt" value="<?php 
                    echo esc_attr($field->field_key);
                    ?>
 size=medium"><?php 
                    _e('Medium', 'formidable');
                    ?>
</option>
                    <option class="frm_subopt" value="<?php 
                    echo esc_attr($field->field_key);
                    ?>
 size=large"><?php 
                    _e('Large', 'formidable');
                    ?>
</option>
                    <option class="frm_subopt" value="<?php 
                    echo esc_attr($field->field_key);
                    ?>
 size=full"><?php 
                    _e('Full Size', 'formidable');
                    ?>
</option>
                <?php 
                } else {
                    if ($field->type == 'data') {
                        //get all fields from linked form
                        if (isset($field->field_options['form_select']) && is_numeric($field->field_options['form_select'])) {
                            $linked_form = FrmDb::get_var('frm_fields', array('id' => $field->field_options['form_select']), 'form_id');
                            if (!in_array($linked_form, $linked_forms)) {
                                $linked_forms[] = $linked_form;
                                $linked_fields = FrmField::getAll(array('fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => (int) $linked_form));
                                foreach ($linked_fields as $linked_field) {
                                    ?>
                    <option class="frm_subopt" value="<?php 
                                    echo esc_attr($field->id . ' show=' . $linked_field->id);
                                    ?>
"><?php 
                                    echo esc_html(FrmAppHelper::truncate($linked_field->name, 60));
                                    ?>
 (<?php 
                                    _e('ID', 'formidable');
                                    ?>
)</option>
                    <option class="frm_subopt" value="<?php 
                                    echo esc_attr($field->field_key . ' show=' . $linked_field->field_key);
                                    ?>
"><?php 
                                    echo esc_html(FrmAppHelper::truncate($linked_field->name, 60));
                                    ?>
 (<?php 
                                    _e('Key', 'formidable');
                                    ?>
)</option>
                    <?php 
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($type != 'field_opt' && $type != 'calc') {
            ?>
            </optgroup>
			<optgroup label="<?php 
            esc_attr_e('Helpers', 'formidable');
            ?>
">
                <option value="editlink"><?php 
            _e('Admin link to edit the entry', 'formidable');
            ?>
</option>
                <?php 
            if ($target_id == 'content') {
                ?>
                <option value="detaillink"><?php 
                _e('Link to view single page if showing dynamic entries', 'formidable');
                ?>
</option>
                <?php 
            }
            if ($type != 'email') {
                ?>
                <option value="evenodd"><?php 
                _e('Add a rotating \'even\' or \'odd\' class', 'formidable');
                ?>
</option>
                <?php 
            } else {
                if ($target_id == 'email_message') {
                    ?>
                <option value="default-message"><?php 
                    _e('Default Email Message', 'formidable');
                    ?>
</option>
                <?php 
                }
            }
            ?>
                <option value="siteurl"><?php 
            _e('Site URL', 'formidable');
            ?>
</option>
                <option value="sitename"><?php 
            _e('Site Name', 'formidable');
            ?>
</option>
            </optgroup>
            <?php 
        }
        ?>
        </select>
    <?php 
    }
コード例 #4
0
ファイル: FrmProDisplay.php プロジェクト: swc-dng/swcsandbox
 /**
  * Check for a qualified view.
  * Qualified:   1. set to show calendar or dynamic
  *              2. published
  *              3. form has posts/entry is linked to a post
  */
 public static function get_auto_custom_display($args)
 {
     $defaults = array('post_id' => false, 'form_id' => false, 'entry_id' => false);
     $args = wp_parse_args($args, $defaults);
     global $wpdb;
     if ($args['form_id']) {
         $display_ids = self::get_display_ids_by_form($args['form_id']);
         if (!$display_ids) {
             return false;
         }
         if (!$args['post_id'] && !$args['entry_id']) {
             //does form have posts?
             $args['entry_id'] = FrmDb::get_var('frm_items', array('form_id' => $args['form_id']), 'post_id');
         }
     }
     if ($args['post_id'] && !$args['entry_id']) {
         //is post linked to an entry?
         $args['entry_id'] = FrmDb::get_var($wpdb->prefix . 'frm_items', array('post_id' => $args['post_id']));
         //is post selected for auto-insertion?
         if (!$args['entry_id']) {
             $query = array('meta_key' => 'frm_post_id', 'meta_value' => $args['post_id']);
             if (isset($display_ids)) {
                 $query['post_ID'] = $display_ids;
             }
             $display_ids = FrmDb::get_col($wpdb->postmeta, $query, 'post_ID');
             if (!$display_ids) {
                 return false;
             }
         }
     }
     //this post does not have an auto display
     if (!$args['entry_id']) {
         return false;
     }
     $query = array('pm.meta_key' => 'frm_show_count', 'post_type' => 'frm_display', 'pm.meta_value' => array('dynamic', 'calendar', 'one'), 'p.post_status' => 'publish');
     if (isset($display_ids)) {
         $query['p.ID'] = $display_ids;
     }
     $display = FrmDb::get_row($wpdb->posts . ' p LEFT JOIN ' . $wpdb->postmeta . ' pm ON (p.ID = pm.post_ID)', $query, 'p.*', array('order_by' => 'p.ID ASC'));
     return $display;
 }
コード例 #5
0
 public static function entry_update_field($atts)
 {
     global $frm_vars, $post, $frm_update_link, $wpdb;
     $atts = shortcode_atts(array('id' => isset($frm_vars['editing_entry']) ? $frm_vars['editing_entry'] : false, 'field_id' => false, 'form_id' => false, 'label' => __('Update', 'formidable'), 'class' => '', 'value' => '', 'message' => '', 'title' => '', 'allow' => ''), $atts);
     $entry_id = $atts['id'] && is_numeric($atts['id']) ? absint($atts['id']) : FrmAppHelper::get_param('entry', false, 'get', 'absint');
     if (!$entry_id || empty($entry_id)) {
         return;
     }
     if (!$atts['form_id']) {
         $atts['form_id'] = (int) FrmDb::get_var($wpdb->prefix . 'frm_items', array('id' => $entry_id), 'form_id');
     }
     if ($atts['allow'] != 'everyone' && !FrmProEntriesHelper::user_can_edit($entry_id, $atts['form_id'])) {
         return;
     }
     $field = FrmField::getOne($atts['field_id']);
     if (!$field) {
         return;
     }
     if (!is_numeric($atts['field_id'])) {
         $atts['field_id'] = $field->id;
     }
     //check if current value is equal to new value
     $current_val = FrmProEntryMetaHelper::get_post_or_meta_value($entry_id, $field);
     if ($current_val == $atts['value']) {
         return;
     }
     if (!$frm_update_link) {
         $frm_update_link = array();
     }
     $num = isset($frm_update_link[$entry_id . '-' . $atts['field_id']]) ? $frm_update_link[$entry_id . '-' . $atts['field_id']] : 0;
     $num = (int) $num + 1;
     $frm_update_link[$entry_id . '-' . $atts['field_id']] = $num;
     if (empty($atts['title'])) {
         $atts['title'] = $atts['label'];
     }
     $link = '<a href="#" onclick="frmUpdateField(' . $entry_id . ',' . $atts['field_id'] . ',\'' . $atts['value'] . '\',\'' . htmlspecialchars(str_replace("'", '\\"', $atts['message'])) . '\',' . $num . ');return false;" id="frm_update_field_' . $entry_id . '_' . $atts['field_id'] . '_' . $num . '" class="frm_update_field_link ' . $atts['class'] . '" title="' . esc_attr($atts['title']) . '">' . $atts['label'] . '</a>';
     return $link;
 }
コード例 #6
0
ファイル: FrmForm.php プロジェクト: mazykin46/portfolio
 /**
  * @param int $id
  * @return string form key
  */
 public static function &getKeyById($id)
 {
     $id = (int) $id;
     $cache = FrmAppHelper::check_cache($id, 'frm_form');
     if ($cache) {
         return $cache->form_key;
     }
     $key = FrmDb::get_var('frm_forms', array('id' => $id), 'form_key');
     return $key;
 }
コード例 #7
0
 /**
  * @param string $id
  */
 public static function &exists($id)
 {
     global $wpdb;
     if (FrmAppHelper::check_cache($id, 'frm_entry')) {
         $exists = true;
         return $exists;
     }
     if (is_numeric($id)) {
         $where = array('id' => $id);
     } else {
         $where = array('item_key' => $id);
     }
     $id = FrmDb::get_var($wpdb->prefix . 'frm_items', $where);
     $exists = $id && $id > 0 ? true : false;
     return $exists;
 }
コード例 #8
0
ファイル: FrmProForm.php プロジェクト: swc-dng/swcsandbox
 public static function is_ajax_on($form)
 {
     $ajax = isset($form->options['ajax_submit']) ? $form->options['ajax_submit'] : 0;
     if ($ajax) {
         $no_ajax_fields = array('file');
         $where = array(array('or' => 1, 'form.id' => $form->id, 'form.parent_form_id' => $form->id), 'type' => $no_ajax_fields);
         if (isset($_POST['frm_page_order_' . $form->id])) {
             $where['field_order <'] = absint($_POST['frm_page_order_' . $form->id]) - 1;
         }
         global $wpdb;
         $no_ajax = FrmDb::get_var($wpdb->prefix . 'frm_fields field INNER JOIN ' . $wpdb->prefix . 'frm_forms form ON field.form_id = form.id', $where, 'field.id');
         $ajax = $no_ajax ? false : true;
     }
     return $ajax;
 }
コード例 #9
0
ファイル: FrmField.php プロジェクト: EyesX/formidable-forms
 /**
  * @param string $key
  * @return int field id
  */
 public static function get_id_by_key($key)
 {
     $id = FrmDb::get_var('frm_fields', array('field_key' => sanitize_title($key)));
     return $id;
 }
コード例 #10
0
ファイル: mb_adv_info.php プロジェクト: tshdvs/GooseMobile
 $linked_forms[] = array();
 foreach ($fields as $f) {
     if (FrmField::is_repeating_field($f)) {
         $repeat_field = $f->id;
     }
     if (FrmField::is_no_save_field($f->type)) {
         continue;
     }
     if ($f->type == 'data' && (!isset($f->field_options['data_type']) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '')) {
         continue;
     }
     FrmAppHelper::insert_opt_html(array('id' => $f->id, 'key' => $f->field_key, 'name' => $f->name, 'type' => $f->type));
     if ($f->type == 'data') {
         //get all fields from linked form
         if (isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select'])) {
             $linked_form = FrmDb::get_var($wpdb->prefix . 'frm_fields', array('id' => $f->field_options['form_select']), 'form_id');
             if (!in_array($linked_form, $linked_forms)) {
                 $linked_forms[] = $linked_form;
                 $linked_fields = FrmField::getAll(array('fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form));
                 $ldfe = '';
                 if ($linked_fields) {
                     foreach ($linked_fields as $linked_field) {
                         FrmAppHelper::insert_opt_html(array('id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type));
                         $ldfe = $linked_field->id;
                         unset($linked_field);
                     }
                 }
             }
         }
         $dfe = $f->id;
     }
コード例 #11
0
 public static function get_dfe_id($value, $field, $ids = array())
 {
     global $wpdb;
     if (!$field || FrmProField::is_list_field($field)) {
         return $value;
     }
     if (!empty($ids) && is_numeric($value) && isset($ids[$value])) {
         // the entry was just imported, so we have the id
         return $ids[$value];
     }
     if (!is_array($value)) {
         $new_id = FrmDb::get_var('frm_item_metas', array('field_id' => $field->field_options['form_select'], 'meta_value' => $value), 'item_id');
         if ($new_id && is_numeric($new_id)) {
             return $new_id;
         }
         unset($new_id);
     }
     if (!is_array($value) && strpos($value, ',')) {
         $checked = maybe_unserialize($value);
         if (!is_array($checked)) {
             $checked = explode(',', $checked);
         }
     } else {
         $checked = $value;
     }
     if (!$checked || !is_array($checked)) {
         return $value;
     }
     $value = array_map('trim', $checked);
     foreach ($value as $dfe_k => $dfe_id) {
         $query = array('field_id' => $field->field_options['form_select'], 'meta_value' => $dfe_id);
         $new_id = FrmDb::get_var('frm_item_metas', $query, 'item_id');
         if ($new_id) {
             $value[$dfe_k] = $new_id;
         }
         unset($new_id);
     }
     unset($checked);
     return $value;
 }
コード例 #12
0
 public static 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 $wpdb;
     $form_id = is_numeric($field) ? $field : $field->form_id;
     $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix . 'frm_fields', 'field_key') : $field->field_key;
     $field_count = FrmDb::get_var('frm_fields', array('form_id' => $form_id), 'field_order', array('order_by' => 'field_order DESC'));
     $frm_settings = FrmAppHelper::get_settings();
     return array('name' => __('Untitled', 'formidable'), 'description' => '', 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', 'field_order' => $field_count + 1, 'required' => false, 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, 'invalid' => __('This field is invalid', 'formidable'), 'form_id' => $form_id, 'field_options' => $field_options);
 }
コード例 #13
0
ファイル: FrmProPost.php プロジェクト: swc-dng/swcsandbox
 public static function destroy_post($entry_id, $entry = false)
 {
     global $wpdb;
     if ($entry) {
         $post_id = $entry->post_id;
     } else {
         $post_id = FrmDb::get_var($wpdb->prefix . 'frm_items', array('id' => $entry_id), 'post_id');
     }
     // delete child entries
     $child_entries = FrmDb::get_col($wpdb->prefix . 'frm_items', array('parent_item_id' => $entry_id));
     foreach ($child_entries as $child_entry) {
         FrmEntry::destroy($child_entry);
     }
     // Remove hook to make things consistent
     // Due to a WP bug, this hook won't be used for parent entry when there are child entries
     remove_action('frm_before_destroy_entry', 'FrmProFormActionsController::trigger_delete_actions', 20, 2);
     // Trigger delete actions for parent entry
     FrmProFormActionsController::trigger_delete_actions($entry_id, $entry);
     if ($post_id) {
         wp_delete_post($post_id);
     }
 }
コード例 #14
0
 public static function graph_shortcode($atts)
 {
     $defaults = array('id' => false, 'id2' => false, 'id3' => false, 'id4' => false, 'ids' => array(), 'colors' => '', 'grid_color' => '#CCC', 'is3d' => false, 'height' => 400, 'width' => 400, 'truncate_label' => 7, 'bg_color' => '#FFFFFF', 'truncate' => 40, 'response_count' => 10, 'user_id' => false, 'entry_id' => false, 'title' => '', 'type' => 'default', 'x_axis' => false, 'data_type' => 'count', 'limit' => '', 'show_key' => false, 'min' => '', 'max' => '', 'y_title' => '', 'x_title' => '', 'include_zero' => false, 'field' => false, 'title_size' => '', 'title_font' => '', 'tooltip_label' => '', 'start_date' => '', 'end_date' => '', 'x_start' => '', 'x_end' => '', 'group_by' => '', 'x_order' => 'default', 'atts' => false);
     // TODO: Remove limit from docs, add x_order='desc' and x_order='field_options'
     // Remove id from docs. Just use ids to simplify.
     // Remove either x start or start_date from docs
     // Remove either x_end or end_date from docs
     // Make sure x_order is set up to work with abc
     // If no id, stop now
     if (!$atts || !$atts['id']) {
         echo __('You must include a field id or key in your graph shortcode.', 'formidable');
         return;
     }
     if (isset($atts['type']) && $atts['type'] == 'geo') {
         $defaults['truncate_label'] = 100;
         $defaults['width'] = 600;
     }
     if (isset($atts['include_js'])) {
         unset($atts['include_js']);
     }
     // Set up array for filtering fields
     // TODO: Ask about simpler way
     $temp_atts = $atts;
     foreach ($defaults as $unset => $val) {
         unset($temp_atts[$unset], $unset, $val);
     }
     foreach ($temp_atts as $unset => $val) {
         unset($atts[$unset]);
         $atts['atts'][$unset] = $val;
         unset($unset, $val);
     }
     // User's values should override default values
     $atts = array_merge($defaults, $atts);
     global $wpdb;
     // Reverse compatibility for id2, id3, and id4
     if (!$atts['ids'] && ($atts['id2'] || $atts['id3'] || $atts['id4'])) {
         _deprecated_argument(__FUNCTION__, '1.07.05', __('id2, id3, and id4 are deprecated. Please use ids instead.', 'formidable'));
         $atts['ids'] = array($atts['id2'], $atts['id3'], $atts['id4']);
         $atts['ids'] = implode(',', $atts['ids']);
         unset($atts['id2'], $atts['id3'], $atts['id4']);
     }
     //x_start and start_date do the same thing
     // Reverse compatibility for x_start
     if ($atts['start_date'] || $atts['x_start']) {
         if ($atts['x_start']) {
             $atts['start_date'] = $atts['x_start'];
             unset($atts['x_start']);
         }
         $atts['start_date'] = FrmAppHelper::replace_quotes($atts['start_date']);
     }
     //x_end and end_date do the same thing
     // Reverse compatibility for x_end
     if ($atts['end_date'] || $atts['x_end']) {
         if ($atts['x_end']) {
             $atts['end_date'] = $atts['x_end'];
             unset($atts['x_end']);
         }
         $atts['end_date'] = FrmAppHelper::replace_quotes($atts['end_date']);
     }
     // Reverse compatibility for x_order=0
     if (!$atts['x_order']) {
         $atts['x_order'] = 'field_opts';
     }
     // If limit is set, get only the top results
     if ($atts['limit']) {
         $atts['x_order'] = 'desc';
     }
     $atts['user_id'] = FrmAppHelper::get_user_id_param($atts['user_id']);
     if ($atts['entry_id']) {
         $atts['entry_id'] = explode(',', $atts['entry_id']);
         //make sure all values are numeric
         //TODO: Make this work with entry keys
         $atts['entry_id'] = array_filter($atts['entry_id'], 'is_numeric');
         if (empty($atts['entry_id'])) {
             // don't continue if there are no entry ids
             return;
         }
         $atts['entry_id'] = implode(',', $atts['entry_id']);
     }
     // Switch to entry_ids for easier reference
     $atts['entry_ids'] = $atts['entry_id'];
     unset($atts['entry_id']);
     //Convert $tooltip_label to array
     if ($atts['tooltip_label']) {
         $atts['tooltip_label'] = explode(',', $atts['tooltip_label']);
     }
     // This will only be an object when coming from show()
     if (is_object($atts['field'])) {
         $fields = array($atts['field']);
         // If creating multiple graphs with one shortcode
     } else {
         $atts['id'] = explode(',', $atts['id']);
         foreach ($atts['id'] as $key => $id) {
             //If using field keys, retrieve the field IDs
             if (!is_numeric($id)) {
                 $atts['id'][$key] = FrmDb::get_var($wpdb->prefix . 'frm_fields', array('field_key' => $id));
             }
             unset($key, $id);
         }
         //make sure all field IDs are numeric - TODO: ask Steph if this is redundant
         $atts['id'] = array_filter($atts['id'], 'is_numeric');
         if (empty($atts['id'])) {
             // don't continue if there is nothing to graph
             return;
         }
         $fields = FrmField::getAll(array('fi.id' => $atts['id']));
         // No longer needed
         unset($atts['id']);
     }
     if (!empty($atts['colors'])) {
         $atts['colors'] = explode(',', $atts['colors']);
     }
     // Trigger js load
     global $frm_vars;
     $frm_vars['forms_loaded'][] = true;
     $html = '';
     foreach ($fields as $field) {
         $data = self::get_google_graph($field, $atts);
         if (empty($data)) {
             $html .= apply_filters('frm_no_data_graph', '<div class="frm_no_data_graph">' . __('No Data', 'formidable') . '</div>');
             continue;
         }
         $html .= '<div id="chart_' . $data['graph_id'] . '" style="height:' . $atts['height'] . ';width:' . $atts['width'] . '"></div>';
     }
     return $html;
 }
コード例 #15
0
 public static function has_field($type, $form_id, $single = true)
 {
     global $wpdb;
     if ($single) {
         $included = FrmDb::get_var('frm_fields', array('form_id' => $form_id, 'type' => $type));
         if ($included) {
             $included = FrmField::getOne($included);
         }
     } else {
         $included = FrmField::get_all_types_in_form($form_id, $type);
     }
     return $included;
 }
コード例 #16
0
ファイル: FrmField.php プロジェクト: realnerdo/multiempac
 public static function getAll($where = array(), $order_by = '', $limit = '', $blog_id = false)
 {
     $cache_key = maybe_serialize($where) . $order_by . 'l' . $limit . 'b' . $blog_id;
     if (self::$use_cache) {
         // make sure old cache doesn't get saved as a transient
         $results = wp_cache_get($cache_key, 'frm_field');
         if (false !== $results) {
             return stripslashes_deep($results);
         }
     }
     global $wpdb;
     if ($blog_id && is_multisite()) {
         global $wpmuBaseTablePrefix;
         if ($wpmuBaseTablePrefix) {
             $prefix = $wpmuBaseTablePrefix . $blog_id . '_';
         } else {
             $prefix = $wpdb->get_blog_prefix($blog_id);
         }
         $table_name = $prefix . 'frm_fields';
         $form_table_name = $prefix . 'frm_forms';
     } else {
         $table_name = $wpdb->prefix . 'frm_fields';
         $form_table_name = $wpdb->prefix . 'frm_forms';
     }
     if (!empty($order_by) && strpos($order_by, 'ORDER BY') === false) {
         $order_by = ' ORDER BY ' . $order_by;
     }
     $limit = FrmAppHelper::esc_limit($limit);
     $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
     $query_type = $limit == ' LIMIT 1' || $limit == 1 ? 'row' : 'results';
     if (is_array($where)) {
         if (isset($where['fi.form_id']) && count($where) == 1) {
             // add sub fields to query
             $form_id = $where['fi.form_id'];
             $where[] = array('or' => 1, 'fi.form_id' => $form_id, 'fr.parent_form_id' => $form_id);
             unset($where['fi.form_id']);
         }
         $results = FrmDb::get_var($table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array('order_by' => $order_by, 'limit' => $limit), '', $query_type);
     } else {
         // if the query is not an array, then it has already been prepared
         $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
         $function_name = $query_type == 'row' ? 'get_row' : 'get_results';
         $results = $wpdb->{$function_name}($query);
     }
     unset($where);
     self::format_field_results($results);
     wp_cache_set($cache_key, $results, 'frm_field', 300);
     return stripslashes_deep($results);
 }
コード例 #17
0
 public static function &get_max($field)
 {
     global $wpdb;
     if (!is_object($field)) {
         $field = FrmField::getOne($field);
     }
     if (!$field) {
         return;
     }
     $max = FrmDb::get_var('frm_item_metas', array('field_id' => $field->id), 'meta_value +0 as odr', array('order_by' => 'odr DESC'));
     if (isset($field->field_options['post_field']) && $field->field_options['post_field'] == 'post_custom') {
         $post_max = FrmDb::get_var($wpdb->postmeta, array('meta_key' => $field->field_options['custom_field']), 'meta_value +0 as odr', array('order_by' => 'odr DESC'));
         if ($post_max && (double) $post_max > (double) $max) {
             $max = $post_max;
         }
     }
     return $max;
 }
コード例 #18
0
ファイル: FrmXMLHelper.php プロジェクト: Darkers54/eLEGO
 /**
  * Prepare the form options for export
  *
  * @since 2.0.19
  * @param string $options
  * @return string
  */
 public static function prepare_form_options_for_export($options)
 {
     $options = maybe_unserialize($options);
     // Change custom_style to the post_name instead of ID
     if (isset($options['custom_style']) && 1 !== $options['custom_style']) {
         global $wpdb;
         $table = $wpdb->prefix . 'posts';
         $where = array('ID' => $options['custom_style']);
         $select = 'post_name';
         $style_name = FrmDb::get_var($table, $where, $select);
         if ($style_name) {
             $options['custom_style'] = $style_name;
         } else {
             $options['custom_style'] = 1;
         }
     }
     $options = serialize($options);
     return self::cdata($options);
 }
コード例 #19
0
ファイル: FrmProCopy.php プロジェクト: swc-dng/swcsandbox
 public static function getAll($where = array(), $order_by = '', $limit = '')
 {
     $method = $limit == ' LIMIT 1' ? 'row' : 'results';
     $results = FrmDb::get_var(self::table_name(), $where, '*', $args = array('order_by' => $order_by), $limit, $method);
     return $results;
 }
コード例 #20
0
ファイル: FrmEntry.php プロジェクト: hugocica/locomotiva-2016
 /**
  * @param string $key
  * @return int entry_id
  */
 public static function get_id_by_key($key)
 {
     $entry_id = FrmDb::get_var('frm_items', array('item_key' => sanitize_title($key)));
     return $entry_id;
 }
コード例 #21
0
ファイル: FrmEntryMeta.php プロジェクト: mazykin46/portfolio
 public static function get_entry_meta_by_field($entry_id, $field_id)
 {
     global $wpdb;
     if (is_object($entry_id)) {
         $entry = $entry_id;
         $entry_id = $entry->id;
         $cached = $entry;
     } else {
         $entry_id = (int) $entry_id;
         $cached = FrmAppHelper::check_cache($entry_id, 'frm_entry');
     }
     if ($cached && isset($cached->metas) && isset($cached->metas[$field_id])) {
         $result = $cached->metas[$field_id];
         return stripslashes_deep($result);
     }
     $get_table = $wpdb->prefix . 'frm_item_metas';
     $query = array('item_id' => $entry_id);
     if (is_numeric($field_id)) {
         $query['field_id'] = $field_id;
     } else {
         $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
         $query['fi.field_key'] = $field_id;
     }
     $result = FrmDb::get_var($get_table, $query, 'meta_value');
     $result = maybe_unserialize($result);
     $result = stripslashes_deep($result);
     return $result;
 }
コード例 #22
0
 public static function get_field($field = 'is_draft', $id)
 {
     $entry = FrmAppHelper::check_cache($id, 'frm_entry');
     if ($entry && isset($entry->{$field})) {
         return $entry->{$field};
     }
     $var = FrmDb::get_var('frm_items', array('id' => $id), $field);
     return $var;
 }
コード例 #23
0
 /**
  * @param string $id
  * @return string
  */
 public static function get_key_by_id($id)
 {
     return FrmDb::get_var('frm_fields', array('id' => $id), 'field_key');
 }
コード例 #24
0
 /**
  * @param string $table_name
  * @param string $column
  */
 public static function get_unique_key($name = '', $table_name, $column, $id = 0, $num_chars = 6)
 {
     global $wpdb;
     $key = '';
     if (!empty($name)) {
         $key = sanitize_key($name);
     }
     if (empty($key)) {
         $max_slug_value = pow(36, $num_chars);
         $min_slug_value = 37;
         // we want to have at least 2 characters in the slug
         $key = base_convert(rand($min_slug_value, $max_slug_value), 10, 36);
     }
     if (is_numeric($key) || in_array($key, array('id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd'))) {
         $key = $key . 'a';
     }
     $key_check = FrmDb::get_var($table_name, array($column => $key, 'ID !' => $id), $column);
     if ($key_check || is_numeric($key_check)) {
         $suffix = 2;
         do {
             $alt_post_name = substr($key, 0, 200 - (strlen($suffix) + 1)) . $suffix;
             $key_check = FrmDb::get_var($table_name, array($column => $alt_post_name, 'ID !' => $id), $column);
             $suffix++;
         } while ($key_check || is_numeric($key_check));
         $key = $alt_post_name;
     }
     return $key;
 }
コード例 #25
0
ファイル: FrmProField.php プロジェクト: swc-dng/swcsandbox
 /**
  * Return all the field IDs for the fields inside of a section (not necessarily repeating) or an embedded form
  *
  * @since 2.0.13
  * @param array $field
  * @return array $children
  */
 public static function get_children($field)
 {
     global $wpdb;
     $children = array();
     // If repeating field or embedded form
     if (FrmField::is_repeating_field($field) || $field['type'] == 'form') {
         $repeat_id = isset($field['form_select']) ? $field['form_select'] : $field['field_options']['form_select'];
         $children = FrmDb::get_col($wpdb->prefix . 'frm_fields', array('form_id' => $repeat_id));
     } else {
         $end_divider_order = FrmDb::get_var($wpdb->prefix . 'frm_fields', array('form_id' => $field['form_id'], 'type' => 'end_divider', 'field_order>' => $field['field_order']), 'field_order', array('order_by' => 'field_order ASC'), 1);
         $min_field_order = $field['field_order'] + 1;
         $max_field_order = $end_divider_order - 1;
         $children = FrmDb::get_col($wpdb->prefix . 'frm_fields', array('form_id' => $field['form_id'], 'field_order>' => $min_field_order, 'field_order<' => $max_field_order));
     }
     return $children;
 }