Exemplo n.º 1
1
function pre_submission_handler($form)
{
    if ($_SERVER["REDIRECT_URL"] == "/edit-page/") {
        //submitted new values that need to be used to update the original entry via $success = GFAPI::update_entry( $entry );
        //var_dump($_POST);
        //Get original entry id
        parse_str($_SERVER["QUERY_STRING"]);
        //will be stored in $entry
        //get the actual entry we want to edit
        $editentry = GFAPI::get_entry($entry);
        //make changes to it from new values in $_POST, this shows only the first field update
        $editentry[1] = $_POST["input_1"];
        //update it
        $updateit = GFAPI::update_entry($editentry);
        if (is_wp_error($updateit)) {
            echo "Error.";
        } else {
            //success, so redirect
            header("Location: http://domain.com/confirmation/");
        }
        //dont process and create new entry
        die;
    } else {
        //any other code you want in this hook for regular entry submit
    }
}
 /**
  * Update the post categories based on all post category fields
  *
  * @since 1.17
  *
  * @param array $form Gravity Forms form array
  * @param int $entry_id Numeric ID of the entry that was updated
  *
  * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
  */
 public function set_post_categories($form = array(), $entry_id = 0)
 {
     $entry = GFAPI::get_entry($entry_id);
     $post_id = rgar($entry, 'post_id');
     if (empty($post_id)) {
         return false;
     }
     $return = false;
     $post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
     if ($post_category_fields) {
         $updated_categories = array();
         foreach ($post_category_fields as $field) {
             // Get the value of the field, including $_POSTed value
             $field_cats = RGFormsModel::get_field_value($field);
             $field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
             $field_cats = gv_map_deep($field_cats, 'intval');
             $updated_categories = array_merge($updated_categories, array_values($field_cats));
         }
         // Remove `0` values from intval()
         $updated_categories = array_filter($updated_categories);
         /**
          * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
          * @since 1.17
          * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
          */
         $append = apply_filters('gravityview/edit_entry/post_categories/append', false);
         $return = wp_set_post_categories($post_id, $updated_categories, $append);
     }
     return $return;
 }
 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;
 }
