Plugin Directory

Changeset 3791567


Ignore:
Timestamp:
11/08/2026 10:10:06 PM (25 hours ago)
Author:
codemonkeys
Message:

V3.3.7 (MAJOR UPDATE!)

  • Built in free native form builder
  • Gravity Forms import tool for existing forms
  • Native quiz feature with scoring and pass/fail
  • Moved tabs out of main submitted forms view into separate pages to improve performance and improve user experience/navigation
  • Minor style rendering improvements in submitted forms and secure pdf generation
Location:
codemonkeys-hipaa-forms/trunk
Files:
53 added
13 edited

Legend:

Unmodified
Added
Removed
  • codemonkeys-hipaa-forms/trunk/admin-enqueue.php

    r3760825 r3791567  
    55
    66function cm_hipaa_enqueue_admin_scripts( $hook_suffix ) {
    7     if ( 'toplevel_page_hipaa-forms' !== $hook_suffix ) {
     7    if ( 'toplevel_page_hipaa-forms' !== $hook_suffix && ! preg_match( '/_page_cm-hipaa-(forms-list|plugin-settings|log|support)$/', $hook_suffix ) ) {
    88        return;
    99    }
    … …  
    1212    wp_enqueue_style( 'cmHipaaGravityAdminBasicStyle', plugin_dir_url( __FILE__ ) . 'css/gravity-basic.min.css', array(), HIPAAFORMS_CURRENT_VERSION );
    1313    wp_enqueue_style( 'cmHipaaGravityAdminCustomStyle', plugin_dir_url( __FILE__ ) . 'css/gravity-admin.css', array(), HIPAAFORMS_CURRENT_VERSION );
     14    wp_enqueue_style( 'cm-hipaa-native-record', plugin_dir_url( __FILE__ ) . 'css/native-record.css', array(), HIPAAFORMS_CURRENT_VERSION . '.' . filemtime( __DIR__ . '/css/native-record.css' ) );
    1415    wp_enqueue_style( 'cmHipaaGravityAdminPrintStyle', plugin_dir_url( __FILE__ ) . 'css/print.css', array(), HIPAAFORMS_CURRENT_VERSION );
    1516    wp_enqueue_style( 'cmHipaaAdminStyle', plugin_dir_url( __FILE__ ) . 'css/admin-style.css', array(), HIPAAFORMS_CURRENT_VERSION . '.' . filemtime( __DIR__ . '/css/admin-style.css' ) );
    1617
     18    wp_enqueue_style( 'cm-hipaa-form-builders', plugin_dir_url( __FILE__ ) . 'css/form-builders.css', array(), HIPAAFORMS_CURRENT_VERSION );
     19    wp_enqueue_script( 'cm-hipaa-form-builders', plugin_dir_url( __FILE__ ) . 'js/form-builder-settings.js', array(), HIPAAFORMS_CURRENT_VERSION, true );
     20    wp_localize_script( 'cm-hipaa-form-builders', 'hipaaBuilderSettings', array(
     21        'ajaxUrl' => admin_url( 'admin-ajax.php' ),
     22        'nonce' => wp_create_nonce( 'cm-hipaa-admin-nonce' ),
     23    ) );
    1724    wp_enqueue_script( 'jquery-form' );
    1825    wp_enqueue_script( 'cmHipaaAdminBuggyFill', plugin_dir_url( __FILE__ ) . 'js/viewport-units-buggyfill.js', array( 'jquery' ), HIPAAFORMS_CURRENT_VERSION, true );
    1926    wp_enqueue_script( 'cmHipaaAdminBuggyFillHack', plugin_dir_url( __FILE__ ) . 'js/viewport-units-buggyfill.hacks.js', array( 'jquery' ), HIPAAFORMS_CURRENT_VERSION, true );
    20     wp_enqueue_script( 'cmHipaaAdminScript', plugin_dir_url( __FILE__ ) . 'js/admin-script.js', array( 'jquery' ), HIPAAFORMS_CURRENT_VERSION, true );
     27    wp_enqueue_script( 'cmHipaaAdminScript', plugin_dir_url( __FILE__ ) . 'js/admin-script.js', array( 'jquery', 'cm-hipaa-form-builders' ), HIPAAFORMS_CURRENT_VERSION, true );
    2128    wp_enqueue_script( 'cm-hipaa-signature', plugin_dir_url( __FILE__ ) . 'js/jSignature/jSignature.min.noconflict.js', array( 'jquery' ), HIPAAFORMS_CURRENT_VERSION, true );
    2229    wp_enqueue_script( 'cm-hipaa-jquery-print', plugin_dir_url( __FILE__ ) . 'js/printThis.js', array( 'jquery' ), HIPAAFORMS_CURRENT_VERSION, true );
    … …  
    2835        'nonce' => wp_create_nonce( 'cm-hipaa-admin-nonce' ),
    2936        'ajax_url' => admin_url( 'admin-ajax.php' ),
     37        'accountNonce' => wp_create_nonce( 'cm-hipaa-forms-nonce' ),
    3038    ) );
    3139}
  • codemonkeys-hipaa-forms/trunk/admin-page.php

    r3773666 r3791567  
    113113function hipaa_admin_menu() {
    114114    add_menu_page( 'HIPAA Forms', 'HIPAA Forms', 'access_hipaa_forms', 'hipaa-forms.php', 'hipaa_admin_page', 'dashicons-lock', 6  );
     115    add_submenu_page( 'hipaa-forms.php', 'Submitted forms', 'Submitted forms', 'access_hipaa_forms', 'hipaa-forms.php', 'hipaa_admin_page' );
    115116}
    116117add_action( 'admin_menu', 'hipaa_admin_menu' );
     118
     119// Priorities place these around Manage forms (19), Add new form (20) and Captcha Settings (22).
     120function cm_hipaa_plugin_settings_menu() {
     121    add_submenu_page( 'hipaa-forms.php', 'Plugin settings', 'Plugin settings', 'manage_options', 'cm-hipaa-plugin-settings', 'hipaa_admin_page' );
     122}
     123add_action( 'admin_menu', 'cm_hipaa_plugin_settings_menu', 21 );
     124
     125function cm_hipaa_log_support_menu() {
     126    add_submenu_page( 'hipaa-forms.php', 'Log', 'Log', 'manage_options', 'cm-hipaa-log', 'hipaa_admin_page' );
     127    add_submenu_page( 'hipaa-forms.php', 'Support', 'Support', 'access_hipaa_forms', 'cm-hipaa-support', 'hipaa_admin_page' );
     128}
     129add_action( 'admin_menu', 'cm_hipaa_log_support_menu', 23 );
     130
     131function cm_hipaa_admin_section() {
     132    $sections = array( 'cm-hipaa-plugin-settings' => 'settings', 'cm-hipaa-log' => 'log', 'cm-hipaa-support' => 'support' );
     133    $page = isset( $_GET['page'] ) && is_string( $_GET['page'] ) ? $_GET['page'] : '';
     134    return isset( $sections[ $page ] ) ? $sections[ $page ] : 'submitted';
     135}
    117136
    118137
    … …  
    149168        $role = 'hipaa';
    150169    }
     170    $cmHipaaSection = cm_hipaa_admin_section();
    151171
    152172    if($approved == 0) {
    … …  
    156176        echo esc_html($hipaaForms->accessLog($user_id, $user_name, $user_first_name, $user_last_name, $user_email, $user_roles, $approved));
    157177    } else {
    158         // GET FORM BUILDER PLUGIN FIELD VALUE
    159         $formBuilder = esc_attr(get_option('form_builder'));
    160         $formsList = '';
    161178
    162179        // VALIDATE ACCOUNT
    … …  
    211228                }
    212229            }
    213         }
    214 
    215         // SET FORM BUILDER SELECT OPTIONS
    216         $formBuilderOptions = array();
    217 
    218         // CHECK IF CALDERA IS INSTALLED
    219         if (method_exists('Caldera_Forms_Forms', 'get_forms')) {
    220             $calderaSelected = '';
    221             if ($formBuilder == 'caldera') {
    222                 // SET FORM SELECT FIELD AS CALDERA SELECTED
    223                 $calderaSelected = ' selected';
    224 
    225                 // GET LIST OF CALDERA FORMS
    226                 $enabledFormsSettings = get_option('enabled_forms_settings'); // NEW JSON VERSION WITH FORM SETTINGS
    227                 $formsList = $hipaaForms->getCalderaForms($enabledFormsSettings);
    228             }
    229 
    230             $formBuilderOptions[] = '<option value="caldera"' . esc_attr($calderaSelected) . '>Caldera</option>';
    231         }
    232 
    233         // CHECK IF GRAVITY ACTIVE
    234         if (method_exists('RGFormsModel', 'get_forms')) {
    235             $gravitySelected = '';
    236             if ($formBuilder == 'gravity') {
    237                 // SET FORM SELECT FIELD AS GRAVITY SELECTED
    238                 $gravitySelected = ' selected';
    239 
    240                 // GET LIST OF GRAVITY FORMS
    241                 //$gravityEnabledForms = explode(',', esc_attr(get_option('gravity_enabled_form_ids'))); -- DEPRECATED
    242                 $gravityEnabledForms = get_option('enabled_forms_settings'); // NEW JSON VERSION WITH FORM SETTINGS
    243                 $formsList = $hipaaForms->getGravityForms($gravityEnabledForms);
    244             }
    245 
    246             $formBuilderOptions[] = '<option value="gravity"' . esc_attr($gravitySelected) . '>Gravity</option>';
    247         } else {
    248             // OLD WAY OF CHECKING IF GRAVITY ACTIVE JUST TO BE SAFE
    249             if (!function_exists('is_plugin_active') || !function_exists('is_plugin_active_for_network')) {
    250                 require_once(ABSPATH . '/wp-admin/includes/plugin.php');
    251             }
    252             if (is_multisite()) {
    253                 $gravityEnabled = (is_plugin_active_for_network('gravityforms/gravityforms.php') || is_plugin_active('gravityforms/gravityforms.php'));
    254             } else {
    255                 $gravityEnabled = is_plugin_active('gravityforms/gravityforms.php');
    256             }
    257             if ($gravityEnabled == 1) {
    258                 $gravitySelected = '';
    259                 if ($formBuilder == 'gravity') {
    260                     // SET FORM SELECT FIELD AS GRAVITY SELECTED
    261                     $gravitySelected = ' selected';
    262 
    263                     // GET LIST OF GRAVITY FORMS
    264                     //$gravityEnabledForms = explode(',', esc_attr(get_option('gravity_enabled_form_ids'))); -- DEPRECATED
    265                     $gravityEnabledForms = get_option('enabled_forms_settings'); // NEW JSON VERSION WITH FORM SETTINGS
    266                     $formsList = $hipaaForms->getGravityForms($gravityEnabledForms);
    267                 }
    268 
    269                 $formBuilderOptions[] = '<option value="gravity"' . esc_attr($gravitySelected) . '>Gravity</option>';
    270             }
    271         }
    272 
    273         // SET FORM BUILDER SELECT OPTIONS
    274         if (count($formBuilderOptions)) {
    275             $formBuilderSelect = '
    276                 <select id="cm-hipaa-form-builder-select">
    277                     <option value="">None</option>
    278                     ' . implode('', $formBuilderOptions) . '
    279                 </select>
    280             ';
    281         } else {
    282             $formBuilderSelect = '
    283                 <div class="cm-hipaa-forms-no-form-builder">
    284                     No Form Builder Detected - Please install & activate <a href="https://www.gravityforms.com/" target="_blank">Gravity Forms (paid plugin)</a>
    285                 </div>';
    286230        }
    287231
    … …  
    424368
    425369        // GET NOTIFICATION EMAIL
    426         $hipaaNotificationEmail = esc_attr(get_option('hipaa_notification_email_message'));
     370        $hipaaNotificationEmail = cm_hipaa_native_global_message();
    427371        if (!$hipaaNotificationEmail || $hipaaNotificationEmail == '') {
    428             $hipaaNotificationEmail = '<table width="600px" style="border-collapse:collapse;"><tbody><tr><th><b>HIPAA Form Submission</b></th></tr><tr><td style="height:30px"></td></tr><tr><td>Location: {location}</td></tr><tr><td>First Name: {firstname}</td></tr><tr><td style="height:15px"></td></tr><tr><td>Last Name: {lastname}</td></tr><tr><td style="height:15px"></td></tr><tr><td>Email: {email}</td></tr><tr><td style="height:15px"></td></tr><tr><td>Phone: {phone}</td></tr><tr><td style="height:30px"></td></tr><tr><td>Please log into the admin dashboard to view the form.</td></tr><tr><td>Please do not reply to this email</td></tr></tbody></table>';
     372            $hipaaNotificationEmail = cm_hipaa_default_notification_message();
    429373        }
    430374
    … …  
    549493        ?>
    550494        <div class="wrap">
    551         <input type="hidden" id="selected-form-builder" value="<?php echo esc_attr($formBuilder); ?>" />
    552495        <h2>HIPAA Forms</h2>
    553496        <?php echo wp_kses($subscriptionNotice, cm_hipaa_admin_allowed_html()); ?>
    554497        <?php echo wp_kses($updateNotice, cm_hipaa_admin_allowed_html()); ?>
    555498        <div class="cm-hipaa-tabs-wrapper">
    556             <div class="cm-hipaa-tabs">
    557                 <div class="cm-hipaa-tab active" data="tab-1">
    558                     Submitted Forms
    559                 </div>
    560                 <?php if($role == 'administrator') { ?>
    561                     <div class="cm-hipaa-tab" data="tab-2">
    562                         Settings
    563                     </div>
    564                     <div class="cm-hipaa-tab" data="tab-3">
    565                         Log
    566                     </div>
    567                 <?php } ?>
    568                 <div class="cm-hipaa-tab" data="tab-4">
    569                     Support
    570                 </div>
    571             </div>
    572499            <div class="cm-hipaa-tab-content-wrapper">
     500                <?php if ( $cmHipaaSection === 'submitted' ) { ?>
    573501                <!-- SUBMITTED FORMS TAB -->
    574502                <div class="cm-hipaa-tab-content" data="tab-1">
    575                     <h1>Submitted Forms</h1>
     503                    <h1>Submitted forms</h1>
    576504                    <div class="cm-submitted-forms-filters-wrapper">
    577505                        <div class="cm-submitted-forms-filters">
    … …  
    631559                    </div>
    632560                </div>
    633                 <?php if($role == 'administrator') { ?>
     561                <?php } ?>
     562                <?php if ( $role == 'administrator' && $cmHipaaSection === 'settings' ) { ?>
    634563                    <!-- PLUGIN SETTINGS TAB -->
    635564                    <div class="cm-hipaa-tab-content" data="tab-2">
     565                        <h1>Plugin settings</h1>
    636566                        <div class="cm_hipaa_grid_row_nogap cm_hipaa_tour_tab_wrapper">
    637567                            <div class="cm-hipaa-tour-tab-menu cm_hipaa_col_25">
    … …  
    640570                                        <div class="cm-hipaa-tour-tab-link-inner">
    641571                                            <i class="material-icons">settings</i> <span class="cm-hipaa-tab-name">PLUGIN SETTINGS</span>
    642                                         </div>
    643                                     </li>
    644                                     <li data="tour-tab-selected-forms" class="cm-hipaa-tour-tab-link">
    645                                         <div class="cm-hipaa-tour-tab-link-inner">
    646                                             <i class="material-icons">note_add</i> <span class="cm-hipaa-tab-name">FORM SETTINGS</span>
    647572                                        </div>
    648573                                    </li>
    … …  
    748673                                                    <input type="hidden" name="gravity_enabled_form_ids" value="<?php echo esc_attr(get_option('gravity_enabled_form_ids')); ?>" />
    749674                                                    <input type="hidden" name="hipaa_form_css" value="<?php echo esc_attr(get_option('hipaa_form_css')); ?>"/>
    750                                                     <input type="hidden" name="enabled_forms_settings" value="<?php echo esc_attr(get_option('enabled_forms_settings')); ?>" />
    751675                                                    <input type="hidden" name="privacy_notice_method" value="<?php echo esc_attr(get_option('privacy_notice_method')); ?>" />
    752676                                                    <input type="hidden" name="privacy_notice_label" value="<?php echo esc_attr(get_option('privacy_notice_label')); ?>" />
    … …  
    770694                                    </form>
    771695                                </div>
    772                                 <!-- FORM SETTINGS -->
    773                                 <section data="tour-tab-selected-forms" class="cm-hipaa-accordion-tab-link">
    774                                     <div class="cm-hipaa-tour-tab-link-inner">
    775                                         <i class="material-icons">note_add</i> <span class="cm-hipaa-tab-name">FORM SETTINGS</span>
    776                                     </div>
    777                                 </section>
    778                                 <div data="tour-tab-selected-forms" class="cm-hipaa-tour-tab-content">
    779                                     <h1>Current Form Plugin: <?php echo esc_html($formBuilder); ?></h1>
    780                                     <div class="cm-hipaa-form-builder-select-wrapper">
    781                                         Select a Form Builder: <?php echo wp_kses($formBuilderSelect, cm_hipaa_admin_allowed_html()); ?> <i class="material-icons cm-hipaa-setting-info" data-content="form-builder-info" title="More Information">info</i>
    782                                         <div id="cm-hipaa-form-builder-select-notice"></div>
    783                                     </div>
    784                                     <div id="cm-hipaa-forms-available-forms-wrapper">
    785                                         <?php echo wp_kses($formsList, cm_hipaa_admin_allowed_html()); ?>
    786                                     </div>
    787                                 </div>
    788696                                <!-- HIPAA USER CAPABILITIES -->
    789697                                <section data="tour-tab-user-role" class="cm-hipaa-accordion-tab-link">
    … …  
    844752                                    <div class="cm-hipaa-notification-input-wrapper">
    845753                                        <label for="cm-hipaa-notification-input">Notification Email Message:</label>
    846                                         <textarea id="cm-hipaa-notification-input" placeholder="Default Notification Email Message..."><?php echo esc_textarea(html_entity_decode($hipaaNotificationEmail)); ?></textarea>
     754                                        <textarea id="cm-hipaa-notification-input" placeholder="Default Notification Email Message..."><?php echo esc_textarea($hipaaNotificationEmail); ?></textarea>
    847755                                    </div>
    848756                                    <div id="cm-hipaa-notification-email-submit" class="cm-button">
    … …  
    1007915                    </div>
    1008916                <?php } ?>
     917                <?php if ( $role == 'administrator' && $cmHipaaSection === 'log' ) { ?>
    1009918                <div class="cm-hipaa-tab-content" data="tab-3">
    1010                     <h1>Access Logs</h1>
     919                    <h1>Log</h1>
    1011920                    <div class="cm-hipaa-forms-logs-filters-wrapper">
    1012921                        <div class="cm-hipaa-forms-logs-filters cm_hipaa_grid_row">
    … …  
    1037946                    </div>
    1038947                </div>
     948                <?php } ?>
     949                <?php if ( $cmHipaaSection === 'support' ) { ?>
    1039950                <div class="cm-hipaa-tab-content" data="tab-4">
     951                    <h1>Support</h1>
    1040952                    <div class="cm_hipaa_grid_row_nogap cm_hipaa_tour_tab_wrapper">
    1041953                        <div class="cm-hipaa-tour-tab-menu cm_hipaa_col_25">
    … …  
    10991011                                                <h4>UPDATE SETTINGS</h4>
    11001012                                                <p>
    1101                                                     Now that you have your license key and Caldera or Gravity Forms installed and activated, go to the "Settings" tab & add your license key.  Also select your preferred compatible form builder plugin (ie. Caldera or Gravity) & set your preferred time zone.
    1102                                                 </p>
    1103                                                 <p>
    1104                                                     Next click on the "user permissions" sub-tab (we'll come back to the "form settings" sub-tab later).  You have the option to give users a HIPAA user role if you have staff that you want to give access to the submitted forms.  We highly recommend giving them the HIPAA user role as opposed to making them administrators.  From this tab you can check which permissions your staff with the HIPAA user role should have beyond just accessing the submitted forms.
     1013                                                    Now that you have your license key and Caldera or Gravity Forms installed and activated, go to Plugin settings & add your license key.  Also select your preferred compatible form builder plugin (ie. Caldera or Gravity) & set your preferred time zone.
     1014                                                </p>
     1015                                                <p>
     1016                                                    Next click on the "user permissions" sub-tab.  You have the option to give users a HIPAA user role if you have staff that you want to give access to the submitted forms.  We highly recommend giving them the HIPAA user role as opposed to making them administrators.  From this tab you can check which permissions your staff with the HIPAA user role should have beyond just accessing the submitted forms.
    11051017                                                </p>
    11061018                                                <p>
    … …  
    12281140                                                </p>
    12291141                                                <p>
    1230                                                     This is restricted by design as it would open up the ability to pass E-PHI from the form to the email notification instantly making your form non-compliant.  Instead you need to build your email notification message from the HIPAA Web Forms plugin under the settings tab->notifications sub-tab or within the selected form settings.  From this interface we do allow a few magic tags restricted to non-health data like form name, name, phone, email, location, etc.
     1142                                                    This is restricted by design as it would open up the ability to pass E-PHI from the form to the email notification instantly making your form non-compliant.  Instead you need to build your email notification message from the HIPAA Web Forms plugin under Plugin settings->notifications sub-tab or within the selected form settings.  From this interface we do allow a few magic tags restricted to non-health data like form name, name, phone, email, location, etc.
    12311143                                                </p>
    12321144                                            </li>
    … …  
    17421654                                                </p>
    17431655                                                <p>
    1744                                                     From the HIPAA Forms plugin interface click on the settings tab and then select the "user permissions" sub-tab.
     1656                                                    From the HIPAA Forms menu open Plugin settings and then select the "user permissions" sub-tab.
    17451657                                                </p>
    17461658                                                <p>
    … …  
    17641676                                                </p>
    17651677                                                <p>
    1766                                                     You will be unable to use the HIPAA FORMS Service until you have signed the BAA with Code Monkeys LLC (the developers of the service) and will receive a notice to do so within the "submitted forms" tab as well as in the settings tab until it has been signed.
     1678                                                    You will be unable to use the HIPAA FORMS Service until you have signed the BAA with Code Monkeys LLC (the developers of the service) and will receive a notice to do so on the Submitted forms page as well as in Plugin settings until it has been signed.
    17671679                                                </p>
    17681680                                                <p>
    … …  
    18421754                                                </p>
    18431755                                                <p>
    1844                                                     From the HIPAA Forms plugin form settings you would set the submit success handler as "success callback" and in the first field for function name put myFormCallback.  In this example you're not passing any parameters to the function so you can just leave the second input empty.
     1756                                                    From the form's settings on the Manage forms page you would set the submit success handler as "success callback" and in the first field for function name put myFormCallback.  In this example you're not passing any parameters to the function so you can just leave the second input empty.
    18451757                                                </p>
    18461758                                                <p>
    … …  
    18551767                                                </p>
    18561768                                                <p>
    1857                                                     Click on the "Settings" tab above and then click on the "Forms CSS" sub-tab.
     1769                                                    Open Plugin settings and then click on the "Forms CSS" sub-tab.
    18581770                                                </p>
    18591771                                                <p>
    … …  
    20361948                    </div>
    20371949                </div>
     1950                <?php } ?>
    20381951            </div>
    20391952            <!-- SETTINGS INFO MODALS -->
    … …  
    20501963                        </p>
    20511964                        <p>
    2052                             If you have already purchased a subscription your license key should have been emailed to you.  If you have not received the email with your license key please submit a support ticket from the support tab or call 715.941.1040.
     1965                            If you have already purchased a subscription your license key should have been emailed to you.  If you have not received the email with your license key please submit a support ticket from the Support page or call 715.941.1040.
    20531966                        </p>
    20541967                        <p>
    … …  
    20962009                        </p>
    20972010                        <p>
    2098                             After a form builder has been selected all of the forms that have been created will appear within the "Form Settings" tab below where you can select which forms you wish to be HIPAA compliant as well as set some form specific options.
     2011                            After a form builder has been selected all of the forms that have been created will appear on the Manage forms page where you can select which forms you wish to be HIPAA compliant as well as set some form specific options.
    20992012                        </p>
    21002013                    </div>
    … …  
    22472160                        </p>
    22482161                        <p>
    2249                             SEE "HOW DO I CREATE A CALLBACK?" IN THE FAQ SECTION UNDER THE SUPPORT TAB FOR HOW TO USE THIS
     2162                            SEE "HOW DO I CREATE A CALLBACK?" IN THE FAQ SECTION OF THE SUPPORT PAGE FOR HOW TO USE THIS
    22502163                        </p>
    22512164                    </div>
    … …  
    23132226                        </p>
    23142227                        <p>
    2315                             These master settings can be over-ridden from a specific form's settings options under the "Form Settings" sub-tab above & clicking on the triangle icon to expand the form setting options.
     2228                            These master settings can be over-ridden from a specific form's settings options on the Manage forms page by clicking the triangle icon to expand the form setting options.
    23162229                        </p>
    23172230                        <p>
  • codemonkeys-hipaa-forms/trunk/ajax-functions.php

    r3747086 r3791567  
    206206        return false;
    207207    }
    208     $configuredBuilder = get_option('form_builder');
     208    if (strpos($formId, 'cmhf') === 0 || strpos($formId, 'gform_cmhf') === 0) {
     209        return ($builder === '' || $builder === 'native') && function_exists('cm_hipaa_native_enabled') ? cm_hipaa_native_enabled($formId) : false;
     210    }
    209211    if ($builder === '') {
    210212        $builder = strpos($formId, 'gform_') === 0 ? 'gravity' : 'caldera';
    211213    }
    212     if ($configuredBuilder !== $builder || !in_array($builder, array('caldera', 'gravity'), true)) {
     214    if (!in_array($builder, array('caldera', 'gravity'), true)) {
    213215        return false;
    214216    }
    … …  
    225227        return false;
    226228    }
    227     $matched = false;
    228     foreach ($settings as $setting) {
    229         if (!is_object($setting) || !isset($setting->form_builder, $setting->enabled, $setting->id)) {
    230             continue;
    231         }
    232         if ($setting->form_builder === $builder && $setting->enabled === 'yes' &&
    233             is_scalar($setting->id) && (string) $setting->id === $savedId) {
    234             if ($matched !== false) {
    235                 return false;
    236             }
    237             $matched = $setting;
    238         }
    239     }
    240     return $matched;
     229    $savedId = cm_hipaa_form_identity($builder, $savedId);
     230    $index = $savedId === false ? null : cm_hipaa_form_governing_row($settings, $builder, $savedId);
     231    if (!is_int($index) || !is_object($settings[$index]) || !isset($settings[$index]->enabled) ||
     232        $settings[$index]->enabled !== 'yes') {
     233        return false;
     234    }
     235    return $settings[$index];
    241236}
    242237
    … …  
    275270            continue;
    276271        }
    277         if ($builder === 'gravity') {
     272        if ($builder === 'native') {
     273            $role = isset($field['cmHipaa']['role']) ? $field['cmHipaa']['role'] : '';
     274            $isLocation = $role === 'office_location';
     275            $isUser = $role === 'selected_user';
     276            $choices = isset($field['choices']) ? $field['choices'] : array();
     277        } elseif ($builder === 'gravity') {
    278278            $classes = isset($field['cssClass']) && is_string($field['cssClass']) ? preg_split('/\s+/', trim($field['cssClass'])) : array();
    279279            $isLocation = in_array('hipaa_forms_office_location', $classes, true);
    … …  
    293293        }
    294294        if ($isUser) {
    295             $choice = cm_hipaa_saved_choice($choices, $selectedUser);
    296             if ($choice !== '' && ctype_digit($choice)) {
     295            $submitted_users = $builder === 'gravity' && isset($field['type']) &&
     296                $field['type'] === 'multiselect' && is_array($selectedUser)
     297                ? $selectedUser : array($selectedUser);
     298            $selected_ids = array();
     299            foreach ($submitted_users as $submitted_user) {
     300                $choice = cm_hipaa_saved_choice($choices, $submitted_user);
     301                if ($choice === '' || !ctype_digit($choice)) {
     302                    $selected_ids = array();
     303                    break;
     304                }
    297305                $user = get_user_by('id', (int) $choice);
    298                 if ($user && user_can($user, 'access_hipaa_forms')) {
    299                     $routing['selected_user'] = $choice;
    300                 }
    301             }
     306                if (!$user || (!user_can($user, 'access_hipaa_forms') &&
     307                    !($builder === 'native' && user_can($user, 'manage_options')))) {
     308                    $selected_ids = array();
     309                    break;
     310                }
     311                $selected_ids[] = $choice;
     312            }
     313            $routing['selected_user'] = implode(',', array_unique($selected_ids));
    302314        }
    303315    }
    … …  
    355367
    356368                // SAVE TRANSIENT SESSION
    357                 set_transient('cm_hipaa_session_' . $sessionId, array(
     369                $sessionData = array(
    358370                    'form_id' => $formId,
    359371                    'created' => time()
    360                 ), 6 * HOUR_IN_SECONDS);
     372                );
     373                if (preg_match('/^cmhf[1-9][0-9]{0,15}$/D', $formId)) {
     374                    $native = cm_hipaa_native_published($formId);
     375                    $addons = isset($results['add_ons']) && is_string($results['add_ons']) ? array_map('trim', explode(',', $results['add_ons'])) : (isset($results['add_ons']) && is_array($results['add_ons']) ? $results['add_ons'] : array());
     376                    $sessionData['native_fileupload'] = in_array('fileupload', $addons, true) && !(isset($results['product'], $results['this_months_submissions']) && $results['product'] === 'basic' && $results['this_months_submissions'] >= 25);
     377                    $sessionData['native_revision'] = $native ? $native['cmHipaa']['publishedRevision'] : 0;
     378                }
     379                set_transient('cm_hipaa_session_' . $sessionId, $sessionData, 6 * HOUR_IN_SECONDS);
    361380
    362381                // PUSH SESSION ID TO RESULTS ARRAY
    … …  
    11981217/* UPDATE AVAILABLE FORMS */
    11991218function cm_hipaa_update_available_forms() {
    1200     if (!current_user_can('manage_options')) {
    1201         wp_send_json(array('error' => 'You are not authorized to perform this action.'), 403);
    1202         return;
    1203     }
    1204 
    1205     if (isset($_REQUEST)) {
    1206         $nonce = isset($_REQUEST['nonce']) ? sanitize_text_field(wp_unslash($_REQUEST['nonce'])) : '';
    1207         $formBuilder = isset($_REQUEST['form_builder']) ? sanitize_text_field(wp_unslash($_REQUEST['form_builder'])) : '';
    1208 
    1209         if(!wp_verify_nonce($nonce, 'cm-hipaa-admin-nonce')) {
    1210             $results = 'Nonce expired, please refresh the page.  If the error persists please contact the site administrator';
    1211         } else {
    1212             // GET LIST OF GRAVITY FORMS
    1213             $hipaaForms = new cmHipaaForms;
    1214 
    1215             if($formBuilder == 'caldera') {
    1216                 $enabledForms = get_option('enabled_forms_settings'); // NEW JSON VERSION WITH FORM SETTINGS
    1217                 $formsList = $hipaaForms->getCalderaForms($enabledForms);
    1218             } else if($formBuilder == 'gravity') {
    1219                 $enabledForms = get_option('enabled_forms_settings'); // NEW JSON VERSION WITH FORM SETTINGS
    1220                 $formsList = $hipaaForms->getGravityForms($enabledForms);
    1221             } else {
    1222                 $formsList = 'The selected form not form';
    1223             }
    1224 
    1225             $results = $formsList;
    1226         }
    1227 
    1228         echo wp_kses($results, cm_hipaa_ajax_allowed_html());
    1229     }
    1230 
    1231     die();
     1219    if ( ! current_user_can( 'manage_options' ) ) {
     1220        wp_send_json( array( 'error' => 'You must be a site administrator to view form settings.' ), 403 );
     1221        return;
     1222    }
     1223    $nonce = isset( $_POST['nonce'] ) && is_string( $_POST['nonce'] ) ? wp_unslash( $_POST['nonce'] ) : '';
     1224    if ( ! wp_verify_nonce( $nonce, 'cm-hipaa-admin-nonce' ) ) {
     1225        wp_send_json( array( 'error' => 'Reload this page and try again.' ), 403 );
     1226        return;
     1227    }
     1228    $builder = isset( $_POST['form_builder'] ) && is_string( $_POST['form_builder'] ) ? wp_unslash( $_POST['form_builder'] ) : '';
     1229    if ( ! in_array( $builder, array( 'native', 'gravity', 'caldera' ), true ) ) {
     1230        wp_send_json( array( 'error' => 'Choose a form builder.' ), 400 );
     1231        return;
     1232    }
     1233    wp_send_json( array( 'content' => cm_hipaa_builder_content( $builder ) ) );
    12321234}
    12331235add_action( 'wp_ajax_cm_hipaa_update_available_forms', 'cm_hipaa_update_available_forms' );
    … …  
    12651267/* GET FILE UPLOAD URL */
    12661268function cm_hipaa_get_file_upload_url() {
     1269    if (isset($_REQUEST['form_id']) && is_string($_REQUEST['form_id']) && (strpos($_REQUEST['form_id'], 'cmhf') === 0 || strpos($_REQUEST['form_id'], 'gform_cmhf') === 0)) {
     1270        cm_hipaa_native_upload_url(); return;
     1271    }
    12671272    if (isset($_REQUEST)) {
    12681273        $nonce = isset($_REQUEST['nonce']) ? sanitize_text_field(wp_unslash($_REQUEST['nonce'])) : '';
    … …  
    21412146        $selectedUser = '';
    21422147        if(isset($_REQUEST['selectedUser'])) {
    2143             $selectedUser = sanitize_text_field(wp_unslash($_REQUEST['selectedUser']));
     2148            $selectedUser = is_array($_REQUEST['selectedUser'])
     2149                ? map_deep(wp_unslash($_REQUEST['selectedUser']), 'sanitize_text_field')
     2150                : sanitize_text_field(wp_unslash($_REQUEST['selectedUser']));
    21442151        }
    21452152        $formNotificationOption = isset($formOptions->notification_option) ? $formOptions->notification_option : '';
  • codemonkeys-hipaa-forms/trunk/css/admin-style.css

    r3782901 r3791567  
    11/**
    22 * Created by codemonkeys on 7/16/2018.
    3  * V3.3.6
     3 * V3.3.7
    44 */
    55
    … …  
    634634    border-bottom: 1px solid #444;
    635635    font-weight: 600;
     636}
     637
     638.cm-hipaa-submitted-forms > thead td,
     639.cm-hipaa-submitted-form > td {
     640    overflow-wrap: anywhere;
     641}
     642
     643@media screen and (max-width: 782px) {
     644    .cm-hipaa-submitted-forms,
     645    .cm-hipaa-submitted-forms > tbody {
     646        display: block;
     647    }
     648
     649    /* Keep the column headings available while each record shows its own labels. */
     650    .cm-hipaa-submitted-forms > thead {
     651        position: absolute;
     652        width: 1px;
     653        height: 1px;
     654        overflow: hidden;
     655        clip-path: inset(50%);
     656        white-space: nowrap;
     657    }
     658
     659    .cm-hipaa-submitted-forms > tbody > .cm-hipaa-submitted-form {
     660        display: grid;
     661        grid-template-columns: repeat(2, minmax(0, 1fr));
     662        margin-top: 16px;
     663        border: 1px solid #bbb;
     664        text-align: left;
     665    }
     666
     667    .cm-hipaa-submitted-form > td {
     668        min-width: 0;
     669        border-bottom: 0;
     670    }
     671
     672    .cm-hipaa-submitted-form > td:first-child,
     673    .cm-hipaa-submitted-form > td:nth-child(2),
     674    .cm-hipaa-submitted-form > td:nth-child(5) {
     675        grid-column: 1 / -1;
     676    }
     677
     678    .cm-hipaa-submitted-form > td::before {
     679        display: block;
     680        margin-bottom: 4px;
     681        font-weight: 600;
     682    }
     683
     684    .cm-hipaa-submitted-form > td:nth-child(2)::before {
     685        content: "Office location";
     686    }
     687
     688    .cm-hipaa-submitted-form > td:nth-child(3)::before {
     689        content: "First name";
     690    }
     691
     692    .cm-hipaa-submitted-form > td:nth-child(4)::before {
     693        content: "Last name";
     694    }
     695
     696    .cm-hipaa-submitted-form > td:nth-child(5)::before {
     697        content: "Form name";
     698    }
     699
     700    .cm-hipaa-submitted-form > td:nth-child(6)::before {
     701        content: "Submission date";
     702    }
     703
     704    .cm-hipaa-submitted-form > td:nth-child(7)::before {
     705        content: "PDF";
     706    }
     707
     708    .cm-hipaa-submitted-form .cm-hipaa-submitted-form-options {
     709        display: flex;
     710        flex-wrap: wrap;
     711        gap: 12px;
     712    }
     713
     714    .cm-hipaa-submitted-form .cm-hipaa-submitted-form-options > div {
     715        margin-right: 0;
     716    }
     717
     718    .cm-hipaa-submitted-form .cm-hipaa-generate-pdf-modal-button {
     719        box-sizing: border-box;
     720        max-width: 100%;
     721    }
     722
     723    .cm-hipaa-submitted-forms > tbody > .cm-hipaa-submitted-form-fields-row,
     724    .cm-hipaa-submitted-form-fields-row > td {
     725        display: block;
     726        width: 100%;
     727    }
    636728}
    637729
  • codemonkeys-hipaa-forms/trunk/css/style.css

    r3782901 r3791567  
    11/**
    22 * Created by codemonkeys on 7/16/2018.
    3  * V3.3.6
     3 * V3.3.7
    44 */
    55
  • codemonkeys-hipaa-forms/trunk/enqueue.php

    r3747086 r3791567  
    99}
    1010
     11function cm_hipaa_public_legacy_id( $builder, $id ) {
     12    if ( ! is_string( $id ) && ! is_int( $id ) ) {
     13        return false;
     14    }
     15    $id = (string) $id;
     16    if ( $builder === 'gravity' ) {
     17        return preg_match( '/^(?:gform_)?([1-9][0-9]{0,15})$/D', $id, $match ) ? $match[1] : false;
     18    }
     19    return $builder === 'caldera' && preg_match( '/^[A-Za-z0-9_-]{1,128}$/D', $id ) ? $id : false;
     20}
     21
     22function cm_hipaa_public_settings_state() {
     23    $refused = array( 'readable' => false, 'rows' => array() );
     24    if ( function_exists( 'cm_hipaa_form_setting_snapshot' ) ) {
     25        $snapshot = cm_hipaa_form_setting_snapshot( 'caldera' );
     26        if ( is_wp_error( $snapshot ) || ! is_array( $snapshot ) || ! array_key_exists( 'raw', $snapshot ) ) {
     27            return $refused;
     28        }
     29        $raw = $snapshot['raw'];
     30    } else {
     31        $raw = get_option( 'enabled_forms_settings' );
     32    }
     33    if ( $raw === false || $raw === null || $raw === '' ) {
     34        return array( 'readable' => true, 'rows' => array() );
     35    }
     36    if ( ! is_string( $raw ) ) {
     37        return $refused;
     38    }
     39    $decoded = json_decode( $raw );
     40    if ( ! is_array( $decoded ) || JSON_ERROR_NONE !== json_last_error() ) {
     41        return $refused;
     42    }
     43    $rows = array();
     44    foreach ( $decoded as $row ) {
     45        if ( ! is_object( $row ) ) {
     46            continue;
     47        }
     48        if ( cm_hipaa_form_row_unlabeled( $row ) ) {
     49            // cm_hipaa_form_governing_row and cmHipaaPublicFormRoute decide which forms this row applies to.
     50            $rows[] = clone $row;
     51            continue;
     52        }
     53        if ( $row->form_builder === 'native' ) {
     54            continue;
     55        }
     56        $id = isset( $row->id ) ? cm_hipaa_public_legacy_id( $row->form_builder, $row->id ) : false;
     57        if ( $id === false || ! isset( $row->enabled ) || ! in_array( $row->enabled, array( 'yes', 'no' ), true ) ) {
     58            continue;
     59        }
     60        $copy = clone $row;
     61        $copy->id = $id;
     62        $rows[] = $copy;
     63    }
     64    return array( 'readable' => true, 'rows' => $rows );
     65}
     66
     67function cm_hipaa_public_legacy_csv( $builder ) {
     68    $value = get_option( $builder . '_enabled_form_ids' );
     69    return is_string( $value ) ? array_map( 'trim', explode( ',', $value ) ) : array();
     70}
     71
     72function cm_hipaa_public_legacy_enabled( $builder, $id, $state ) {
     73    $id = cm_hipaa_public_legacy_id( $builder, $id );
     74    if ( $id === false || ! $state['readable'] ) {
     75        return false;
     76    }
     77    $index = cm_hipaa_form_governing_row( $state['rows'], $builder, $id );
     78    if ( $index !== null ) {
     79        return $index !== false && $state['rows'][ $index ]->enabled === 'yes';
     80    }
     81    foreach ( cm_hipaa_public_legacy_csv( $builder ) as $legacy_id ) {
     82        if ( cm_hipaa_public_legacy_id( $builder, $legacy_id ) === $id ) {
     83            return true;
     84        }
     85    }
     86    return false;
     87}
     88
     89function cm_hipaa_public_needs_legacy_assets( $state ) {
     90    if ( get_option( 'load_css_js_conditionally' ) !== 'enabled' || ! $state['readable'] ) {
     91        return true;
     92    }
     93    $caldera_ids = cm_hipaa_public_legacy_csv( 'caldera' );
     94    foreach ( $state['rows'] as $row ) {
     95        if ( cm_hipaa_form_row_unlabeled( $row ) ? isset( $row->id ) : $row->form_builder === 'caldera' ) {
     96            $caldera_ids[] = $row->id;
     97        }
     98    }
     99    foreach ( $caldera_ids as $id ) {
     100        if ( cm_hipaa_public_legacy_enabled( 'caldera', $id, $state ) ) {
     101            return true;
     102        }
     103    }
     104    if ( ! class_exists( 'GFCommon' ) || ! is_singular() || ! method_exists( 'GFCommon', 'get_base_path' ) ) {
     105        return false;
     106    }
     107    $display_file = GFCommon::get_base_path() . '/form_display.php';
     108    if ( ! is_file( $display_file ) ) {
     109        return false;
     110    }
     111    require_once $display_file;
     112    if ( ! method_exists( 'GFFormDisplay', 'parse_forms' ) ) {
     113        return false;
     114    }
     115    $post = get_queried_object();
     116    if ( ! is_object( $post ) || ! isset( $post->post_content ) || ! is_string( $post->post_content ) ) {
     117        return false;
     118    }
     119    GFFormDisplay::parse_forms( $post->post_content, $forms, $blocks );
     120    foreach ( is_array( $forms ) ? array_keys( $forms ) : array() as $id ) {
     121        if ( cm_hipaa_public_legacy_enabled( 'gravity', $id, $state ) ) {
     122            return true;
     123        }
     124    }
     125    return false;
     126}
     127
    11128//* ENQUEUE FRONT END AJAX JAVASCRIPT
    12129function cm_hipaa_enqueue_scripts() {
     130    $public_state = cm_hipaa_public_settings_state();
     131    if ( ! cm_hipaa_public_needs_legacy_assets( $public_state ) ) {
     132        return;
     133    }
    13134    // ENQUEUE GOOGLE MATERIAL.IO ICONS
    14135    wp_enqueue_style( 'materialIcons', plugin_dir_url( __FILE__ ) . 'css/material-icons.css', array(), HIPAAFORMS_CURRENT_VERSION );
    … …  
    40161    $calderaEnabledForms = json_encode(explode(',', esc_attr(get_option('caldera_enabled_form_ids'))));
    41162    $gravityEnabledForms = json_encode(explode(',', esc_attr(get_option('gravity_enabled_form_ids'))));
    42     $enabledFormsSettings = get_option('enabled_forms_settings'); // NEW JSON VERSION WITH FORM SETTINGS
    43 
    44163    $newDecodedSettings = [];
    45     $decodedSettings = json_decode($enabledFormsSettings);
     164    $decodedSettings = $public_state['rows'];
    46165    $gravityVersion = '';
    47166    if(is_array($decodedSettings)) {
    48167        foreach($decodedSettings as $decodedSetting) {
     168            if (isset($decodedSetting->form_builder) && $decodedSetting->form_builder === 'native') {
     169                continue;
     170            }
    49171            // REMOVE EMAILS AND ANY OTHER DATA NOT WANTED IN THE WEB BROWSER
    50172            $newDecodedSetting = [];
    51173            //var_dump($decodedSetting);
    52174            foreach($decodedSetting as $key => $value){
    53                 if($key !== "notification_from_name" && $key !== "notification_from_email" && $key !== "notification_sendto" && $key !== "notification_subject" && $key !== "notification_message"){
     175                if($key !== "notification_from_name" && $key !== "notification_from_email" && $key !== "notification_sendto" && $key !== "notification_subject" && $key !== "notification_message" && strpos((string) $key, '_cm_') !== 0){
    54176                    $newDecodedSetting[$key] = $value;
    55177                }
    … …  
    57179            $newDecodedSettings[] = $newDecodedSetting;
    58180
    59             if($decodedSetting->form_builder == 'gravity' && $decodedSetting->enabled == 'yes') {
     181            $gravity_id = isset( $decodedSetting->id ) ? cm_hipaa_public_legacy_id( 'gravity', $decodedSetting->id ) : false;
     182            if( ( cm_hipaa_form_row_unlabeled( $decodedSetting ) || $decodedSetting->form_builder === 'gravity' ) && $gravity_id !== false &&
     183                cm_hipaa_public_legacy_enabled( 'gravity', $gravity_id, $public_state ) && class_exists( 'GFCommon' )) {
    60184                wp_enqueue_style(
    61185                    'custom-gravity-style',
    … …  
    65189                );
    66190                $custom_css = '
    67                         #gform_' . absint( $decodedSetting->id ) . ' .gform_fileupload_multifile {
     191                        #gform_' . absint( $gravity_id ) . ' .gform_fileupload_multifile {
    68192                            display: none;
    69193                        }
    … …  
    88212        //'enabledFormsSettings' => $enabledFormsSettings, OLD FORMSETTINGS
    89213        'enabledFormsSettings' => json_encode($newDecodedSettings),
     214        'formSettingsReadable' => $public_state['readable'] ? 'yes' : 'no',
    90215        'privacyNoticeMethod' => esc_attr(get_option('privacy_notice_method')),
    91216        'privacyNoticeLabel' => esc_attr(get_option('privacy_notice_label')),
  • codemonkeys-hipaa-forms/trunk/hipaa-forms.php

    r3782901 r3791567  
    1010 * Plugin URI: https://www.hipaaforms.online
    1111 * Description: HIPAA Compliant Forms
    12  * Version: 3.3.6
     12 * Version: 3.3.7
     13 * Requires at least: 6.0
    1314 * Author: Code Monkeys LLC
    1415 * Author URI: https://www.codemonkeysllc.com
    … …  
    2122}
    2223
     24require_once plugin_dir_path(__FILE__) . 'includes/activation.php';
     25register_activation_hook(__FILE__, 'cm_hipaa_activate');
     26
    2327//* REQUIRE ADMIN ENQUEUE FILE
    2428require(plugin_dir_path(__FILE__) . 'admin-enqueue.php');
    2529
    26 if(esc_attr(get_option('form_builder')) == 'gravity' && esc_attr(get_option('load_css_js_conditionally')) == 'enabled') {
    27 //* CHECK IF GRAVITY FORM IS LOADED ON PAGE
    28     add_filter('wp', function () {
    29         if (!class_exists('GFCommon') || !is_singular()) {
    30             return;
    31         }
    32 
    33         require_once(GFCommon::get_base_path() . '/form_display.php');
    34         GFFormDisplay::parse_forms(get_queried_object()->post_content, $forms, $blocks);
    35 
    36         $cm_hipaa_enabledFormsSettings = json_decode(get_option('enabled_forms_settings'));
    37 
    38         if (is_array($cm_hipaa_enabledFormsSettings) && is_array($forms)) {
    39             // GET HIPAA ENABLED GRAVITY FORM ID'S
    40             $enabledFormIds = array();
    41             foreach ($cm_hipaa_enabledFormsSettings as $enabledFormSettings) {
    42                 if($enabledFormSettings->enabled == 'yes') {
    43                     array_push($enabledFormIds, $enabledFormSettings->id);
    44                 }
    45             }
    46 
    47             // CHECK IF ANY FORMS LOADED ON CURRENT PAGE MATCH ENABLED HIPAA FORM ID
    48             foreach ($forms as $index => $form) {
    49                 if (in_array($index, $enabledFormIds)) {
    50                     //* REQUIRE FRONTEND ENQUEUE FILE TO LOAD CSS & JS IF GRAVITY FORM ON PAGE IS HIPAA ENABLED (PREVENTS LOADING ON EVERY PAGE IF NOT NEEDED)
    51                     require(plugin_dir_path(__FILE__) . 'enqueue.php');
    52 
    53                     return;
    54                 }
    55             }
    56         }
    57     });
    58 } else {
    59     //* REQUIRE FRONTEND ENQUEUE FILE TO LOAD CSS & JS (WILL LOAD ON EVERY PAGE, NEEDED IF SOMEONE STILL USING DEPRECATED CALDERA)
    60     require(plugin_dir_path(__FILE__) . 'enqueue.php');
    61 }
     30require_once plugin_dir_path( __FILE__ ) . 'enqueue.php';
    6231
    6332//* REQUIRE HIPAA FORMS OPTIONS
    … …  
    7039require(plugin_dir_path(__FILE__) . 'includes/record-access.php');
    7140require(plugin_dir_path(__FILE__) . 'ajax-functions.php');
     41require(plugin_dir_path(__FILE__) . 'includes/native-forms.php');
    7242
    7343//* REQUIRE USER ROLE
    … …  
    8959$cm_hipaa_decodedSettings = json_decode($cm_hipaa_enabledFormsSettings);
    9060if(is_array($cm_hipaa_decodedSettings)) {
    91     foreach($cm_hipaa_decodedSettings as $cm_hipaa_decodedSetting) {
    92         if($cm_hipaa_decodedSetting->form_builder == 'gravity' && $cm_hipaa_decodedSetting->enabled == 'yes') {
     61    // cm_hipaa_form_enabled_gravity_ids applies the shared saved-row rule from includes/form-builders.php.
     62    foreach(cm_hipaa_form_enabled_gravity_ids($cm_hipaa_decodedSettings) as $cm_hipaa_gravityFormId) {
     63        if($cm_hipaa_gravityFormId !== '') {
    9364            // REMOVE GRAVITY SUBMIT BUTTON FOR ENABLED FORMS
    94             add_filter( 'gform_submit_button_' . $cm_hipaa_decodedSetting->id, '__return_false', 9999 );
     65            add_filter( 'gform_submit_button_' . $cm_hipaa_gravityFormId, '__return_false', 9999 );
    9566
    9667            // CATCH ANY HIPAA FORM SUBMITTED TO GRAVITY VALIDATION (THIS IS A FALLBACK, AND SHOULD NEVER ACTUALLY RUN)
    97             add_filter( 'gform_validation_' . $cm_hipaa_decodedSetting->id, function($validation_result){
     68            add_filter( 'gform_validation_' . $cm_hipaa_gravityFormId, function($validation_result){
    9869                $form  = $validation_result['form'];
    9970
  • codemonkeys-hipaa-forms/trunk/includes/class-cm-hipaa.php

    r3782901 r3791567  
    33    exit;
    44}
     5require_once __DIR__ . '/native-entry-view.php';
    56/**
    67 * Created by Code Monkeys LLC
    … …  
    371372        // Keep intended form markup, but remove browser-executable markup/attributes before admin JS inserts it with .html().
    372373        $html = self::formatSubmittedPhoneHtml($html);
     374        $html = cm_hipaa_native_format_entry_html($html);
    373375        $html = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', '', $html);
    374376
    … …  
    404406
    405407    /*** GET USERS WITH ADMIN OR HIPAA ROLES ***/
     408    // Everyone a selected-user entry can be routed to, which the router checks by capability, not role.
    406409    private function getApprovedUsers() {
    407410        $users = array();
    408         $roles = array('administrator', 'hipaa_forms');
    409 
    410         foreach ($roles as $role) {
     411
     412        foreach (array('access_hipaa_forms', 'manage_options') as $capability) {
    411413            $users_query = new WP_User_Query(array(
    412414                'fields' => 'all_with_meta',
    413                 'role' => $role,
     415                'capability' => $capability,
    414416                'orderby' => 'display_name'
    415417            ));
    416             $results = $users_query->get_results();
    417             if ($results) {
    418                 $users = array_merge($users, $results);
    419             }
    420         }
     418            foreach ((array) $users_query->get_results() as $user) {
     419                $users[$user->ID] = $user;
     420            }
     421        }
     422        usort($users, function ($a, $b) {
     423            return strcasecmp($a->display_name, $b->display_name);
     424        });
    421425
    422426        return $users;
    … …  
    15851589
    15861590            $licenseKey = esc_attr(get_option('license_key'));
    1587             $customCss = esc_attr(get_option('hipaa_form_css'));
     1591            $customCss = cm_hipaa_sanitize_css_setting(
     1592                get_option( 'hipaa_form_css', '' )
     1593            );
    15881594            $timeZone = esc_attr(get_option('time_zone'));
    15891595
    … …  
    16641670            $enabledForms = json_decode(trim(wp_strip_all_tags(get_option('enabled_forms_settings'))));
    16651671
    1666             // LOOP ENABLED FORMS AND SET EXCLUDED FORM ID'S IF NOT ADMIN
    1667             $excludedForms = array();
    1668             if ($role !== 'administrator' && is_array($enabledForms) && count($enabledForms)) {
    1669                 foreach ($enabledForms as $enabledForm) {
    1670                     // CHECK IF FORM IS SET TO SPECIFIC USERS ONLY
    1671                     if ($enabledForm->users_handler == 'specific') {
    1672                         // CONVERT COMMA DELIMITED STRING OF USER ID'S TO ARRAY
    1673                         $approvedUsers = explode(',', $enabledForm->approved_users);
    1674 
    1675                         if (!in_array($myId, $approvedUsers)) {
    1676                             // IF MY ID NOT SET ADD FORM ID TO EXCLUDED FORMS ARRAY
    1677                             if ($enabledForm->form_builder == 'gravity') {
    1678                                 // IF GRAVITY FORM PREPEND GFORM_ TO ID
    1679                                 $excludedForms[] = 'gform_' . $enabledForm->id;
    1680                             } else {
    1681                                 $excludedForms[] = $enabledForm->id;
    1682                             }
    1683                         }
    1684                     }
    1685                 }
    1686             }
     1672            // SET EXCLUDED FORM ID'S IF NOT ADMIN
     1673            $excludedForms = $role !== 'administrator' ? cm_hipaa_record_excluded_forms($enabledForms, $myId) : array();
    16871674
    16881675            // CONVERT EXCLUDED FORMS ARRAY TO COMMA DELIMITED STRING
    … …  
    21692156
    21702157                            $content = '
    2171                             <style>' . htmlspecialchars_decode($customCss) . '</style>
     2158                            <style>' . $customCss . '</style>
    21722159                            ' . $stagingMessage . '
    21732160                            <table class="cm-hipaa-submitted-forms">
    … …  
    23582345                            foreach ($formsData as $formData) {
    23592346                                $formId = $formData->form_id;
     2347                                $nativeSnapshot = isset($formData->form_builder_id) && is_string($formData->form_builder_id)
     2348                                    && preg_match('/^(?:gform_)?cmhf[1-9][0-9]{0,15}$/D', $formData->form_builder_id);
    23602349                                $formName = '';
    23612350                                if($formData->form_name) {
    2362                                     $formName = self::accent2ascii(stripslashes($formData->form_name));
     2351                                    $formName = $nativeSnapshot ? $formData->form_name : self::accent2ascii(stripslashes($formData->form_name));
    23632352                                }
    23642353                                $usersTimezone = new DateTimeZone($tz);
    … …  
    23782367                                    $rawDecryptedForm = self::decrypt($formHtml, $encryptKey, $encryptIv);
    23792368                                    if (is_string($rawDecryptedForm)) {
    2380                                         $decryptedForm = self::accent2ascii(stripslashes($rawDecryptedForm));
     2369                                        $decryptedForm = $nativeSnapshot ? $rawDecryptedForm : self::accent2ascii(stripslashes($rawDecryptedForm));
    23812370                                    }
    23822371                                }
    … …  
    24892478
    24902479                                $webForm = $decryptedForm;
     2480                                $notes_html = '';
     2481                                if ( ! empty( $decryptedNotes ) ) {
     2482                                    $notes_html = sprintf(
     2483                                        '<div class="cm-hipaa-submitted-form-webview-notes"><h4>NOTES:</h4>%s</div>',
     2484                                        implode( '', $decryptedNotes )
     2485                                    );
     2486                                }
    24912487
    24922488                                $forms[] = '
    … …  
    24952491                                <div class="clearfix"></div>
    24962492                                ' . $signature . '
    2497                                 <div class="cm-hipaa-submitted-form-webview-notes">
    2498                                     <h4>NOTES:</h4>
    2499                                     ' . implode('', $decryptedNotes) . '
    2500                                 </div>
     2493                                ' . $notes_html . '
    25012494                            ';
    25022495                            }
    … …  
    26242617                $formSettingsTitleField = '';
    26252618
     2619                $form_settings_state = cm_hipaa_form_setting_state('caldera', (string) $formId);
     2620                $enabledForms = is_wp_error($form_settings_state) ? array() : array((object) array_merge(
     2621                    $form_settings_state['settings'],
     2622                    array('id' => (string) $formId, 'form_builder' => 'caldera')
     2623                ));
     2624                $formSettingsEnabled = is_wp_error($form_settings_state) ? 'no' : $form_settings_state['settings']['enabled'];
     2625
    26262626                if(!empty($enabledForms)) {
    26272627                    foreach ($enabledForms as $enabledForm) {
    2628                         if ($formId == $enabledForm->id) {
     2628                        if (isset($enabledForm->form_builder) && $enabledForm->form_builder === 'caldera' && (string) $formId === (string) $enabledForm->id) {
    26292629                            if(isset($enabledForm->enabled)){
    26302630                                $formSettingsEnabled = $enabledForm->enabled;
    … …  
    27982798                }
    27992799
    2800                 // CHECK IF FORM IS SELECTED - OLD ENABLED FORMS FOR BACKWARDS COMPATIBILITY
    2801                 if(in_array($formId, $oldEnabledForms) || $formSettingsEnabled == 'yes') {
     2800                if($formSettingsEnabled === 'yes') {
    28022801                    $formSelectIcon = '<i class="material-icons">check_box</i>';
    28032802                    $formSelected = ' selected';
    … …  
    28972896
    28982897                $formsArray[] = '
    2899                     <div id="' . $formId . '" class="cm-hipaa-select-form-item' . $errorClass . $formSelected . '">
     2898                    <div id="cm-hipaa-caldera-' . esc_attr($formId) . '" data-cm-form-title="' . esc_attr($formName) . '" ' . cm_hipaa_form_row_attributes('caldera', (string) $formId, $form_settings_state) . ' class="cm-hipaa-select-form-item' . $errorClass . $formSelected . '">
    29002899                        <div class="cm-hipaa-select-form-item-name">
    2901                             <span class="cm-hipaa-form-select">
     2900                            <span class="cm-hipaa-form-select" role="checkbox" tabindex="0" aria-label="Enable ' . esc_attr($formName) . '" aria-checked="' . ($formSettingsEnabled === 'yes' ? 'true' : 'false') . '">
    29022901                                ' . $formSelectIcon . '
    29032902                            </span>
    … …  
    29102909                        </div>
    29112910                        <div class="cm-hipaa-select-form-item-fields">
    2912                             <form class="cm-hipaa-select-form-form" data="' . $formId . '">
     2911                            <form method="post" class="cm-hipaa-select-form-form" data="' . $formId . '">
    29132912                                <div class="cm-hipaa-select-form-field-wrapper">
    29142913                                    <h4>SIGNATURE FIELD</h4> <i class="material-icons cm-hipaa-setting-info" data-content="signature-settings-info" title="More Information">info</i>
    … …  
    30053004    }
    30063005
     3006    public function getNativeForms() {
     3007        return cm_hipaa_native_admin_list();
     3008    }
     3009
    30073010    /*** GET GRAVITY FORMS LIST ***/
    30083011    public function getGravityForms($enabledForms) {
    … …  
    30283031                $active = $form->is_active;
    30293032
     3033                if ($active != 1) {
     3034                    $formsArray[] = '<div class="cm-hipaa-native-enable-row" data-cm-form-title="' . esc_attr($formName) . '"><strong>' . esc_html($formName) . '</strong><p>This form is inactive in Gravity Forms. Turn it on there before you enable it here.</p></div>';
     3035                    continue;
     3036                }
    30303037                if($active == 1) {
    30313038                    // GET FIELDS
    … …  
    31523159                    $formSettingsTitleField = '';
    31533160
     3161                    $form_settings_state = cm_hipaa_form_setting_state('gravity', (string) $formId);
     3162                    $enabledForms = is_wp_error($form_settings_state) ? array() : array((object) array_merge(
     3163                        $form_settings_state['settings'],
     3164                        array('id' => (string) $formId, 'form_builder' => 'gravity')
     3165                    ));
     3166                    $formSettingsEnabled = is_wp_error($form_settings_state) ? 'no' : $form_settings_state['settings']['enabled'];
     3167
    31543168                    if(!empty($enabledForms)) {
    31553169                        foreach ($enabledForms as $enabledForm) {
    3156                             if ($formId == $enabledForm->id) {
     3170                            if (isset($enabledForm->form_builder) && $enabledForm->form_builder === 'gravity' && (string) $formId === preg_replace('/^gform_/', '', (string) $enabledForm->id)) {
    31573171                                if(isset($enabledForm->enabled)){
    31583172                                    $formSettingsEnabled = $enabledForm->enabled;
    … …  
    33263340                    }
    33273341
    3328                     // CHECK IF FORM IS SELECTED - OLD ENABLED FORMS FOR BACKWARDS COMPATIBILITY
    3329                     if(in_array($formId, $oldEnabledForms) || $formSettingsEnabled == 'yes') {
     3342                    if($formSettingsEnabled === 'yes') {
    33303343                        $formSelectIcon = '<i class="material-icons">check_box</i>';
    33313344                        $formSelected = ' selected';
    … …  
    34253438
    34263439                    $formsArray[] = '
    3427                         <div id="' . $formId . '" class="cm-hipaa-select-form-item' . $errorClass . $formSelected . '">
     3440                        <div id="cm-hipaa-gravity-' . esc_attr($formId) . '" data-cm-form-title="' . esc_attr($formName) . '" ' . cm_hipaa_form_row_attributes('gravity', (string) $formId, $form_settings_state) . ' class="cm-hipaa-select-form-item' . $errorClass . $formSelected . '">
    34283441                            <div class="cm-hipaa-select-form-item-name">
    3429                                 <span class="cm-hipaa-form-select">
     3442                                <span class="cm-hipaa-form-select" role="checkbox" tabindex="0" aria-label="Enable ' . esc_attr($formName) . '" aria-checked="' . ($formSettingsEnabled === 'yes' ? 'true' : 'false') . '">
    34303443                                    ' . $formSelectIcon . '
    34313444                                </span>
    … …  
    34383451                            </div>
    34393452                            <div class="cm-hipaa-select-form-item-fields">
    3440                                 <form class="cm-hipaa-select-form-form" data="' . $formId . '">                                   
     3453                                <form method="post" class="cm-hipaa-select-form-form" data="' . $formId . '">
    34413454                                    <div class="cm-hipaa-select-form-field-wrapper">
    34423455                                        <h4>SIGNATURE FIELD</h4>  <i class="material-icons cm-hipaa-setting-info" data-content="signature-settings-info" title="More Information">info</i>
    … …  
    35653578            $licenseKey = esc_attr(get_option('license_key'));
    35663579            $timeZone = esc_attr(get_option('time_zone'));
    3567             $customCss = esc_attr(get_option('hipaa_form_css'));
     3580            $customCss = cm_hipaa_sanitize_css_setting(
     3581                get_option( 'hipaa_form_css', '' )
     3582            );
    35683583
    35693584            // GET USER DATA
    … …  
    65906605
    65916606                        if ($selectedUser) {
    6592                             // SET USER BY ID
    6593                             $user = get_user_by('id', $selectedUser);
    6594 
    6595                             // GET SELECTED USER'S EMAIL
    6596                             array_push($toMail, $user->user_email);
     6607                            foreach (explode(',', (string) $selectedUser) as $selected_user_id) {
     6608                                $user = get_user_by('id', $selected_user_id);
     6609                                if ($user && !empty($user->user_email)) {
     6610                                    array_push($toMail, $user->user_email);
     6611                                }
     6612                            }
    65976613                        }
    65986614
  • codemonkeys-hipaa-forms/trunk/includes/options.php

    r3747086 r3791567  
    3636
    3737function cm_hipaa_sanitize_builder_setting( $value ) {
    38     return in_array( $value, array( 'caldera', 'gravity' ), true ) ? $value : '';
     38    return in_array( $value, array( 'caldera', 'gravity', 'native' ), true ) ? $value : '';
    3939}
    4040
    … …  
    131131    register_setting( 'cm-hipaa-settings-group', 'hipaa_notification_email_message', array( 'sanitize_callback' => 'cm_hipaa_sanitize_html_setting' ) );
    132132    register_setting( 'cm-hipaa-settings-group', 'hipaa_form_css', array( 'sanitize_callback' => 'cm_hipaa_sanitize_css_setting' ) );
    133     register_setting( 'cm-hipaa-settings-group', 'enabled_forms_settings', array( 'sanitize_callback' => 'cm_hipaa_sanitize_forms_setting' ) );
    134133    register_setting( 'cm-hipaa-settings-group', 'privacy_notice_method', array( 'sanitize_callback' => 'cm_hipaa_sanitize_text_setting' ) );
    135134    register_setting( 'cm-hipaa-settings-group', 'privacy_notice_label', array( 'sanitize_callback' => 'cm_hipaa_sanitize_text_setting' ) );
    … …  
    151150        $gravitySelected = 'selected="selected"';
    152151    }
     152    $nativeSelected = $formBuilder === 'native' ? 'selected="selected"' : '';
    153153
    154154    // GET PREFERRED TIME ZONE
    … …  
    224224                            </tr>
    225225                            <tr valign="top">
    226                                 <th scope="row">Select a Form Builder</th>
    227                                 <td>
    228                                     <select name="form_builder">
    229                                         <option value="caldera"<?php echo esc_attr( $calderaSelected ); ?>>Caldera</option>
    230                                         <option value="gravity"<?php echo esc_attr( $gravitySelected ); ?>>Gravity</option>
    231                                     </select>
    232                                 </td>
    233                             </tr>
    234                             <tr valign="top">
    235226                                <th scope="row">Preferred Timezone</th>
    236227                                <td>
    … …  
    266257            <input type="hidden" name="gravity_enabled_form_ids" value="<?php echo esc_attr( get_option('gravity_enabled_form_ids') ); ?>" />
    267258            <input type="hidden" name="hipaa_form_css" value="<?php echo esc_attr(get_option('hipaa_form_css')); ?>"/>
    268             <input type="hidden" name="enabled_forms_settings" value="<?php echo esc_attr(get_option('enabled_forms_settings')); ?>"/>
    269259            <input type="hidden" name="privacy_notice_method" value="<?php echo esc_attr(get_option('privacy_notice_method')); ?>"/>
    270260            <input type="hidden" name="privacy_notice_label" value="<?php echo esc_attr(get_option('privacy_notice_label')); ?>"/>
  • codemonkeys-hipaa-forms/trunk/includes/record-access.php

    r3747086 r3791567  
    2121
    2222function cm_hipaa_record_policy_allows($record, $settings, $user_id) {
    23     if (!is_array($record) || !is_array($settings) || empty($record['form_builder_id'])) {
     23    if (!is_array($record) || empty($record['form_builder_id'])) {
    2424        return false;
    2525    }
    2626    $builder_id = (string) $record['form_builder_id'];
     27    $is_native = false;
     28    if (strpos($builder_id, 'cmhf') === 0 || strpos($builder_id, 'gform_cmhf') === 0) {
     29        if (!preg_match('/^(?:gform_)?(cmhf[1-9][0-9]{0,15})$/D', $builder_id, $native_id)) { return false; }
     30        $builder_id = $native_id[1];
     31        if (!function_exists('cm_hipaa_native_record_settings')) { return false; }
     32        $native = cm_hipaa_native_record_settings($builder_id);
     33        if (!$native) { return false; }
     34        $settings = array((array) $native);
     35        $is_native = true;
     36    }
     37    if (!is_array($settings)) { return false; }
     38    $form_id = false;
     39    if (!$is_native && function_exists('cm_hipaa_form_governing_row')) {
     40        $builder = strpos($builder_id, 'gform_') === 0 ? 'gravity' : 'caldera';
     41        $form_id = cm_hipaa_form_identity($builder, $builder_id);
     42    }
    2743    $matching = array();
    28     foreach ($settings as $setting) {
    29         if (!is_array($setting) || !isset($setting['id'], $setting['form_builder'], $setting['users_handler'])) {
    30             continue;
     44    if ($form_id !== false) {
     45        // The row that governs the form in every other reader also sets its staff rule.
     46        $index = cm_hipaa_form_governing_row($settings, $builder, $form_id);
     47        $row = $index === null || !isset($settings[$index]) ? array() : (array) $settings[$index];
     48        if (isset($row['users_handler'])) {
     49            $matching[] = $row;
    3150        }
    32         $configured_id = $setting['form_builder'] === 'gravity' ? 'gform_' . $setting['id'] : (string) $setting['id'];
    33         if ($configured_id === $builder_id) {
    34             $matching[] = $setting;
     51    } else {
     52        foreach ($settings as $setting) {
     53            if (!is_array($setting) || !isset($setting['id'], $setting['form_builder'], $setting['users_handler']) ||
     54                $setting['form_builder'] === '') {
     55                continue;
     56            }
     57            $configured_id = $setting['form_builder'] === 'gravity'
     58                ? 'gform_' . preg_replace('/^gform_/', '', (string) $setting['id']) : (string) $setting['id'];
     59            if ($configured_id === $builder_id) {
     60                $matching[] = $setting;
     61            }
    3562        }
    3663    }
    … …  
    121148}
    122149cm_hipaa_register_record_admission();
     150
     151// Form ids the entry list asks the service to leave out for this staff user. Each form follows the row that
     152// governs it under cm_hipaa_form_governing_row, as record access does.
     153function cm_hipaa_record_excluded_forms($settings, $user_id) {
     154    $settings = is_array($settings) ? $settings : array();
     155    $excluded = array();
     156    foreach ($settings as $index => $setting) {
     157        $setting = (array) $setting;
     158        if (!isset($setting['id'], $setting['users_handler']) || $setting['users_handler'] !== 'specific' ||
     159            in_array($user_id, explode(',', isset($setting['approved_users']) ? (string) $setting['approved_users'] : ''))) {
     160            continue;
     161        }
     162        $builder = isset($setting['form_builder']) ? (string) $setting['form_builder'] : '';
     163        $owned = false;
     164        foreach (cm_hipaa_form_row_unlabeled($setting) ? array('caldera', 'gravity') : array($builder) as $each) {
     165            $id = cm_hipaa_form_identity($each, $setting['id']);
     166            if ($id === false) {
     167                continue;
     168            }
     169            $owned = true;
     170            $governing = cm_hipaa_form_governing_row($settings, $each, $id);
     171            if (is_int($governing) && $governing !== $index) {
     172                continue;
     173            }
     174            if ($each !== 'gravity') {
     175                $excluded[] = $id;
     176            }
     177            if ($each !== 'caldera') {
     178                // Historical native entries keep their old service identity.
     179                $excluded[] = 'gform_' . $id;
     180            }
     181        }
     182        if (!$owned) {
     183            $excluded[] = in_array($builder, array('gravity', 'native'), true) ? 'gform_' . $setting['id'] : (string) $setting['id'];
     184        }
     185    }
     186    return array_values(array_unique($excluded));
     187}
  • codemonkeys-hipaa-forms/trunk/js/admin-script.js

    r3782901 r3791567  
    11/**
    2  * V3.3.6
     2 * V3.3.7
    33 */
     4
     5function cmHipaaBuilderForForm(formId, settings, fallback) {
     6    var id = String(formId || '').replace(/^gform_/, '');
     7    if (/^cmhf[1-9][0-9]*$/.test(id)) return 'native';
     8    var matches = (Array.isArray(settings) ? settings : []).filter(function (setting) {
     9        return setting && String(setting.id) === id;
     10    });
     11    if (matches.length > 1) return '';
     12    return matches.length === 1 ? matches[0].form_builder : fallback;
     13}
    414
    515jQuery(document).ready(function() {
    … …  
    1323    } else {
    1424        /*** GET FORMS ON PAGE LOAD ***/
    15         cmGetSubmittedFormsList();
     25        if (jQuery('#cm-submitted-forms-results').length) cmGetSubmittedFormsList();
    1626    }
    1727
    1828    /*** GET BAA AGREEMENT PDF URL ON PAGE LOAD ***/
    19     cmGetBaaPdf();
     29    if (jQuery('.cm-hipaa-tabs-wrapper').length) cmGetBaaPdf();
    2030
    2131    /*** GET OPEN SUPPORT TICKETS
    … …  
    203213    });
    204214
    205     /*** UPDATE FORM BUILDER ***/
    206     jQuery(document).on('change', '#cm-hipaa-form-builder-select', function() {
    207         if(jQuery(this).val()) {
    208             cmUpdateFormBuilder(jQuery(this).val());
    209         }
    210     });
    211 
    212     /*** SELECT / DESELECT FORM ***/
    213215    jQuery(document).on('click', '.cm-hipaa-form-select', function() {
    214         var item = jQuery(this).parent().parent();
    215         var formId = item.attr('id');
    216         var formBuilder = jQuery('#selected-form-builder').val();
    217         var enabledIdsInput;
    218         if(formBuilder === 'caldera') {
    219             enabledIdsInput = jQuery('form#cm_hipaa_forms_options input[name="caldera_enabled_form_ids"]');
    220         } else if(formBuilder === 'gravity') {
    221             enabledIdsInput = jQuery('form#cm_hipaa_forms_options input[name="gravity_enabled_form_ids"]');
    222         }
    223         var settingsForm = jQuery(this).parent().parent().parent().find('.cm-hipaa-select-form-form');
    224         var enabledIds = enabledIdsInput.val();
    225         var selected;
    226         var newEnabledIds;
    227         var thisOption = jQuery(this);
    228 
    229         if(item.hasClass('selected')) {
    230             item.removeClass('selected');
    231             thisOption.html('<i class="material-icons">check_box_outline_blank</i>');
    232 
    233             // REMOVE FORM ID FROM ENABLED FORMS INPUT STRING - DEPRECATED
    234             //newEnabledIds = enabledIds.replace(formId + ',', '');
    235 
    236             // UPDATE ENABLED FORMS INPUT - DEPRECATED, REMOVE VALUE
    237             enabledIdsInput.val('');
    238 
    239             selected = false;
    240 
    241             // SAVE FORM
    242             cmSaveFormSettings(item);
    243         } else if(!item.hasClass('selected') && !item.hasClass('errors')) {
    244             var selectedForms = jQuery('.cm-hipaa-select-form-item.selected');
    245 
    246             /*** VALIDATE ACCOUNT ***/
    247             thisOption.html('<img style="float:left;width:24px;height:24px;margin:auto;" src="' + hipaaScript.pluginUrl + '/images/loading/loading19.gif" />');
    248             jQuery.ajax({
    249                 method: 'POST',
    250                 type: 'POST',
    251                 dataType: 'json',
    252                 url: hipaaScript.ajax_url,
    253                 data: {
    254                     'action': 'cm_hipaa_validate_account',
    255                     'nonce': hipaaScript.nonce
    256                 },
    257                 success: function (resultData) {
    258                     if (resultData.success === 'success' && resultData.product === 'basic') {
    259                         if(selectedForms.length >= 1) {
    260                             // IF A FORM IS ALREADY SELECTED SHOW MESSAGE ONLY ONE FORM ALLOWED
    261                             alert('Only 1 form can be selected under the Basic Free subscription. Upgrade to the standard subscription to enable multiple forms');
    262                             thisOption.html('<i class="material-icons">check_box_outline_blank</i>');
    263                         } else {
    264                             item.addClass('selected');
    265                             thisOption.html('<i class="material-icons">check_box</i>');
    266 
    267                             // APPEND FORM ID TO ENABLED FORMS INPUT STRING - DEPRECATED
    268                             //newEnabledIds = enabledIds + formId + ',';
    269 
    270                             // UPDATE ENABLED FORMS INPUT - DEPRECATED, REMOVE VALUE
    271                             enabledIdsInput.val('');
    272 
    273                             selected = true;
    274 
    275                             // SAVE FORM
    276                             cmSaveFormSettings(item);
    277                         }
    278                     } else {
    279                         item.addClass('selected');
    280                         thisOption.html('<i class="material-icons">check_box</i>');
    281 
    282                         // APPEND FORM ID TO ENABLED FORMS INPUT STRING - DEPRECATED
    283                         //newEnabledIds = enabledIds + formId + ',';
    284 
    285                         // UPDATE ENABLED FORMS INPUT - DEPRECATED, REMOVE VALUE
    286                         enabledIdsInput.val('');
    287 
    288                         selected = true;
    289 
    290                         // SAVE FORM
    291                         cmSaveFormSettings(item);
    292                     }
    293                 },
    294                 error: function (errorThrown) {
    295                     console.log(errorThrown);
    296                 }
    297             });
    298         }
    299     });
    300 
    301     /*** SAVE FORM SETTINGS ***/
     216        var row = jQuery(this).closest('[data-cm-builder]');
     217        if (row.hasClass('selected') || !row.hasClass('errors')) cmHipaaSetFormEnabled(row, !row.hasClass('selected'));
     218    });
     219
     220    jQuery(document).on('keydown', '.cm-hipaa-form-select', function(event) {
     221        if (event.key === ' ' || event.key === 'Enter') {
     222            event.preventDefault();
     223            jQuery(this).trigger('click');
     224        }
     225    });
     226
     227    document.addEventListener('cm-hipaa-form-state', function(event) {
     228        var row = jQuery(event.target).closest('[data-cm-builder]');
     229        var state = event.detail;
     230        if (!row.length || !state || state.builder !== row.attr('data-cm-builder') || String(state.id) !== row.attr('data-cm-form-id')) return;
     231        cmHipaaApplyFormState(row, state);
     232    });
     233
     234    jQuery(document).on('change', '[data-cm-native-toggle]', function() {
     235        var row = jQuery(this).closest('[data-cm-builder]');
     236        var enabled = this.checked;
     237        this.checked = !enabled;
     238        cmHipaaSetFormEnabled(row, enabled);
     239    });
     240
    302241    jQuery(document).on('click', '.cm-hipaa-forms-form-settings-submit', function() {
    303         var formWrapper = jQuery(this).parent().parent().parent();
    304         cmSaveFormSettings(formWrapper);
     242        cmSaveFormSettings(jQuery(this).closest('[data-cm-builder]'));
     243    });
     244
     245    jQuery(document).on('submit', '.cm-hipaa-select-form-form', function(event) {
     246        event.preventDefault();
     247        cmSaveFormSettings(jQuery(this).closest('[data-cm-builder]'));
    305248    });
    306249
    … …  
    742685    jQuery('#cm-hipaa-forms-logs-search').click(function() {
    743686        var startDate = jQuery('#cm-hipaa-forms-logs-filter-start-date').val();
    744         var endDate = jQuery('#cm-submitted-form-filter-end-date').val();
     687        var endDate = jQuery('#cm-hipaa-forms-logs-filter-end-date').val();
    745688        var limit = jQuery('#cm-hipaa-forms-logs-filter-limit').val();
    746689        var page = jQuery('#cm-hipaa-forms-logs-filter-page').val();
    … …  
    754697    jQuery(document).on('click', '#cm-hipaa-forms-logs-prev .cm-pagination-button', function() {
    755698        var startDate = jQuery('#cm-hipaa-forms-logs-filter-start-date').val();
    756         var endDate = jQuery('#cm-submitted-form-filter-end-date').val();
     699        var endDate = jQuery('#cm-hipaa-forms-logs-filter-end-date').val();
    757700        var limit = jQuery('#cm-hipaa-forms-logs-filter-limit').val();
    758701        var page = jQuery('#cm-hipaa-forms-logs-filter-page').val();
    … …  
    766709    jQuery(document).on('click', '#cm-hipaa-forms-logs-next .cm-pagination-button', function() {
    767710        var startDate = jQuery('#cm-hipaa-forms-logs-filter-start-date').val();
    768         var endDate = jQuery('#cm-submitted-form-filter-end-date').val();
     711        var endDate = jQuery('#cm-hipaa-forms-logs-filter-end-date').val();
    769712        var limit = jQuery('#cm-hipaa-forms-logs-filter-limit').val();
    770713        var page = jQuery('#cm-hipaa-forms-logs-filter-page').val();
    … …  
    10711014        var calderaCSS = hipaaScript.contentUrl + '/plugins/caldera-forms/assets/css/caldera-form.css';
    10721015        var printCSS = hipaaScript.pluginUrl + '/css/print.css';
     1016        var nativeCSS = hipaaScript.pluginUrl + 'css/native-record.css';
    10731017        var form = jQuery(this).closest('.cm-hipaa-submitted-form-fields-inner');
    10741018        var formId = jQuery(this).attr('data-form-id');
    … …  
    11151059            importStyle: true,
    11161060            copyTagClasses: true,
    1117             loadCSS: [pluginCSS, gravityCSS, calderaCSS, printCSS],
     1061            loadCSS: [pluginCSS, gravityCSS, calderaCSS, nativeCSS, printCSS],
    11181062            pageTitle: pageTitle
    11191063        });
    … …  
    11951139        }
    11961140    }
    1197 }
    1198 
    1199 /*** UPDATE FORM BUILDER ***/
    1200 function cmUpdateFormBuilder(formBuilder) {
    1201     // UPDATE FORM
    1202     jQuery('input[name="form_builder"]').val(formBuilder).promise().done(function() {
    1203         var availableFormsWrapper = jQuery('#cm-hipaa-forms-available-forms-wrapper');
    1204         //var nonce = hipaaScript.nonce;
    1205 
    1206         // SAVE FORM
    1207         availableFormsWrapper.html('<img src="' + hipaaScript.pluginUrl + '/images/loading/loading16.gif" />');
    1208         jQuery('form#cm_hipaa_forms_options').ajaxSubmit({
    1209             success: function(){
    1210                 // UPDATE AVAILABLE FORMS
    1211                 jQuery.ajax({
    1212                     method: 'POST',
    1213                     type: 'POST',
    1214                     dataType: 'json',
    1215                     url: hipaaScript.ajax_url,
    1216                     data: {
    1217                         'action': 'cm_hipaa_update_available_forms',
    1218                         'nonce': hipaaScript.nonce,
    1219                         'form_builder': formBuilder
    1220                     },
    1221                     success: function (resultData) {
    1222                         if(resultData.error) {
    1223                             availableFormsWrapper.text(resultData.error);
    1224                         } else {
    1225                             availableFormsWrapper.html(resultData.content || '');
    1226                         }
    1227                     },
    1228                     error: function (errorThrown) {
    1229                         console.log(errorThrown);
    1230                         availableFormsWrapper.text('There was a problem updating the available forms list.');
    1231                     }
    1232                 });
    1233             },
    1234             error: function (errorThrown) {
    1235                 availableFormsWrapper.html(errorThrown);
    1236             }
    1237         });
    1238     });
    12391141}
    12401142
    … …  
    12981200}
    12991201
    1300 /*** SAVE FORM SETTINGS ***/
    1301 function cmSaveFormSettings(formWrapper) {
    1302     var formBuilder = jQuery('#selected-form-builder').val();
    1303     var enabledFormsSettingsInput = jQuery('input[name="enabled_forms_settings"]');
    1304     var enabledFormsSettings = enabledFormsSettingsInput.val();
    1305     if(enabledFormsSettings) {
    1306         try{
    1307             enabledFormsSettings = JSON.parse(enabledFormsSettings);
    1308         }catch (e) {
    1309             console.log(enabledFormsSettings);
    1310             console.log('JSON.parse ERROR:',e);
    1311 
    1312         }
    1313     } else {
    1314         enabledFormsSettings = [];
    1315     }
    1316 
    1317     var formId = formWrapper.attr('id');
    1318     var formEnabled = 'no';
    1319     if(formWrapper.hasClass('selected')) {
    1320         formEnabled = 'yes';
    1321     }
    1322     var showSig = formWrapper.find('input[name="cm-hipaa-forms-show-signature"]:checked').val();
    1323     var submitBtnText = formWrapper.find('input[name="cm-hipaa-forms-submit-button-text"]').val();
    1324     var successHandler = formWrapper.find('input[name="cm-hipaa-forms-success-handler"]:checked').val();
    1325     var successMessage = formWrapper.find('textarea[name="cm-hipaa-forms-success-message"]').val();
    1326     var successHideForm = formWrapper.find('input[name="cm-hipaa-forms-success-hide-form"]:checked').val();
    1327     var successRedirect = formWrapper.find('input[name="cm-hipaa-forms-success-redirect"]').val();
    1328     var successCallback = formWrapper.find('input[name="cm-hipaa-forms-success-callback"]').val();
    1329     var successCallbackParams = formWrapper.find('input[name="cm-hipaa-forms-success-callback-params"]').val();
    1330     var usersHandler = formWrapper.find('input[name="cm-hipaa-forms-users-handler"]:checked').val();
    1331     var approvedUsersInputs = formWrapper.find('input[name="cm-hipaa-forms-approved-users"]:checked');
    1332     var selectedUserSlug = formWrapper.find('input[name="cm-hipaa-forms-selected-user-slug"]').val();
    1333     var notificationOption = formWrapper.find('input[name="cm-hipaa-forms-notification-handler"]:checked').val();
    1334     var notificationFromName = formWrapper.find('input[name="cm-hipaa-selected-form-notification-from-name-input"]').val();
    1335     var notificationFromEmail = formWrapper.find('input[name="cm-hipaa-selected-form-notification-from-email-input"]').val();
    1336     var notificationSendTo = formWrapper.find('input[name="cm-hipaa-selected-form-notification-sendto-input"]').val();
    1337     var notificationSubject = formWrapper.find('input[name="cm-hipaa-selected-form-notification-subject-input"]').val();
    1338     var notificationMessage = formWrapper.find('textarea[name="cm-hipaa-selected-form-notification-message-input"]').val();
    1339     var noticeEle = formWrapper.find('.cm-form-settings-notice');
    1340     var approvedUsersArr = [];
    1341     //var additionalFormTitle = formWrapper.find('input[name="cm-hipaa-forms-title-field"]').val();
    1342 
    1343     approvedUsersInputs.each(function() {
    1344         approvedUsersArr.push(jQuery(this).val());
    1345     });
    1346 
    1347     var approvedUsers = approvedUsersArr.join(',');
    1348 
    1349     // CHECK IF FORM OBJECT EXISTS IN ARRAY
    1350     var formFound;
    1351     enabledFormsSettings.some(function(el) {
    1352         if(el.id === formId) {
    1353             formFound = true;
    1354         }
    1355     });
    1356 
    1357     //console.log('submit:'+submitBtnText);
    1358     if(formFound) {
    1359         // LOOP ENABLED FORMS SETTINGS
    1360         enabledFormsSettings.forEach(function(enabledFormSettings) {
    1361             if(enabledFormSettings.id === formId) {
    1362                 // IF OBJECT FORM ID EQUALS THIS FORM ID UPDATE OBJECT VALUES
    1363                 enabledFormSettings.form_builder = formBuilder;
    1364                 enabledFormSettings.enabled = formEnabled;
    1365                 enabledFormSettings.show_signature = showSig;
    1366                 enabledFormSettings.submit_btn_text = submitBtnText;
    1367                 enabledFormSettings.success_handler = successHandler;
    1368                 enabledFormSettings.success_message = successMessage;
    1369                 enabledFormSettings.success_hide_form = successHideForm;
    1370                 enabledFormSettings.success_redirect = successRedirect;
    1371                 enabledFormSettings.success_callback = successCallback;
    1372                 enabledFormSettings.success_callback_params = successCallbackParams;
    1373                 enabledFormSettings.users_handler = usersHandler;
    1374                 enabledFormSettings.approved_users = approvedUsers;
    1375                 enabledFormSettings.selected_user_slug = selectedUserSlug;
    1376                 enabledFormSettings.notification_option = notificationOption;
    1377                 enabledFormSettings.notification_from_name = notificationFromName;
    1378                 enabledFormSettings.notification_from_email = notificationFromEmail;
    1379                 enabledFormSettings.notification_sendto = notificationSendTo;
    1380                 enabledFormSettings.notification_subject = notificationSubject;
    1381                 enabledFormSettings.notification_message = notificationMessage;
    1382                 //enabledFormSettings.additional_title_field = additionalFormTitle;
    1383             }
    1384         });
    1385     } else {
    1386         // CREATE FORM OBJECT AND SET VALUES
    1387         var formSettings = {};
    1388         formSettings.form_builder = formBuilder;
    1389         formSettings.id = formId;
    1390         formSettings.enabled = formEnabled;
    1391         formSettings.show_signature = showSig;
    1392         formSettings.submit_btn_text = submitBtnText;
    1393         formSettings.success_handler = successHandler;
    1394         formSettings.success_message = successMessage;
    1395         formSettings.success_hide_form = successHideForm;
    1396         formSettings.success_redirect = successRedirect;
    1397         formSettings.success_callback = successCallback;
    1398         formSettings.success_callback_params = successCallbackParams;
    1399         formSettings.users_handler = usersHandler;
    1400         formSettings.approved_users = approvedUsers;
    1401         formSettings.selected_user_slug = selectedUserSlug;
    1402         formSettings.notification_option = notificationOption;
    1403         formSettings.notification_from_name = notificationFromName;
    1404         formSettings.notification_from_email = notificationFromEmail;
    1405         formSettings.notification_sendto = notificationSendTo;
    1406         formSettings.notification_subject = notificationSubject;
    1407         formSettings.notification_message = notificationMessage;
    1408         //formSettings.additional_title_field = additionalFormTitle;
    1409 
    1410         // PUSH NEW FORM SETTINGS OBJECT TO ENABLED FORMS SETTINGS ARRAY
    1411         enabledFormsSettings.push(formSettings);
    1412     }
    1413 
    1414     var enabledFormsSettingsJson = JSON.stringify(enabledFormsSettings);
    1415 
    1416     // VALIDATE JSON STRING
    1417     if(isJsonString(enabledFormsSettingsJson) === true) {
    1418         // ADD/UPDATE FORM SETTINGS TO HIDDEN OPTION INPUT
    1419         enabledFormsSettingsInput.val(JSON.stringify(enabledFormsSettings)).promise().done(function() {
    1420             // SAVE FORM
    1421             noticeEle.html('<img src="' + hipaaScript.pluginUrl + '/images/loading/loading10.gif" />');
    1422             jQuery('form#cm_hipaa_forms_options').ajaxSubmit({
    1423                 success: function(){
    1424                     noticeEle.html('Settings Saved');
    1425                 },
    1426                 error: function (errorThrown) {
    1427                     noticeEle.html(errorThrown);
    1428                 }
    1429             });
    1430         });
    1431     } else {
    1432         noticeEle.html('Settings were prevented from saving due to an invalid JSON format, this can sometimes happen when adding custom css.  Please submit a support ticket and mention the error: Invalid Json');
    1433     }
     1202function cmHipaaSetFormEnabled(row, enabled) {
     1203    if (!row.length || row.attr('aria-busy') === 'true' || !window.cmHipaaFormSettings) return;
     1204    var previous = row.data('cm-account-check');
     1205    if (previous && window.cmHipaaFormSettings.isCurrentRow(previous)) return;
     1206    if (!enabled) return cmSaveFormSettings(row, false);
     1207    var opening = window.cmHipaaFormSettings.captureRow(row[0]);
     1208    if (!window.cmHipaaFormSettings.isCurrentRow(opening)) return;
     1209    row.data('cm-account-check', opening);
     1210    var notice = cmHipaaFormNotice(row);
     1211    notice.text('Checking your account…');
     1212    jQuery.ajax({
     1213        method: 'POST',
     1214        dataType: 'json',
     1215        url: hipaaScript.ajax_url,
     1216        data: { action: 'cm_hipaa_validate_account', nonce: hipaaScript.accountNonce }
     1217    }).done(function(result) {
     1218        if (row.data('cm-account-check') !== opening || !window.cmHipaaFormSettings.isCurrentRow(opening)) return;
     1219        if (!result || result.success !== 'success') {
     1220            notice.text('Your account could not be checked. Reload the page and try again.');
     1221            return;
     1222        }
     1223        var selected = jQuery('.cm-hipaa-select-form-item.selected').length;
     1224        selected += jQuery('[data-cm-native-toggle]:checked').length;
     1225        if (result.product === 'basic' && selected >= 1) {
     1226            notice.text('Your plan allows one form. Turn off another form or upgrade your plan.');
     1227            return;
     1228        }
     1229        cmSaveFormSettings(row, true);
     1230    }).fail(function() {
     1231        if (row.data('cm-account-check') === opening && window.cmHipaaFormSettings.isCurrentRow(opening)) notice.text('Your account could not be checked. Reload the page and try again.');
     1232    }).always(function() {
     1233        if (row.data('cm-account-check') === opening) row.removeData('cm-account-check');
     1234    });
     1235}
     1236
     1237function cmHipaaFormNotice(row) {
     1238    var notice = row.find('.cm-form-settings-notice').first();
     1239    if (!notice.length) notice = jQuery('<p class="cm-form-settings-notice" role="status"></p>');
     1240    if (notice.parent()[0] !== row[0]) notice.appendTo(row);
     1241    return notice;
     1242}
     1243
     1244function cmSaveFormSettings(formWrapper, enabled) {
     1245    var row = formWrapper[0];
     1246    if (!row || !window.cmHipaaFormSettings) return;
     1247    var builder = row.getAttribute('data-cm-builder');
     1248    var settings = { enabled: (enabled === undefined ? formWrapper.hasClass('selected') : enabled) ? 'yes' : 'no' };
     1249    if (builder !== 'native') {
     1250        var fields = {
     1251            show_signature: 'input[name="cm-hipaa-forms-show-signature"]:checked',
     1252            submit_btn_text: 'input[name="cm-hipaa-forms-submit-button-text"]',
     1253            success_handler: 'input[name="cm-hipaa-forms-success-handler"]:checked',
     1254            success_message: 'textarea[name="cm-hipaa-forms-success-message"]',
     1255            success_hide_form: 'input[name="cm-hipaa-forms-success-hide-form"]:checked',
     1256            success_redirect: 'input[name="cm-hipaa-forms-success-redirect"]',
     1257            success_callback: 'input[name="cm-hipaa-forms-success-callback"]',
     1258            success_callback_params: 'input[name="cm-hipaa-forms-success-callback-params"]',
     1259            users_handler: 'input[name="cm-hipaa-forms-users-handler"]:checked',
     1260            selected_user_slug: 'input[name="cm-hipaa-forms-selected-user-slug"]',
     1261            notification_option: 'input[name="cm-hipaa-forms-notification-handler"]:checked',
     1262            notification_from_name: 'input[name="cm-hipaa-selected-form-notification-from-name-input"]',
     1263            notification_from_email: 'input[name="cm-hipaa-selected-form-notification-from-email-input"]',
     1264            notification_sendto: 'input[name="cm-hipaa-selected-form-notification-sendto-input"]',
     1265            notification_subject: 'input[name="cm-hipaa-selected-form-notification-subject-input"]',
     1266            notification_message: 'textarea[name="cm-hipaa-selected-form-notification-message-input"]'
     1267        };
     1268        Object.keys(fields).forEach(function(key) { settings[key] = formWrapper.find(fields[key]).val() || ''; });
     1269        settings.show_signature = settings.show_signature === 'yes' ? 'yes' : 'no';
     1270        settings.success_hide_form = settings.success_hide_form === 'hide' ? 'hide' : 'show';
     1271        settings.approved_users = formWrapper.find('input[name="cm-hipaa-forms-approved-users"]:checked').map(function() { return this.value; }).get().join(',');
     1272    }
     1273    return window.cmHipaaFormSettings.saveRow(row, settings).then(function(state) {
     1274        if (!state || !row.isConnected) return;
     1275        cmHipaaApplyFormState(formWrapper, state);
     1276    });
     1277}
     1278
     1279function cmHipaaApplyFormState(row, state) {
     1280    var active = state.settings.enabled === 'yes';
     1281    row.toggleClass('selected', active);
     1282    row.find('.cm-hipaa-form-select').attr('aria-checked', String(active)).html('<i class="material-icons">' + (active ? 'check_box' : 'check_box_outline_blank') + '</i>');
     1283    row.find('[data-cm-native-toggle]').prop('checked', active);
    14341284}
    14351285
  • codemonkeys-hipaa-forms/trunk/js/script.js

    r3782901 r3791567  
    11/**
    2  * V3.3.6
     2 * V3.3.7
    33 */
     4
     5function cmHipaaPublicId(builder, id) {
     6    if (typeof id !== 'string' && typeof id !== 'number') return '';
     7    id = String(id);
     8    if (builder === 'gravity') {
     9        var match = /^(?:gform_)?([1-9][0-9]{0,15})$/.exec(id);
     10        return match ? match[1] : '';
     11    }
     12    return builder === 'caldera' && /^[A-Za-z0-9_-]{1,128}$/.test(id) ? id : '';
     13}
     14
     15function cmHipaaPublicArray(value) {
     16    if (value === undefined || value === null || value === '') return [];
     17    try {
     18        var result = typeof value === 'string' ? JSON.parse(value) : value;
     19        return Array.isArray(result) ? result : null;
     20    } catch (_error) {
     21        return null;
     22    }
     23}
     24
     25function cmHipaaPublicFormIdentity(form) {
     26    var mainId = form.attr('id') || '';
     27    var id = form.attr('data-cm-form-id') || form.attr('data-form-id') || mainId;
     28    var declared = form.attr('data-cm-builder') || '';
     29    if (form.hasClass('cm-hipaa-native-form') || /^cm-hipaa-native-form-/.test(mainId) ||
     30        declared === 'native') return null;
     31
     32    var gravity = /^gform_[1-9][0-9]*$/.test(mainId);
     33    var caldera = form.hasClass('caldera_forms_form') || /^caldera_form_/.test(mainId) ||
     34        /^CF[A-Za-z0-9_-]+$/.test(id);
     35    if (gravity && caldera) return null;
     36    var builder = declared || (gravity ? 'gravity' : caldera ? 'caldera' : '');
     37    if ((gravity && builder !== 'gravity') || (caldera && builder !== 'caldera')) return null;
     38    var normalized = cmHipaaPublicId(builder, id);
     39    if (!normalized || (gravity && cmHipaaPublicId('gravity', mainId) !== normalized)) return null;
     40    return { builder: builder, id: normalized, formId: builder === 'gravity' ? 'gform_' + normalized : normalized };
     41}
     42
     43function cmHipaaPublicFormRoute(form, config) {
     44    var identity = cmHipaaPublicFormIdentity(form);
     45    var refused = { enabled: false, builder: '', id: '', formId: '', settings: null };
     46    if (!identity || config.formSettingsReadable === 'no') return refused;
     47    var rows = cmHipaaPublicArray(config.enabledFormsSettings);
     48    if (!rows) return refused;
     49    var matches = [];
     50    var released = [];
     51    for (var index = 0; index < rows.length; index++) {
     52        var row = rows[index];
     53        if (!row || typeof row !== 'object' || Array.isArray(row) || (row.enabled !== 'yes' && row.enabled !== 'no')) continue;
     54        // Same rule as cm_hipaa_form_governing_row: a row with no builder, or one that cannot own its id, matches by id.
     55        var labeled = row.form_builder === 'native' ? /^cmhf[1-9][0-9]{0,15}$/.test(String(row.id))
     56            : !!cmHipaaPublicId(row.form_builder, row.id);
     57        if (!labeled) {
     58            if (cmHipaaPublicId(identity.builder, row.id) === identity.id) released.push(row);
     59        } else if (row.form_builder === identity.builder && cmHipaaPublicId(row.form_builder, row.id) === identity.id) {
     60            matches.push(row);
     61        }
     62    }
     63    var governing = null;
     64    (matches.length ? matches : released).forEach(function (row) {
     65        if (!governing || row.enabled === 'yes' || governing.enabled !== 'yes') governing = row;
     66    });
     67    if (governing) {
     68        identity.enabled = governing.enabled === 'yes';
     69        identity.settings = governing;
     70        return identity;
     71    }
     72
     73    // A saved row, including an explicit disable, takes precedence over the old CSV list.
     74    var legacy = cmHipaaPublicArray(config[identity.builder === 'gravity' ? 'gravityEnabledForms' : 'calderaEnabledForms']);
     75    if (!legacy) return refused;
     76    identity.enabled = legacy.some(function (id) {
     77        return cmHipaaPublicId(identity.builder, id) === identity.id;
     78    });
     79    identity.settings = null;
     80    return identity;
     81}
    482
    583// IE FIX FOR startsWith METHOD
    … …  
    23101
    24102    return JSON.parse(data);
     103}
     104
     105// A choice value that differs from its label shows after the label. Inline styles keep the look in print and the PDF.
     106function cmHipaaChoicePill(value) {
     107    if (!value) {
     108        return '';
     109    }
     110    return jQuery('<span class="cm-hipaa-forms-choice-value" style="display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid #d0d5dd; border-radius: 8px; background: #f2f4f7; color: #667085; font-size: 0.8em; line-height: 1.5; vertical-align: middle; white-space: nowrap;"></span>').text(value);
    25111}
    26112
    … …  
    150236    /*** CHECK IF FORMS ON THE PAGE ***/
    151237    var forms = jQuery('form');
    152     var formBuilder = cmHipaaScript.formBuilder;
    153 
    154     var calderaEnabledForms;
    155     if(cmHipaaScript.calderaEnabledForms) {
    156         calderaEnabledForms = JSON.parse(cmHipaaScript.calderaEnabledForms);
    157     }
    158 
    159     var gravityEnabledForms;
    160     if(cmHipaaScript.gravityEnabledForms) {
    161         gravityEnabledForms = JSON.parse(cmHipaaScript.gravityEnabledForms);
    162     }
    163 
    164     var enabledFormsSettings;
    165     if(cmHipaaScript.enabledFormsSettings) {
    166         enabledFormsSettings = JSON.parse(cmHipaaScript.enabledFormsSettings);
    167     }
    168 
    169     formIds = [];
    170     // LOOP ENABLED CALDERA FORMS AND PUSH IDS TO ARRAY - DEPRECATED
    171     for(var i = 0; i < calderaEnabledForms.length; i++){
    172         if(calderaEnabledForms[i]) {
    173             formIds.push(calderaEnabledForms[i]);
    174         }
    175     }
    176 
    177     // LOOP ENABLED GRAVITY FORMS AND PUSH IDS TO ARRAY - DEPRECATED
    178     for(var i = 0; i < gravityEnabledForms.length; i++){
    179         if(gravityEnabledForms[i]) {
    180             formIds.push('gform_' + gravityEnabledForms[i]);
    181         }
    182     }
    183238    /*** LOOP FORMS ***/
    184239    forms.each(function() {
    185240        var form = jQuery(this);
    186241        var formMainId = form.attr('id');
    187         var formId = form.attr('data-form-id');
    188         if(!formId) {
    189             formId = formMainId;
     242        var routing = cmHipaaPublicFormRoute(form, cmHipaaScript);
     243        if (!routing.enabled) return;
     244        var formId = routing.formId;
     245        var newSubmitButton = '<div class="cm-hipaa-forms-submit ' + routing.builder + ' cm-hipaa-forms-button active" role="button" tabindex="0"><i class="material-icons">lock</i> SUBMIT</div>';
     246        var showSig = cmHipaaScript.enabledFormsSettings ? undefined : 'yes';
     247        if (routing.settings) {
     248            if (routing.settings.show_signature) showSig = routing.settings.show_signature;
     249            if (routing.settings.submit_btn_text) {
     250                newSubmitButton = '<div class="cm-hipaa-forms-submit ' + routing.builder + ' cm-hipaa-forms-button active" role="button" tabindex="0">' + routing.settings.submit_btn_text + '</div>';
     251            }
    190252        }
    191 
    192         // SET NEW SUBMIT BUTTON
    193         var newSubmitButton;
    194         if(formId && formId.startsWith('gform_')) {
    195             newSubmitButton = '<div class="cm-hipaa-forms-submit gravity cm-hipaa-forms-button active" role="button" tabindex="0" ><i class="material-icons">lock</i> SUBMIT</div>';
    196         } else {
    197             newSubmitButton = '<div class="cm-hipaa-forms-submit caldera cm-hipaa-forms-button active" role="button" tabindex="0" ><i class="material-icons">lock</i> SUBMIT</div>';
    198         }
    199 
    200         var showSig;
    201         if(!enabledFormsSettings) {
    202             // IF NEW ENABLED FORMS SETTINGS DOESN'T EXIST SET SIGNATURE TO YES
    203             showSig = 'yes';
    204         }
    205 
    206         // CHECK IF FORM OBJECT EXISTS IN ARRAY - NEW FORMS SETTINGS JSON OBJECT ARRAY METHOD
    207         var formFound;
    208         if(cmHipaaScript.enabledFormsSettings) {
    209             enabledFormsSettings.some(function (el) {
    210                 if (el.id === formId && el.enabled === 'yes' || el.form_builder === 'gravity' && 'gform_' + el.id === formId && el.enabled === 'yes') {
    211                     formFound = true;
    212 
    213                     // IF SIGNATURE OPTION HAS VALUE SET IT
    214                     if(el.show_signature) {
    215                         showSig = el.show_signature;
    216                     }
    217                     // SET SUBMIT BUTTON
    218                     if(el.submit_btn_text){
    219                         if(el.form_builder === 'gravity' && 'gform_' + el.id === formId){
    220                             newSubmitButton = '<div class="cm-hipaa-forms-submit gravity cm-hipaa-forms-button active" role="button" tabindex="0" >' + el.submit_btn_text + '</div>';
    221                         } else {
    222                             newSubmitButton = '<div class="cm-hipaa-forms-submit caldera cm-hipaa-forms-button active" role="button" tabindex="0" >' + el.submit_btn_text + '</div>';
    223                         }
    224                     }
    225                 }
    226             });
    227         }
    228         // IF FORM ID IN DEPRECATED METHOD OR FORM FOUND IN NEW JSON OBJECT ARRAY METHOD
    229         if(jQuery.inArray(formId, formIds) !== -1 || formFound) {
     253        if (routing.enabled) {
    230254            // CHECK IF SSL ENABLED
    231255            var protocol = document.location.protocol;
    … …  
    12781302        var noticeEle = form.find('.cm-hipaa-notice');
    12791303        var formMainId = form.attr('id');
    1280         var formId = form.attr('data-form-id');
    1281         if(!formId) {
    1282             formId = formMainId;
     1304        var routing = cmHipaaPublicFormRoute(form, cmHipaaScript);
     1305        if (!routing.enabled || routing.builder !== 'caldera') {
     1306            e.preventDefault();
     1307            noticeEle.text('This form is not available. Reload the page.');
     1308            return;
    12831309        }
     1310        var formId = routing.formId;
    12841311
    12851312        // REMOVE ACTIVE CLASS FROM SUBMIT BUTTON TO PREVENT RE-SUBMITTING
    12861313        submitButton.removeClass('active').addClass('inactive');
    12871314
    1288         var calderaEnabledForms = JSON.parse(cmHipaaScript.calderaEnabledForms); // DEPRECATED
    1289         formIds = [];
    1290 
    1291         // LOOP CALDERA FORMS AND PUSH IDS TO ARRAY - DEPRECATED
    1292         for(var i = 0; i < calderaEnabledForms.length; i++){
    1293             if(calderaEnabledForms[i]) {
    1294                 formIds.push(calderaEnabledForms[i]);
    1295             }
    1296         }
    1297 
    1298         var enabledFormsSettings;
    1299         if(cmHipaaScript.enabledFormsSettings) {
    1300             enabledFormsSettings = JSON.parse(cmHipaaScript.enabledFormsSettings); // NEW JSON OBJECT ARRAY
    1301         }
    1302 
    1303 
    1304         // CHECK IF FORM OBJECT EXISTS IN ARRAY - NEW FORMS SETTINGS JSON OBJECT ARRAY METHOD
    1305         var formFound = false;
    1306         var successHandler;
    1307         var successMessage;
    1308         var successHideForm;
    1309         var successRedirect;
    1310         var successCallback;
    1311         var successCallbackParams;
    1312         var selectedUserSlug = '';
    1313         var showSignature;
    1314         var notificationOption = '';
    1315 
    1316         if(cmHipaaScript.enabledFormsSettings) {
    1317             enabledFormsSettings.some(function (el) {
    1318                 if (el.id === formId && el.enabled === 'yes') {
    1319                     formFound = true;
    1320                     successHandler = el.success_handler;
    1321                     successMessage = el.success_message;
    1322                     successHideForm = el.success_hide_form;
    1323                     successRedirect = el.success_redirect;
    1324                     successCallback = el.success_callback;
    1325                     successCallbackParams = el.success_callback_params;
    1326                     selectedUserSlug = el.selected_user_slug;
    1327                     showSignature = el.show_signature;
    1328                     notificationOption = el.notification_option;
    1329                 }
    1330             });
    1331         }
     1315        var settings = routing.settings || {};
     1316        var formFound = Boolean(routing.settings);
     1317        var successHandler = settings.success_handler;
     1318        var successMessage = settings.success_message;
     1319        var successHideForm = settings.success_hide_form;
     1320        var successRedirect = settings.success_redirect;
     1321        var successCallback = settings.success_callback;
     1322        var successCallbackParams = settings.success_callback_params;
     1323        var selectedUserSlug = routing.settings ? settings.selected_user_slug : '';
     1324        var showSignature = settings.show_signature;
     1325        var notificationOption = routing.settings ? settings.notification_option : '';
    13321326
    13331327        // SET SUCCESS MESSAGE IF NOT SET
    … …  
    13371331
    13381332        // IF FORM ID IS IN ENABLED FORMS PREVENT DEFAULT SUBMIT AND SEND TO CODE MONKEYS
    1339         if(jQuery.inArray(formId, formIds) !== -1 || formFound) {
     1333        if(routing.enabled) {
    13401334            e.preventDefault(); //Prevent the normal submission action
    13411335            var defaultBorder;
    … …  
    14821476                    } else if (fieldType === 'checkbox') {
    14831477                        // SET CHECKBOX VALUE IF DIFFERENT THAN LABEL
    1484                         if(value !== checkboxLabel) {
    1485                             checkboxValue = value;
    1486                         }
     1478                        checkboxValue = value !== checkboxLabel ? value : '';
    14871479
    14881480                        if (jQuery(this).prop('checked') === true) {
    14891481                            // SET CHECKED CHECKBOX IMAGE AND VALUE
    1490                             value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + checkboxValue + '</span>';
     1482                            value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';
     1483                            if (jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')) {
     1484                                value = value.replace('</span>', checkboxValue + '</span>');
     1485                            } else {
     1486                                jQuery(this).parent().append(cmHipaaChoicePill(checkboxValue));
     1487                            }
    14911488                            jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-checked-wrapper');
    14921489                            if(checkboxParentLabel) {
    … …  
    15011498                    } else if (fieldType === 'radio') {
    15021499                        // SET RADIO VALUE IF DIFFERENT THAN LABEL
    1503                         if (value !== checkboxLabel) {
    1504                             radioValue = value;
    1505                         }
     1500                        radioValue = value !== checkboxLabel ? value : '';
    15061501                        if (jQuery(this).prop('checked') === true) {
    15071502                            // SET CHECKED RADIO BUTTON IMAGE AND VALUE
    1508                             value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + radioValue + '</span>';
     1503                            value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';
     1504                            if (jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')) {
     1505                                value = value.replace('</span>', radioValue + '</span>');
     1506                            } else {
     1507                                jQuery(this).parent().append(cmHipaaChoicePill(radioValue));
     1508                            }
    15091509                            jQuery(this).parent().addClass('cm-hipaa-forms-radio-checked-wrapper');
    15101510                            if (checkboxParentLabel) {
    … …  
    21272127        var noticeEle = form.find('.cm-hipaa-notice');
    21282128        var formMainId = form.attr('id');
    2129         var formId = form.attr('data-form-id');
     2129        var routing = cmHipaaPublicFormRoute(form, cmHipaaScript);
     2130        if (!routing.enabled || routing.builder !== 'gravity') {
     2131            e.preventDefault();
     2132            noticeEle.text('This form is not available. Reload the page.');
     2133            return;
     2134        }
     2135        var formId = routing.formId;
     2136
    21302137        var newFormat = false;
    21312138        var legacyMarkup = false;
    2132         if(!formId) {
    2133             formId = formMainId;
    2134         }
    21352139
    21362140        // REMOVE ALL TAGS BEFORE CLONING FORM
    … …  
    21802184        jQuery('.validation_error').remove();
    21812185
    2182         var gravityEnabledForms = JSON.parse(cmHipaaScript.gravityEnabledForms); // DEPRECATED
    2183         formIds = [];
    2184 
    2185         // LOOP GRAVITY FORMS AND PUSH IDS TO ARRAY - DEPRECATED
    2186         for(var i = 0; i < gravityEnabledForms.length; i++){
    2187             if(gravityEnabledForms[i]) {
    2188                 formIds.push('gform_' + gravityEnabledForms[i]);
    2189             }
    2190         }
    2191 
    2192         var enabledFormsSettings;
    2193         if(cmHipaaScript.enabledFormsSettings) {
    2194             enabledFormsSettings = JSON.parse(cmHipaaScript.enabledFormsSettings); // NEW JSON OBJECT ARRAY
    2195         }
    2196 
    2197         // CHECK IF FORM OBJECT EXISTS IN ARRAY - NEW FORMS SETTINGS JSON OBJECT ARRAY METHOD
    2198         var formFound;
    2199         var successHandler;
    2200         var successMessage;
    2201         var successHideForm;
    2202         var successRedirect;
    2203         var successCallback;
    2204         var successCallbackParams;
    2205         var selectedUserSlug = '';
    2206         var showSignature;
    2207         var notificationOption = '';
    2208 
    2209         if(cmHipaaScript.enabledFormsSettings) {
    2210             enabledFormsSettings.some(function (el) {
    2211                 if (el.form_builder === 'gravity' && 'gform_' + el.id === formId && el.enabled === 'yes') {
    2212                     formFound = true;
    2213                     successHandler = el.success_handler;
    2214                     successMessage = el.success_message;
    2215                     successHideForm = el.success_hide_form;
    2216                     successRedirect = el.success_redirect;
    2217                     successCallback = el.success_callback;
    2218                     successCallbackParams = el.success_callback_params;
    2219                     selectedUserSlug = el.selected_user_slug;
    2220                     showSignature = el.show_signature;
    2221                     notificationOption = el.notification_option;
    2222                 }
    2223             });
    2224         }
     2186        var settings = routing.settings || {};
     2187        var formFound = Boolean(routing.settings);
     2188        var successHandler = settings.success_handler;
     2189        var successMessage = settings.success_message;
     2190        var successHideForm = settings.success_hide_form;
     2191        var successRedirect = settings.success_redirect;
     2192        var successCallback = settings.success_callback;
     2193        var successCallbackParams = settings.success_callback_params;
     2194        var selectedUserSlug = routing.settings ? settings.selected_user_slug : '';
     2195        var showSignature = settings.show_signature;
     2196        var notificationOption = routing.settings ? settings.notification_option : '';
    22252197
    22262198        // SET SUCCESS MESSAGE IF NOT SET
    … …  
    22302202
    22312203        // IF FORM ID IS IN ENABLED FORMS PREVENT DEFAULT SUBMIT AND SEND TO CODE MONKEYS
    2232         if(jQuery.inArray(formId, formIds) !== -1 || formFound) {
     2204        if(routing.enabled) {
    22332205            e.preventDefault(); //Prevent the normal submission action
    22342206
    … …  
    29892961                    } else if (fieldType === 'checkbox') {
    29902962                        // SET CHECKBOX VALUE IF DIFFERENT THAN LABEL
    2991                         if (value !== checkboxLabel && !jQuery(this).parent().hasClass('ginput_container_consent')) {
    2992                             checkboxValue = value;
    2993                         }
     2963                        checkboxValue = value !== checkboxLabel && !jQuery(this).parent().hasClass('ginput_container_consent') ? value : '';
    29942964
    29952965                        if (jQuery(this).prop('checked') === true) {
    29962966                            // SET CHECKED CHECKBOX IMAGE AND VALUE
    2997                             value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + checkboxValue + '</span>';
     2967                            value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';
     2968                            if (jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')) {
     2969                                value = value.replace('</span>', checkboxValue + '</span>');
     2970                            } else {
     2971                                jQuery(this).parent().append(cmHipaaChoicePill(checkboxValue));
     2972                            }
    29982973                            // ADD CHECKED WRAPPER CLASS TO PARENT ELEMENT
    29992974                            jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-checked-wrapper');
    … …  
    30112986                    } else if (fieldType === 'radio') {
    30122987                        // SET RADIO VALUE IF DIFFERENT THAN LABEL
    3013                         if (value !== checkboxLabel) {
    3014                             radioValue = value;
    3015                         }
     2988                        radioValue = value !== checkboxLabel ? value : '';
    30162989
    30172990                        if (jQuery(this).prop('checked') === true) {
    30182991                            // SET CHECKED RADIO BUTTON IMAGE AND VALUE
    3019                             value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + radioValue + '</span>';
     2992                            value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';
     2993                            if (jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')) {
     2994                                value = value.replace('</span>', radioValue + '</span>');
     2995                            } else {
     2996                                jQuery(this).parent().append(cmHipaaChoicePill(radioValue));
     2997                            }
    30202998                            jQuery(this).parent().addClass('cm-hipaa-forms-radio-checked-wrapper');
    30212999
  • codemonkeys-hipaa-forms/trunk/readme.txt

    r3782901 r3791567  
    22Contributors: codemonkeys
    33Tags: hipaa forms, gravity forms, secure forms, health forms, medical forms
    4 Requires at least: 5.4
     4Requires at least: 6.0
    55Tested up to: 7.1.4
    6 Stable tag: 3.3.6
     6Stable tag: 3.3.7
    77License: GPLv2
    88
    9 Add HIPAA Compliant web forms easily to your Wordpress website using the HIPAA FORMS SaaS Service and Gravity Forms.
     9Build secure web forms with the included form builder and the HIPAA FORMS service, or connect existing Gravity Forms.
    1010
    1111== Description ==
    … …  
    1616
    1717*** ATTENTION ***
    18 A free comprehensive native form builder will be included in the next release removing the dependency on Gravity Forms.
     18Includes a native form builder and Gravity Forms import. Gravity Forms is optional.
    1919
    2020If you need a more robust solution, please see our new EHR, practice management and patient portal solution at https://akashic.health or search the Wordpress repository for Akashic Health Records.
    … …  
    2727***
    2828
    29 The HIPAA FORMS plugin allows you to create web forms using Gravity Forms just like you would a simple contact form.  A simple checkbox next to the form within the plugin admin interface instantly takes over your form, appends the form with a HIPAA Compliant badge and signature field where users can sign by dragging their mouse or with their finger on touch screens, and upon submit encrypts the data and pushes it to the HIPAA FORMS Service API which then stores it within a HIPAA Compliant storage solution.
     29The HIPAA FORMS plugin includes a form builder and supports existing Gravity Forms. Native forms use the HIPAA FORMS service automatically. For Gravity Forms, a checkbox next to the form within the plugin admin interface takes over your form, appends the form with a HIPAA Compliant badge and signature field where users can sign by dragging their mouse or with their finger on touch screens, and upon submit encrypts the data and pushes it to the HIPAA FORMS Service API which then stores it within a HIPAA Compliant storage solution.
    3030
    3131Users with login credentials and the appropriate user roles (administrator or hipaa) can then log into your Wordpress administrator dashboard and search/view the submitted forms and even generate an encrypted and password protected PDF file of the form which can then be printed or saved to a hard drive.
    … …  
    8181Next make sure you have Caldera Forms or Gravity Forms installed and active.  Caldera is a free form builder plugin that can easily be installed from the "plugins->add" interface and searching for Caldera Forms.  Gravity Forms is a premium paid form builder plugin that can be purchased <a href="https://www.gravityforms.com/" target="_blank">HERE</a> No additional extensions are needed.
    8282
    83 Now that you have your license key and Caldera or Gravity Forms installed and activated, go to the "Settings" tab and add your license key, select your preferred compatible form builder plugin (ie. Caldera or Gravity), enter the email address you wish to receive form submission notices to and set your preferred time zone.  If you plan on using the custom HIPAA FORMS user role you can also set what permissions that role should have here.
     83Now that you have your license key and Caldera or Gravity Forms installed and activated, go to HIPAA Forms > Plugin settings and add your license key, select your preferred compatible form builder plugin (ie. Caldera or Gravity), enter the email address you wish to receive form submission notices to and set your preferred time zone.  If you plan on using the custom HIPAA FORMS user role you can also set what permissions that role should have here.
    8484
    8585Once the plugin settings are save you need to create a form.  You must have 4 required fields in the form which are needed in order to filter/search the submitted forms. These fields are:
    … …  
    169169
    170170WHAT IS A BAA?
    171 A Business Associate Agreement (BAA) typically is required for companies that are subject to the Health Insurance Portability and Accountability Act (HIPAA) to ensure that protected health information (PHI) is appropriately safeguarded. Failure to manage data privacy risks with non-business associate vendors may lead to both violations of HIPAA and state privacy laws.  You will be unable to use the HIPAA FORMS Service until you have signed the BAA with Code Monkeys LLC (the developers of the service) and will receive a notice to do so within the "submitted forms" tab as well as in the settings tab until it has been signed.  We HIGHLY recommend that you have a BAA in place with your web designer as well if you use a 3rd party contractor for web design service.
     171A Business Associate Agreement (BAA) typically is required for companies that are subject to the Health Insurance Portability and Accountability Act (HIPAA) to ensure that protected health information (PHI) is appropriately safeguarded. Failure to manage data privacy risks with non-business associate vendors may lead to both violations of HIPAA and state privacy laws.  You will be unable to use the HIPAA FORMS Service until you have signed the BAA with Code Monkeys LLC (the developers of the service) and will receive a notice to do so on the Submitted forms page as well as in Plugin settings until it has been signed.  We HIGHLY recommend that you have a BAA in place with your web designer as well if you use a 3rd party contractor for web design service.
    172172
    173173CAN WE USE OUR OWN BAA INSTEAD OF YOURS?
    … …  
    203203
    204204== Changelog ==
    205 V3.3.7 (PENDING RELEASE)
     205V3.3.7 (MAJOR UPDATE!)
    206206- Built in free native form builder
    207207- Gravity Forms import tool for existing forms
    208208- Native quiz feature with scoring and pass/fail
     209- Moved tabs out of main submitted forms view into separate pages to improve performance and improve user experience/navigation
     210- Minor style rendering improvements in submitted forms and secure pdf generation
    209211
    210212V3.3.6
Note: See TracChangeset for help on using the changeset viewer.