Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/plugin-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Build plugin
run: |
pnpm build
Comment thread
RishadAlam marked this conversation as resolved.
Outdated
bash .github/copy-assets
bash .github/build

Comment thread
RishadAlam marked this conversation as resolved.
- name: WordPress Plugin Check
uses: wordpress/plugin-check-action@v1
Expand All @@ -86,7 +86,6 @@ jobs:
checks: |
i18n_usage
late_escaping
plugin_header
plugin_readme
file_type
performant_wp_query_params
Expand Down
50 changes: 50 additions & 0 deletions backend/Actions/CreatorLms/CreatorLmsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* Creator LMS Integration
*/

namespace BitApps\Integrations\Actions\CreatorLms;

use WP_Error;

/**
* Provide functionality for Creator LMS integration
*/
class CreatorLmsController
{
public static function isExists()
{
if (!class_exists('CreatorLms') || !\function_exists('crlms_get_course')) {
wp_send_json_error(
__(
'Creator LMS is not activated or not installed',
'bit-integrations'
),
400
);
}
}

public static function creatorLmsAuthorize()
{
self::isExists();
wp_send_json_success(true);
}

public function execute($integrationData, $fieldValues)
{
$integrationDetails = $integrationData->flow_details;
$integId = $integrationData->id;
$fieldMap = $integrationDetails->field_map;
$utilities = isset($integrationDetails->utilities) ? $integrationDetails->utilities : [];

if (empty($fieldMap)) {
return new WP_Error('field_map_empty', __('Field map is empty', 'bit-integrations'));
}

$recordApiHelper = new RecordApiHelper($integrationDetails, $integId);

return $recordApiHelper->execute($fieldValues, $fieldMap, $utilities);
}
}
106 changes: 106 additions & 0 deletions backend/Actions/CreatorLms/RecordApiHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

/**
* Creator LMS Record Api
*/

namespace BitApps\Integrations\Actions\CreatorLms;

use BitApps\Integrations\Config;
use BitApps\Integrations\Core\Util\Common;
use BitApps\Integrations\Core\Util\Hooks;
use BitApps\Integrations\Log\LogHandler;

/**
* Provide functionality for Record insert, update
*/
class RecordApiHelper
{
private $_integrationID;

private $_integrationDetails;

public function __construct($integrationDetails, $integId)
{
$this->_integrationDetails = $integrationDetails;
$this->_integrationID = $integId;
}

public function execute($fieldValues, $fieldMap, $utilities)
{
if (!class_exists('CreatorLms') || !\function_exists('crlms_get_course')) {
return [
'success' => false,
'message' => __('Creator LMS is not installed or activated', 'bit-integrations')
];
}

$fieldData = $this->generateReqDataFromFieldMap($fieldMap, $fieldValues);
$mainAction = $this->_integrationDetails->mainAction ?? 'create_student';

$defaultResponse = [
'success' => false,
// translators: %s is replaced with the plugin name "Bit Integrations Pro"
'message' => wp_sprintf(__('%s plugin is not installed or activated', 'bit-integrations'), 'Bit Integrations Pro')
];

switch ($mainAction) {
case 'create_student':
$response = Hooks::apply(Config::withPrefix('creator_lms_create_student'), $defaultResponse, $fieldData);
$type = 'student';
$actionType = 'create_student';

break;
case 'update_student_data':
$response = Hooks::apply(Config::withPrefix('creator_lms_update_student_data'), $defaultResponse, $fieldData);
$type = 'student';
$actionType = 'update_student_data';

break;
case 'enroll_user_in_course':
$response = Hooks::apply(Config::withPrefix('creator_lms_enroll_user_in_course'), $defaultResponse, $fieldData);
$type = 'enrollment';
$actionType = 'enroll_user_in_course';

break;
case 'create_course':
$response = Hooks::apply(Config::withPrefix('creator_lms_create_course'), $defaultResponse, $fieldData, $this->_integrationDetails);
$type = 'course';
$actionType = 'create_course';

break;
case 'mark_lesson_completed':
$response = Hooks::apply(Config::withPrefix('creator_lms_mark_lesson_completed'), $defaultResponse, $fieldData);
$type = 'lesson';
$actionType = 'mark_lesson_completed';

break;
default:
$response = ['success' => false, 'message' => __('Invalid action', 'bit-integrations')];
$type = 'CreatorLms';
$actionType = 'unknown';

break;
}

$responseType = isset($response['success']) && $response['success'] ? 'success' : 'error';
LogHandler::save($this->_integrationID, ['type' => $type, 'type_name' => $actionType], $responseType, $response);

return $response;
}

private function generateReqDataFromFieldMap($fieldMap, $fieldValues)
{
$dataFinal = [];
foreach ($fieldMap as $item) {
$triggerValue = $item->formField;
$actionValue = $item->creatorLmsField;

$dataFinal[$actionValue] = $triggerValue === 'custom' && isset($item->customValue)
? Common::replaceFieldWithValue($item->customValue, $fieldValues)
: $fieldValues[$triggerValue] ?? '';
}

return $dataFinal;
}
}
10 changes: 10 additions & 0 deletions backend/Actions/CreatorLms/Routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

if (!defined('ABSPATH')) {
exit;
}

use BitApps\Integrations\Actions\CreatorLms\CreatorLmsController;
use BitApps\Integrations\Core\Util\Route;