Exemplo n.º 4
0
 /**
  * Processes a status update for a specified assignee of the current step of the specified entry.
  *
  * @param $entry_id
  * @param string $assignee_key
  */
 function post_entries_assignees($entry_id, $assignee_key = null)
 {
     global $HTTP_RAW_POST_DATA;
     $capability = apply_filters('gravityflow_web_api_capability_post_entries_assignees', 'gravityflow_create_steps');
     $this->authorize($capability);
     if (empty($assignee_key)) {
         $this->end(400, 'Bad request');
     }
     $entry = GFAPI::get_entry($entry_id);
     if (empty($entry)) {
         $this->end(404, 'Entry not found');
     }
     $form_id = absint($entry['form_id']);
     $api = new Gravity_Flow_API($form_id);
     $step = $api->get_current_step($entry);
     $assignee = new Gravity_Flow_Assignee($assignee_key, $step);
     if (!isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = file_get_contents('php://input');
     }
     $data = json_decode($HTTP_RAW_POST_DATA, true);
     $new_status = $data['status'];
     $form = GFAPI::get_form($form_id);
     $step->process_assignee_status($assignee, $new_status, $form);
     $api->process_workflow($entry_id);
     $response = 'Status updated successfully';
     $this->end(200, $response);
 }
 /**
  * Update the WordPress user profile based on the GF User Registration create feed
  *
  * @since 1.11
  *
  * @param array $form Gravity Forms form array
  * @param string $entry_id Gravity Forms entry ID
  * @return void
  */
 public function update_user($form = array(), $entry_id = 0)
 {
     if (!class_exists('GFAPI') || !class_exists('GFUser') || empty($entry_id)) {
         return;
     }
     $entry = GFAPI::get_entry($entry_id);
     /**
      * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
      * @since 1.11
      * @param array $entry Gravity Forms entry
      * @param array $form Gravity Forms form
      */
     $entry = apply_filters('gravityview/edit_entry/user_registration/entry', $entry, $form);
     /**
      * @since 1.14
      */
     $config = GFUser::get_active_config($form, $entry);
     /**
      * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
      * @since 1.14
      * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
      * @param[in] array $form Gravity Forms form array
      * @param[in] array $entry Gravity Forms entry being edited
      */
     $config = apply_filters('gravityview/edit_entry/user_registration/config', $config, $form, $entry);
     $this->_user_before_update = get_userdata($entry['created_by']);
     // The priority is set to 3 so that default priority (10) will still override it
     add_filter('send_password_change_email', '__return_false', 3);
     add_filter('send_email_change_email', '__return_false', 3);
     // Trigger the User Registration update user method
     GFUser::update_user($entry, $form, $config);
     remove_filter('send_password_change_email', '__return_false', 3);
     remove_filter('send_email_change_email', '__return_false', 3);
 }
 /**
  * Update the WordPress user profile based on the GF User Registration create feed
  *
  * @since 1.11
  *
  * @param array $form Gravity Forms form array
  * @param string $entry_id Gravity Forms entry ID
  * @return void
  */
 public function update_user($form = array(), $entry_id = 0)
 {
     if (!class_exists('GFAPI') || !class_exists('GFUser') || empty($entry_id)) {
         return;
     }
     $entry = GFAPI::get_entry($entry_id);
     /**
      * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
      * @since 1.11
      * @param array $entry Gravity Forms entry
      * @param array $form Gravity Forms form
      */
     $entry = apply_filters('gravityview/edit_entry/user_registration/entry', $entry, $form);
     /**
      * @since 1.14
      */
     $config = GFUser::get_active_config($form, $entry);
     /**
      * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
      * @since 1.15
      * @param[in,out] boolean $preserve_role Preserve current user role Default: true
      * @param[in] array $config Gravity Forms User Registration feed configuration for the form
      * @param[in] array $form Gravity Forms form array
      * @param[in] array $entry Gravity Forms entry being edited
      */
     $preserve_role = apply_filters('gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry);
     if ($preserve_role) {
         $config['meta']['role'] = 'gfur_preserve_role';
     }
     /**
      * Make sure the current display name is not changed with the update user method.
      * @since 1.15
      */
     $config['meta']['displayname'] = $this->match_current_display_name($entry['created_by']);
     /**
      * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
      * @since 1.14
      * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
      * @param[in] array $form Gravity Forms form array
      * @param[in] array $entry Gravity Forms entry being edited
      */
     $config = apply_filters('gravityview/edit_entry/user_registration/config', $config, $form, $entry);
     $is_create_feed = $config && rgars($config, 'meta/feed_type') === 'create';
     // Only update if it's a create feed
     if (!$is_create_feed) {
         return;
     }
     // The priority is set to 3 so that default priority (10) will still override it
     add_filter('send_password_change_email', '__return_false', 3);
     add_filter('send_email_change_email', '__return_false', 3);
     // Trigger the User Registration update user method
     GFUser::update_user($entry, $form, $config);
     remove_filter('send_password_change_email', '__return_false', 3);
     remove_filter('send_email_change_email', '__return_false', 3);
 }
Exemplo n.º 7
0
 /**
  * Force refreshing a cache when an entry is deleted.
  *
  * The `gform_delete_lead` action is called before the lead is deleted; we fetch the entry to find out the form ID so it can be added to the blacklist.
  *
  * @since  1.5.1
  *
  * @param  int $lead_id Entry ID
  * @param  string $property_value Previous value of the lead status passed by gform_update_status hook
  * @param  string $previous_value Previous value of the lead status passed by gform_update_status hook
  *
  * @return void
  */
 public function entry_status_changed($lead_id, $property_value = '', $previous_value = '')
 {
     /** @var array $entry */
     $entry = GFAPI::get_entry($lead_id);
     if (is_wp_error($entry)) {
         /** @var WP_Error $entry */
         do_action('gravityview_log_error', __METHOD__ . ' Could not retrieve entry ' . $lead_id . ' to delete it: ' . $entry->get_error_message());
         return;
     }
     do_action('gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array('value' => $property_value, 'previous' => $previous_value));
     $this->blacklist_add($entry['form_id']);
 }
 /**
  * The Signature Addon only displays the output in the editable form if it thinks it's in the Admin or a form has been submitted
  *
  * @since 1.17
  *
  * @param string $field_content Always empty. Returning not-empty overrides the input.
  * @param GF_Field $field
  * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
  * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
  * @param int $form_id Form ID
  *
  * @return string Empty string forces Gravity Forms to use the $_POST values
  */
 function edit_entry_field_input($field_content = '', $field, $value = '', $lead_id = 0, $form_id = 0)
 {
     $context = function_exists('gravityview_get_context') ? gravityview_get_context() : '';
     if ('signature' !== $field->type || 'edit' !== $context) {
         return $field_content;
     }
     // We need to fetch a fresh version of the entry, since the saved entry hasn't refreshed in GV yet.
     $entry = GravityView_View::getInstance()->getCurrentEntry();
     $entry = GFAPI::get_entry($entry['id']);
     $entry_value = rgar($entry, $field->id);
     $_POST["input_{$field->id}"] = $entry_value;
     // Used when Edit Entry form *is* submitted
     $_POST["input_{$form_id}_{$field->id}_signature_filename"] = $entry_value;
     // Used when Edit Entry form *is not* submitted
     return '';
     // Return empty string to force using $_POST values instead
 }
 /**
  *
  * Update the WordPress user profile based on the GF User Registration create feed
  *
  * @since 1.11
  *
  * @param array $form Gravity Forms form array
  * @param string $entry_id Gravity Forms entry ID
  */
 public function update_user($form = array(), $entry_id = 0)
 {
     if (!class_exists('GFAPI') || !class_exists('GFUser') || empty($entry_id)) {
         return;
     }
     $entry = GFAPI::get_entry($entry_id);
     /**
      * Modify the entry details before updating the user
      *
      * @since 1.11
      * @param array $entry GF entry
      * @param array $form GF form
      */
     $entry = apply_filters('gravityview/edit_entry/user_registration/entry', $entry, $form);
     // Trigger the User Registration update user method
     GFUser::update_user($entry, $form);
 }
Exemplo n.º 10
0
 /**
  * Save function stores class data as Wordpress meta data
  * @return boolean true on success and false on failure
  *
  */
 public function save()
 {
     throw new NotImplementedException();
     if (!defined('WPINC') || !$this->_post_id || !class_exists('GFAPI')) {
         return false;
     }
     $lead = GFAPI::get_entry($this->_post_id);
     $form = GFAPI::get_form($lead['form_id']);
     $values = array();
     foreach ($form['fields'] as $field) {
         $key = $field['adminLabel'] ? $field['adminLabel'] : strtolower($field['label']);
         $value = $lead[$field['id']];
         $values[$key] = $value;
     }
     $success = GFAPI::update_entry($this->_data, $this->_post_id);
     return $success;
 }
Exemplo n.º 11
0
 public function load()
 {
     // you only need this if creating custom posts form the form
     // Get this post to also load in related gravity form data
     if (parent::load()) {
         $config_meta = self::CONFIG_META;
         $config = get_post_meta($this->_post_id, $config_meta, true);
         $this->config($config);
         if (!is_numeric($this->lead_id)) {
             $this->lead_id = get_post_custom_values('lead_id');
         }
         $lead = \GFAPI::get_entry($this->lead_id);
         if (is_wp_error($lead)) {
             return false;
         }
         $this->load_form_data($lead, $lead['form_id']);
     }
 }
Exemplo n.º 12
0
 public static function gravityforms_send_entry_to_jdb($id)
 {
     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     if ($mysqli->connect_errno) {
         echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
     }
     error_log('gravityforms_send_entry_to_jdb');
     $entry_id = $id;
     $entry = GFAPI::get_entry($entry_id);
     $form = GFAPI::get_form($entry['form_id']);
     //$jdb_encoded_entry = gravityforms_to_jdb_record($entry,$row[0],$row[1]);
     $jdb_encoded_entry = http_build_query(self::gravityforms_to_jdb_record($entry, $entry_id, $form));
     $synccontents = '"' . $mysqli->real_escape_string($jdb_encoded_entry) . '"';
     $results_on_send = self::gravityforms_send_record_to_jdb($entry_id, $jdb_encoded_entry);
     $results_on_send_prepared = '"' . $mysqli->real_escape_string($results_on_send) . '"';
     // MySqli Insert Query
     $insert_row = $mysqli->query("INSERT INTO `wp_rg_lead_jdb_sync`(`lead_id`, `synccontents`, `jdb_response`) VALUES ({$entry_id},{$synccontents}, {$results_on_send_prepared})");
     if ($insert_row) {
         error_log('Success! Response from JDB  was: ' . $results_on_send . '<br />');
     } else {
         die('Error : (' . $mysqli->errno . ') ' . $mysqli->error);
     }
 }
Exemplo n.º 13
0
    public static function get_lead_row($lid, $atts, $fields)
    {
        ob_start();
        /*
         * Get our lead information 
         */
        $lead = GFAPI::get_entry($lid);
        /*
         * Update the created by date 
         */
        $lead['date_created_usa'] = date('m/d/Y', strtotime($lead['date_created']));
        $lead['date_created'] = date('d/m/Y', strtotime($lead['date_created']));
        /*
         * Loop through the columns 
         */
        foreach ($atts['columns'] as $cid) {
            ?>
                <td class="gfpdfe_<?php 
            echo $cid;
            ?>
">
                <?php 
            if (is_numeric($cid)) {
                $value = RGFormsModel::get_lead_field_value($lead, $fields[$cid]);
                echo GFPDFEntryDetail::pdf_get_lead_field_display($fields[$cid], $value, $lead['currency']);
            } else {
                echo array_key_exists($cid, $lead) ? $lead[$cid] : '';
            }
            ?>
                </td>
            <?php 
        }
        $html = ob_get_contents();
        ob_end_flush();
        return $html;
    }
Exemplo n.º 14
0
 /**
  * Return a single entry object
  *
  * Since 1.4, supports custom entry slugs. The way that GravityView fetches an entry based on the custom slug is by searching `gravityview_unique_id` meta. The `$entry_slug` is fetched by getting the current query var set by `is_single_entry()`
  *
  * @access public
  * @param mixed $entry_id
  * @param boolean $force_allow_ids Force the get_entry() method to allow passed entry IDs, even if the `gravityview_custom_entry_slug_allow_id` filter returns false.
  * @return object or false
  */
 public static function get_entry($entry_slug, $force_allow_ids = false)
 {
     if (class_exists('GFAPI') && !empty($entry_slug)) {
         /**
          * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
          * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
          */
         $custom_slug = apply_filters('gravityview_custom_entry_slug', false);
         /**
          * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID).
          * - If disabled (default), only allow access to an entry using the custom slug value.  (example: `/entry/custom-slug/` NOT `/entry/123/`)
          * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`)
          * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method.
          */
         $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false);
         /**
          * If we're using custom entry slugs, we do a meta value search
          * instead of doing a straightup ID search.
          */
         if ($custom_slug) {
             $entry_id = self::get_entry_id_from_slug($entry_slug);
         }
         // If custom slug is off, search using the entry ID
         // ID allow ID access is on, also use entry ID as a backup
         if (empty($custom_slug) || !empty($custom_slug_id_access)) {
             // Search for IDs matching $entry_slug
             $entry_id = $entry_slug;
         }
         if (empty($entry_id)) {
             return false;
         }
         // fetch the entry
         $entry = GFAPI::get_entry($entry_id);
         // Is the entry allowed
         $entry = self::check_entry_display($entry);
         return $entry;
     }
     return false;
 }
Exemplo n.º 15
0
 public function ajax_cancel_subscription()
 {
     check_ajax_referer('gaddon_cancel_subscription', 'gaddon_cancel_subscription');
     $entry_id = $_POST['entry_id'];
     $entry = GFAPI::get_entry($entry_id);
     $form = GFAPI::get_form($entry['form_id']);
     $feed = $this->get_payment_feed($entry, $form);
     if ($this->cancel($entry, $feed)) {
         $this->cancel_subscription($entry, $feed);
         die('1');
     } else {
         die('0');
     }
 }
Exemplo n.º 16
0
 /**
  * Updates the entry status
  *
  * Called via AJAX
  * Passes data off to either RGFormsModel::update_lead_property or RGFormsModel::delete_lead
  *
  * @access public
  * @static
  * @see RGFormsModel::update_lead_property
  * @see RGFormsModel::delete_lead
  */
 public static function update_lead_status()
 {
     check_ajax_referer('gf_delete_entry');
     $status = rgpost('status');
     $lead_id = rgpost('entry');
     $entry = GFAPI::get_entry($lead_id);
     $form = GFAPI::get_form($entry['form_id']);
     switch ($status) {
         case 'unspam':
             RGFormsModel::update_lead_property($lead_id, 'status', 'active');
             break;
         case 'delete':
             if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                 RGFormsModel::delete_lead($lead_id);
             }
             break;
         default:
             RGFormsModel::update_lead_property($lead_id, 'status', $status);
             break;
     }
     require_once 'entry_list.php';
     $filter_links = GFEntryList::get_filter_links($form);
     $counts = array();
     foreach ($filter_links as $filter_link) {
         $id = $filter_link['id'] == '' ? 'all' : $filter_link['id'];
         $counts[$id . '_count'] = $filter_link['count'];
     }
     $x = new WP_Ajax_Response();
     $x->add(array('what' => 'gf_entry', 'id' => $lead_id, 'supplemental' => $counts));
     $x->send();
 }
