Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F555046
PhrequentTrackingEditor.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhrequentTrackingEditor.php
View Options
<?php
final
class
PhrequentTrackingEditor
extends
PhabricatorEditor
{
public
function
startTracking
(
PhabricatorUser
$user
,
$phid
,
$timestamp
)
{
$usertime
=
new
PhrequentUserTime
();
$usertime
->
setDateStarted
(
$timestamp
);
$usertime
->
setUserPHID
(
$user
->
getPHID
());
$usertime
->
setObjectPHID
(
$phid
);
$usertime
->
save
();
return
$phid
;
}
public
function
stopTracking
(
PhabricatorUser
$user
,
$phid
,
$timestamp
,
$note
)
{
if
(!
PhrequentUserTimeQuery
::
isUserTrackingObject
(
$user
,
$phid
))
{
// Don't do anything, it's not being tracked.
return
null
;
}
$usertime_dao
=
new
PhrequentUserTime
();
$conn
=
$usertime_dao
->
establishConnection
(
'r'
);
queryfx
(
$conn
,
'UPDATE %T usertime '
.
'SET usertime.dateEnded = %d, '
.
'usertime.note = %s '
.
'WHERE usertime.userPHID = %s '
.
'AND usertime.objectPHID = %s '
.
'AND usertime.dateEnded IS NULL '
.
'ORDER BY usertime.dateStarted, usertime.id DESC '
.
'LIMIT 1'
,
$usertime_dao
->
getTableName
(),
$timestamp
,
$note
,
$user
->
getPHID
(),
$phid
);
return
$phid
;
}
public
function
stopTrackingTop
(
PhabricatorUser
$user
,
$timestamp
,
$note
)
{
$times
=
id
(
new
PhrequentUserTimeQuery
())
->
setViewer
(
$user
)
->
withUserPHIDs
(
array
(
$user
->
getPHID
()))
->
withEnded
(
PhrequentUserTimeQuery
::
ENDED_NO
)
->
setOrder
(
PhrequentUserTimeQuery
::
ORDER_STARTED_DESC
)
->
execute
();
if
(
count
(
$times
)
===
0
)
{
// Nothing to stop tracking.
return
null
;
}
$current
=
head
(
$times
);
return
$this
->
stopTracking
(
$user
,
$current
->
getObjectPHID
(),
$timestamp
,
$note
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 6:22 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
124694
Default Alt Text
PhrequentTrackingEditor.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment