public function __construct($slug, $config)
 {
     $this->_slug = $slug;
     $this->_title = rgar($config, "title");
     $this->_search_title = rgempty("search_title", $config) ? __("Results Filters", "gravityforms") : rgar($config, "search_title");
     $this->_callbacks = isset($config["callbacks"]) ? $config["callbacks"] : array();
     $this->_capabilities = isset($config["capabilities"]) ? $config["capabilities"] : array();
 }
Example #2
0
 public function __construct($slug, $config)
 {
     $this->_slug = $slug;
     $this->_title = rgar($config, 'title');
     $this->_icon = rgar($config, 'icon');
     $this->_search_title = rgempty('search_title', $config) ? esc_html__('Results Filters', 'gravityforms') : rgar($config, 'search_title');
     $this->_callbacks = isset($config['callbacks']) ? $config['callbacks'] : array();
     $this->_capabilities = isset($config['capabilities']) ? $config['capabilities'] : array();
 }
Example #3
0
 public static function process_exterior_pages()
 {
     if (rgempty("gf_page", $_GET)) {
         return;
     }
     //ensure users are logged in
     if (!is_user_logged_in()) {
         auth_redirect();
     }
     switch (rgget("gf_page")) {
         case "directory_columns":
             require_once "select_directory_columns.php";
             break;
     }
     exit;
 }
 public function validate($value, $form)
 {
     $email = is_array($value) ? rgar($value, 0) : $value;
     // Form objects created in 1.8 will supply a string as the value.
     $is_blank = rgblank($value) || is_array($value) && rgempty(array_filter($value));
     if (!$is_blank && !GFCommon::is_valid_email($email)) {
         $this->failed_validation = true;
         $this->validation_message = empty($this->errorMessage) ? esc_html__('Please enter a valid email address.', 'gravityforms') : $this->errorMessage;
     } elseif ($this->emailConfirmEnabled && !empty($email)) {
         $confirm = is_array($value) ? rgar($value, 1) : rgpost('input_' . $this->id . '_2');
         if ($confirm != $email) {
             $this->failed_validation = true;
             $this->validation_message = esc_html__('Your emails do not match.', 'gravityforms');
         }
     }
 }
Example #5
0
function process_exterior_pages()
{
    if (rgempty("gf_pdf", $_GET)) {
        return;
    }
    //ensure users are logged in
    if (!is_user_logged_in()) {
        auth_redirect();
    }
    switch (rgget("gf_pdf")) {
        case "print-entry":
            require_once "render_to_pdf.php";
            break;
    }
    exit;
}
Example #6
0
 public function validate($value, $form)
 {
     if (is_array($value) && rgempty(0, $value) && rgempty(1, $value) && rgempty(2, $value)) {
         $value = null;
     }
     if (!empty($value)) {
         $format = empty($this->dateFormat) ? 'mdy' : $this->dateFormat;
         $date = GFCommon::parse_date($value, $format);
         if (empty($date) || !$this->checkdate($date['month'], $date['day'], $date['year'])) {
             $this->failed_validation = true;
             $format_name = '';
             switch ($format) {
                 case 'mdy':
                     $format_name = 'mm/dd/yyyy';
                     break;
                 case 'dmy':
                     $format_name = 'dd/mm/yyyy';
                     break;
                 case 'dmy_dash':
                     $format_name = 'dd-mm-yyyy';
                     break;
                 case 'dmy_dot':
                     $format_name = 'dd.mm.yyyy';
                     break;
                 case 'ymd_slash':
                     $format_name = 'yyyy/mm/dd';
                     break;
                 case 'ymd_dash':
                     $format_name = 'yyyy-mm-dd';
                     break;
                 case 'ymd_dot':
                     $format_name = 'yyyy.mm.dd';
                     break;
             }
             $message = $this->dateType == 'datepicker' ? sprintf(esc_html__('Please enter a valid date in the format (%s).', 'gravityforms'), $format_name) : esc_html__('Please enter a valid date.', 'gravityforms');
             $this->validation_message = empty($this->errorMessage) ? $message : $this->errorMessage;
         }
     }
 }
Example #7
0
    public static function page_header($title = '')
    {
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        // register admin styles
        wp_register_style('gform_admin', GFCommon::get_base_url() . "/css/admin{$min}.css");
        wp_print_styles(array('jquery-ui-styles', 'gform_admin'));
        $current_tab = rgempty('view', $_GET) ? 'export_entry' : rgget('view');
        $setting_tabs = self::get_tabs();
        // kind of boring having to pass the title, optionally get it from the settings tab
        if (!$title) {
            foreach ($setting_tabs as $tab) {
                if ($tab['name'] == $current_tab) {
                    $title = $tab['name'];
                }
            }
        }
        ?>


		<div class="wrap <?php 
        echo sanitize_html_class($current_tab);
        ?>
">

		<h2><?php 
        echo esc_html($title);
        ?>
</h2>

		<?php 
        GFCommon::display_admin_message();
        ?>

		<div id="gform_tab_group" class="gform_tab_group vertical_tabs">
		<ul id="gform_tabs" class="gform_tabs">
			<?php 
        foreach ($setting_tabs as $tab) {
            $query = array('view' => $tab['name']);
            if (isset($tab['query'])) {
                $query = array_merge($query, $tab['query']);
            }
            $url = add_query_arg($query);
            ?>
				<li <?php 
            echo $current_tab == $tab['name'] ? "class='active'" : '';
            ?>
>
					<a href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            echo esc_html($tab['label']);
            ?>
</a>
				</li>
			<?php 
        }
        ?>
		</ul>

		<div id="gform_tab_container" class="gform_tab_container">
		<div class="gform_tab_content" id="tab_<?php 
        echo esc_attr($current_tab);
        ?>
">

	<?php 
    }
 protected function is_entry_list()
 {
     if (rgget("page") == "gf_entries" && rgempty("view", $_GET)) {
         return true;
     }
     return false;
 }
Example #9
0
 /**
  * Retrieve the field label.
  *
  * @param bool $force_frontend_label Should the frontend label be displayed in the admin even if an admin label is configured.
  * @param string $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
  *
  * @return string
  */
 public function get_field_label($force_frontend_label, $value)
 {
     $field_label = $force_frontend_label ? $this->label : GFCommon::get_label($this);
     if (($this->inputType == 'singleproduct' || $this->inputType == 'calculation') && !rgempty($this->id . '.1', $value)) {
         $field_label = rgar($value, $this->id . '.1');
     }
     return $field_label;
 }
Example #10
0
 private static function toolbar_class($item)
 {
     switch ($item) {
         case 'editor':
             if (in_array(rgget('page'), array('gf_edit_forms', 'gf_new_form')) && rgempty('view', $_GET)) {
                 return 'gf_toolbar_active';
             }
             break;
         case 'settings':
             if (rgget('view') == 'settings') {
                 return 'gf_toolbar_active';
             }
             break;
         case 'notifications':
             if (rgget('page') == 'gf_new_form') {
                 return 'gf_toolbar_disabled';
             } else {
                 if (rgget('page') == 'gf_edit_forms' && rgget('view') == 'notification') {
                     return 'gf_toolbar_active';
                 }
             }
             break;
         case 'entries':
             if (rgget('page') == 'gf_new_form') {
                 return 'gf_toolbar_disabled';
             } else {
                 if (rgget('page') == 'gf_entries' && rgempty('view', $_GET)) {
                     return 'gf_toolbar_active';
                 }
             }
             break;
         case 'preview':
             if (rgget('page') == 'gf_new_form') {
                 return 'gf_toolbar_disabled';
             }
             break;
     }
     return '';
 }
 protected function get_sales_data($form_id, $search, $state)
 {
     global $wpdb;
     $data = array('chart' => array('hAxis' => array(), 'vAxis' => array('column' => 'revenue', 'label' => esc_html__('Revenue', 'gravityforms'))), 'table' => array('header' => array('orders' => esc_html__('Orders', 'gravityforms'), 'subscriptions' => esc_html__('Subscriptions', 'gravityforms'), 'recurring_payments' => esc_html__('Recurring Payments', 'gravityforms'), 'refunds' => esc_html__('Refunds', 'gravityforms'), 'revenue' => esc_html__('Revenue', 'gravityforms'))), 'rows' => array());
     $tz_offset = $this->get_mysql_tz_offset();
     $page_size = 10;
     $group = strtolower(rgpost('group'));
     switch ($group) {
         case 'weekly':
             $select = "concat(left(lead.week,4), ' - ', right(lead.week,2)) as week";
             $select_inner1 = "yearweek(CONVERT_TZ(date_created, '+00:00', '" . $tz_offset . "')) week";
             $select_inner2 = "yearweek(CONVERT_TZ(t.date_created, '+00:00', '" . $tz_offset . "')) week";
             $group_by = 'week';
             $order_by = 'week desc';
             $join = 'lead.week = transaction.week';
             $data['chart']['hAxis']['column'] = 'week';
             $data['chart']['hAxis']['label'] = esc_html__('Week', 'gravityforms');
             $data['table']['header'] = array_merge(array('week' => esc_html__('Week', 'gravityforms')), $data['table']['header']);
             break;
         case 'monthly':
             $select = "date_format(lead.month, '%%Y') as year, date_format(lead.month, '%%c') as month, '' as month_abbrev, '' as month_year";
             $select_inner1 = "date_format(CONVERT_TZ(date_created, '+00:00', '" . $tz_offset . "'), '%%Y-%%m-01') month";
             $select_inner2 = "date_format(CONVERT_TZ(t.date_created, '+00:00', '" . $tz_offset . "'), '%%Y-%%m-01') month";
             $group_by = 'month';
             $order_by = 'year desc, month desc';
             $join = 'lead.month = transaction.month';
             $data['chart']['hAxis']['column'] = 'month_abbrev';
             $data['chart']['hAxis']['label'] = esc_html__('Month', 'gravityforms');
             $data['table']['header'] = array_merge(array('month_year' => esc_html__('Month', 'gravityforms')), $data['table']['header']);
             break;
         default:
             //daily
             $select = "lead.date, date_format(lead.date, '%%c') as month, day(lead.date) as day, dayname(lead.date) as day_of_week, '' as month_day";
             $select_inner1 = "date(CONVERT_TZ(date_created, '+00:00', '" . $tz_offset . "')) as date";
             $select_inner2 = "date(CONVERT_TZ(t.date_created, '+00:00', '" . $tz_offset . "')) as date";
             $group_by = 'date';
             $order_by = 'date desc';
             $join = 'lead.date = transaction.date';
             $data['chart']['hAxis']['column'] = 'month_day';
             $data['chart']['hAxis']['label'] = esc_html__('Day', 'gravityforms');
             $data['table']['header'] = array_merge(array('date' => esc_html__('Date', 'gravityforms'), 'day_of_week' => esc_html__('Day', 'gravityforms')), $data['table']['header']);
             break;
     }
     $lead_date_filter = '';
     $transaction_date_filter = '';
     if (isset($search['start_date'])) {
         $lead_date_filter = $wpdb->prepare(" AND timestampdiff(SECOND, %s, CONVERT_TZ(l.date_created, '+00:00', '" . $tz_offset . "')) >= 0", $search['start_date']);
         $transaction_date_filter = $wpdb->prepare(" AND timestampdiff(SECOND, %s, CONVERT_TZ(t.date_created, '+00:00', '" . $tz_offset . "')) >= 0", $search['start_date']);
     }
     if (isset($search['end_date'])) {
         $lead_date_filter .= $wpdb->prepare(" AND timestampdiff(SECOND, %s, CONVERT_TZ(l.date_created, '+00:00', '" . $tz_offset . "')) <= 0", $search['end_date']);
         $transaction_date_filter .= $wpdb->prepare(" AND timestampdiff(SECOND, %s, CONVERT_TZ(t.date_created, '+00:00', '" . $tz_offset . "')) <= 0", $search['end_date']);
     }
     $payment_method = rgpost('payment_method');
     $payment_method_filter = '';
     if (!empty($payment_method)) {
         $payment_method_filter = $wpdb->prepare(' AND l.payment_method=%s', $payment_method);
     }
     $current_page = rgempty('paged') ? 1 : absint(rgpost('paged'));
     $offset = $page_size * ($current_page - 1);
     $sql = $wpdb->prepare(" SELECT SQL_CALC_FOUND_ROWS {$select}, lead.orders, lead.subscriptions, transaction.refunds, transaction.recurring_payments, transaction.revenue\n                                FROM (\n                                  SELECT  {$select_inner1},\n                                          sum( if(transaction_type = 1,1,0) ) as orders,\n                                          sum( if(transaction_type = 2,1,0) ) as subscriptions\n                                  FROM {$wpdb->prefix}rg_lead l\n                                  WHERE l.status='active' AND form_id=%d {$lead_date_filter} {$payment_method_filter}\n                                  GROUP BY {$group_by}\n                                ) AS lead\n\n                                LEFT OUTER JOIN(\n                                  SELECT  {$select_inner2},\n                                          sum( if(t.transaction_type = 'refund', abs(t.amount) * -1, t.amount) ) as revenue,\n                                          sum( if(t.transaction_type = 'refund', 1, 0) ) as refunds,\n                                          sum( if(t.transaction_type = 'payment' AND t.is_recurring = 1, 1, 0) ) as recurring_payments\n                                  FROM {$wpdb->prefix}gf_addon_payment_transaction t\n                                  INNER JOIN {$wpdb->prefix}rg_lead l ON l.id = t.lead_id\n                                  WHERE l.status='active' AND l.form_id=%d {$lead_date_filter} {$transaction_date_filter} {$payment_method_filter}\n                                  GROUP BY {$group_by}\n\n                                ) AS transaction on {$join}\n                                ORDER BY {$order_by}\n                                LIMIT {$page_size} OFFSET {$offset}\n                                ", $form_id, $form_id);
     $results = $wpdb->get_results($sql, ARRAY_A);
     foreach ($results as &$result) {
         $result['orders'] = intval($result['orders']);
         $result['subscriptions'] = intval($result['subscriptions']);
         $result['refunds'] = intval($result['refunds']);
         $result['recurring_payments'] = intval($result['recurring_payments']);
         $result['revenue'] = floatval($result['revenue']);
         $result = $this->format_chart_h_axis($result);
     }
     $data['row_count'] = $wpdb->get_var('SELECT FOUND_ROWS()');
     $data['page_size'] = $page_size;
     $data['rows'] = $results;
     return $data;
 }
Example #12
0
 public static function get_post_category_values()
 {
     $has_input_name = strtolower(rgpost('inputName')) != 'false';
     $id = !$has_input_name ? rgpost('objectType') . '_rule_value_' . rgpost('ruleIndex') : rgpost('inputName');
     $selected = rgempty('selectedValue') ? 0 : rgpost('selectedValue');
     $dropdown = wp_dropdown_categories(array('class' => 'gfield_rule_select gfield_rule_value_dropdown gfield_category_dropdown', 'orderby' => 'name', 'id' => $id, 'name' => $id, 'selected' => $selected, 'hierarchical' => true, 'hide_empty' => 0, 'echo' => false));
     die($dropdown);
 }
 public static function update_lead($lead)
 {
     _deprecated_function('GFFormsModel::update_lead()', '1.8.8', 'GFAPI::update_entry()');
     global $wpdb;
     $lead_table = self::get_lead_table_name();
     $payment_date = strtotime(rgar($lead, 'payment_date')) ? "'" . gmdate('Y-m-d H:i:s', strtotime("{$lead['payment_date']}")) . "'" : 'NULL';
     $payment_amount = !rgblank(rgar($lead, 'payment_amount')) ? (double) rgar($lead, 'payment_amount') : 'NULL';
     $transaction_type = !rgempty('transaction_type', $lead) ? intval($lead['transaction_type']) : 'NULL';
     $status = !rgempty('status', $lead) ? $lead['status'] : 'active';
     $source_url = self::truncate(rgar($lead, 'source_url'), 200);
     $user_agent = self::truncate(rgar($lead, 'user_agent'), 250);
     $sql = $wpdb->prepare("UPDATE {$lead_table} SET\n\t\t\t\tform_id=%d,\n\t\t\t\tpost_id=%d,\n\t\t\t\tis_starred=%d,\n\t\t\t\tis_read=%d,\n\t\t\t\tip=%s,\n\t\t\t\tsource_url=%s,\n\t\t\t\tuser_agent=%s,\n\t\t\t\tcurrency=%s,\n\t\t\t\tpayment_status=%s,\n\t\t\t\tpayment_date={$payment_date},\n\t\t\t\tpayment_amount={$payment_amount},\n\t\t\t\ttransaction_id=%s,\n\t\t\t\tis_fulfilled=%d,\n\t\t\t\ttransaction_type={$transaction_type},\n\t\t\t\tpayment_method=%s,\n\t\t\t\tstatus='{$status}'\n\t\t   WHERE id=%d", rgar($lead, 'form_id'), rgar($lead, 'post_id'), rgar($lead, 'is_starred'), rgar($lead, 'is_read'), rgar($lead, 'ip'), $source_url, $user_agent, rgar($lead, 'currency'), rgar($lead, 'payment_status'), rgar($lead, 'transaction_id'), rgar($lead, 'is_fulfilled'), rgar($lead, 'payment_method'), rgar($lead, 'id'));
     $wpdb->query($sql);
     self::set_current_lead($lead);
 }
 public function get_current_feed_id()
 {
     if ($this->_current_feed_id) {
         return $this->_current_feed_id;
     } else {
         if (!rgempty('gf_feed_id')) {
             return rgpost('gf_feed_id');
         } else {
             return rgget('fid');
         }
     }
 }
