Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120652443
PhabricatorAuditPreviewController.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, Jul 6, 00:20
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Jul 8, 00:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27222497
Attached To
rPH Phabricator
PhabricatorAuditPreviewController.php
View Options
<?php
final
class
PhabricatorAuditPreviewController
extends
PhabricatorAuditController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$commit
=
id
(
new
PhabricatorRepositoryCommit
())->
load
(
$this
->
id
);
if
(!
$commit
)
{
return
new
Aphront404Response
();
}
$action
=
$request
->
getStr
(
'action'
);
$phids
=
array
(
$user
->
getPHID
(),
$commit
->
getPHID
(),
);
$comments
=
array
();
if
(
$action
!=
PhabricatorAuditActionConstants
::
COMMENT
)
{
$action_comment
=
id
(
new
PhabricatorAuditComment
())
->
setActorPHID
(
$user
->
getPHID
())
->
setTargetPHID
(
$commit
->
getPHID
())
->
setAction
(
$action
);
$auditors
=
$request
->
getStrList
(
'auditors'
);
if
(
$action
==
PhabricatorAuditActionConstants
::
ADD_AUDITORS
&&
$auditors
)
{
$action_comment
->
setMetadata
(
array
(
PhabricatorAuditComment
::
METADATA_ADDED_AUDITORS
=>
$auditors
));
$phids
=
array_merge
(
$phids
,
$auditors
);
}
$ccs
=
$request
->
getStrList
(
'ccs'
);
if
(
$action
==
PhabricatorAuditActionConstants
::
ADD_CCS
&&
$ccs
)
{
$action_comment
->
setMetadata
(
array
(
PhabricatorAuditComment
::
METADATA_ADDED_CCS
=>
$ccs
));
$phids
=
array_merge
(
$phids
,
$ccs
);
}
$comments
[]
=
$action_comment
;
}
$content
=
$request
->
getStr
(
'content'
);
if
(
strlen
(
$content
))
{
$comments
[]
=
id
(
new
PhabricatorAuditComment
())
->
setActorPHID
(
$user
->
getPHID
())
->
setTargetPHID
(
$commit
->
getPHID
())
->
setAction
(
PhabricatorAuditActionConstants
::
COMMENT
)
->
setContent
(
$content
);
}
$engine
=
new
PhabricatorMarkupEngine
();
$engine
->
setViewer
(
$user
);
foreach
(
$comments
as
$comment
)
{
$engine
->
addObject
(
$comment
,
PhabricatorAuditComment
::
MARKUP_FIELD_BODY
);
}
$engine
->
process
();
$views
=
array
();
foreach
(
$comments
as
$comment
)
{
$view
=
id
(
new
DiffusionCommentView
())
->
setMarkupEngine
(
$engine
)
->
setUser
(
$user
)
->
setComment
(
$comment
)
->
setIsPreview
(
true
);
$phids
=
array_merge
(
$phids
,
$view
->
getRequiredHandlePHIDs
());
$views
[]
=
$view
;
}
$handles
=
$this
->
loadViewerHandles
(
$phids
);
foreach
(
$views
as
$view
)
{
$view
->
setHandles
(
$handles
);
}
id
(
new
PhabricatorDraft
())
->
setAuthorPHID
(
$user
->
getPHID
())
->
setDraftKey
(
'diffusion-audit-'
.
$this
->
id
)
->
setDraft
(
$content
)
->
replaceOrDelete
();
return
id
(
new
AphrontAjaxResponse
())->
setContent
(
hsprintf
(
'%s'
,
$views
));
}
}
Event Timeline
Log In to Comment