Passed
Push — 1.11.x ( bce6cd...c146d9 )
by Angel Fernando Quiroz
12:25
created

plugin/sepe/src/sepe.lib.php (3 issues)

1
<?php
2
3
/**
4
 * Functions.
5
 *
6
 * @package chamilo.plugin.sepe
7
 */
8
$tableSepeCenter = Database::get_main_table(SepePlugin::TABLE_SEPE_CENTER);
9
$tableSepeActions = Database::get_main_table(SepePlugin::TABLE_SEPE_ACTIONS);
10
$tableSepeSpecialty = Database::get_main_table(SepePlugin::TABLE_SEPE_SPECIALTY);
11
$tableSepeSpecialtyClassroom = Database::get_main_table(SepePlugin::TABLE_SEPE_SPECIALTY_CLASSROOM);
12
$tableSepeSpecialtyTutors = Database::get_main_table(SepePlugin::TABLE_SEPE_SPECIALTY_TUTORS);
13
$tableSepeTutors = Database::get_main_table(SepePlugin::TABLE_SEPE_TUTORS);
14
$tableSepeParticipants = Database::get_main_table(SepePlugin::TABLE_SEPE_PARTICIPANTS);
15
$tableSepeParticipantsSpecialty = Database::get_main_table(SepePlugin::TABLE_SEPE_PARTICIPANTS_SPECIALTY);
16
$tableSepeParticipantsSpecialtyTutorials = Database::get_main_table(SepePlugin::TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS);
17
$tableSepeCourseActions = Database::get_main_table(SepePlugin::TABLE_SEPE_COURSE_ACTIONS);
18
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
19
$tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
20
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
21
$tableCenters = Database::get_main_table(SepePlugin::TABLE_SEPE_CENTERS);
22
$tableTutorCompany = Database::get_main_table(SepePlugin::TABLE_SEPE_TUTORS_COMPANY);
23
$tableSepeCourseActions = Database::get_main_table(SepePlugin::TABLE_SEPE_COURSE_ACTIONS);
24
$tableSepeLogParticipant = Database::get_main_table(SepePlugin::TABLE_SEPE_LOG_PARTICIPANT);
25
$tableSepeLogChangeParticipant = Database::get_main_table(SepePlugin::TABLE_SEPE_LOG_MOD_PARTICIPANT);
26
27
function getInfoIdentificationData()
28
{
29
    global $tableSepeCenter;
30
    $sql = "SELECT * FROM $tableSepeCenter;";
31
    $res = Database::query($sql);
32
    if (Database::num_rows($res) > 0) {
33
        $row = Database::fetch_assoc($res);
34
        $row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
35
        $row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
36
        $row['center_name'] = Security::remove_XSS(stripslashes($row['center_name']));
37
        $row['url'] = Security::remove_XSS(stripslashes($row['url']));
38
        $row['tracking_url'] = Security::remove_XSS(stripslashes($row['tracking_url']));
39
        $row['phone'] = Security::remove_XSS(stripslashes($row['phone']));
40
        $row['mail'] = Security::remove_XSS(stripslashes($row['mail']));
41
    } else {
42
        $row = false;
43
    }
44
45
    return $row;
46
}
47
48
function checkIdentificationData()
49
{
50
    global $tableSepeCenter;
51
    $sql = "SELECT 1 FROM $tableSepeCenter;";
52
    $result = Database::query($sql);
53
    if (Database::affected_rows($result) > 0) {
54
        return true;
55
    }
56
57
    return false;
58
}
59
60
function getActionId($courseId)
61
{
62
    global $tableSepeCourseActions;
63
    $courseId = (int) $courseId;
64
    $sql = "SELECT action_id FROM $tableSepeCourseActions WHERE course_id = $courseId";
65
    $rs = Database::query($sql);
66
    $aux = Database::fetch_assoc($rs);
67
68
    return $aux['action_id'];
69
}
70
71
function getCourse($actionId)
72
{
73
    global $tableSepeCourseActions;
74
    $actionId = (int) $actionId;
75
    $sql = "SELECT course_id FROM $tableSepeCourseActions WHERE action_id = $actionId";
76
    $rs = Database::query($sql);
77
    $aux = Database::fetch_assoc($rs);
78
79
    return $aux['course_id'];
80
}
81
function getCourseCode($actionId)
82
{
83
    global $tableCourse;
84
    $actionId = (int) $actionId;
85
    $courseId = getCourse($actionId);
86
    $sql = "SELECT code FROM $tableCourse WHERE id = $courseId";
87
    $rs = Database::query($sql);
88
    $aux = Database::fetch_assoc($rs);
89
90
    return $aux['code'];
91
}
92
93
function getActionInfo($id)
94
{
95
    global $tableSepeActions;
96
97
    $id = (int) $id;
98
    $sql = "SELECT * FROM $tableSepeActions WHERE id = $id";
99
    $res = Database::query($sql);
100
    $row = false;
101
    if (Database::num_rows($res) > 0) {
102
        $row['action_origin'] = Security::remove_XSS(stripslashes($row['action_origin']));
103
        $row['action_code'] = Security::remove_XSS(stripslashes($row['action_code']));
104
        $row['situation'] = Security::remove_XSS(stripslashes($row['situation']));
105
        $row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
106
        $row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
107
        $row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
108
        $row['full_itinerary_indicator'] = Security::remove_XSS(stripslashes($row['full_itinerary_indicator']));
109
        $row['financing_type'] = Security::remove_XSS(stripslashes($row['financing_type']));
110
        $row['action_name'] = Security::remove_XSS(stripslashes($row['action_name']));
111
        $row['global_info'] = Security::remove_XSS(stripslashes($row['global_info']));
112
        $row['schedule'] = Security::remove_XSS(stripslashes($row['schedule']));
113
        $row['requirements'] = Security::remove_XSS(stripslashes($row['requirements']));
114
        $row['contact_action'] = Security::remove_XSS(stripslashes($row['contact_action']));
115
        $row = Database::fetch_assoc($res);
116
    }
117
118
    return $row;
119
}
120
121
function getSpecialtActionInfo($specialtyId)
122
{
123
    global $tableSepeSpecialty;
124
    $specialtyId = (int) $specialtyId;
125
    $sql = "SELECT * FROM $tableSepeSpecialty WHERE id = $specialtyId";
126
    $res = Database::query($sql);
127
    $row = false;
128
    if (Database::num_rows($res) > 0) {
129
        $row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
130
        $row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
131
        $row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
132
        $row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
133
        $row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
134
        $row['modality_impartition'] = Security::remove_XSS(stripslashes($row['modality_impartition']));
135
        $row = Database::fetch_assoc($res);
136
    }
137
138
    return $row;
139
}
140
141
function getInfoSpecialtyClassroom($classroomId)
142
{
143
    global $tableSepeSpecialtyClassroom;
144
    global $tableCenters;
145
    $classroomId = (int) $classroomId;
146
    $sql = "SELECT a.*, center_origin, center_code
147
            FROM $tableSepeSpecialtyClassroom a
148
            LEFT JOIN $tableCenters b ON a.center_id = b.id
149
            WHERE a.id = $classroomId";
150
    $res = Database::query($sql);
151
    $row = false;
152
    if (Database::num_rows($res) > 0) {
153
        $row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
154
        $row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
155
        $row = Database::fetch_assoc($res);
156
    }
157
158
    return $row;
159
}
160
161
function getInfoSpecialtyTutorial($tutorialId)
162
{
163
    global $tableSepeParticipantsSpecialtyTutorials;
164
    $tutorialId = (int) $tutorialId;
165
    $sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials WHERE id = $tutorialId";
166
    $res = Database::query($sql);
167
    if (Database::num_rows($res) > 0) {
168
        $row = Database::fetch_assoc($res);
169
    } else {
170
        $row = false;
171
    }
172
173
    return $row;
174
}
175
176
function list_tutor($specialtyId)
177
{
178
    global $tableSepeSpecialtyTutors;
179
    $specialtyId = (int) $specialtyId;
180
    $sql = "SELECT * FROM $tableSepeSpecialtyTutors WHERE specialty_id = $specialtyId";
181
    $res = Database::query($sql);
182
    if (Database::num_rows($res) > 0) {
183
        $row = Database::fetch_assoc($res);
184
    } else {
185
        $row = false;
186
    }
187
188
    return $row;
189
}
190
191
function getCentersList()
192
{
193
    global $tableCenters;
194
    $sql = "SELECT * FROM $tableCenters;";
195
    $res = Database::query($sql);
196
    $aux = [];
197
    while ($row = Database::fetch_assoc($res)) {
198
        $aux[] = $row;
199
    }
200
201
    return $aux;
202
}
203
204
function listTutorType($condition)
205
{
206
    global $tableTutorCompany;
207
    $condition = Database::escape_string($condition);
208
    $sql = "SELECT * FROM $tableTutorCompany WHERE ".$condition." ORDER BY alias ASC, document_number ASC;";
209
    $res = Database::query($sql);
210
    $aux = [];
211
    while ($row = Database::fetch_assoc($res)) {
212
        $tmp = [];
213
        $tmp['id'] = $row['id'];
214
        if (trim($row['alias']) != '') {
215
            $tmp['alias'] = $row['alias'].' - '.$row['document_type'].' '.$row['document_number'].' '.$row['document_letter'];
216
        } else {
217
            $tmp['alias'] = $row['document_type'].' '.$row['document_number'].' '.$row['document_letter'];
218
        }
219
        $aux[] = $tmp;
220
    }
221
222
    return $aux;
223
}
224
225
function getTutorsSpecialty($specialtyId)
226
{
227
    global $tableSepeSpecialtyTutors;
228
    global $tableSepeTutors;
229
    global $tableUser;
230
    $specialtyId = (int) $specialtyId;
231
232
    $sql = "SELECT tutor_id FROM $tableSepeSpecialtyTutors WHERE specialty_id = $specialtyId";
233
    $rs = Database::query($sql);
234
    $tutorsList = [];
235
    while ($tmp = Database::fetch_assoc($rs)) {
236
        $tutorsList[] = $tmp['tutor_id'];
237
    }
238
    $sql = "SELECT a.*, b.firstname AS firstname, b.lastname AS lastname
239
            FROM $tableSepeTutors AS a
240
            LEFT JOIN $tableUser AS b ON a.platform_user_id=b.user_id;";
241
    $res = Database::query($sql);
242
    $aux = [];
243
    while ($row = Database::fetch_assoc($res)) {
244
        if (!in_array($row['id'], $tutorsList)) {
245
            $tutor = [];
246
            $tutor['id'] = $row['id'];
247
            if (trim($row['firstname']) != '' || trim($row['lastname']) != '') {
248
                $tutor['data'] = $row['firstname'].' '.$row['lastname'].' ('.$row['document_type'].' '.$row['document_number'].' '.$row['document_letter'].' )';
249
            } else {
250
                $tutor['data'] = $row['document_type'].' '.$row['document_number'].' '.$row['document_letter'];
251
            }
252
            $aux[] = $tutor;
253
        }
254
    }
255
256
    return $aux;
257
}
258
259
function getInfoSpecialtyTutor($tutorId)
260
{
261
    global $tableSepeSpecialtyTutors;
262
    global $tableSepeTutors;
263
    $tutorId = (int) $tutorId;
264
    $sql = "SELECT a.*,platform_user_id,document_type, document_number,document_letter
265
            FROM $tableSepeSpecialtyTutors a
266
            INNER JOIN $tableSepeTutors b ON a.tutor_id=b.id
267
            WHERE a.id = $tutorId;";
268
    $res = Database::query($sql);
269
    if (Database::num_rows($res) > 0) {
270
        $row['tutor_accreditation'] = Security::remove_XSS(stripslashes($row['tutor_accreditation']));
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $row seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
$row was never initialized. Although not strictly required by PHP, it is generally a good practice to add $row = array(); before regardless.
Loading history...
271
        $row['teaching_competence'] = Security::remove_XSS(stripslashes($row['teaching_competence']));
272
        $row['training_teleforming'] = Security::remove_XSS(stripslashes($row['training_teleforming']));
273
        $row = Database::fetch_assoc($res);
274
    } else {
275
        $row = false;
276
    }
277
278
    return $row;
279
}
280
281
function freeTeacherList($teacherList, $specialtyId, $platform_user_id)
282
{
283
    global $tableSepeSpecialtyTutors;
284
    global $tableSepeTutors;
285
286
    $specialtyId = (int) $specialtyId;
287
    $platform_user_id = (int) $platform_user_id;
288
289
    $sql = "SELECT tutor_id FROM $tableSepeSpecialtyTutors WHERE specialty_id = $specialtyId";
290
    $rs = Database::query($sql);
291
    if (Database::num_rows($rs) > 0) {
292
        while ($aux = Database::fetch_assoc($rs)) {
293
            $sql = "SELECT platform_user_id FROM $tableSepeTutors WHERE id='".$aux['tutor_id']."';";
294
            $res = Database::query($sql);
295
            if (Database::num_rows($res) > 0) {
296
                $tmp = Database::fetch_assoc($res);
297
                if ($tmp['platform_user_id'] != 0 && $tmp['platform_user_id'] != $platform_user_id) {
298
                    foreach ($teacherList as $key => $value) {
299
                        if ($value['id'] == $tmp['platform_user_id']) {
300
                            unset($teacherList[$key]);
301
                            break;
302
                        }
303
                    }
304
                }
305
            }
306
        }
307
    }
308
309
    return $teacherList;
310
}
311
312
function getInfoParticipantAction($participantId)
313
{
314
    global $tableSepeParticipants;
315
    $participantId = (int) $participantId;
316
    $sql = "SELECT * FROM $tableSepeParticipants WHERE id = $participantId";
317
    $res = Database::query($sql);
318
    if (Database::num_rows($res) > 0) {
319
        $row = Database::fetch_assoc($res);
320
        $result = [];
321
        $result['id'] = $row[''];
322
        $result['action_id'] = $row['action_id'];
323
        $result['company_tutor_id'] = $row['company_tutor_id'];
324
        $result['training_tutor_id'] = $row['training_tutor_id'];
325
        $result['platform_user_id'] = $row['platform_user_id'];
326
        $result['document_type'] = Security::remove_XSS(stripslashes($row['document_type']));
327
        $result['document_number'] = Security::remove_XSS(stripslashes($row['document_number']));
328
        $result['document_letter'] = Security::remove_XSS(stripslashes($row['document_letter']));
329
        $result['key_competence'] = Security::remove_XSS(stripslashes($row['key_competence']));
330
        $result['contract_id'] = Security::remove_XSS(stripslashes($row['contract_id']));
331
        $result['company_fiscal_number'] = Security::remove_XSS(stripslashes($row['company_fiscal_number']));
332
    } else {
333
        $result = false;
334
    }
335
336
    return $result;
337
}
338
339
function getParticipantId($id)
340
{
341
    global $tableSepeParticipantsSpecialty;
342
    $id = (int) $id;
343
    $sql = "SELECT participant_id FROM  $tableSepeParticipantsSpecialty WHERE id = $id";
344
    $rs = Database::query($sql);
345
    $aux = Database::fetch_assoc($rs);
346
347
    return $aux['participant_id'];
348
}
349
350
function getInfoSpecialtyParticipant($specialtyId)
351
{
352
    global $tableSepeParticipantsSpecialty;
353
    $specialtyId = (int) $specialtyId;
354
    $sql = "SELECT * FROM $tableSepeParticipantsSpecialty WHERE id = $specialtyId";
355
    $res = Database::query($sql);
356
    if (Database::num_rows($res) > 0) {
357
        $row = Database::fetch_assoc($res);
358
        $row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
359
        $row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
360
        $row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
361
        $row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
362
        $row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
363
        $row['final_result'] = Security::remove_XSS(stripslashes($row['final_result']));
364
        $row['final_qualification'] = Security::remove_XSS(stripslashes($row['final_qualification']));
365
        $row['final_score'] = Security::remove_XSS(stripslashes($row['final_score']));
366
    } else {
367
        $row = false;
368
    }
369
370
    return $row;
371
}
372
373
function specialtyList($actionId)
374
{
375
    global $tableSepeSpecialty;
376
    $actionId = (int) $actionId;
377
    $sql = "SELECT id, specialty_origin, professional_area, specialty_code
378
            FROM $tableSepeSpecialty
379
            WHERE action_id = $actionId";
380
    $res = Database::query($sql);
381
    $aux = [];
382
    while ($row = Database::fetch_assoc($res)) {
383
        $aux[] = $row;
384
    }
385
386
    return $aux;
387
}
388
389
function participantList($actionId)
390
{
391
    global $tableSepeParticipants;
392
    global $tableUser;
393
    $actionId = (int) $actionId;
394
    $sql = "SELECT $tableSepeParticipants.id AS id, document_type, document_number, document_letter, firstname, lastname
395
            FROM $tableSepeParticipants
396
            LEFT JOIN $tableUser ON $tableSepeParticipants.platform_user_id=$tableUser.user_id
397
            WHERE action_id = $actionId";
398
    $res = Database::query($sql);
399
    $aux = [];
400
    while ($row = Database::fetch_assoc($res)) {
401
        $aux[] = $row;
402
    }
403
404
    return $aux;
405
}
406
407
function listParticipantSpecialty($participantId)
408
{
409
    global $tableSepeParticipantsSpecialty;
410
411
    $participantId = (int) $participantId;
412
    $sql = "SELECT * FROM $tableSepeParticipantsSpecialty WHERE participant_id = $participantId";
413
    $res = Database::query($sql);
414
    $aux = [];
415
    while ($row = Database::fetch_assoc($res)) {
416
        $row['specialty_origin'] = Security::remove_XSS(stripslashes($row['specialty_origin']));
417
        $row['professional_area'] = Security::remove_XSS(stripslashes($row['professional_area']));
418
        $row['specialty_code'] = Security::remove_XSS(stripslashes($row['specialty_code']));
419
        $row['center_origin'] = Security::remove_XSS(stripslashes($row['center_origin']));
420
        $row['center_code'] = Security::remove_XSS(stripslashes($row['center_code']));
421
        $row['final_result'] = Security::remove_XSS(stripslashes($row['final_result']));
422
        $row['final_qualification'] = Security::remove_XSS(stripslashes($row['final_qualification']));
423
        $row['final_score'] = Security::remove_XSS(stripslashes($row['final_score']));
424
        $aux[] = $row;
425
    }
426
427
    return $aux;
428
}
429
430
function classroomList($specialtyId)
431
{
432
    global $tableSepeSpecialtyClassroom;
433
    global $tableCenters;
434
    $specialtyId = (int) $specialtyId;
435
    $sql = "SELECT a.*, center_origin, center_code
436
            FROM $tableSepeSpecialtyClassroom a
437
            LEFT JOIN $tableCenters b ON a.center_id=b.id
438
            WHERE specialty_id = $specialtyId";
439
    $res = Database::query($sql);
440
    $aux = [];
441
    while ($row = Database::fetch_assoc($res)) {
442
        $aux[] = $row;
443
    }
444
445
    return $aux;
446
}
447
448
function tutorsList($specialtyId)
449
{
450
    global $tableSepeSpecialtyTutors;
451
    global $tableSepeTutors;
452
    global $tableUser;
453
    $specialtyId = (int) $specialtyId;
454
    $aux = [];
455
    $sql = "SELECT a.*,document_type,document_number,document_letter, firstname, lastname
456
            FROM $tableSepeSpecialtyTutors a
457
            INNER JOIN $tableSepeTutors b ON a.tutor_id=b.id
458
            LEFT JOIN $tableUser c ON b.platform_user_id=c.user_id
459
            WHERE a.specialty_id = $specialtyId";
460
    $res = Database::query($sql);
461
    while ($row = Database::fetch_assoc($res)) {
462
        $aux[] = $row;
463
    }
464
465
    return $aux;
466
}
467
468
function getListSpecialtyTutorial($specialtyId)
469
{
470
    global $tableSepeParticipantsSpecialtyTutorials;
471
    $specialtyId = (int) $specialtyId;
472
    $sql = "SELECT * FROM $tableSepeParticipantsSpecialtyTutorials
473
            WHERE participant_specialty_id = $specialtyId";
474
    $res = Database::query($sql);
475
    $aux = [];
476
    while ($row = Database::fetch_assoc($res)) {
477
        $row['tutor_accreditation'] = Security::remove_XSS(stripslashes($row['tutor_accreditation']));
478
        $row['teaching_competence'] = Security::remove_XSS(stripslashes($row['teaching_competence']));
479
        $row['training_teleforming'] = Security::remove_XSS(stripslashes($row['training_teleforming']));
480
        $aux[] = $row;
481
    }
482
483
    return $aux;
484
}
485
486
function listCourseAction()
487
{
488
    global $tableSepeActions;
489
    global $tableSepeCourseActions;
490
491
    $sql = "SELECT
492
            $tableSepeCourseActions.*, course.title AS title,
493
            $tableSepeActions.action_origin AS action_origin,
494
            $tableSepeActions.action_code AS action_code
495
            FROM $tableSepeCourseActions, course, $tableSepeActions
496
            WHERE $tableSepeCourseActions.course_id=course.id
497
            AND $tableSepeActions.id=$tableSepeCourseActions.action_id";
498
    $res = Database::query($sql);
499
    $aux = [];
500
    while ($row = Database::fetch_assoc($res)) {
501
        $aux[] = $row;
502
    }
503
504
    return $aux;
505
}
506
507
function listCourseFree()
508
{
509
    global $tableCourse;
510
    global $tableSepeCourseActions;
511
    $sql = "SELECT id, title FROM $tableCourse
512
            WHERE NOT EXISTS (
513
                SELECT * FROM $tableSepeCourseActions
514
                WHERE $tableCourse.id = $tableSepeCourseActions.course_id)
515
            ;";
516
    $res = Database::query($sql);
517
    while ($row = Database::fetch_assoc($res)) {
518
        $aux[] = $row;
519
    }
520
521
    return $aux;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $aux does not seem to be defined for all execution paths leading up to this point.
Loading history...
522
}
523
524
function listActionFree()
525
{
526
    global $tableSepeActions;
527
    global $tableSepeCourseActions;
528
    $sql = "SELECT id, action_origin, action_code FROM $tableSepeActions
529
            WHERE NOT EXISTS (
530
                SELECT * FROM $tableSepeCourseActions WHERE $tableSepeActions.id = $tableSepeCourseActions.action_id)
531
            ;";
532
    $res = Database::query($sql);
533
    $aux = [];
534
    while ($row = Database::fetch_assoc($res)) {
535
        $row['action_origin'] = Security::remove_XSS(stripslashes($row['action_origin']));
536
        $row['action_code'] = Security::remove_XSS(stripslashes($row['action_code']));
537
        $aux[] = $row;
538
    }
539
540
    return $aux;
541
}
542
543
function getSpecialtyTutorId($specialtyId, $tutorId)
544
{
545
    global $tableSepeSpecialtyTutors;
546
    $specialtyId = (int) $specialtyId;
547
    $tutorId = (int) $tutorId;
548
549
    $sql = "SELECT id
550
            FROM $tableSepeSpecialtyTutors
551
            WHERE specialty_id = $specialtyId AND tutor_id = $tutorId";
552
    $res = Database::query($sql);
553
    $row = Database::fetch_assoc($res);
554
555
    return $row['id'];
556
}
557
558
function checkInsertNewLog($platformUserId, $actionId)
559
{
560
    global $tableSepeLogParticipant;
561
    $platformUserId = (int) $platformUserId;
562
    $actionId = (int) $actionId;
563
    $sql = "SELECT * FROM $tableSepeLogParticipant
564
            WHERE platform_user_id = $platformUserId AND action_id = $actionId";
565
    $res = Database::query($sql);
566
    if (Database::num_rows($res) > 0) {
567
        return false;
568
    } else {
569
        return true;
570
    }
571
}
572
573
function getUserPlatformFromParticipant($participantId)
574
{
575
    global $tableSepeParticipants;
576
    $participantId = (int) $participantId;
577
578
    $sql = "SELECT * FROM $tableSepeParticipants WHERE id = $participantId";
579
    $res = Database::query($sql);
580
    $row = Database::fetch_assoc($res);
581
    if ($row['platform_user_id'] == 0 || $row['platform_user_id'] == '') {
582
        return false;
583
    } else {
584
        return $row['platform_user_id'];
585
    }
586
}
587