Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96119711
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
Sun, Dec 22, 20:23
Size
3 KB
Mime Type
text/x-php
Expires
Tue, Dec 24, 20:23 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23126587
Attached To
rPH Phabricator
DiffusionCommitAuditTransaction.php
View Options
<?php
abstract
class
DiffusionCommitAuditTransaction
extends
DiffusionCommitActionTransaction
{
protected
function
getCommitActionGroupKey
()
{
return
DiffusionCommitEditEngine
::
ACTIONGROUP_AUDIT
;
}
public
function
generateOldValue
(
$object
)
{
return
false
;
}
protected
function
isViewerAnyAuditor
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
return
(
$this
->
getViewerAuditStatus
(
$commit
,
$viewer
)
!==
null
);
}
protected
function
isViewerAnyActiveAuditor
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
// This omits various inactive states like "Resigned" and "Not Required".
$active
=
array
(
PhabricatorAuditStatusConstants
::
AUDIT_REQUIRED
,
PhabricatorAuditStatusConstants
::
CONCERNED
,
PhabricatorAuditStatusConstants
::
ACCEPTED
,
PhabricatorAuditStatusConstants
::
AUDIT_REQUESTED
,
);
$active
=
array_fuse
(
$active
);
$viewer_status
=
$this
->
getViewerAuditStatus
(
$commit
,
$viewer
);
return
isset
(
$active
[
$viewer_status
]);
}
protected
function
isViewerFullyAccepted
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
return
$this
->
isViewerAuditStatusFullyAmong
(
$commit
,
$viewer
,
array
(
PhabricatorAuditStatusConstants
::
ACCEPTED
,
));
}
protected
function
isViewerFullyRejected
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
)
{
return
$this
->
isViewerAuditStatusFullyAmong
(
$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
isViewerAuditStatusFullyAmong
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
,
array
$status_list
)
{
$status
=
$this
->
getViewerAuditStatus
(
$commit
,
$viewer
);
if
(
$status
===
null
)
{
return
false
;
}
$status_map
=
array_fuse
(
$status_list
);
foreach
(
$commit
->
getAudits
()
as
$audit
)
{
if
(!
$commit
->
hasAuditAuthority
(
$viewer
,
$audit
))
{
continue
;
}
$status
=
$audit
->
getAuditStatus
();
if
(
isset
(
$status_map
[
$status
]))
{
continue
;
}
return
false
;
}
return
true
;
}
protected
function
applyAuditorEffect
(
PhabricatorRepositoryCommit
$commit
,
PhabricatorUser
$viewer
,
$value
,
$status
)
{
$actor
=
$this
->
getActor
();
$acting_phid
=
$this
->
getActingAsPHID
();
$audits
=
$commit
->
getAudits
();
$audits
=
mpull
(
$audits
,
null
,
'getAuditorPHID'
);
$map
=
array
();
$with_authority
=
(
$status
!=
PhabricatorAuditStatusConstants
::
RESIGNED
);
if
(
$with_authority
)
{
foreach
(
$audits
as
$audit
)
{
if
(
$commit
->
hasAuditAuthority
(
$actor
,
$audit
,
$acting_phid
))
{
$map
[
$audit
->
getAuditorPHID
()]
=
$status
;
}
}
}
// In all cases, you affect yourself.
$map
[
$viewer
->
getPHID
()]
=
$status
;
$this
->
updateAudits
(
$commit
,
$map
);
}
}
Event Timeline
Log In to Comment