<?php /** * Display other entries created by the entry creator field type * * @package GravityView * @subpackage GravityView/templates/fields */ $gravityview_view = GravityView_View::getInstance(); $field = $gravityview_view->getCurrentField(); $created_by = rgar($field['entry'], 'created_by'); // There was no logged in user who created this entry. if (empty($created_by)) { return; } // Generate the search parameters $args = array('id' => $gravityview_view->getViewId(), 'page_size' => $gravityview_view->getCurrentFieldSetting('page_size'), 'search_field' => 'created_by', 'search_value' => $created_by, 'search_operator' => 'is'); /** * @since 1.7.6 */ $args = apply_filters('gravityview/field/other_entries/args', $args, $field); // Get the entries for the search $entries = GravityView_frontend::get_view_entries($args, $field['form']['id']); // Don't show if no entries and the setting says so if (empty($entries['entries']) && $gravityview_view->getCurrentFieldSetting('no_entries_hide')) { return; } // If there are search results, get the entry list object $list = new GravityView_Entry_List($entries['entries'], $gravityview_view->getPostId(), $field['form'], $gravityview_view->getCurrentFieldSetting('link_format'), $gravityview_view->getCurrentFieldSetting('after_link'), 'other_entries'); // Generate and echo the output $list->output();
/** * main AJAX logic to retrieve DataTables data */ function get_datatables_data() { global $gravityview_view; if (empty($_POST)) { return; } // Prevent error output ob_start(); // Send correct headers $this->do_ajax_headers('application/javascript'); $this->check_ajax_nonce(); if (empty($_POST['view_id'])) { do_action('gravityview_log_debug', '[DataTables] AJAX request - View ID check failed'); exit(false); } // Prevent emails from being encrypted add_filter('gravityview_email_prevent_encrypt', '__return_true'); do_action('gravityview_log_debug', '[DataTables] AJAX Request ($_POST)', $_POST); // include some frontend logic if (class_exists('GravityView_Plugin') && !class_exists('GravityView_View')) { GravityView_Plugin::getInstance()->frontend_actions(); } // Pass $_GET variables to the View functions, since they're relied on heavily // for searching and filtering, for example the A-Z widget $_GET = json_decode(stripslashes($_POST['getData']), true); $view_id = intval($_POST['view_id']); // create the view object based on the post_id $GravityView_View_Data = GravityView_View_Data::getInstance((int) $_POST['post_id']); // get the view data $view_data = $GravityView_View_Data->get_view($view_id); $view_data['atts']['id'] = $view_id; $atts = $view_data['atts']; // check for order/sorting if (isset($_POST['order'][0]['column'])) { $order_index = $_POST['order'][0]['column']; if (!empty($_POST['columns'][$order_index]['name'])) { // remove prefix 'gv_' $atts['sort_field'] = substr($_POST['columns'][$order_index]['name'], 3); $atts['sort_direction'] = !empty($_POST['order'][0]['dir']) ? strtoupper($_POST['order'][0]['dir']) : 'ASC'; } } // check for search if (!empty($_POST['search']['value'])) { $atts['search_value'] = esc_attr(stripslashes_deep($_POST['search']['value'])); } // Paging/offset $atts['page_size'] = isset($_POST['length']) ? intval($_POST['length']) : ''; $atts['offset'] = isset($_POST['start']) ? intval($_POST['start']) : 0; // prepare to get entries $atts = wp_parse_args($atts, GravityView_View_Data::get_default_args()); // check if someone requested the full filtered data (eg. TableTools print button) if ($atts['page_size'] == '-1') { $mode = 'all'; $atts['page_size'] = PHP_INT_MAX; } else { // regular mode - get view entries $mode = 'page'; } $view_data['atts'] = $atts; $gravityview_view = new GravityView_View($view_data); if (class_exists('GravityView_Cache')) { // We need to fetch the search criteria and pass it to the Cache so that the search is used when generating the cache transient key. $search_criteria = GravityView_frontend::get_search_criteria($atts, $view_data['form_id']); // make sure to allow late filter ( used on Advanced Filter extension ) $criteria = apply_filters('gravityview_search_criteria', array('search_criteria' => $search_criteria), $view_data['form_id'], $_POST['view_id']); $atts['search_criteria'] = $criteria['search_criteria']; // Cache key should also depend on the View assigned fields $atts['directory_table-columns'] = !empty($view_data['fields']['directory_table-columns']) ? $view_data['fields']['directory_table-columns'] : array(); // cache depends on user session $atts['user_session'] = $this->get_user_session(); $Cache = new GravityView_Cache($view_data['form_id'], $atts); if ($output = $Cache->get()) { do_action('gravityview_log_debug', '[DataTables] Cached output found; using cache with key ' . $Cache->get_key()); // update DRAW (mr DataTables is very sensitive!) $temp = json_decode($output, true); $temp['draw'] = intval($_POST['draw']); $output = json_encode($temp); exit($output); } } $view_entries = GravityView_frontend::get_view_entries($atts, $view_data['form_id']); $data = $this->get_output_data($view_entries, $view_data); // wrap all $output = array('draw' => intval($_POST['draw']), 'recordsTotal' => intval($view_entries['count']), 'recordsFiltered' => intval($view_entries['count']), 'data' => $data); do_action('gravityview_log_debug', '[DataTables] Ajax request answer', $output); $json = json_encode($output); if (class_exists('GravityView_Cache')) { do_action('gravityview_log_debug', '[DataTables] Setting cache'); // Cache results $Cache->set($json, 'datatables_output'); } // End prevent error output ob_end_clean(); exit($json); }