Example #15
0
    public static function lead_detail_page()
    {
        global $wpdb;
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta($_GET["id"]);
        $form_id = $form["id"];
        $form = apply_filters("gform_admin_pre_render_" . $form["id"], apply_filters("gform_admin_pre_render", $form));
        $lead_id = rgget('lid');
        $filter = rgget("filter");
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $star = $filter == "star" ? 1 : null;
        $read = $filter == "unread" ? 0 : null;
        $search_criteria["status"] = $status;
        if ($star) {
            $search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
        }
        $search_field_id = rgget("field_id");
        if (isset($_GET["field_id"]) && $_GET["field_id"] !== '') {
            $key = $search_field_id;
            $val = rgget("s");
            $strpos_row_key = strpos($search_field_id, "|");
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode("|", $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ":" . $val;
            }
            $type = rgget("type");
            if (empty($type)) {
                $type = rgget("field_id") == "0" ? "global" : "field";
            }
            $search_criteria["field_filters"][] = array("key" => $key, "type" => $type, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET["sort"], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            _e("Oops! We couldn't find your entry. Please try again", "gravityforms");
            return;
        }
        RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
        switch (RGForms::post("action")) {
            case "update":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post("gform_uploaded_files")));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action("gform_after_update_entry", $form, $lead["id"]);
                do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
                $lead = RGFormsModel::get_lead($lead["id"]);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case "add_note":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
                //emailing notes if configured
                if (rgpost("gentry_email_notes_to")) {
                    $email_to = $_POST["gentry_email_notes_to"];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST["gentry_email_subject"]);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    $result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
                }
                break;
            case "add_quick_note":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["quick_note"]));
                break;
            case "bulk":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST["bulk_action"] == "delete") {
                    RGFormsModel::delete_notes($_POST["note"]);
                }
                break;
            case "trash":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "trash");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "restore":
            case "unspam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "active");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "spam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "spam");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "delete":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    die(__("You don't have adequate permissions to delete entries.", "gravityforms"));
                }
                RGFormsModel::delete_lead($lead["id"]);
                ?>
                <script type="text/javascript">
                    document.location.href='<?php 
                echo "admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]);
                ?>
';
                </script>
                <?php 
                break;
        }
        $mode = empty($_POST["screen_mode"]) ? "view" : $_POST["screen_mode"];
        ?>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" />
         <script type="text/javascript">

            jQuery(document).ready(function(){
                toggleNotificationOverride(true);
            });

            function DeleteFile(leadId, fieldId, deleteButton){
                if(confirm(<?php 
        _e("'Would you like to delete this file? \\'Cancel\\' to stop. \\'OK\\' to delete'", "gravityforms");
        ?>
)){
                    var fileIndex = jQuery(deleteButton).parent().index();
                    var mysack = new sack("<?php 
        echo admin_url("admin-ajax.php");
        ?>
");
                    mysack.execute = 1;
                    mysack.method = 'POST';
                    mysack.setVar( "action", "rg_delete_file" );
                    mysack.setVar( "rg_delete_file", "<?php 
        echo wp_create_nonce("rg_delete_file");
        ?>
" );
                    mysack.setVar( "lead_id", leadId );
                    mysack.setVar( "field_id", fieldId );
                    mysack.setVar( "file_index", fileIndex );
                    mysack.onError = function() { alert('<?php 
        echo esc_js(__("Ajax error while deleting field.", "gravityforms"));
        ?>
' )};
                    mysack.runAJAX();

                    return true;
                }
            }

            function EndDeleteFile(fieldId, fileIndex){
                var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview";
                var $previewFiles = jQuery(previewFileSelector);
                var rr = $previewFiles.eq(fileIndex);
                $previewFiles.eq(fileIndex).remove();
                var $visiblePreviewFields = jQuery(previewFileSelector);
                if($visiblePreviewFields.length == 0){
                    jQuery('#preview_' + fieldId).hide();
                    jQuery('#upload_' + fieldId).show('slow');
                }
            }

            function ToggleShowEmptyFields(){
                if(jQuery("#gentry_display_empty_fields").is(":checked")){
                    createCookie("gf_display_empty_fields", true, 10000);
                    document.location = document.location.href;
                }
                else{
                    eraseCookie("gf_display_empty_fields");
                    document.location = document.location.href;
                }
            }

            function createCookie(name,value,days) {
                if (days) {
                    var date = new Date();
                    date.setTime(date.getTime()+(days*24*60*60*1000));
                    var expires = "; expires="+date.toGMTString();
                }
                else var expires = "";
                document.cookie = name+"="+value+expires+"; path=/";
            }

            function eraseCookie(name) {
                createCookie(name,"",-1);
            }

            function ResendNotifications() {

                var selectedNotifications = new Array();
                jQuery(".gform_notifications:checked").each(function(){
                    selectedNotifications.push(jQuery(this).val());
                });

                var sendTo = jQuery('#notification_override_email').val();

                if(selectedNotifications.length <=0) {
                    displayMessage("<?php 
        _e("You must select at least one type of notification to resend.", "gravityforms");
        ?>
", "error", "#notifications_container");
                    return;
                }

                jQuery('#please_wait_container').fadeIn();

                jQuery.post(ajaxurl, {
                        action : "gf_resend_notifications",
                        gf_resend_notifications : '<?php 
        echo wp_create_nonce('gf_resend_notifications');
        ?>
',
                        notifications: jQuery.toJSON(selectedNotifications),
                        sendTo : sendTo,
                        leadIds : '<?php 
        echo $lead['id'];
        ?>
',
                        formId : '<?php 
        echo $form['id'];
        ?>
'
                    },
                    function(response) {
                        if(response) {
                            displayMessage(response, "error", "#notifications_container");
                        } else {
                            displayMessage("<?php 
        _e("Notifications were resent successfully.", "gravityforms");
        ?>
", "updated", "#notifications_container");

                            // reset UI
                            jQuery(".gform_notifications").attr('checked', false);
                            jQuery('#notification_override_email').val('');
                        }

                        jQuery('#please_wait_container').hide();
                        setTimeout(function(){jQuery('#notifications_container').find('.message').slideUp();}, 5000);
                    }
                );

            }

            function displayMessage(message, messageClass, container){

                jQuery(container).find('.message').hide().html(message).attr('class', 'message ' + messageClass).slideDown();

            }

            function toggleNotificationOverride(isInit) {

                if(isInit)
                    jQuery('#notification_override_email').val('');

                if(jQuery(".gform_notifications:checked").length > 0 ) {
                    jQuery('#notifications_override_settings').slideDown();
                }
                else {
                    jQuery('#notifications_override_settings').slideUp(function(){
                        jQuery('#notification_override_email').val('');
                    });
                }
            }

        </script>

        <form method="post" id="entry_form" enctype='multipart/form-data'>
            <?php 
        wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
        ?>
            <input type="hidden" name="action" id="action" value=""/>
            <input type="hidden" name="screen_mode" id="screen_mode" value="<?php 
        echo esc_attr(rgpost("screen_mode"));
        ?>
" />

            <div class="wrap gf_entry_wrap">
            <h2 class="gf_admin_page_title"><span><?php 
        echo __("Entry #", "gravityforms") . absint($lead["id"]);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo $form['id'];
        ?>
</span><?php 
        echo $form['title'];
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></h2>

            <?php 
        if (isset($_GET["pos"])) {
            ?>
            <div class="gf_entry_detail_pagination">
                <ul>
                    <li class="gf_entry_count"><span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span></li>
                    <li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', "fa fa-arrow-circle-o-left");
            ?>
</li>
                    <li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', "fa fa-arrow-circle-o-right");
            ?>
</li>
                </ul>
            </div>
            <?php 
        }
        ?>

            <?php 
        RGForms::top_toolbar();
        ?>

            <div id="poststuff" class="metabox-holder has-right-sidebar">
                <div id="side-info-column" class="inner-sidebar">
                	<?php 
        do_action("gform_entry_detail_sidebar_before", $form, $lead);
        ?>

                    <!-- INFO BOX -->
                    <div id="submitdiv" class="stuffbox">
                        <h3>
                            <span class="hndle"><?php 
        _e("Entry", "gravityforms");
        ?>
</span>
                        </h3>
                        <div class="inside">
                            <div id="submitcomment" class="submitbox">
                                <div id="minor-publishing" style="padding:10px;">
                                    <br/>
                                    <?php 
        _e("Entry Id", "gravityforms");
        ?>
: <?php 
        echo absint($lead["id"]);
        ?>
<br/><br/>
                                    <?php 
        _e("Submitted on", "gravityforms");
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead["date_created"], false, "Y/m/d"));
        ?>
                                    <br/><br/>
                                    <?php 
        _e("User IP", "gravityforms");
        ?>
: <?php 
        echo $lead["ip"];
        ?>
                                    <br/><br/>
                                    <?php 
        if (!empty($lead["created_by"]) && ($usermeta = get_userdata($lead["created_by"]))) {
            ?>
                                        <?php 
            _e("User", "gravityforms");
            ?>
: <a href="user-edit.php?user_id=<?php 
            echo absint($lead["created_by"]);
            ?>
" alt="<?php 
            _e("View user profile", "gravityforms");
            ?>
" title="<?php 
            _e("View user profile", "gravityforms");
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
                                        <br/><br/>
                                        <?php 
        }
        ?>

                                    <?php 
        _e("Embed Url", "gravityforms");
        ?>
: <a href="<?php 
        echo esc_url($lead["source_url"]);
        ?>
" target="_blank" alt="<?php 
        echo esc_url($lead["source_url"]);
        ?>
" title="<?php 
        echo esc_url($lead["source_url"]);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead["source_url"]));
        ?>
</a>
                                    <br/><br/>
                                    <?php 
        if (!empty($lead["post_id"])) {
            $post = get_post($lead["post_id"]);
            ?>
                                        <?php 
            _e("Edit Post", "gravityforms");
            ?>
: <a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            _e("Click to edit post", "gravityforms");
            ?>
" title="<?php 
            _e("Click to edit post", "gravityforms");
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
                                        <br/><br/>
                                        <?php 
        }
        if (apply_filters("gform_enable_entry_info_payment_details", true, $lead)) {
            if (!empty($lead["payment_status"])) {
                echo $lead["transaction_type"] == 2 ? __("Subscription Status", "gravityforms") : __("Payment Status", "gravityforms");
                ?>
: <span id="gform_payment_status"><?php 
                echo apply_filters("gform_payment_status", $lead["payment_status"], $form, $lead);
                ?>
</span>
                                            <br/><br/>
                                            <?php 
                if (!empty($lead["payment_date"])) {
                    echo $lead["transaction_type"] == 2 ? __("Start Date", "gravityforms") : __("Payment Date", "gravityforms");
                    ?>
: <?php 
                    echo GFCommon::format_date($lead["payment_date"], false, "Y/m/d", $lead["transaction_type"] != 2);
                    ?>
                                                <br/><br/>
                                                <?php 
                }
                if (!empty($lead["transaction_id"])) {
                    echo $lead["transaction_type"] == 2 ? __("Subscriber Id", "gravityforms") : __("Transaction Id", "gravityforms");
                    ?>
: <?php 
                    echo $lead["transaction_id"];
                    ?>
                                                <br/><br/>
                                                <?php 
                }
                if (!rgblank($lead["payment_amount"])) {
                    echo $lead["transaction_type"] == 2 ? __("Subscription Amount", "gravityforms") : __("Payment Amount", "gravityforms");
                    ?>
: <?php 
                    echo GFCommon::to_money($lead["payment_amount"], $lead["currency"]);
                    ?>
                                                <br/><br/>
                                                <?php 
                }
            }
        }
        do_action("gform_entry_info", $form["id"], $lead);
        ?>
                                </div>
                                <div id="major-publishing-actions">
                                    <div id="delete-action">
                                        <?php 
        switch ($lead["status"]) {
            case "spam":
                if (GFCommon::akismet_enabled($form['id'])) {
                    ?>
                                                    <a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Not Spam", "gravityforms");
                    ?>
</a>
                                                    <?php 
                    echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    _e("You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</a>
                                                    <?php 
                }
                break;
            case "trash":
                ?>
                                                <a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                _e("Restore", "gravityforms");
                ?>
</a>
                                                <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    |
                                                    <a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    _e("You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</a>
                                                    <?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Move to Trash", "gravityforms");
                    ?>
</a>
                                                    <?php 
                    echo GFCommon::akismet_enabled($form['id']) ? "|" : "";
                }
                if (GFCommon::akismet_enabled($form['id'])) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Mark as Spam", "gravityforms");
                    ?>
</a>
                                                <?php 
                }
        }
        ?>
                                    </div>
                                    <div id="publishing-action">
                                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_edit_entries") && $lead["status"] != "trash") {
            $button_text = $mode == "view" ? __("Edit", "gravityforms") : __("Update", "gravityforms");
            $button_click = $mode == "view" ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input class="button button-large button-primary" type="submit" tabindex="4" value="' . $button_text . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters("gform_entrydetail_update_button", $update_button);
            if ($mode == "edit") {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . __("Cancel", "gravityforms") . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <?php 
        if (!empty($lead["payment_status"]) && !apply_filters("gform_enable_entry_info_payment_details", true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

                    <?php 
        do_action("gform_entry_detail_sidebar_middle", $form, $lead);
        ?>

                    <?php 
        if (GFCommon::current_user_can_any("gravityforms_edit_entry_notes")) {
            ?>
                        <!-- start notifications -->
                        <div class="postbox" id="notifications_container">
                            <h3 style="cursor:default;"><span><?php 
            _e("Notifications", "gravityforms");
            ?>
</span></h3>
                            <div class="inside">
                                <div class="message" style="display:none; padding:10px; margin:10px 0px;"></div>
                                <div>
                                    <?php 
            if (!is_array($form["notifications"]) || count($form["notifications"]) <= 0) {
                ?>
                                        <p class="description"><?php 
                _e("You cannot resend notifications for this entry because this form does not currently have any notifications configured.", "gravityforms");
                ?>
</p>

                                        <a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form["id"]}");
                ?>
" class="button"><?php 
                _e("Configure Notifications", "gravityforms");
                ?>
</a>
                                    <?php 
            } else {
                foreach ($form["notifications"] as $notification) {
                    ?>
                                            <input type="checkbox" class="gform_notifications" value="<?php 
                    echo $notification["id"];
                    ?>
" id="notification_<?php 
                    echo $notification["id"];
                    ?>
" onclick="toggleNotificationOverride();" />
                                            <label for="notification_<?php 
                    echo $notification["id"];
                    ?>
"><?php 
                    echo $notification["name"];
                    ?>
</label> <br /><br />
                                        <?php 
                }
                ?>

                                        <div id="notifications_override_settings" style="display:none;">

                                            <p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
                                                by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
                                            <label for="notification_override_email"><?php 
                _e("Send To", "gravityforms");
                ?>
 <?php 
                gform_tooltip("notification_override_email");
                ?>
</label><br />
                                            <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
                                            <br /><br />

                                        </div>

                                        <input type="button" name="notification_resend" value="<?php 
                _e("Resend Notifications", "gravityforms");
                ?>
" class="button" style="" onclick="ResendNotifications();"/>
                                        <span id="please_wait_container" style="display:none; margin-left: 5px;">
                                            <img src="<?php 
                echo GFCommon::get_base_url();
                ?>
/images/loading.gif"> <?php 
                _e("Resending...", "gravityforms");
                ?>
                                        </span>
                                    <?php 
            }
            ?>

                                </div>
                            </div>
                        </div>
                       <!-- / end notifications -->
                   <?php 
        }
        ?>

                   <!-- begin print button -->
                   <div class="detail-view-print">
                       <a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo $form['id'];
        ?>
&lid=<?php 
        echo $lead['id'];
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        _e("Print", "gravityforms");
        ?>
</a>
                       <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                           <input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes"/>
                           <label for="print_notes"><?php 
            _e("include notes", "gravityforms");
            ?>
</label>
                       <?php 
        }
        ?>
                   </div>
                   <!-- end print button -->
				   <?php 
        do_action("gform_entry_detail_sidebar_after", $form, $lead);
        ?>
                </div>

                <div id="post-body" class="has-sidebar">
                    <div id="post-body-content" class="has-sidebar-content">
                        <?php 
        do_action("gform_entry_detail_content_before", $form, $lead);
        if ($mode == "view") {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action("gform_entry_detail", $form, $lead);
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                            <div class="postbox">
                                <h3>
                                    <label for="name"><?php 
            _e("Notes", "gravityforms");
            ?>
</label>
                                </h3>

                                <form method="post">
                                    <?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
                                    <div class="inside">
                                        <?php 
            $notes = RGFormsModel::get_lead_notes($lead["id"]);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field["id"]])) {
                    $emails[] = $lead[$email_field["id"]];
                }
            }
            //displaying notes grid
            $subject = !empty($form["autoResponder"]["subject"]) ? "RE: " . GFCommon::replace_variables($form["autoResponder"]["subject"], $form, $lead) : "";
            self::notes_grid($notes, true, $emails, $subject);
            ?>
                                    </div>
                                </form>
                            </div>
                        <?php 
        }
        do_action("gform_entry_detail_content_after", $form, $lead);
        ?>
                    </div>
                </div>
            </div>
        </div>
        </form>
        <?php 
        if (rgpost("action") == "update") {
            ?>
            <div class="updated fade" style="padding:6px;">
                <?php 
            _e("Entry Updated.", "gravityforms");
            ?>
            </div>
            <?php 
        }
    }
