Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79630366
DiffusionCommitAuditTransaction.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
Tue, Aug 27, 11:14
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Aug 29, 11:14 (2 d)
Engine
blob
Format
Raw Data
Handle
20212034
Attached To
rPH Phabricator
DiffusionCommitAuditTransaction.php
View Options
<?php
abstract
class
DiffusionCommitAuditTransaction
extends
DiffusionCommitActionTransaction
{
protected
function
getCommitActionGroupKey
()
{
return
DiffusionCommitEditEngine
::
ACTIONGROUP_AUDIT
;
}
protected
function
isViewerAnyAuditor
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
return
(
$this
->
getViewerAuditStatus
(
$commit
,
$viewer
)
!==
null
);
}
protected
function
isViewerAcceptingAuditor
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
return
$this
->
isViewerAuditStatusAmong
(
$commit
,
$viewer
,
array
(
PhabricatorAuditStatusConstants
::
ACCEPTED
,
));
}
protected
function
isViewerRejectingAuditor
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
return
$this
->
isViewerAuditStatusAmong
(
$commit
,
$viewer
,
array
(
PhabricatorAuditStatusConstants
::
CONCERNED
,
));
}
protected
function
getViewerAuditStatus
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
if
(!
$viewer
->
getPHID
())
{
return
null
;
}
foreach
(
$commit
->
getAudits
()
as
$audit
)
{
if
(
$audit
->
getAuditorPHID
()
!=
$viewer
->
getPHID
())
{
continue
;
}
return
$audit
->
getAuditStatus
();
}
return
null
;
}
protected
function
isViewerAuditStatusAmong
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
,
array
$status_list
)
{
$status
=
$this
->
getViewerAuditStatus
(
$commit
,
$viewer
);
if
(
$status
===
null
)
{
return
false
;
}
$status_map
=
array_fuse
(
$status_list
);
return
isset
(
$status_map
[
$status
]);
}
protected
function
applyAuditorEffect
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
,
$value
,
$status
)
{
$audits
=
$commit
->
getAudits
();
$audits
=
mpull
(
$audits
,
null
,
'getAuditorPHID'
);
$map
=
array
();
$with_authority
=
(
$status
!=
PhabricatorAuditStatusConstants
::
RESIGNED
);
if
(
$with_authority
)
{
$has_authority
=
PhabricatorAuditCommentEditor
::
loadAuditPHIDsForUser
(
$viewer
);
$has_authority
=
array_fuse
(
$has_authority
);
foreach
(
$audits
as
$audit
)
{
$auditor_phid
=
$audit
->
getAuditorPHID
();
if
(
isset
(
$has_authority
[
$auditor_phid
]))
{
$map
[
$auditor_phid
]
=
$status
;
}
}
}
// In all cases, you affect yourself.
$map
[
$viewer
->
getPHID
()]
=
$status
;
$this
->
updateAudits
(
$commit
,
$map
);
}
}
Event Timeline
Log In to Comment