Changeset 2943131
- Timestamp:
- 07/25/2023 02:00:26 PM (3 years ago)
- Location:
- lmsace-connect/trunk
- Files:
-
- 11 added
- 2 deleted
- 14 edited
-
README.md (modified) (5 diffs)
-
assets/css/styles.css (modified) (3 diffs)
-
assets/js/admin.js (modified) (3 diffs)
-
includes/admin/class-lac-admin-request.php (modified) (4 diffs)
-
includes/admin/class-lac-admin.php (modified) (12 diffs)
-
includes/admin/class-lac-product-settings.php (modified) (2 diffs)
-
includes/class-lac-client.php (modified) (2 diffs)
-
includes/class-lac-course.php (modified) (9 diffs)
-
includes/class-lac-user.php (modified) (6 diffs)
-
includes/class-lac-woocom.php (modified) (16 diffs)
-
includes/class-lac.php (modified) (14 diffs)
-
languages/en.mo (deleted)
-
languages/en.po (deleted)
-
languages/en.pot (added)
-
lmsace-connect.php (modified) (3 diffs)
-
modules (added)
-
modules/sso (added)
-
modules/sso/includes (added)
-
modules/sso/includes/admin (added)
-
modules/sso/includes/admin/class-lacsso-admin.php (added)
-
modules/sso/includes/class-lacsso-user.php (added)
-
modules/sso/includes/class-lacsso.php (added)
-
modules/sso/module.php (added)
-
readme.txt (modified) (7 diffs)
-
styles.css (added)
-
templates/coursedata.php (added)
-
templates/mycourses.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lmsace-connect/trunk/README.md
r2755933 r2943131 3 3 ================== 4 4 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. 6 6 7 It gives the course creatores as options to import courses from the Moodle LMSand create courses as woocommerce products and sell their courses to customer.7 It 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. 8 8 9 Once the course products are purchased by customer, Plugin will create those users on Moodle LMS and enrol them into the linked course. 9 Once the course products are purchased by customer, Plugin will create those users on Moodle™ Software and enrol them into the linked course. 10 11 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. 10 12 11 13 12 ### Version14 ### Moodle™ Software Side Plugin. 13 15 14 Pl ugin version: 1.016 Please 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. 15 17 16 Released on: 28 March 202217 18 Authors: https://lmsace.com, LMSACE Dev Team19 20 ### Plugin Repository21 22 Publlic Git Repository23 [https://github.com/lmsace/lmsace-connect](https://github.com/lmsace/lmsace-connect)24 25 #### Moodle Side Plugin.26 Helps to genearate the token easier.27 18 [https://github.com/lmsace/lmsace-connect-moodle](https://github.com/lmsace/lmsace-connect-moodle) 28 19 29 ## Dependencies 20 21 ### Dependencies 30 22 31 23 Component: WooCommerce … … 35 27 Plugin URI: https://woocommerce.com/ 36 28 29 37 30 ## Documenation 38 31 39 The official documentation for LMSACE Connect can be found at [https://lmsace.com/docs/lmsace-connect](https://lmsace.com/docs/lmsace-connect). 32 The 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 40 34 41 35 ## Bugs and Problems Report. 42 36 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. 37 This 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 44 39 45 40 ## Feature Proposals. 46 41 47 You are develop custom feature for LMSACE Connect. Please create pull request and createissue on Github: https://github.com/lmsace/lmsace-connect/issues.42 You 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. 48 43 49 44 … … 51 46 52 47 1. Selective Course Imports. 53 2. Link course with existing products.48 2. Link the course with existing products. 54 49 3. User creation and enrolment on order completion. 55 3. User unerollment on order cancellation. 56 4. Selectable role for pariticipants. 50 3. User un-enrollment on order cancellation. 51 4. Selectable role for participants. 52 5. Seamless login with SSO 53 6. Bundle multiple courses in a product. 54 7. Import courses with syllabus summary. 55 57 56 58 57 … … 61 60 > **Note:** Make sure the **Woocommerce** is correctly installed. 62 61 63 1. Clone Project Git repository in any of your prefered location.62 1. Download the latest "**LMSACE Connect WooCommerce**" plugin file from the [github releases](https://github.com/lmsace/lmsace-connect-woocommerce/releases) 64 63 65 2. Rename the folder name into '**lmsace-connect**'.64 2. Next login as Site Administrator 66 65 67 3. Next login as Site administrator66 3. Go to '*Plugins*' -> '*Add New*' -> '*Upload Plugin*', On here upload the plugin zip '**lmsace-connect.zip**'. 68 67 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. 68 4. Click the "**Instal Now**" button. 72 69 73 70 74 > You will get **success message** once the plugininstalled successfully.71 > You will get a **success message** once the plugin is installed successfully. 75 72 76 73 77 6. By clicking "**Activate**" button on success page , Plugin willactivated and you will redirect to Your dashboard.74 5. By clicking the "**Activate**" button on the success page, Plugin will be activated and you will redirect to Your dashboard. 78 75 79 76 … … 81 78 82 79 83 1. Clone **LMSACE Connect**plugin Git repository into the folder '*plugins*'.80 1. Clone [**LMSACE Connect WooCommerce**](https://github.com/lmsace/lmsace-connect-woocommerce) plugin Git repository into the folder '*plugins*'. 84 81 85 82 > '*Your root diroctory*' -> '*wp-content*' -> '*plugins*'. 86 83 87 2. Rename the folder name into '**lmsace-connect**'.84 2. Rename the folder name to '**lmsace-connect**'. 88 85 89 3. Next login as Site administrator86 3. Next login as Site Administrator 90 87 91 4. Go to the '*Plugins*' -> '*Installed plugins*'. On here LMSACE Connect plugin willlisted.88 4. Go to the '*Plugins*' -> '*Installed plugins*'. Here LMSACE Connect plugin will be listed. 92 89 93 5. Activate the plugin by clicking "**Activate**" button placed on the bottom of the plugin name, Plugin will get the success message.90 5. Activate the plugin by clicking the "**Activate**" button placed on the bottom of the plugin name, Plugin will get the success message. 94 91 95 92 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  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  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  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. 138 94 139 95 140 96 ## Copyright 141 97 142 LMSACE DEV TEAM https://lmsace.com 98 @LMSACE DEV TEAM [https://lmsace.com](https://lmsace.com) 99 143 100 144 101 ### Review 145 102 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.103 You feel LMSACE Connect helps you to sell courses easier. "**Give a review and rating on wordpress.org**". We are looking for your comments. 147 104 105 106 ### Changes log 107 108 1. 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 117 2. 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 55 55 } 56 56 #wpbody-content .lmsace-connect-admin-config .tab-content form { 57 57 58 58 } 59 59 #wpbody-content .lmsace-connect-admin-config .dataTables_wrapper table.dataTable { … … 106 106 107 107 #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; 110 110 text-align: center; 111 111 white-space: nowrap; … … 119 119 #wpbody-content .lmsace-connect-admin-config tr:nth-child(4) th { 120 120 /* display: none; */ 121 font-size: 1.3em;121 /* font-size: 1.3em; */ 122 122 } 123 123 -
lmsace-connect/trunk/assets/js/admin.js
r2755044 r2943131 21 21 startSyncCourses($(this)); 22 22 }); 23 24 if ( $("#login_lms").length ) { 25 26 $("#login_lms").change(function() { 27 hideRedirectLess(); 28 }) 29 } 23 30 } 24 31 … … 114 121 function course_selectbox() { 115 122 if ($('.woocommerce_options_panel#course_options').length) { 116 $(' [name=lac_moodle_course_id]').select2();123 $('#lac_moodle_courses').select2(); 117 124 } 118 125 } … … 232 239 } 233 240 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 234 256 // Init. 235 257 register_event_handler(); 236 258 importTable(); 237 259 course_selectbox(); 260 261 hideRedirectLess(); 238 262 }) -
lmsace-connect/trunk/includes/admin/class-lac-admin-request.php
r2755044 r2943131 79 79 $assign_category = in_array( 'course_category', $import_option) ? true : false; 80 80 81 // $others = in_array( 'other', $import_option) ? $import_option['other'] : []; 82 81 83 $selectedcourses = explode(',', $courses); 84 85 $service = 'get_courses_by_field'; 86 87 $service = apply_filters('lmsace_connect_course_import_service', $service, $import_option); 82 88 83 89 if ( !empty($courses) && count($selectedcourses) < LACONN_IMPORT_LIMIT) { 84 90 /* 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), 86 92 array( 87 93 'field' => 'ids', … … 94 100 95 101 // 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 ); 97 103 if (isset($status['response_body'])) { 98 104 $counts = $status['response_body']; 99 105 $count = (count($counts['created'])) ? count($counts['created']).' courses created, ' : ' No courses created, '; 100 106 $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 } 102 109 103 110 $result = array('error' => false, 'message' => '<span class="connection-success">'. … … 105 112 ); 106 113 } 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>'); 108 115 } 109 116 … … 113 120 if (!empty($count)) { 114 121 $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 ); 116 123 $message = esc_html( __('Courses import process running in background. Please staty logged in.', LAC_TEXTDOMAIN)); 117 124 $result = array('error' => false, 'message' => '<span class="connection-info">'.$message.'</span>' ); -
lmsace-connect/trunk/includes/admin/class-lac-admin.php
r2755933 r2943131 42 42 */ 43 43 public function get_tabs() { 44 return[44 $tabs = [ 45 45 'lac-connection-options' => esc_html( __( 'Connection Setup', 'lmsace-connect' )), 46 46 'lac-general-options' => esc_html( __('General Setup', 'lmsace-connect' )), 47 47 'lac-import-courses' => esc_html( __('Import Courses', 'lmsace-connect' )), 48 48 ]; 49 50 return apply_filters( 'lmsace_connect_get_setting_tabs', $tabs); 49 51 } 50 52 … … 67 69 add_filter( 'woocommerce_product_data_panels', 'lac_moodle_courses_product_tab_content' ); 68 70 // 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') ); 72 77 } 73 78 … … 187 192 $doc = new DOMDocument(); 188 193 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()); 190 196 } 191 197 @$doc->loadHTML($course->summary); … … 193 199 $images = $src = []; 194 200 foreach ($tags as $tag) { 201 $class = $tag->getAttribute('class'); 202 if ($class == 'modicon') { 203 continue; 204 } 195 205 $url = $tag->getAttribute('src'); 196 206 $src[] = $url; // Used on replace. … … 201 211 $updated = $LACONN->Course->upload_product_image($post_id, $images, 'course_summary'); 202 212 $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() ); 206 216 } 207 217 … … 249 259 ); 250 260 261 do_action( 'lmsace_connect_admin_setting_menu' ); 262 251 263 remove_submenu_page('lac-admin-settings', 'lac-admin-settings' ); 252 264 … … 257 269 } 258 270 271 /** 272 * Connection setup admin settings section. 273 * 274 * @return void 275 */ 259 276 public function admin_setting_connectionsetup() { 260 277 $this->admin_setting_tabs( 'lac-connection-options', 'sitedetails' ); 261 278 } 262 279 /** 280 * Init the general settings setup section. 281 * 282 * @return void 283 */ 263 284 public function admin_setting_generaloptions() { 264 285 $this->admin_setting_tabs( 'lac-general-options', 'generaloptions' ); 265 286 } 266 287 288 /** 289 * Admin settings defined to import courses. 290 * 291 * @return void 292 */ 267 293 public function admin_setting_importcourses() { 268 294 $this->admin_setting_tabs( 'lac-import-courses', 'importcourses' ); … … 319 345 } 320 346 347 /** 348 * General options admin tab content. 349 * 350 * @return void 351 */ 321 352 public function generaloptions_admin_tabcontent() { 322 353 settings_errors(); … … 325 356 <form method="post" action="options.php"> 326 357 <?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 ?> 328 362 <?php submit_button(); ?> 329 363 </form> … … 452 486 'connection_settings_section' 453 487 ); 488 454 489 // Moodle token to connect. 455 490 add_settings_field( … … 502 537 ); 503 538 539 do_action( 'lmsace_connect_register_setting_fields' ); 540 504 541 LACONN()->is_setup_completed(); 505 542 } … … 687 724 ?> 688 725 <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> 691 728 </p> 692 729 <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> 695 732 </p> 696 733 <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> 699 736 </p> 700 737 <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> 703 744 </p> 704 745 <?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; 705 810 } 706 811 } -
lmsace-connect/trunk/includes/admin/class-lac-product-settings.php
r2755044 r2943131 19 19 20 20 $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 = []; 22 22 if (!empty($result) && isset($result->courses)) { 23 23 $courses = $result->courses; … … 34 34 ?><div id='course_options' class='panel woocommerce_options_panel'><?php 35 35 ?><div class='options_group'><?php 36 woocommerce_wp_select( array( 36 37 $attr = array( 37 38 'id' => LACONN_MOODLE_COURSE_ID, 38 'label' => esc_html( __( 'Select Course ', 'lmsace-connect' )),39 'label' => esc_html( __( 'Select Courses', 'lmsace-connect' )), 39 40 'desc_tip' => 'true', 40 41 '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 45 51 ?></div> 46 52 </div><?php 47 53 } 48 54 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 100 100 $response['response_message'] = esc_html( __(' URL Not Found, Please check your url', 'lmsace-connect')); 101 101 } 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' => '' ); 109 108 } 110 109 … … 230 229 } 231 230 231 232 232 233 } -
lmsace-connect/trunk/includes/class-lac-course.php
r2755044 r2943131 41 41 add_filter( 'cron_schedules', array( $this, 'lac_cron_definer' ) ); 42 42 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 44 50 /** 45 51 * Returns an instance of the plugin object … … 334 340 * @return array result of connection 335 341 */ 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=[]) { 337 343 global $LACONN; 338 344 $this->get_user(); 339 345 if ( !empty($courseslist) ) { 346 347 $courseslist = apply_filters( 'lmsace_connect_before_course_update', $courseslist); 340 348 341 349 $successUpdate = $errorUpdate = $successCourses = $errorCourses = $errorExist = array(); … … 345 353 if ($update_existing) { 346 354 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) ) { 348 357 $successUpdate[$course->id] = $course->fullname; 349 358 LACONN()->logger()->add('course', 'Course product updated - '.$course->fullname.''); … … 358 367 } else { 359 368 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) ) { 362 371 $successCourses[$course->id] = $course->fullname; 363 372 LACONN()->logger()->add('course', 'Course created as product - '.$course->fullname.''); … … 397 406 * @return bool 398 407 */ 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=[]) { 400 409 global $LACONN; 401 410 … … 412 421 $summary = $this->admin->replace_coursesummary_images($post_id, $course); 413 422 $postcontent = [ 'ID' => $post_id, 'post_content' => $summary ]; 423 414 424 wp_update_post( $postcontent, true ); 415 425 … … 470 480 * @return void 471 481 */ 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=[]) { 473 483 global $LACONN; 474 484 $post = array( … … 482 492 483 493 $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 } 484 505 $post['post_content'] = $summary; 485 506 486 // update course details in product post.507 // update course details in product post. 487 508 $postid = wp_update_post($post, true); 488 509 … … 546 567 update_post_meta( $post_id, '_sku', $course->shortname ); 547 568 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 ); 549 571 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); 551 573 } else { 552 update_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $course ->id);574 update_post_meta( $post_id, LACONN_MOODLE_COURSE_ID, $courses); 553 575 } 554 576 -
lmsace-connect/trunk/includes/class-lac-user.php
r2755044 r2943131 193 193 if (!empty($moo_users)) { 194 194 // 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 ); 196 202 197 203 if ( !empty($moodle_users) ) { 198 204 199 205 foreach ( $moodle_users as $moodle_user ) { 200 201 206 // Add moodle userid with the associated wp user. 202 207 $this->add_user_moodle_id( $user_data->ID, $moodle_user->id ); 203 208 $LACONN->logger()->add( 'order', 'User "'.$moodle_user->username.'" (WPuserid - '. $user_data->ID.') created in moodle and synced with WP'); 204 205 209 $this->set_admin_notices( 'success', esc_html( __('User created successfully on LMS', 'lmsace-connect') )); 206 207 210 $md_user_id = $moodle_user->id; 208 209 211 } 210 212 // Returns the reterived moodle user ids. … … 237 239 ); 238 240 241 242 239 243 return $user_fields; 240 244 } … … 301 305 global $LACONN; 302 306 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 ); 304 308 if ( !empty($user) ) { 305 309 $args = array( 'field' => 'email', 'values' => array( sanitize_user($user->user_email) ) ); … … 339 343 ); 340 344 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 : []; 344 356 } 345 357 … … 352 364 353 365 if ( $md_user_id = $this->is_moodle_user( $user->ID )) { 354 $this->wooCom = $this->get_handler('woocom');355 366 $enrolments = $list = []; 356 367 if ( $orders = $this->get_user_orders( $user->ID, true ) ) { 357 368 foreach ( $orders as $key => $order ) { 358 $itemids = [];359 369 $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); 373 374 } 374 375 } … … 378 379 return []; 379 380 } 381 382 380 383 } -
lmsace-connect/trunk/includes/class-lac-woocom.php
r2755044 r2943131 42 42 43 43 // 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 ); 45 45 // 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); 47 47 // add_action('woocommerce_order_refunded', array($this, 'process_order_refund' ), 10, 2); 48 48 49 49 // 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' ) ); 51 51 // 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' ) ); 53 53 // 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') ); 55 55 // Rearrange the menu order on user dashboard. 56 add_filter( 'woocommerce_account_menu_items', array( $this, 'my_account_menu_order') );57 58 56 add_filter( 'woocommerce_account_menu_items', array( $this, 'my_account_menu_order') ); 59 57 … … 72 70 add_filter( 'woocommerce_add_to_cart_validation', array( $this, 'lac_prevent_twice_course_product' ), 10, 2 ); 73 71 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>'; 74 98 } 75 99 … … 85 109 86 110 $md_course_id = $this->get_product_moodle_id( $product_id ); 111 // Product not a course linked no need to prevent. 87 112 if ( !$md_course_id ) { 88 113 return $validation; … … 93 118 $products[] = $product->get_id(); 94 119 } 95 120 // Course Product already added to the cart. 96 121 if ( in_array($product_id, array_values($products)) ) { 97 122 return false; … … 122 147 */ 123 148 public function create_order_enrollment() { 149 124 150 if (isset($_POST['order_id']) && !empty($_POST['order_id'])) { 125 151 $result = $this->process_order_completed( sanitize_text_field( $_POST['order_id'] ) ); … … 136 162 ?> 137 163 <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> 139 165 <p><?php esc_html_e( 'Disable the guest checkout on woocommerce..', 'lmsace-connect' ); ?></p> 140 166 </div> … … 180 206 $user_id = $details['order']->get_user_id(); 181 207 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. 182 214 $md_user_id = $LACONN->User->is_moodle_user( $user_id, true, $details['user'] ); 183 215 … … 188 220 $product_id = $product->get_product_id(); 189 221 // 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 = []; 196 227 foreach ( $md_courses as $md_course_id ) { 197 228 // Enrol the user in the course in lms environment. … … 202 233 'courseid' => $md_course_id 203 234 ); 235 204 236 $metaenrols[] = array_merge($enrols, ['productid' => $product_id]); 205 237 $enrolments[] = $enrols; 206 238 207 239 $LACONN->logger()->add( 'order', 208 ' Preparing enrolment - "'.$product_id.'" ('.json_encode($enrolments).') ');240 ' Preparing enrolment - "'.$product_id.'" ('.json_encode( $enrolments ).') ' ); 209 241 } 210 242 } … … 216 248 $details['order']->update_meta_data( 'lac_enrolments', $metaenrols ); 217 249 $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'] ) ) { 220 252 $LACONN->set_admin_notices( 'success', sprintf ( esc_html( __('User %1s enrolled on the courses', 'lmsace-connect') ), $details['user']->user_login ) ); 253 } 221 254 } 222 255 } … … 231 264 $t = $details['order']->save(); 232 265 } 233 266 // exit; 234 267 } 235 268 … … 238 271 * 239 272 * @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 ) { 243 277 global $LACONN; 278 244 279 if (!empty($order_id)) { 245 280 // Get the refuned order details to unenroll the user from moodle. … … 252 287 $order_enrolments = $details['order']->get_meta( 'lac_enrolments' ); 253 288 289 $order_enrolments = apply_filters( 'lmsace_connect_order_enrolments', $order_enrolments, $details['order'] ); 290 254 291 // User id connected with moodle. 255 292 $user_id = $details['order']->get_user_id(); 293 256 294 $data = $details['order']->get_data(); 257 295 258 296 $refund = isset($this->options['refund_suspend']) ? $this->options['refund_suspend'] : LACONN_SUSPEND; 259 297 260 if ( $data['status'] != 'completed'&& $refund && !empty($order_enrolments) ) {298 if ( ($force || $data['status'] != 'completed') && $refund && !empty($order_enrolments) ) { 261 299 262 300 $LACONN->logger()->add( 'order', ' Order refund init - orderID: '.$order_id); … … 319 357 320 358 // 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(); 323 360 324 361 if (!isset($user->email) && isset($user->user_email) && !empty($user->user_email)) { 325 362 $user->email = $user->user_email; 326 363 } 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 ); 329 375 } 330 376 … … 371 417 array( 372 418 'key' => LACONN_MOODLE_COURSE_ID, 373 'value' => $courseid419 'value' => serialize([$courseid]) 374 420 ) 375 421 ) … … 392 438 } 393 439 440 /** 441 * Fetch the list of courses linked with the product. 442 * 443 * @param int $product_id 444 * @return void 445 */ 394 446 public function get_product_moodle_id( $product_id ) { 395 447 return get_post_meta($product_id, LACONN_MOODLE_COURSE_ID, true); -
lmsace-connect/trunk/includes/class-lac.php
r2755933 r2943131 38 38 public $site_url; 39 39 40 public $handlers; 41 42 public $options; 43 44 public const KEY = 'LACONN_'; 45 40 46 /** 41 47 * Returns an instance of the plugin object … … 57 63 */ 58 64 public function __construct() { 59 60 65 $this->define(); 61 66 $this->setup_config(); 67 $this->includes(); 68 } 69 70 public function setup_config() { 62 71 $this->dirroot = dirname( LAC_PLUGIN_FILE ); 63 72 $this->wwwroot = plugin_dir_url(__DIR__); … … 74 83 $this->site_url .= '/'; 75 84 } 76 77 $this->includes();78 85 } 79 86 … … 83 90 * @return void 84 91 */ 85 private function define() { 92 protected function define() { 93 86 94 $upload_dir = wp_upload_dir( null, false ); 87 95 $params = [ 88 96 'LAC_TEXTDOMAIN' => 'lmsace-connect', 89 97 'NONCEKEY' => 'lmsace-connect-nonce', 90 'LACONN_MOODLE_COURSE_ID' => 'lac_moodle_course _id',98 'LACONN_MOODLE_COURSE_ID' => 'lac_moodle_courses', 91 99 'LMSCONF_DEBUG' => true, 92 100 'ENROLLED' => 1, … … 98 106 'LACONN_IMPORT_LIMIT' => 25 99 107 ]; 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 { 100 118 foreach ($params as $key => $value) { 101 119 if ( !defined($key) ) { … … 118 136 add_action( 'woocommerce_loaded', array($this, 'woocommerce_version_check')); 119 137 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 } 120 159 } 121 160 } … … 141 180 } 142 181 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 ); 146 196 $this->{$handler} = $handler_class; 147 197 } 148 }198 } 149 199 150 200 /** … … 200 250 public function logger() { 201 251 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 } 202 263 } 203 264 … … 214 275 $path .= 'class-lac-'.$class.'.php'; 215 276 require_once($path); 216 $class = 'LACONN_'.ucwords(str_replace( '-', '_', $class));277 $class = self::KEY.ucwords(str_replace( '-', '_', $class)); 217 278 return (new ReflectionClass ( $class ))->newInstanceArgs ( $params ); 218 279 } … … 239 300 */ 240 301 public function register_actions() { 302 241 303 add_action('init', array($this, 'register_lac_session')); 242 304 foreach ( array_keys($this->handlers) as $key => $handler ) { 243 305 $handler_class = (new $handler()); 244 $handler = str_replace( 'LACONN_', '', $handler);306 $handler = str_replace( self::KEY, '', $handler); 245 307 $this->{$handler} = $handler_class; 246 if ( method_exists($handler_class, 'lac_register_actions')) {308 if ( method_exists( $handler_class, 'lac_register_actions' ) ) { 247 309 $handler_class->lac_register_actions(); 248 310 } 249 311 250 312 // 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' ) ) { 252 314 $this->{$handler}->lac_register_admin_actions(); 253 315 } … … 317 379 public function is_setup_completed() { 318 380 global $LACONN; 319 381 320 382 $options = $this->get_options(); 321 383 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); 323 385 } else { 324 386 $request = $this->Client->request(self::services('get_user_roles'), array(), false); … … 410 472 } 411 473 474 /** 475 * Removed the admin notifce flash messages. 476 * 477 * @param string $name 478 * @return void 479 */ 412 480 public function remove_admin_notices($name) { 413 481 if (isset($_SESSION['lac_admin_flash'][$name])) … … 418 486 * Allowed html tags to kses. 419 487 * 420 * @return array488 * @return void 421 489 */ 422 490 public function allowed_tags() { … … 466 534 'get_user_roles' => 'local_lmsace_connect_user_roles', 467 535 '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' 469 538 ]; 470 539 540 $services = apply_filters( 'lmsace_connect_get_services', $services ); 541 471 542 return isset($services[$key]) ? $services[$key] : $services; 472 543 } 544 545 473 546 } -
lmsace-connect/trunk/lmsace-connect.php
r2755044 r2943131 4 4 * Plugin URI: http://lmsace.com/product/lmsace-connect 5 5 * Description: This plugin connects the Moodle™ LMS + WooCommerce. Helps course creators to sell their Moodle™ LMS courses via WooCommerce. 6 * Version: 1.06 * Version: 2.0 7 7 * Author: LMSACE 8 8 * Author URI: https://www.lmsace.com/ 9 9 * Requires at least: 4.6+ 10 * Tested up to: 6. 010 * Tested up to: 6.2.2 11 11 * Requires PHP: 5.6 12 12 * 13 13 * WC requires at least: 3.0 14 * WC tested up to: 6.3.114 * WC tested up to: 7.8.0 15 15 * 16 16 * License: GNU General Public License v3.0 … … 39 39 add_action('plugins_loaded', 'lac_load_textdomain'); 40 40 41 /** 42 * Plugins admin settings. 43 * 44 * @param array $links 45 * @return void 46 */ 41 47 function lmsace_connect_settings_link($links) { 42 48 $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>'; 44 50 array_unshift($links, $settings_link); 45 51 return $links; 46 52 } 47 53 $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' ); 49 55 50 56 /** … … 115 121 return LACONN::instance(); 116 122 } 123 124 125 126 function print_object($data) { 127 echo '<pre>'; 128 print_r($data); 129 echo '</pre>'; 130 } 131 117 132 // Initialize the plugin intial function to register actions. 118 133 global $LACONN; 119 134 $LACONN = LACONN(); 120 135 $LACONN->init(); 136 137 // TODO: Update the course product meta to array. 121 138 } 139 140 -
lmsace-connect/trunk/readme.txt
r2757257 r2943131 1 1 === LMSACE Connect - WooCommerce Moodle™ LMS Integration === 2 2 Contributors: 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 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, lmsace-connect, moodle-sso, moodle-wordpress-sso, moodle-woocommerce-sso 4 4 Requires at least: 4.6 5 Tested up to: 6. 05 Tested up to: 6.2.2 6 6 Requires PHP: 5.6 7 Stable tag: 1.0.17 Stable tag: 2.0 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 13 13 == Description == 14 14 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.15 This 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. 16 16 17 17 **Plugin Features** … … 23 23 - 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. 24 24 - Removes users from Moodle™ courses when refunded or cancelling a Woocommerce order. 25 - Seamless login with SSO 26 - Import courses with its syllabus summary. 25 27 26 28 **Benefits of integrating Moodle™ LMS with Woocommerce Store** … … 37 39 - Automatically enroll students after payment 38 40 - You Can Add up-sells, order bumps, and other revenue boosters 39 - [PRO]Sell multiple courses bundled41 - Sell multiple courses bundled 40 42 - [PRO] Monetize online courses via offering membership subscriptions 41 43 … … 64 66 - Go to the "Add new" section under the "Plugins" menu. 65 67 - 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. 67 69 - Click the "**Install Now**" button. 68 70 - 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 L MSACE Connect.71 - By clicking the "**Activate**" button, you can able to access the features of LACONN. 70 72 71 73 = Manual installation = 72 74 73 1. Download the plugin file [lmsace-connect-woocommerce.zip](http ://www.lmsace.com/plugins/downloads/lmsace-connect-woocommerce.zip)75 1. Download the plugin file [lmsace-connect-woocommerce.zip](https://downloads.wordpress.org/plugin/lmsace-connect.2.0.zip) 74 76 2. In your WordPress admin area, navigate to PLUGINS > ADD NEW 75 77 3. Click Upload Plugin … … 80 82 **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 )** 81 83 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.** 83 85 84 86 == Screenshots == … … 119 121 Initial LMSACE Connect Release Version 120 122 121 = 1.0.1 =122 Fixed html escape in warning messages123 124 123 == Upgrade Notice == 125 124 126 125 = 1.0 = 127 126 Initial release. No upgrade notices 127 128 = 2.0 = 129 SSO feature implemented. 130 Bundle multiple courses in a single product. 131 Import course with outline data. -
lmsace-connect/trunk/templates/mycourses.php
r2755044 r2943131 18 18 19 19 <?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 ); 20 24 foreach ( $courses as $key => $course ) { 21 25 26 $course = (object) $course; 22 27 $courseid = $course->courseid; 23 28 // Get product id from the enrolled LMS course id. … … 27 32 28 33 $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 30 37 ?> 31 38 <div class="product-item col-md-3"> … … 34 41 </div> 35 42 <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> 38 46 </div> 39 47 </div>
Note: See TracChangeset
for help on using the changeset viewer.