Plugin Directory

Changeset 2001946


Ignore:
Timestamp:
12/26/2018 11:34:54 PM (7 years ago)
Author:
felipemontoya
Message:

Adding version 1.6.0 to the trunk

Location:
edunext-openedx-integrator/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • edunext-openedx-integrator/trunk/includes/class-wp-edunext-eox-core-api.php

    r1946360 r2001946  
    6464            add_action('eoxapi_after_settings_page_html', array($this, 'eoxapi_settings_custom_html'));
    6565            add_action('wp_ajax_save_users_ajax', array($this, 'save_users_ajax'));
     66            add_action('wp_ajax_get_users_ajax', array($this, 'get_users_ajax'));
    6667            add_action('wp_ajax_get_userinfo_ajax', array($this, 'get_userinfo_ajax'));
    6768            add_action('wp_ajax_save_enrollments_ajax', array($this, 'save_enrollments_ajax'));
     
    9293                    'default' => '',
    9394                    'placeholder' => ''
     95                ) ,
     96                array(
     97                    'id' => 'eox_client_wc_field_mappings',
     98                    'label' => __('User fields mappings', 'wp-edunext-marketing-site') ,
     99                    'description' => __('Mapping of user fields for pre-filling, from Open-edX (extended_profile) to Woocommerce', 'wp-edunext-marketing-site', 'wp-edunext-marketing-site') ,
     100                    'type' => 'text',
     101                    'default' => '',
     102                    'placeholder' => '{"wc_example": "example"}'
    94103                )
    95104            )
     
    145154            }
    146155        }
     156        $this->show_notices();
     157        wp_die();
     158    }
     159
     160    /**
     161     * Called with AJAX function to POST to users API
     162     */
     163    public function get_users_ajax() {
     164        $new_users = $this->handle_ajax_json_input($_POST['users']);
     165        $users_info = [];
     166        if ($new_users) {
     167            foreach ($new_users as $user) {
     168                $users_info[] = $this->get_user_info($user);
     169            }
     170        }
     171        $this->add_notice('user-info', '<pre>' . json_encode($users_info, JSON_PRETTY_PRINT) . '</pre>');
    147172        $this->show_notices();
    148173        wp_die();
     
    244269        $success_message = 'User creation success!';
    245270        return $this->api_call($api_url, $data, $ref, $success_message);
     271    }
     272
     273    /**
     274     * Function to execute the API calls required to get an existing edxapp user
     275     */
     276    public function get_user_info($args) {
     277        $args = (array)$args;
     278        $api_url = self::PATH_USER_API;
     279        $ref = $args['email'] ?: $args['username'] ?: '';
     280        $success_message = 'User fetching success!';
     281        $api_url .= '?' . http_build_query($args);
     282        return $this->api_call($api_url, NULL, $ref, $success_message);
    246283    }
    247284
  • edunext-openedx-integrator/trunk/includes/class-wp-edunext-marketing-site-settings.php

    r1931230 r2001946  
    155155                    'default'       => '',
    156156                    'placeholder'   => __( '', 'wp-edunext-marketing-site' )
     157                ),
     158                array(
     159                    'id'                => 'enable_woocommerce_integration',
     160                    'label'             => __( 'Enable Eox-core Woocommerce integrations' , 'wp-edunext-marketing-site' ),
     161                    'description'       => __( 'Features: Checkout pre-filling', 'wp-edunext-marketing-site' ),
     162                    'type'              => 'checkbox',
     163                    'default'           => false,
     164                    'placeholder'       => __( '', 'wp-edunext-marketing-site' ),
     165                    'advanced_setting'  => true
    157166                ),
    158167                array(
  • edunext-openedx-integrator/trunk/includes/class-wp-edunext-marketing-site.php

    r1931230 r2001946  
    117117        // Add attributes for menus items
    118118        add_action( 'init', array( 'Edx_Walker_Nav_Menu_Edit', 'setup' ) );
     119
     120        if ( get_option('wpt_enable_woocommerce_integration') ) {
     121            $this->woocommerce = new WP_eduNEXT_Woocommerce_Integration();
     122        }
    119123
    120124        if ( is_admin() ) {
  • edunext-openedx-integrator/trunk/includes/templates/exoapi_settings_custom_html.php

    r1922563 r2001946  
    5252        <option value="exoapi-add-new-users" selected>Users</option>
    5353        <option value="exoapi-add-new-enrollments">Enrollments</option>
     54        <option value="exoapi-get-users">Get users info</option>
    5455    </select>
    55    
     56    <div class="exoapi-get-users">
     57        <h2>Get Open edx users info</h2>
     58        <p>
     59            Write an array of users as JSON array:
     60        </p>
     61        <textarea name="eox-api-get-users" id="eox-api-get-users" cols="70" rows="10">
     62[{
     63    "username": "honor"
     64}]</textarea>
     65        <button class="button-secondary get-users-button">Execute API call</button>
     66    </div>
    5667    <div class="exoapi-add-new-users">
    5768        <h2>Add new Open edx users</h2>
     
    109120    });
    110121
     122    $('.get-users-button').click(function (e) {
     123        var data = {users: $('#eox-api-get-users').val()};
     124        callAction('get_users_ajax', data);
     125        e.stopPropagation();
     126        return false;
     127    });
     128
    111129    $('.save-enrollments-button').click(function (e) {
    112130        var data = {enrollments: $('#eox-api-new-enrollments').val()};
  • edunext-openedx-integrator/trunk/readme.txt

    r1946360 r2001946  
    44Requires at least: 3.9
    55Tested up to: 4.9.5
    6 Stable tag: 1.5.0
     6Stable tag: 1.6.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • edunext-openedx-integrator/trunk/wp-edunext-marketing-site.php

    r1946360 r2001946  
    2323require_once( 'includes/class-wp-edunext-marketing-site-settings.php' );
    2424require_once( 'includes/class-wp-edunext-eox-core-api.php' );
     25require_once( 'includes/class-wp-edunext-eox-woocommerce-integration.php' );
    2526
    2627// Load plugin libraries
     
    6364
    6465WP_EoxCoreApi();
    65 
Note: See TracChangeset for help on using the changeset viewer.