Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77111505
ConduitAPI_user_addstatus_Method.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 12, 11:59
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Aug 14, 11:59 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
19826586
Attached To
rPH Phabricator
ConduitAPI_user_addstatus_Method.php
View Options
<?php
/**
* @group conduit
*/
final
class
ConduitAPI_user_addstatus_Method
extends
ConduitAPI_user_Method
{
public
function
getMethodStatus
()
{
return
self
::
METHOD_STATUS_UNSTABLE
;
}
public
function
getMethodDescription
()
{
return
"Add status information to the logged-in user."
;
}
public
function
defineParamTypes
()
{
return
array
(
'fromEpoch'
=>
'required int'
,
'toEpoch'
=>
'required int'
,
'status'
=>
'required enum<away, sporadic>'
,
'description'
=>
'optional string'
,
);
}
public
function
defineReturnType
()
{
return
'void'
;
}
public
function
defineErrorTypes
()
{
return
array
(
'ERR-BAD-EPOCH'
=>
"'toEpoch' must be bigger than 'fromEpoch'."
,
'ERR-OVERLAP'
=>
'There must be no status in any part of the specified epoch.'
,
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$user_phid
=
$request
->
getUser
()->
getPHID
();
$from
=
$request
->
getValue
(
'fromEpoch'
);
$to
=
$request
->
getValue
(
'toEpoch'
);
$status
=
ucfirst
(
$request
->
getValue
(
'status'
));
$description
=
$request
->
getValue
(
'description'
,
''
);
try
{
id
(
new
PhabricatorUserStatus
())
->
setUserPHID
(
$user_phid
)
->
setDateFrom
(
$from
)
->
setDateTo
(
$to
)
->
setTextStatus
(
$status
)
->
setDescription
(
$description
)
->
save
();
}
catch
(
PhabricatorUserStatusInvalidEpochException
$e
)
{
throw
new
ConduitException
(
'ERR-BAD-EPOCH'
);
}
catch
(
PhabricatorUserStatusOverlapException
$e
)
{
throw
new
ConduitException
(
'ERR-OVERLAP'
);
}
}
}
Event Timeline
Log In to Comment