PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.9.13
Tutor LMS – eLearning and online course solution v3.9.13
3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / includes / droip / backend / VisibilityCondition.php
tutor / includes / droip / backend Last commit date
ElementGenerator 2 months ago Ajax.php 2 weeks ago Backend.php 1 year ago Editor.php 1 year ago Frontend.php 1 year ago Helper.php 9 months ago Hooks.php 4 months ago Iframe.php 1 year ago Pages.php 9 months ago VisibilityCondition.php 4 months ago
VisibilityCondition.php
1082 lines
1 <?php
2
3 /**
4 * Preview script for html markup generator
5 *
6 * @package tutor-droip-elements
7 */
8
9 namespace TutorLMSDroip;
10
11 use TUTOR\Course;
12 use Tutor\Models\CartModel;
13 use TUTOR_CERT\Certificate;
14 use TutorLMSDroip\ElementGenerator\CourseMetaGenerator;
15
16 if (! defined('ABSPATH')) {
17 exit; // Exit if accessed directly.
18 }
19
20 /**
21 * Class Helper
22 * This class is used to define all helper functions.
23 */
24 class VisibilityCondition
25 {
26
27 use CourseMetaGenerator;
28
29 public static function visibility_condition_fields($conditions, $collection_data)
30 {
31 $type = $collection_data['type'];
32 $collectionType = $collection_data['collectionType'];
33 if ($collectionType === 'posts') {
34 switch ($type) {
35 case 'courses': {
36 $conditions = self::get_course_type_conditions($conditions);
37 $conditions = self::get_lms_setting_type_conditions($conditions);
38 break;
39 }
40 }
41
42 } elseif ($collectionType === 'user') {
43 switch ($type) {
44 case 'courses': {
45 $conditions['user'] = array(
46 'title' => 'Instructor',
47 'fields' => array_merge(
48 $conditions['user']['fields'],
49 array(
50 array(
51 'source' => TDE_APP_PREFIX,
52 'value' => 'instructor_course_count',
53 'title' => 'Course Count',
54 'operator_type' => 'numeric_operators',
55 'operand_type' => array_merge(
56 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
57 array(
58 'placeholder' => 'Course Count',
59 )
60 ),
61 ),
62 array(
63 'source' => TDE_APP_PREFIX,
64 'value' => 'instructor_student_count',
65 'title' => 'Student Count',
66 'operator_type' => 'numeric_operators',
67 'operand_type' => array_merge(
68 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
69 array(
70 'placeholder' => 'Student Count',
71 )
72 ),
73 ),
74 array(
75 'source' => TDE_APP_PREFIX,
76 'value' => 'instructor_rating',
77 'title' => 'Rating',
78 'operator_type' => 'numeric_operators',
79 'operand_type' => array_merge(
80 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
81 array(
82 'placeholder' => 'Rating',
83 )
84 ),
85 ),
86 array(
87 'source' => TDE_APP_PREFIX,
88 'value' => 'instructor_rating_count',
89 'title' => 'Rating Count',
90 'operator_type' => 'numeric_operators',
91 'operand_type' => array_merge(
92 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
93 array(
94 'placeholder' => 'Rating Count',
95 )
96 ),
97 ),
98 )
99 ),
100 );
101 }
102 }
103 } else {
104 switch ($type) {
105 case 'TUTOR_LMS-tutor_course_rating': {
106 $conditions = self::get_course_type_conditions($conditions);
107 break;
108 }
109
110 case 'TUTOR_LMS-subscriptions': {
111 $conditions = self::get_subscription_type_conditions($conditions);
112 break;
113 }
114
115 case 'TUTOR_LMS-membership-plans': {
116 $conditions = self::get_membership_type_conditions($conditions);
117 break;
118 }
119
120 case 'TUTOR_LMS-membership-features': {
121 $conditions = self::get_membership_features_type_conditions($conditions);
122 break;
123 }
124 }
125 }
126
127 return $conditions;
128 }
129
130 private static function get_subscription_type_conditions($conditions)
131 {
132 if (!isset($conditions['post']['fields'])) {
133 $conditions['post']['fields'] = array();
134 }
135 $conditions['post'] = array(
136 'title' => 'Subscription',
137 'fields' => array_merge(
138 $conditions['post']['fields'],
139 array(
140
141 // recurring_interval
142 array(
143 'source' => TDE_APP_PREFIX,
144 'value' => 'recurring_interval',
145 'title' => 'Recurring Interval',
146 'operator_type' => 'dropdown_operators',
147 'operand_type' => array_merge(
148 DROIP_PLUGIN_SETTINGS['SELECT'],
149 array(
150 'options' => array(
151 array(
152 'value' => 'day',
153 'title' => 'Day',
154 ),
155 array(
156 'value' => 'week',
157 'title' => 'Week',
158 ),
159 array(
160 'value' => 'month',
161 'title' => 'Month',
162 ),
163 array(
164 'value' => 'year',
165 'title' => 'Year',
166 ),
167 ),
168 ),
169 ),
170 ),
171
172 // enrollment_fee
173 array(
174 'source' => TDE_APP_PREFIX,
175 'value' => 'enrollment_fee',
176 'title' => 'Enrollment Fee',
177 'operator_type' => 'numeric_operators',
178 'operand_type' => array_merge(
179 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
180 array(
181 'placeholder' => 'Enrollment Fee',
182 ),
183 ),
184 ),
185
186 // provide_certificate DEFAULT 1, -- 0 or 1
187 array(
188 'source' => TDE_APP_PREFIX,
189 'value' => 'provide_certificate',
190 'title' => 'Provide Certificate',
191 'operator_type' => 'dropdown_operators',
192 'operand_type' => array_merge(
193 DROIP_PLUGIN_SETTINGS['SELECT'],
194 array(
195 'options' => array(
196 array(
197 'value' => '1',
198 'title' => 'Yes',
199 ),
200 array(
201 'value' => '0',
202 'title' => 'No',
203 ),
204 ),
205 )
206 ),
207 ),
208
209 // is_featured
210 array(
211 'source' => TDE_APP_PREFIX,
212 'value' => 'is_featured',
213 'title' => 'Is Featured',
214 'operator_type' => 'dropdown_operators',
215 'operand_type' => array_merge(
216 DROIP_PLUGIN_SETTINGS['SELECT'],
217 array(
218 'options' => array(
219 array(
220 'value' => '1',
221 'title' => 'Yes',
222 ),
223 array(
224 'value' => '0',
225 'title' => 'No',
226 ),
227 ),
228 ),
229 ),
230 ),
231
232 // sale_price
233 array(
234 'source' => TDE_APP_PREFIX,
235 'value' => 'sale_price',
236 'title' => 'Sale Price',
237 'operator_type' => 'boolean_operators',
238 ),
239 ),
240 ),
241 );
242
243 return $conditions;
244 }
245
246 private static function get_membership_type_conditions($conditions)
247 {
248 if (!isset($conditions['post']['fields'])) {
249 $conditions['post']['fields'] = array();
250 }
251 $conditions['post'] = array(
252 'title' => 'Membership',
253 'fields' => array_merge(
254 $conditions['post']['fields'],
255 array(
256 array(
257 'source' => TDE_APP_PREFIX,
258 'value' => 'recurring_interval',
259 'title' => 'Recurring Interval',
260 'operator_type' => 'dropdown_operators',
261 'operand_type' => array_merge(
262 DROIP_PLUGIN_SETTINGS['SELECT'],
263 array(
264 'options' => array(
265 array(
266 'value' => 'day',
267 'title' => 'Day',
268 ),
269 array(
270 'value' => 'week',
271 'title' => 'Week',
272 ),
273 array(
274 'value' => 'month',
275 'title' => 'Month',
276 ),
277 array(
278 'value' => 'year',
279 'title' => 'Year',
280 ),
281 ),
282 ),
283 ),
284 ),
285
286 // recurring_value
287 array(
288 'source' => TDE_APP_PREFIX,
289 'value' => 'recurring_value',
290 'title' => 'Recurring Value',
291 'operator_type' => 'numeric_operators',
292 'operand_type' => array_merge(
293 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
294 array(
295 'placeholder' => 'Recurring Value',
296 )
297 ),
298 ),
299
300 // enrollment_fee
301 array(
302 'source' => TDE_APP_PREFIX,
303 'value' => 'enrollment_fee',
304 'title' => 'Has enrollment fee',
305 'operator_type' => 'boolean_operators',
306 ),
307
308 // provide_certificate DEFAULT 1, -- 0 or 1
309 array(
310 'source' => TDE_APP_PREFIX,
311 'value' => 'provide_certificate',
312 'title' => 'Provide Certificate',
313 'operator_type' => 'boolean_operators',
314 ),
315
316 // is_featured
317 array(
318 'source' => TDE_APP_PREFIX,
319 'value' => 'is_featured',
320 'title' => 'Is Featured',
321 'operator_type' => 'boolean_operators',
322 ),
323
324 // sale_price
325 array(
326 'source' => TDE_APP_PREFIX,
327 'value' => 'sale_price',
328 'title' => 'Offer sale Price',
329 'operator_type' => 'boolean_operators',
330 ),
331
332 // start: trial
333 array(
334 'source' => TDE_APP_PREFIX,
335 'value' => 'trial_value',
336 'title' => 'Length of Trial',
337 'operator_type' => 'numeric_operators',
338 'operand_type' => array_merge(
339 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
340 array(
341 'placeholder' => 'Trial Value',
342 )
343 ),
344 ),
345
346 array(
347 'source' => TDE_APP_PREFIX,
348 'value' => 'trial_interval',
349 'title' => 'Trial Interval',
350 'operator_type' => 'dropdown_operators',
351 'operand_type' => array_merge(
352 DROIP_PLUGIN_SETTINGS['SELECT'],
353 array(
354 'options' => array(
355 array(
356 'value' => 'day',
357 'title' => 'Day',
358 ),
359 ),
360 ),
361 ),
362 ),
363
364 array(
365 'source' => TDE_APP_PREFIX,
366 'value' => 'trial_fee',
367 'title' => 'Trial Fee',
368 'operator_type' => 'numeric_operators',
369 'operand_type' => array_merge(
370 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
371 array(
372 'placeholder' => 'Trial Fee',
373 )
374 ),
375 ),
376 // end: trial
377 ),
378 ),
379 );
380
381 return $conditions;
382 }
383
384 private static function get_membership_features_type_conditions($conditions)
385 {
386 if (!isset($conditions['post']['fields'])) {
387 $conditions['post']['fields'] = array();
388 }
389 $conditions['post'] = array(
390 'title' => 'Feature',
391 'fields' => array_merge(
392 $conditions['post']['fields'],
393 array(
394 array(
395 'source' => TDE_APP_PREFIX,
396 'value' => 'icon_type',
397 'title' => 'Icon',
398 'operator_type' => 'dropdown_operators',
399 'operand_type' => array_merge(
400 DROIP_PLUGIN_SETTINGS['SELECT'],
401 array(
402 'options' => array(
403 array(
404 'value' => 'yes',
405 'title' => 'Check',
406 ),
407 array(
408 'value' => 'no',
409 'title' => 'Times',
410 ),
411 ),
412 ),
413 ),
414 ),
415 ),
416 ),
417 );
418
419 return $conditions;
420 }
421
422 private static function get_course_type_conditions($conditions)
423 {
424 if (!isset($conditions['post']['fields'])) {
425 $conditions['post']['fields'] = array();
426 }
427 $conditions['post'] = array(
428 'title' => 'Course',
429 'fields' => array_merge(
430 $conditions['post']['fields'],
431 array(
432 array(
433 'source' => TDE_APP_PREFIX,
434 'value' => 'is_paid',
435 'title' => 'Paid',
436 'operator_type' => 'boolean_operators',
437 ),
438 array(
439 'source' => TDE_APP_PREFIX,
440 'value' => 'on_sale',
441 'title' => 'On Sale',
442 'operator_type' => 'boolean_operators',
443 ),
444 array(
445 'source' => TDE_APP_PREFIX,
446 'value' => 'purchase_options',
447 'title' => 'Purchase Options',
448 'operator_type' => 'dropdown_operators',
449 'operand_type' => array_merge(
450 DROIP_PLUGIN_SETTINGS['SELECT'],
451 array(
452 'options' => array(
453 array(
454 'value' => Course::SELLING_OPTION_ONE_TIME,
455 'title' => 'One Time',
456 ),
457 array(
458 'value' => Course::SELLING_OPTION_SUBSCRIPTION,
459 'title' => 'Subscription',
460 ),
461
462 array(
463 'value' => Course::SELLING_OPTION_BOTH,
464 'title' => 'Subscription & One-Time',
465 ),
466
467 array(
468 'value' => Course::SELLING_OPTION_MEMBERSHIP,
469 'title' => 'Membership',
470 ),
471 array(
472 'value' => Course::SELLING_OPTION_ALL,
473 'title' => 'All',
474 ),
475 ),
476 )
477 ),
478 ),
479 array(
480 'source' => TDE_APP_PREFIX,
481 'value' => 'average_rating',
482 'title' => 'Rating (Avg.)',
483 'operator_type' => 'numeric_operators',
484 'operand_type' => array_merge(
485 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
486 array(
487 'placeholder' => 'Rating',
488 )
489 ),
490 ),
491 array(
492 'source' => TDE_APP_PREFIX,
493 'value' => 'total_ratings',
494 'title' => 'Total Ratings',
495 'operator_type' => 'numeric_operators',
496 'operand_type' => array_merge(
497 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
498 array(
499 'placeholder' => 'Rating count',
500 )
501 ),
502 ),
503 array(
504 'source' => TDE_APP_PREFIX,
505 'value' => 'enroll_count',
506 'title' => 'Enrollment Count',
507 'operator_type' => 'numeric_operators',
508 'operand_type' => array_merge(
509 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
510 array(
511 'placeholder' => 'Enroll Count',
512 )
513 ),
514 ),
515 array(
516 'source' => TDE_APP_PREFIX,
517 'value' => 'student_state',
518 'title' => 'Student status',
519 'operator_type' => array(
520 array(
521 'title' => '= Equals',
522 'value' => 'user_state-is_equal',
523 ),
524 array(
525 'title' => '≠ Does not equal',
526 'value' => 'user_state-not_equal',
527 ),
528 ),
529 'operand_type' => array_merge(
530 DROIP_PLUGIN_SETTINGS['SELECT'],
531 array(
532 'options' => array(
533 array(
534 'value' => 'logged_in',
535 'title' => 'Logged in',
536 ),
537 array(
538 'value' => 'wishlisted',
539 'title' => 'Wishlisted',
540 ),
541 array(
542 'value' => 'added_in_cart',
543 'title' => 'Added in Cart',
544 ),
545 array(
546 'value' => 'enrolled',
547 'title' => 'Enrolled',
548 ),
549 array(
550 'value' => 'learner',
551 'title' => 'Learner',
552 ),
553 array(
554 'value' => 'can_retake',
555 'title' => 'Can Retake',
556 ),
557 array(
558 'value' => 'completed',
559 'title' => 'Completed',
560 ),
561 ),
562 )
563 ),
564 ),
565 // [
566 // 'source' => TDE_APP_PREFIX,
567 // 'value' => 'user_authored',
568 // 'title' => 'User authored',
569 // 'operator_type' => 'dropdown_operators',
570 // 'operand_type' => array_merge(
571 // DROIP_PLUGIN_SETTINGS['SELECT'],
572 // [
573 // 'options' => [
574 // ['value' => 'no_review', 'title' => 'No Review'],
575 // ['value' => 'current_review', 'title' => 'Current Review'],
576 // ['value' => 'no_question', 'title' => 'No Question'],
577 // ['value' => 'current_question', 'title' => 'Current Question'],
578 // ],
579 // ]
580 // ),
581 // ],
582 array(
583 'source' => TDE_APP_PREFIX,
584 'value' => 'resource_count',
585 'title' => 'Resources',
586 'operator_type' => 'numeric_operators',
587 'operand_type' => array_merge(
588 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
589 array(
590 'placeholder' => 'Resource Count',
591 )
592 ),
593 ),
594 array(
595 'source' => TDE_APP_PREFIX,
596 'value' => 'lesson_count',
597 'title' => 'Lessons',
598 'operator_type' => 'numeric_operators',
599 'operand_type' => array_merge(
600 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
601 array(
602 'placeholder' => 'Lesson Count',
603 )
604 ),
605 ),
606 array(
607 'source' => TDE_APP_PREFIX,
608 'value' => 'quiz_count',
609 'title' => 'Quizzes',
610 'operator_type' => 'numeric_operators',
611 'operand_type' => array_merge(
612 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
613 array(
614 'placeholder' => 'Quiz Count',
615 )
616 ),
617 ),
618 array(
619 'source' => TDE_APP_PREFIX,
620 'value' => 'assignments_count',
621 'title' => 'Assignments',
622 'operator_type' => 'numeric_operators',
623 'operand_type' => array_merge(
624 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
625 array(
626 'placeholder' => 'Assignment Count',
627 )
628 ),
629 ),
630 array(
631 'source' => TDE_APP_PREFIX,
632 'value' => 'is_review_enabled',
633 'title' => 'Review Enabled',
634 'operator_type' => 'boolean_operators',
635 ),
636 array(
637 'source' => TDE_APP_PREFIX,
638 'value' => 'is_qna_enabled',
639 'title' => 'QnA Enabled',
640 'operator_type' => 'boolean_operators',
641 ),
642 array(
643 'source' => TDE_APP_PREFIX,
644 'value' => 'is_certificate_enabled',
645 'title' => 'Certificate Enabled',
646 'operator_type' => 'boolean_operators',
647 ),
648 array(
649 'source' => TDE_APP_PREFIX,
650 'value' => 'difficulty_level',
651 'title' => 'Difficulty Level',
652 'operator_type' => 'dropdown_operators',
653 'operand_type' => array_merge(
654 DROIP_PLUGIN_SETTINGS['SELECT'],
655 array(
656 'options' => array(
657 array(
658 'value' => 'all_levels',
659 'title' => 'All Levels',
660 ),
661 array(
662 'value' => 'beginner',
663 'title' => 'Beginner',
664 ),
665 array(
666 'value' => 'intermediate',
667 'title' => 'Intermediate',
668 ),
669 array(
670 'value' => 'expert',
671 'title' => 'Expert',
672 ),
673 ),
674 )
675 ),
676 ),
677 )
678 ),
679 );
680 return $conditions;
681 }
682
683 private static function get_lms_setting_type_conditions($conditions)
684 {
685 if (!isset($conditions['lms-settings']['fields'])) {
686 $conditions['lms-settings']['fields'] = array();
687 }
688
689 $conditions['lms-settings'] = array(
690 'title' => 'LMS Settings',
691 'fields' => array_merge(
692 $conditions['lms-settings']['fields'],
693 array(
694 array(
695 'source' => TDE_APP_PREFIX,
696 'value' => 'is_membership_only_mode_enabled',
697 'title' => 'Membership-Only Mode',
698 'operator_type' => 'boolean_operators',
699 ),
700 array(
701 'source' => TDE_APP_PREFIX,
702 'value' => 'enable_spotlight_mode',
703 'title' => 'Spotlight Mode Enabled',
704 'operator_type' => 'boolean_operators',
705 ),
706
707 array(
708 'source' => TDE_APP_PREFIX,
709 'value' => 'display_course_instructors',
710 'title' => 'Instructor Info Enabled',
711 'operator_type' => 'boolean_operators',
712 ),
713 array(
714 'source' => TDE_APP_PREFIX,
715 'value' => 'enable_wishlist',
716 'title' => 'Wishlist Enabled',
717 'operator_type' => 'boolean_operators',
718 ),
719 array(
720 'source' => TDE_APP_PREFIX,
721 'value' => 'enable_q_and_a_on_course',
722 'title' => 'Q&A Enabled',
723 'operator_type' => 'boolean_operators',
724 ),
725 array(
726 'source' => TDE_APP_PREFIX,
727 'value' => 'enable_course_author',
728 'title' => 'Author Enabled',
729 'operator_type' => 'boolean_operators',
730 ),
731 array(
732 'source' => TDE_APP_PREFIX,
733 'value' => 'enable_course_level',
734 'title' => 'Level Enabled',
735 'operator_type' => 'boolean_operators',
736 ),
737 array(
738 'source' => TDE_APP_PREFIX,
739 'value' => 'enable_course_share',
740 'title' => 'Social Share Enabled',
741 'operator_type' => 'boolean_operators',
742 ),
743 array(
744 'source' => TDE_APP_PREFIX,
745 'value' => 'enable_course_duration',
746 'title' => 'Duration Enabled',
747 'operator_type' => 'boolean_operators',
748 ),
749 array(
750 'source' => TDE_APP_PREFIX,
751 'value' => 'enable_course_total_enrolled',
752 'title' => 'Total Enrolled Enabled',
753 'operator_type' => 'boolean_operators',
754 ),
755 array(
756 'source' => TDE_APP_PREFIX,
757 'value' => 'enable_course_update_date',
758 'title' => 'Update Date Enabled',
759 'operator_type' => 'boolean_operators',
760 ),
761 array(
762 'source' => TDE_APP_PREFIX,
763 'value' => 'enable_course_progress_bar',
764 'title' => 'Progress Bar Enabled',
765 'operator_type' => 'boolean_operators',
766 ),
767 array(
768 'source' => TDE_APP_PREFIX,
769 'value' => 'enable_course_material',
770 'title' => 'Show Material Enabled',
771 'operator_type' => 'boolean_operators',
772 ),
773 array(
774 'source' => TDE_APP_PREFIX,
775 'value' => 'enable_course_about',
776 'title' => 'About Enabled',
777 'operator_type' => 'boolean_operators',
778 ),
779 array(
780 'source' => TDE_APP_PREFIX,
781 'value' => 'enable_course_description',
782 'title' => 'Description Enabled',
783 'operator_type' => 'boolean_operators',
784 ),
785 array(
786 'source' => TDE_APP_PREFIX,
787 'value' => 'enable_course_benefits',
788 'title' => 'Course Benefits Enabled',
789 'operator_type' => 'boolean_operators',
790 ),
791 array(
792 'source' => TDE_APP_PREFIX,
793 'value' => 'enable_course_requirements',
794 'title' => 'Requirements Enabled',
795 'operator_type' => 'boolean_operators',
796 ),
797 array(
798 'source' => TDE_APP_PREFIX,
799 'value' => 'enable_course_target_audience',
800 'title' => 'Target Audience Enabled',
801 'operator_type' => 'boolean_operators',
802 ),
803 array(
804 'source' => TDE_APP_PREFIX,
805 'value' => 'enable_course_announcements',
806 'title' => 'Announcements Enabled',
807 'operator_type' => 'boolean_operators',
808 ),
809 array(
810 'source' => TDE_APP_PREFIX,
811 'value' => 'enable_course_review',
812 'title' => 'Review Enabled',
813 'operator_type' => 'boolean_operators',
814 )
815
816 )
817 ),
818 );
819
820 return $conditions;
821 }
822
823 public static function element_visibility_condition_check($default_value, $condition, $options)
824 {
825 $source = $condition['source'];
826 $field = $condition['field']['value'];
827 $operator = $condition['operator']['value'];
828 $operand = $condition['operand']['value'];
829 $field_group = isset($condition['field']['group']) ? $condition['field']['group'] : '';
830
831 if (isset($options['TUTOR_LMS-subscriptions'])) {
832 $subscription = (array) $options['TUTOR_LMS-subscriptions'];
833 $fieldValue = self::get_subscription_field_value($subscription, $field, $options);
834 } else if (isset($options['membership-plan'], $options['itemType']) && $options['itemType'] === 'membership-plan') {
835 $membership_plan = (array) $options['membership-plan'];
836 $fieldValue = self::get_membership_plan_field_value($membership_plan, $field);
837 } else if (isset($options['membership-feature'], $options['itemType']) && $options['itemType'] === 'membership-feature') {
838 $membership_feature = (array) $options['membership-feature'];
839 $fieldValue = self::get_membership_feature_field_value($membership_feature, $field);
840 } else {
841 if ($field_group === 'lms-settings') {
842 $fieldValue = self::get_lms_settings_field_value($field);
843 } else {
844 $fieldValue = self::get_course_field_value($field, $options);
845 }
846 }
847
848 if ($source === TDE_APP_PREFIX) {
849 switch ($operator) {
850 case 'true': {
851 return (bool) $fieldValue;
852 }
853 case 'false': {
854 return ! $fieldValue;
855 }
856 case 'is_equal': {
857 return $fieldValue == $operand;
858 }
859 case 'not_equal': {
860 return $fieldValue != $operand;
861 }
862 case 'less_than': {
863 return $fieldValue < $operand;
864 }
865 case 'greater_than': {
866 return $fieldValue > $operand;
867 }
868 case 'less_than_or_equal': {
869 return $fieldValue <= $operand;
870 }
871 case 'greater_than_or_equal': {
872 return $fieldValue >= $operand;
873 }
874 case 'user_state-is_equal': {
875 return in_array($operand, $fieldValue);
876 }
877 case 'user_state-not_equal': {
878 return !in_array($operand, $fieldValue);
879 }
880 }
881 }
882
883 return $default_value;
884 }
885
886 private static function get_membership_feature_field_value($membership_feature, $field)
887 {
888 $yes_icon_types = array(
889 'tick',
890 'tick_circle',
891 'tick_circle_fill',
892 'plus_square',
893 'plus_circle',
894 'plus_circle_fill',
895 'plus_square_fill',
896 );
897
898 $no_icon_types = array(
899 'cross',
900 'cross_circle',
901 'cross_circle_fill',
902 'minus_square',
903 'minus_circle',
904 'minus_circle_fill',
905 'minus_square_fill',
906 );
907
908 switch ($field) {
909 case 'icon_type': {
910 if (in_array($membership_feature['icon'], $yes_icon_types)) {
911 return 'yes';
912 } elseif (in_array($membership_feature['icon'], $no_icon_types)) {
913 return 'no';
914 }
915
916 return null;
917 }
918 }
919
920 return isset($membership_feature[$field]) ? $membership_feature[$field] : null;
921 }
922
923 private static function get_subscription_field_value($subscription, $field, $options)
924 {
925 switch ($field) {
926 case 'sale_price': {
927 return $subscription['sale_price'] !== '0.00';
928 }
929 }
930 return isset($subscription[$field]) ? $subscription[$field] : null;
931 }
932
933 private static function get_membership_plan_field_value($membership_plan, $field)
934 {
935 switch ($field) {
936 case 'enrollment_fee':
937 case 'sale_price': {
938 return $membership_plan[$field] !== '0.00';
939 }
940
941 case 'is_featured':
942 case 'provide_certificate': {
943 return $membership_plan[$field] == '1';
944 }
945
946 case 'trial_value':
947 case 'trial_fee': {
948 if (isset($membership_plan[$field])) {
949 return floatval($membership_plan[$field]);
950 }
951
952 return false;
953 }
954
955 case 'trial_interval': {
956 return $membership_plan['trial_interval'] ?? false;
957 }
958
959 default:
960 return isset($membership_plan[$field]) ? $membership_plan[$field] : null;
961 }
962 }
963
964 private static function get_course_field_value($field, $options)
965 {
966 $course_id = isset($options['post']) ? $options['post']->ID : get_the_ID();
967 switch ($field) {
968 case 'is_paid': {
969 $is_paid_course = tutor_utils()->is_course_purchasable($course_id);
970 return $is_paid_course;
971 }
972 case 'on_sale': {
973 $course_price = tutor_utils()->get_raw_course_price($course_id);
974 return $course_price->sale_price != 0;
975 }
976 case 'purchase_options': {
977 $selling_option = Course::get_selling_option($course_id);
978 return $selling_option;
979 }
980 case 'average_rating': {
981 $average_rating = self::get_course_meta($field, $course_id, $options);
982 $average_rating = floatval(str_replace(',', '', $average_rating));
983 return $average_rating;
984 }
985 case 'total_ratings':
986 case 'enroll_count':
987 case 'resource_count':
988 case 'lesson_count':
989 case 'quiz_count':
990 case 'assignments_count': {
991 $value = self::get_course_meta($field, $course_id, $options);
992 return $value;
993 }
994 case 'student_state': {
995 $state = array();
996 $entry_box_logic = tutor_entry_box_buttons($course_id);
997 if (is_user_logged_in()) {
998 $state[] = 'logged_in';
999 if (tutor_utils()->is_wishlisted($course_id)) {
1000 $state[] = 'wishlisted';
1001 }
1002
1003 if ($entry_box_logic->show_view_cart_btn) {
1004 $state[] = 'added_in_cart';
1005 } elseif (tutor_utils()->is_enrolled($course_id)) {
1006 $state[] = 'enrolled';
1007 }
1008
1009 if ($entry_box_logic->show_continue_learning_btn) {
1010 $state[] = 'learner';
1011 } elseif (tutor_utils()->is_completed_course($course_id)) {
1012 $state[] = 'completed';
1013 }
1014
1015 if ($entry_box_logic->show_retake_course_btn) {
1016 $state[] = 'can_retake';
1017 }
1018 }
1019 return $state;
1020 }
1021 case 'is_review_enabled': {
1022 $review_enabled = (bool) get_tutor_option('enable_course_review');
1023 return $review_enabled;
1024 }
1025 case 'is_qna_enabled': {
1026 $enable_q_and_a_on_course = (bool) get_tutor_option('enable_q_and_a_on_course');
1027 $disable_qa_for_this_course = get_post_meta($course_id, '_tutor_enable_qa', true) != 'yes' ?? false;
1028 return ! (! $enable_q_and_a_on_course || $disable_qa_for_this_course);
1029 }
1030 case 'is_certificate_enabled': {
1031 $addon_config = tutor_utils()->get_addon_config('tutor-pro/addons/tutor-certificate/tutor-certificate.php');
1032 $is_enabled = (bool) tutor_utils()->avalue_dot('is_enable', $addon_config);
1033 if ($is_enabled) {
1034 $has_course_certificate_template = (new Certificate(true))->has_course_certificate_template($course_id);
1035 return $has_course_certificate_template;
1036 }
1037 return false;
1038 }
1039
1040 case 'difficulty_level': {
1041 return get_post_meta($course_id, '_tutor_course_level', true);
1042 }
1043 }
1044 }
1045
1046 private static function get_lms_settings_field_value($field)
1047 {
1048 switch ($field) {
1049 case 'is_membership_only_mode_enabled': {
1050 $is_membership_only_mode_enabled = apply_filters('tutor_membership_only_mode', false);
1051 return $is_membership_only_mode_enabled;
1052 }
1053
1054 case 'enable_spotlight_mode':
1055 case 'display_course_instructors':
1056 case 'enable_wishlist':
1057 case 'enable_q_and_a_on_course':
1058 case 'enable_course_author':
1059 case 'enable_course_level':
1060 case 'enable_course_share':
1061 case 'enable_course_duration':
1062 case 'enable_course_total_enrolled':
1063 case 'enable_course_update_date':
1064 case 'enable_course_progress_bar':
1065 case 'enable_course_material':
1066 case 'enable_course_about':
1067 case 'enable_course_description':
1068 case 'enable_course_benefits':
1069 case 'enable_course_requirements':
1070 case 'enable_course_target_audience':
1071 case 'enable_course_announcements':
1072 case 'enable_course_review': {
1073 $is_enabled = tutor_utils()->get_option($field, false);
1074 return $is_enabled;
1075 }
1076
1077 default: {
1078 return false;
1079 }
1080 }
1081 }
1082 }