Exemplo n.º 17
0
 /**
  * Update the is_approved meta whenever the entry is updated
  *
  * @since 1.7.6.1 Was previously named `update_approved_meta`
  *
  * @param  array $form     Gravity Forms form array
  * @param  int $entry_id ID of the Gravity Forms entry
  * @return void
  */
 public static function after_update_entry_update_approved_meta($form, $entry_id = NULL)
 {
     $approvedcolumn = self::get_approved_column($form['id']);
     /**
      * If the form doesn't contain the approve field, don't assume anything.
      */
     if (empty($approvedcolumn)) {
         return;
     }
     $entry = GFAPI::get_entry($entry_id);
     self::update_approved_meta($entry_id, $entry[(string) $approvedcolumn]);
 }
Exemplo n.º 18
0
 public function start_cancel_subscription()
 {
     check_ajax_referer("gaddon_cancel_subscription", "gaddon_cancel_subscription");
     $entry_id = $_POST["entry_id"];
     $entry = GFAPI::get_entry($entry_id);
     $form = GFAPI::get_form($entry["form_id"]);
     $feed = $this->get_payment_feed($entry, $form);
     if ($this->cancel_subscription($entry, $feed)) {
         die('1');
     } else {
         die('0');
     }
 }
Exemplo n.º 19
0
 public function get_entries($entry_ids, $form_ids = null, $schema = '', $field_ids = array())
 {
     $this->log_debug(__METHOD__ . '(): Running.');
     $capability = apply_filters('gform_web_api_capability_get_entries', 'gravityforms_view_entries');
     $this->authorize($capability);
     $status = 200;
     $response = array();
     $result = array();
     if ($entry_ids) {
         if (is_array($entry_ids)) {
             foreach ($entry_ids as $entry_id) {
                 $result = GFAPI::get_entry($entry_id);
                 if (!is_wp_error($result)) {
                     $result = $this->maybe_json_encode_list_fields($result);
                     $response[$entry_id] = $result;
                     if (!empty($field_ids) && !empty($response[$entry_id])) {
                         $response[$entry_id] = $this->filter_entry_object($response[$entry_id], $field_ids);
                     }
                 }
             }
         } else {
             $result = GFAPI::get_entry($entry_ids);
             if (!is_wp_error($result)) {
                 $result = $this->maybe_json_encode_list_fields($result);
                 $response = $result;
                 if (!empty($field_ids) && !empty($response)) {
                     $response = $this->filter_entry_object($response, $field_ids);
                 }
             }
         }
         if ($schema == 'mtd') {
             $response = self::mtd_transform_entry_data($response);
         }
     } else {
         //sorting parameters
         $sort_key = isset($_GET['sorting']['key']) && !empty($_GET['sorting']['key']) ? $_GET['sorting']['key'] : 'id';
         $sort_dir = isset($_GET['sorting']['direction']) && !empty($_GET['sorting']['direction']) ? $_GET['sorting']['direction'] : 'DESC';
         $sorting = array('key' => $sort_key, 'direction' => $sort_dir);
         if (isset($_GET['sorting']['is_numeric'])) {
             $sorting['is_numeric'] = $_GET['sorting']['is_numeric'];
         }
         //paging parameters
         $page_size = isset($_GET['paging']['page_size']) ? intval($_GET['paging']['page_size']) : 10;
         if (isset($_GET['paging']['current_page'])) {
             $current_page = intval($_GET['paging']['current_page']);
             $offset = $page_size * ($current_page - 1);
         } else {
             $offset = isset($_GET['paging']['offset']) ? intval($_GET['paging']['offset']) : 0;
         }
         $paging = array('offset' => $offset, 'page_size' => $page_size);
         if (isset($_GET['search'])) {
             $search = $_GET['search'];
             if (!is_array($search)) {
                 $search = urldecode(stripslashes($search));
                 $search = json_decode($search, true);
             }
         } else {
             $search = array();
         }
         if (empty($form_ids)) {
             $form_ids = 0;
         }
         // all forms
         $entry_count = GFAPI::count_entries($form_ids, $search);
         $result = $entry_count > 0 ? GFAPI::get_entries($form_ids, $search, $sorting, $paging) : array();
         if (!is_wp_error($result)) {
             foreach ($result as &$entry) {
                 $entry = $this->maybe_json_encode_list_fields($entry);
             }
             $response = array('total_count' => $entry_count, 'entries' => $result);
             if ($schema == 'mtd') {
                 $response = $this->mtd_transform_entries_data($response, $form_ids);
             }
         }
     }
     if (is_wp_error($result)) {
         $response = $this->get_error_response($result);
         $status = $this->get_error_status($result);
     }
     $this->end($status, $response);
 }
