예제 #1
0
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' );
        }
    }
}
예제 #2
0
function ninja_forms_save_view_subs($form_id, $data = array())
{
    global $ninja_forms_admin_update_message;
    $plugin_settings = get_option("ninja_forms_settings");
    if (isset($_POST['submit']) and $_REQUEST['page'] == 'ninja-forms-subs') {
        switch ($_POST['submit']) {
            case __('Apply', 'ninja-forms'):
                if (isset($_POST['bulk_action'])) {
                    if ($_POST['bulk_action'] == 'delete') {
                        if (isset($_POST['ninja_forms_sub']) and is_array($_POST['ninja_forms_sub']) and !empty($_POST['ninja_forms_sub'])) {
                            $subs = ninja_forms_esc_html_deep($_POST['ninja_forms_sub']);
                            foreach ($subs as $sub_id) {
                                ninja_forms_delete_sub($sub_id);
                            }
                            $ninja_forms_admin_update_message = count($_POST['ninja_forms_sub']) . ' ';
                            if (count($_POST['ninja_forms_sub']) > 1) {
                                $ninja_forms_admin_update_message .= __('Submissions Deleted', 'ninja-forms');
                            } else {
                                $ninja_forms_admin_update_message .= __('Submission Deleted', 'ninja-forms');
                            }
                        }
                    } elseif ($_POST['bulk_action'] == 'export') {
                        if (isset($_POST['ninja_forms_sub']) and is_array($_POST['ninja_forms_sub']) and !empty($_POST['ninja_forms_sub'])) {
                            $subs = ninja_forms_esc_html_deep($_POST['ninja_forms_sub']);
                            ninja_forms_export_subs_to_csv($subs);
                        }
                    }
                }
                break;
            case __('Download All Submissions', 'ninja-forms'):
                if (isset($plugin_settings['date_format']) and $plugin_settings['date_format'] != '') {
                    $date_format = $plugin_settings['date_format'];
                } else {
                    $date_format = 'm/d/Y';
                }
                if (isset($_REQUEST['form_id']) and !empty($_REQUEST['form_id'])) {
                    $form_id = absint($_REQUEST['form_id']);
                } else {
                    $form_id = '';
                }
                if (isset($_REQUEST['ninja_forms_begin_date']) and !empty($_REQUEST['ninja_forms_begin_date'])) {
                    $begin_date = esc_html($_REQUEST['ninja_forms_begin_date']);
                } else {
                    $begin_date = '';
                }
                if (isset($_REQUEST['ninja_forms_end_date']) and !empty($_REQUEST['ninja_forms_end_date'])) {
                    $end_date = esc_html($_REQUEST['ninja_forms_end_date']);
                } else {
                    $end_date = '';
                }
                $args = array('form_id' => $form_id, 'begin_date' => $begin_date, 'end_date' => $end_date);
                $sub_results = ninja_forms_get_subs($args);
                $sub_results = apply_filters('ninja_forms_download_all_subs_results', $sub_results);
                if (is_array($sub_results) and !empty($sub_results)) {
                    $sub_ids = array();
                    foreach ($sub_results as $sub) {
                        $sub_ids[] = $sub['id'];
                    }
                    ninja_forms_export_subs_to_csv($sub_ids);
                }
                break;
            case __('Save Sub', 'ninja-forms'):
                break;
            case __('View Submissions', 'ninja-forms'):
                break;
        }
    }
}