當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GFEntryDetail::lead_detail_edit方法代碼示例

本文整理匯總了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" />';
//.........這裏部分代碼省略.........
開發者ID:healthcommcore,項目名稱:osnap,代碼行數:101,代碼來源:gravity-forms-addons.php


注:本文中的GFEntryDetail::lead_detail_edit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。