function get_feeds($feed_add_on)
 {
     $form_id = $this->get_form_id();
     $feeds = array();
     if (is_subclass_of($feed_add_on['class'], 'GFFeedAddOn')) {
         /* @var GFFeedAddOn $add_on */
         $add_on = call_user_func(array($feed_add_on['class'], 'get_instance'));
         $feeds = $add_on->get_feeds($form_id);
     } else {
         // Legacy add-ons
         switch ($feed_add_on['slug']) {
             case 'gravityformszapier':
                 if (class_exists('GFZapierData')) {
                     $feeds = GFZapierData::get_feed_by_form($form_id);
                 }
                 break;
             case 'gravityformsuserregistration':
                 if (class_exists('GFUserData')) {
                     $feeds = GFUserData::get_feeds($form_id);
                 }
                 break;
         }
     }
     return $feeds;
 }
 function get_feeds()
 {
     $form_id = $this->get_form_id();
     if (class_exists('GF_User_Registration')) {
         $feeds = parent::get_feeds();
     } else {
         $feeds = GFUserData::get_feeds($form_id);
     }
     return $feeds;
 }
Ejemplo n.º 3
0
 public static function get_pending_activation_forms()
 {
     $forms = RGFormsModel::get_forms(null, 'title');
     $feeds = GFUserData::get_feeds();
     $available_form_ids = array();
     foreach ($feeds as $feed) {
         if (self::is_pending_activation_enabled($feed)) {
             $available_form_ids[] = $feed['form_id'];
         }
     }
     $available_form_ids = array_unique($available_form_ids);
     $available_forms = array();
     foreach ($forms as $form) {
         if (in_array($form->id, $available_form_ids)) {
             $available_forms[] = $form;
         }
     }
     return $available_forms;
 }
