Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96677636
PhamePostBlogTransaction.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
Sun, Dec 29, 18:19
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 31, 18:19 (2 d)
Engine
blob
Format
Raw Data
Handle
23210537
Attached To
rPH Phabricator
PhamePostBlogTransaction.php
View Options
<?php
final
class
PhamePostBlogTransaction
extends
PhamePostTransactionType
{
const
TRANSACTIONTYPE
=
'phame.post.blog'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getBlogPHID
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setBlogPHID
(
$value
);
}
public
function
getTitle
()
{
return
pht
(
'%s changed the blog for this post.'
,
$this
->
renderAuthor
());
}
public
function
getTitleForFeed
()
{
return
pht
(
'%s changed the blog for post %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getBlogPHID
(),
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Posts must be attached to a blog.'
));
}
foreach
(
$xactions
as
$xaction
)
{
$new_phid
=
$xaction
->
getNewValue
();
$blog
=
id
(
new
PhameBlogQuery
())
->
setViewer
(
$this
->
getActor
())
->
withPHIDs
(
array
(
$new_phid
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
execute
();
if
(
$blog
)
{
continue
;
}
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'The specified blog PHID ("%s") is not valid. You can only '
.
'create a post on (or move a post into) a blog which you '
.
'have permission to see and edit.'
,
$new_phid
));
}
return
$errors
;
}
}
Event Timeline
Log In to Comment