Plugin Directory

Changeset 2943131


Ignore:
Timestamp:
07/25/2023 02:00:26 PM (3 years ago)
Author:
lmsace
Message:

Set v2.0 as default

Location:
lmsace-connect/trunk
Files:
11 added
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • lmsace-connect/trunk/README.md

    r2755933 r2943131  
    33==================
    44
    5 **LMSACE Connect** is a woocommerce integration plugin that focused on the Moodle + WooCommerce Integrations.
     5**LMSACE Connect** is a woocommerce integration plugin that focused on the Moodle™ Software + WooCommerce Integrations.
    66
    7 It gives the course creatores as options to import courses from the Moodle LMS and create courses as woocommerce products and sell their courses to customer.
     7It gives the course creatores as options to import courses from the Moodle™ Software and create courses as woocommerce products and sell their courses to customer.
    88
    9 Once the course products are purchased by customer, Plugin will create those users on Moodle LMS and enrol them into the linked course.
     9Once the course products are purchased by customer, Plugin will create those users on Moodle™ Software and enrol them into the linked course.
     10
     11With the new version, we've added exciting features to further enhance your e-learning experience. Enjoy the seamless login with SSO, sync multiple courses with a single product, and import course outline data effortlessly.
    1012
    1113
    12 ### Version
     14### Moodle™ Software Side Plugin.
    1315
    14 Plugin version: 1.0
     16Please install the Moodle™ Software side plugin to generate the token easier and setup the connection between Moodle™ Software and Wordpress. This plugin should be installed on your Moodle™ Software.
    1517
    16 Released on: 28 March 2022
    17 
    18 Authors: https://lmsace.com, LMSACE Dev Team
    19 
    20 ### Plugin Repository
    21 
    22 Publlic Git Repository
    23 [https://github.com/lmsace/lmsace-connect](https://github.com/lmsace/lmsace-connect)
    24 
    25 #### Moodle Side Plugin.
    26 Helps to genearate the token easier.
    2718[https://github.com/lmsace/lmsace-connect-moodle](https://github.com/lmsace/lmsace-connect-moodle)
    2819
    29 ## Dependencies
     20
     21### Dependencies
    3022
    3123Component: WooCommerce
     
    3527Plugin URI: https://woocommerce.com/
    3628
     29
    3730## Documenation
    3831
    39 The official documentation for LMSACE Connect can be found at [https://lmsace.com/docs/lmsace-connect](https://lmsace.com/docs/lmsace-connect).
     32The official documentation to setup connections and SSO between Moodle™ Software and WooCommerce using LMSACE Connect can be found at [https://github.com/lmsace/lmsace-connect-woocommerce/wiki](https://github.com/lmsace/lmsace-connect-woocommerce/wiki)
     33
    4034
    4135## Bugs and Problems Report.
    4236
    43 This plugin is carefully developed and highly tested with multiple version of Moodle LMS, WordPress, and WooCommerce. If you found any issues with LMSACE Connect or you have any problems or difficulty with its workflow please feel free to report on Github: http://github.com/lmsace/lmsace-connect/issues. We will do our best to solve the problems.
     37This plugin is carefully developed and highly tested with multiple versions of Moodle™ Software, WordPress, and WooCommerce. If you found any issues with LMSACE Connect or you have any problems or difficulty with its workflow please feel free to report on Github: http://github.com/lmsace/lmsace-connect/issues. We will do our best to solve the problems.
     38
    4439
    4540## Feature Proposals.
    4641
    47 You are develop custom feature for LMSACE Connect. Please create pull request and create issue on Github: https://github.com/lmsace/lmsace-connect/issues.
     42You are developing a custom feature for LMSACE Connect. Please create a pull request and create an issue on Github: https://github.com/lmsace/lmsace-connect/issues.
    4843
    4944
     
    5146
    52471. Selective Course Imports.
    53 2. Link course with existing products.
     482. Link the course with existing products.
    54493. User creation and enrolment on order completion.
    55 3. User unerollment on order cancellation.
    56 4. Selectable role for pariticipants.
     503. User un-enrollment on order cancellation.
     514. Selectable role for participants.
     525. Seamless login with SSO
     536. Bundle multiple courses in a product.
     547. Import courses with syllabus summary.
     55
    5756
    5857
     
    6160> **Note:** Make sure the **Woocommerce** is correctly installed.
    6261
    63 1. Clone Project Git repository in any of your prefered location.
     621. Download the latest "**LMSACE Connect WooCommerce**" plugin file from the [github releases](https://github.com/lmsace/lmsace-connect-woocommerce/releases)
    6463
    65 2. Rename the folder name into '**lmsace-connect**'.
     642. Next login as Site Administrator
    6665
    67 3. Next login as Site administrator
     663. Go to '*Plugins*' -> '*Add New*' -> '*Upload Plugin*', On here upload the plugin zip '**lmsace-connect.zip**'.
    6867
    69 4. Go to '*Plugins*' -> '*Add New*' -> '*Upload Plugin*', On here upload the plugin zip '**lmsace-connect.zip**'.
    70 
    71 5. Click the "**Instal Now**" button.
     684. Click the "**Instal Now**" button.
    7269
    7370
    74 > You will get **success message** once the plugin installed successfully.
     71> You will get a **success message** once the plugin is installed successfully.
    7572
    7673
    77 6. By clicking "**Activate**" button on success page , Plugin will activated and you will redirect to Your dashboard.
     745. By clicking the "**Activate**" button on the success page, Plugin will be activated and you will redirect to Your dashboard.
    7875
    7976
     
    8178
    8279
    83 1. Clone **LMSACE Connect** plugin Git repository into the folder '*plugins*'.
     801. Clone [**LMSACE Connect WooCommerce**](https://github.com/lmsace/lmsace-connect-woocommerce) plugin Git repository into the folder '*plugins*'.
    8481
    8582> '*Your root diroctory*' -> '*wp-content*' -> '*plugins*'.
    8683
    87 2. Rename the folder name into '**lmsace-connect**'.
     842. Rename the folder name to '**lmsace-connect**'.
    8885
    89 3. Next login as Site administrator
     863. Next login as Site Administrator
    9087
    91 4. Go to the '*Plugins*' -> '*Installed plugins*'. On here LMSACE Connect plugin will listed.
     884. Go to the '*Plugins*' -> '*Installed plugins*'. Here LMSACE Connect plugin will be listed.
    9289
    93 5. Activate the plugin by clicking "**Activate**" button placed on the bottom of the plugin name, Plugin will get the success message.
     905. Activate the plugin by clicking the "**Activate**" button placed on the bottom of the plugin name, Plugin will get the success message.
    9491
    9592
    96 ## Steps to setup connection.
    97 
    98 > Please install the moodle side plugin and generate webservice token in your Moodle LMS.<br> Follow the steps mentioned on the readme to generate token. [https://github.com/lmsace/lmsace-connect-moodle](https://github.com/lmsace/lmsace-connect-moodle)
    99 
    100 1. Log in as site administrator and go to admin backend.
    101 
    102 2. Go to the **LMSACE Connect**.
    103 
    104 3. Enter your Moodle Site URL and Site token which you can copy from your Moodle **LMSACE Connect** "*General*" tab.
    105 
    106 > Note: Test the given details are working fine using the "**Test Connection**" button.
    107 
    108 4. Please click the '**Save Change**' button to save the details.
    109 
    110 ![Connection Setup](https://www.lmsace.com/docs/lmsace-connect/images/connection-setup.png)
    111 
    112 > After you have saved the details, you can get the notification about the connection status. If you received any errors then please check the given details.
    113 
    114 5. Once you completed the connection setup successfully. Please goto the "**General Setup**" tab.
    115 
    116 6. In General setup, Please select the role for a customer user. The selected role will be assigned for the pariticipants who enrolled in the course from your WooCommerce.
    117 
    118 ![Connection Setup](https://www.lmsace.com/docs/lmsace-connect/images/general-setup.png)
    119 
    120 ## Import courses as products.
    121 
    122 
    123 > **LMSACE Connect** brings the course import as much easier compare with other moodle + woocommerce integrations options.
    124 
    125 1. Goto the "**Import courses**" tab in "**LMSACE Connect**" admin menu.
    126 
    127 2. In Import page, you can view the list of courses available in the connected Moodle LMS instance.
    128 
    129 3. Click the checkbox to select the courses you want to import.
    130 
    131 4. Select any or all options based on your need. After the course table, You can found the various "***Import Options***".
    132 
    133 5. Click the "**Start Import Courses**" button to import the selected courses.
    134 
    135 > **LMSACE Connect** will import the courses in background using WP_Schedule if you have tried to import more than 25 courses in single time.
    136 
    137 ![Import Courses](https://www.lmsace.com/docs/lmsace-connect/images/import-course.png)
     93> Once the wordpress side plugin was installed, Please **install the mandatory Moodle™ software side plugin to generate the token and setup the connection** between Moodle and Wordpress.
    13894
    13995
    14096## Copyright
    14197
    142 LMSACE DEV TEAM https://lmsace.com
     98@LMSACE DEV TEAM [https://lmsace.com](https://lmsace.com)
     99
    143100
    144101### Review
    145102
    146 You feel LMSACE Connect helps you to sell courses easier. Give a review and rating on wordpress.org. We are looking for your comments.
     103You feel LMSACE Connect helps you to sell courses easier. "**Give a review and rating on wordpress.org**". We are looking for your comments.
    147104
     105
     106### Changes log
     107
     1081. Version 1.0 ( Released on 28 March 2022 )
     109
     110     - Selective Course Imports.
     111     - Link course with existing products.
     112     - User creation and enrolment on order completion.
     113     - User un-erollment on order cancellation.
     114     - Selectable role for participants.
     115
     116
     1172. Version 2.0 ( Release on 25 July 2023 )
     118
     119     - Single Sign ON
     120     - Bundle courses in a product.
     121     - Import course data.
  • lmsace-connect/trunk/assets/css/styles.css

    r2755044 r2943131  
    5555}
    5656 #wpbody-content .lmsace-connect-admin-config .tab-content form {
    57    
     57
    5858}
    5959#wpbody-content .lmsace-connect-admin-config .dataTables_wrapper table.dataTable {
     
    106106
    107107#wpbody-content .lmsace-connect-admin-config .select2-container--default .select2-selection--multiple .select2-selection__choice {
    108     padding: 0.25em 0.4em;   
    109     font-weight: 700;   
     108    padding: 0.25em 0.4em;
     109    font-weight: 700;
    110110    text-align: center;
    111111    white-space: nowrap;
     
    119119#wpbody-content .lmsace-connect-admin-config tr:nth-child(4) th {
    120120    /* display: none; */
    121     font-size: 1.3em;
     121    /* font-size: 1.3em; */
    122122}
    123123
  • lmsace-connect/trunk/assets/js/admin.js

    r2755044 r2943131  
    2121            startSyncCourses($(this));
    2222        });
     23
     24        if ( $("#login_lms").length ) {
     25
     26            $("#login_lms").change(function() {
     27                hideRedirectLess();
     28            })
     29        }
    2330    }
    2431
     
    114121    function course_selectbox() {
    115122        if ($('.woocommerce_options_panel#course_options').length) {
    116             $('[name=lac_moodle_course_id]').select2();
     123            $('#lac_moodle_courses').select2();
    117124        }
    118125    }
     
    232239    }
    233240
     241    function hideRedirectLess() {
     242
     243        if ( !$("#login_lms").length ) {
     244            return '';
     245        }
     246
     247        if ($("#login_lms").val() == 'course') {
     248            $("#redirectless_login").prop('disabled', true);
     249            $("#redirectless_login").prop('readonly', true);
     250        } else {
     251            $("#redirectless_login").prop('disabled', false);
     252            $("#redirectless_login").prop('readonly', false);
     253        }
     254    }
     255
    234256    // Init.
    235257    register_event_handler();
    236258    importTable();
    237259    course_selectbox();
     260
     261    hideRedirectLess();
    238262})
  • lmsace-connect/trunk/includes/admin/class-lac-admin-request.php

    r2755044 r2943131  
    7979            $assign_category = in_array( 'course_category', $import_option) ? true : false;
    8080
     81            // $others = in_array( 'other', $import_option) ? $import_option['other'] : [];
     82
    8183            $selectedcourses = explode(',', $courses);
     84
     85            $service = 'get_courses_by_field';
     86
     87            $service = apply_filters('lmsace_connect_course_import_service', $service, $import_option);
    8288
    8389            if ( !empty($courses) && count($selectedcourses) < LACONN_IMPORT_LIMIT) {
    8490                /* Retrive Courses from Moodle  */
    85                 $courses = (array) $this->client->request(LACONN::services('get_courses_by_field'),
     91                $courses = (array) $this->client->request(LACONN::services($service),
    8692                    array(
    8793                        'field' => 'ids',
     
    94100
    95101                    // Create imported courses as product on WP.
    96                     $status = $this->courseSync->create_courses( $courses, $assign_category, $make_draft, $update_existing );
     102                    $status = $this->courseSync->create_courses( $courses, $assign_category, $make_draft, $update_existing, $import_option );
    97103                    if (isset($status['response_body'])) {
    98104                        $counts = $status['response_body'];
    99105                        $count = (count($counts['created'])) ? count($counts['created']).' courses created, ' : ' No courses created, ';
    100106                        $count .= (count($counts['updated'])) ? count($counts['updated']).' courses updated, ' : ' No courses updated, ';
    101                         $count .= (count($counts['existing'])) ? count($counts['existing']).' courses exists. ' : '';                   }
     107                        $count .= (count($counts['existing'])) ? count($counts['existing']).' courses exists. ' : '';                   
     108                    }
    102109
    103110                    $result = array('error' => false, 'message' => '<span class="connection-success">'.
     
    105112                    );
    106113                } else {
    107                     $result = array('error' => true, 'message' => '<span class="connection-error">'. esc_html(__( 'Courses not found on connected LMS site', LAC_TEXTDOMAIN ))).'</span>';
     114                    $result = array('error' => true, 'message' => '<span class="connection-error">'. esc_html(__( 'Courses not found on connected LMS site', LAC_TEXTDOMAIN )).'</span>');
    108115                }
    109116
     
    113120                if (!empty($count)) {
    114121                    $split = array_chunk($selectedcourses, LACONN_IMPORT_LIMIT);
    115                     $this->courseSync->set_schedule_course_import( $split, $assign_category, $make_draft, $update_existing );
     122                    $this->courseSync->set_schedule_course_import( $split, $assign_category, $make_draft, $update_existing, $import_option );
    116123                    $message = esc_html( __('Courses import process running in background. Please staty logged in.', LAC_TEXTDOMAIN));
    117124                    $result = array('error' => false, 'message' => '<span class="connection-info">'.$message.'</span>' );
  • lmsace-connect/trunk/includes/admin/class-lac-admin.php

    r2755933 r2943131  
    4242     */
    4343    public function get_tabs() {
    44         return [
     44        $tabs = [
    4545            'lac-connection-options' => esc_html( __( 'Connection Setup', 'lmsace-connect' )),
    4646            'lac-general-options' => esc_html( __('General Setup', 'lmsace-connect' )),
    4747            'lac-import-courses' => esc_html( __('Import Courses', 'lmsace-connect' )),
    4848        ];
     49
     50        return apply_filters( 'lmsace_connect_get_setting_tabs', $tabs);
    4951    }
    5052
     
    6769        add_filter( 'woocommerce_product_data_panels', 'lac_moodle_courses_product_tab_content' );
    6870        // Save course id for the prodct when the product Updated.
    69         add_action( 'woocommerce_process_product_meta_simple', 'lac_save_moodlecourse_option_fields'  );
    70         add_action( 'woocommerce_process_product_meta_variable', 'lac_save_moodlecourse_option_fields'  );
    71 
     71        add_action( 'woocommerce_process_product_meta_simple', array( $this, 'lac_save_moodlecourse_option_fields' ) );
     72        add_action( 'woocommerce_process_product_meta_variable', array( $this, 'lac_save_moodlecourse_option_fields' ) );
     73
     74        // Import courses and its course module details.
     75        add_filter( 'lmsace_connect_course_import_service', array($this, 'course_import_service'), 1, 2 );
     76        add_filter( 'lmsace_connect_before_course_update', array($this, 'before_course_update') );
    7277    }
    7378
     
    187192        $doc = new DOMDocument();
    188193        if (empty($course->summary)) {
    189             return sanitize_textarea_field( $course->summary );
     194            // return sanitize_textarea_field( $course->summary );
     195            return wp_kses_post_deep( $course->summary, $LACONN->allowed_tags());
    190196        }
    191197        @$doc->loadHTML($course->summary);
     
    193199        $images = $src = [];
    194200        foreach ($tags as $tag) {
     201            $class = $tag->getAttribute('class');
     202            if ($class == 'modicon') {
     203                continue;
     204            }
    195205            $url = $tag->getAttribute('src');
    196206            $src[] = $url; // Used on replace.
     
    201211            $updated = $LACONN->Course->upload_product_image($post_id, $images, 'course_summary');
    202212            $summary = strtr($course->summary, array_combine($src, $updated));
    203             return sanitize_textarea_field( $summary );
    204         }
    205         return sanitize_textarea_field( $course->summary );
     213            return wp_kses_post_deep( $summary, $LACONN->allowed_tags() );
     214        }
     215        return wp_kses_post_deep( $course->summary, $LACONN->allowed_tags() );
    206216    }
    207217
     
    249259        );
    250260
     261        do_action( 'lmsace_connect_admin_setting_menu' );
     262
    251263        remove_submenu_page('lac-admin-settings', 'lac-admin-settings' );
    252264
     
    257269    }
    258270
     271    /**
     272     * Connection setup admin settings section.
     273     *
     274     * @return void
     275     */
    259276    public function admin_setting_connectionsetup() {
    260277        $this->admin_setting_tabs( 'lac-connection-options', 'sitedetails' );
    261278    }
    262 
     279    /**
     280     * Init the general settings setup section.
     281     *
     282     * @return void
     283     */
    263284    public function admin_setting_generaloptions() {
    264285        $this->admin_setting_tabs( 'lac-general-options', 'generaloptions' );
    265286    }
    266287
     288    /**
     289     * Admin settings defined to import courses.
     290     *
     291     * @return void
     292     */
    267293    public function admin_setting_importcourses() {
    268294        $this->admin_setting_tabs( 'lac-import-courses', 'importcourses' );
     
    319345    }
    320346
     347    /**
     348     * General options admin tab content.
     349     *
     350     * @return void
     351     */
    321352    public function generaloptions_admin_tabcontent() {
    322353        settings_errors();
     
    325356            <form method="post" action="options.php">
    326357                <?php settings_fields( 'lac-general-settings' ); ?>
    327                 <?php do_settings_sections( 'lac-general-settings' ); ?>
     358                <?php
     359                do_settings_sections( 'lac-general-settings' );
     360                do_action( 'lmsace_connect_general_section_settings' );
     361                ?>
    328362                <?php submit_button(); ?>
    329363            </form>
     
    452486            'connection_settings_section'
    453487        );
     488
    454489        //  Moodle token to connect.
    455490        add_settings_field(
     
    502537        );
    503538
     539        do_action( 'lmsace_connect_register_setting_fields' );
     540
    504541        LACONN()->is_setup_completed();
    505542    }
     
    687724    ?>
    688725        <p>
    689             <input type="checkbox" name="lac_import_settings[import_options][]" value="course" checked disabled>
    690             <?php echo esc_html( __('Import selected courses as WooCommerce product.') );  ?>
     726            <input id="import_course" type="checkbox" name="lac_import_settings[import_options][]" value="course" checked disabled>
     727            <label for="import_course"> <?php echo esc_html( __('Import selected courses as WooCommerce product.') );  ?> </label>
    691728        </p>
    692729        <p>
    693             <input type="checkbox" name="lac_import_settings[import_options][]" value="course_draft" >
    694             <?php echo esc_html( __('Import selected courses as product and save as draft.') ); ?>
     730            <input id="import_course_draft" type="checkbox" name="lac_import_settings[import_options][]" value="course_draft" >
     731            <label for="import_course_draft"> <?php echo esc_html( __('Import selected courses as product and save as draft.') ); ?> </label>
    695732        </p>
    696733        <p>
    697             <input type="checkbox" name="lac_import_settings[import_options][]" value="update_existing" >
    698             <?php echo esc_html( __('Update the existing linked product data with current course content.') ); ?>
     734            <input id="import_update_existing" type="checkbox" name="lac_import_settings[import_options][]" value="update_existing" >
     735            <label for="import_update_existing"> <?php echo esc_html( __('Update the existing linked product data with current course content.') ); ?> </label>
    699736        </p>
    700737        <p>
    701             <input type="checkbox" name="lac_import_settings[import_options][]" value="course_category" >
    702             <?php echo esc_html( __('Import selected courses with its category.') ); ?>
     738            <input id="import_course_category" type="checkbox" name="lac_import_settings[import_options][]" value="course_category" >
     739            <label for="import_course_category"> <?php echo esc_html( __('Import selected courses with its category.') ); ?> </label>
     740        </p>
     741        <p>
     742            <input id="import_course_details" type="checkbox" name="lac_import_settings[import_options][]" value="course_details" >
     743            <label for="import_course_details"> <?php echo esc_html( __('Import selected courses with its syllabus summary.') ); ?> </label>
    703744        </p>
    704745    <?php
     746        do_action( 'lmsace_connect_import_settings_list', $options );
     747    }
     748
     749    /**
     750     * Save the custom fields.
     751     */
     752    public function lac_save_moodlecourse_option_fields( $post_id ) {
     753
     754        if ( isset( $_POST[LACONN_MOODLE_COURSE_ID] ) ) :
     755            $courses = wp_kses_post_deep(array_values($_POST[LACONN_MOODLE_COURSE_ID]));
     756            // Convert the type of course id into integer.
     757            // Typecast issue with searialize.
     758            array_walk($courses, function(&$value) {
     759                $value = (int) $value;
     760            });
     761            update_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $courses );
     762        endif;
     763    }
     764
     765    /**
     766     * Course import service.
     767     *
     768     * @param [type] $servicename
     769     * @param [type] $options
     770     * @return void
     771     */
     772    public function course_import_service( $servicename, $options ) {
     773        if (in_array('course_details', $options)) {
     774            return 'get_courses_detail_by_field';
     775        }
     776        return $servicename;
     777    }
     778
     779    /**
     780     * Before course update, added the course content details with course summary.
     781     *
     782     * @param [type] $courses
     783     * @return void
     784     */
     785    public function before_course_update($courses) {
     786        foreach ($courses as $key => $course) {
     787            $courses[$key]->summary = $course->summary . $this->render_course_details($course);
     788        }
     789
     790        return $courses;
     791    }
     792
     793    /**
     794     * Render the course details. Look at the coursedata.php file in templates folder.
     795     *
     796     * @param stdclass $course
     797     * @return void
     798     */
     799    public function render_course_details($course) {
     800        if ( isset($course->details) && !empty($course->details) ) {
     801            $details = (object) json_decode($course->details);
     802            $sections = (object) (property_exists($details, 'sections') ? $details->sections : []);
     803            ob_start();
     804            require_once( dirname( LAC_PLUGIN_FILE ) . '/templates/coursedata.php' );
     805            $data = ob_get_contents();
     806            ob_clean();
     807            return $data;
     808        }
     809        return null;
    705810    }
    706811}
  • lmsace-connect/trunk/includes/admin/class-lac-product-settings.php

    r2755044 r2943131  
    1919
    2020    $result = $LACONN->Client->request(LACONN::services('get_courses_by_field'), array('fields' => array(), 'values' => array()));
    21     $options = [ 0 => esc_html( __('No Course', LAC_TEXTDOMAIN) ) ];
     21    $options = [];
    2222    if (!empty($result) && isset($result->courses)) {
    2323        $courses = $result->courses;
     
    3434    ?><div id='course_options' class='panel woocommerce_options_panel'><?php
    3535        ?><div class='options_group'><?php
    36             woocommerce_wp_select( array(
     36
     37            $attr = array(
    3738                'id'                => LACONN_MOODLE_COURSE_ID,
    38                 'label'             => esc_html( __( 'Select Course', 'lmsace-connect' )),
     39                'label'             => esc_html( __( 'Select Courses', 'lmsace-connect' )),
    3940                'desc_tip'          => 'true',
    4041                'description'       => esc_html( __( 'Select the course to make this product as course product.', 'lmsace-connect' )),
    41                 'custom_attributes' => array(),
    42                 'name'      => LACONN_MOODLE_COURSE_ID,
    43                 'options' => $options
    44             ) );
     42                'custom_attributes' => array('multiple' => true),
     43                'name'      => LACONN_MOODLE_COURSE_ID."[]",
     44                'options' => $options,
     45            );
     46            // Change the select bar filter options.
     47            $attr = apply_filters( 'lmsace_connect_product_select_attributes', $attr );
     48
     49            woocommerce_wp_select( $attr );
     50
    4551        ?></div>
    4652    </div><?php
    4753}
    4854
    49 /**
    50  * Save the custom fields.
    51  */
    52 function lac_save_moodlecourse_option_fields( $post_id ) {
    53     if ( isset( $_POST[LACONN_MOODLE_COURSE_ID] ) ) :
    54         update_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, absint( sanitize_text_field( $_POST[LACONN_MOODLE_COURSE_ID] ) ) );
    55     endif;
    56 }
     55
     56
  • lmsace-connect/trunk/includes/class-lac-client.php

    r2755933 r2943131  
    100100                $response['response_message'] = esc_html( __(' URL Not Found, Please check your url', 'lmsace-connect'));
    101101            } else if ($response['response_code'] == 403) {
    102                 $response['response_message'] = wp_kses(__(' Forbidden. <ul> <li> Please check your webservice settings on Your LMS </li> </ul>', 'lmsace-connect'), $LACONN->allowed_tags());
    103             }
    104 
    105              // Returns the request error.
    106             return array('error' => true, 'message' => $response['response_message'] );
    107         }
    108         return array('error' => false, 'message' => '' );
     102                $response['response_message'] = wp_kses( __(' Forbidden. <ul> <li> Please check your webservice settings on Your LMS </li> </ul>', 'lmsace-connect'), $LACONN->allowed_tags() );
     103            }
     104            // Returns the request error.
     105            return array( 'error' => true, 'message' => $response['response_message'] );
     106        }
     107        return array( 'error' => false, 'message' => '' );
    109108    }
    110109
     
    230229    }
    231230
     231
     232
    232233}
  • lmsace-connect/trunk/includes/class-lac-course.php

    r2755044 r2943131  
    4141        add_filter( 'cron_schedules', array( $this, 'lac_cron_definer' ) );
    4242        add_action( 'lac_import_courses_action', array($this, 'lac_import_courses') );
    43     }
     43        add_shortcode( 'lmsace_connect_summary', array($this, 'summary_shortcode'));
     44    }
     45
     46    public function summary_shortcode( $atts, $content ) {
     47        return $content;
     48    }
     49
    4450    /**
    4551     * Returns an instance of the plugin object
     
    334340     * @return array result of connection
    335341     */
    336     public function create_courses($courseslist = array(), $assign_category=false, $make_draft=false, $update_existing=false) {
     342    public function create_courses($courseslist = array(), $assign_category=false, $make_draft=false, $update_existing=false, $options=[]) {
    337343        global $LACONN;
    338344        $this->get_user();
    339345        if ( !empty($courseslist) ) {
     346
     347            $courseslist = apply_filters( 'lmsace_connect_before_course_update', $courseslist);
    340348
    341349            $successUpdate = $errorUpdate = $successCourses = $errorCourses = $errorExist = array();
     
    345353                        if ($update_existing) {
    346354                            foreach ($posts as $post) {
    347                                 if ($this->update_course($post, $course, $assign_category, $make_draft) ) {
     355                                // Update existing courses.
     356                                if ($this->update_course($post, $course, $assign_category, $make_draft, $options) ) {
    348357                                    $successUpdate[$course->id] = $course->fullname;
    349358                                    LACONN()->logger()->add('course', 'Course product updated - '.$course->fullname.'');
     
    358367                    } else {
    359368                        LACONN()->logger()->add('course', 'Assign-category - '.$assign_category);
    360 
    361                         if ( $this->create_course($course, $assign_category, $make_draft) ) {
     369                        // Create courses.
     370                        if ( $this->create_course($course, $assign_category, $make_draft, $options) ) {
    362371                            $successCourses[$course->id] = $course->fullname;
    363372                            LACONN()->logger()->add('course', 'Course created as product - '.$course->fullname.'');
     
    397406     * @return bool
    398407     */
    399     public function create_course($course, $assign_category=false, $make_draft=false) {
     408    public function create_course($course, $assign_category=false, $make_draft=false, $options=[]) {
    400409        global $LACONN;
    401410
     
    412421            $summary = $this->admin->replace_coursesummary_images($post_id, $course);
    413422            $postcontent = [ 'ID' => $post_id, 'post_content' => $summary ];
     423
    414424            wp_update_post( $postcontent, true );
    415425
     
    470480     * @return void
    471481     */
    472     public function update_course($post_id, $course, $assign_category=false, $make_draft=false) {
     482    public function update_course($post_id, $course, $assign_category=false, $make_draft=false, $options=[]) {
    473483        global $LACONN;
    474484        $post = array(
     
    482492
    483493        $summary = $this->admin->replace_coursesummary_images($post_id, $course);
     494        $summary = '[lmsace_connect_summary]'.$summary.'[/lmsace_connect_summary]';
     495
     496
     497        $currentpost = get_post($post_id);
     498        if ($currentpost != '') {
     499            $postcontent = $currentpost->post_content;
     500            if (has_shortcode($postcontent, 'lmsace_connect_summary')) {
     501                $pattern = get_shortcode_regex();
     502                $summary = preg_replace('/'. $pattern .'/s', $summary, $postcontent);
     503            }
     504        }
    484505        $post['post_content'] = $summary;
    485506
    486         // update course details in product post.
     507        // update course details in product post.
    487508        $postid = wp_update_post($post, true);
    488509
     
    546567        update_post_meta( $post_id, '_sku', $course->shortname );
    547568        update_post_meta( $post_id, '_visibility', ($course->visible) ? 'visible' : 'hide' );
    548 
     569        // LAConnect support multiple courses link with single product.
     570        $courses = array( $course->id );
    549571        if ( ! metadata_exists('post', $post_id, LACONN_MOODLE_COURSE_ID) ) {
    550             add_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $course->id);
     572            add_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $courses);
    551573        } else {
    552             update_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $course->id);
     574            update_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $courses);
    553575        }
    554576
  • lmsace-connect/trunk/includes/class-lac-user.php

    r2755044 r2943131  
    193193        if (!empty($moo_users)) {
    194194            // Send the request to connected moodle to create users.
    195             $moodle_users = $LACONN->Client->request( LACONN::services('create_users'), array( 'users' => $moo_users ) );
     195            $userdata = array( 'users' => $moo_users );
     196            // Filter the data to make the SSO changes.
     197            $userdata = apply_filters( 'lmsace_connect_create_userdata', $userdata );
     198
     199            $moodle_users = $LACONN->Client->request( LACONN::services('create_users'), $userdata );
     200
     201            $moodle_users = apply_filters( 'lmsace_connect_user_create_results', $moodle_users );
    196202
    197203            if ( !empty($moodle_users) ) {
    198204
    199205                foreach ( $moodle_users as $moodle_user ) {
    200 
    201206                    // Add moodle userid with the associated wp user.
    202207                    $this->add_user_moodle_id( $user_data->ID, $moodle_user->id );
    203208                    $LACONN->logger()->add( 'order', 'User "'.$moodle_user->username.'" (WPuserid - '. $user_data->ID.') created in moodle and synced with WP');
    204 
    205209                    $this->set_admin_notices( 'success', esc_html( __('User created successfully on LMS', 'lmsace-connect') ));
    206 
    207210                    $md_user_id = $moodle_user->id;
    208 
    209211                }
    210212                // Returns the reterived moodle user ids.
     
    237239        );
    238240
     241
     242
    239243        return $user_fields;
    240244    }
     
    301305        global $LACONN;
    302306        if (!empty($user_id)) {
    303             $user = ($email) ? get_user_by( 'email', $user_id ) : get_userdata( $user_id );
     307            $user = ($email || is_email($user_id)) ? get_user_by( 'email', $user_id ) : get_userdata( $user_id );
    304308            if ( !empty($user) ) {
    305309                $args = array( 'field' => 'email', 'values' => array( sanitize_user($user->user_email) ) );
     
    339343        );
    340344
    341         $orders = array_merge($customer_orders, $guest_orders);     
    342 
    343         return (!empty($orders)) ? $orders : [];
     345        $orders = array_merge($customer_orders, $guest_orders);
     346
     347        // Filter the unique orders.
     348        $filterorder = [];
     349        foreach ( $orders as $key => $order ) {
     350            if (!in_array($order->id, $filterorder)) {
     351                $filterorder[] = $order->id;
     352                $finalorders[] = $order;
     353            }
     354        }
     355        return (isset($finalorders)) ? $finalorders : [];
    344356    }
    345357
     
    352364
    353365        if ( $md_user_id = $this->is_moodle_user( $user->ID )) {
    354             $this->wooCom = $this->get_handler('woocom');
    355366            $enrolments = $list = [];
    356367            if ( $orders = $this->get_user_orders( $user->ID, true ) ) {
    357368                foreach ( $orders as $key => $order ) {
    358                     $itemids = [];
    359369                    $orderdata = $order->get_data();
    360                     $items = $order->get_items();
    361                     // List of items added in the order.
    362                     foreach ( $items as $item ) {
    363                         $productid = $item->get_product_id();
    364                         if (in_array($productid, $list)) {
    365                             continue;
    366                         }
    367                         array_push($list, $productid);
    368                         // Moodle course id synced with the selected product.
    369                         $moodle_courseid = $this->wooCom->get_product_moodle_id( $productid );
    370                         if ( $orderdata['status'] == 'completed' ) {
    371                             $enrolments[] = (object) ['productid' => $productid, 'courseid' => $moodle_courseid];
    372                         }
     370                    // Moodle course id synced with the selected product.
     371                    if ( $orderdata['status'] == 'completed' ) {
     372                        $courses = get_post_meta($order->id, 'lac_enrolments', true);
     373                        $enrolments = array_merge($enrolments, $courses);
    373374                    }
    374375                }
     
    378379        return [];
    379380    }
     381
     382
    380383}
  • lmsace-connect/trunk/includes/class-lac-woocom.php

    r2755044 r2943131  
    4242
    4343        // Observer the order status changed to completed. then create user on LMS.
    44         add_action('woocommerce_order_status_completed', array($this, 'process_order_completed'), 10, 1 );
     44        add_action( 'woocommerce_order_status_completed', array($this, 'process_order_completed'), 10, 1 );
    4545        // Unenrol the user form LMS after the order refunded.
    46         add_action('woocommerce_order_status_changed', array($this, 'process_order_refund' ), 10, 2);
     46        add_action( 'woocommerce_order_status_changed', array($this, 'process_order_refund' ), 10, 1);
    4747        // add_action('woocommerce_order_refunded', array($this, 'process_order_refund' ), 10, 2);
    4848
    4949        // Warning message to disable the guest checkout on woocommerce.
    50         add_action('admin_notices', array( $this, 'warn_disable_guest_checkout' ) );
     50        add_action( 'admin_notices', array( $this, 'warn_disable_guest_checkout' ) );
    5151        // Add user enrolment status metabox on admin backend order page.
    52         add_action('add_meta_boxes', array( $this, 'add_user_enrollment_metabox' ) );
     52        add_action( 'add_meta_boxes', array( $this, 'add_user_enrollment_metabox' ) );
    5353        // Ajax observer for create enrolment manually.
    54         add_action('wp_ajax_lac_user_enrollment', array( $this, 'create_order_enrollment') );
     54        add_action( 'wp_ajax_lac_user_enrollment', array( $this, 'create_order_enrollment') );
    5555        // Rearrange the menu order on user dashboard.
    56         add_filter( 'woocommerce_account_menu_items', array( $this, 'my_account_menu_order') );
    57 
    5856        add_filter( 'woocommerce_account_menu_items', array( $this, 'my_account_menu_order') );
    5957
     
    7270        add_filter( 'woocommerce_add_to_cart_validation', array( $this, 'lac_prevent_twice_course_product' ), 10, 2 );
    7371
     72        add_action( 'wp_enqueue_scripts',  array( $this, 'enqueue_accordion_scripts' ) );
     73
     74        add_action( 'wp_footer', array( $this, 'initialize_accordion_script' ) );
     75
     76    }
     77
     78    // Enqueue the necessary scripts and styles.
     79    public function enqueue_accordion_scripts() {
     80        wp_enqueue_script('jquery-ui-accordion');
     81        wp_enqueue_style('jquery-ui-style', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css');
     82        wp_enqueue_style('lmsace-connect-style', $this->wwwroot . 'styles.css');
     83    }
     84
     85    /**
     86     * Initialize the script for accordion.
     87     *
     88     * @return void
     89     */
     90    function initialize_accordion_script() {
     91        echo '<script type="text/javascript">
     92            jQuery(document).ready(function($) {
     93                $("#lmsace-connect-summary-accord").accordion({
     94                    collapsible: true
     95                });
     96            });
     97        </script>';
    7498    }
    7599
     
    85109
    86110        $md_course_id = $this->get_product_moodle_id( $product_id );
     111        // Product not a course linked no need to prevent.
    87112        if ( !$md_course_id ) {
    88113            return $validation;
     
    93118            $products[] = $product->get_id();
    94119        }
    95 
     120        // Course Product already added to the cart.
    96121        if ( in_array($product_id, array_values($products)) ) {
    97122            return false;
     
    122147     */
    123148    public function create_order_enrollment() {
     149
    124150        if (isset($_POST['order_id']) && !empty($_POST['order_id'])) {
    125151            $result = $this->process_order_completed( sanitize_text_field( $_POST['order_id'] ) );
     
    136162            ?>
    137163            <div class="notice notice-error is-dismissible lmsace-notice">
    138                 <h4> <?php echo esc_html('LMSACE Connect'); ?> </h4>
     164                <h4> <?php echo esc_html('LMSACE Connect', 'lmsace-connect'); ?> </h4>
    139165                <p><?php esc_html_e( 'Disable the guest checkout on woocommerce..', 'lmsace-connect' ); ?></p>
    140166            </div>
     
    180206                $user_id = $details['order']->get_user_id();
    181207
     208                // Guest checkout support. if user_id is empty then use the useremail as userid.
     209                if ( !$user_id ) {
     210                    $user_id = $details['user']->email;
     211                }
     212
     213                // Check the order user is moodle user or already created in moodle.
    182214                $md_user_id = $LACONN->User->is_moodle_user( $user_id, true, $details['user'] );
    183215
     
    188220                        $product_id = $product->get_product_id();
    189221                        // Get course id related to the moodle for the current item in order.
    190                         $md_courses = (int) $this->get_product_moodle_id($product_id);
    191 
    192                         if ( is_integer($md_courses) ) {
    193                             $md_courses = array( $md_courses );
    194                         }
    195 
     222                        $md_courses = $this->get_product_moodle_id($product_id);
     223
     224                        $md_courses = (!is_array($md_courses)) ? array($md_courses) : $md_courses;
     225
     226                        $metaenrols = $enrolments = [];
    196227                        foreach ( $md_courses as $md_course_id ) {
    197228                            // Enrol the user in the course in lms environment.
     
    202233                                    'courseid' => $md_course_id
    203234                                );
     235
    204236                                $metaenrols[] = array_merge($enrols, ['productid' => $product_id]);
    205237                                $enrolments[] = $enrols;
    206238
    207239                                $LACONN->logger()->add( 'order',
    208                                 ' Preparing enrolment - "'.$product_id.'" ('.json_encode($enrolments).') ');
     240                                    ' Preparing enrolment - "'.$product_id.'" ('.json_encode( $enrolments ).') ' );
    209241                            }
    210242                        }
     
    216248                            $details['order']->update_meta_data( 'lac_enrolments', $metaenrols );
    217249                            $LACONN->logger()->add( 'order', ' Updated enrolments in order meta - '.json_encode($enrolments));
    218                             foreach ($enrolments as $enrolment) {
    219                                 if (isset( $enrolment['courseid'] ) )
     250                            foreach ( $enrolments as $enrolment ) {
     251                                if ( isset( $enrolment['courseid'] ) ) {
    220252                                    $LACONN->set_admin_notices( 'success', sprintf ( esc_html( __('User %1s enrolled on the courses', 'lmsace-connect') ), $details['user']->user_login ) );
     253                                }
    221254                            }
    222255                        }
     
    231264            $t = $details['order']->save();
    232265        }
    233 
     266        // exit;
    234267    }
    235268
     
    238271     *
    239272     * @param  mixed $order_id
    240      * @return void
    241      */
    242     public function process_order_refund( $order_id ) {
     273     * @param string $force Force the unenrolment.
     274     * @return void
     275     */
     276    public function process_order_refund( $order_id, $force = false ) {
    243277        global $LACONN;
     278
    244279        if (!empty($order_id)) {
    245280            // Get the refuned order details to unenroll the user from moodle.
     
    252287            $order_enrolments = $details['order']->get_meta( 'lac_enrolments' );
    253288
     289            $order_enrolments = apply_filters( 'lmsace_connect_order_enrolments', $order_enrolments, $details['order'] );
     290
    254291            // User id connected with moodle.
    255292            $user_id = $details['order']->get_user_id();
     293
    256294            $data = $details['order']->get_data();
    257295
    258296            $refund = isset($this->options['refund_suspend']) ? $this->options['refund_suspend'] : LACONN_SUSPEND;
    259297
    260             if ( $data['status'] != 'completed' && $refund && !empty($order_enrolments) ) {
     298            if ( ($force || $data['status'] != 'completed') && $refund && !empty($order_enrolments) ) {
    261299
    262300                $LACONN->logger()->add( 'order', ' Order refund init - orderID: '.$order_id);
     
    319357
    320358        // Order User object.
    321         // Order User object.
    322         $user = $order->get_user() ? $order->get_user()->data : [];
     359        $user = $order->get_user() ? $order->get_user()->data : new stdclass();
    323360
    324361        if (!isset($user->email) && isset($user->user_email) && !empty($user->user_email)) {
    325362            $user->email = $user->user_email;
    326363        }
    327 
    328         return array('order' => $order, 'products' => $products, 'user' => $user  );
     364        // Adding guest user support.
     365        if (!isset($user->email) || $user->email == '') {
     366            // Set the billing email as user email if it's empty.
     367            $user->email = $order->get_billing_email();
     368            $user->ID = 'guest';
     369            $user->firstname = $order->get_billing_first_name();
     370            $user->lastname = $order->get_billing_last_name();
     371            $user->user_login = $order->get_billing_email();
     372        }
     373
     374        return array( 'order' => $order, 'products' => $products, 'user' => $user );
    329375    }
    330376
     
    371417                array(
    372418                    'key' => LACONN_MOODLE_COURSE_ID,
    373                     'value' => $courseid
     419                    'value' => serialize([$courseid])
    374420                )
    375421            )
     
    392438    }
    393439
     440    /**
     441     * Fetch the list of courses linked with the product.
     442     *
     443     * @param int $product_id
     444     * @return void
     445     */
    394446    public function get_product_moodle_id( $product_id ) {
    395447        return get_post_meta($product_id, LACONN_MOODLE_COURSE_ID, true);
  • lmsace-connect/trunk/includes/class-lac.php

    r2755933 r2943131  
    3838    public $site_url;
    3939
     40    public $handlers;
     41
     42    public $options;
     43
     44    public const KEY = 'LACONN_';
     45
    4046    /**
    4147     * Returns an instance of the plugin object
     
    5763     */
    5864    public function __construct() {
    59 
    6065        $this->define();
    61 
     66        $this->setup_config();
     67        $this->includes();
     68    }
     69
     70    public function setup_config() {
    6271        $this->dirroot = dirname( LAC_PLUGIN_FILE );
    6372        $this->wwwroot = plugin_dir_url(__DIR__);
     
    7483            $this->site_url .= '/';
    7584        }
    76 
    77         $this->includes();
    7885    }
    7986
     
    8390     * @return void
    8491     */
    85     private function define() {
     92    protected function define() {
     93
    8694        $upload_dir = wp_upload_dir( null, false );
    8795        $params = [
    8896            'LAC_TEXTDOMAIN'           => 'lmsace-connect',
    8997            'NONCEKEY'             => 'lmsace-connect-nonce',
    90             'LACONN_MOODLE_COURSE_ID' => 'lac_moodle_course_id',
     98            'LACONN_MOODLE_COURSE_ID' => 'lac_moodle_courses',
    9199            'LMSCONF_DEBUG'        => true,
    92100            'ENROLLED'             => 1,
     
    98106            'LACONN_IMPORT_LIMIT'      => 25
    99107        ];
     108        $this->define_params( $params );
     109    }
     110
     111    /**
     112     * Define the params.
     113     *
     114     * @param array $params
     115     * @return void
     116     */
     117    public function define_params( $params=array() ): void {
    100118        foreach ($params as $key => $value) {
    101119            if ( !defined($key) ) {
     
    118136            add_action( 'woocommerce_loaded', array($this, 'woocommerce_version_check'));
    119137            add_action( 'admin_notices', array($this, 'display_admin_notices') );
     138        }
     139
     140
     141        $this->load_submodules();
     142    }
     143
     144    /**
     145     * load all of its submodules.
     146     * Read directory "modules" and check the function "laconn_mod_PLUGINNAME" function exists. Init the functions.
     147     *
     148     * @return void
     149     */
     150    public function load_submodules() {
     151
     152        $dir = scandir( $this->dirroot.'/modules' );
     153        $modules = array_diff( $dir, array('.', '..') );
     154        foreach ( $modules as $mod ) {
     155            $file = $this->dirroot.'/modules/'.$mod.'/module.php';
     156            if (file_exists($file)) {
     157                require_once($file);
     158            }
    120159        }
    121160    }
     
    141180        }
    142181
    143         foreach ( array_keys($this->handlers) as $key => $handler ) {
    144             $handler_class = (new $handler());
    145             $handler = str_replace('LACONN_', '', $handler);
     182        $this->register_handlers('LACONN_');
     183    }
     184
     185    /**
     186     * Build the handlers class instance and setup class variables. Replaced the key from class name.
     187     * Final handlers instance are looks $this->Admin, $this->Client.
     188     *
     189     * @return void
     190     */
     191    public function register_handlers() {
     192
     193        foreach ( array_keys($this->handlers) as $k => $handler ) {
     194            $handler_class = ( new $handler() );
     195            $handler = str_replace( self::KEY, '', $handler );
    146196            $this->{$handler} = $handler_class;
    147197        }
    148     }
     198    }
    149199
    150200    /**
     
    200250    public function logger() {
    201251        return LACONN_Log::instance();
     252    }
     253
     254    /**
     255     * Check is LAC Pro plugin installed.
     256     */
     257    public static function has_pro() {
     258        if ( is_plugin_active( 'lmsace-connect-pro/lmsace-connect-pro.php' ) ) {
     259            $path = WP_PLUGIN_DIR.'/lmsace-connect-pro/includes/class-lacpro.php';
     260            require_once( $path );
     261            return false; // true;
     262        }
    202263    }
    203264
     
    214275        $path .= 'class-lac-'.$class.'.php';
    215276        require_once($path);
    216         $class = 'LACONN_'.ucwords(str_replace( '-', '_', $class));
     277        $class = self::KEY.ucwords(str_replace( '-', '_', $class));
    217278        return (new ReflectionClass ( $class ))->newInstanceArgs ( $params );
    218279    }
     
    239300     */
    240301    public function register_actions() {
     302
    241303        add_action('init', array($this, 'register_lac_session'));
    242304        foreach ( array_keys($this->handlers) as $key => $handler ) {
    243305            $handler_class = (new $handler());
    244             $handler = str_replace('LACONN_', '', $handler);
     306            $handler = str_replace( self::KEY, '', $handler);
    245307            $this->{$handler} = $handler_class;
    246             if (method_exists($handler_class, 'lac_register_actions')) {
     308            if ( method_exists( $handler_class, 'lac_register_actions' ) ) {
    247309                $handler_class->lac_register_actions();
    248310            }
    249311
    250312            // Register admin side based actions.
    251             if ( is_admin() && method_exists($this->{$handler}, 'lac_register_admin_actions' ) ) {
     313            if ( is_admin() && method_exists( $this->{$handler}, 'lac_register_admin_actions' ) ) {
    252314                $this->{$handler}->lac_register_admin_actions();
    253315            }
     
    317379    public function is_setup_completed() {
    318380        global $LACONN;
    319        
     381
    320382        $options = $this->get_options();
    321383        if (!isset($options['site_url']) || empty($options['site_url'])) {
    322             $this->set_admin_notices('warning', '<h4> LMSACE Connect </h4>'.sprintf( wp_kses( __(' <p> <b>You need to specify a Moodle LMS domain and a Moodle LMS Access token.</b> You must <a href="%s">enter your domain and API key</a> for it to work.</p> ', 'lmsace-connect'), $LACONN->allowed_tags()), 'admin.php?page=lac-admin-settings'), 'connection', true);
     384            $this->set_admin_notices('warning', '<h4> LMSACE Connect </h4>'.sprintf( wp_kses(__(' <p> <b>You need to specify a Moodle LMS domain and a Moodle LMS Access token.</b> You must <a href="%s">enter your domain and API key</a> for it to work.</p> ', 'lmsace-connect'), $LACONN->allowed_tags()), 'admin.php?page=lac-admin-settings'), 'connection', true);
    323385        } else {
    324386            $request = $this->Client->request(self::services('get_user_roles'), array(), false);
     
    410472    }
    411473
     474    /**
     475     * Removed the admin notifce flash messages.
     476     *
     477     * @param string $name
     478     * @return void
     479     */
    412480    public function remove_admin_notices($name) {
    413481        if (isset($_SESSION['lac_admin_flash'][$name]))
     
    418486     * Allowed html tags to kses.
    419487     *
    420      * @return array
     488     * @return void
    421489     */
    422490    public function allowed_tags() {
     
    466534            'get_user_roles' => 'local_lmsace_connect_user_roles',
    467535            'get_limit_courses' => 'local_lmsace_connect_limit_courses',
    468             'get_courses_count' => 'local_lmsace_connect_get_courses_count'
     536            'get_courses_count' => 'local_lmsace_connect_get_courses_count',
     537            'get_courses_detail_by_field' => 'lacpro_coursedata_get_courses_detail_by_field'
    469538        ];
    470539
     540        $services = apply_filters( 'lmsace_connect_get_services', $services );
     541
    471542        return isset($services[$key]) ? $services[$key] : $services;
    472543    }
     544
     545
    473546}
  • lmsace-connect/trunk/lmsace-connect.php

    r2755044 r2943131  
    44 * Plugin URI: http://lmsace.com/product/lmsace-connect
    55 * Description: This plugin connects the Moodle™ LMS + WooCommerce. Helps course creators to sell their Moodle™ LMS courses via WooCommerce.
    6  * Version: 1.0
     6 * Version: 2.0
    77 * Author: LMSACE
    88 * Author URI: https://www.lmsace.com/
    99 * Requires at least: 4.6+
    10  * Tested up to: 6.0
     10 * Tested up to: 6.2.2
    1111 * Requires PHP: 5.6
    1212 *
    1313 * WC requires at least: 3.0
    14  * WC tested up to: 6.3.1
     14 * WC tested up to: 7.8.0
    1515 *
    1616 * License: GNU General Public License v3.0
     
    3939    add_action('plugins_loaded', 'lac_load_textdomain');
    4040
     41    /**
     42     * Plugins admin settings.
     43     *
     44     * @param array $links
     45     * @return void
     46     */
    4147    function lmsace_connect_settings_link($links) {
    4248        $connection = admin_url().'admin.php?page=lac-connection-options';
    43         $settings_link = '<a href="'.$connection.'">'.esc_html(__('Settings', 'lmsace-connect')).'</a>';
     49        $settings_link = '<a href="'.$connection.'">'.esc_html( __('Settings', 'lmsace-connect') ).'</a>';
    4450        array_unshift($links, $settings_link);
    4551        return $links;
    4652    }
    4753    $plugin = plugin_basename( __FILE__ );
    48     add_filter("plugin_action_links_$plugin", 'lmsace_connect_settings_link' );
     54    add_filter( "plugin_action_links_$plugin", 'lmsace_connect_settings_link' );
    4955
    5056    /**
     
    115121        return LACONN::instance();
    116122    }
     123
     124
     125
     126    function print_object($data) {
     127        echo '<pre>';
     128        print_r($data);
     129        echo '</pre>';
     130    }
     131
    117132    // Initialize the plugin intial function to register actions.
    118133    global $LACONN;
    119134    $LACONN = LACONN();
    120135    $LACONN->init();
     136
     137    // TODO: Update the course product meta to array.
    121138}
     139
     140
  • lmsace-connect/trunk/readme.txt

    r2757257 r2943131  
    11=== LMSACE Connect - WooCommerce Moodle™ LMS Integration ===
    22Contributors: lmsace
    3 Tags: LACONN, woocommerce-moodle-integration, moodle-woocommerce-integration, moodle, woocommerce, LMS, moodle+woocommerce, course, course-product, course-purchase, sell-course, buy-course, sell-moodle-course
     3Tags: LACONN, woocommerce-moodle-integration, moodle-woocommerce-integration, moodle, woocommerce, LMS, moodle+woocommerce, course, course-product, course-purchase, sell-course, buy-course, sell-moodle-course, lmsace-connect, moodle-sso, moodle-wordpress-sso, moodle-woocommerce-sso
    44Requires at least: 4.6
    5 Tested up to: 6.0
     5Tested up to: 6.2.2
    66Requires PHP: 5.6
    7 Stable tag: 1.0.1
     7Stable tag: 2.0
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    1313== Description ==
    1414
    15 This plugin is an extension of WooCommerce which allows you to sell your Moodle™ LMS courses with WooCommerce shopping cart. Simply assign Moodle™ course(s) to a WooCommerce product. When a student purchases the product in Woocommerce, they will be automatically enrolled into the associated course(s) in Moodle™ LMS.
     15This plugin is an extension of WooCommerce, which allows you to sell your Moodle™ LMS courses with the WooCommerce shopping cart. Simply assign Moodle™ course(s) to a WooCommerce product. When a student purchases the product in WooCommerce, they will be automatically enrolled in the associated course(s) in Moodle™ LMS. With the new version, we've added exciting features to further enhance your e-learning experience. Enjoy the seamless login with SSO, sync multiple courses with a single product, and import course outline data effortlessly.
    1616
    1717**Plugin Features**
     
    2323- After a successful product purchase in Woocommerce, the integration will auto-enroll the customer into the Moodle™ course(s) so that they can begin taking the course.
    2424- Removes users from Moodle™ courses when refunded or cancelling a Woocommerce order.
     25- Seamless login with SSO
     26- Import courses with its syllabus summary.
    2527
    2628**Benefits of integrating Moodle™ LMS with Woocommerce Store**
     
    3739- Automatically enroll students after payment
    3840- You Can Add up-sells, order bumps, and other revenue boosters
    39 - [PRO] Sell multiple courses bundled
     41- Sell multiple courses bundled
    4042- [PRO] Monetize online courses via offering membership subscriptions
    4143
     
    6466- Go to the "Add new" section under the "Plugins" menu.
    6567- Search the plugin by entering the "lmsace-connect" in the search box.
    66 - You will find the plugin **LMSACE Connect - WooCommerce Moodle™ LMS Integration** in the plugins search listing.
     68- You will find the plugin **LMSACE WooCommerce Moodle** in the plugins search listing.
    6769- Click the "**Install Now**" button.
    6870- Once plugin files are added to WordPress, you can find the "**Activate**" button.
    69 - By clicking the "**Activate**" button, you can able to access the features of LMSACE Connect.
     71- By clicking the "**Activate**" button, you can able to access the features of LACONN.
    7072
    7173= Manual installation =
    7274
    73 1. Download the plugin file [lmsace-connect-woocommerce.zip](http://www.lmsace.com/plugins/downloads/lmsace-connect-woocommerce.zip)
     751. Download the plugin file [lmsace-connect-woocommerce.zip](https://downloads.wordpress.org/plugin/lmsace-connect.2.0.zip)
    74762. In your WordPress admin area, navigate to PLUGINS > ADD NEW
    75773. Click Upload Plugin
     
    8082**In the same way, you have to install the [LMSACE Connect’s](https://github.com/lmsace/lmsace-connect-moodle) corresponding Moodle™ plugin too ( Manual Installation )**
    8183
    82 Once you have successfully installed both Moodle and WordPress side plugins. Please follow the steps described in the [README.MD](https://github.com/lmsace/lmsace-connect-woocommerce) to **Setup the connection** between WooCommerce and Moodle™ LMS.
     84**Please follow the steps described in the [Documentation Wiki](https://github.com/lmsace/lmsace-connect-woocommerce/wiki) to **Setup the connection and SSO** between WooCommerce and Moodle™ Software.**
    8385
    8486== Screenshots ==
     
    119121Initial LMSACE Connect Release Version
    120122
    121 = 1.0.1 =
    122 Fixed html escape in warning messages
    123 
    124123== Upgrade Notice ==
    125124
    126125= 1.0 =
    127126Initial release. No upgrade notices
     127
     128= 2.0 =
     129SSO feature implemented.
     130Bundle multiple courses in a single product.
     131Import course with outline data.
  • lmsace-connect/trunk/templates/mycourses.php

    r2755044 r2943131  
    1818
    1919    <?php
     20    $loginurl = apply_filters( 'lmsace_connect_courseurl', $thiscourseurl );
     21
     22    $courseids = array_column($courses, 'courseid');
     23    $md_courses = $LACONN->Course->get_courses_byid( $courseids );
    2024    foreach ( $courses as $key => $course ) {
    2125
     26        $course = (object) $course;
    2227        $courseid = $course->courseid;
    2328        // Get product id from the enrolled LMS course id.
     
    2732
    2833        $product = wc_get_product( $product_id );
    29         $thiscourseurl = $LACONN->site_url.'course/view.php?id='.$courseid;
     34        $thiscourseurl = $loginurl . $LACONN->site_url.'course/view.php?id='.$courseid;
     35        $coursename = isset($md_courses[$courseid]) ? $md_courses[$courseid]->fullname : '';
     36
    3037        ?>
    3138            <div class="product-item col-md-3">
     
    3441                </div>
    3542                <div class="product-details">
    36                     <h4 class="product-name"> <a href="<?php echo esc_attr( $thiscourseurl ); ?>"> <?php echo esc_html( $product->get_name() ); ?> </a> </h4>
    37                     <a class="button button-primary" href="<?php echo esc_attr( $thiscourseurl ); ?>" > <?php echo esc_html( __("View Course", 'lmsconnect') ); ?> </a>
     43                    <label><?php echo esc_html( $coursename ); ?> </label>
     44                    <h4 class="product-name"> <a href="<?php echo esc_attr( $thiscourseurl ); ?>"><?php echo esc_html( $product->get_name() );?> </a> </h4>
     45                    <a class="button button-primary moodle-course-access" href="<?php echo esc_attr( $thiscourseurl ); ?>" > <?php echo esc_html( __("View Course", 'lmsconnect') ); ?> </a>
    3846                </div>
    3947            </div>
Note: See TracChangeset for help on using the changeset viewer.