Route::post('creator_lms_authorize', [CreatorLmsController::class, 'creatorLmsAuthorize']);
1 change: 1 addition & 0 deletions backend/Core/Util/AllTriggersName.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static function allTriggersName()
'FF' => ['name' => 'Fluent Forms', 'isPro' => true, 'is_active' => false],
'FluentBoards' => ['name' => 'Fluent Boards', 'isPro' => true, 'is_active' => false],
'FluentBooking' => ['name' => 'Fluent Booking', 'isPro' => true, 'is_active' => false],
'CreatorLms' => ['name' => 'Creator LMS', 'isPro' => true, 'is_active' => false],
Comment thread
RishadAlam marked this conversation as resolved.
'FluentCart' => ['name' => 'FluentCart', 'isPro' => true, 'is_active' => false],
'FluentCrm' => ['name' => 'Fluent CRM', 'isPro' => true, 'is_active' => false],
'FluentCommunity' => ['name' => 'Fluent Community', 'isPro' => true, 'is_active' => false],
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/Utils/StaticData/tutorialLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ const tutorialLinks = {
'https://youtube.com/playlist?list=PL7c6CDwwm-AL0ckxqJPUdiG0syI65HXg2&si=JkJ_0Q0iOA24_wtl',
docLink: 'https://bit-integrations.com/wp-docs/actions/academy-lms-integrations-as-an-action/'
},
creatorLms: {
youTubeLink: '',
docLink: 'https://bit-integrations.com/wp-docs/actions/creator-lms-integrations/'
},
woodpecker: {
youTubeLink:
'https://youtube.com/playlist?list=PL7c6CDwwm-AL0mmQk0yX6u-HnqDzJeXDu&si=MdiwtkYVb0kBIjPD',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/Utils/StaticData/webhookIntegrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const customFormIntegrations = [
'FormGent',
'GeoDirectory',
'StoreEngine',
'CreatorLms',
'FluentCart',
'MailMint',
'BookingCalendarContactForm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Autonami({ formFields, setFlow, flow, allIntegURL }) {
style={{
width: step === 2 && 900,
height: step === 2 && 'auto',
minHeight: step === 2 && `${200}px`
minHeight: step === 2 && `${500}px`
}}>
<AutonamiIntegLayout
formID={formID}
Expand Down
106 changes: 106 additions & 0 deletions frontend/src/components/AllIntegrations/CreatorLms/CreatorLms.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { useState } from 'react'
import 'react-multiple-select-dropdown-lite/dist/index.css'
import { useNavigate, useParams } from 'react-router-dom'
import BackIcn from '../../../Icons/BackIcn'
import { __ } from '../../../Utils/i18nwrap'
import SnackMsg from '../../Utilities/SnackMsg'
import { saveIntegConfig } from '../IntegrationHelpers/IntegrationHelpers'
import IntegrationStepThree from '../IntegrationHelpers/IntegrationStepThree'
import CreatorLmsAuthorization from './CreatorLmsAuthorization'
import { checkMappedFields } from './CreatorLmsCommonFunc'
import CreatorLmsIntegLayout from './CreatorLmsIntegLayout'

export default function CreatorLms({ formFields, setFlow, flow, allIntegURL }) {
const navigate = useNavigate()
const { formID } = useParams()
const [isLoading, setIsLoading] = useState(false)
const [step, setStep] = useState(1)
const [snack, setSnackbar] = useState({ show: false })
const [creatorLmsConf, setCreatorLmsConf] = useState({
name: 'Creator LMS',
type: 'CreatorLms',
field_map: [{ formField: '', creatorLmsField: '' }],
actions: {},
mainAction: ''
})

const nextPage = val => {
setTimeout(() => {
document.getElementById('btcd-settings-wrp').scrollTop = 0
}, 300)

if (val === 3) {
if (!checkMappedFields(creatorLmsConf)) {
setSnackbar({
show: true,
msg: __('Please map all required fields to continue.', 'bit-integrations')
})
return
}

if (creatorLmsConf.name !== '' && creatorLmsConf.field_map.length > 0) {
setStep(val)
}
} else {
setStep(val)
}
}

return (
<div>
<SnackMsg snack={snack} setSnackbar={setSnackbar} />
<div className="txt-center mt-2">{/* <Steps step={3} active={step} /> */}</div>

{/* STEP 1 */}
<CreatorLmsAuthorization
formID={formID}
creatorLmsConf={creatorLmsConf}
setCreatorLmsConf={setCreatorLmsConf}
step={step}
nextPage={nextPage}
isLoading={isLoading}
setIsLoading={setIsLoading}
setSnackbar={setSnackbar}
/>

{/* STEP 2 */}
<div
className="btcd-stp-page"
style={{
width: step === 2 && 900,
height: step === 2 && 'auto',
minHeight: step === 2 && `${500}px`
}}>
<CreatorLmsIntegLayout
formID={formID}
formFields={formFields}
creatorLmsConf={creatorLmsConf}
setCreatorLmsConf={setCreatorLmsConf}
setSnackbar={setSnackbar}
setIsLoading={setIsLoading}
isLoading={isLoading}
/>
<br />
<br />
<br />
Comment thread
RishadAlam marked this conversation as resolved.
<button
onClick={() => nextPage(3)}
disabled={!checkMappedFields(creatorLmsConf)}
className="btn f-right btcd-btn-lg purple sh-sm flx"
type="button">
{__('Next', 'bit-integrations')}
<BackIcn className="ml-1 rev-icn" />
</button>
</div>

{/* STEP 3 */}
<IntegrationStepThree
step={step}
saveConfig={() =>
saveIntegConfig(flow, setFlow, allIntegURL, creatorLmsConf, navigate, '', '', setIsLoading)
}
isLoading={isLoading}
/>
</div>
)
}
Loading
Loading