Commit 1310a97b authored by Kevin Stover's avatar Kevin Stover

Merge branch 'release/v2.7'

parents 7bef5809 0a00f928
......@@ -4,7 +4,7 @@
Tags: form, forms, contact form, custom form, form builder, form creator, form manager, form creation, contact forms, custom forms, forms builder, forms creator, forms manager, forms creation, form administration,
Requires at least: 3.6
Tested up to: 3.9
Stable tag: 2.6.4
Stable tag: 2.6.5
License: GPLv2 or later
Forms created with a simple drag and drop interface. Contact forms, Email collection forms, or any other form you want on your WordPress site.
......
.wp-list-table .type-nf_sub ul {
margin: 0;
}
.download-all {
float: right;
}
#postcustomstuff table td {
padding: 0 10px;
}
#postcustomstuff table input,
#postcustomstuff table select,
#postcustomstuff table textarea {
width: 100%;
}
#postcustomstuff table input[type=checkbox],
#postcustomstuff table input[type=radio] {
width: auto;
}
#postcustomstuff table textarea {
height: 150px;
}
.wrap h2 a {
font-size: 16px;
}
::-webkit-input-placeholder {
padding: 2px 5px 4px;
}
:-moz-placeholder {
padding: 2px 5px 4px;
}
::-moz-placeholder {
padding: 2px 5px 4px;
}
:-ms-input-placeholder {
padding: 2px 5px 4px;
}
#nf_fields {
/*background: transparent;
border: 0;*/
}
#postcustomstuff table {
background: transparent;
border: 0;
}
#postcustomstuff table tr td:first-child {
padding-top: 12px;
}
#nf_fields_save #major-publishing-actions {
margin: 10px -12px -12px;
}
.misc-pub-section span {
font-weight: bold;
}
.nf-sub-edit-value {
position: relative;
}
.type-_upload input[type=text] {
padding-right: 48px;
}
.type-_upload a {
background: #333;
color: #fff;
height: 27px;
line-height: 27px;
text-decoration: none;
padding: 0 10px;
position: absolute;
top: 8px;
right: -8px;
}
.type-_upload a:hover {
background: #f1f1f1;
color: #333;
<?php
// Silence is golden.
This diff is collapsed.
<?php
// Silence is golden.
<?php
// Silence is golden.
<?php
// Silence is golden.
<?php
// Silence is golden.
jQuery(document).ready(function($) {
var nf_columns = {
init: function() {
//this.move_row_actions();
// Remove our "ID" checkbox.
$( '#id-hide' ).parent().remove();
var that = this;
$( document ).on( 'click', '.hide-column-tog', that.save_hidden_columns );
},
save_hidden_columns: function() {
// Send our hidden columns to our backend for saving.
var hidden = columns.hidden();
$.post(
ajaxurl,
{
form_id: nf_sub.form_id,
hidden: hidden,
action:'nf_hide_columns'
}
);
// Move our row-actions
//nf_columns.move_row_actions();
},
move_row_actions: function() {
// Move our row-actions class to our first column.
$( "#the-list tr" ).each( function( e ) {
var first_column = $( this ).find( 'td:visible' ).eq(0);
if ( typeof $( first_column ).html() == 'undefined' ) {
first_column = $( this ).find( 'td:first' );
}
$( this ).find( 'td div.row-actions' ).detach().appendTo( first_column );
});
}
}
nf_columns.init();
$( '.datepicker' ).datepicker( { dateFormat: nf_sub.date_format } );
$( document ).on( 'change', '.nf-form-jump', function( e ) {
$( '#posts-filter' ).submit();
});
$( document ).on( 'submit', function( e ) {
$( '.spinner' ).show();
if ( $( 'select[name="action"]' ).val() == 'export' || $( 'select[name="action2"]' ).val() == 'export' ) {
setTimeout(function(){ // Delay for Chrome
$( 'input:checkbox' ).attr( 'checked', false );
$( '.spinner' ).hide();
$( 'select[name="action"]' ).val( '-1' );
$( 'select[name="action2"]' ).val( '-1' );
}, 2000);
}
});
$( '.screen-options' ).prepend( $( '#nf-subs-screen-options' ).html() );
$( '#nf-subs-screen-options' ).remove();
});
\ No newline at end of file
<?php
// Silence is golden.
<?php
/**
* Handles the output of our form, as well as interacting with its settings.
*
* @package Ninja Forms
* @subpackage Classes/Form
* @copyright Copyright (c) 2014, WPNINJAS
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.7
*/
class NF_Form {
/**
* @var form_id
* @since 2.7
*/
var $form_id;
/**
* @var settings - Form Settings
* @since 2.7
*/
var $settings = array();
/**
* @var fields - Form Fields
* @since 2.7
*/
var $fields = array();
/**
* @var fields - Fields List
* @since 2.7
*/
var $field_keys = array();
/**
* @var errors - Form errors
* @since 2.7
*/
var $errors = array();
/**
* Get things started
*
* @access public
* @since 2.7
* @return void
*/
public function __construct( $form_id ) {
// Set our current form id.
$this->form_id = $form_id;
$this->fields = nf_get_fields_by_form_id( $form_id );
$this->settings = nf_get_form_settings( $form_id );
}
/**
* Get one of our form settings.
*
* @access public
* @since 2.7
* @return string $setting
*/
public function get_setting( $setting ) {
if ( isset ( $this->settings[ $setting ] ) ) {
return $this->settings[ $setting ];
} else {
return false;
}
}
/**
* Update a form setting (this doesn't update anything in the database)
* Changes are only applied to this object.
*
* @access public
* @param string $setting
* @param mixed $value
* @return bool
*/
public function update_setting( $setting, $value ) {
$this->settings[ $setting ] = $value;
return true;
}
/**
* Get all the submissions for this form
*
* @access public
* @since 2.7
* @return array $sub_ids
*/
public function get_subs( $args = array() ) {
$args['form_id'] = $this->form_id;
return Ninja_Forms()->subs()->get( $args );
}
/**
* Return a count of the submissions this form has had
*
* @access public
* @param array $args
* @since 2.7
* @return int $count
*/
public function sub_count( $args = array() ) {
return count( $this->get_subs( $args ) );
}
}
\ No newline at end of file
<?php
// Silence is golden.
<?php
/**
* Submission.
* This class handles storing, retrieving, editing a submission.
*
* @package Ninja Forms
* @subpackage Classes/Submissions
* @copyright Copyright (c) 2014, WPNINJAS
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.7
*/
class NF_Sub {
/**
* @var $sub_id store our sub id
*/
var $sub_id;
/**
* @var $seq_num store our sequential number
*/
var $seq_num;
/**
* @var $form_id store our form_id
*/
var $form_id;
/**
* @var $fields store our user values
*/
var $fields;
/**
* @var $action store the action that created this sub
*/
var $action;
/**
* @var $user_id store the user ID for this submission
*/
var $user_id;
/**
* @var $meta store our non-field meta
*/
var $meta;
/**
* @var $date_submitted store our submitted date
*/
var $date_submitted;
/**
* @var $date_modified store our modified date
*/
var $date_modified;
/**
* Get things started
*
* @access public
* @since 2.7
* @return void/
*/
public function __construct( $sub_id ) {
global $ninja_forms_fields;
// Bail if the sub doesn't exist.
$sub = get_post( $sub_id );
if ( ! is_object( $sub ) )
return false;
// Set our sub id
$this->sub_id = $sub_id;
// Setup our form id var
$this->form_id = $this->get_meta( '_form_id' );
// Setup our action var
$this->action = $this->get_meta( '_action' );
// Setup our sequential id
$this->seq_num = $this->get_meta( '_seq_num' );
// Setup our user_id var
$this->user_id = $sub->post_author;
// Setup our date submitted var
$this->date_submitted = get_the_time( 'Y-m-d G:i:s', $sub_id );
// Setup our date modified var
$this->date_modified = get_post_modified_time( 'Y-m-d G:i:s', false, $sub_id );
// Setup our fields and meta vars.
$post_meta = get_post_custom( $this->sub_id );
$this->fields = array();
foreach ( $post_meta as $key => $array ) {
if ( is_serialized( $array[0] ) ) {
$meta_value = unserialize( $array[0] );
} else {
$meta_value = $array[0];
}
if ( strpos( $key, '_field_' ) !== false ) {
$field_id = str_replace( '_field_', '', $key );
$field = ninja_forms_get_field_by_id( $field_id );
$field_type = $field['type'];
// Check to see if our field type has been set as a "process_field".
if ( isset ( $ninja_forms_fields[ $field_type ] ) ) {
$reg_field = $ninja_forms_fields[ $field_type ];
$process_field = $reg_field['process_field'];
} else {
$process_field = false;
}
if ( $process_field ) {
$this->fields[ $field_id ] = $meta_value;
}
} else if ( $key != '_form_id' && $key != '_action' ) {
$this->meta[ $key ] = $meta_value;
}
}
}
/**
* Update our form id
*
* @access public
* @since 2.7
* @return bool
*/
public function update_form_id( $form_id ) {
if ( update_post_meta( $this->sub_id, '_form_id', $form_id ) ) {
$this->form_id = $form_id;
return true;
} else {
return false;
}
}
/**
* Update our action
*
* @access public
* @since 2.7
* @return bool
*/
public function update_action( $action ) {
if ( update_post_meta( $this->sub_id, '_action', $action ) ) {
$this->action = $action;
return true;
} else {
return false;
}
}
/**
* Update our sequential id
*
* @access public
* @since 2.7
* @return bool
*/
public function update_seq_num( $seq_num ) {
if ( update_post_meta( $this->sub_id, '_seq_num', $seq_num ) ) {
$this->seq_num = $seq_num;
return true;
} else {
return false;
}
}
/**
* Update our user id
*
* @access public
* @since 2.7
* @return bool
*/
public function update_user_id( $user_id ) {
$args = array(
'ID' => $this->sub_id,
'post_author' => $user_id,
);
// Update the post into the database
if ( wp_update_post( $args ) ) {
$this->user_id = $user_id;
return true;
} else {
return false;
}
}
/**
* Update our date submitted
*
* @access public
* @since 2.7
* @return bool
*/
public function update_date_submitted( $date ) {
$args = array(
'ID' => $this->sub_id,
'post_date' => $date,
'post_date_gmt' => get_gmt_from_date( $date ),
);
// Update the post into the database
if ( wp_update_post( $args ) ) {
$this->date_submitted = $date;
return true;
} else {
return false;
}
}
/**
* Update our date modified
*
* @access public
* @since 2.7
* @return bool
*/
public function update_date_modified( $date ) {
$args = array(
'ID' => $this->sub_id,
'post_modified' => $date,
'post_modified_gmt' => get_gmt_from_date( $date ),
);
// Update the post into the database
if ( wp_update_post( $args ) ) {
$this->date_modified = $date;
return true;
} else {
return false;
}
}
/**
* Add a meta value to our submission.
*
* @access public
* @since 2.7
* @return bool
*/
public function add_meta( $meta_key, $value ) {
if ( update_post_meta( $this->sub_id, $meta_key, $value ) ) {
$this->meta[ $meta_key ] = $value;
return true;
} else {
return false;
}
}
/**
* Update a meta value.
* Wrapper for add_field().
*
* @access public
* @since 2.7
* @return bool
*/
public function update_meta( $meta_key, $value ) {
return $this->add_meta( $meta_key, $value );
}
/**
* Add a field value to our submission.
*
* @access public
* @since 2.7
* @return bool
*/
public function add_field( $field_id, $value ) {
$meta_key = '_field_' . $field_id;
if ( update_post_meta( $this->sub_id, $meta_key, $value ) ) {
$this->field[ $field_id ] = $value;
return true;
} else {
return false;
}
}
/**
* Update a field value
*
* @access public
* @since 2.7
* @return bool
*/
public function update_field( $field_id, $value ) {
return $this->add_field( $field_id, $value );
}
/**
* Get a meta value from our submission by meta key
*
* @access public
* @since 2.7
* @return array|bool
*/
public function get_meta( $meta_key ) {
if ( isset ( $this->meta[ $meta_key ] ) ) {
return $this->meta[ $meta_key ];
} else {
return get_post_meta( $this->sub_id, $meta_key, true );
}
}
/**
* Get a field value from our submission by field id
*
* @access public
* @since 2.7
* @return array|bool
*/
public function get_field( $field_id ) {
if ( isset ( $this->fields[ $field_id ] ) ) {
return $this->fields[ $field_id ];
} else {
return get_post_meta( $this->sub_id, '_field_' . $field_id, true );
}
}
/**
* Get a submission from the database, returning all the field data.
*
* @access public
* @since 2.7
* @return array $sub
*/
public function get_all_fields() {
return $this->fields;
}
/**
* Get a submission sequential ID by the post ID.
* This function puts together the prefix, sequential number, and postfix
*
* @access public
* @since 2.7
* @return string $seq_num
*/
public function get_seq_num() {
return apply_filters( 'nf_subs_seq_num', $this->seq_num, $this->sub_id );
}
/**
* Export our current submission.
*
* @access public
* @param array $sub_ids
* @param bool @return
* @since 2.7
* @return void
*/
public function export( $return = false ){
Ninja_Forms()->subs()->export( array( $this->sub_id ) );
}
/**
* Delete this submission
*
* @access public
* @since 2.7
* @return void
*/
public function delete() {
wp_delete_post( $this->sub_id, true );
}
}
\ No newline at end of file
This diff is collapsed.
<?php
/**
* Submissions.
* This class handles creating and exporting submissions.
*
* @package Ninja Forms
* @subpackage Classes/Submissions
* @copyright Copyright (c) 2014, WPNINJAS
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.7
*/
class NF_Subs {
/**
* Get things started
*
* @access public
* @since 2.7