本文整理汇总了PHP中GFEntryDetail::lead_detail_edit方法的典型用法代码示例。如果您正苦于以下问题:PHP GFEntryDetail::lead_detail_edit方法的具体用法?PHP GFEntryDetail::lead_detail_edit怎么用?PHP GFEntryDetail::lead_detail_edit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFEntryDetail
的用法示例。
在下文中一共展示了GFEntryDetail::lead_detail_edit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_lead_detail
public static function edit_lead_detail($Form, $lead, $options)
{
global $current_user, $_gform_directory_approvedcolumn;
require_once GFCommon::get_base_path() . "/form_display.php";
if (empty($_gform_directory_approvedcolumn)) {
$_gform_directory_approvedcolumn = self::get_approved_column($Form);
}
// We fetch this again, since it may have had some admin-only columns taken out.
#$lead = RGFormsModel::get_lead($lead["id"]);
// If you want to allow users to edit their own approval (?) add a filter and return true.
if (apply_filters('kws_gf_directory_allow_user_edit_approved', false) === false) {
$Form['fields'] = self::remove_approved_column('form', $Form['fields'], $_gform_directory_approvedcolumn);
}
// If this is not the form that should be edited
list($urlformid, $urlleadid) = self::get_form_and_lead_ids();
if (intval($Form['id']) !== intval($urlformid) || intval($lead['id']) !== intval($urlleadid)) {
return;
}
// If either of these two things are false (creator of lead, or admin)
if (!((!empty($options['useredit']) && is_user_logged_in() && intval($current_user->ID) === intval($lead['created_by'])) === true || (!empty($options['adminedit']) && self::has_access("gravityforms_directory")) === true)) {
// Kick them out.
printf(esc_html_e('%sYou do not have permission to edit this form.%s', 'gravity-forms-addons'), '<div class="error">', '</div>');
return;
}
$validation_message = '';
// If the form is submitted
if (RGForms::post("action") === "update") {
check_admin_referer('gforms_save_entry', 'gforms_save_entry');
$lead = apply_filters('kws_gf_directory_lead_being_updated', $lead, $Form);
// We don't DO passwords.
foreach ($Form['fields'] as $key => $field) {
if ($field['type'] === 'password') {
unset($Form['fields'][$key]);
}
}
$is_valid = GFFormDisplay::validate($Form, $lead);
$validation_message = '';
foreach ($Form['fields'] as $field) {
if (!GFCommon::is_product_field($field["type"])) {
$validation_message .= rgget("failed_validation", $field) && !empty($field["validation_message"]) ? sprintf("<li class='gfield_description validation_message'><strong>%s</strong>: %s</li>", $field["label"], $field["validation_message"]) : "";
}
}
if (!empty($validation_message)) {
$validation_message = '<ul>' . $validation_message . '</ul>';
echo esc_html(apply_filters('kws_gf_directory_lead_error_message', sprintf(__("%sThere were errors with the edit you made.%s%s", 'gravity-forms-addons'), "<div class='error' id='message' style='padding:.5em .75em; background-color:#ffffcc; border:1px solid #ccc;'><p>", "</p>", $validation_message . '</div>'), $lead, $Form));
}
// So the form submission always throws an error even though there's no problem.
// Product fields can't be edited, so that doesn't really matter.
if (!empty($is_valid) || empty($is_valid) && empty($validation_message)) {
do_action('kws_gf_directory_pre_update_lead', $lead, $Form);
// since @3.6.1 to enable conditional fields' updates.
self::save_lead($Form, $lead);
$lead = RGFormsModel::get_lead($lead["id"]);
do_action('kws_gf_directory_post_update_lead', $lead, $Form);
echo apply_filters('kws_gf_directory_lead_updated_message', sprintf(esc_html__("%sThe entry was successfully updated.%s", 'gravity-forms-addons'), "<p class='updated' id='message' style='padding:.5em .75em; background-color:#ffffcc; border:1px solid #ccc;'>", "</p>"), $lead, $Form);
return $lead;
}
}
if (isset($_GET['edit']) && wp_verify_nonce($_GET['edit'], 'edit' . $lead['id'] . $Form["id"]) || !empty($validation_message)) {
// The ID of the form needs to be `gform_{form_id}` for the pluploader
?>
<form method="post" id="gform_<?php
echo esc_attr($Form['id']);
?>
" enctype="multipart/form-data" action="<?php
echo remove_query_arg(array('gf_search', 'sort', 'dir', 'pagenum', 'edit'), add_query_arg(array()));
?>
">
<?php
wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
?>
<input type="hidden" name="action" id="action" value="update"/>
<input type="hidden" name="screen_mode" id="screen_mode" value="edit" />
<?php
$form_without_products = $Form;
$post_message_shown = false;
$product_fields = array();
foreach ($Form['fields'] as $key => $field) {
if (GFCommon::is_product_field($field["type"]) || is_numeric($lead["post_id"]) && GFCommon::is_post_field($field)) {
if (is_numeric($lead["post_id"]) && GFCommon::is_post_field($field) && !$message_shown) {
echo apply_filters('kws_gf_directory_edit_post_details_text', sprintf(esc_html__('You can edit post details from the %1$spost page%2$s.', 'gravity-forms-addons'), '<a href="' . admin_url('post.php?action=edit&post=' . $lead["post_id"]) . '">', '</a>'), $field, $lead, $lead['post_id']);
$message_shown = true;
}
unset($form_without_products['fields'][$key]);
$product_fields[] = $field['id'];
if (!empty($field['inputs'])) {
foreach ($field['inputs'] as $input) {
$product_fields[] = $input['id'];
}
}
}
}
$lead_without_products =& $lead;
foreach ($product_fields as $product_field) {
$value = RGFormsModel::get_lead_field_value($lead, $field);
unset($lead_without_products[$product_field]);
}
require_once GFCommon::get_base_path() . "/entry_detail.php";
GFEntryDetail::lead_detail_edit(apply_filters('kws_gf_directory_form_being_edited', $form_without_products, $lead), apply_filters('kws_gf_directory_lead_being_edited', $lead_without_products, $form_without_products));
echo '<input class="button-primary" type="submit" tabindex="4" value="' . esc_attr(apply_filters('kws_gf_directory_update_lead_button_text', __('Update Entry', 'gravity-forms-addons'))) . '" name="save" />';
//.........这里部分代码省略.........