Exemplo n.º 20
0
 public function get_entry($custom_field)
 {
     //Valid IPN requests must have a custom field
     if (empty($custom_field)) {
         $this->log_error(__METHOD__ . '(): IPN request does not have a custom field, so it was not created by Gravity Forms. Aborting.');
         return false;
     }
     //Getting entry associated with this IPN message (entry id is sent in the 'custom' field)
     list($entry_id, $hash) = explode('|', $custom_field);
     $hash_matches = wp_hash($entry_id) == $hash;
     //allow the user to do some other kind of validation of the hash
     $hash_matches = apply_filters('gform_paypal_hash_matches', $hash_matches, $entry_id, $hash, $custom_field);
     //Validates that Entry Id wasn't tampered with
     if (!rgpost('test_ipn') && !$hash_matches) {
         $this->log_error(__METHOD__ . "(): Entry Id verification failed. Hash does not match. Custom field: {$custom_field}. Aborting.");
         return false;
     }
     $this->log_debug(__METHOD__ . "(): IPN message has a valid custom field: {$custom_field}");
     $entry = GFAPI::get_entry($entry_id);
     if (is_wp_error($entry)) {
         $this->log_error(__METHOD__ . '(): ' . $entry->get_error_message());
         return false;
     }
     return $entry;
 }
Exemplo n.º 21
0
function createOutput($entry_id, $pdf)
{
    $entry = GFAPI::get_entry($entry_id);
    $makers = array();
    if (strlen($entry['160.3']) > 0) {
        $makers[] = $entry['160.3'] . ' ' . $entry['160.6'];
    }
    if (strlen($entry['158.3']) > 0) {
        $makers[] = $entry['158.3'] . ' ' . $entry['158.6'];
    }
    if (strlen($entry['155.3']) > 0) {
        $makers[] = $entry['155.3'] . ' ' . $entry['155.6'];
    }
    if (strlen($entry['156.3']) > 0) {
        $makers[] = $entry['156.3'] . ' ' . $entry['156.6'];
    }
    if (strlen($entry['157.3']) > 0) {
        $makers[] = $entry['157.3'] . ' ' . $entry['157.6'];
    }
    if (strlen($entry['159.3']) > 0) {
        $makers[] = $entry['159.3'] . ' ' . $entry['159.6'];
    }
    if (strlen($entry['154.3']) > 0) {
        $makers[] = $entry['154.3'] . ' ' . $entry['154.6'];
    }
    //maker 1 bio
    $bio = filterText($entry['234']);
    $groupname = $entry['109'];
    $groupphoto = $entry['111'];
    $groupbio = filterText($entry['110']);
    $project_name = filterText($entry['151']);
    $project_photo = $entry['22'];
    $project_short = filterText($entry['16']);
    $project_website = $entry['27'];
    $project_video = $entry['32'];
    $project_title = filterText((string) $entry['151']);
    $project_title = preg_replace('/\\v+|\\\\[rn]/', '<br/>', $project_title);
    // Project ID
    $pdf->SetFont('Benton Sans', '', 12);
    $pdf->setTextColor(168, 170, 172);
    $pdf->SetXY(240, 20);
    $pdf->MultiCell(115, 10, $entry_id, 0, 'L');
    // Project Title
    $pdf->setTextColor(0);
    $pdf->SetXY(12, 75);
    //auto adjust the font so the text will fit
    $x = 65;
    // set the starting font size
    $pdf->SetFont('Benton Sans', 'B', 65);
    /* Cycle thru decreasing the font size until it's width is lower than the max width */
    while ($pdf->GetStringWidth(utf8_decode($project_title)) > 400) {
        $x--;
        // Decrease the variable which holds the font size
        $pdf->SetFont('Benton Sans', 'B', $x);
    }
    $lineHeight = $x * 0.2645833333333 * 1.3;
    /* Output the title at the required font size */
    $pdf->MultiCell(0, $lineHeight, $project_title, 0, 'L');
    //field 16 - short description
    //auto adjust the font so the text will fit
    $pdf->SetXY(145, 135);
    //auto adjust the font so the text will fit
    $sx = 30;
    // set the starting font size
    $pdf->SetFont('Benton Sans', '', $sx);
    // Cycle thru decreasing the font size until it's width is lower than the max width
    while ($pdf->GetStringWidth(utf8_decode($project_short)) > 1300) {
        $sx--;
        // Decrease the variable which holds the font size
        $pdf->SetFont('Benton Sans', '', $sx);
    }
    $lineHeight = $sx * 0.2645833333333 * 1.3;
    $pdf->MultiCell(125, $lineHeight, $project_short, 0, 'L');
    //field 22 - project photo
    $photo_extension = exif_imagetype($project_photo);
    if ($photo_extension) {
        //DEBUG:
        $project_photo = legacy_get_fit_remote_image_url($project_photo, 450, 450, 0);
        $pdf->Image($project_photo, 12, 135, null, null, image_type_to_extension($photo_extension, false));
    }
    //print white box to overlay long descriptions or photos
    /*$pdf->SetXY(10, 255); 
      $pdf->Cell(300,80,'',0,2,'L',true);*/
    //maker info, use a background of white to overlay any long images or text
    $pdf->setTextColor(0, 174, 239);
    $pdf->SetFont('Benton Sans', 'B', 48);
    $pdf->SetXY(10, 270);
    if (!empty($groupbio)) {
        //auto adjust the font so the text will fit
        $sx = 48;
        // set the starting font size
        // Cycle thru decreasing the font size until it's width is lower than the max width
        while ($pdf->GetStringWidth(utf8_decode($groupname)) > 240) {
            $sx--;
            // Decrease the variable which holds the font size
            $pdf->SetFont('Benton Sans', 'B', $sx);
        }
        $lineHeight = $sx * 0.2645833333333 * 1.3;
        $pdf->MultiCell(0, $lineHeight, $groupname, 0, 'L', true);
        $pdf->setTextColor(0);
        $pdf->SetFont('Benton Sans', '', 24);
        //auto adjust the font so the text will fit
        $x = 24;
        // set the starting font size
        /* Cycle thru decreasing the font size until it's width is lower than the max width */
        while ($pdf->GetStringWidth($groupbio) > 1200) {
            $x--;
            // Decrease the variable which holds the font size
            $pdf->SetFont('Benton Sans', '', $x);
        }
        $lineHeight = $x * 0.2645833333333 * 1.3;
        $pdf->MultiCell(0, $lineHeight, $groupbio, 0, 'L', true);
    } else {
        $makerList = implode(', ', $makers);
        $pdf->SetFont('Benton Sans', 'B', 48);
        //auto adjust the font so the text will fit
        $x = 48;
        // set the starting font size
        /* Cycle thru decreasing the font size until it's width is lower than the max width */
        while ($pdf->GetStringWidth(utf8_decode($makerList)) > 900) {
            $x--;
            // Decrease the variable which holds the font size
            $pdf->SetFont('Benton Sans', '', $x);
        }
        $lineHeight = $x * 0.2645833333333 * 1.3;
        $pdf->MultiCell(0, $lineHeight, $makerList, 0, 'L', true);
        //if size of makers is 1, then display maker bio
        if (sizeof($makers) == 1) {
            $pdf->setTextColor(0);
            $pdf->SetFont('Benton Sans', '', 24);
            //auto adjust the font so the text will fit
            $x = 24;
            // set the starting font size
            /* Cycle thru decreasing the font size until it's width is lower than the max width */
            while ($pdf->GetStringWidth($bio) > 900) {
                $x--;
                // Decrease the variable which holds the font size
                $pdf->SetFont('Benton Sans', '', $x);
            }
            $lineHeight = $x * 0.2645833333333 * 1.37;
            $pdf->MultiCell(0, $lineHeight, $bio, 0, 'L', true);
        }
    }
}
Exemplo n.º 22
0
 public function get_captured_payment_note($entry_id)
 {
     $entry = GFAPI::get_entry($entry_id);
     $feed = $this->get_payment_feed($entry);
     if (rgars($feed, 'meta/setupFee_enabled')) {
         $note = __('Setup fee has been paid.', 'gravityformsstripe');
     } else {
         $note = __('Trial has been paid.', 'gravityformsstripe');
     }
     return $note;
 }
