/
Email.php
41 lines (38 loc) · 982 Bytes
/
Email.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
<?php
class Email
{
/**
* @url POST sendemail
*/
protected function postSendEmail($from, $to, $subject, $message)
{
if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
\TTOMail::createAndSend($from, $to, $subject, $message);
} else {
throw new RestException(401, 'No Authorize or Invalid request !!!');
}
}
/**
* @url POST sendemailadmin/{userId}
*/
protected function postSendEmailAdmin($userId, $subject, $message)
{
if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
\TTOMail::createAndSendAdmin($subject, $message);
} else {
throw new RestException(401, 'No Authorize or Invalid request !!!');
}
}
/**
* @url GET useremail/{userId}
*/
protected function getUserEmail($userId)
{
if (\TTO::getRole() == 'admin') {
$response = new \stdClass();
return \TTO::getUserEmail($userId);
} else {
throw new RestException(401, 'No Authorize or Invalid request !!!');
}
}
}