-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-course.php
executable file
·107 lines (97 loc) · 2.82 KB
/
single-course.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* The Template for displaying all single posts
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package WordPress
*
* @subpackage Timber
*
* @since Timber 0.1
*/
global $wpdb;
$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
$tableName = $wpdb->prefix."rkg_course_meta";
$context['meta'] = $wpdb->get_row(
"SELECT id, category, "
."organiser, location, terms, price, limitation, locked, registered, starttime, "
."endtime, deadline FROM "
.$tableName
." WHERE id="
.$post->ID
);
$context['organiser'] = new Timber\User($context['meta']->organiser);
// Drugi termini
$context['courseTerms'] = $wpdb->get_results(
"SELECT orig.id AS id, category, "
."starttime, endtime, deadline FROM "
.$tableName . " orig"
." LEFT JOIN wp_posts wps ON orig.id = wps.id"
." WHERE deadline > "
.date("'Y-m-d'")
." AND category = "
.$context['meta']->category
." AND orig.id != " . $post->ID
." AND post_type = 'course'"
." AND post_status = 'publish'"
." ORDER BY deadline"
);
foreach ($context['courseTerms'] as $key => $value) {
$context['courseTerms'][$key]->link = get_permalink($value->id);
}
$tableName = $wpdb->prefix."rkg_course_template";
$context['metaTemplate'] = $wpdb->get_row(
"SELECT * FROM "
.$tableName
." WHERE id="
.$context['meta']->category
);
$context['metaTemplate']->hub3_price =
str_replace(",", "", $context['metaTemplate']->payment_price);
$context['metaTemplate']->hub3_price =
str_pad($context['metaTemplate']->hub3_price, 15, "0", STR_PAD_LEFT);
$tableName = $wpdb->prefix."rkg_course_signup";
$students = $wpdb->get_results(
"SELECT user_id, payed FROM "
.$tableName
." WHERE course_id="
.$post->ID
." ORDER BY created"
);
foreach ($students as $value) {
$student = new Timber\User($value->user_id);
$context['students'][] = $student;
if ($student->id === $context['user']->id) {
$context['user']->payed = !!$value->payed;
}
}
if ($context['user']) {
$tableName = $wpdb->prefix."rkg_course_medical_meta";
$context['helthsurvey'] = $wpdb->get_row(
"SELECT * FROM "
.$tableName
." WHERE post_id="
.$post->ID
." AND user_id="
.$context['user']->id
." ORDER BY created"
);
$tableName = $wpdb->prefix."rkg_course_liability_meta";
$context['responsibilitysurvey'] = $wpdb->get_row(
"SELECT * FROM "
.$tableName
." WHERE post_id="
.$post->ID
." AND user_id="
.$context['user']->id
." ORDER BY created"
);
}
if (post_password_required($post->ID)) {
Timber::render('single-password.twig', $context);
} else {
Timber::render('single-course.twig', $context);
}