Exemplo n.º 23
0
 public function get_entries($entry_ids, $form_ids = null, $schema = "", $field_ids = array())
 {
     $this->authorize("gravityforms_view_entries");
     $status = 200;
     $response = array();
     $result = array();
     if ($entry_ids) {
         if (is_array($entry_ids)) {
             foreach ($entry_ids as $entry_id) {
                 $result = GFAPI::get_entry($entry_id);
                 if (!is_wp_error($result)) {
                     $response[$entry_id] = $result;
                     if (!empty($field_ids) && !empty($response[$entry_id])) {
                         $response[$entry_id] = $this->filter_entry_object($response[$entry_id], $field_ids);
                     }
                 }
             }
         } else {
             $result = GFAPI::get_entry($entry_ids);
             if (!is_wp_error($result)) {
                 $response = $result;
                 if (!empty($field_ids) && !empty($response)) {
                     $response = $this->filter_entry_object($response, $field_ids);
                 }
             }
         }
         if ($schema == "mtd") {
             $response = self::mtd_transform_entry_data($response);
         }
     } else {
         //sorting parameters
         $sort_key = isset($_GET["sorting"]["key"]) && !empty($_GET["sorting"]["key"]) ? $_GET["sorting"]["key"] : "id";
         $sort_dir = isset($_GET["sorting"]["direction"]) && !empty($_GET["sorting"]["direction"]) ? $_GET["sorting"]["direction"] : "DESC";
         $sorting = array('key' => $sort_key, 'direction' => $sort_dir);
         //paging parameters
         $page_size = isset($_GET["paging"]["page_size"]) ? intval($_GET["paging"]["page_size"]) : 10;
         if (isset($_GET["paging"]["current_page"])) {
             $current_page = intval($_GET["paging"]["current_page"]);
             $offset = $page_size * ($current_page - 1);
         } else {
             $offset = isset($_GET["paging"]["offset"]) ? intval($_GET["paging"]["offset"]) : 0;
         }
         $paging = array('offset' => $offset, 'page_size' => $page_size);
         $search = isset($_GET["search"]) ? $_GET["search"] : array();
         if (empty($form_ids)) {
             $form_ids = 0;
         }
         // all forms
         $entry_count = GFAPI::count_entries($form_ids, $search);
         $result = $entry_count > 0 ? GFAPI::get_entries($form_ids, $search, $sorting, $paging) : array();
         if (!is_wp_error($result)) {
             $response = array("total_count" => $entry_count, "entries" => $result);
             if ($schema == "mtd") {
                 $response = $this->mtd_transform_entries_data($response, $form_ids);
             }
         }
     }
     if (is_wp_error($result)) {
         $response = $this->get_error_response($result);
         $status = $this->get_error_status($result);
     }
     $this->end($status, $response);
 }
Exemplo n.º 24
0
/**
 * Updates a single field of an entry.
 *
 * @since  1.9
 * @access public
 * @static
 *
 * @param int    $entry_id The ID of the Entry object
 * @param string $input_id The id of the input to be updated. For single input fields such as text, paragraph, website, drop down etc... this will be the same as the field ID.
 *                         For multi input fields such as name, address, checkboxes, etc... the input id will be in the format {FIELD_ID}.{INPUT NUMBER}. ( i.e. "1.3" )
 *                         The $input_id can be obtained by inspecting the key for the specified field in the $entry object.
 *
 * @param mixed  $value    The value to which the field should be set
 *
 * @return bool Whether the entry property was updated successfully
 */