Example #16
0
 private static function get_field_mapping($config, $form_id, $merge_vars)
 {
     //getting list of all fields for the selected form
     $form_fields = self::get_form_fields($form_id);
     $str = "<table cellpadding='0' cellspacing='0'><tr><td class='campaignmonitor_col_heading'>" . __("List Fields", "gravityformscampaignmonitor") . "</td><td class='campaignmonitor_col_heading'>" . __("Form Fields", "gravityformscampaignmonitor") . "</td></tr>";
     foreach ($merge_vars as $var) {
         $meta = rgar($config, "meta");
         if (!is_array($meta)) {
             $meta = array("field_map" => "");
         }
         $selected_field = rgar($meta["field_map"], self::get_field_key($var));
         $required = self::get_field_key($var) == "email" ? "<span class='gfield_required'>*</span> " : "";
         $error_class = self::get_field_key($var) == "email" && empty($selected_field) && !rgempty("gf_campaignmonitor_submit") ? " feeds_validation_error" : "";
         $str .= "<tr class='{$error_class}'><td class='campaignmonitor_field_cell'>" . esc_html($var["FieldName"]) . " {$required}</td><td class='campaignmonitor_field_cell'>" . self::get_mapped_field_list(self::get_field_key($var), $selected_field, $form_fields) . "</td></tr>";
     }
     $str .= "</table>";
     return $str;
 }
 public function get_field_input($form, $value = '', $entry = null)
 {
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $form_id = $form['id'];
     $id = intval($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
     $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $form_sub_label_placement = rgar($form, 'subLabelPlacement');
     $field_sub_label_placement = $this->subLabelPlacement;
     $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
     $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
     $card_number = '';
     $card_name = '';
     $expiration_month = '';
     $expiration_year = '';
     $security_code = '';
     $autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : '';
     if (is_array($value)) {
         $card_number = esc_attr(rgget($this->id . '.1', $value));
         $card_name = esc_attr(rgget($this->id . '.5', $value));
         $expiration_date = rgget($this->id . '.2', $value);
         if (!is_array($expiration_date) && !empty($expiration_date)) {
             $expiration_date = explode('/', $expiration_date);
         }
         if (is_array($expiration_date) && count($expiration_date) == 2) {
             $expiration_month = $expiration_date[0];
             $expiration_year = $expiration_date[1];
         }
         $security_code = esc_attr(rgget($this->id . '.3', $value));
     }
     $action = !($is_entry_detail || $is_form_editor) ? "gformMatchCard(\"{$field_id}_1\");" : '';
     $onchange = "onchange='{$action}'";
     $onkeyup = "onkeyup='{$action}'";
     $card_icons = '';
     $cards = GFCommon::get_card_types();
     $card_style = $this->creditCardStyle ? $this->creditCardStyle : 'style1';
     foreach ($cards as $card) {
         $style = '';
         if ($this->is_card_supported($card['slug'])) {
             $print_card = true;
         } elseif ($is_form_editor || $is_entry_detail) {
             $print_card = true;
             $style = "style='display:none;'";
         } else {
             $print_card = false;
         }
         if ($print_card) {
             $card_icons .= "<div class='gform_card_icon gform_card_icon_{$card['slug']}' {$style}>{$card['name']}</div>";
         }
     }
     $payment_methods = apply_filters('gform_payment_methods', array(), $this, $form_id);
     $payment_options = '';
     if (is_array($payment_methods)) {
         foreach ($payment_methods as $payment_method) {
             $checked = rgpost('gform_payment_method') == $payment_method['key'] ? "checked='checked'" : '';
             $payment_options .= "<div class='gform_payment_option gform_payment_{$payment_method['key']}'><input type='radio' name='gform_payment_method' value='{$payment_method['key']}' id='gform_payment_method_{$payment_method['key']}' onclick='gformToggleCreditCard();' onkeypress='gformToggleCreditCard();' {$checked}/> {$payment_method['label']}</div>";
         }
     }
     $checked = rgpost('gform_payment_method') == 'creditcard' || rgempty('gform_payment_method') ? "checked='checked'" : '';
     $card_radio_button = empty($payment_options) ? '' : "<input type='radio' name='gform_payment_method' id='gform_payment_method_creditcard' value='creditcard' onclick='gformToggleCreditCard();' onkeypress='gformToggleCreditCard();' {$checked}/>";
     $card_icons = "{$payment_options}<div class='gform_card_icon_container gform_card_icon_{$card_style}'>{$card_radio_button}{$card_icons}</div>";
     //card number fields
     $tabindex = $this->get_tabindex();
     $card_number_field_input = GFFormsModel::get_input($this, $this->id . '.1');
     $html5_output = !is_admin() && GFFormsModel::is_html5_enabled() ? "pattern='[0-9]*' title='" . esc_attr__('Only digits are allowed', 'gravityforms') . "'" : '';
     $card_number_label = rgar($card_number_field_input, 'customLabel') != '' ? $card_number_field_input['customLabel'] : esc_html__('Card Number', 'gravityforms');
     $card_number_label = gf_apply_filters(array('gform_card_number', $form_id), $card_number_label, $form_id);
     $card_number_placeholder = $this->get_input_placeholder_attribute($card_number_field_input);
     if ($is_sub_label_above) {
         $card_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' >\n                                    {$card_icons}\n                                    <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$card_number_label}</label>\n                                    <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$card_number}' {$tabindex} {$disabled_text} {$onchange} {$onkeyup} {$autocomplete} {$html5_output} {$card_number_placeholder}/>\n                                 </span>";
     } else {
         $card_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' >\n                                    {$card_icons}\n                                    <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$card_number}' {$tabindex} {$disabled_text} {$onchange} {$onkeyup} {$autocomplete} {$html5_output} {$card_number_placeholder}/>\n                                    <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$card_number_label}</label>\n                                 </span>";
     }
     //expiration date field
     $expiration_month_tab_index = $this->get_tabindex();
     $expiration_year_tab_index = $this->get_tabindex();
     $expiration_month_input = GFFormsModel::get_input($this, $this->id . '.2_month');
     $expiration_month_placeholder = $this->get_input_placeholder_value($expiration_month_input);
     $expiration_year_input = GFFormsModel::get_input($this, $this->id . '.2_year');
     $expiration_year_placeholder = $this->get_input_placeholder_value($expiration_year_input);
     $expiration_months = $this->get_expiration_months($expiration_month, $expiration_month_placeholder);
     $expiration_years = $this->get_expiration_years($expiration_year, $expiration_year_placeholder);
     $expiration_label = rgar($expiration_month_input, 'customLabel') != '' ? $expiration_month_input['customLabel'] : esc_html__('Expiration Date', 'gravityforms');
     $expiration_label = gf_apply_filters(array('gform_card_expiration', $form_id), $expiration_label, $form_id);
     if ($is_sub_label_above) {
         $expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>\n                                            <span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_cardinfo_left'>\n                                                <span class='ginput_card_expiration_container ginput_card_field'>\n                                                    <label for='{$field_id}_2_month' {$sub_label_class_attribute}>{$expiration_label}</label>\n                                                    <select name='input_{$id}.2[]' id='{$field_id}_2_month' {$expiration_month_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>\n                                                        {$expiration_months}\n                                                    </select>\n                                                    <select name='input_{$id}.2[]' id='{$field_id}_2_year' {$expiration_year_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>\n                                                        {$expiration_years}\n                                                    </select>\n                                                </span>\n                                            </span>";
     } else {
         $expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>\n                                            <span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_cardinfo_left'>\n                                                <span class='ginput_card_expiration_container ginput_card_field'>\n                                                    <select name='input_{$id}.2[]' id='{$field_id}_2_month' {$expiration_month_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>\n                                                        {$expiration_months}\n                                                    </select>\n                                                    <select name='input_{$id}.2[]' id='{$field_id}_2_year' {$expiration_year_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>\n                                                    {$expiration_years}\n                                                    </select>\n                                                    <label for='{$field_id}_2_month' {$sub_label_class_attribute}>{$expiration_label}</label>\n                                                </span>\n                                            </span>";
     }
     //security code field
     $tabindex = $this->get_tabindex();
     $security_code_field_input = GFFormsModel::get_input($this, $this->id . '.3');
     $security_code_label = rgar($security_code_field_input, 'customLabel') != '' ? $security_code_field_input['customLabel'] : esc_html__('Security Code', 'gravityforms');
     $security_code_label = gf_apply_filters(array('gform_card_security_code', $form_id), $security_code_label, $form_id);
     $html5_output = GFFormsModel::is_html5_enabled() ? "pattern='[0-9]*' title='" . esc_attr__('Only digits are allowed', 'gravityforms') . "'" : '';
     $security_code_placeholder = $this->get_input_placeholder_attribute($security_code_field_input);
     if ($is_sub_label_above) {
         $security_field = "<span class='ginput_cardinfo_right{$class_suffix}' id='{$field_id}_2_cardinfo_right'>\n                                                <label for='{$field_id}_3' {$sub_label_class_attribute}>{$security_code_label}</label>\n                                                <input type='text' name='input_{$id}.3' id='{$field_id}_3' {$tabindex} {$disabled_text} class='ginput_card_security_code' value='{$security_code}' {$autocomplete} {$html5_output} {$security_code_placeholder} />\n                                                <span class='ginput_card_security_code_icon'>&nbsp;</span>\n                                             </span>\n                                        </span>";
     } else {
         $security_field = "<span class='ginput_cardinfo_right{$class_suffix}' id='{$field_id}_2_cardinfo_right'>\n                                                <input type='text' name='input_{$id}.3' id='{$field_id}_3' {$tabindex} {$disabled_text} class='ginput_card_security_code' value='{$security_code}' {$autocomplete} {$html5_output} {$security_code_placeholder}/>\n                                                <span class='ginput_card_security_code_icon'>&nbsp;</span>\n                                                <label for='{$field_id}_3' {$sub_label_class_attribute}>{$security_code_label}</label>\n                                             </span>\n                                        </span>";
     }
     $tabindex = $this->get_tabindex();
     $card_name_field_input = GFFormsModel::get_input($this, $this->id . '.5');
     $card_name_label = rgar($card_name_field_input, 'customLabel') != '' ? $card_name_field_input['customLabel'] : esc_html__('Cardholder Name', 'gravityforms');
     $card_name_label = gf_apply_filters(array('gform_card_name', $form_id), $card_name_label, $form_id);
     $card_name_placeholder = $this->get_input_placeholder_attribute($card_name_field_input);
     if ($is_sub_label_above) {
         $card_name_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_5_container'>\n                                            <label for='{$field_id}_5' id='{$field_id}_5_label' {$sub_label_class_attribute}>{$card_name_label}</label>\n                                            <input type='text' name='input_{$id}.5' id='{$field_id}_5' value='{$card_name}' {$tabindex} {$disabled_text} {$card_name_placeholder}/>\n                                        </span>";
     } else {
         $card_name_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_5_container'>\n                                            <input type='text' name='input_{$id}.5' id='{$field_id}_5' value='{$card_name}' {$tabindex} {$disabled_text} {$card_name_placeholder}/>\n                                            <label for='{$field_id}_5' id='{$field_id}_5_label' {$sub_label_class_attribute}>{$card_name_label}</label>\n                                        </span>";
     }
     return "<div class='ginput_complex{$class_suffix} ginput_container ginput_container_creditcard' id='{$field_id}'>" . $card_field . $expiration_field . $security_field . $card_name_field . ' </div>';
 }
 public function is_entry_list()
 {
     if (rgget('page') == 'gf_entries' && (rgget('view') == 'entries' || rgempty('view', $_GET))) {
         return true;
     }
     return false;
 }
Example #19
0
 public static function get_label($field, $input_id = 0, $input_only = false)
 {
     $field_label = (IS_ADMIN || RG_CURRENT_PAGE == "select_columns.php" || RG_CURRENT_PAGE == "print-entry.php" || rgget("gf_page", $_GET) == "select_columns" || rgget("gf_page", $_GET) == "print-entry") && !rgempty("adminLabel", $field) ? rgar($field, "adminLabel") : rgar($field, "label");
     $input = self::get_input($field, $input_id);
     if (rgget("type", $field) == "checkbox" && $input != null) {
         return $input["label"];
     } else {
         if ($input != null) {
             return $input_only ? $input["label"] : $field_label . ' (' . $input["label"] . ')';
         } else {
             return $field_label;
         }
     }
 }
Example #20
0
    public static function leads_page($form_id)
    {
        global $wpdb;
        //quit if version of wp is not supported
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $action = RGForms::post("action");
        $filter = rgget("filter");
        $search = rgget("s");
        $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1;
        $star = $filter == "star" ? 1 : null;
        $read = $filter == "unread" ? 0 : null;
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $search_criteria["status"] = $status;
        if ($star) {
            $search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
        }
        $search_field_id = rgget("field_id");
        $search_operator = rgget("operator");
        if (isset($_GET["field_id"]) && $_GET["field_id"] !== '') {
            $key = $search_field_id;
            $val = rgget("s");
            $strpos_row_key = strpos($search_field_id, "|");
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode("|", $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ":" . $val;
            }
            if ("entry_id" == $key) {
                $key = "id";
            }
            $search_criteria["field_filters"][] = array("key" => $key, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
        }
        $update_message = "";
        switch ($action) {
            case "delete":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $lead_id = $_POST["action_argument"];
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    RGFormsModel::delete_lead($lead_id);
                    $update_message = __("Entry deleted.", "gravityforms");
                } else {
                    $update_message = __("You don't have adequate permissions to delete entries.", "gravityforms");
                }
                break;
            case "bulk":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $bulk_action = !empty($_POST["bulk_action"]) ? $_POST["bulk_action"] : $_POST["bulk_action2"];
                $select_all = rgpost("all_entries");
                $leads = empty($select_all) ? $_POST["lead"] : GFFormsModel::search_lead_ids($form_id, $search_criteria);
                $entry_count = count($leads) > 1 ? sprintf(__("%d entries", "gravityforms"), count($leads)) : __("1 entry", "gravityforms");
                switch ($bulk_action) {
                    case "delete":
                        if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                            RGFormsModel::delete_leads($leads);
                            $update_message = sprintf(__("%s deleted.", "gravityforms"), $entry_count);
                        } else {
                            $update_message = __("You don't have adequate permissions to delete entries.", "gravityforms");
                        }
                        break;
                    case "trash":
                        RGFormsModel::update_leads_property($leads, "status", "trash");
                        $update_message = sprintf(__("%s moved to Trash.", "gravityforms"), $entry_count);
                        break;
                    case "restore":
                        RGFormsModel::update_leads_property($leads, "status", "active");
                        $update_message = sprintf(__("%s restored from the Trash.", "gravityforms"), $entry_count);
                        break;
                    case "unspam":
                        RGFormsModel::update_leads_property($leads, "status", "active");
                        $update_message = sprintf(__("%s restored from the spam.", "gravityforms"), $entry_count);
                        break;
                    case "spam":
                        RGFormsModel::update_leads_property($leads, "status", "spam");
                        $update_message = sprintf(__("%s marked as spam.", "gravityforms"), $entry_count);
                        break;
                    case "mark_read":
                        RGFormsModel::update_leads_property($leads, "is_read", 1);
                        $update_message = sprintf(__("%s marked as read.", "gravityforms"), $entry_count);
                        break;
                    case "mark_unread":
                        RGFormsModel::update_leads_property($leads, "is_read", 0);
                        $update_message = sprintf(__("%s marked as unread.", "gravityforms"), $entry_count);
                        break;
                    case "add_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 1);
                        $update_message = sprintf(__("%s starred.", "gravityforms"), $entry_count);
                        break;
                    case "remove_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 0);
                        $update_message = sprintf(__("%s unstarred.", "gravityforms"), $entry_count);
                        break;
                }
                break;
            case "change_columns":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $columns = GFCommon::json_decode(stripslashes($_POST["grid_columns"]), true);
                RGFormsModel::update_grid_column_meta($form_id, $columns);
                break;
        }
        if (rgpost("button_delete_permanently")) {
            if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                RGFormsModel::delete_leads_by_form($form_id, $filter);
            }
        }
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"];
        $form = RGFormsModel::get_form_meta($form_id);
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $page_size = apply_filters("gform_entry_page_size", apply_filters("gform_entry_page_size_{$form_id}", 20, $form_id), $form_id);
        $first_item_index = $page_index * $page_size;
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET["sort"], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $paging = array('offset' => $first_item_index, 'page_size' => $page_size);
        $total_count = 0;
        $leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging, $total_count);
        $summary = RGFormsModel::get_form_counts($form_id);
        $active_lead_count = $summary["total"];
        $unread_count = $summary["unread"];
        $starred_count = $summary["starred"];
        $spam_count = $summary["spam"];
        $trash_count = $summary["trash"];
        $columns = RGFormsModel::get_grid_columns($form_id, true);
        $search_qs = empty($search) ? "" : "&s=" . urlencode($search);
        $sort_qs = empty($sort_field) ? "" : "&sort={$sort_field}";
        $dir_qs = empty($sort_field) ? "" : "&dir={$sort_direction}";
        $star_qs = $star !== null ? "&star={$star}" : "";
        $read_qs = $read !== null ? "&read={$read}" : "";
        $filter_qs = "&filter=" . $filter;
        $search_field_id_qs = !isset($_GET["field_id"]) ? "" : "&field_id={$search_field_id}";
        $search_operator_urlencoded = urlencode($search_operator);
        $search_operator_qs = empty($search_operator_urlencoded) ? "" : "&operator={$search_operator_urlencoded}";
        $display_total = ceil($total_count / $page_size);
        $page_links = paginate_links(array('base' => admin_url("admin.php") . "?page=gf_entries&view=entries&id={$form_id}&%_%" . $search_qs . $sort_qs . $dir_qs . $star_qs . $read_qs . $filter_qs . $search_field_id_qs . $search_operator_qs, 'format' => 'paged=%#%', 'prev_text' => __('&laquo;', 'gravityforms'), 'next_text' => __('&raquo;', 'gravityforms'), 'total' => $display_total, 'current' => $page_index + 1, 'show_all' => false));
        wp_print_styles(array("thickbox"));
        $field_filters = GFCommon::get_field_filter_settings($form);
        $init_field_id = empty($search_field_id) ? 0 : $search_field_id;
        $init_field_operator = empty($search_operator) ? "contains" : $search_operator;
        $init_filter_vars = array("mode" => "off", "filters" => array(array("field" => $init_field_id, "operator" => $init_field_operator, "value" => $search)));
        ?>

        <script type="text/javascript">

            var messageTimeout = false,
                gformFieldFilters = <?php 
        echo json_encode($field_filters);
        ?>