Ejemplo n.º 4
0
    public static function add_paypal_user_registration_options($config, $form)
    {
        global $wp_roles;
        // activate user registration tooltips for integration with PayPal plugin
        add_filter('gform_tooltips', array('GFUser', 'tooltips'));
        $id = rgget('id');
        $registration_config = self::get_config(rgar($config, 'form_id'));
        $registration_feeds = GFUserData::get_feeds();
        $registration_forms = array();
        foreach ($registration_feeds as $feed) {
            $registration_forms[] = $feed['form_id'];
        }
        $json_registration_forms = GFCommon::json_encode($registration_forms);
        if (empty($json_registration_forms)) {
            $json_registration_forms = '[]';
        }
        $roles = array_keys($wp_roles->roles);
        $display_registration_options = !empty($registration_config) ? '' : 'display:none;';
        $display_multisite_options = is_multisite() && self::is_root_site() && $config['meta']['type'] == 'subscription' ? '' : 'display:none;';
        ?>

        <script type="text/javascript">
            jQuery(document).ready(function($){
                $(document).bind('paypalFormSelected', function(event, form) {

                    var registration_form_ids = <?php 
        echo $json_registration_forms;
        ?>
;
                    var transaction_type = $("#gf_paypal_type").val();
                    var form = form;
                    var has_registration = false;
                    var display_multisite_options = <?php 
        echo is_multisite() && self::is_root_site() ? 'true' : 'false';
        ?>
;

                    if($.inArray(String(form['id']), registration_form_ids) != -1)
                        has_registration = true;

                    if(has_registration == true) {
                        $("#gf_paypal_user_registration_options").show();
                    } else {
                        $("#gf_paypal_user_registration_options").hide();
                    }

                    $("#gf_paypal_update_user_option, #gf_paypal_update_site_option").hide();

                    if(transaction_type == "subscription")
                        $("#gf_paypal_update_user_option").show();

                    if(transaction_type == "subscription" && display_multisite_options)
                        $("#gf_paypal_update_site_option").show();

                });
            });
        </script>

        <div id="gf_paypal_user_registration_options" class="margin_vertical_10" style="<?php 
        echo $display_registration_options;
        ?>
">
            <label class="left_header"><?php 
        _e("User Registration", "gravityformsuserregistration");
        ?>
 <?php 
        gform_tooltip("user_registration_paypal_user_options");
        ?>
</label>

            <ul style="overflow:hidden;">

                <!-- Standard Options -->

                <li>
                    <input type="checkbox" name="gf_paypal_delay_registration" id="gf_paypal_delay_registration" value="1" <?php 
        echo rgar($config['meta'], 'delay_registration') ? "checked='checked'" : "";
        ?>
 />
                    <label class="inline" for="gf_paypal_delay_registration">
                        <?php 
        if (!is_multisite()) {
            _e("Register user only when a payment is received.", "gravityformsuserregistration");
        } else {
            _e("Register user and create site only when a payment is received.", "gravityformsuserregistration");
        }
        ?>
                    </label>
                </li>

                <li id="gf_paypal_update_user_option" <?php 
        echo rgars($config, "meta/type") == "subscription" ? "" : "style='display:none;'";
        ?>
>
                    <input type="checkbox" name="gf_paypal_update_user" id="gf_paypal_update_user" value="1" <?php 
        echo rgars($config, "meta/update_user_action") ? "checked='checked'" : "";
        ?>
 onclick="var action = this.checked ? '<?php 
        echo $roles[0];
        ?>
' : ''; jQuery('#gf_paypal_update_user_action').val(action);" />
                    <label class="inline" for="gf_paypal_update_user"><?php 
        _e("Update <strong>user</strong> when subscription is cancelled.", "gravityformsuserregistration");
        ?>
</label>
                    <select id="gf_paypal_update_user_action" name="gf_paypal_update_user_action" onchange="var checked = jQuery(this).val() ? 'checked' : false; jQuery('#gf_paypal_update_user').attr('checked', checked);">
                        <option value=""></option>
                        <?php 
        foreach ($roles as $role) {
            $role_name = ucfirst($role);
            ?>
                            <option value="<?php 
            echo $role;
            ?>
" <?php 
            echo rgars($config, "meta/update_user_action") == $role ? "selected='selected'" : "";
            ?>
><?php 
            echo sprintf(__("Set User as %s", "gravityformsuserregistration"), $role_name);
            ?>
</option>
                        <?php 
        }
        ?>
                    </select>
                </li>

                <!-- Multisite Options -->

                <li id="gf_paypal_update_site_option" style="<?php 
        echo $display_multisite_options;
        ?>
">
                    <input type="checkbox" name="gf_paypal_update_site" id="gf_paypal_update_site" value="1" <?php 
        echo $config["meta"]["update_site_action"] ? "checked='checked'" : "";
        ?>
 onclick="var action = this.checked ? 'deactivate' : ''; jQuery('#gf_paypal_update_site_action').val(action);" />
                    <label class="inline" for="gf_paypal_update_site"><?php 
        _e("Update <strong>site</strong> when subscription is cancelled.", "gravityformsuserregistration");
        ?>
</label>
                    <select id="gf_paypal_update_site_action" name="gf_paypal_update_site_action" onchange="var checked = jQuery(this).val() ? 'checked' : false; jQuery('#gf_paypal_update_site').attr('checked', checked);">
                        <option value=""></option>
                        <?php 
        $site_options = array('deactivate' => __('Deactivate', 'gravityformsuserregistration'), 'delete' => __('Delete', 'gravityformsuserregistration'));
        ?>
                        <?php 
        foreach ($site_options as $option_key => $option_label) {
            ?>
                            <option value="<?php 
            echo $option_key;
            ?>
" <?php 
            echo $config["meta"]["update_site_action"] == $option_key ? "selected='selected'" : "";
            ?>
><?php 
            echo sprintf(__("%s site", "gravityformsuserregistration"), $option_key);
            ?>
</option>
                        <?php 
        }
        ?>
                    </select>
                </li>

            </ul>
        </div>

        <?php 
    }