-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPages.php
More file actions
166 lines (142 loc) · 5.61 KB
/
Copy pathPages.php
File metadata and controls
166 lines (142 loc) · 5.61 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Pages extends Controller_Base_preDispatch
{
public function action_join()
{
if (Security::check(Arr::get($_POST, 'csrf'))) {
$this->action_process_join_form();
/** Refresh CSRF token */
Security::token(true);
}
$this->view['request'] = $this->user->getUserRequest();
/**
* Till what date and time people can join the club
* @param string $last_chance_to_join - string in Date format Y-m-d H:i
*/
// $this->view['joinTimeLeft'] = Model_Methods::countDownJoinTime("2020-09-20 23:59");
/**
* If LANG from i18n equals "en" then show english page
*/
if (LANG == 'en') {
$this->title = 'Join CodeX team';
$this->description = 'How to join CodeX';
$this->template->content = View::factory('templates/join/index-en', $this->view);
} else {
$this->title = 'Набор в команду CodeX';
$this->description = 'Как вступить в CodeX';
$this->template->content = View::factory('templates/join/index', $this->view);
}
}
public function action_All()
{
$this->title = 'Задания для вступающих в команду';
$this->template->content = View::factory('templates/task/index', $this->view);
}
public function action_whoSet()
{
$who = $this->request->param('who');
switch ($who) {
case 'design':
$this->title = 'Задание для веб-дизайнеров';
$this->description = 'Веб-дизайн: вступительные испытания';
$this->template->content = View::factory('templates/task/design', $this->view);
break;
case 'frontend':
$this->title = 'Задание на frontend-разработку';
$this->description = 'Frontend: вступительные испытания';
$this->template->content = View::factory('templates/task/frontend', $this->view);
break;
case 'backend':
$this->title = 'Задание на backend-разработку';
$this->description = 'Backend: вступительные испытания';
$this->template->content = View::factory('templates/task/backend', $this->view);
break;
default:
throw new HTTP_Exception_404();
break;
}
}
public function action_process_join_form()
{
$this->auto_render = false;
if (!$this->request->is_ajax()) {
$this->sendAjaxResponse(array(
'message' => 'Request is not ajax.',
'success' => 0
));
return;
}
if (!Security::check(Arr::get($_POST, 'csrf'))) {
$this->sendAjaxResponse(array(
'message' => 'CSRF token is bad. Please reload a page and try again.',
'success' => 0
));
return;
}
if ($this->user->getUserRequest()) {
$this->sendAjaxResponse(array(
'message' => 'You have already send a request.',
'success' => 0
));
return;
}
$name = HTML::chars(Arr::get($_POST, 'name', null));
$email = HTML::chars(Arr::get($_POST, 'email', null));
$skills = HTML::chars(Arr::get($_POST, 'skills'));
$wishes = HTML::chars(Arr::get($_POST, 'wishes'));
$fields = array(
'skills' => $skills,
'wishes' => $wishes,
'email' => $email,
'name' => $name
);
if (!$fields['email'] && !$this->user->id) {
$this->sendAjaxResponse(array(
'message' => 'Enter your contact information so that we can reach you.',
'success' => 0
));
return;
}
if ($this->user->id) {
$fields['uid'] = $this->user->id;
}
$this->view['success'] = $this->methods->saveJoinRequest($fields);
if ($this->view['success']) {
/**
* If user is registered then show link to the profile
* otherwise show email and mailto link
*/
if ($this->user->id) {
$name = $this->user->name;
$id = $this->user->id;
$host = Arr::get($_SERVER, 'HTTP_HOST');
$link = "{$host}/user/{$id}";
$footer = "👤 [$link]($link)";
} else {
$footer = "✉️ {$email}";
}
$text = "🦄 {$name} wants to join the team\n" .
"\n" .
"🛠 *Skills*\n" .
"{$skills}\n" .
"\n" .
"💫 *Wishes*\n" .
"{$wishes}\n" .
"\n" .
"{$footer}";
$parse_mode = 'Markdown';
$disable_web_page_preview = true;
Model_Methods::sendBotNotification($text, $parse_mode, $disable_web_page_preview);
$this->sendAjaxResponse(array(
'message' => 'Your request has been saved successfully 😎',
'success' => 1
));
return;
}
$this->sendAjaxResponse(array(
'message' => 'Something went wrong. Please try again later',
'success' => 0
));
return;
}
}