forked from LibreBooking/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTermsOfService.php
138 lines (121 loc) · 2.58 KB
/
TermsOfService.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
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
<?php
class TermsOfService
{
public const RESERVATION = 'RESERVATION';
public const REGISTRATION = 'REGISTRATION';
private $id;
private $termsText;
private $termsUrl;
private $filename;
private $applicability;
/**
* @param int $id
* @param string $termsText
* @param string $termsUrl
* @param string $filename
* @param string $applicability
*/
public function __construct($id, $termsText, $termsUrl, $filename, $applicability)
{
$this->id = $id;
$this->termsText = $termsText;
$this->termsUrl = $termsUrl;
$this->filename = $filename;
$this->applicability = $applicability;
}
/**
* @param string $termsText
* @param string $termsUrl
* @param string $filename
* @param string $applicability
* @return TermsOfService
*/
public static function Create($termsText, $termsUrl, $filename, $applicability)
{
return new TermsOfService(0, $termsText, $termsUrl, $filename, $applicability);
}
/**
* @return int
*/
public function Id()
{
return $this->id;
}
/**
* @return string
*/
public function Text()
{
return $this->termsText;
}
/**
* @return string
*/
public function Url()
{
return $this->termsUrl;
}
/**
* @return string
*/
public function FileName()
{
return $this->filename;
}
/**
* @return string
*/
public function Applicability()
{
return $this->applicability;
}
/**
* @return bool
*/
public function AppliesToReservation()
{
return $this->Applicability() == self::RESERVATION;
}
/**
* @return bool
*/
public function AppliesToRegistration()
{
return $this->Applicability() == self::REGISTRATION;
}
/**
* @return string
*/
public function DisplayUrl()
{
$scriptUrl = Configuration::Instance()->GetScriptUrl();
if ($this->IsText()) {
return $scriptUrl . '/tos.php';
}
if ($this->IsUrl()) {
return $this->termsUrl;
}
return $scriptUrl . "/uploads/tos/{$this->filename}";
}
/**
* @return bool
*/
public function IsText()
{
return !empty($this->termsText);
}
/**
* @return bool
*/
public function IsUrl()
{
return !empty($this->termsUrl);
}
/**
* @return bool
*/
public function IsFile()
{
return !empty($this->filename);
}
}