function mf_update_entry_field($entry_id, $input_id, $value)
{
    global $wpdb;
    $entry = GFAPI::get_entry($entry_id);
    if (is_wp_error($entry)) {
        return $entry;
    }
    $form = GFAPI::get_form($entry['form_id']);
    if (!$form) {
        return false;
    }
    $field = GFFormsModel::get_field($form, $input_id);
    $lead_detail_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}rg_lead_detail WHERE lead_id=%d AND  CAST(field_number AS CHAR) ='%s'", $entry_id, $input_id));
    $result = true;
    if (!isset($entry[$input_id]) || $entry[$input_id] != $value) {
        $result = GFFormsModel::update_lead_field_value($form, $entry, $field, $lead_detail_id, $input_id, $value);
    }
    return $result;
}
Exemplo n.º 25
0
    public static function lead_detail_page()
    {
        global $wpdb;
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta($_GET["id"]);
        $form_id = $form["id"];
        $form = apply_filters("gform_admin_pre_render_" . $form["id"], apply_filters("gform_admin_pre_render", $form));
        $lead_id = rgget('lid');
        $filter = rgget("filter");
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $star = $filter == "star" ? 1 : null;
        $read = $filter == "unread" ? 0 : null;
        $search_criteria["status"] = $status;
        if ($star) {
            $search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
        }
        $search_field_id = rgget("field_id");
        if (isset($_GET["field_id"]) && $_GET["field_id"] !== '') {
            $key = $search_field_id;
            $val = rgget("s");
            $strpos_row_key = strpos($search_field_id, "|");
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode("|", $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ":" . $val;
            }
            $type = rgget("type");
            if (empty($type)) {
                $type = rgget("field_id") == "0" ? "global" : "field";
            }
            $search_criteria["field_filters"][] = array("key" => $key, "type" => $type, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET["sort"], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            _e("Oops! We couldn't find your entry. Please try again", "gravityforms");
            return;
        }
        RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
        switch (RGForms::post("action")) {
            case "update":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post("gform_uploaded_files")));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action("gform_after_update_entry", $form, $lead["id"]);
                do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
                $lead = RGFormsModel::get_lead($lead["id"]);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case "add_note":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
                //emailing notes if configured
                if (rgpost("gentry_email_notes_to")) {
                    $email_to = $_POST["gentry_email_notes_to"];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST["gentry_email_subject"]);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    $result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
                }
                break;
            case "add_quick_note":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["quick_note"]));
                break;
            case "bulk":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST["bulk_action"] == "delete") {
                    RGFormsModel::delete_notes($_POST["note"]);
                }
                break;
            case "trash":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "trash");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "restore":
            case "unspam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "active");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "spam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "spam");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "delete":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    die(__("You don't have adequate permissions to delete entries.", "gravityforms"));
                }
                RGFormsModel::delete_lead($lead["id"]);
                ?>
                <script type="text/javascript">
                    document.location.href='<?php 
                echo "admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]);
                ?>
';
                </script>
                <?php 
                break;
        }
        $mode = empty($_POST["screen_mode"]) ? "view" : $_POST["screen_mode"];
        ?>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" />
         <script type="text/javascript">

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

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

                    return true;
                }
            }

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

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

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

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

            function ResendNotifications() {

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

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

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

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

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

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

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

            }

            function displayMessage(message, messageClass, container){

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

            }

            function toggleNotificationOverride(isInit) {

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

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

        </script>

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        </div>

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

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

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

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

                                <form method="post">
                                    <?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
                                    <div class="inside">
                                        <?php 
            $notes = RGFormsModel::get_lead_notes($lead["id"]);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field["id"]])) {
                    $emails[] = $lead[$email_field["id"]];
                }
            }
            //displaying notes grid
            $subject = !empty($form["autoResponder"]["subject"]) ? "RE: " . GFCommon::replace_variables($form["autoResponder"]["subject"], $form, $lead) : "";
            self::notes_grid($notes, true, $emails, $subject);
            ?>
                                    </div>
                                </form>
                            </div>
                        <?php 
        }
        do_action("gform_entry_detail_content_after", $form, $lead);
        ?>
                    </div>
                </div>
            </div>
        </div>
        </form>
        <?php 
        if (rgpost("action") == "update") {
            ?>
            <div class="updated fade" style="padding:6px;">
                <?php 
            _e("Entry Updated.", "gravityforms");
            ?>
            </div>
            <?php 
        }
    }
Exemplo n.º 26
0
 /**
  * Adds a single Entry object.
  *
  * Intended to be used for importing an entry object. The usual hooks that are triggered while saving entries are not fired here.
  * Checks that the form id, field ids and entry meta exist and ignores legacy values (i.e. values for fields that no longer exist).
  *
  * @since  1.8
  * @access public
  * @static
  *
  * @param array $entry The Entry object
  *
  * @return mixed Either the new Entry ID or a WP_Error instance
  */
 public static function add_entry($entry)
 {
     global $wpdb;
     if (!is_array($entry)) {
         return new WP_Error('invalid_entry_object', __('The entry object must be an array', 'gravityforms'));
     }
     // make sure the form id exists
     $form_id = rgar($entry, 'form_id');
     if (empty($form_id)) {
         return new WP_Error('empty_form_id', __('The form id must be specified', 'gravityforms'));
     }
     if (false === self::form_id_exists($form_id)) {
         return new WP_Error('invalid_form_id', __('The form for this entry does not exist', 'gravityforms'));
     }
     // use values in the entry object if present
     $post_id = isset($entry['post_id']) ? intval($entry['post_id']) : 'NULL';
     $date_created = isset($entry['date_created']) && $entry['date_created'] != '' ? sprintf("'%s'", esc_sql($entry['date_created'])) : 'utc_timestamp()';
     $is_starred = isset($entry['is_starred']) ? $entry['is_starred'] : 0;
     $is_read = isset($entry['is_read']) ? $entry['is_read'] : 0;
     $ip = isset($entry['ip']) ? $entry['ip'] : GFFormsModel::get_ip();
     $source_url = isset($entry['source_url']) ? $entry['source_url'] : esc_url_raw(GFFormsModel::get_current_page_url());
     $user_agent = isset($entry['user_agent']) ? $entry['user_agent'] : 'API';
     $currency = isset($entry['currency']) ? $entry['currency'] : GFCommon::get_currency();
     $payment_status = isset($entry['payment_status']) ? sprintf("'%s'", esc_sql($entry['payment_status'])) : 'NULL';
     $payment_date = strtotime(rgar($entry, 'payment_date')) ? sprintf("'%s'", gmdate('Y-m-d H:i:s', strtotime("{$entry['payment_date']}"))) : 'NULL';
     $payment_amount = isset($entry['payment_amount']) ? (double) $entry['payment_amount'] : 'NULL';
     $payment_method = isset($entry['payment_method']) ? $entry['payment_method'] : '';
     $transaction_id = isset($entry['transaction_id']) ? sprintf("'%s'", esc_sql($entry['transaction_id'])) : 'NULL';
     $is_fulfilled = isset($entry['is_fulfilled']) ? intval($entry['is_fulfilled']) : 'NULL';
     $status = isset($entry['status']) ? $entry['status'] : 'active';
     global $current_user;
     $user_id = isset($entry['created_by']) ? absint($entry['created_by']) : '';
     if (empty($user_id)) {
         $user_id = $current_user && $current_user->ID ? absint($current_user->ID) : 'NULL';
     }
     $transaction_type = isset($entry['transaction_type']) ? intval($entry['transaction_type']) : 'NULL';
     $lead_table = GFFormsModel::get_lead_table_name();
     $result = $wpdb->query($wpdb->prepare("\n                INSERT INTO {$lead_table}\n                (form_id, post_id, date_created, is_starred, is_read, ip, source_url, user_agent, currency, payment_status, payment_date, payment_amount, transaction_id, is_fulfilled, created_by, transaction_type, status, payment_method)\n                VALUES\n                (%d, {$post_id}, {$date_created}, %d,  %d, %s, %s, %s, %s, {$payment_status}, {$payment_date}, {$payment_amount}, {$transaction_id}, {$is_fulfilled}, {$user_id}, {$transaction_type}, %s, %s)\n                ", $form_id, $is_starred, $is_read, $ip, $source_url, $user_agent, $currency, $status, $payment_method));
     if (false === $result) {
         return new WP_Error('insert_entry_properties_failed', __('There was a problem while inserting the entry properties', 'gravityforms'), $wpdb->last_error);
     }
     // reading newly created lead id
     $entry_id = $wpdb->insert_id;
     $entry['id'] = $entry_id;
     // only save field values for fields that currently exist in the form
     $form = GFFormsModel::get_form_meta($form_id);
     foreach ($form['fields'] as $field) {
         /* @var GF_Field $field */
         if (in_array($field->type, array('html', 'page', 'section'))) {
             continue;
         }
         $inputs = $field->get_entry_inputs();
         if (is_array($inputs)) {
             foreach ($inputs as $input) {
                 $input_id = (string) $input['id'];
                 if (isset($entry[$input_id])) {
                     $result = GFFormsModel::update_lead_field_value($form, $entry, $field, 0, $input_id, $entry[$input_id]);
                     if (false === $result) {
                         return new WP_Error('insert_input_value_failed', __('There was a problem while inserting one of the input values for the entry', 'gravityforms'), $wpdb->last_error);
                     }
                 }
             }
         } else {
             $field_id = $field->id;
             $field_value = isset($entry[(string) $field_id]) ? $entry[(string) $field_id] : '';
             $result = GFFormsModel::update_lead_field_value($form, $entry, $field, 0, $field_id, $field_value);
             if (false === $result) {
                 return new WP_Error('insert_field_values_failed', __('There was a problem while inserting the field values', 'gravityforms'), $wpdb->last_error);
             }
         }
     }
     // add save the entry meta values - only for the entry meta currently available for the form, ignore the rest
     $entry_meta = GFFormsModel::get_entry_meta($form_id);
     if (is_array($entry_meta)) {
         foreach (array_keys($entry_meta) as $key) {
             if (isset($entry[$key])) {
                 gform_update_meta($entry_id, $key, $entry[$key], $form['id']);
             }
         }
     }
     // Refresh the entry
     $entry = GFAPI::get_entry($entry['id']);
     /**
      * Fires after the Entry is added using the API.
      *
      * @since  1.9.14.26
      *
      * @param array $entry
      * @param array $form
      */
     do_action('gform_post_add_entry', $entry, $form);
     return $entry_id;
 }
