public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br) { $use_value = $modifier == 'value'; $use_price = in_array($modifier, array('price', 'currency')); $format_currency = $modifier == 'currency'; if (is_array($raw_value) && (string) intval($input_id) != $input_id) { $items = array($input_id => $value); //float input Ids. (i.e. 4.1 ). Used when targeting specific checkbox items } elseif (is_array($raw_value)) { $items = $raw_value; } else { $items = array($input_id => $raw_value); } $ary = array(); foreach ($items as $input_id => $item) { if ($use_value) { list($val, $price) = rgexplode('|', $item, 2); } elseif ($use_price) { list($name, $val) = rgexplode('|', $item, 2); if ($format_currency) { $val = GFCommon::to_money($val, rgar($entry, 'currency')); } } elseif ($this->type == 'post_category') { $use_id = strtolower($modifier) == 'id'; $item_value = GFCommon::format_post_category($item, $use_id); $val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : $item_value; } else { $val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : RGFormsModel::get_choice_text($this, $raw_value, $input_id); } $ary[] = GFCommon::format_variable_value($val, $url_encode, $esc_html, $format); } return GFCommon::implode_non_blank(', ', $ary); }
public function get_value_entry_list($value, $entry, $field_id, $columns, $form) { 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 = GFEntryList::get_icon_url($url); $value = "<a href='" . esc_attr($url) . "' target='_blank' title='" . __('Click to view', 'gravityforms') . "'><img src='{$thumb}'/></a>"; } return $value; }
public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead) { // ignore submitted value and recalculate price in backend list($prefix, $field_id, $input_id) = rgexplode('_', $input_name, 3); if ($input_id == 2) { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = $currency->to_money(GFCommon::calculate($this, $form, $lead)); } return $value; }
function __construct($args = array(), $step = false) { $this->step = $step; if (is_string($args)) { $parts = explode('|', $args); $type = $parts[0]; $id = $parts[1]; } elseif (is_array($args)) { $id = $args['id']; $type = $args['type']; if (isset($args['editable_fields'])) { $this->editable_fields = $args['editable_fields']; } } else { throw new Exception('Assignees must be instantiated with either a string or an array'); } switch ($type) { case 'assignee_field': $entry = $this->step->get_entry(); $assignee_key = rgar($entry, $id); list($this->type, $this->id) = rgexplode('|', $assignee_key, 2); break; case 'assignee_user_field': $entry = $this->step->get_entry(); $this->id = absint(rgar($entry, $id)); $this->type = 'user_id'; break; case 'assignee_role_field': $entry = $this->step->get_entry(); $this->id = sanitize_text_field(rgar($entry, $id)); $this->type = 'role'; break; case 'email_field': $entry = $this->step->get_entry(); $this->id = sanitize_email(rgar($entry, $id)); $this->type = 'email'; break; case 'entry': $entry = $this->step->get_entry(); $this->id = rgar($entry, $id); $this->type = 'user_id'; break; default: $this->type = $type; $this->id = $id; } $this->key = $this->type . '|' . $this->id; }
/** * Prepare the value before saving it to the lead. * * @param mixed $form * @param mixed $field * @param mixed $value * @param mixed $input_name * @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations) * @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function */ public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array()) { $form_id = $form["id"]; $input_type = self::get_input_type($field); switch ($input_type) { case "total": $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = GFCommon::get_order_total($form, $lead); break; case "calculation": // ignore submitted value and recalculate price in backend list(, , $input_id) = rgexplode("_", $input_name, 3); if ($input_id == 2) { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = $currency->to_money(GFCommon::calculate($field, $form, $lead)); } break; case "phone": if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) { $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]); } break; case "time": if (!is_array($value) && !empty($value)) { preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches); $value = array(); $value[0] = $matches[1]; $value[1] = $matches[2]; $value[2] = rgar($matches, 3); } $hour = empty($value[0]) ? "0" : strip_tags($value[0]); $minute = empty($value[1]) ? "0" : strip_tags($value[1]); $ampm = strip_tags(rgar($value, 2)); if (!empty($ampm)) { $ampm = " {$ampm}"; } if (!(empty($hour) && empty($minute))) { $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm); } else { $value = ""; } break; case "date": $value = self::prepare_date($field["dateFormat"], $value); break; case "post_image": $url = self::get_fileupload_value($form_id, $input_name); $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : ""; $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : ""; $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : ""; $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : ""; break; case "fileupload": $value = self::get_fileupload_value($form_id, $input_name); break; case "number": $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat")); //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false if (GFCommon::has_field_calculation($field) && $value == 0) { $value = "0"; } break; case "website": if ($value == "http://") { $value = ""; } break; case "list": if (GFCommon::is_empty_array($value)) { $value = ""; } else { $value = self::create_list_array($field, $value); $value = serialize($value); } break; case "radio": if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') { $value = rgpost("input_{$field['id']}_other"); } break; case "multiselect": $value = empty($value) ? "" : implode(",", $value); break; case "creditcard": //saving last 4 digits of credit card list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3); if ($input_id == "1") { $value = str_replace(" ", "", $value); $card_number_length = strlen($value); $value = substr($value, -4, 4); $value = str_pad($value, $card_number_length, "X", STR_PAD_LEFT); } else { if ($input_id == "4") { $card_number = rgpost("input_{$field_id_token}_1"); $card_type = GFCommon::get_card_type($card_number); $value = $card_type ? $card_type["name"] : ""; } else { $value = ""; } } break; default: //allow HTML for certain field types $allow_html = in_array($field["type"], array("post_custom_field", "post_title", "post_content", "post_excerpt", "post_tags")) || in_array($input_type, array("checkbox", "radio")) ? true : false; $allowable_tags = apply_filters("gform_allowable_tags_{$form_id}", apply_filters("gform_allowable_tags", $allow_html, $field, $form_id), $field, $form_id); if ($allowable_tags !== true) { $value = strip_tags($value, $allowable_tags); } break; } // special format for Post Category fields if ($field['type'] == 'post_category') { $full_values = array(); if (!is_array($value)) { $value = explode(',', $value); } foreach ($value as $cat_id) { $cat = get_term($cat_id, 'category'); $full_values[] = !is_wp_error($cat) && is_object($cat) ? $cat->name . ":" . $cat_id : ""; } $value = implode(',', $full_values); } //do not save price fields with blank price if (rgar($field, "enablePrice")) { $ary = explode("|", $value); $label = count($ary) > 0 ? $ary[0] : ""; $price = count($ary) > 1 ? $ary[1] : ""; $is_empty = strlen(trim($price)) <= 0; if ($is_empty) { $value = ""; } } return $value; }
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' => __('«', 'gravityforms'), 'next_text' => __('»', '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&inlineId=notifications_modal_container', ''); return false; break; case 'print': resetPrintUI(); tb_show('<?php _e("Print Entries", "gravityforms"); ?> ', '#TB_inline?width=350&height=250&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') ? '¬es=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" > </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" > </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); ?> <?php do_action("gform_entries_column", $form_id, $field_id, $value, $lead, $query_string); ?> </td> <?php } $is_first_column = false; } ?> <td> </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 }
/** * Take a passed CSV of terms and generate a linked list of terms * * Gravity Forms passes categories as "Name:ID" so we handle that using the ID, which * is more accurate than checking the name, which is more likely to change. * * @param string $value Existing value * @param string $taxonomy Type of term (`post_tag` or `category`) * @return string CSV of linked terms */ function gravityview_convert_value_to_term_list($value, $taxonomy = 'post_tag') { $output = array(); $terms = explode(', ', $value); foreach ($terms as $term_name) { // If we're processing a category, if ($taxonomy === 'category') { // Use rgexplode to prevent errors if : doesn't exist list($term_name, $term_id) = rgexplode(':', $value, 2); // The explode was succesful; we have the category ID if (!empty($term_id)) { $term = get_term_by('id', $term_id, $taxonomy); } else { // We have to fall back to the name $term = get_term_by('name', $term_name, $taxonomy); } } else { // Use the name of the tag to get the full term information $term = get_term_by('name', $term_name, $taxonomy); } // There's still a tag/category here. if ($term) { $term_link = get_term_link($term, $taxonomy); // If there was an error, continue to the next term. if (is_wp_error($term_link)) { continue; } $output[] = gravityview_get_link($term_link, esc_html($term->name)); } } return implode(', ', $output); }
/** * extract the shipping amount from a shipping field * @return float */ private static function getShipping($form, $field) { $shipping = 0; $id = $field['id']; if (!GFFormsModel::is_field_hidden($form, $field, array())) { $value = rgpost("input_{$id}"); if (!empty($value) && $field["inputType"] != 'singleshipping') { // drop-down list / radio buttons list($name, $value) = rgexplode('|', $value, 2); } $shipping = GFCommon::to_number($value); } return $shipping; }
public static function date_display($value, $format = "mdy") { $date = self::parse_date($value, $format); if (empty($date)) { return $value; } list($position, $separator) = rgexplode("_", $format, 2); switch ($separator) { case "dash": $separator = "-"; break; case "dot": $separator = "."; break; default: $separator = "/"; break; } switch ($position) { case "ymd": return $date["year"] . $separator . $date["month"] . $separator . $date["day"]; break; case "dmy": return $date["day"] . $separator . $date["month"] . $separator . $date["year"]; break; default: return $date["month"] . $separator . $date["day"] . $separator . $date["year"]; break; } }
private static function prepare_value($form, $field, $value, $input_name, $lead_id) { $form_id = $form["id"]; $input_type = self::get_input_type($field); switch ($input_type) { case "total": $lead = RGFormsModel::get_lead($lead_id); $value = GFCommon::get_order_total($form, $lead); break; case "post_category": $cat = get_category($value); $value = !empty($cat) ? $cat->name . ":" . $value : ""; break; case "phone": if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) { $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]); } break; case "time": if (!is_array($value) && !empty($value)) { preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches); $value = array(); $value[0] = $matches[1]; $value[1] = $matches[2]; $value[2] = rgar($matches, 3); } $hour = empty($value[0]) ? "0" : strip_tags($value[0]); $minute = empty($value[1]) ? "0" : strip_tags($value[1]); $ampm = strip_tags(rgar($value, 2)); if (!empty($ampm)) { $ampm = " {$ampm}"; } if (!(empty($hour) && empty($minute))) { $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm); } else { $value = ""; } break; case "date": $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"]; $date_info = GFCommon::parse_date($value, $format); if (!empty($date_info)) { $value = sprintf("%d-%02d-%02d", $date_info["year"], $date_info["month"], $date_info["day"]); } else { $value = ""; } break; case "post_image": $url = self::get_fileupload_value($form_id, $input_name); $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : ""; $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : ""; $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : ""; $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : ""; break; case "fileupload": $value = self::get_fileupload_value($form_id, $input_name); break; case "number": $value = GFCommon::clean_number($value, rgar($field, "numberFormat")); break; case "website": if ($value == "http://") { $value = ""; } break; case "list": if (GFCommon::is_empty_array($value)) { $value = ""; } else { $value = self::create_list_array($field, $value); $value = serialize($value); } break; case "radio": if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') { $value = rgpost("input_{$field['id']}_other"); } break; case "multiselect": $value = empty($value) ? "" : implode(",", $value); break; case "creditcard": //saving last 4 digits of credit card list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3); if ($input_id == "1") { $value = str_replace(" ", "", $value); $card_number_length = strlen($value); $value = substr($value, -4, 4); $value = str_pad($value, $card_number_length, "X", STR_PAD_LEFT); } else { if ($input_id == "4") { $card_number = rgpost("input_{$field_id_token}_1"); $card_type = GFCommon::get_card_type($card_number); $value = $card_type ? $card_type["name"] : ""; } else { $value = ""; } } break; default: //allow HTML for certain field types $allow_html = in_array($field["type"], array("post_custom_field", "post_title", "post_content", "post_excerpt", "post_tags")) || in_array($input_type, array("checkbox", "radio")) ? true : false; $allowable_tags = apply_filters("gform_allowable_tags_{$form_id}", apply_filters("gform_allowable_tags", $allow_html, $field, $form_id), $field, $form_id); if ($allowable_tags !== true) { $value = strip_tags($value, $allowable_tags); } break; } //do not save price fields with blank price if (rgar($field, "enablePrice")) { $ary = explode("|", $value); $label = count($ary) > 0 ? $ary[0] : ""; $price = count($ary) > 1 ? $ary[1] : ""; $is_empty = strlen(trim($price)) <= 0; if ($is_empty) { $value = ""; } } return $value; }
public static function display($args) { $assignee_key = sanitize_text_field(rgget('assignee')); list($assignee_type, $assignee_id) = rgexplode('|', $assignee_key, 2); $range = sanitize_key(rgget('range')); switch ($range) { case 'last-6-months': $start_date = date('Y-m-d', strtotime('-6 months')); break; case 'last-3-months': $start_date = date('Y-m-d', strtotime('-3 months')); break; default: $start_date = date('Y-m-d', strtotime('-1 year')); } $defaults = array('view' => rgget('view'), 'form_id' => absint(rgget('form-id')), 'step_id' => absint(rgget('step-id')), 'category' => sanitize_key(rgget('category')), 'range' => $range, 'start_date' => $start_date, 'assignee' => $assignee_key, 'assignee_type' => $assignee_type, 'assignee_id' => $assignee_id, 'check_permissions' => true, 'base_url' => admin_url('admin.php?page=gravityflow-reports')); $args = array_merge($defaults, $args); if ($args['check_permissions'] && !GFAPI::current_user_can_any('gravityflow_reports')) { esc_html_e("You don't have permission to view this page", 'gravityflow'); return; } $filter_vars['config'] = self::get_filter_config_vars(); $filter_vars['selected'] = array('formId' => $args['form_id'], 'category' => $args['category'], 'stepId' => empty($args['step_id']) ? '' : $args['step_id'], 'assignee' => $args['assignee']); ?> <script>var gravityflowFilterVars = <?php echo json_encode($filter_vars); ?> ;</script> <div id="gravityflow-reports-filter" style="margin-bottom:10px;"> <form method="GET" action="<?php echo esc_url($args['base_url']); ?> "> <input type="hidden" value="gravityflow-reports" name="page" /> <?php self::range_drop_down($args['range']); ?> <?php self::form_drop_down($args['form_id']); ?> <?php self::category_drop_down($args['category']); ?> <select id="gravityflow-reports-steps" style="display:none;" name="step-id"></select> <select id="gravityflow-reports-assignees" style="display:none;" name="assignee"></select> <input type="submit" value="<?php esc_html_e('Filter', 'gravityflow'); ?> " class="button-secondary" /> </form> </div> <?php if (empty($args['form_id'])) { self::report_all_forms($args); return; } $form_id = $args['form_id']; if ($args['category'] == 'assignee') { if (empty($args['assignee_key'])) { self::report_form_by_assignee($form_id, $args); } } elseif ($args['category'] == 'step') { if (empty($args['step_id'])) { self::report_form_by_step($form_id, $args); } else { $step_id = $args['step_id']; if (empty($args['assignee_id'])) { self::report_step_by_assignee($step_id, $args); } else { $assignee_type = $args['assignee_type']; $assignee_id = $args['assignee_id']; self::report_assignee_by_month($assignee_type, $assignee_id, $args); } } } else { self::report_form_by_month($form_id, $args); } }
private static function get_post_fields($form, $lead) { $post_data = array(); $post_data['post_custom_fields'] = array(); $post_data['tags_input'] = array(); $categories = array(); $images = array(); foreach ($form['fields'] as $field) { if ($field->type == 'post_category') { $field = GFCommon::add_categories_as_choices($field, ''); } $value = self::get_post_field_value($field, $lead); switch ($field->type) { case 'post_title': case 'post_excerpt': case 'post_content': $post_data[$field->type] = $value; break; case 'post_tags': $tags = explode(',', $value); if (is_array($tags) && sizeof($tags) > 0) { $post_data['tags_input'] = array_merge($post_data['tags_input'], $tags); } break; case 'post_custom_field': $type = self::get_input_type($field); if ('fileupload' === $type && $field->multipleFiles) { $value = json_decode($value, true); } $meta_name = $field->postCustomFieldName; if (!isset($post_data['post_custom_fields'][$meta_name])) { $post_data['post_custom_fields'][$meta_name] = $value; } else { if (!is_array($post_data['post_custom_fields'][$meta_name])) { $post_data['post_custom_fields'][$meta_name] = array($post_data['post_custom_fields'][$meta_name], $value); } else { $post_data['post_custom_fields'][$meta_name][] = $value; } } break; case 'post_category': foreach (explode(',', $value) as $cat_string) { list($cat_name, $cat_id) = rgexplode(':', $cat_string, 2); array_push($categories, $cat_id); } break; case 'post_image': $ary = !empty($value) ? explode('|:|', $value) : array(); $url = count($ary) > 0 ? $ary[0] : ''; $title = count($ary) > 1 ? $ary[1] : ''; $caption = count($ary) > 2 ? $ary[2] : ''; $description = count($ary) > 3 ? $ary[3] : ''; array_push($images, array('field_id' => $field->id, 'url' => $url, 'title' => $title, 'description' => $description, 'caption' => $caption)); break; } } $post_data['post_status'] = rgar($form, 'postStatus'); $post_data['post_category'] = !empty($categories) ? $categories : array(rgar($form, 'postCategory')); $post_data['images'] = $images; //setting current user as author depending on settings $post_data['post_author'] = $form['useCurrentUserAsAuthor'] && !empty($lead['created_by']) ? $lead['created_by'] : $form['postAuthor']; return $post_data; }
public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead) { //saving last 4 digits of credit card list($input_token, $field_id_token, $input_id) = rgexplode('_', $input_name, 3); if ($input_id == '1') { $value = str_replace(' ', '', $value); $card_number_length = strlen($value); $value = substr($value, -4, 4); $value = str_pad($value, $card_number_length, 'X', STR_PAD_LEFT); } elseif ($input_id == '4') { $value = rgpost("input_{$field_id_token}_4"); if (!$value) { $card_number = rgpost("input_{$field_id_token}_1"); $card_type = GFCommon::get_card_type($card_number); $value = $card_type ? $card_type['name'] : ''; } } else { $value = ''; } return $this->sanitize_entry_value($value, $form['id']); }
public static function get_parameter_value($name, $field_values, $field) { $value = stripslashes(rgget($name)); if (empty($value)) { $value = rgget($name, $field_values); } //converting list format if (RGFormsModel::get_input_type($field) == 'list') { //transforms this: col1|col2,col1b|col2b into this: col1,col2,col1b,col2b $column_count = count($field->choices); $rows = explode(',', $value); $ary_rows = array(); if (!empty($rows)) { foreach ($rows as $row) { $ary_rows = array_merge($ary_rows, rgexplode('|', $row, $column_count)); } $value = $ary_rows; } } return gf_apply_filters(array('gform_field_value', $name), $value, $field, $name); }
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"); $update_message = ""; switch ($action) { case "delete": check_admin_referer('gforms_entry_list', 'gforms_entry_list'); $lead_id = $_POST["action_argument"]; RGFormsModel::delete_lead($lead_id); $update_message = __("Entry deleted.", "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"]; $leads = $_POST["lead"]; $entry_count = count($leads) > 1 ? sprintf(__("%d entries", "gravityforms"), count($leads)) : __("1 entry", "gravityforms"); switch ($bulk_action) { case "delete": RGFormsModel::delete_leads($leads); $update_message = sprintf(__("%s deleted.", "gravityforms"), $entry_count); 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; } $filter = rgget("filter"); if (rgpost("button_delete_permanently")) { RGFormsModel::delete_leads_by_form($form_id, $filter); } $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"]; $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"]; $search = RGForms::get("s"); $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1; $star = $filter == "star" ? 1 : null; // is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null; $read = $filter == "unread" ? 0 : null; //is_numeric(RGForms::get("read")) ? intval(RGForms::get("read")) : null; $page_size = 20; $first_item_index = $page_index * $page_size; $form = RGFormsModel::get_form_meta($form_id); $sort_field_meta = RGFormsModel::get_field($form, $sort_field); $is_numeric = $sort_field_meta["type"] == "number"; $status = in_array($filter, array("trash", "spam")) ? $filter : "active"; $leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric, null, null, $status); $lead_count = RGFormsModel::get_lead_count($form_id, $search, $star, $read); $summary = RGFormsModel::get_form_counts($form_id); $total_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}" : ""; $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, 'format' => 'paged=%#%', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($lead_count / $page_size), 'current' => $page_index + 1, 'show_all' => false)); wp_print_scripts(array("thickbox")); wp_print_styles(array("thickbox")); ?> <script src="<?php echo GFCommon::get_base_url(); ?> /js/jquery.json-1.3.js?ver=<?php echo GFCommon::$version; ?> "></script> <script src="<?php echo includes_url(); ?> /js/wp-lists.dev.js" type="text/javascript"></script> <script src="<?php echo includes_url(); ?> /js/wp-ajax-response.dev.js" type="text/javascript"></script> <script type="text/javascript"> var messageTimeout = false; 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){ var search_qs = search == "" ? "" : "&s=" + search; var star_qs = star == "" ? "" : "&star=" + star; var read_qs = read == "" ? "" : "&read=" + read; var location = "?page=gf_entries&view=entries&id=" + form_id + "&sort=" + sort_field_id + "&dir=" + sort_direction + search_qs + star_qs + read_qs; document.location = location; } function ToggleStar(img, lead_id){ 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"); UpdateCount("star_count", is_starred ? -1 : 1); UpdateLeadProperty(lead_id, "is_starred", is_starred ? 0 : 1); } function ToggleRead(lead_id){ 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"); 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.encVar( "cookie", document.cookie, false ); 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 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&inlineId=notifications_modal_container', ''); return false; break; case 'print': resetPrintUI(); tb_show('<?php _e("Print Entries", "gravityforms"); ?> ', '#TB_inline?width=350&height=250&inlineId=print_modal_container', ''); return false; break; default: jQuery('#action').val('bulk'); } } function getLeadIds(){ 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 sendAdmin = jQuery("#notification_admin").is(":checked") ? 1 : 0; var sendUser = jQuery("#notification_user").is(":checked") ? 1 : 0; var leadIds = getLeadIds(); var sendTo = jQuery('#notification_override_email').val(); if(!sendAdmin && !sendUser) { 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'); ?> ', sendAdmin : sendAdmin, sendUser : sendUser, sendTo : sendTo, leadIds : leadIds, 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"); ?> '; displayMessage(message.replace('%s', leadIds.length + ' ' + getPlural(leadIds.length, '<?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(); var leadsQS = '&lid=' + leadIds.join(','); var notesQS = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var pageBreakQS = jQuery('#gform_print_page_break').is(':checked') ? '&page_break=1' : ''; var url = '<?php echo site_url(); ?> /?gf_page=print-entry&fid=<?php echo $form['id']; ?> ' + leadsQS + notesQS + pageBreakQS; 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('#notification_admin').is(':checked') || jQuery('#notification_user').is(':checked')) { jQuery('#notifications_override_settings').slideDown(); } else { jQuery('#notifications_override_settings').slideUp(function(){ jQuery('#notification_override_email').val(''); }); } } jQuery(document).ready(function(){ jQuery("#lead_search").keypress(function(event){ if(event.keyCode == 13){ Search('<?php echo $sort_field; ?> ', '<?php echo $sort_direction; ?> ', <?php echo $form_id; ?> , this.value, '<?php echo $star; ?> ', '<?php echo $read; ?> '); event.preventDefault(); } }); 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){ var currentStatus = "<?php echo $filter == "trash" || $filter == "spam" ? $filter : "active"; ?> "; var movingTo = "active"; if(s.target.className.indexOf(':status=trash') != -1) movingTo = "trash"; else if(s.target.className.indexOf(':status=spam') != -1) movingTo = "spam"; else if(s.target.className.indexOf(':status=delete') != -1) 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); } //Updating trash count if(currentStatus == "trash" || movingTo == "trash"){ var spamCount = movingTo == "trash" ? 1 : -1; UpdateCount("trash_count", spamCount); } });; }); </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; } </style> <div class="wrap"> <div class="icon32" id="gravity-entry-icon"><br></div> <h2><?php _e("Entries", "gravityforms"); ?> : <?php echo $form["title"]; ?> </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" /> <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 $total_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::has_akismet()) { ?> <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> <p class="search-box"> <label class="hidden" for="lead_search"><?php _e("Search Entries:", "gravityforms"); ?> </label> <input type="text" id="lead_search" value="<?php echo $search; ?> "><a class="button" id="lead_search_button" href="javascript:Search('<?php echo $sort_field; ?> ', '<?php echo $sort_direction; ?> ', <?php echo $form_id; ?> , jQuery('#lead_search').val(), '<?php echo $star; ?> ', '<?php echo $read; ?> ');"><?php _e("Search", "gravityforms"); ?> </a> </p> <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::has_akismet()) { ?> <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.") : __("WARNING! This operation cannot be undone. Permanently delete all spam? \\'Ok\\' to delete. \\'Cancel\\' to abort."); $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"> <p class="description"><?php _e("Specify which notifications you would like to resend for the selected entries.", "gravityforms"); ?> </p> <?php if (GFCommon::has_admin_notification($form)) { ?> <input type="checkbox" name="notification_admin" id="notification_admin" onclick="toggleNotificationOverride();" /> <label for="notification_admin"><?php _e("Admin Notification", "gravityforms"); ?> </label> <br /><br /> <?php } ?> <?php if (GFCommon::has_user_notification($form)) { ?> <input type="checkbox" name="notification_user" id="notification_user" onclick="toggleNotificationOverride();" /> <label for="notification_user"><?php _e("User Notification", "gravityforms"); ?> </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> </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 id="post_tag" 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 //Displaying paging links if appropriate if ($page_links) { ?> <div class="tablenav-pages"> <span class="displaying-num"><?php printf(__("Displaying %d - %d of %d", "gravityforms"), $first_item_index + 1, $first_item_index + $page_size > $lead_count ? $lead_count : $first_item_index + $page_size, $lead_count); ?> </span> <?php echo $page_links; ?> </div> <?php } ?> <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" > </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; ?> ');" style="cursor:pointer;"><?php echo esc_html($field_info["label"]); ?> </th> <?php } ?> <th scope="col" align="right" width="50"> <a title="<?php _e("Select Columns", "gravityforms"); ?> " href="<?php echo site_url(); ?> /?gf_page=select_columns&id=<?php echo $form_id; ?> &TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><?php _e("Edit", "gravityforms"); ?> </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" > </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; ?> ');" style="cursor:pointer;"><?php echo esc_html($field_info["label"]); ?> </th> <?php } ?> <th scope="col" style="width:15px;"> <a href="<?php echo site_url(); ?> /?gf_page=select_columns&id=<?php echo $form_id; ?> &TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><?php _e("Edit", "gravityforms"); ?> </a> </th> </tr> </tfoot> <tbody class="list:gf_entry user-list" id="gf_entry_list"> <?php if (sizeof($leads) > 0) { $field_ids = array_keys($columns); foreach ($leads as $lead) { ?> <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" : ""; ?> ' valign="top"> <th scope="row" class="check-column"> <input type="checkbox" name="lead[]" value="<?php echo $lead["id"]; ?> " /> </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"]; ?> );" /> </td> <?php } $is_first_column = true; $nowrap_class = "entry_nowrap"; foreach ($field_ids as $field_id) { $value = RGForms::get($field_id, $lead); //filtering lead value $value = apply_filters("gform_get_field_value", $value, $lead, RGFormsModel::get_field($form, $field_id)); $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); } else { $value = ""; //looping through lead detail values trying to find an item identical to the column label. Mark with a tick if found. $lead_field_keys = array_keys($lead); foreach ($lead_field_keys as $input_id) { //mark as a tick if input label (from form meta) is equal to submitted value (from lead) if (is_numeric($input_id) && absint($input_id) == absint($field_id)) { if ($lead[$input_id] == $columns[$field_id]["label"]) { $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>"; } else { $field = RGFormsModel::get_field($form, $field_id); if (rgar($field, "enableChoiceValue") || rgar($field, "enablePrice")) { foreach ($field["choices"] as $choice) { if ($choice["value"] == $lead[$field_id]) { $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>"; break; } else { if ($field["enablePrice"]) { $ary = explode("|", $lead[$field_id]); $val = count($ary) > 0 ? $ary[0] : ""; $price = count($ary) > 1 ? $ary[1] : ""; if ($val == $choice["value"]) { $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>"; break; } } } } } } } } } 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 "post_category": $ary = explode(":", $value); $cat_name = count($ary) > 0 ? $ary[0] : ""; $value = $cat_name; break; case "fileupload": $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, $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); $value = $userdata->user_login; } break; default: $value = esc_html($value); } $value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead); $query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_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; ?> &paged=<?php echo $page_index + 1; ?> "><?php echo $value; ?> </a> <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; ?> &paged=<?php echo $page_index + 1; ?> "><?php _e("View", "gravityforms"); ?> </a> | </span> <span class="edit"> <a class='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 class="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; ?> &paged=<?php echo $page_index + 1; ?> "><?php _e("View", "gravityforms"); ?> </a> | </span> <span class="unspam"> <a class='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 class="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; ?> &paged=<?php echo $page_index + 1; ?> "><?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"]; ?> );" 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"]; ?> );" 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::has_akismet() ? "|" : ""; ?> </span> <?php if (GFCommon::has_akismet()) { ?> <span class="spam"> <a class='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 class='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 $value; ?> <?php do_action("gform_entries_column", $form_id, $field_id, $value, $lead, $query_string); ?> </td> <?php } $is_first_column = false; } ?> <td> </td> </tr> <?php } } else { $message = ""; $column_count = sizeof($columns) + 3; switch ($filter) { case "unread": $message = __("This form does not have any unread entries.", "gravityforms"); break; case "star": $message = __("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 = __("This form does not have any entries in the trash.", "gravityforms"); $column_count = sizeof($columns) + 2; break; default: $message = __("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", "gravityforms"); ?> </option> <?php if (GFCommon::has_akismet()) { ?> <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_action2\');" />'; echo apply_filters("gform_entry_apply_button", $apply_button); ?> </div> <?php //Displaying paging links if appropriate if ($page_links) { ?> <div class="tablenav-pages"> <span class="displaying-num"><?php printf(__("Displaying %d - %d of %d", "gravityforms"), $first_item_index + 1, $first_item_index + $page_size > $lead_count ? $lead_count : $first_item_index + $page_size, $lead_count); ?> </span> <?php echo $page_links; ?> </div> <?php } ?> <div class="clear"></div> </div> </form> </div> <?php }
/** * Return the Likert column text for the stored entry value. * * @param string|array $value The field value. * @param array|false $entry The Entry Object currently being processed. * @param string|false $field_id The field or input ID currently being processed. * @param bool|false $include_row_text Should the row text be returned along with the column text? * * @return string */ public function get_column_text($value, $entry = false, $field_id = false, $include_row_text = false) { if ($this->gsurveyLikertEnableMultipleRows) { $row_id = $this->get_row_id($field_id); $values = !empty($entry) ? RGFormsModel::get_lead_field_value($entry, $this) : $value; if ($row_id && is_array($values)) { foreach ($values as $value) { if (!empty($value)) { list($row_val, $col_val) = rgexplode(':', $value, 2); if ($row_id == $row_val) { $choice_text = $this->get_choice_text($col_val); return $include_row_text ? sprintf('%s: %s', $this->get_row_label($field_id), $choice_text) : $choice_text; } } } } return ''; } else { return $this->get_choice_text($value); } }
/** * Prepare the value before saving it to the lead. * * @param mixed $form * @param mixed $field * @param mixed $value * @param mixed $input_name * @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations) * @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function */ public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array()) { $form_id = $form["id"]; $input_type = self::get_input_type($field); switch ($input_type) { case "total": $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = GFCommon::get_order_total($form, $lead); break; case "calculation": // ignore submitted value and recalculate price in backend list(, , $input_id) = rgexplode("_", $input_name, 3); if ($input_id == 2) { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = $currency->to_money(GFCommon::calculate($field, $form, $lead)); } break; case "phone": if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) { $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]); } break; case "time": if (!is_array($value) && !empty($value)) { preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches); $value = array(); $value[0] = $matches[1]; $value[1] = $matches[2]; $value[2] = rgar($matches, 3); } $hour = empty($value[0]) ? "0" : strip_tags($value[0]); $minute = empty($value[1]) ? "0" : strip_tags($value[1]); $ampm = strip_tags(rgar($value, 2)); if (!empty($ampm)) { $ampm = " {$ampm}"; } if (!(empty($hour) && empty($minute))) { $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm); } else { $value = ""; } break; case "date": $value = self::prepare_date(rgar($field, 'dateFormat'), $value); break; case "post_image": $url = self::get_fileupload_value($form_id, $input_name); $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : ""; $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : ""; $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : ""; $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : ""; break; case "fileupload": if (rgar($field, "multipleFiles")) { global $_gf_uploaded_files; if (isset($_gf_uploaded_files[$input_name])) { $value = $_gf_uploaded_files[$input_name]; } else { if (isset(GFFormsModel::$uploaded_files[$form_id][$input_name])) { $uploaded_temp_files = GFFormsModel::$uploaded_files[$form_id][$input_name]; $uploaded_files = array(); foreach ($uploaded_temp_files as $i => $file_info) { $temp_filepath = self::get_upload_path($form_id) . '/tmp/' . $file_info['temp_filename']; if ($file_info && file_exists($temp_filepath)) { $uploaded_files[$i] = self::move_temp_file($form_id, $file_info); } } if (!empty($value)) { // merge with existing files (admin edit entry) $value = json_decode($value, true); $value = array_merge($value, $uploaded_files); $value = json_encode($value); } else { $value = json_encode($uploaded_files); } } else { $value = ''; } $_gf_uploaded_files[$input_name] = $value; } } else { $value = self::get_fileupload_value($form_id, $input_name); } break; case "number": $value = GFCommon::maybe_add_leading_zero($value); $is_hidden = RGFormsModel::is_field_hidden($form, $field, array()); $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead; $value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat")); //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false if (GFCommon::has_field_calculation($field) && $value == 0) { $value = "0"; } break; case "website": if ($value == "http://") { $value = ""; } break; case "list": if (rgar($field, "adminOnly") && rgar($field, "allowsPrepopulate")) { $value = json_decode($value); } if (GFCommon::is_empty_array($value)) { $value = ""; } else { foreach ($value as &$val) { $val = self::sanitize_entry_value($field, $val, $input_type, $form_id); } $value = self::create_list_array($field, $value); $value = serialize($value); } break; case "radio": if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') { $value = rgpost("input_{$field['id']}_other"); } $value = self::sanitize_entry_value($field, $value, $input_type, $form_id); break; case "multiselect": $value = empty($value) ? "" : is_array($value) ? implode(",", $value) : $value; $value = self::sanitize_entry_value($field, $value, $input_type, $form_id); break; case "creditcard": //saving last 4 digits of credit card list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3); if ($input_id == "1") { $value = str_replace(" ", "", $value); $card_number_length = strlen($value); $value = substr($value, -4, 4); $value = str_pad($value, $card_number_length, "X", STR_PAD_LEFT); } else { if ($input_id == '4') { $value = rgpost("input_{$field_id_token}_4"); if (!$value) { $card_number = rgpost("input_{$field_id_token}_1"); $card_type = GFCommon::get_card_type($card_number); $value = $card_type ? $card_type['name'] : ''; } } else { $value = ""; } } break; case 'password': $encrypt_password = apply_filters('gform_encrypt_password', false, $field, $form); if ($encrypt_password) { $value = GFCommon::encrypt($value); self::set_encrypted_fields($lead_id, $field['id']); } break; default: // only filter HTML on non-array based values if (!is_array($value)) { $value = self::sanitize_entry_value($field, $value, $input_type, $form_id); } break; } // special format for Post Category fields if ($field['type'] == 'post_category') { $full_values = array(); if (!is_array($value)) { $value = explode(',', $value); } foreach ($value as $cat_id) { $cat = get_term($cat_id, 'category'); $full_values[] = !is_wp_error($cat) && is_object($cat) ? $cat->name . ":" . $cat_id : ""; } $value = implode(',', $full_values); } //do not save price fields with blank price if (rgar($field, "enablePrice")) { $ary = explode("|", $value); $label = count($ary) > 0 ? $ary[0] : ""; $price = count($ary) > 1 ? $ary[1] : ""; $is_empty = strlen(trim($price)) <= 0; if ($is_empty) { $value = ""; } } return $value; }
/** * Adds a note to the timeline. The timeline is a filtered subset of the Gravity Forms Entry notes. * * @param $note * @param bool $user_id * @param bool $user_name */ public function add_note($note, $user_id = false, $user_name = false) { global $current_user; if (empty($user_id)) { $type = ''; if ($token = gravity_flow()->decode_access_token()) { $assignee_key = sanitize_text_field($token['sub']); list($type, $user_id) = rgexplode('|', $assignee_key, 2); } elseif (is_user_logged_in()) { $user_id = $current_user->ID; $type = 'user_id'; } if ($type == 'user_id') { $user = get_user_by('id', $user_id); $user_name = $user ? $user->display_name : ''; } } if (empty($user_name)) { $user_name = 'gravityflow'; } GFFormsModel::add_note($this->get_entry_id(), $user_id, $user_name, $note, 'gravityflow'); }
/** * Used to determine the required validation result. * * @param int $form_id The ID of the form currently being processed. * * @return bool */ public function is_value_submission_empty($form_id) { $copy_values_option_activated = $this->enableCopyValuesOption && rgpost('input_' . $this->id . '_copy_values_activated'); if (is_array($this->inputs)) { foreach ($this->inputs as $input) { if ($copy_values_option_activated) { $input_id = $input['id']; $input_name = 'input_' . str_replace('.', '_', $input_id); $source_field_id = $this->copyValuesOptionField; $source_input_name = str_replace('input_' . $this->id, 'input_' . $source_field_id, $input_name); $value = rgpost($source_input_name); } else { $value = rgpost('input_' . str_replace('.', '_', $input['id'])); } if (is_array($value) && !empty($value)) { return false; } if (!is_array($value) && strlen(trim($value)) > 0) { return false; } } return true; } else { if ($copy_values_option_activated) { $value = rgpost('input_' . $this->copyValuesOptionField); } else { $value = rgpost('input_' . $this->id); } if (is_array($value)) { //empty if any of the inputs are empty (for inputs with the same name) foreach ($value as $input) { $input = GFCommon::trim_deep($input); if (GFCommon::safe_strlen($input) <= 0) { return true; } } return false; } elseif ($this->enablePrice) { list($label, $price) = rgexplode('|', $value, 2); $is_empty = strlen(trim($price)) <= 0; return $is_empty; } else { $is_empty = strlen(trim($value)) <= 0 || $this->type == 'post_category' && $value < 0; return $is_empty; } } }
public static function get_parameter_value($name, $field_values, $field) { $value = stripslashes(rgget($name)); if (empty($value)) { $value = rgget($name, $field_values); } //converting list format if (RGFormsModel::get_input_type($field) == 'list') { //transforms this: col1|col2,col1b|col2b into this: col1,col2,col1b,col2b $column_count = count($field->choices); $rows = explode(',', $value); $ary_rows = array(); if (!empty($rows)) { foreach ($rows as $row) { /** * Allow modification of the delimiter used to parse List field URL parameters. * * @since 2.0.0 * * @param string $delimiter Defaults to '|'; * @param array $field GF_Field object for the current field. * @param string $name Name of the current dynamic population parameter. * @param array $field_values Array of values provided for pre-population into the form. */ $delimiter = apply_filters('gform_list_field_parameter_delimiter', '|', $field, $name, $field_values); $ary_rows = array_merge($ary_rows, rgexplode($delimiter, $row, $column_count)); } $value = $ary_rows; } } return gf_apply_filters(array('gform_field_value', $name), $value, $field, $name); }
public static function date_display($value, $input_format = 'mdy', $output_format = false) { if (!$output_format) { $output_format = $input_format; } $date = self::parse_date($value, $input_format); if (empty($date)) { return $value; } list($position, $separator) = rgexplode('_', $output_format, 2); switch ($separator) { case 'dash': $separator = '-'; break; case 'dot': $separator = '.'; break; default: $separator = '/'; break; } switch ($position) { case 'year': case 'month': case 'day': return $date[$position]; case 'ymd': return $date['year'] . $separator . $date['month'] . $separator . $date['day']; break; case 'dmy': return $date['day'] . $separator . $date['month'] . $separator . $date['year']; break; default: return $date['month'] . $separator . $date['day'] . $separator . $date['year']; break; } }
function maybe_process_admin_action($form, $entry) { $feedback = false; if (isset($_POST['_gravityflow_admin_action']) && check_admin_referer('gravityflow_admin_action', '_gravityflow_admin_action_nonce') && GFAPI::current_user_can_any('gravityflow_workflow_detail_admin_actions')) { $admin_action = rgpost('gravityflow_admin_action'); switch ($admin_action) { case 'cancel_workflow': $api = new Gravity_Flow_API($form['id']); $success = $api->cancel_workflow($entry); if ($success) { $this->log_debug(__METHOD__ . '() - workflow cancelled. entry id ' . $entry['id']); $feedback = esc_html__('Workflow cancelled.', 'gravityflow'); } else { $this->log_debug(__METHOD__ . '() - workflow cancel failed. entry id ' . $entry['id']); $feedback = esc_html__('The entry does not currently have an active step.', 'gravityflow'); } break; case 'restart_step': $api = new Gravity_Flow_API($form['id']); $success = $api->restart_step($entry); if ($success) { $this->log_debug(__METHOD__ . '() - step restarted. entry id ' . $entry['id']); $feedback = esc_html__('Workflow Step restarted.', 'gravityflow'); } else { $this->log_debug(__METHOD__ . '() - step restart failed. entry id ' . $entry['id']); $feedback = esc_html__('The entry does not currently have an active step.', 'gravityflow'); } break; case 'restart_workflow': $api = new Gravity_Flow_API($form['id']); $api->restart_workflow($entry); $this->log_debug(__METHOD__ . '() - workflow restarted. entry id ' . $entry['id']); $feedback = esc_html__('Workflow restarted.', 'gravityflow'); break; } list($admin_action, $action_id) = rgexplode('|', $admin_action, 2); if ($admin_action == 'send_to_step') { $step_id = $action_id; $api = new Gravity_Flow_API($form['id']); $api->send_to_step($entry, $step_id); $new_step = $api->get_current_step($entry); $feedback = sprintf(esc_html__('Sent to step: %s', 'gravityflow'), $new_step->get_name()); } } return $feedback; }