PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.9.6
Tutor LMS – eLearning and online course solution v3.9.6
4.0.0 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 5 months ago Ajax.php 5 months ago Backend.php 1 year ago Editor.php 1 year ago Frontend.php 1 year ago Helper.php 9 months ago Hooks.php 5 months ago Iframe.php 1 year ago Pages.php 9 months ago VisibilityCondition.php 5 months ago
VisibilityCondition.php
990 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 ),
333 );
334
335 return $conditions;
336 }
337
338 private static function get_membership_features_type_conditions($conditions)
339 {
340 if (!isset($conditions['post']['fields'])) {
341 $conditions['post']['fields'] = array();
342 }
343 $conditions['post'] = array(
344 'title' => 'Feature',
345 'fields' => array_merge(
346 $conditions['post']['fields'],
347 array(
348 array(
349 'source' => TDE_APP_PREFIX,
350 'value' => 'icon_type',
351 'title' => 'Icon',
352 'operator_type' => 'dropdown_operators',
353 'operand_type' => array_merge(
354 DROIP_PLUGIN_SETTINGS['SELECT'],
355 array(
356 'options' => array(
357 array(
358 'value' => 'yes',
359 'title' => 'Check',
360 ),
361 array(
362 'value' => 'no',
363 'title' => 'Times',
364 ),
365 ),
366 ),
367 ),
368 ),
369 ),
370 ),
371 );
372
373 return $conditions;
374 }
375
376 private static function get_course_type_conditions($conditions)
377 {
378 if (!isset($conditions['post']['fields'])) {
379 $conditions['post']['fields'] = array();
380 }
381 $conditions['post'] = array(
382 'title' => 'Course',
383 'fields' => array_merge(
384 $conditions['post']['fields'],
385 array(
386 array(
387 'source' => TDE_APP_PREFIX,
388 'value' => 'is_paid',
389 'title' => 'Paid',
390 'operator_type' => 'boolean_operators',
391 ),
392 array(
393 'source' => TDE_APP_PREFIX,
394 'value' => 'on_sale',
395 'title' => 'On Sale',
396 'operator_type' => 'boolean_operators',
397 ),
398 array(
399 'source' => TDE_APP_PREFIX,
400 'value' => 'purchase_options',
401 'title' => 'Purchase Options',
402 'operator_type' => 'dropdown_operators',
403 'operand_type' => array_merge(
404 DROIP_PLUGIN_SETTINGS['SELECT'],
405 array(
406 'options' => array(
407 array(
408 'value' => Course::SELLING_OPTION_ONE_TIME,
409 'title' => 'One Time',
410 ),
411 array(
412 'value' => Course::SELLING_OPTION_SUBSCRIPTION,
413 'title' => 'Subscription',
414 ),
415
416 array(
417 'value' => Course::SELLING_OPTION_BOTH,
418 'title' => 'Subscription & One-Time',
419 ),
420
421 array(
422 'value' => Course::SELLING_OPTION_MEMBERSHIP,
423 'title' => 'Membership',
424 ),
425 array(
426 'value' => Course::SELLING_OPTION_ALL,
427 'title' => 'All',
428 ),
429 ),
430 )
431 ),
432 ),
433 array(
434 'source' => TDE_APP_PREFIX,
435 'value' => 'average_rating',
436 'title' => 'Rating (Avg.)',
437 'operator_type' => 'numeric_operators',
438 'operand_type' => array_merge(
439 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
440 array(
441 'placeholder' => 'Rating',
442 )
443 ),
444 ),
445 array(
446 'source' => TDE_APP_PREFIX,
447 'value' => 'total_ratings',
448 'title' => 'Total Ratings',
449 'operator_type' => 'numeric_operators',
450 'operand_type' => array_merge(
451 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
452 array(
453 'placeholder' => 'Rating count',
454 )
455 ),
456 ),
457 array(
458 'source' => TDE_APP_PREFIX,
459 'value' => 'enroll_count',
460 'title' => 'Enrollment Count',
461 'operator_type' => 'numeric_operators',
462 'operand_type' => array_merge(
463 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
464 array(
465 'placeholder' => 'Enroll Count',
466 )
467 ),
468 ),
469 array(
470 'source' => TDE_APP_PREFIX,
471 'value' => 'student_state',
472 'title' => 'Student status',
473 'operator_type' => array(
474 array(
475 'title' => '= Equals',
476 'value' => 'user_state-is_equal',
477 ),
478 array(
479 'title' => '≠ Does not equal',
480 'value' => 'user_state-not_equal',
481 ),
482 ),
483 'operand_type' => array_merge(
484 DROIP_PLUGIN_SETTINGS['SELECT'],
485 array(
486 'options' => array(
487 array(
488 'value' => 'logged_in',
489 'title' => 'Logged in',
490 ),
491 array(
492 'value' => 'wishlisted',
493 'title' => 'Wishlisted',
494 ),
495 array(
496 'value' => 'added_in_cart',
497 'title' => 'Added in Cart',
498 ),
499 array(
500 'value' => 'enrolled',
501 'title' => 'Enrolled',
502 ),
503 array(
504 'value' => 'learner',
505 'title' => 'Learner',
506 ),
507 array(
508 'value' => 'can_retake',
509 'title' => 'Can Retake',
510 ),
511 array(
512 'value' => 'completed',
513 'title' => 'Completed',
514 ),
515 ),
516 )
517 ),
518 ),
519 // [
520 // 'source' => TDE_APP_PREFIX,
521 // 'value' => 'user_authored',
522 // 'title' => 'User authored',
523 // 'operator_type' => 'dropdown_operators',
524 // 'operand_type' => array_merge(
525 // DROIP_PLUGIN_SETTINGS['SELECT'],
526 // [
527 // 'options' => [
528 // ['value' => 'no_review', 'title' => 'No Review'],
529 // ['value' => 'current_review', 'title' => 'Current Review'],
530 // ['value' => 'no_question', 'title' => 'No Question'],
531 // ['value' => 'current_question', 'title' => 'Current Question'],
532 // ],
533 // ]
534 // ),
535 // ],
536 array(
537 'source' => TDE_APP_PREFIX,
538 'value' => 'resource_count',
539 'title' => 'Resources',
540 'operator_type' => 'numeric_operators',
541 'operand_type' => array_merge(
542 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
543 array(
544 'placeholder' => 'Resource Count',
545 )
546 ),
547 ),
548 array(
549 'source' => TDE_APP_PREFIX,
550 'value' => 'lesson_count',
551 'title' => 'Lessons',
552 'operator_type' => 'numeric_operators',
553 'operand_type' => array_merge(
554 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
555 array(
556 'placeholder' => 'Lesson Count',
557 )
558 ),
559 ),
560 array(
561 'source' => TDE_APP_PREFIX,
562 'value' => 'quiz_count',
563 'title' => 'Quizzes',
564 'operator_type' => 'numeric_operators',
565 'operand_type' => array_merge(
566 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
567 array(
568 'placeholder' => 'Quiz Count',
569 )
570 ),
571 ),
572 array(
573 'source' => TDE_APP_PREFIX,
574 'value' => 'assignments_count',
575 'title' => 'Assignments',
576 'operator_type' => 'numeric_operators',
577 'operand_type' => array_merge(
578 DROIP_PLUGIN_SETTINGS['INPUT_NUMBER'],
579 array(
580 'placeholder' => 'Assignment Count',
581 )
582 ),
583 ),
584 array(
585 'source' => TDE_APP_PREFIX,
586 'value' => 'is_review_enabled',
587 'title' => 'Review Enabled',
588 'operator_type' => 'boolean_operators',
589 ),
590 array(
591 'source' => TDE_APP_PREFIX,
592 'value' => 'is_qna_enabled',
593 'title' => 'QnA Enabled',
594 'operator_type' => 'boolean_operators',
595 ),
596 array(
597 'source' => TDE_APP_PREFIX,
598 'value' => 'is_certificate_enabled',
599 'title' => 'Certificate Enabled',
600 'operator_type' => 'boolean_operators',
601 ),
602 )
603 ),
604 );
605 return $conditions;
606 }
607
608 private static function get_lms_setting_type_conditions($conditions)
609 {
610 if (!isset($conditions['lms-settings']['fields'])) {
611 $conditions['lms-settings']['fields'] = array();
612 }
613
614 $conditions['lms-settings'] = array(
615 'title' => 'LMS Settings',
616 'fields' => array_merge(
617 $conditions['lms-settings']['fields'],
618 array(
619 array(
620 'source' => TDE_APP_PREFIX,
621 'value' => 'is_membership_only_mode_enabled',
622 'title' => 'Membership-Only Mode',
623 'operator_type' => 'boolean_operators',
624 ),
625 array(
626 'source' => TDE_APP_PREFIX,
627 'value' => 'enable_spotlight_mode',
628 'title' => 'Spotlight Mode Enabled',
629 'operator_type' => 'boolean_operators',
630 ),
631
632 array(
633 'source' => TDE_APP_PREFIX,
634 'value' => 'display_course_instructors',
635 'title' => 'Instructor Info Enabled',
636 'operator_type' => 'boolean_operators',
637 ),
638 array(
639 'source' => TDE_APP_PREFIX,
640 'value' => 'enable_wishlist',
641 'title' => 'Wishlist Enabled',
642 'operator_type' => 'boolean_operators',
643 ),
644 array(
645 'source' => TDE_APP_PREFIX,
646 'value' => 'enable_q_and_a_on_course',
647 'title' => 'Q&A Enabled',
648 'operator_type' => 'boolean_operators',
649 ),
650 array(
651 'source' => TDE_APP_PREFIX,
652 'value' => 'enable_course_author',
653 'title' => 'Author Enabled',
654 'operator_type' => 'boolean_operators',
655 ),
656 array(
657 'source' => TDE_APP_PREFIX,
658 'value' => 'enable_course_level',
659 'title' => 'Level Enabled',
660 'operator_type' => 'boolean_operators',
661 ),
662 array(
663 'source' => TDE_APP_PREFIX,
664 'value' => 'enable_course_share',
665 'title' => 'Social Share Enabled',
666 'operator_type' => 'boolean_operators',
667 ),
668 array(
669 'source' => TDE_APP_PREFIX,
670 'value' => 'enable_course_duration',
671 'title' => 'Duration Enabled',
672 'operator_type' => 'boolean_operators',
673 ),
674 array(
675 'source' => TDE_APP_PREFIX,
676 'value' => 'enable_course_total_enrolled',
677 'title' => 'Total Enrolled Enabled',
678 'operator_type' => 'boolean_operators',
679 ),
680 array(
681 'source' => TDE_APP_PREFIX,
682 'value' => 'enable_course_update_date',
683 'title' => 'Update Date Enabled',
684 'operator_type' => 'boolean_operators',
685 ),
686 array(
687 'source' => TDE_APP_PREFIX,
688 'value' => 'enable_course_progress_bar',
689 'title' => 'Progress Bar Enabled',
690 'operator_type' => 'boolean_operators',
691 ),
692 array(
693 'source' => TDE_APP_PREFIX,
694 'value' => 'enable_course_material',
695 'title' => 'Show Material Enabled',
696 'operator_type' => 'boolean_operators',
697 ),
698 array(
699 'source' => TDE_APP_PREFIX,
700 'value' => 'enable_course_about',
701 'title' => 'About Enabled',
702 'operator_type' => 'boolean_operators',
703 ),
704 array(
705 'source' => TDE_APP_PREFIX,
706 'value' => 'enable_course_description',
707 'title' => 'Description Enabled',
708 'operator_type' => 'boolean_operators',
709 ),
710 array(
711 'source' => TDE_APP_PREFIX,
712 'value' => 'enable_course_benefits',
713 'title' => 'Course Benefits Enabled',
714 'operator_type' => 'boolean_operators',
715 ),
716 array(
717 'source' => TDE_APP_PREFIX,
718 'value' => 'enable_course_requirements',
719 'title' => 'Requirements Enabled',
720 'operator_type' => 'boolean_operators',
721 ),
722 array(
723 'source' => TDE_APP_PREFIX,
724 'value' => 'enable_course_target_audience',
725 'title' => 'Target Audience Enabled',
726 'operator_type' => 'boolean_operators',
727 ),
728 array(
729 'source' => TDE_APP_PREFIX,
730 'value' => 'enable_course_announcements',
731 'title' => 'Announcements Enabled',
732 'operator_type' => 'boolean_operators',
733 ),
734 array(
735 'source' => TDE_APP_PREFIX,
736 'value' => 'enable_course_review',
737 'title' => 'Review Enabled',
738 'operator_type' => 'boolean_operators',
739 )
740
741 )
742 ),
743 );
744
745 return $conditions;
746 }
747
748 public static function element_visibility_condition_check($default_value, $condition, $options)
749 {
750 $source = $condition['source'];
751 $field = $condition['field']['value'];
752 $operator = $condition['operator']['value'];
753 $operand = $condition['operand']['value'];
754 $field_group = isset($condition['field']['group']) ? $condition['field']['group'] : '';
755
756 if (isset($options['TUTOR_LMS-subscriptions'])) {
757 $subscription = (array) $options['TUTOR_LMS-subscriptions'];
758 $fieldValue = self::get_subscription_field_value($subscription, $field, $options);
759 } else if (isset($options['membership-plan'], $options['itemType']) && $options['itemType'] === 'membership-plan') {
760 $membership_plan = (array) $options['membership-plan'];
761 $fieldValue = self::get_membership_plan_field_value($membership_plan, $field);
762 } else if (isset($options['membership-feature'], $options['itemType']) && $options['itemType'] === 'membership-feature') {
763 $membership_feature = (array) $options['membership-feature'];
764 $fieldValue = self::get_membership_feature_field_value($membership_feature, $field);
765 } else {
766 if ($field_group === 'lms-settings') {
767 $fieldValue = self::get_lms_settings_field_value($field);
768 } else {
769 $fieldValue = self::get_course_field_value($field, $options);
770 }
771 }
772
773 if ($source === TDE_APP_PREFIX) {
774 switch ($operator) {
775 case 'true': {
776 return (bool) $fieldValue;
777 }
778 case 'false': {
779 return ! $fieldValue;
780 }
781 case 'is_equal': {
782 return $fieldValue == $operand;
783 }
784 case 'not_equal': {
785 return $fieldValue != $operand;
786 }
787 case 'less_than': {
788 return $fieldValue < $operand;
789 }
790 case 'greater_than': {
791 return $fieldValue > $operand;
792 }
793 case 'less_than_or_equal': {
794 return $fieldValue <= $operand;
795 }
796 case 'greater_than_or_equal': {
797 return $fieldValue >= $operand;
798 }
799 case 'user_state-is_equal': {
800 return in_array($operand, $fieldValue);
801 }
802 case 'user_state-not_equal': {
803 return !in_array($operand, $fieldValue);
804 }
805 }
806 }
807
808 return $default_value;
809 }
810
811 private static function get_membership_feature_field_value($membership_feature, $field)
812 {
813 $yes_icon_types = array(
814 'tick',
815 'tick_circle',
816 'tick_circle_fill',
817 'plus_square',
818 'plus_circle',
819 'plus_circle_fill',
820 'plus_square_fill',
821 );
822
823 $no_icon_types = array(
824 'cross',
825 'cross_circle',
826 'cross_circle_fill',
827 'minus_square',
828 'minus_circle',
829 'minus_circle_fill',
830 'minus_square_fill',
831 );
832
833 switch ($field) {
834 case 'icon_type': {
835 if (in_array($membership_feature['icon'], $yes_icon_types)) {
836 return 'yes';
837 } elseif (in_array($membership_feature['icon'], $no_icon_types)) {
838 return 'no';
839 }
840
841 return null;
842 }
843 }
844
845 return isset($membership_feature[$field]) ? $membership_feature[$field] : null;
846 }
847
848 private static function get_subscription_field_value($subscription, $field, $options)
849 {
850 switch ($field) {
851 case 'sale_price': {
852 return $subscription['sale_price'] !== '0.00';
853 }
854 }
855 return isset($subscription[$field]) ? $subscription[$field] : null;
856 }
857
858 private static function get_membership_plan_field_value($membership_plan, $field)
859 {
860 switch ($field) {
861 case 'enrollment_fee':
862 case 'sale_price': {
863 return $membership_plan[$field] !== '0.00';
864 }
865
866 case 'is_featured':
867 case 'provide_certificate': {
868 return $membership_plan[$field] == '1';
869 }
870
871 default:
872 return isset($membership_plan[$field]) ? $membership_plan[$field] : null;
873 }
874 }
875
876 private static function get_course_field_value($field, $options)
877 {
878 $course_id = isset($options['post']) ? $options['post']->ID : get_the_ID();
879 switch ($field) {
880 case 'is_paid': {
881 $is_paid_course = tutor_utils()->is_course_purchasable($course_id);
882 return $is_paid_course;
883 }
884 case 'on_sale': {
885 $course_price = tutor_utils()->get_raw_course_price($course_id);
886 return $course_price->sale_price != 0;
887 }
888 case 'purchase_options': {
889 $selling_option = Course::get_selling_option($course_id);
890 return $selling_option;
891 }
892 case 'average_rating': {
893 $average_rating = self::get_course_meta($field, $course_id, $options);
894 $average_rating = floatval(str_replace(',', '', $average_rating));
895 return $average_rating;
896 }
897 case 'total_ratings':
898 case 'enroll_count':
899 case 'resource_count':
900 case 'lesson_count':
901 case 'quiz_count':
902 case 'assignments_count': {
903 $value = self::get_course_meta($field, $course_id, $options);
904 return $value;
905 }
906 case 'student_state': {
907 $state = array();
908 $entry_box_logic = tutor_entry_box_buttons($course_id);
909 if (is_user_logged_in()) {
910 $state[] = 'logged_in';
911 if (tutor_utils()->is_wishlisted($course_id)) {
912 $state[] = 'wishlisted';
913 }
914
915 if ($entry_box_logic->show_view_cart_btn) {
916 $state[] = 'added_in_cart';
917 } elseif (tutor_utils()->is_enrolled($course_id)) {
918 $state[] = 'enrolled';
919 }
920
921 if ($entry_box_logic->show_continue_learning_btn) {
922 $state[] = 'learner';
923 } elseif (tutor_utils()->is_completed_course($course_id)) {
924 $state[] = 'completed';
925 }
926
927 if ($entry_box_logic->show_retake_course_btn) {
928 $state[] = 'can_retake';
929 }
930 }
931 return $state;
932 }
933 case 'is_review_enabled': {
934 $review_enabled = (bool) get_tutor_option('enable_course_review');
935 return $review_enabled;
936 }
937 case 'is_qna_enabled': {
938 $enable_q_and_a_on_course = (bool) get_tutor_option('enable_q_and_a_on_course');
939 $disable_qa_for_this_course = get_post_meta($course_id, '_tutor_enable_qa', true) != 'yes' ?? false;
940 return ! (! $enable_q_and_a_on_course || $disable_qa_for_this_course);
941 }
942 case 'is_certificate_enabled': {
943 $addon_config = tutor_utils()->get_addon_config('tutor-pro/addons/tutor-certificate/tutor-certificate.php');
944 $is_enabled = (bool) tutor_utils()->avalue_dot('is_enable', $addon_config);
945 if ($is_enabled) {
946 $has_course_certificate_template = (new Certificate(true))->has_course_certificate_template($course_id);
947 return $has_course_certificate_template;
948 }
949 return false;
950 }
951 }
952 }
953
954 private static function get_lms_settings_field_value($field)
955 {
956 switch ($field) {
957 case 'is_membership_only_mode_enabled': {
958 $is_membership_only_mode_enabled = apply_filters('tutor_membership_only_mode', false);
959 return $is_membership_only_mode_enabled;
960 }
961
962 case 'enable_spotlight_mode':
963 case 'display_course_instructors':
964 case 'enable_wishlist':
965 case 'enable_q_and_a_on_course':
966 case 'enable_course_author':
967 case 'enable_course_level':
968 case 'enable_course_share':
969 case 'enable_course_duration':
970 case 'enable_course_total_enrolled':
971 case 'enable_course_update_date':
972 case 'enable_course_progress_bar':
973 case 'enable_course_material':
974 case 'enable_course_about':
975 case 'enable_course_description':
976 case 'enable_course_benefits':
977 case 'enable_course_requirements':
978 case 'enable_course_target_audience':
979 case 'enable_course_announcements':
980 case 'enable_course_review': {
981 $is_enabled = tutor_utils()->get_option($field, false);
982 return $is_enabled;
983 }
984
985 default: {
986 return false;
987 }
988 }
989 }
990 }