-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTransaction.php
More file actions
250 lines (225 loc) · 5.07 KB
/
Transaction.php
File metadata and controls
250 lines (225 loc) · 5.07 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?PHP
abstract class libEJ_Transaction implements ArrayAccess, IteratorAggregate {
// Meta-Data
private $Timestamp = 0x00;
private $ID = 0x000000;
private $User = 0x00;
// Bits
private $isCopy = false;
private $isTraining = false;
// All records
private $Records = array ();
// {{{ __toString
/**
* Convert this transaction into a string
*
* @access friendly
* @return string
**/
function __toString () {
$Result = sprintf ('#%06d %s' . "\n" . '%02d 000000' . "\n", $this->ID, date ('d/m/Y H:i', $this->Timestamp), $this->User);
foreach ($this->Records as $Record)
$Result .= strval ($Record) . "\n";
return $Result;
}
// }}}
// {{{ getTimestamp
/**
* Retrive the timestamp from this transaction
*
* @access public
* @return int
**/
public function getTimestamp () {
return $this->Timestamp;
}
// }}}
// {{{ setTimestamp
/**
* Set the timestamp of this transaction
*
* @param int $Timestamp
*
* @access public
* @return void
**/
public function setTimestamp ($Timestamp) {
if (is_numeric ($Timestamp))
$this->Timestamp = intval ($Timestamp);
else
$this->Timestamp = strtotime ($Timestamp);
}
// }}}
// {{{ getID
/**
* Retrive the number of this transaction
*
* @access public
* @return int
**/
public function getID () {
return $this->ID;
}
// }}}
// {{{ setID
/**
* Set the number of this transaction
*
* @param int $ID
*
* @access public
* @return void
**/
public function setID ($ID) {
$this->ID = intval ($ID);
}
// }}}
// {{{ getUserID
/**
* Retrive the ID of the user who made this transaction
*
* @access public
* @return int
**/
public function getUserID () {
return $this->User;
}
// }}}
// {{{ setUserID
/**
* Set the ID of the user who made this transaction
*
* @param int $User
*
* @access public
* @return void
**/
public function setUserID ($User) {
$this->User = intval ($User);
}
// }}}
// {{{ isCopy
/**
* Check if this transaction is the copy of another one
*
* @access public
* @return bool
**/
public function isCopy () {
return $this->isCopy;
}
// }}}
// {{{ setCopy
/**
* Set the copy-bit of this transaction
*
* @param bool $Toggle
*
* @access public
* @return void
**/
public function setCopy ($Toggle) {
$this->isCopy = ($Toggle == true);
}
// }}}
// {{{ isTraining
/**
* Check if this transaction was made for training purposes
*
* @access public
* @return bool
**/
public function isTraining () {
return $this->isTraining;
}
// }}}
// {{{ setTraining
/**
* Set the training-bit of this transaction
*
* @param bool $Toggle
*
* @access public
* @return void
**/
public function setTraining ($Toggle) {
$this->isTraining = ($Toggle == true);
}
// }}}
// {{{ offsetExists
/**
* Check if a record exists on our collection
*
* @param mixed $Offset
*
* @access public
* @return bool
**/
public function offsetExists ($Offset) {
return isset ($this->Records [$Offset]);
}
// }}}
// {{{ offsetGet
/**
* Retrive a record from our collection
*
* @param mixed $Offset
*
* @access public
* @return object
**/
public function offsetGet ($Offset) {
if (!isset ($this->Records [$Offset]))
return null;
return $this->Records [$Offset];
}
// }}}
// {{{ offsetSet
/**
* Append/Insert a record into our collection
*
* @param mixed $Offset
* @param object $Value
*
* @access public
* @return void
**/
public function offsetSet ($Offset, $Value) {
// Check the type
if (!($Value instanceof libEJ_Record)) {
trigger_error ('This collection only carries records of type libEJ_Record');
return null;
}
// Append to our collection
if ($Offset === null)
$this->Records [] = $Value;
else
$this->Records [$Offset] = $Value;
}
// }}}
// {{{ offsetUnset
/**
* Remove a record from our collection
*
* @param mixed $Offset
*
* @access public
* @return void
**/
public function offsetUnset ($Offset) {
unset ($this->Records [$Offset]);
}
// }}}
// {{{ getIterator
/**
* Retrive an object to iterate through our records
*
* @access public
* @return object
**/
public function getIterator () {
return new ArrayIterator ($this->Records);
}
// }}}
}
?>