Exemplo n.º 27
0
 /**
  * Return a single entry object
  *
  * Since 1.4, supports custom entry slugs. The way that GravityView fetches an entry based on the custom slug is by searching `gravityview_unique_id` meta. The `$entry_slug` is fetched by getting the current query var set by `is_single_entry()`
  *
  * @access public
  * @param mixed $entry_id
  * @param boolean $force_allow_ids Force the get_entry() method to allow passed entry IDs, even if the `gravityview_custom_entry_slug_allow_id` filter returns false.
  * @return object or false
  */
 public static function get_entry($entry_slug, $force_allow_ids = false)
 {
     if (class_exists('GFAPI') && !empty($entry_slug)) {
         /**
          * Enable custom entry slug functionality.
          *
          * @see  GravityView_API::get_entry_slug()
          * @var boolean
          */
         $custom_slug = apply_filters('gravityview_custom_entry_slug', false);
         /**
          * When using a custom slug, allow access to the entry using the original slug (the Entry ID).
          *
          * If disabled (default), only allow access to an entry using the custom slug value.  (example: `/entry/custom-slug/` NOT `/entry/123/`)
          * If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`)
          *
          * @var boolean
          */
         $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false);
         /**
          * If we're using custom entry slugs, we do a meta value search
          * instead of doing a straightup ID search.
          */
         if ($custom_slug) {
             $entry_id = self::get_entry_id_from_slug($entry_slug);
         }
         // If custom slug is off, search using the entry ID
         // ID allow ID access is on, also use entry ID as a backup
         if (empty($custom_slug) || !empty($custom_slug_id_access)) {
             // Search for IDs matching $entry_slug
             $entry_id = $entry_slug;
         }
         if (empty($entry_id)) {
             return false;
         }
         // fetch the entry
         $entry = GFAPI::get_entry($entry_id);
         // Is the entry allowed
         $entry = self::check_entry_display($entry);
         return $entry;
     }
     return false;
 }
