function ninja_forms_feditor_add_sub_filter() { if (isset($_REQUEST['ninja_forms_action']) and $_REQUEST['ninja_forms_action'] != '' and (isset($_REQUEST['sub_id']) and $_REQUEST['sub_id'] != '')) { // Grab our form information from the submission ID. $form_row = ninja_forms_get_form_by_sub_id($_REQUEST['sub_id']); $form_id = $form_row['id']; $user_id = get_current_user_id(); // Check to make sure that this user can edit form submissions. $manage_sub = ninja_forms_manage_sub_check($user_id, $form_id); if ($manage_sub) { $edit = $manage_sub['edit']; $delete = $manage_sub['delete']; } else { $edit = false; $delete = false; } $sub_row = ninja_forms_get_sub_by_id($_REQUEST['sub_id']); if ($sub_row['user_id'] == $user_id) { if ($_REQUEST['ninja_forms_action'] == 'edit' and $edit) { add_action('init', 'ninja_forms_feditor_register_edit_sub_filter'); add_action('init', 'ninja_forms_feditor_register_edit_sub_id_output'); } if ($_REQUEST['ninja_forms_action'] == 'delete' and $delete) { ninja_forms_delete_sub($_REQUEST['sub_id']); $new_url = remove_query_arg(array('ninja_forms_action', 'sub_id')); wp_redirect($new_url); exit; } } else { //wp_redirect( 'http://www.cnn.com' ); } } }
function ninja_forms_output_manage_sub_table($subs, $user_id, $form_id, $cols = array(), $url = '') { $manage_sub = ninja_forms_manage_sub_check($user_id, $form_id); if ($manage_sub) { $edit = $manage_sub['edit']; $delete = $manage_sub['delete']; } else { $edit = false; $delete = false; } $plugin_settings = get_option('ninja_forms_settings'); $date_format = $plugin_settings['date_format']; $cols_array = array(); if (is_array($cols) and !empty($cols)) { foreach ($cols as $field_id) { $field_row = ninja_forms_get_field_by_id($field_id); $field_data = $field_row['data']; if (isset($field_data['label'])) { $cols_array[] = $field_data['label']; } } } if (!empty($subs)) { ?> <table id="ninja_forms_manage_subs" class=""> <thead> <?php if ($delete) { ?> <th></th> <?php } ?> <th><?php _e('Date Updated', 'ninja-forms-feditor'); ?> </th> <?php if (is_array($cols_array) and !empty($cols_array)) { foreach ($cols_array as $label) { ?> <th><?php echo $label; ?> </th> <?php } } ?> </thead> <tbody> <?php foreach ($subs as $sub) { $date_updated = $sub['date_updated']; $updated_timestamp = strtotime($date_updated); $date_updated = date($date_format, $updated_timestamp); if ($url == '') { $edit_url = add_query_arg(array('ninja_forms_action' => 'edit', 'sub_id' => $sub['id'])); $delete_url = add_query_arg(array('ninja_forms_action' => 'delete', 'sub_id' => $sub['id'])); } else { $edit_url = add_query_arg(array('ninja_forms_action' => 'edit', 'sub_id' => $sub['id']), $url); $delete_url = add_query_arg(array('ninja_forms_action' => 'delete', 'sub_id' => $sub['id']), $url); } $edit_url = remove_query_arg(array('ninja_forms_response_msg'), $edit_url); $delete_url = remove_query_arg(array('ninja_forms_response_msg'), $delete_url); if (isset($_REQUEST['ninja_forms_action']) and $_REQUEST['ninja_forms_action'] == 'edit' and isset($_REQUEST['sub_id']) and $sub['id'] == $_REQUEST['sub_id']) { $class = 'ninja-forms-active'; $active = true; } else { $class = ''; $active = false; } ?> <tr class="<?php echo $class; ?> "> <td> <?php if ($delete) { ?> <a href="<?php echo $delete_url; ?> " id="" class="ninja-forms-feditor-delete-sub" rel="<?php echo $sub['id']; ?> "> <?php _e('Delete', 'ninja-forms-feditor'); ?> <?php } ?> </td> <td> <?php if (!$active and $edit) { ?> <a href="<?php echo $edit_url; ?> #ninja_forms_form_<?php echo $form_id; ?> "> <?php } echo $date_updated; if (!$active and $edit) { ?> </a> <?php } ?> </td> <?php if (is_array($cols) and !empty($cols)) { foreach ($cols as $field_id) { foreach ($sub['data'] as $data) { if ($data['field_id'] == $field_id) { ?> <td> <?php if (!$active and $edit) { ?> <a href="<?php echo $edit_url; ?> #ninja_forms_form_<?php echo $form_id; ?> "> <?php } echo $data['user_value']; if (!$active and $edit) { ?> </a> <?php } ?> </td> <?php } } } } ?> </tr> <?php } if (empty($subs)) { $empty_msg = __('No Submissions Found', 'ninja-forms-feditor'); $empty_msg = apply_filters('ninja_forms_empty_sub_table', $empty_msg); ?> <tr> <td colspan="2"> <?php echo $empty_msg; ?> </td> </tr> <?php } ?> </tbody> </table> <?php } }