,
                gformInitFilter = <?php 
        echo json_encode($init_filter_vars);
        ?>

            function ChangeColumns(columns){
                jQuery("#action").val("change_columns");
                jQuery("#grid_columns").val(jQuery.toJSON(columns));
                tb_remove();
                jQuery("#lead_form")[0].submit();
            }

            function Search(sort_field_id, sort_direction, form_id, search, star, read, filter, field_id, operator){
                var search_qs = search == "" ? "" : "&s=" + search;
                var star_qs = star == "" ? "" : "&star=" + star;
                var read_qs = read == "" ? "" : "&read=" + read;
                var filter_qs = filter == "" ? "" : "&filter=" + filter;
                var field_id_qs = field_id == "" ? "" : "&field_id=" + field_id;
                var operator_qs = operator == "" ? "" : "&operator=" + operator;

                var location = "?page=gf_entries&view=entries&id=" + form_id + "&sort=" + sort_field_id + "&dir=" + sort_direction + search_qs + star_qs + read_qs + filter_qs + field_id_qs + operator_qs;
                document.location = location;
            }

            function ToggleStar(img, lead_id, filter){
                var is_starred = img.src.indexOf("star1.png") >=0
                if(is_starred)
                    img.src = img.src.replace("star1.png", "star0.png");
                else
                    img.src = img.src.replace("star0.png", "star1.png");

                jQuery("#lead_row_" + lead_id).toggleClass("lead_starred");
                //if viewing the starred entries, hide the row and adjust the paging counts
                if (filter == "star")
                {
                	var title = jQuery("#lead_row_" + lead_id);
                	title.css("display", "none");
                	UpdatePagingCounts(1);
				}

                UpdateCount("star_count", is_starred ? -1 : 1);

                UpdateLeadProperty(lead_id, "is_starred", is_starred ? 0 : 1);
            }

            function ToggleRead(lead_id, filter){
                var title = jQuery("#lead_row_" + lead_id);
                marking_read = title.hasClass("lead_unread");

                jQuery("#mark_read_" + lead_id).css("display", marking_read ? "none" : "inline");
                jQuery("#mark_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
                jQuery("#is_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
                title.toggleClass("lead_unread");
                //if viewing the unread entries, hide the row and adjust the paging counts
                if (filter == "unread")
                {
                	title.css("display", "none");
                	UpdatePagingCounts(1);
				}

                UpdateCount("unread_count", marking_read ? -1 : 1);
                UpdateLeadProperty(lead_id, "is_read", marking_read ? 1 : 0);
            }

            function UpdateLeadProperty(lead_id, name, value){
                var mysack = new sack("<?php 
        echo admin_url("admin-ajax.php");
        ?>
" );
                mysack.execute = 1;
                mysack.method = 'POST';
                mysack.setVar( "action", "rg_update_lead_property" );
                mysack.setVar( "rg_update_lead_property", "<?php 
        echo wp_create_nonce("rg_update_lead_property");
        ?>
" );
                mysack.setVar( "lead_id", lead_id);
                mysack.setVar( "name", name);
                mysack.setVar( "value", value);
                mysack.onError = function() { alert('<?php 
        echo esc_js(__("Ajax error while setting lead property", "gravityforms"));
        ?>
' )};
                mysack.runAJAX();

                return true;
            }

            function UpdateCount(element_id, change){
                var element = jQuery("#" + element_id);
                var count = parseInt(element.html()) + change
                element.html(count + "");
            }

            function UpdatePagingCounts(change){
				//update paging header/footer Displaying # - # of #, use counts from header, no need to use footer since they are the same, just update footer paging with header info
                var paging_range_max_header = jQuery("#paging_range_max_header");
                var paging_range_max_footer = jQuery("#paging_range_max_footer");
                var range_change_max = parseInt(paging_range_max_header.html()) - change;
                var paging_total_header = jQuery("#paging_total_header");
                var paging_total_footer = jQuery("#paging_total_footer");
                var total_change = parseInt(paging_total_header.html()) - change;
                var paging_range_min_header = jQuery("#paging_range_min_header");
                var paging_range_min_footer = jQuery("#paging_range_min_footer");
				//if min and max are the same, this is the last entry item on the page, clear out the displaying # - # of # text
                if (parseInt(paging_range_min_header.html()) == parseInt(paging_range_max_header.html()))
                {
					var paging_header = jQuery("#paging_header");
					paging_header.html("");
					var paging_footer = jQuery("#paging_footer");
					paging_footer.html("");
                }
                else
                {
                	paging_range_max_header.html(range_change_max + "");
                	paging_range_max_footer.html(range_change_max + "");
                	paging_total_header.html(total_change + "");
                	paging_total_footer.html(total_change + "");
				}
                gformVars.countAllEntries = gformVars.countAllEntries - change;
                setSelectAllText();
            }

            function DeleteLead(lead_id){
                jQuery("#action").val("delete");
                jQuery("#action_argument").val(lead_id);
                jQuery("#lead_form")[0].submit();
                return true;
            }

            function handleBulkApply(actionElement){

                var action = jQuery("#" + actionElement).val();
                var defaultModalOptions = '';
                var leadIds = getLeadIds();

                if(leadIds.length == 0){
                    alert('<?php 
        _e('Please select at least one entry.', 'gravityforms');
        ?>
');
                    return false;
                }

                switch(action){

                case 'resend_notifications':
                    resetResendNotificationsUI();
                    tb_show('<?php 
        _e("Resend Notifications", "gravityforms");
        ?>
', '#TB_inline?width=350&amp;inlineId=notifications_modal_container', '');
                    return false;
                    break;

                case 'print':
                    resetPrintUI();
                    tb_show('<?php 
        _e("Print Entries", "gravityforms");
        ?>
', '#TB_inline?width=350&amp;height=250&amp;inlineId=print_modal_container', '');
                    return false;
                    break;

                default:
                    jQuery('#action').val('bulk');
                }

            }

            function getLeadIds(){
                var all = jQuery("#all_entries").val();
                //compare string, the boolean isn't correct, even when casting to a boolean the 0 is set to true
                if(all == "1")
                    return 0;

                var leads = jQuery(".check-column input[name='lead[]']:checked");
                var leadIds = new Array();

                jQuery(leads).each(function(i){
                    leadIds[i] = jQuery(leads[i]).val();
                });

                return leadIds;
            }

            function BulkResendNotifications(){


                var selectedNotifications = new Array();
                jQuery(".gform_notifications:checked").each(function(){
                    selectedNotifications.push(jQuery(this).val());
                });
                var leadIds = getLeadIds();

                var sendTo = jQuery('#notification_override_email').val();

                if(selectedNotifications.length <=0) {
                    displayMessage("<?php 
        _e("You must select at least one type of notification to resend.", "gravityforms");
        ?>
", "error", "#notifications_container");
                    return;
                }

                jQuery('#please_wait_container').fadeIn();

                jQuery.post(ajaxurl, {
                    action : "gf_resend_notifications",
                    gf_resend_notifications : '<?php 
        echo wp_create_nonce('gf_resend_notifications');
        ?>
',
                    notifications: jQuery.toJSON(selectedNotifications),
                    sendTo : sendTo,
                    leadIds : leadIds,
                    filter: '<?php 
        echo esc_attr(rgget("filter"));
        ?>
',
                    search: '<?php 
        echo esc_attr(rgget("s"));
        ?>
',
                    operator: '<?php 
        echo esc_attr(rgget("operator"));
        ?>
',
                    fieldId: '<?php 
        echo esc_attr(rgget("field_id"));
        ?>
',
                    formId : '<?php 
        echo $form['id'];
        ?>
'
                    },
                    function(response){

                        jQuery('#please_wait_container').hide();

                        if(response) {
                            displayMessage(response, "error", "#notifications_container");
                        } else {
                            var message = '<?php 
        _e("Notifications for %s were resent successfully.", "gravityforms");
        ?>
';
                            var c = leadIds == 0 ? gformVars.countAllEntries : leadIds.length;
                            displayMessage(message.replace('%s', c + ' ' + getPlural(c, '<?php 
        _e('entry', 'gravityforms');
        ?>
', '<?php 
        _e('entries', 'gravityforms');
        ?>
')), "updated", "#lead_form");
                            closeModal(true);
                        }

                    }
                );

            }

            function resetResendNotificationsUI(){

                jQuery('#notification_admin, #notification_user').attr('checked', false);
                jQuery('#notifications_container .message, #notifications_override_settings').hide();

            }

            function BulkPrint(){

                var leadIds = getLeadIds();
                if(leadIds != 0)
                    leadIds = leadIds.join(',');
                var leadsQS = '&lid=' + leadIds;
                var notesQS = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : '';
                var pageBreakQS = jQuery('#gform_print_page_break').is(':checked') ? '&page_break=1' : '';
                var filterQS = '&filter=<?php 
        echo esc_attr(rgget("filter"));
        ?>
';
                var searchQS = '&s=<?php 
        echo esc_attr(rgget("s"));
        ?>
';
                var searchFieldIdQS = '&field_id=<?php 
        echo esc_attr(rgget("field_id"));
        ?>
';
                var searchOperatorQS = '&operator=<?php 
        echo esc_attr(rgget("operator"));
        ?>
';

                var url = '<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo $form['id'];
        ?>
' + leadsQS + notesQS + pageBreakQS + filterQS + searchQS + searchFieldIdQS + searchOperatorQS;
                window.open (url,'printwindow');

                closeModal(true);
                hideMessage('#lead_form', false);
            }

            function resetPrintUI(){

                jQuery('#print_options input[type="checkbox"]').attr('checked', false);

            }

            function displayMessage(message, messageClass, container){

                hideMessage(container, true);

                var messageBox = jQuery('<div class="message ' + messageClass + '" style="display:none;"><p>' + message + '</p></div>');
                jQuery(messageBox).prependTo(container).slideDown();

                if(messageClass == 'updated')
                    messageTimeout = setTimeout(function(){ hideMessage(container, false); }, 10000);

            }

            function hideMessage(container, messageQueued){

                if(messageTimeout)
                    clearTimeout(messageTimeout);

                var messageBox = jQuery(container).find('.message');

                if(messageQueued)
                    jQuery(messageBox).remove();
                else
                    jQuery(messageBox).slideUp(function(){ jQuery(this).remove(); });

            }

            function closeModal(isSuccess) {

                if(isSuccess)
                    jQuery('.check-column input[type="checkbox"]').attr('checked', false);

                tb_remove();

            }

            function getPlural(count, singular, plural) {
                return count > 1 ? plural : singular;
            }

            function toggleNotificationOverride(isInit) {

                if(isInit)
                    jQuery('#notification_override_email').val('');

                if(jQuery(".gform_notifications:checked").length > 0 ) {
                    jQuery('#notifications_override_settings').slideDown();
                } else {
                    jQuery('#notifications_override_settings').slideUp(function(){
                        jQuery('#notification_override_email').val('');
                    });
                }

            }

            // Select All

            var gformStrings = {
                "allEntriesOnPageAreSelected" : "<?php 
        printf(__("All %s{0}%s entries on this page are selected.", "gravityforms"), "<strong>", "</strong>");
        ?>
",
                "selectAll" : "<?php 
        printf(__("Select all %s{0}%s entries.", "gravityforms"), "<strong>", "</strong>");
        ?>
",
                "allEntriesSelected" : "<?php 
        printf(__("All %s{0}%s entries have been selected.", "gravityforms"), "<strong>", "</strong>");
        ?>
",
                "clearSelection" : "<?php 
        _e("Clear selection", "gravityforms");
        ?>
"
            }

            var gformVars = {
                "countAllEntries" : <?php 
        echo intval($total_count);
        ?>
,
                "perPage" : <?php 
        echo intval($page_size);
        ?>
            }

            function setSelectAllText(){
                var tr = getSelectAllText();
                jQuery("#gform-select-all-message td").html(tr);
            }

            function getSelectAllText(){
                var count;
                count = jQuery("#gf_entry_list tr:visible:not('#gform-select-all-message')").length;
                return gformStrings.allEntriesOnPageAreSelected.format(count) + " <a href='javascript:void(0)' onclick='selectAllEntriesOnAllPages();'>" + gformStrings.selectAll.format(gformVars.countAllEntries) + "</a>";
            }

            function getSelectAllTr(){
                var t = getSelectAllText();
                var colspan = jQuery("#gf_entry_list").find("tr:first td").length + 1;
                return "<tr id='gform-select-all-message' style='display:none;background-color:lightyellow;text-align:center;'><td colspan='{0}'>{1}</td></tr>".format(colspan, t);
            }
            function toggleSelectAll(visible){
                if(gformVars.countAllEntries <= gformVars.perPage){
                    jQuery('#gform-select-all-message').hide();
                    return;
                }

                if(visible)
                    setSelectAllText();
                jQuery('#gform-select-all-message').toggle(visible);
            }


            function clearSelectAllEntries(){
                jQuery(".check-column input[type=checkbox]").prop('checked', false);
                clearSelectAllMessage();
            }

            function clearSelectAllMessage(){
                jQuery("#all_entries").val("0");
                jQuery("#gform-select-all-message").hide();
                jQuery("#gform-select-all-message td").html('');
            }

            function selectAllEntriesOnAllPages (){
                var trHtmlClearSelection;
                trHtmlClearSelection = gformStrings.allEntriesSelected.format(gformVars.countAllEntries) + " <a href='javascript:void(0);' onclick='clearSelectAllEntries();'>" + gformStrings.clearSelection + "</a>";
                jQuery("#all_entries").val("1");
                jQuery("#gform-select-all-message td").html(trHtmlClearSelection);
            }

            function initSelectAllEntries(){

                if(gformVars.countAllEntries > gformVars.perPage){
                    var tr = getSelectAllTr();
                    jQuery("#gf_entry_list").prepend(tr);
                    jQuery(".headercb").click(function(){
                        toggleSelectAll(jQuery(this).prop('checked'));
                    });
                    jQuery("#gf_entry_list .check-column input[type=checkbox]").click(function(){
                        clearSelectAllMessage();
                    })
                }
            }

            String.prototype.format = function() {
                var args = arguments;
                return this.replace(/{(\d+)}/g, function (match, number) {
                    return typeof args[number] != 'undefined' ? args[number] : match;
                });
            };

            // end Select All

            jQuery(document).ready(function(){


                var action = '<?php 
        echo $action;
        ?>
';
                var message = '<?php 
        echo $update_message;
        ?>
';
                if(action && message)
                    displayMessage(message, 'updated', '#lead_form');

                var list = jQuery("#gf_entry_list").wpList( { alt: '<?php 
        echo esc_js(__('Entry List', 'gravityforms'));
        ?>
'} );
                list.bind('wpListDelEnd', function(e, s, list){

                    var currentStatus = "<?php 
        echo $filter == "trash" || $filter == "spam" ? $filter : "active";
        ?>
";
                    var filter = "<?php 
        echo $filter;
        ?>
";
                    var movingTo = "active";
                    if(s.data.status == "trash")
                        movingTo = "trash";
                    else if(s.data.status == "spam")
                        movingTo = "spam";
                    else if(s.data.status == "delete")
                        movingTo = "delete";

                    var id = s.data.entry;
                    var title = jQuery("#lead_row_" + id);
                    var isUnread = title.hasClass("lead_unread");
                    var isStarred = title.hasClass("lead_starred");

                    if(movingTo != "delete"){
                        //Updating All count
                        var allCount = currentStatus == "active" ? -1 : 1;
                        UpdateCount("all_count", allCount);

                        //Updating Unread count
                        if(isUnread){
                            var unreadCount = currentStatus == "active" ? -1 : 1;
                            UpdateCount("unread_count", unreadCount);
                        }

                        //Updating Starred count
                        if(isStarred){
                            var starCount = currentStatus == "active" ? -1 : 1;
                            UpdateCount("star_count", starCount);
                        }
                    }

                    //Updating Spam count
                    if(currentStatus == "spam" || movingTo == "spam"){
                        var spamCount = movingTo == "spam" ? 1 : -1;
                        UpdateCount("spam_count", spamCount);
                        //adjust paging counts
                        if (filter == "spam")
                        {
                        	UpdatePagingCounts(1);
						}
						else
						{
							UpdatePagingCounts(spamCount);
						}
                    }

                    //Updating trash count
                    if(currentStatus == "trash" || movingTo == "trash"){
                        var trashCount = movingTo == "trash" ? 1 : -1;
                        UpdateCount("trash_count", trashCount);
                        //adjust paging counts
                        if (filter == "trash")
                        {
                        	UpdatePagingCounts(1);
						}
						else
						{
							UpdatePagingCounts(trashCount);
						}
                    }

                });

                initSelectAllEntries();

                jQuery('#entry_filters').gfFilterUI(gformFieldFilters, gformInitFilter, false);
                jQuery("#entry_filters").on("keypress", ".gform-filter-value", (function(event){
                    if(event.keyCode == 13){
                        Search('<?php 
        echo $sort_field;
        ?>
', '<?php 
        echo $sort_direction;
        ?>
', <?php 
        echo $form_id;
        ?>
, jQuery('.gform-filter-value').val(), '<?php 
        echo $star;
        ?>
', '<?php 
        echo $read;
        ?>
', '<?php 
        echo $filter;
        ?>
', jQuery('.gform-filter-field').val(), jQuery('.gform-filter-operator').val());
                        event.preventDefault();
                    }
                }));
            });


        </script>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" type="text/css" />
        <style>
            /*#TB_window { height: 400px !important; }
            #TB_ajaxContent[style] { height: 370px !important; }*/
            .lead_unread a, .lead_unread td{font-weight: bold;}
            .lead_spam_trash a, .lead_spam_trash td{font-weight:normal;}
            .row-actions a { font-weight:normal;}
            .entry_nowrap{ overflow:hidden; white-space:nowrap; }
            .message { margin: 15px 0 0 !important; }
            .gform-filter-operator{width:100px}
        </style>


        <div class="wrap <?php 
        echo GFCommon::get_browser_class();
        ?>
">
            <h2 class="gf_admin_page_title"><span><?php 
        _e("Entries", "gravityforms");
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo $form['id'];
        ?>
</span><span class="gf_admin_page_formname"><?php 
        _e("Form Name", "gravityforms");
        ?>
: <?php 
        echo $form['title'];
        ?>
</span></span></h2>

            <?php 
        RGForms::top_toolbar();
        ?>

            <form id="lead_form" method="post">
                <?php 
        wp_nonce_field('gforms_entry_list', 'gforms_entry_list');
        ?>

                <input type="hidden" value="" name="grid_columns" id="grid_columns" />
                <input type="hidden" value="" name="action" id="action" />
                <input type="hidden" value="" name="action_argument" id="action_argument" />
                <input type="hidden" value="" name="all_entries" id="all_entries" />

                <ul class="subsubsub">
                    <li><a class="<?php 
        echo empty($filter) ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
"><?php 
        _e("All", "gravityforms");
        ?>
 <span class="count">(<span id="all_count"><?php 
        echo $active_lead_count;
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $read !== null ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
&filter=unread"><?php 
        _e("Unread", "gravityforms");
        ?>
 <span class="count">(<span id="unread_count"><?php 
        echo $unread_count;
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $star !== null ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
&filter=star"><?php 
        _e("Starred", "gravityforms");
        ?>
 <span class="count">(<span id="star_count"><?php 
        echo $starred_count;
        ?>
</span>)</span></a> | </li>
                    <?php 
        if (GFCommon::akismet_enabled($form_id)) {
            ?>
                        <li><a class="<?php 
            echo $filter == "spam" ? "current" : "";
            ?>
" href="?page=gf_entries&view=entries&id=<?php 
            echo $form_id;
            ?>
&filter=spam"><?php 
            _e("Spam", "gravityforms");
            ?>
 <span class="count">(<span id="spam_count"><?php 
            echo $spam_count;
            ?>
</span>)</span></a> | </li>
                        <?php 
        }
        ?>
                    <li><a class="<?php 
        echo $filter == "trash" ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
&filter=trash"><?php 
        _e("Trash", "gravityforms");
        ?>
 <span class="count">(<span id="trash_count"><?php 
        echo $trash_count;
        ?>
</span>)</span></a></li>
                </ul>
                <div style="margin-top:12px;float:right;">
                    <a style="float:right;" class="button" id="lead_search_button" href="javascript:Search('<?php 
        echo $sort_field;
        ?>
', '<?php 
        echo $sort_direction;
        ?>
', <?php 
        echo $form_id;
        ?>
, jQuery('.gform-filter-value').val(), '<?php 
        echo $star;
        ?>
', '<?php 
        echo $read;
        ?>
', '<?php 
        echo $filter;
        ?>
', jQuery('.gform-filter-field').val(), jQuery('.gform-filter-operator').val());"><?php 
        _e("Search", "gravityforms");
        ?>
</a>
                    <div id="entry_filters" style="float:right"></div>
                </div>
                <div class="tablenav">

                    <div class="alignleft actions" style="padding:8px 0 7px 0;">
                        <label class="hidden" for="bulk_action"> <?php 
        _e("Bulk action", "gravityforms");
        ?>
</label>
                        <select name="bulk_action" id="bulk_action">
                            <option value=''><?php 
        _e(" Bulk action ", "gravityforms");
        ?>
</option>
                            <?php 
        switch ($filter) {
            case "trash":
                ?>
                                    <option value='restore'><?php 
                _e("Restore", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            case "spam":
                ?>
                                    <option value='unspam'><?php 
                _e("Not Spam", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            default:
                ?>
                                    <option value='mark_read'><?php 
                _e("Mark as Read", "gravityforms");
                ?>
</option>
                                    <option value='mark_unread'><?php 
                _e("Mark as Unread", "gravityforms");
                ?>
</option>
                                    <option value='add_star'><?php 
                _e("Add Star", "gravityforms");
                ?>
</option>
                                    <option value='remove_star'><?php 
                _e("Remove Star", "gravityforms");
                ?>
</option>
                                    <option value='resend_notifications'><?php 
                _e("Resend Notifications", "gravityforms");
                ?>
</option>
                                    <option value='print'><?php 
                _e("Print", "gravityforms");
                ?>
</option>

                                    <?php 
                if (GFCommon::akismet_enabled($form_id)) {
                    ?>
                                        <option value='spam'><?php 
                    _e("Spam", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='trash'><?php 
                    _e("Trash", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
        }
        ?>
                        </select>
                        <?php 
        $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return handleBulkApply(\'bulk_action\');" />';
        echo apply_filters("gform_entry_apply_button", $apply_button);
        if (in_array($filter, array("trash", "spam"))) {
            $message = $filter == "trash" ? __("WARNING! This operation cannot be undone. Empty trash? \\'Ok\\' to empty trash. \\'Cancel\\' to abort.", "gravityforms") : __("WARNING! This operation cannot be undone. Permanently delete all spam? \\'Ok\\' to delete. \\'Cancel\\' to abort.", "gravityforms");
            $button_label = $filter == "trash" ? __("Empty Trash", "gravityforms") : __("Delete All Spam", "gravityforms");
            ?>
                            <input type="submit" class="button" name="button_delete_permanently" value="<?php 
            echo $button_label;
            ?>
" onclick="return confirm('<?php 
            echo esc_attr($message);
            ?>
');" />
                            <?php 
        }
        ?>
                        <div id="notifications_modal_container" style="display:none;">
                            <div id="notifications_container">

                                <div id="post_tag" class="tagsdiv">
                                    <div id="resend_notifications_options">

                                        <?php 
        if (!is_array($form["notifications"]) || count($form["notifications"]) <= 0) {
            ?>
                                            <p class="description"><?php 
            _e("You cannot resend notifications for these entries because this form does not currently have any notifications configured.", "gravityforms");
            ?>
</p>

                                            <a href="<?php 
            echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form["id"]}");
            ?>
" class="button"><?php 
            _e("Configure Notifications", "gravityforms");
            ?>
</a>
                                            <?php 
        } else {
            ?>
                                            <p class="description"><?php 
            _e("Specify which notifications you would like to resend for the selected entries.", "gravityforms");
            ?>
</p>
                                            <?php 
            foreach ($form["notifications"] as $notification) {
                ?>
                                                <input type="checkbox" class="gform_notifications" value="<?php 
                echo $notification["id"];
                ?>
" id="notification_<?php 
                echo $notification["id"];
                ?>
" onclick="toggleNotificationOverride();" />
                                                <label for="notification_<?php 
                echo $notification["id"];
                ?>
"><?php 
                echo $notification["name"];
                ?>
</label> <br /><br />
                                                <?php 
            }
            ?>
                                            <div id="notifications_override_settings" style="display:none;">

                                                <p class="description" style="padding-top:0; margin-top:0;">You may override the default notification settings
                                                    by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
                                                <label for="notification_override_email"><?php 
            _e("Send To", "gravityforms");
            ?>
 <?php 
            gform_tooltip("notification_override_email");
            ?>
</label><br />
                                                <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" /><br /><br />

                                            </div>

                                            <input type="button" name="notification_resend" id="notification_resend" value="<?php 
            _e("Resend Notifications", "gravityforms");
            ?>
" class="button" style="" onclick="BulkResendNotifications();"/>
                                            <span id="please_wait_container" style="display:none; margin-left: 5px;">
                                                <img src="<?php 
            echo GFCommon::get_base_url();
            ?>
/images/loading.gif"> <?php 
            _e("Resending...", "gravityforms");
            ?>
                                            </span>
                                            <?php 
        }
        ?>

                                    </div>

                                    <div id="resend_notifications_close" style="display:none;margin:10px 0 0;">
                                        <input type="button" name="resend_notifications_close_button" value="<?php 
        _e("Close Window", "gravityforms");
        ?>
" class="button" style="" onclick="closeModal(true);"/>
                                    </div>

                                </div>

                            </div>
                        </div> <!-- / Resend Notifications -->

                        <div id="print_modal_container" style="display:none;">
                            <div id="print_container">

                                <div class="tagsdiv">
                                    <div id="print_options">

                                        <p class="description"><?php 
        _e("Print all of the selected entries at once.", "gravityforms");
        ?>
</p>

                                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                                            <input type="checkbox" name="gform_print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
                                            <label for="gform_print_notes"><?php 
            _e("Include notes", "gravityforms");
            ?>
</label>
                                            <br /><br />
                                        <?php 
        }
        ?>

                                        <input type="checkbox" name="gform_print_page_break" value="print_notes" checked="checked" id="gform_print_page_break" />
                                        <label for="gform_print_page_break"><?php 
        _e("Add page break between entries", "gravityforms");
        ?>
</label>
                                        <br /><br />

                                        <input type="button" value="<?php 
        _e("Print", "gravityforms");
        ?>
" class="button" onclick="BulkPrint();" />

                                    </div>
                                </div>

                            </div>
                        </div> <!-- / Print -->

                    </div>

                    <?php 
        echo self::display_paging_links("header", $page_links, $first_item_index, $page_size, $total_count);
        ?>

                    <div class="clear"></div>
                </div>

                <table class="widefat fixed" cellspacing="0">
                <thead>
                    <tr>
                        <th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" class="headercb" /></th>
                        <?php 
        if (!in_array($filter, array("spam", "trash"))) {
            ?>
                            <th scope="col" id="cb" class="manage-column column-cb check-column" >&nbsp;</th>
                            <?php 
        }
        foreach ($columns as $field_id => $field_info) {
            $dir = $field_id == 0 ? "DESC" : "ASC";
            //default every field so ascending sorting except date_created (id=0)
            if ($field_id == $sort_field) {
                //reverting direction if clicking on the currently sorted field
                $dir = $sort_direction == "ASC" ? "DESC" : "ASC";
            }
            ?>
                            <th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php 
            echo $field_id;
            ?>
', '<?php 
            echo $dir;
            ?>
', <?php 
            echo $form_id;
            ?>
, '<?php 
            echo $search;
            ?>
', '<?php 
            echo $star;
            ?>
', '<?php 
            echo $read;
            ?>
', '<?php 
            echo $filter;
            ?>
', '<?php 
            echo $search_field_id;
            ?>
', '<?php 
            echo $search_operator;
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info["label"]);
            ?>
</th>
                            <?php 
        }
        ?>
                        <th scope="col" align="right" width="50">
                            <a title="<?php 
        _e("click to select columns to display", "gravityforms");
        ?>
" href="<?php 
        echo trailingslashit(site_url(null, "admin"));
        ?>
?gf_page=select_columns&id=<?php 
        echo $form_id;
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><i class="fa fa-cog"></i></a>
                        </th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
                        <?php 
        if (!in_array($filter, array("spam", "trash"))) {
            ?>
                            <th scope="col" id="cb" class="manage-column column-cb check-column" >&nbsp;</th>
                        <?php 
        }
        foreach ($columns as $field_id => $field_info) {
            $dir = $field_id == 0 ? "DESC" : "ASC";
            //default every field so ascending sorting except date_created (id=0)
            if ($field_id == $sort_field) {
                //reverting direction if clicking on the currently sorted field
                $dir = $sort_direction == "ASC" ? "DESC" : "ASC";
            }
            ?>
                            <th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php 
            echo $field_id;
            ?>
', '<?php 
            echo $dir;
            ?>
', <?php 
            echo $form_id;
            ?>
, '<?php 
            echo $search;
            ?>
', '<?php 
            echo $star;
            ?>
', '<?php 
            echo $read;
            ?>
', '<?php 
            echo $filter;
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info["label"]);
            ?>
</th>
                            <?php 
        }
        ?>
                        <th scope="col" style="width:15px;">
                            <a title="<?php 
        _e("click to select columns to display", "gravityforms");
        ?>
" href="<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=select_columns&id=<?php 
        echo $form_id;
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><i class=fa-cog"></i></a>
                        </th>
                    </tr>
                </tfoot>

                <tbody data-wp-lists="list:gf_entry" class="user-list" id="gf_entry_list">
                    <?php 
        if (sizeof($leads) > 0) {
            $field_ids = array_keys($columns);
            $gf_entry_locking = new GFEntryLocking();
            $alternate_row = false;
            foreach ($leads as $position => $lead) {
                $position = $page_size * $page_index + $position;
                ?>
                            <tr id="lead_row_<?php 
                echo $lead["id"];
                ?>
" class='author-self status-inherit <?php 
                echo $lead["is_read"] ? "" : "lead_unread";
                ?>
 <?php 
                echo $lead["is_starred"] ? "lead_starred" : "";
                ?>
 <?php 
                echo in_array($filter, array("trash", "spam")) ? "lead_spam_trash" : "";
                ?>
 <?php 
                $gf_entry_locking->list_row_class($lead["id"]);
                ?>
 <?php 
                echo ($alternate_row = !$alternate_row) ? 'alternate' : '';
                ?>
'  valign="top" data-id="<?php 
                echo esc_attr($lead["id"]);
                ?>
">
                                <th scope="row" class="check-column">
                                    <input type="checkbox" name="lead[]" value="<?php 
                echo $lead["id"];
                ?>
" />
                                    <?php 
                $gf_entry_locking->lock_indicator();
                ?>
                                </th>
                                <?php 
                if (!in_array($filter, array("spam", "trash"))) {
                    ?>
                                    <td >
                                        <img id="star_image_<?php 
                    echo $lead["id"];
                    ?>
" src="<?php 
                    echo GFCommon::get_base_url();
                    ?>
/images/star<?php 
                    echo intval($lead["is_starred"]);
                    ?>
.png" onclick="ToggleStar(this, <?php 
                    echo $lead["id"] . ",'" . $filter . "'";
                    ?>
);" />
                                    </td>
                                <?php 
                }
                $is_first_column = true;
                $nowrap_class = "entry_nowrap";
                foreach ($field_ids as $field_id) {
                    /* maybe move to function */
                    $field = RGFormsModel::get_field($form, $field_id);
                    $value = rgar($lead, $field_id);
                    if ($field['type'] == 'post_category') {
                        $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
                    }
                    //filtering lead value
                    $value = apply_filters("gform_get_field_value", $value, $lead, $field);
                    $input_type = !empty($columns[$field_id]["inputType"]) ? $columns[$field_id]["inputType"] : $columns[$field_id]["type"];
                    switch ($input_type) {
                        case "checkbox":
                            $value = "";
                            //if this is the main checkbox field (not an input), display a comma separated list of all inputs
                            if (absint($field_id) == $field_id) {
                                $lead_field_keys = array_keys($lead);
                                $items = array();
                                foreach ($lead_field_keys as $input_id) {
                                    if (is_numeric($input_id) && absint($input_id) == $field_id) {
                                        $items[] = GFCommon::selection_display(rgar($lead, $input_id), null, $lead["currency"], false);
                                    }
                                }
                                $value = GFCommon::implode_non_blank(", ", $items);
                                // special case for post category checkbox fields
                                if ($field['type'] == 'post_category') {
                                    $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
                                }
                            } else {
                                $value = "";
                                if (GFFormsModel::is_checkbox_checked($field_id, $columns[$field_id]["label"], $lead, $form)) {
                                    $value = "<i class='fa fa-check gf_valid'></i>";
                                }
                            }
                            break;
                        case "post_image":
                            list($url, $title, $caption, $description) = rgexplode("|:|", $value, 4);
                            if (!empty($url)) {
                                //displaying thumbnail (if file is an image) or an icon based on the extension
                                $thumb = self::get_icon_url($url);
                                $value = "<a href='" . esc_attr($url) . "' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
                            }
                            break;
                        case "fileupload":
                            if (rgar($field, "multipleFiles")) {
                                $uploaded_files_arr = empty($value) ? array() : json_decode($value, true);
                                $file_count = count($uploaded_files_arr);
                                if ($file_count > 1) {
                                    $value = empty($uploaded_files_arr) ? "" : sprintf(__("%d files", "gravityforms"), count($uploaded_files_arr));
                                    break;
                                } elseif ($file_count == 1) {
                                    $value = $uploaded_files_arr[0];
                                }
                            }
                            $file_path = $value;
                            if (!empty($file_path)) {
                                //displaying thumbnail (if file is an image) or an icon based on the extension
                                $thumb = self::get_icon_url($file_path);
                                $file_path = esc_attr($file_path);
                                $value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
                            }
                            break;
                        case "source_url":
                            $value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
                            break;
                        case "textarea":
                        case "post_content":
                        case "post_excerpt":
                            $value = esc_html($value);
                            break;
                        case "date_created":
                        case "payment_date":
                            $value = GFCommon::format_date($value, false);
                            break;
                        case "date":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::date_display($value, rgar($field, "dateFormat"));
                            break;
                        case "radio":
                        case "select":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::selection_display($value, $field, $lead["currency"]);
                            break;
                        case "number":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::format_number($value, rgar($field, "numberFormat"));
                            break;
                        case "total":
                        case "payment_amount":
                            $value = GFCommon::to_money($value, $lead["currency"]);
                            break;
                        case "created_by":
                            if (!empty($value)) {
                                $userdata = get_userdata($value);
                                if (!empty($userdata)) {
                                    $value = $userdata->user_login;
                                }
                            }
                            break;
                        case "multiselect":
                            // add space after comma-delimited values
                            $value = implode(', ', explode(',', $value));
                            break;
                        default:
                            $value = esc_html($value);
                    }
                    $value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
                    /* ^ maybe move to function */
                    $query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}{$filter_qs}&paged=" . ($page_index + 1);
                    if ($is_first_column) {
                        ?>
                                        <td class="column-title" >
                                            <a href="admin.php?page=gf_entries&view=entry&id=<?php 
                        echo $form_id;
                        ?>
&lid=<?php 
                        echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                        ?>
&paged=<?php 
                        echo $page_index + 1;
                        ?>
&pos=<?php 
                        echo $position;
                        ?>
&field_id=<?php 
                        echo $search_field_id;
                        ?>
&operator=<?php 
                        echo $search_operator;
                        ?>
"><?php 
                        echo $value;
                        ?>
</a>

                                            <?php 
                        $gf_entry_locking->lock_info($lead["id"]);
                        ?>

                                            <div class="row-actions">
                                                <?php 
                        switch ($filter) {
                            case "trash":
                                ?>
                                                        <span class="edit">
                                                            <a title="<?php 
                                _e("View this entry", "gravityforms");
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo $form_id;
                                ?>
&lid=<?php 
                                echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
&field_id=<?php 
                                echo $search_field_id;
                                ?>
&operator=<?php 
                                echo $search_operator;
                                ?>
"><?php 
                                _e("View", "gravityforms");
                                ?>
</a>
                                                            |
                                                        </span>

                                                        <span class="edit">
                                                            <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                echo $lead["id"];
                                ?>
::status=active&entry=<?php 
                                echo $lead["id"];
                                ?>
' title="<?php 
                                echo _e("Restore this entry", "gravityforms");
                                ?>
" href="<?php 
                                echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                ?>
"><?php 
                                _e("Restore", "gravityforms");
                                ?>
</a>
                                                            <?php 
                                echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                                ?>
                                                        </span>

                                                        <?php 
                                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                                    ?>
                                                            <span class="delete">
                                                                <?php 
                                    $delete_link = '<a data-wp-lists="delete:gf_entry_list:lead_row_' . $lead["id"] . '::status=delete&entry=' . $lead["id"] . '" title="' . __("Delete this entry permanently", "gravityforms") . '"  href="' . wp_nonce_url("?page=gf_entries", "gf_delete_entry") . '">' . __("Delete Permanently", "gravityforms") . '</a>';
                                    echo apply_filters("gform_delete_entry_link", $delete_link);
                                    ?>
                                                            </span>
                                                            <?php 
                                }
                                break;
                            case "spam":
                                ?>
                                                        <span class="edit">
                                                            <a title="<?php 
                                _e("View this entry", "gravityforms");
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo $form_id;
                                ?>
&lid=<?php 
                                echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
"><?php 
                                _e("View", "gravityforms");
                                ?>
</a>
                                                            |
                                                        </span>

                                                        <span class="unspam">
                                                            <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                echo $lead["id"];
                                ?>
::status=unspam&entry=<?php 
                                echo $lead["id"];
                                ?>
' title="<?php 
                                echo _e("Mark this entry as not spam", "gravityforms");
                                ?>
" href="<?php 
                                echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                ?>
"><?php 
                                _e("Not Spam", "gravityforms");
                                ?>
</a>
                                                            <?php 
                                echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                                ?>
                                                        </span>

                                                        <?php 
                                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                                    ?>
                                                            <span class="delete">
                                                                <?php 
                                    $delete_link = '<a data-wp-lists="delete:gf_entry_list:lead_row_' . $lead["id"] . '::status=delete&entry=' . $lead["id"] . '" title="' . __("Delete this entry permanently", "gravityforms") . '"  href="' . wp_nonce_url("?page=gf_entries", "gf_delete_entry") . '">' . __("Delete Permanently", "gravityforms") . '</a>';
                                    echo apply_filters("gform_delete_entry_link", $delete_link);
                                    ?>
                                                            </span>
                                                            <?php 
                                }
                                break;
                            default:
                                ?>
                                                        <span class="edit">
                                                            <a title="<?php 
                                _e("View this entry", "gravityforms");
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo $form_id;
                                ?>
&lid=<?php 
                                echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
&field_id=<?php 
                                echo $search_field_id;
                                ?>
&operator=<?php 
                                echo $search_operator;
                                ?>
"><?php 
                                _e("View", "gravityforms");
                                ?>
</a>
                                                            |
                                                        </span>
                                                        <span class="edit">
                                                            <a id="mark_read_<?php 
                                echo $lead["id"];
                                ?>
" title="Mark this entry as read" href="javascript:ToggleRead(<?php 
                                echo $lead["id"] . ",'" . $filter . "'";
                                ?>
);" style="display:<?php 
                                echo $lead["is_read"] ? "none" : "inline";
                                ?>
;"><?php 
                                _e("Mark read", "gravityforms");
                                ?>
</a><a id="mark_unread_<?php 
                                echo $lead["id"];
                                ?>
" title="<?php 
                                _e("Mark this entry as unread", "gravityforms");
                                ?>
" href="javascript:ToggleRead(<?php 
                                echo $lead["id"] . ",'" . $filter . "'";
                                ?>
);" style="display:<?php 
                                echo $lead["is_read"] ? "inline" : "none";
                                ?>
;"><?php 
                                _e("Mark unread", "gravityforms");
                                ?>
</a>
                                                            <?php 
                                echo GFCommon::current_user_can_any("gravityforms_delete_entries") || GFCommon::akismet_enabled($form_id) ? "|" : "";
                                ?>
                                                        </span>
                                                        <?php 
                                if (GFCommon::akismet_enabled($form_id)) {
                                    ?>
                                                            <span class="spam">
                                                                <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                    echo $lead["id"];
                                    ?>
::status=spam&entry=<?php 
                                    echo $lead["id"];
                                    ?>
' title="<?php 
                                    _e("Mark this entry as spam", "gravityforms");
                                    ?>
" href="<?php 
                                    echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                    ?>
"><?php 
                                    _e("Spam", "gravityforms");
                                    ?>
</a>
                                                                <?php 
                                    echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                                    ?>
                                                            </span>

                                                        <?php 
                                }
                                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                                    ?>
                                                            <span class="trash">
                                                                <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                    echo $lead["id"];
                                    ?>
::status=trash&entry=<?php 
                                    echo $lead["id"];
                                    ?>
' title="<?php 
                                    _e("Move this entry to the trash", "gravityforms");
                                    ?>
" href="<?php 
                                    echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                    ?>
"><?php 
                                    _e("Trash", "gravityforms");
                                    ?>
</a>
                                                            </span>
                                                            <?php 
                                }
                                break;
                        }
                        do_action("gform_entries_first_column_actions", $form_id, $field_id, $value, $lead, $query_string);
                        ?>

                                            </div>
                                            <?php 
                        do_action("gform_entries_first_column", $form_id, $field_id, $value, $lead, $query_string);
                        ?>
                                        </td>
                                        <?php 
                    } else {
                        ?>
                                        <td class="<?php 
                        echo $nowrap_class;
                        ?>
">
                                            <?php 
                        echo apply_filters("gform_entries_column_filter", $value, $form_id, $field_id, $lead, $query_string);
                        ?>
&nbsp;
                                            <?php 
                        do_action("gform_entries_column", $form_id, $field_id, $value, $lead, $query_string);
                        ?>
                                        </td>
                                        <?php 
                    }
                    $is_first_column = false;
                }
                ?>
                                <td>&nbsp;</td>
                            </tr>
                            <?php 
            }
        } else {
            $column_count = sizeof($columns) + 3;
            switch ($filter) {
                case "unread":
                    $message = isset($_GET["field_id"]) ? __("This form does not have any unread entries matching the search criteria.", "gravityforms") : __("This form does not have any unread entries.", "gravityforms");
                    break;
                case "star":
                    $message = isset($_GET["field_id"]) ? __("This form does not have any starred entries matching the search criteria.", "gravityforms") : __("This form does not have any starred entries.", "gravityforms");
                    break;
                case "spam":
                    $message = __("This form does not have any spam.", "gravityforms");
                    $column_count = sizeof($columns) + 2;
                    break;
                case "trash":
                    $message = isset($_GET["field_id"]) ? __("This form does not have any entries in the trash matching the search criteria.", "gravityforms") : __("This form does not have any entries in the trash.", "gravityforms");
                    $column_count = sizeof($columns) + 2;
                    break;
                default:
                    $message = isset($_GET["field_id"]) ? __("This form does not have any entries matching the search criteria.", "gravityforms") : __("This form does not have any entries yet.", "gravityforms");
            }
            ?>
                        <tr>
                            <td colspan="<?php 
            echo $column_count;
            ?>
" style="padding:20px;"><?php 
            echo $message;
            ?>
</td>
                        </tr>
                        <?php 
        }
        ?>
                </tbody>
                </table>

                <div class="clear"></div>

                <div class="tablenav">

                    <div class="alignleft actions" style="padding:8px 0 7px 0;">
                        <label class="hidden" for="bulk_action2"> <?php 
        _e("Bulk action", "gravityforms");
        ?>
</label>
                        <select name="bulk_action2" id="bulk_action2">
                            <option value=''><?php 
        _e(" Bulk action ", "gravityforms");
        ?>
</option>
                            <?php 
        switch ($filter) {
            case "trash":
                ?>
                                    <option value='restore'><?php 
                _e("Restore", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            case "spam":
                ?>
                                    <option value='unspam'><?php 
                _e("Not Spam", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            default:
                ?>
                                <option value='mark_read'><?php 
                _e("Mark as Read", "gravityforms");
                ?>
</option>
                                <option value='mark_unread'><?php 
                _e("Mark as Unread", "gravityforms");
                ?>
</option>
                                <option value='add_star'><?php 
                _e("Add Star", "gravityforms");
                ?>
</option>
                                <option value='remove_star'><?php 
                _e("Remove Star", "gravityforms");
                ?>
</option>
                                <option value='resend_notifications'><?php 
                _e("Resend Notifications", "gravityforms");
                ?>
</option>
                                <option value='print'><?php 
                _e("Print Entries", "gravityforms");
                ?>
</option>
                                <?php 
                if (GFCommon::akismet_enabled($form_id)) {
                    ?>
                                    <option value='spam'><?php 
                    _e("Spam", "gravityforms");
                    ?>
</option>
                                    <?php 
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                    <option value='trash'><?php 
                    _e("Move to Trash", "gravityforms");
                    ?>
</option>
                                    <?php 
                }
        }
        ?>
                        </select>
                        <?php 
        $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return handleBulkApply(\'bulk_action2\');" />';
        echo apply_filters("gform_entry_apply_button", $apply_button);
        ?>
                    </div>

                    <?php 
        echo self::display_paging_links("footer", $page_links, $first_item_index, $page_size, $total_count);
        ?>

                    <div class="clear"></div>
                </div>

            </form>
        </div>
        <?php 
    }
Example #21
0
 public static function get_field($field, $value = '', $force_frontend_label = false, $form = null, $field_values = null)
 {
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     $custom_class = $is_admin ? '' : esc_attr($field->cssClass);
     if ($field->type == 'page') {
         if ($is_entry_detail) {
             return;
             //ignore page breaks in the entry detail page
         } else {
             if (!$is_form_editor) {
                 $save_button = rgars($form, 'save/enabled') ? self::get_form_button($form['id'], "gform_save_{$form['id']}", $form['save']['button'], rgars($form, 'save/button/text'), 'gform_save_link', rgars($form, 'save/button/text'), 0, "jQuery(\"#gform_save_{$form['id']}\").val(1);") : '';
                 $next_button_alt = rgempty('imageAlt', $field->nextButton) ? __('Next Page', 'gravityforms') : $field->nextButton['imageAlt'];
                 $next_button = self::get_form_button($form['id'], "gform_next_button_{$form['id']}_{$field->id}", $field->nextButton, __('Next', 'gravityforms'), 'gform_next_button', $next_button_alt, $field->pageNumber);
                 $next_button = gf_apply_filters(array('gform_next_button', $form['id']), $next_button, $form);
                 $previous_button_alt = rgempty('imageAlt', $field->previousButton) ? __('Previous Page', 'gravityforms') : $field->previousButton['imageAlt'];
                 $previous_button = $field->pageNumber == 2 ? '' : self::get_form_button($form['id'], "gform_previous_button_{$form['id']}_{$field->id}", $field->previousButton, __('Previous', 'gravityforms'), 'gform_previous_button', $previous_button_alt, $field->pageNumber - 2);
                 if (!empty($previous_button)) {
                     $previous_button = gf_apply_filters(array('gform_previous_button', $form['id']), $previous_button, $form);
                 }
                 $style = self::is_page_active($form['id'], $field->pageNumber) ? '' : "style='display:none;'";
                 $custom_class = !empty($custom_class) ? " {$custom_class}" : '';
                 $html = "</ul>\n                    </div>\n                    <div class='gform_page_footer'>\n                        {$previous_button} {$next_button} {$save_button}\n                    </div>\n                </div>\n                <div id='gform_page_{$form['id']}_{$field->pageNumber}' class='gform_page{$custom_class}' {$style}>\n                    <div class='gform_page_fields'>\n                        <ul id='gform_fields_{$form['id']}_{$field->pageNumber}' class='" . GFCommon::get_ul_classes($form) . "'>";
                 return $html;
             }
         }
     }
     if (!$is_admin && $field->adminOnly) {
         if ($field->allowsPrepopulate) {
             $field->inputType = 'adminonly_hidden';
         } else {
             return;
         }
     }
     $id = $field->id;
     $input_type = GFFormsModel::get_input_type($field);
     $error_class = $field->failed_validation ? 'gfield_error' : '';
     $admin_only_class = $field->adminOnly ? 'field_admin_only' : '';
     $selectable_class = $is_admin ? 'selectable' : '';
     $hidden_class = in_array($input_type, array('hidden', 'hiddenproduct')) ? 'gform_hidden' : '';
     $section_class = $field->type == 'section' ? 'gsection' : '';
     $page_class = $field->type == 'page' ? 'gpage' : '';
     $html_block_class = $field->type == 'html' ? 'gfield_html' : '';
     $html_formatted_class = $field->type == 'html' && !$is_admin && !$field->disableMargins ? 'gfield_html_formatted' : '';
     $html_no_follows_desc_class = $field->type == 'html' && !$is_admin && !self::prev_field_has_description($form, $field->id) ? 'gfield_no_follows_desc' : '';
     $calculation_class = $input_type == 'calculation' || $input_type == 'number' && $field->has_calculation() ? 'gfield_calculation' : '';
     $product_suffix = "_{$form['id']}_" . $field->productField;
     $option_class = $field->type == 'option' ? "gfield_price gfield_price{$product_suffix} gfield_option{$product_suffix}" : '';
     $quantity_class = $field->type == 'quantity' ? "gfield_price gfield_price{$product_suffix} gfield_quantity gfield_quantity{$product_suffix}" : '';
     $total_class = $field->type == 'total' ? "gfield_price gfield_price{$product_suffix} gfield_total gfield_total{$product_suffix}" : '';
     $shipping_class = $field->type == 'shipping' ? "gfield_price gfield_shipping gfield_shipping_{$form['id']}" : '';
     $product_class = $field->type == 'product' ? "gfield_price gfield_price_{$form['id']}_{$field->id} gfield_product_{$form['id']}_{$field->id}" : '';
     $hidden_product_class = $input_type == 'hiddenproduct' ? 'gfield_hidden_product' : '';
     $donation_class = $field->type == 'donation' ? "gfield_price gfield_price_{$form['id']}_{$field->id} gfield_donation_{$form['id']}_{$field->id}" : '';
     $required_class = $field->isRequired ? 'gfield_contains_required' : '';
     $creditcard_warning_class = $input_type == 'creditcard' && !GFCommon::is_ssl() ? 'gfield_creditcard_warning' : '';
     $form_sublabel_setting = rgempty('subLabelPlacement', $form) ? 'below' : $form['subLabelPlacement'];
     $sublabel_setting = !isset($field->subLabelPlacement) || empty($field->subLabelPlacement) ? $form_sublabel_setting : $field->subLabelPlacement;
     $sublabel_class = "field_sublabel_{$sublabel_setting}";
     $form_description_setting = rgempty('descriptionPlacement', $form) ? 'below' : $form['descriptionPlacement'];
     $description_setting = !isset($field->descriptionPlacement) || empty($field->descriptionPlacement) ? $form_description_setting : $field->descriptionPlacement;
     $description_class = "field_description_{$description_setting}";
     $field_setting_label_placement = $field->labelPlacement;
     $label_placement = empty($field_setting_label_placement) ? '' : $field_setting_label_placement;
     $css_class = "{$selectable_class} gfield {$error_class} {$section_class} {$admin_only_class} {$custom_class} {$hidden_class} {$html_block_class} {$html_formatted_class} {$html_no_follows_desc_class} {$option_class} {$quantity_class} {$product_class} {$total_class} {$donation_class} {$shipping_class} {$page_class} {$required_class} {$hidden_product_class} {$creditcard_warning_class} {$calculation_class} {$sublabel_class} {$description_class} {$label_placement}";
     $css_class = preg_replace('/\\s+/', ' ', $css_class);
     //removing extra spaces
     $css_class = gf_apply_filters(array('gform_field_css_class', $form['id']), trim($css_class), $field, $form);
     $style = '';
     $field_id = $is_admin || empty($form) ? "field_{$id}" : 'field_' . $form['id'] . "_{$id}";
     $field_content = self::get_field_content($field, $value, $force_frontend_label, $form == null ? 0 : $form['id'], $form);
     $css_class = esc_attr($css_class);
     $field_container = "<li id='{$field_id}' class='{$css_class}' {$style}>{FIELD_CONTENT}</li>";
     $field_container = gf_apply_filters(array('gform_field_container', $form['id'], $field->id), $field_container, $field, $form, $css_class, $style, $field_content);
     $field_markup = str_replace('{FIELD_CONTENT}', $field_content, $field_container);
     return $field_markup;
 }
Example #22
0
    public static function settings_page()
    {
        if (rgpost("uninstall")) {
            check_admin_referer("uninstall", "gf_paypal_uninstall");
            self::uninstall();
            ?>
            <div class="updated fade" style="padding:20px;"><?php 
            _e(sprintf("Gravity Forms PayPal Add-On have been successfully uninstalled. It can be re-activated from the %splugins page%s.", "<a href='plugins.php'>", "</a>"), "gravityformspaypal");
            ?>
</div>
            <?php 
            return;
        } else {
            if (isset($_POST["gf_debug_submit"])) {
                check_admin_referer("update", "gf_paypal_update");
                $settings = array("log_level" => rgpost("gf_paypal_log_level"));
                update_option("gf_paypal_settings", $settings);
            }
        }
        $settings = get_option("gf_paypal_settings");
        $is_configured = get_option("gf_paypal_configured");
        ?>
        <form action="" method="post">
            <?php 
        wp_nonce_field("update", "gf_paypal_update");
        ?>
            <h3><?php 
        _e("PayPal Settings", "gravityformspaypal");
        ?>
</h3>
            <p style="text-align: left;">
                <?php 
        _e("Gravity Forms requires IPN to be enabled on your PayPal account. Follow the following steps to confirm IPN is enabled.", "gravityformspaypal");
        ?>
            </p>

            <ul>
                <li><?php 
        echo sprintf(__("Navigate to your PayPal %sIPN Settings page.%s", "gravityformspaypal"), "<a href='https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-ipn-notify' target='_blank'>", "</a>");
        ?>
</li>
                <li><?php 
        _e("If IPN is already enabled, you will see your current IPN settings along with a button to turn off IPN. If that is the case, just check the confirmation box below and you are ready to go!", "gravityformspaypal");
        ?>
</li>
                <li><?php 
        _e("If IPN is not enabled, click the 'Choose IPN Settings' button.", "gravityformspaypal");
        ?>
</li>
                <li><?php 
        echo sprintf(__("Click the box to enable IPN and enter the following Notification URL: %s", "gravityformspaypal"), "<strong>" . add_query_arg("page", "gf_paypal_ipn", get_bloginfo("url") . "/") . "</strong>");
        ?>
</li>
            </ul>
            <br/>
            <input type="checkbox" name="gf_paypal_configured" id="gf_paypal_configured" onclick="confirm_settings()" <?php 
        echo $is_configured ? "checked='checked'" : "";
        ?>
/>
            <label for="gf_paypal_configured" class="inline"><?php 
        _e("Confirm that your have configured your PayPal account to enable IPN", "gravityformspaypal");
        ?>
</label>

            <div style="display:<?php 
        echo rgempty("debug", $_GET) ? "none" : "block";
        ?>
;">
                <div class="hr-divider"></div>
                <h3><?php 
        _e("Debugging Settings", "gravityformspaypal");
        ?>
</h3>
                <label for="gf_paypal_log_level" class="inline"><?php 
        _e("Logging", "gravityformspaypal");
        ?>
</label>
                <select id="gf_paypal_log_level" name="gf_paypal_log_level">
                    <option value="<?php 
        echo KLogger::OFF;
        ?>
" <?php 
        echo rgempty("log_level", $settings) ? "selected='selected'" : "";
        ?>
><?php 
        _e("Off", "gravityformspaypal");
        ?>
</option>
                    <option value="<?php 
        echo KLogger::DEBUG;
        ?>
" <?php 
        echo rgar($settings, "log_level") == KLogger::DEBUG ? "selected='selected'" : "";
        ?>
><?php 
        _e("Log all messages", "gravityformspaypal");
        ?>
</option>
                    <option value="<?php 
        echo KLogger::ERROR;
        ?>
" <?php 
        echo rgar($settings, "log_level") == KLogger::ERROR ? "selected='selected'" : "";
        ?>
><?php 
        _e("Log errors only", "gravityformspaypal");
        ?>
</option>
                </select>
                <?php 
        if (file_exists(self::get_base_path() . "/log.txt")) {
            ?>
                    &nbsp;<a href="<?php 
            echo self::get_base_url() . "/log.txt";
            ?>
" target="_blank"><?php 
            _e("view log", "gravityformspaypal");
            ?>
</a>
                    <?php 
        }
        ?>
                <div style="margin-top: 15px;"><input type="submit" name="gf_debug_submit" class="button-primary" value="<?php 
        _e("Save", "gravityformspaypal");
        ?>
" /></div>
            </div>

            <script type="text/javascript">
                function confirm_settings(){
                    var confirmed = jQuery("#gf_paypal_configured").is(":checked") ? 1 : 0;
                    jQuery.post(ajaxurl, {action:"gf_paypal_confirm_settings", is_confirmed: confirmed, cookie: encodeURIComponent(document.cookie)});
                }
            </script>

        </form>

        <form action="" method="post">
            <?php 
        wp_nonce_field("uninstall", "gf_paypal_uninstall");
        ?>
            <?php 
        if (GFCommon::current_user_can_any("gravityforms_paypal_uninstall")) {
            ?>
                <div class="hr-divider"></div>

                <h3><?php 
            _e("Uninstall PayPal Add-On", "gravityformspaypal");
            ?>
</h3>
                <div class="delete-alert"><?php 
            _e("Warning! This operation deletes ALL PayPal Feeds.", "gravityformspaypal");
            ?>
                    <?php 
            $uninstall_button = '<input type="submit" name="uninstall" value="' . __("Uninstall PayPal Add-On", "gravityformspaypal") . '" class="button" onclick="return confirm(\'' . __("Warning! ALL PayPal Feeds will be deleted. This cannot be undone. \\'OK\\' to delete, \\'Cancel\\' to stop", "gravityformspaypal") . '\');"/>';
            echo apply_filters("gform_paypal_uninstall_button", $uninstall_button);
            ?>
                </div>
            <?php 
        }
        ?>
        </form>
        <?php 
    }
Example #23
0
 public static function get_field_content($field, $value = "", $force_frontend_label = false, $form_id = 0)
 {
     $id = $field["id"];
     $size = rgar($field, "size");
     $validation_message = rgget("failed_validation", $field) && !empty($field["validation_message"]) ? sprintf("<div class='gfield_description validation_message'>%s</div>", $field["validation_message"]) : "";
     $duplicate_disabled = array('captcha', 'post_title', 'post_content', 'post_excerpt', 'total', 'shipping', 'creditcard');
     $duplicate_field_link = !in_array($field['type'], $duplicate_disabled) ? "<a class='field_duplicate_icon' id='gfield_duplicate_{$id}' title='" . __("click to duplicate this field", "gravityforms") . "' href='#' onclick='StartDuplicateField(this); return false;'>" . __("Duplicate", "gravityforms") . "</a>" : "";
     $duplicate_field_link = apply_filters("gform_duplicate_field_link", $duplicate_field_link);
     $delete_field_link = "<a class='field_delete_icon' id='gfield_delete_{$id}' title='" . __("click to delete this field", "gravityforms") . "' href='#' onclick='StartDeleteField(this); return false;'>" . __("Delete", "gravityforms") . "</a>";
     $delete_field_link = apply_filters("gform_delete_field_link", $delete_field_link);
     $field_type_title = GFCommon::get_field_type_title($field["type"]);
     $admin_buttons = IS_ADMIN ? "<div class='gfield_admin_icons'><div class='gfield_admin_header_title'>{$field_type_title} : " . __("Field ID", "gravityforms") . " {$field["id"]}</div>" . $delete_field_link . $duplicate_field_link . "<a class='field_edit_icon edit_icon_collapsed' title='" . __("click to edit this field", "gravityforms") . "'>" . __("Edit", "gravityforms") . "</a></div>" : "";
     $field_label = $force_frontend_label ? $field["label"] : GFCommon::get_label($field);
     if (rgar($field, "inputType") == "singleproduct" && !rgempty($field["id"] . ".1", $value)) {
         $field_label = rgar($value, $field["id"] . ".1");
     }
     $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
     $required_div = IS_ADMIN || rgar($field, "isRequired") ? sprintf("<span class='gfield_required'>%s</span>", $field["isRequired"] ? "*" : "") : "";
     $target_input_id = "";
     $is_description_above = rgar($field, "descriptionPlacement") == "above";
     switch (RGFormsModel::get_input_type($field)) {
         case "section":
             $description = self::get_description(rgget("description", $field), "gsection_description");
             $field_content = sprintf("%s<h2 class='gsection_title'>%s</h2>%s", $admin_buttons, esc_html($field_label), $description);
             break;
         case "page":
             //only executed on the form editor in the admin
             $page_label = __("Page Break", "gravityforms");
             $src = GFCommon::get_base_url() . "/images/gf_pagebreak_inline.png";
             $field_content = "{$admin_buttons} <label class='gfield_label'>&nbsp;</label><img src='{$src}' alt='{$page_label}' title='{$page_label}' />";
             break;
         case "adminonly_hidden":
         case "hidden":
         case "html":
             $field_content = !IS_ADMIN ? "{FIELD}" : ($field_content = sprintf("%s<label class='gfield_label' for='%s'>%s</label>{FIELD}", $admin_buttons, $field_id, esc_html($field_label)));
             break;
         case "checkbox":
         case "radio":
             $description = self::get_description(rgget("description", $field), "gfield_description");
             if ($is_description_above) {
                 $field_content = sprintf("%s<label class='gfield_label'>%s%s</label>%s{FIELD}%s", $admin_buttons, esc_html($field_label), $required_div, $description, $validation_message);
             } else {
                 $field_content = sprintf("%s<label class='gfield_label'>%s%s</label>{FIELD}%s%s", $admin_buttons, esc_html($field_label), $required_div, $description, $validation_message);
             }
             break;
         case "name":
             switch (rgar($field, "nameFormat")) {
                 case "simple":
                     $target_input_id = $field_id;
                     break;
                 case "extended":
                     $target_input_id = $field_id . "_2";
                     break;
                 default:
                     $target_input_id = $field_id . "_3";
             }
         case "address":
             if (empty($target_input_id)) {
                 $target_input_id = $field_id . "_1";
             }
         default:
             if (empty($target_input_id)) {
                 $target_input_id = $field_id;
             }
             $description = self::get_description(rgget("description", $field), "gfield_description");
             if ($is_description_above) {
                 $field_content = sprintf("%s<label class='gfield_label' for='%s'>%s%s</label>%s{FIELD}%s", $admin_buttons, $target_input_id, esc_html($field_label), $required_div, $description, $validation_message);
             } else {
                 $field_content = sprintf("%s<label class='gfield_label' for='%s'>%s%s</label>{FIELD}%s%s", $admin_buttons, $target_input_id, esc_html($field_label), $required_div, $description, $validation_message);
             }
             break;
     }
     if (RGFormsModel::get_input_type($field) == "creditcard" && !GFCommon::is_ssl() && !IS_ADMIN) {
         $field_content = "<div class='gfield_creditcard_warning_message'>" . __("This page is unsecured. Do not enter a real credit card number. Use this field only for testing purposes. ", "gravityforms") . "</div>" . $field_content;
     }
     $value = self::default_if_empty($field, $value);
     $field_content = str_replace("{FIELD}", GFCommon::get_field_input($field, $value, 0, $form_id), $field_content);
     $field_content = apply_filters("gform_field_content", $field_content, $field, $value, 0, $form_id);
     return $field_content;
 }
Example #24
0
    if (!is_null($read)) {
        $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
    }
    $search_field_id = rgget("field_id");
    $search_operator = rgget("operator");
    if (isset($_GET["field_id"]) && $_GET["field_id"] !== '') {
        $key = $search_field_id;
        $val = rgget("s");
        $strpos_row_key = strpos($search_field_id, "|");
        if ($strpos_row_key !== false) {
            //multi-row
            $key_array = explode("|", $search_field_id);
            $key = $key_array[0];
            $val = $key_array[1] . ":" . $val;
        }
        $search_criteria["field_filters"][] = array("key" => $key, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
    }
    $lead_ids = GFFormsModel::search_lead_ids($form_id, $search_criteria);
} else {
    $lead_ids = explode(',', $leads);
}
$page_break = rgget("page_break") ? 'print-page-break' : false;
// sort lead IDs numerically
sort($lead_ids);
if (empty($form_id) || empty($lead_ids)) {
    die(__("Form Id and Lead Id are required parameters.", "gravityforms"));
}
$form = RGFormsModel::get_form_meta($form_id);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Example #25
0
    public static function page_header($title = '')
    {
        // register admin styles
        wp_register_style('gform_admin', GFCommon::get_base_url() . '/css/admin.css');
        wp_print_styles(array('jquery-ui-styles', 'gform_admin', 'wp-pointer'));
        $form = GFFormsModel::get_form_meta(rgget('id'));
        $current_tab = rgempty('subview', $_GET) ? 'settings' : rgget('subview');
        $setting_tabs = GFFormSettings::get_tabs($form['id']);
        // kind of boring having to pass the title, optionally get it from the settings tab
        if (!$title) {
            foreach ($setting_tabs as $tab) {
                if ($tab['name'] == $current_tab) {
                    $title = $tab['label'];
                }
            }
        }
        ?>

		<div class="wrap gforms_edit_form <?php 
        echo GFCommon::get_browser_class();
        ?>
">
			<h2 class="gf_admin_page_title">
				<span><?php 
        echo $title;
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo $form['id'];
        ?>
</span><span class="gf_admin_page_formname"><?php 
        _e('Form Name', 'gravityforms');
        ?>
: <?php 
        echo $form['title'];
        ?>
</span></span>
			</h2>

			<?php 
        GFCommon::display_admin_message();
        ?>

			<?php 
        RGForms::top_toolbar();
        ?>

			<div id="gform_tab_group" class="gform_tab_group vertical_tabs">
				<ul id="gform_tabs" class="gform_tabs">
				<?php 
        foreach ($setting_tabs as $tab) {
            $query = array('subview' => $tab['name']);
            if (isset($tab['query'])) {
                $query = array_merge($query, $tab['query']);
            }
            $url = add_query_arg($query);
            ?>
					<li <?php 
            echo $current_tab == $tab['name'] ? "class='active'" : '';
            ?>
>
						<a href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            echo esc_html($tab['label']);
            ?>
</a><span></span>
					</li>
				<?php 
        }
        ?>
				</ul>

				<div id="gform_tab_container_1" class="gform_tab_container">
					<div class="gform_tab_content" id="tab_<?php 
        echo $current_tab;
        ?>
">

	<?php 
    }
Example #26
0
 public static function get_post_category_values()
 {
     $id = "routing_value_" . rgpost("ruleIndex");
     $selected = rgempty("selectedValue") ? 0 : rgpost("selectedValue");
     $dropdown = wp_dropdown_categories(array("class" => "gfield_routing_select gfield_routing_value_dropdown gfield_category_dropdown", "orderby" => "name", "id" => $id, "selected" => $selected, "hierarchical" => true, "hide_empty" => 0, "echo" => false));
     die($dropdown);
 }
Example #27
0
    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta(absint($_GET['id']));
        $form_id = absint($form['id']);
        $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form));
        $lead_id = absint(rgget('lid'));
        $filter = rgget('filter');
        $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta['type'] == 'number';
        $star = $filter == 'star' ? 1 : null;
        $read = $filter == 'unread' ? 0 : null;
        $search_criteria['status'] = $status;
        if ($star) {
            $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
        }
        $search_field_id = rgget('field_id');
        if (isset($_GET['field_id']) && $_GET['field_id'] !== '') {
            $key = $search_field_id;
            $val = rgget('s');
            $strpos_row_key = strpos($search_field_id, '|');
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode('|', $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ':' . $val;
            }
            $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_GET) ? 'is' : rgget('operator'), 'value' => $val);
            $type = rgget('type');
            if (empty($type)) {
                if (rgget('field_id') == '0') {
                    $search_criteria['type'] = 'global';
                }
            }
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action('gform_after_update_entry', $form, $lead['id']);
                do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST['bulk_action'] == 'delete') {
                    if (!GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
                        die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms'));
                    }
                    RGFormsModel::delete_notes($_POST['note']);
                }
                break;
            case 'trash':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'trash');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'restore':
            case 'unspam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'active');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'spam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'spam');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'delete':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    die(esc_html__("You don't have adequate permission to delete entries.", 'gravityforms'));
                }
                RGFormsModel::delete_lead($lead['id']);
                ?>
				<script type="text/javascript">
					document.location.href = '<?php 
                echo 'admin.php?page=gf_entries&view=entries&id=' . absint($form['id']);
                ?>
';
				</script>
				<?php 
                break;
        }
        $mode = empty($_POST['screen_mode']) ? 'view' : $_POST['screen_mode'];
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css" />
		<script type="text/javascript">

			jQuery(document).ready(function () {
				toggleNotificationOverride(true);
				jQuery('#gform_update_button').prop('disabled', false);
			});

			function DeleteFile(leadId, fieldId, deleteButton) {
				if (confirm(<?php 
        echo json_encode(__("Would you like to delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityforms'));
        ?>
)) {
					var fileIndex = jQuery(deleteButton).parent().index();
					var mysack = new sack("<?php 
        echo admin_url('admin-ajax.php');
        ?>
");
					mysack.execute = 1;
					mysack.method = 'POST';
					mysack.setVar("action", "rg_delete_file");
					mysack.setVar("rg_delete_file", "<?php 
        echo wp_create_nonce('rg_delete_file');
        ?>
");
					mysack.setVar("lead_id", leadId);
					mysack.setVar("field_id", fieldId);
					mysack.setVar("file_index", fileIndex);
					mysack.onError = function () {
						alert(<?php 
        echo json_encode(__('Ajax error while deleting field.', 'gravityforms'));
        ?>
)
					};
					mysack.runAJAX();

					return true;
				}
			}

			function EndDeleteFile(fieldId, fileIndex) {
				var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview";
				var $previewFiles = jQuery(previewFileSelector);
				var rr = $previewFiles.eq(fileIndex);
				$previewFiles.eq(fileIndex).remove();
				var $visiblePreviewFields = jQuery(previewFileSelector);
				if ($visiblePreviewFields.length == 0) {
					jQuery('#preview_' + fieldId).hide();
					jQuery('#upload_' + fieldId).show('slow');
				}
			}

			function ToggleShowEmptyFields() {
				if (jQuery("#gentry_display_empty_fields").is(":checked")) {
					createCookie("gf_display_empty_fields", true, 10000);
					document.location = document.location.href;
				}
				else {
					eraseCookie("gf_display_empty_fields");
					document.location = document.location.href;
				}
			}

			function createCookie(name, value, days) {
				if (days) {
					var date = new Date();
					date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
					var expires = "; expires=" + date.toGMTString();
				}
				else var expires = "";
				document.cookie = name + "=" + value + expires + "; path=/";
			}

			function eraseCookie(name) {
				createCookie(name, "", -1);
			}

			function ResendNotifications() {

				var selectedNotifications = new Array();
				jQuery(".gform_notifications:checked").each(function () {
					selectedNotifications.push(jQuery(this).val());
				});

				var sendTo = jQuery('#notification_override_email').val();

				if (selectedNotifications.length <= 0) {
					displayMessage(<?php 
        echo json_encode(__('You must select at least one type of notification to resend.', 'gravityforms'));
        ?>
, 'error', '#notifications_container');
					return;
				}

				jQuery('#please_wait_container').fadeIn();

				jQuery.post(ajaxurl, {
						action                 : "gf_resend_notifications",
						gf_resend_notifications: '<?php 
        echo wp_create_nonce('gf_resend_notifications');
        ?>
',
						notifications          : jQuery.toJSON(selectedNotifications),
						sendTo                 : sendTo,
						leadIds                : '<?php 
        echo absint($lead['id']);
        ?>
',
						formId                 : '<?php 
        echo absint($form['id']);
        ?>
'
					},
					function (response) {
						if (response) {
							displayMessage(response, "error", "#notifications_container");
						} else {
							displayMessage(<?php 
        echo json_encode(esc_html__('Notifications were resent successfully.', 'gravityforms'));
        ?>
, "updated", "#notifications_container" );

							// reset UI
							jQuery(".gform_notifications").attr( 'checked', false );
							jQuery('#notification_override_email').val('');

							toggleNotificationOverride();

						}

						jQuery('#please_wait_container').hide();
						setTimeout(function () {
							jQuery('#notifications_container').find('.message').slideUp();
						}, 5000);
					}
				);

			}

			function displayMessage( message, messageClass, container ) {
				jQuery( container ).find( '.message' ).hide().html( message ).attr( 'class', 'message ' + messageClass ).slideDown();
			}

			function toggleNotificationOverride(isInit) {

				if (isInit)
					jQuery('#notification_override_email').val('');

				if (jQuery(".gform_notifications:checked").length > 0) {
					jQuery('#notifications_override_settings').slideDown();
				}
				else {
					jQuery('#notifications_override_settings').slideUp(function () {
						jQuery('#notification_override_email').val('');
					});
				}
			}

		</script>

		<form method="post" id="entry_form" enctype='multipart/form-data'>
		<?php 
        wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
        ?>
		<input type="hidden" name="action" id="action" value="" />
		<input type="hidden" name="screen_mode" id="screen_mode" value="<?php 
        echo esc_attr(rgpost('screen_mode'));
        ?>
" />

		<div class="wrap gf_entry_wrap">
		<h2 class="gf_admin_page_title">
			<span><?php 
        echo esc_html__('Entry #', 'gravityforms') . absint($lead['id']);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo absint($form['id']);
        ?>
</span><span class='gf_admin_page_formname'><?php 
        esc_html_e('Form Name', 'gravityforms');
        ?>
: <?php 
        echo esc_html($form['title']);
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></span></h2>

		<?php 
        if (isset($_GET['pos'])) {
            ?>
			<div class="gf_entry_detail_pagination">
				<ul>
					<li class="gf_entry_count">
						<span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span>
					</li>
					<li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', 'fa fa-arrow-circle-o-left');
            ?>
</li>
					<li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', 'fa fa-arrow-circle-o-right');
            ?>
</li>
				</ul>
			</div>
		<?php 
        }
        ?>

		<?php 
        RGForms::top_toolbar();
        ?>

		<div id="poststuff" class="metabox-holder has-right-sidebar">
		<div id="side-info-column" class="inner-sidebar">
		<?php 
        do_action('gform_entry_detail_sidebar_before', $form, $lead);
        ?>

		<!-- INFO BOX -->
		<div id="submitdiv" class="stuffbox">
			<h3 class="hndle" style="cursor:default;">
				<span><?php 
        esc_html_e('Entry', 'gravityforms');
        ?>
</span>
			</h3>

			<div class="inside">
				<div id="submitcomment" class="submitbox">
					<div id="minor-publishing" style="padding:10px;">
						<?php 
        esc_html_e('Entry Id', 'gravityforms');
        ?>
: <?php 
        echo absint($lead['id']);
        ?>
<br /><br />
						<?php 
        esc_html_e('Submitted on', 'gravityforms');
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead['date_created'], false, 'Y/m/d'));
        ?>
						<br /><br />
						<?php 
        esc_html_e('User IP', 'gravityforms');
        ?>
: <?php 
        echo esc_html($lead['ip']);
        ?>
						<br /><br />
						<?php 
        if (!empty($lead['created_by']) && ($usermeta = get_userdata($lead['created_by']))) {
            ?>
							<?php 
            esc_html_e('User', 'gravityforms');
            ?>
:
							<a href="user-edit.php?user_id=<?php 
            echo absint($lead['created_by']);
            ?>
" alt="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
							<br /><br />
						<?php 
        }
        ?>

						<?php 
        esc_html_e('Embed Url', 'gravityforms');
        ?>
:
						<a href="<?php 
        echo esc_url($lead['source_url']);
        ?>
" target="_blank" alt="<?php 
        echo esc_attr($lead['source_url']);
        ?>
" title="<?php 
        echo esc_attr($lead['source_url']);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead['source_url']));
        ?>
</a>
						<br /><br />
						<?php 
        if (!empty($lead['post_id'])) {
            $post = get_post($lead['post_id']);
            ?>
							<?php 
            esc_html_e('Edit Post', 'gravityforms');
            ?>
:
							<a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
							<br /><br />
						<?php 
        }
        if (do_action('gform_enable_entry_info_payment_details', true, $lead)) {
            if (!empty($lead['payment_status'])) {
                echo $lead['transaction_type'] != 2 ? esc_html__('Payment Status', 'gravityforms') : esc_html__('Subscription Status', 'gravityforms');
                ?>
:
								<span id="gform_payment_status"><?php 
                echo apply_filters('gform_payment_status', $lead['payment_status'], $form, $lead);
                ?>
</span>
								<br /><br />
								<?php 
                if (!empty($lead['payment_date'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Date', 'gravityforms') : esc_html__('Start Date', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::format_date($lead['payment_date'], false, 'Y/m/d', $lead['transaction_type'] != 2);
                    ?>
									<br /><br />
								<?php 
                }
                if (!empty($lead['transaction_id'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Transaction Id', 'gravityforms') : esc_html__('Subscriber Id', 'gravityforms');
                    ?>
: <?php 
                    echo esc_html($lead['transaction_id']);
                    ?>
									<br /><br />
								<?php 
                }
                if (!rgblank($lead['payment_amount'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Amount', 'gravityforms') : esc_html__('Subscription Amount', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::to_money($lead['payment_amount'], $lead['currency']);
                    ?>
									<br /><br />
								<?php 
                }
            }
        }
        do_action('gform_entry_info', $form['id'], $lead);
        ?>
					</div>
					<div id="major-publishing-actions">
						<div id="delete-action">
							<?php 
        switch ($lead['status']) {
            case 'spam':
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Not Spam', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                }
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            case 'trash':
                ?>
									<a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</a>
									<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										|
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Move to Trash', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::spam_enabled($form['id']) ? '|' : '';
                }
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Mark as Spam', 'gravityforms');
                    ?>
</a>
									<?php 
                }
        }
        ?>
						</div>
						<div id="publishing-action">
							<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entries') && $lead['status'] != 'trash') {
            $button_text = $mode == 'view' ? __('Edit', 'gravityforms') : __('Update', 'gravityforms');
            $disabled = $mode == 'view' ? '' : ' disabled="disabled" ';
            $update_button_id = $mode == 'view' ? 'gform_edit_button' : 'gform_update_button';
            $button_click = $mode == 'view' ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input id="' . $update_button_id . '" ' . $disabled . ' class="button button-large button-primary" type="submit" tabindex="4" value="' . esc_attr($button_text) . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters('gform_entrydetail_update_button', $update_button);
            if ($mode == 'edit') {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . esc_attr__('Cancel', 'gravityforms') . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
						</div>
						<div class="clear"></div>
					</div>
				</div>
			</div>
		</div>

		<?php 
        if (!empty($lead['payment_status']) && !apply_filters('gform_enable_entry_info_payment_details', true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

		<?php 
        do_action('gform_entry_detail_sidebar_middle', $form, $lead);
        ?>

		<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
            ?>
			<!-- start notifications -->
			<div class="postbox" id="notifications_container">
				<h3 class="hndle" style="cursor:default;">
					<span><?php 
            esc_html_e('Notifications', 'gravityforms');
            ?>
</span>
				</h3>

				<div class="inside">
					<div class="message" style="display:none;padding:10px;"></div>
					<div>
						<?php 
            $notifications = GFCommon::get_notifications('resend_notifications', $form);
            if (!is_array($notifications) || count($form['notifications']) <= 0) {
                ?>
							<p class="description"><?php 
                esc_html_e('You cannot resend notifications for this entry because this form does not currently have any notifications configured.', 'gravityforms');
                ?>
</p>

							<a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form_id}");
                ?>
" class="button"><?php 
                esc_html_e('Configure Notifications', 'gravityforms');
                ?>
</a>
						<?php 
            } else {
                foreach ($notifications as $notification) {
                    ?>
								<input type="checkbox" class="gform_notifications" value="<?php 
                    echo esc_attr($notification['id']);
                    ?>
" id="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
" onclick="toggleNotificationOverride();" />
								<label for="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
"><?php 
                    echo esc_html($notification['name']);
                    ?>
</label>
								<br /><br />
							<?php 
                }
                ?>

							<div id="notifications_override_settings" style="display:none;">

								<p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
									by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
								<label for="notification_override_email"><?php 
                esc_html_e('Send To', 'gravityforms');
                ?>
 <?php 
                gform_tooltip('notification_override_email');
                ?>
</label><br />
								<input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
								<br /><br />

							</div>

							<input type="button" name="notification_resend" value="<?php 
                esc_attr_e('Resend Notifications', 'gravityforms');
                ?>
" class="button" style="" onclick="ResendNotifications();" />
							<span id="please_wait_container" style="display:none; margin-left: 5px;">
								<i class='gficon-gravityforms-spinner-icon gficon-spin'></i> <?php 
                esc_html_e('Resending...', 'gravityforms');
                ?>
                            </span>
						<?php 
            }
            ?>

					</div>
				</div>
			</div>
			<!-- / end notifications -->
		<?php 
        }
        ?>

		<!-- begin print button -->
		<div class="detail-view-print">
			<a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo absint($form['id']);
        ?>
&lid=<?php 
        echo absint($lead['id']);
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        esc_html_e('Print', 'gravityforms');
        ?>
</a>
			<?php 
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
				<input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
				<label for="print_notes"><?php 
            esc_html_e('include notes', 'gravityforms');
            ?>
</label>
			<?php 
        }
        ?>
		</div>
		<!-- end print button -->
		<?php 
        do_action('gform_entry_detail_sidebar_after', $form, $lead);
        ?>
		</div>

		<div id="post-body" class="has-sidebar">
			<div id="post-body-content" class="has-sidebar-content">
				<?php 
        do_action('gform_entry_detail_content_before', $form, $lead);
        if ($mode == 'view') {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action('gform_entry_detail', $form, $lead);
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
					<div class="postbox">
						<h3>
							<label for="name"><?php 
            esc_html_e('Notes', 'gravityforms');
            ?>
</label>
						</h3>

						<form method="post">
							<?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
							<div class="inside">
								<?php 
            $notes = RGFormsModel::get_lead_notes($lead['id']);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field->id])) {
                    $emails[] = $lead[$email_field->id];
                }
            }
            //displaying notes grid
            $subject = '';
            self::notes_grid($notes, true, $emails, $subject);
            ?>
							</div>
						</form>
					</div>
				<?php 
        }
        do_action('gform_entry_detail_content_after', $form, $lead);
        ?>
			</div>
		</div>
		</div>
		</div>
		</form>
		<?php 
        if (rgpost('action') == 'update') {
            ?>
			<div class="updated fade" style="padding:6px;">
				<?php 
            esc_html_e('Entry Updated.', 'gravityforms');
            ?>
			</div>
		<?php 
        }
    }
Example #28
0
 private function _tab_matches($tabs)
 {
     if ($tabs == null) {
         return true;
     }
     if (!is_array($tabs)) {
         $tabs = array($tabs);
     }
     $current_tab = rgempty("subview", $_GET) ? "settings" : rgget("subview");
     foreach ($tabs as $tab) {
         if (strtolower($tab) == strtolower($current_tab)) {
             return true;
         }
     }
 }
Example #29
0
 public static function process_ipn($wp)
 {
     if (!self::is_gravityforms_supported()) {
         return;
     }
     //Ignore requests that are not IPN
     if (RGForms::get("page") != "gf_paypal_ipn") {
         return;
     }
     self::log_debug("IPN request received. Starting to process...");
     self::log_debug(print_r($_POST, true));
     //Send request to paypal and verify it has not been spoofed
     if (!self::verify_paypal_ipn()) {
         self::log_error("IPN request could not be verified by PayPal. Aborting.");
         return;
     }
     self::log_debug("IPN message successfully verified by PayPal");
     //Valid IPN requests must have a custom field
     $custom = RGForms::post("custom");
     if (empty($custom)) {
         self::log_error("IPN request does not have a custom field, so it was not created by Gravity Forms. Aborting.");
         return;
     }
     //Getting entry associated with this IPN message (entry id is sent in the "custom" field)
     list($entry_id, $hash) = explode("|", $custom);
     $hash_matches = wp_hash($entry_id) == $hash;
     //Validates that Entry Id wasn't tampered with
     if (!RGForms::post("test_ipn") && !$hash_matches) {
         self::log_error("Entry Id verification failed. Hash does not match. Custom field: {$custom}. Aborting.");
         return;
     }
     self::log_debug("IPN message has a valid custom field: {$custom}");
     //$entry_id = RGForms::post("custom");
     $entry = RGFormsModel::get_lead($entry_id);
     //Ignore orphan IPN messages (ones without an entry)
     if (!$entry) {
         self::log_error("Entry could not be found. Entry ID: {$entry_id}. Aborting.");
         return;
     }
     self::log_debug("Entry has been found." . print_r($entry, true));
     // config ID is stored in entry via send_to_paypal() function
     $config = self::get_config_by_entry($entry);
     //Ignore IPN messages from forms that are no longer configured with the PayPal add-on
     if (!$config) {
         self::log_error("Form no longer is configured with PayPal Addon. Form ID: {$entry["form_id"]}. Aborting.");
         return;
     }
     self::log_debug("Form {$entry["form_id"]} is properly configured.");
     //Only process test messages coming fron SandBox and only process production messages coming from production PayPal
     if ($config["meta"]["mode"] == "test" && !RGForms::post("test_ipn") || $config["meta"]["mode"] == "production" && RGForms::post("test_ipn")) {
         self::log_error("Invalid test/production mode. IPN message mode (test/production) does not match mode configured in the PayPal feed. Configured Mode: {$config["meta"]["mode"]}. IPN test mode: " . RGForms::post("test_ipn"));
         return;
     }
     //Check business email to make sure it matches
     $recipient_email = rgempty("business") ? rgpost("receiver_email") : rgpost("business");
     if (strtolower(trim($recipient_email)) != strtolower(trim($config["meta"]["email"]))) {
         self::log_error("PayPal email does not match. Email entered on PayPal feed:" . strtolower(trim($config["meta"]["email"])) . " - Email from IPN message: " . $recipient_email);
         return;
     }
     //Pre IPN processing filter. Allows users to cancel IPN processing
     $cancel = apply_filters("gform_paypal_pre_ipn", false, $_POST, $entry, $config);
     if (!$cancel) {
         self::log_debug("Setting payment status...");
         self::set_payment_status($config, $entry, RGForms::post("payment_status"), RGForms::post("txn_type"), RGForms::post("txn_id"), RGForms::post("parent_txn_id"), RGForms::post("subscr_id"), RGForms::post("mc_gross"), RGForms::post("pending_reason"), RGForms::post("reason_code"));
     } else {
         self::log_debug("IPN processing cancelled by the gform_paypal_pre_ipn filter. Aborting.");
     }
     self::log_debug("Before gform_paypal_post_ipn.");
     //Post IPN processing action
     do_action("gform_paypal_post_ipn", $_POST, $entry, $config, $cancel);
     self::log_debug("IPN processing complete.");
 }
Example #30
0
        protected function entry_edit_page($entry_id, $form_id)
        {
            if (empty($entry_id) && !rgempty("gforms_entry_id")) {
                $entry_id = rgpost("gforms_entry_id");
            }
            $api = $this->get_api();
            if (isset($_POST["gform_submit"])) {
                $entry = json_decode(rgpost("gform_entry_meta"), true);
                if (empty($entry_id)) {
                    $entry_id = $api->create_entry($entry);
                    $this->display_status("Entry created successfully", "There was an error creating your entry. ", $entry_id);
                    if (GFWebAPIError::is_error($entry_id)) {
                        return;
                    }
                } else {
                    $result = $api->update_entry($entry_id, $entry);
                    $this->display_status("Entry updated successfully", "There was an error updating your entry. ", $result);
                    if (GFWebAPIError::is_error($result)) {
                        return;
                    }
                }
            }
            $entry = empty($entry_id) ? array("id" => "", "date_created" => "", "form_id" => $form_id) : $api->get_entry($entry_id);
            if (GFWebAPIError::is_error($entry)) {
                $this->display_error("Could not load entry. Error: " . $entry->get_message());
                return;
            }
            ?>
            <div id="entry_detail">
                <form method="post">
                    <input name="gforms_entry_id" type="hidden" value="<?php 
            echo $entry_id;
            ?>
" />
                    <table class="gforms_form_settings" style="width:100%;">
                        <tbody>
                        <tr>
                            <td colspan="2"><h4 class="gf_settings_subgroup_title">Entry Information</h4></td>
                        </tr>
                        <tr>
                            <th>ID</th>
                            <td><?php 
            echo $entry["id"];
            ?>
</td>
                        </tr>
                        <tr>
                            <th>Date</th>
                            <td><?php 
            echo $entry["date_created"];
            ?>
</td>
                        </tr>
                        <tr>
                            <td colspan="2"><h4 class="gf_settings_subgroup_title">Entry Meta</h4></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <textarea name="gform_entry_meta" style="width:750px; height:300px;"><?php 
            echo json_encode($entry);
            ?>
</textarea>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input type="submit" name="gform_submit" value="Update" class="button-primary" />
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        <?php 
        }