Exemplo n.º 28
0
function wpcampus_convert_entry_to_post($entry, $form)
{
    // If ID, get the entry
    if (is_numeric($entry) && $entry > 0) {
        $entry = GFAPI::get_entry($entry);
    }
    // If ID, get the form
    if (is_numeric($form) && $form > 0) {
        $form = GFAPI::get_form($form);
    }
    // Make sure we have some info
    if (!$entry || !$form) {
        return false;
    }
    // Set the entry id
    $entry_id = $entry['id'];
    // First, check to see if the entry has already been processed
    $entry_post = wpcampus_get_entry_post($entry_id);
    // If this entry has already been processed, then skip
    if ($entry_post && isset($entry_post->ID)) {
        return false;
    }
    // Fields to store in post meta
    // Names will be used dynamically when processing fields below
    $fields_to_store = array('name', 'involvement', 'sessions', 'event_time', 'email', 'status', 'employer', 'attend_preference', 'traveling_city', 'traveling_state', 'traveling_country', 'traveling_latitude', 'traveling_longitude', 'slack_invite', 'slack_email');
    // Process one field at a time
    foreach ($form['fields'] as $field) {
        // Set the admin label
        $admin_label = strtolower(preg_replace('/\\s/i', '_', $field['adminLabel']));
        // Only process if one of our fields
        // We need to process traveling_from but not store it in post meta which is why it's not in the array
        if (!in_array($admin_label, array_merge($fields_to_store, array('traveling_from')))) {
            continue;
        }
        // Process fields according to admin label
        switch ($admin_label) {
            case 'name':
                // Get name parts
                $first_name = null;
                $last_name = null;
                // Process each name part
                foreach ($field->inputs as $input) {
                    $name_label = strtolower($input['label']);
                    switch ($name_label) {
                        case 'first':
                        case 'last':
                            ${$name_label . '_name'} = rgar($entry, $input['id']);
                            break;
                    }
                }
                // Build name to use when creating post
                $name = trim("{$first_name} {$last_name}");
                break;
            case 'involvement':
            case 'sessions':
            case 'event_time':
                // Get all the input data and place in array
                ${$admin_label} = array();
                foreach ($field->inputs as $input) {
                    if ($this_data = rgar($entry, $input['id'])) {
                        ${$admin_label}[] = $this_data;
                    }
                }
                break;
            case 'traveling_from':
                // Get all the input data and place in array
                ${$admin_label} = array();
                foreach ($field->inputs as $input) {
                    // Create the data index
                    $input_label = strtolower(preg_replace('/\\s/i', '_', preg_replace('/\\s\\/\\s/i', '_', $input['label'])));
                    // Change to simply state
                    if ('state_province' == $input_label) {
                        $input_label = 'state';
                    }
                    // Store data
                    if ($this_data = rgar($entry, $input['id'])) {
                        ${"traveling_{$input_label}"} = $this_data;
                    }
                    // Store all traveling data in an array
                    ${$admin_label}[$input_label] = $this_data;
                }
                // Create string of traveling data
                $traveling_string = preg_replace('/[\\s]{2,}/i', ' ', implode(' ', ${$admin_label}));
                // Get latitude and longitude
                if ($traveling_lat_long = wpcampus_get_lat_long($traveling_string)) {
                    // Store data (will be stored in post meta later)
                    $traveling_latitude = isset($traveling_lat_long->lat) ? $traveling_lat_long->lat : false;
                    $traveling_longitude = isset($traveling_lat_long->lng) ? $traveling_lat_long->lng : false;
                }
                break;
                // Get everyone else
            // Get everyone else
            default:
                // Get field value
                ${$admin_label} = rgar($entry, $field->id);
                break;
        }
    }
    // Create entry post title
    $post_title = "Entry #{$entry_id}";
    // Add name
    if (!empty($name)) {
        $post_title .= " - {$name}";
    }
    // Create entry
    if ($new_entry_post_id = wp_insert_post(array('post_type' => 'wpcampus_interest', 'post_status' => 'publish', 'post_title' => $post_title, 'post_content' => ''))) {
        // Store entry ID in post
        update_post_meta($new_entry_post_id, 'gf_entry_id', $entry_id);
        // Store post ID in the entry
        GFAPI::update_entry_property($entry_id, 'post_id', $new_entry_post_id);
        // Store fields
        foreach ($fields_to_store as $field_name) {
            update_post_meta($new_entry_post_id, $field_name, ${$field_name});
        }
        return true;
    }
    return false;
}
Exemplo n.º 29
0
    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta(absint($_GET['id']));
        $form_id = absint($form['id']);
        $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form));
        $lead_id = absint(rgget('lid'));
        $filter = rgget('filter');
        $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta['type'] == 'number';
        $star = $filter == 'star' ? 1 : null;
        $read = $filter == 'unread' ? 0 : null;
        $search_criteria['status'] = $status;
        if ($star) {
            $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
        }
        $search_field_id = rgget('field_id');
        if (isset($_GET['field_id']) && $_GET['field_id'] !== '') {
            $key = $search_field_id;
            $val = rgget('s');
            $strpos_row_key = strpos($search_field_id, '|');
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode('|', $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ':' . $val;
            }
            $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_GET) ? 'is' : rgget('operator'), 'value' => $val);
            $type = rgget('type');
            if (empty($type)) {
                if (rgget('field_id') == '0') {
                    $search_criteria['type'] = 'global';
                }
            }
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action('gform_after_update_entry', $form, $lead['id']);
                do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST['bulk_action'] == 'delete') {
                    if (!GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
                        die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms'));
                    }
                    RGFormsModel::delete_notes($_POST['note']);
                }
                break;
            case 'trash':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'trash');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'restore':
            case 'unspam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'active');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'spam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'spam');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'delete':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    die(esc_html__("You don't have adequate permission to delete entries.", 'gravityforms'));
                }
                RGFormsModel::delete_lead($lead['id']);
                ?>
				<script type="text/javascript">
					document.location.href = '<?php 
                echo 'admin.php?page=gf_entries&view=entries&id=' . absint($form['id']);
                ?>
';
				</script>
				<?php 
                break;
        }
        $mode = empty($_POST['screen_mode']) ? 'view' : $_POST['screen_mode'];
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css" />
		<script type="text/javascript">

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

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

					return true;
				}
			}

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

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

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

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

			function ResendNotifications() {

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

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

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

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

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

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

							toggleNotificationOverride();

						}

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

			}

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

			function toggleNotificationOverride(isInit) {

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

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

		</script>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

							</div>

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

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

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

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

						<form method="post">
							<?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
							<div class="inside">
								<?php 
            $notes = RGFormsModel::get_lead_notes($lead['id']);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field->id])) {
                    $emails[] = $lead[$email_field->id];
                }
            }
            //displaying notes grid
            $subject = '';
            self::notes_grid($notes, true, $emails, $subject);
            ?>
							</div>
						</form>
					</div>
				<?php 
        }
        do_action('gform_entry_detail_content_after', $form, $lead);
        ?>
			</div>
		</div>
		</div>
		</div>
		</form>
		<?php 
        if (rgpost('action') == 'update') {
            ?>
			<div class="updated fade" style="padding:6px;">
				<?php 
            esc_html_e('Entry Updated.', 'gravityforms');
            ?>
			</div>
		<?php 
        }
    }
 /**
  * Delete entries
  * This function is used to delete entries with an ajax request
  * Could use better (or at least some) error handling
  */
 public function maybe_delete_entry()
 {
     if (isset($_POST["mode"]) && $_POST["mode"] == "delete" && isset($_POST["delete_id"]) && isset($_POST["form_id"])) {
         $form_id = $_POST["form_id"];
         $form = GFAPI::get_form($form_id);
         $settings = $this->get_form_settings($form);
         $enable_delete = $settings["enable_delete"];
         $delete_type = $settings["delete_type"];
         if ($enable_delete) {
             $delete_id = $_POST["delete_id"];
             $entry = GFAPI::get_entry($delete_id);
             if (!is_wp_error($entry)) {
                 if ($entry["created_by"] == $this->stickylist_get_current_user() || current_user_can('delete_others_posts') || current_user_can('stickylist_delete_entries')) {
                     if ($_POST["delete_post_id"] != null) {
                         $delete_post_id = $_POST["delete_post_id"];
                     } else {
                         $delete_post_id = "";
                     }
                     if ($delete_type == "trash") {
                         $entry["status"] = "trash";
                         $success = GFAPI::update_entry($entry, $delete_id);
                         if ($delete_post_id != "") {
                             wp_delete_post($delete_post_id, false);
                         }
                     }
                     if ($delete_type == "permanent") {
                         $success = GFAPI::delete_entry($delete_id);
                         if ($delete_post_id != "") {
                             wp_delete_post($delete_post_id, true);
                         }
                     }
                     if ($success) {
                         $notifications = $form["notifications"];
                         $notification_ids = array();
                         foreach ($notifications as $notification) {
                             $notification_type = $notification["stickylist_notification_type"];
                             if ($notification_type == "delete" || $notification_type == "all") {
                                 $id = $notification["id"];
                                 array_push($notification_ids, $id);
                             }
                         }
                         GFCommon::send_notifications($notification_ids, $form, $entry);
                     }
                 }
             }
         }
     }
 }