本文整理汇总了PHP中RGForms::post方法的典型用法代码示例。如果您正苦于以下问题:PHP RGForms::post方法的具体用法?PHP RGForms::post怎么用?PHP RGForms::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGForms
的用法示例。
在下文中一共展示了RGForms::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: leads_page
public static function leads_page($form_id)
{
global $wpdb;
//quit if version of wp is not supported
if (!GFCommon::ensure_wp_version()) {
return;
}
$form_id = absint($form_id);
echo GFCommon::get_remote_message();
$action = RGForms::post('action');
$filter = rgget('filter');
$search = stripslashes(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';
$form = RGFormsModel::get_form_meta($form_id);
$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 = stripslashes(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';
}
$filter_operator = empty($search_operator) ? 'is' : $search_operator;
$field = GFFormsModel::get_field($form, $key);
if ($field) {
$input_type = GFFormsModel::get_input_type($field);
if ($field->type == 'product' && in_array($input_type, array('radio', 'select'))) {
$filter_operator = 'contains';
}
}
$search_criteria['field_filters'][] = array('key' => $key, 'operator' => $filter_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 = esc_html__('Entry deleted.', 'gravityforms');
} else {
$update_message = esc_html__("You don't have adequate permission 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(esc_html__('%d entries', 'gravityforms'), count($leads)) : esc_html__('1 entry', 'gravityforms');
switch ($bulk_action) {
case 'delete':
if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
RGFormsModel::delete_leads($leads);
$update_message = sprintf(esc_html__('%s deleted.', 'gravityforms'), $entry_count);
} else {
$update_message = esc_html__("You don't have adequate permission to delete entries.", 'gravityforms');
}
break;
case 'trash':
RGFormsModel::update_leads_property($leads, 'status', 'trash');
$update_message = sprintf(esc_html__('%s moved to Trash.', 'gravityforms'), $entry_count);
break;
case 'restore':
RGFormsModel::update_leads_property($leads, 'status', 'active');
$update_message = sprintf(esc_html__('%s restored from the Trash.', 'gravityforms'), $entry_count);
break;
case 'unspam':
RGFormsModel::update_leads_property($leads, 'status', 'active');
$update_message = sprintf(esc_html__('%s restored from the spam.', 'gravityforms'), $entry_count);
break;
case 'spam':
RGFormsModel::update_leads_property($leads, 'status', 'spam');
$update_message = sprintf(esc_html__('%s marked as spam.', 'gravityforms'), $entry_count);
break;
case 'mark_read':
RGFormsModel::update_leads_property($leads, 'is_read', 1);
$update_message = sprintf(esc_html__('%s marked as read.', 'gravityforms'), $entry_count);
break;
case 'mark_unread':
RGFormsModel::update_leads_property($leads, 'is_read', 0);
$update_message = sprintf(esc_html__('%s marked as unread.', 'gravityforms'), $entry_count);
break;
//.........这里部分代码省略.........
示例2: get_form_parent_post_id
function get_form_parent_post_id($form)
{
foreach ($form['fields'] as $field) {
if ($field['type'] == 'select' && $field['setParentPost']) {
$parent_id = RGForms::post('input_' . $field['id']);
return $parent_id;
}
}
return 0;
}
示例3: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
if (is_array($value)) {
$value = array_values($value);
}
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$is_admin = $is_entry_detail || $is_form_editor;
$id = (int) $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$class_suffix = $is_entry_detail ? '_admin' : '';
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = $this->subLabelPlacement;
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : '';
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$first_tabindex = $this->get_tabindex();
$last_tabindex = $this->get_tabindex();
$strength_style = !$this->passwordStrengthEnabled ? "style='display:none;'" : '';
$strength_indicator_label = __('Strength indicator', 'gravityforms');
$strength = $this->passwordStrengthEnabled || $is_admin ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$strength_indicator_label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : '';
$action = !$is_admin ? "gformShowPasswordStrength(\"{$field_id}\");" : '';
$onchange = $this->passwordStrengthEnabled ? "onchange='{$action}'" : '';
$onkeyup = $this->passwordStrengthEnabled ? "onkeyup='{$action}'" : '';
$confirmation_value = RGForms::post('input_' . $id . '_2');
$password_value = is_array($value) ? $value[0] : $value;
$password_value = esc_attr($password_value);
$confirmation_value = esc_attr($confirmation_value);
$enter_password_field_input = GFFormsModel::get_input($this, $this->id . '');
$confirm_password_field_input = GFFormsModel::get_input($this, $this->id . '.2');
$enter_password_label = rgar($enter_password_field_input, 'customLabel') != '' ? $enter_password_field_input['customLabel'] : __('Enter Password', 'gravityforms');
$enter_password_label = apply_filters("gform_password_{$form_id}", apply_filters('gform_password', $enter_password_label, $form_id), $form_id);
$confirm_password_label = rgar($confirm_password_field_input, 'customLabel') != '' ? $confirm_password_field_input['customLabel'] : __('Confirm Password', 'gravityforms');
$confirm_password_label = apply_filters("gform_password_confirm_{$form_id}", apply_filters('gform_password_confirm', $confirm_password_label, $form_id), $form_id);
$enter_password_placeholder_attribute = GFCommon::get_input_placeholder_attribute($enter_password_field_input);
$confirm_password_placeholder_attribute = GFCommon::get_input_placeholder_attribute($confirm_password_field_input);
if ($is_sub_label_above) {
return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}_container'>\n\t\t\t\t\t<span id='{$field_id}_container' class='ginput_left'>\n\t\t\t\t\t\t<label for='{$field_id}' {$sub_label_class_attribute}>{$enter_password_label}</label>\n\t\t\t\t\t\t<input type='password' name='input_{$id}' id='{$field_id}' {$onkeyup} {$onchange} value='{$password_value}' {$first_tabindex} {$enter_password_placeholder_attribute} {$disabled_text}/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span id='{$field_id}_2_container' class='ginput_right'>\n\t\t\t\t\t\t<label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_password_label}</label>\n\t\t\t\t\t\t<input type='password' name='input_{$id}_2' id='{$field_id}_2' {$onkeyup} {$onchange} value='{$confirmation_value}' {$last_tabindex} {$confirm_password_placeholder_attribute} {$disabled_text}/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class='gf_clear gf_clear_complex'></div>\n\t\t\t\t</div>{$strength}";
} else {
return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}_container'>\n\t\t\t\t\t<span id='{$field_id}_container' class='ginput_left'>\n\t\t\t\t\t\t<input type='password' name='input_{$id}' id='{$field_id}' {$onkeyup} {$onchange} value='{$password_value}' {$first_tabindex} {$enter_password_placeholder_attribute} {$disabled_text}/>\n\t\t\t\t\t\t<label for='{$field_id}' {$sub_label_class_attribute}>{$enter_password_label}</label>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span id='{$field_id}_2_container' class='ginput_right'>\n\t\t\t\t\t\t<input type='password' name='input_{$id}_2' id='{$field_id}_2' {$onkeyup} {$onchange} value='{$confirmation_value}' {$last_tabindex} {$confirm_password_placeholder_attribute} {$disabled_text}/>\n\t\t\t\t\t\t<label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_password_label}</label>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class='gf_clear gf_clear_complex'></div>\n\t\t\t\t</div>{$strength}";
}
}
示例4: process_bulk_update
public static function process_bulk_update()
{
global $process_bulk_update_message;
if (RGForms::post("action") === '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");
$bulk_action = explode('-', $bulk_action);
if (!isset($bulk_action[1]) || empty($leads)) {
return false;
}
switch ($bulk_action[0]) {
case "approve":
self::directory_update_bulk($leads, 1, $bulk_action[1]);
$process_bulk_update_message = sprintf(__("%s approved.", "gravity-forms-addons"), $entry_count);
break;
case "unapprove":
self::directory_update_bulk($leads, 0, $bulk_action[1]);
$process_bulk_update_message = sprintf(__("%s disapproved.", "gravity-forms-addons"), $entry_count);
break;
}
}
}
示例5: process_bulk_action
/**
* Capture bulk actions - gf_entries table
*
* @uses GravityView_frontend::get_search_criteria() Convert the $_POST search request into a properly formatted request.
* @access public
* @return void|boolean
*/
public function process_bulk_action()
{
if (!class_exists('RGForms')) {
return;
}
if ('bulk' === RGForms::post('action')) {
check_admin_referer('gforms_entry_list', 'gforms_entry_list');
// The action is formatted like: approve-16 or disapprove-16, where the first word is the name of the action and the second is the ID of the form. Bulk action 2 is the bottom bulk action select form.
$bulk_action = !empty($_POST['bulk_action']) ? $_POST['bulk_action'] : $_POST['bulk_action2'];
/**
* The extra '-' is to make sure that there are at *least* two items in array.
* @see https://github.com/katzwebservices/GravityView/issues/370
*/
$bulk_action .= '-';
list($approved_status, $form_id) = explode('-', $bulk_action);
if (empty($form_id)) {
do_action('gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action);
return false;
}
// All entries are set to be updated, not just the visible ones
if (!empty($_POST['all_entries'])) {
// Convert the current entry search into GF-formatted search criteria
$search = array('search_field' => isset($_POST['f']) ? $_POST['f'][0] : 0, 'search_value' => isset($_POST['v'][0]) ? $_POST['v'][0] : '', 'search_operator' => isset($_POST['o'][0]) ? $_POST['o'][0] : 'contains');
$search_criteria = GravityView_frontend::get_search_criteria($search, $form_id);
// Get all the entry IDs for the form
$entries = gravityview_get_entry_ids($form_id, $search_criteria);
} else {
$entries = $_POST['lead'];
}
if (empty($entries)) {
do_action('gravityview_log_error', '[process_bulk_action] Entries are empty');
return false;
}
$entry_count = count($entries) > 1 ? sprintf(__('%d entries', 'gravityview'), count($entries)) : __('1 entry', 'gravityview');
switch ($approved_status) {
case 'approve':
self::update_bulk($entries, 1, $form_id);
$this->bulk_update_message = sprintf(__('%s approved.', 'gravityview'), $entry_count);
break;
case 'unapprove':
self::update_bulk($entries, 0, $form_id);
$this->bulk_update_message = sprintf(__('%s disapproved.', 'gravityview'), $entry_count);
break;
}
}
}
示例6: validate
/**
* Process validation for a edit entry submission
*
* Sets the `is_valid` object var
*
* @return void
*/
function validate()
{
// If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry
if (class_exists('GFUser')) {
remove_filter('gform_validation', array('GFUser', 'user_registration_validation'));
}
/**
* For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.
* You can enter whatever you want!
* We try validating, and customize the results using `self::custom_validation()`
*/
add_filter('gform_validation_' . $this->form_id, array($this, 'custom_validation'), 10, 4);
// Needed by the validate funtion
$failed_validation_page = NULL;
$field_values = RGForms::post('gform_field_values');
// Prevent entry limit from running when editing an entry, also
// prevent form scheduling from preventing editing
unset($this->form['limitEntries'], $this->form['scheduleForm']);
// Hide fields depending on Edit Entry settings
$this->form['fields'] = $this->get_configured_edit_fields($this->form, $this->view_id);
$this->is_valid = GFFormDisplay::validate($this->form, $field_values, 1, $failed_validation_page);
remove_filter('gform_validation_' . $this->form_id, array($this, 'custom_validation'), 10);
}
示例7: initialise_form_edit
public static function initialise_form_edit()
{
/*
* If we aren't editing our form, don't do anything
*/
if (empty($_GET['action']) || empty($_GET['lid']) || !is_user_logged_in()) {
return false;
}
$lid = isset($_GET['lid']) ? (int) $_GET['lid'] : 0;
self::$lead = $lead = GFAPI::get_entry($lid);
self::$form = $form = GFAPI::get_form(self::$lead['form_id']);
if (!self::check_user_permission(self::$lead)) {
return false;
}
self::$allowed_edit = true;
if (!class_exists('GFFormDisplay')) {
require_once GFCommon::get_base_path() . "/form_display.php";
}
$field_values = RGForms::post("gform_field_values");
/*
* Include appropriate css/javascript here...
*/
GFFormDisplay::enqueue_form_scripts($form, false);
GFFormDisplay::add_init_script($form["id"], "conditional_logic", GFFormDisplay::ON_PAGE_RENDER, self::get_conditional_logic($form, $field_values));
GFFormDisplay::add_init_script($form["id"], "pricing", GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_pricing_init_script($form));
$chosen_script = GFFormDisplay::get_chosen_init_script($form);
GFFormDisplay::add_init_script($form["id"], "chosen", GFFormDisplay::ON_PAGE_RENDER, $chosen_script);
GFFormDisplay::add_init_script($form["id"], "chosen", GFFormDisplay::ON_CONDITIONAL_LOGIC, $chosen_script);
GFFormDisplay::add_init_script($form['id'], 'input_mask', GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_input_mask_init_script($form));
GFFormDisplay::add_init_script($form['id'], 'calculation', GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_calculations_init_script($form));
GFFormDisplay::add_init_script($form['id'], 'currency_format', GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_currency_format_init_script($form));
return true;
}
示例8: lead_detail_page
public static function lead_detail_page()
{
global $wpdb;
global $current_user;
if (!GFCommon::ensure_wp_version()) {
return;
}
echo GFCommon::get_remote_message();
$form = RGFormsModel::get_form_meta($_GET["id"]);
$lead = RGFormsModel::get_lead($_GET["lid"]);
if (!$lead) {
_e("OOps! We couldn't find your lead. Please try again", "gravityforms");
return;
}
RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
$search_qs = empty($_GET["s"]) ? "" : "&s=" . $_GET["s"];
$sort_qs = empty($_GET["sort"]) ? "" : "&sort=" . $_GET["sort"];
$dir_qs = empty($_GET["dir"]) ? "" : "&dir=" . $_GET["dir"];
$page_qs = empty($_GET["paged"]) ? "" : "&paged=" . absint($_GET["paged"]);
switch (RGForms::post("action")) {
case "update":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::save_lead($form, $lead);
$lead = RGFormsModel::get_lead($_GET["lid"]);
break;
case "add_note":
check_admin_referer('gforms_update_note', 'gforms_update_note');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
//emailing notes if configured
if (rgpost("gentry_email_notes_to")) {
$email_to = $_POST["gentry_email_notes_to"];
$email_from = $current_user->user_email;
$email_subject = stripslashes($_POST["gentry_email_subject"]);
$headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
$result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
}
break;
case "add_quick_note":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["quick_note"]));
break;
case "bulk":
check_admin_referer('gforms_update_note', 'gforms_update_note');
if ($_POST["bulk_action"] == "delete") {
RGFormsModel::delete_notes($_POST["note"]);
}
break;
case "delete":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::delete_lead($lead["id"]);
?>
<div id="message" class="updated fade" style="background-color: rgb(255, 251, 204); margin-top:50px; padding:50px;">
<?php
_e("Entry has been deleted.", "gravityforms");
?>
<a href="<?php
echo esc_url("admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]) . $search_qs . $sort_qs . $dir_qs . $page_qs);
?>
"><?php
_e("Back to entries list", "gravityforms");
?>
</a>
</div>
<?php
exit;
break;
}
$mode = empty($_POST["screen_mode"]) ? "view" : $_POST["screen_mode"];
?>
<link rel="stylesheet" href="<?php
echo GFCommon::get_base_url();
?>
/css/admin.css" />
<script type="text/javascript">
function DeleteFile(leadId, fieldId){
if(confirm(<?php
_e("'Would you like to delete this file? \\'Cancel\\' to stop. \\'OK\\' to delete'", "gravityforms");
?>
)){
var mysack = new sack("<?php
echo admin_url("admin-ajax.php");
?>
");
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar( "action", "rg_delete_file" );
mysack.setVar( "rg_delete_file", "<?php
echo wp_create_nonce("rg_delete_file");
?>
" );
mysack.setVar( "lead_id", leadId );
mysack.setVar( "field_id", fieldId );
mysack.encVar( "cookie", document.cookie, false );
mysack.onError = function() { alert('<?php
echo esc_js(__("Ajax error while deleting field.", "gravityforms"));
?>
//.........这里部分代码省略.........
示例9: lead_detail_page
public static function lead_detail_page()
{
global $wpdb;
global $current_user;
if (!GFCommon::ensure_wp_version()) {
return;
}
echo GFCommon::get_remote_message();
$form = RGFormsModel::get_form_meta($_GET["id"]);
$form_id = $form["id"];
$form = apply_filters("gform_admin_pre_render_" . $form["id"], apply_filters("gform_admin_pre_render", $form));
$lead_id = rgget('lid');
$filter = rgget("filter");
$status = in_array($filter, array("trash", "spam")) ? $filter : "active";
$position = rgget('pos') ? rgget('pos') : 0;
$sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
$sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
$sort_field_meta = RGFormsModel::get_field($form, $sort_field);
$is_numeric = $sort_field_meta["type"] == "number";
$star = $filter == "star" ? 1 : null;
$read = $filter == "unread" ? 0 : null;
$search_criteria["status"] = $status;
if ($star) {
$search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star);
}
if (!is_null($read)) {
$search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
}
$search_field_id = rgget("field_id");
if (isset($_GET["field_id"]) && $_GET["field_id"] !== '') {
$key = $search_field_id;
$val = rgget("s");
$strpos_row_key = strpos($search_field_id, "|");
if ($strpos_row_key !== false) {
//multi-row likert
$key_array = explode("|", $search_field_id);
$key = $key_array[0];
$val = $key_array[1] . ":" . $val;
}
$type = rgget("type");
if (empty($type)) {
$type = rgget("field_id") == "0" ? "global" : "field";
}
$search_criteria["field_filters"][] = array("key" => $key, "type" => $type, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
}
$paging = array('offset' => $position, 'page_size' => 1);
if (!empty($sort_field)) {
$sorting = array('key' => $_GET["sort"], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
} else {
$sorting = array();
}
$total_count = 0;
$leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
$prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
$next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
// unread filter requires special handling for pagination since entries are filter out of the query as they are read
if ($filter == 'unread') {
$next_pos = $position;
if ($next_pos + 1 == $total_count) {
$next_pos = false;
}
}
if (!$lead_id) {
$lead = !empty($leads) ? $leads[0] : false;
} else {
$lead = GFAPI::get_entry($lead_id);
}
if (!$lead) {
_e("Oops! We couldn't find your entry. Please try again", "gravityforms");
return;
}
RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
switch (RGForms::post("action")) {
case "update":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
//Loading files that have been uploaded to temp folder
$files = GFCommon::json_decode(stripslashes(RGForms::post("gform_uploaded_files")));
if (!is_array($files)) {
$files = array();
}
GFFormsModel::$uploaded_files[$form_id] = $files;
GFFormsModel::save_lead($form, $lead);
do_action("gform_after_update_entry", $form, $lead["id"]);
do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
$lead = RGFormsModel::get_lead($lead["id"]);
$lead = GFFormsModel::set_entry_meta($lead, $form);
break;
case "add_note":
check_admin_referer('gforms_update_note', 'gforms_update_note');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
//emailing notes if configured
if (rgpost("gentry_email_notes_to")) {
$email_to = $_POST["gentry_email_notes_to"];
$email_from = $current_user->user_email;
$email_subject = stripslashes($_POST["gentry_email_subject"]);
$headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
$result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
}
break;
//.........这里部分代码省略.........
示例10: get_form_unique_id
public static function get_form_unique_id($form_id)
{
if (RGForms::post("gform_submit") == $form_id) {
return RGForms::post("gform_unique_id");
} else {
return uniqid();
}
}
示例11: loadForm
/**
* load the form data we care about from the form array
* @param array $form
*/
private function loadForm(&$form)
{
foreach ($form['fields'] as &$field) {
$id = $field['id'];
switch (GFFormsModel::get_input_type($field)) {
case 'name':
// only pick up the first name field (assume later ones are additional info)
if (empty($this->firstName) && empty($this->lastName)) {
$this->namePrefix = trim(rgpost("input_{$id}_2"));
$this->firstName = trim(rgpost("input_{$id}_3"));
$this->lastName = trim(rgpost("input_{$id}_6"));
}
break;
case 'email':
// only pick up the first email address field (assume later ones are additional info)
if (empty($this->email)) {
$this->email = trim(rgpost("input_{$id}"));
}
break;
case 'phone':
// only pick up the first phone number field (assume later ones are additional info)
if (empty($this->phone)) {
$this->phone = trim(rgpost("input_{$id}"));
}
break;
case 'address':
// only pick up the first address field (assume later ones are additional info, e.g. shipping)
if (empty($this->address) && empty($this->postcode)) {
$parts = array(trim(rgpost("input_{$id}_1")), trim(rgpost("input_{$id}_2")));
$this->address_street = implode(', ', array_filter($parts, 'strlen'));
$this->address_suburb = trim(rgpost("input_{$id}_3"));
$this->address_state = trim(rgpost("input_{$id}_4"));
$this->address_country = trim(rgpost("input_{$id}_6"));
$this->postcode = trim(rgpost("input_{$id}_5"));
// aggregate street, city, state, country into a single string (for regular one-off payments)
$parts = array($this->address_street, $this->address_suburb, $this->address_state, $this->address_country);
$this->address = implode(', ', array_filter($parts, 'strlen'));
}
break;
case 'creditcard':
$this->isCcHiddenFlag = GFFormsModel::is_field_hidden($form, $field, RGForms::post('gform_field_values'));
$this->ccField =& $field;
$this->ccName = trim(rgpost("input_{$id}_5"));
$this->ccNumber = self::cleanCcNumber(trim(rgpost("input_{$id}_1")));
$ccExp = rgpost("input_{$id}_2");
if (is_array($ccExp)) {
list($this->ccExpMonth, $this->ccExpYear) = $ccExp;
}
$this->ccCVN = trim(rgpost("input_{$id}_3"));
break;
case 'total':
$this->total = GFCommon::to_number(rgpost("input_{$id}"));
$this->hasPurchaseFieldsFlag = true;
break;
case GFEWAY_FIELD_RECURRING:
// only pick it up if it isn't hidden
if (!GFFormsModel::is_field_hidden($form, $field, RGForms::post('gform_field_values'))) {
$this->recurring = GFEwayRecurringField::getPost($id);
}
break;
default:
// check for shipping field
if ($field['type'] == 'shipping') {
$this->shipping += self::getShipping($form, $field);
$this->hasPurchaseFieldsFlag = true;
} elseif (in_array($field['type'], array('option', 'donation', 'product', 'calculation'))) {
$this->amount += self::getProductPrice($form, $field);
$this->hasPurchaseFieldsFlag = true;
}
break;
}
}
// if form didn't pass the total, use sum of the product and shipping fields
if ($this->total === 0) {
$this->total = $this->amount + $this->shipping;
}
}
示例12: lead_detail_page
public static function lead_detail_page()
{
global $wpdb;
global $current_user;
if (!GFCommon::ensure_wp_version()) {
return;
}
echo GFCommon::get_remote_message();
$form = RGFormsModel::get_form_meta($_GET["id"]);
$lead_id = rgget('lid');
$filter = rgget("filter");
$status = in_array($filter, array("trash", "spam")) ? $filter : "active";
$search = rgget("s");
$position = rgget('pos') ? rgget('pos') : 0;
$sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
$sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
$sort_field_meta = RGFormsModel::get_field($form, $sort_field);
$is_numeric = $sort_field_meta["type"] == "number";
$star = $filter == "star" ? 1 : null;
$read = $filter == "unread" ? 0 : null;
// added status as an optional parameter to get_lead_count because the counts are inaccurate without using the status
$lead_count = RGFormsModel::get_lead_count($form['id'], $search, $star, $read, null, null, $status);
$prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
$next_pos = !rgblank($position) && $position < $lead_count - 1 ? $position + 1 : false;
// unread filter requires special handling for pagination since entries are filter out of the query as they are read
if ($filter == 'unread') {
$next_pos = $position;
if ($next_pos + 1 == $lead_count) {
$next_pos = false;
}
}
// get the lead
$leads = RGFormsModel::get_leads($form['id'], $sort_field, $sort_direction, $search, $position, 1, $star, $read, $is_numeric, null, null, $status);
if (!$lead_id) {
$lead = !empty($leads) ? $leads[0] : false;
} else {
$lead = RGFormsModel::get_lead($lead_id);
}
if (!$lead) {
_e("Oops! We couldn't find your lead. Please try again", "gravityforms");
return;
}
RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
switch (RGForms::post("action")) {
case "update":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::save_lead($form, $lead);
do_action("gform_after_update_entry", $form, $lead["id"]);
do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
$lead = RGFormsModel::get_lead($lead["id"]);
break;
case "add_note":
check_admin_referer('gforms_update_note', 'gforms_update_note');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
//emailing notes if configured
if (rgpost("gentry_email_notes_to")) {
$email_to = $_POST["gentry_email_notes_to"];
$email_from = $current_user->user_email;
$email_subject = stripslashes($_POST["gentry_email_subject"]);
$headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
$result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
}
break;
case "add_quick_note":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["quick_note"]));
break;
case "bulk":
check_admin_referer('gforms_update_note', 'gforms_update_note');
if ($_POST["bulk_action"] == "delete") {
RGFormsModel::delete_notes($_POST["note"]);
}
break;
case "trash":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::update_lead_property($lead["id"], "status", "trash");
$lead = RGFormsModel::get_lead($lead["id"]);
break;
case "restore":
case "unspam":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::update_lead_property($lead["id"], "status", "active");
$lead = RGFormsModel::get_lead($lead["id"]);
break;
case "spam":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::update_lead_property($lead["id"], "status", "spam");
$lead = RGFormsModel::get_lead($lead["id"]);
break;
case "delete":
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
RGFormsModel::delete_lead($lead["id"]);
?>
<script type="text/javascript">
document.location.href='<?php
echo "admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]);
?>
';
//.........这里部分代码省略.........
示例13: metarecovery_page
public static function metarecovery_page()
{
if (RGForms::post("gf_metarecovery_submit")) {
global $wpdb;
$table_name = RGFormsModel::get_meta_table_name();
$form_id = RGForms::post("gf_metarecovery_form_id");
$meta = $wpdb->get_var($wpdb->prepare("SELECT display_meta FROM {$table_name} WHERE form_id=%d", $form_id));
//fixing meta
$meta = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $meta);
//if successfull, store new meta
$obj = unserialize($meta);
if ($obj) {
RGFormsModel::update_form_meta($form_id, $obj);
$is_success = true;
} else {
$is_failure = true;
}
}
?>
<style>
.left_header{float:left; width:200px;}
.margin_vertical_10{margin: 10px 0;}
</style>
<div class="wrap">
<form method="post">
<h2><?php
_e("Meta Recovery Utility", "gravityformsmetarecovery");
?>
</h2>
<?php
if ($is_success) {
?>
<div class="updated fade" style="padding:6px"><?php
echo sprintf(__("Meta recovered successfully. %sGo to form editor%s", "gravityformsmetarecovery"), "<a href='?page=gf_edit_forms&id={$form_id}'>", "</a>");
?>
</div>
<?php
}
if ($is_failure) {
?>
<div class="error" style="padding:6px"><?php
echo __("This form's meta could not be recovered.", "gravityformsmetarecovery");
?>
</div>
<?php
}
?>
<div class="margin_vertical_10">
<label for="gf_metarecovery_form_id" class="left_header"><?php
_e("Gravity Form", "gravityforms_feed");
?>
</label>
<select name="gf_metarecovery_form_id" id="gf_metarecovery_form_id">
<option value=""><?php
_e("Select a form", "gravityforms_feed");
?>
</option>
<?php
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
?>
<option value="<?php
echo absint($form->id);
?>
"><?php
echo esc_html($form->title);
?>
</option>
<?php
}
?>
</select>
</div>
<div class="margin_vertical_10">
<input type="submit" class="button-primary" name="gf_metarecovery_submit" value="<?php
_e("Submit", "gravityformsmetarecovery");
?>
" />
</div>
</form>
</div>
<?php
}
示例14: leads_page
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");
switch ($action) {
case "delete":
check_admin_referer('gforms_entry_list', 'gforms_entry_list');
$lead_id = $_POST["action_argument"];
RGFormsModel::delete_lead($lead_id);
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"];
switch ($bulk_action) {
case "delete":
RGFormsModel::delete_leads($leads);
break;
case "mark_read":
RGFormsModel::update_leads_property($leads, "is_read", 1);
break;
case "mark_unread":
RGFormsModel::update_leads_property($leads, "is_read", 0);
break;
case "add_star":
RGFormsModel::update_leads_property($leads, "is_starred", 1);
break;
case "remove_star":
RGFormsModel::update_leads_property($leads, "is_starred", 0);
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;
}
$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 = is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null;
$read = 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";
$leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric);
$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"];
$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>
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");
//.........这里部分代码省略.........
示例15: lead_detail_page
public static function lead_detail_page()
{
global $current_user;
if (!GFCommon::ensure_wp_version()) {
return;
}
echo GFCommon::get_remote_message();
$requested_form_id = absint($_GET['id']);
if (empty($requested_form_id)) {
return;
}
$lead = self::get_current_entry();
if (is_wp_error($lead) || !$lead) {
esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
return;
}
$lead_id = $lead['id'];
$form = self::get_current_form();
$form_id = absint($form['id']);
$total_count = self::get_total_count();
$position = rgget('pos') ? rgget('pos') : 0;
$prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
$next_pos = !rgblank($position) && $position < self::$_total_count - 1 ? $position + 1 : false;
$filter = rgget('filter');
// unread filter requires special handling for pagination since entries are filter out of the query as they are read
if ($filter == 'unread') {
$next_pos = $position;
if ($next_pos + 1 == $total_count) {
$next_pos = false;
}
}
RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
switch (RGForms::post('action')) {
case 'update':
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
//Loading files that have been uploaded to temp folder
$files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
if (!is_array($files)) {
$files = array();
}
$original_entry = $lead;
GFFormsModel::$uploaded_files[$form_id] = $files;
GFFormsModel::save_lead($form, $lead);
/**
* Fires after the Entry is updated from the entry detail page.
*
* @param array $form The form object for the entry.
* @param integer $lead['id'] The entry ID.
* @param array $original_entry The entry object before being updated.
*/
gf_do_action(array('gform_after_update_entry', $form['id']), $form, $lead['id'], $original_entry);
$lead = RGFormsModel::get_lead($lead['id']);
$lead = GFFormsModel::set_entry_meta($lead, $form);
self::set_current_entry($lead);
break;
case 'add_note':
check_admin_referer('gforms_update_note', 'gforms_update_note');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
//emailing notes if configured
if (rgpost('gentry_email_notes_to')) {
GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
$email_to = $_POST['gentry_email_notes_to'];
$email_from = $current_user->user_email;
$email_subject = stripslashes($_POST['gentry_email_subject']);
$body = stripslashes($_POST['new_note']);
$headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
$is_success = wp_mail($email_to, $email_subject, $body, $headers);
$result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
if (!is_wp_error($is_success) && $is_success) {
GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
} else {
GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
}
if (has_filter('phpmailer_init')) {
GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
}
/**
* Fires after a note is attached to an entry and sent as an email
*
* @param string $result The Error message or success message when the entry note is sent
* @param string $email_to The email address to send the entry note to
* @param string $email_from The email address from which the email is sent from
* @param string $email_subject The subject of the email that is sent
* @param mixed $body The Full body of the email containing the message after the note is sent
* @param array $form The current form object
* @param array $lead The Current lead object
*/
do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
}
break;
case 'add_quick_note':
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
$user_data = get_userdata($current_user->ID);
RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
break;
case 'bulk':
check_admin_referer('gforms_update_note', 'gforms_update_note');
//.........这里部分代码省略.........