Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893815
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
13 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php b/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php
index 932b1c7bff..bfbf83e012 100644
--- a/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php
+++ b/src/applications/differential/field/specification/DifferentialCCsFieldSpecification.php
@@ -1,110 +1,110 @@
<?php
final class DifferentialCCsFieldSpecification
extends DifferentialFieldSpecification {
private $ccs = array();
public function shouldAppearOnRevisionView() {
return true;
}
public function getRequiredHandlePHIDsForRevisionView() {
return $this->getCCPHIDs();
}
public function renderLabelForRevisionView() {
return 'CCs:';
}
public function renderValueForRevisionView() {
return $this->renderUserList($this->getCCPHIDs());
}
private function getCCPHIDs() {
$revision = $this->getRevision();
return $revision->getCCPHIDs();
}
public function shouldAppearOnEdit() {
return true;
}
protected function didSetRevision() {
$this->ccs = $this->getCCPHIDs();
}
public function getRequiredHandlePHIDsForRevisionEdit() {
return $this->ccs;
}
public function getRequiredHandlePHIDsForCommitMessage() {
return $this->ccs;
}
public function setValueFromRequest(AphrontRequest $request) {
$this->ccs = $request->getArr('cc');
return $this;
}
public function renderEditControl() {
$cc_map = array();
foreach ($this->ccs as $phid) {
$cc_map[$phid] = $this->getHandle($phid)->getFullName();
}
return id(new AphrontFormTokenizerControl())
->setLabel('CC')
->setName('cc')
->setUser($this->getUser())
->setDatasource('/typeahead/common/mailable/')
->setValue($cc_map);
}
public function willWriteRevision(DifferentialRevisionEditor $editor) {
$editor->setCCPHIDs($this->ccs);
}
public function shouldAppearOnCommitMessage() {
return true;
}
public function getCommitMessageKey() {
return 'ccPHIDs';
}
public function setValueFromParsedCommitMessage($value) {
- $this->ccs = array_unique(nonempty($value), array());
+ $this->ccs = array_unique(nonempty($value, array()));
return $this;
}
public function renderLabelForCommitMessage() {
return 'CC';
}
public function renderValueForCommitMessage($is_edit) {
if (!$this->ccs) {
return null;
}
$names = array();
foreach ($this->ccs as $phid) {
$handle = $this->getHandle($phid);
if ($handle->isComplete()) {
$names[] = $handle->getName();
}
}
return implode(', ', $names);
}
public function getSupportedCommitMessageLabels() {
return array(
'CC',
'CCs',
);
}
public function parseValueFromCommitMessage($value) {
return $this->parseCommitMessageMailableList($value);
}
}
diff --git a/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php b/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php
index 4af92b55ec..dad5bf54d3 100644
--- a/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php
+++ b/src/applications/differential/field/specification/DifferentialManiphestTasksFieldSpecification.php
@@ -1,176 +1,176 @@
<?php
final class DifferentialManiphestTasksFieldSpecification
extends DifferentialFieldSpecification {
private $oldManiphestTasks = array();
private $maniphestTasks = array();
public function shouldAppearOnRevisionView() {
return PhabricatorEnv::getEnvConfig('maniphest.enabled');
}
public function getRequiredHandlePHIDsForRevisionView() {
return $this->getManiphestTaskPHIDs();
}
public function renderLabelForRevisionView() {
return 'Maniphest Tasks:';
}
public function renderValueForRevisionView() {
$task_phids = $this->getManiphestTaskPHIDs();
if (!$task_phids) {
return null;
}
$links = array();
foreach ($task_phids as $task_phid) {
$links[] = $this->getHandle($task_phid)->renderLink();
}
return phutil_implode_html(phutil_tag('br'), $links);
}
private function getManiphestTaskPHIDs() {
$revision = $this->getRevision();
if (!$revision->getPHID()) {
return array();
}
return PhabricatorEdgeQuery::loadDestinationPHIDs(
$revision->getPHID(),
PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK);
}
/**
* Attach the revision to the task(s) and the task(s) to the revision.
*
* @return void
*/
public function didWriteRevision(DifferentialRevisionEditor $editor) {
$revision = $editor->getRevision();
$revision_phid = $revision->getPHID();
$edge_type = PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK;
$old_phids = $this->oldManiphestTasks;
$add_phids = $this->maniphestTasks;
$rem_phids = array_diff($old_phids, $add_phids);
$edge_editor = id(new PhabricatorEdgeEditor())
->setActor($this->getUser());
foreach ($add_phids as $phid) {
$edge_editor->addEdge($revision_phid, $edge_type, $phid);
}
foreach ($rem_phids as $phid) {
$edge_editor->removeEdge($revision_phid, $edge_type, $phid);
}
$edge_editor->save();
}
protected function didSetRevision() {
$this->maniphestTasks = $this->getManiphestTaskPHIDs();
$this->oldManiphestTasks = $this->maniphestTasks;
}
public function getRequiredHandlePHIDsForCommitMessage() {
return $this->maniphestTasks;
}
public function shouldAppearOnCommitMessageTemplate() {
return PhabricatorEnv::getEnvConfig('maniphest.enabled');
}
public function shouldAppearOnCommitMessage() {
return PhabricatorEnv::getEnvConfig('maniphest.enabled');
}
public function getCommitMessageKey() {
return 'maniphestTaskPHIDs';
}
public function setValueFromParsedCommitMessage($value) {
- $this->maniphestTasks = array_unique(nonempty($value), array());
+ $this->maniphestTasks = array_unique(nonempty($value, array()));
return $this;
}
public function renderLabelForCommitMessage() {
return 'Maniphest Tasks';
}
public function getSupportedCommitMessageLabels() {
return array(
'Maniphest Task',
'Maniphest Tasks',
);
}
public function renderValueForCommitMessage($is_edit) {
if (!$this->maniphestTasks) {
return null;
}
$names = array();
foreach ($this->maniphestTasks as $phid) {
$handle = $this->getHandle($phid);
$names[] = 'T'.$handle->getAlternateID();
}
return implode(', ', $names);
}
public function parseValueFromCommitMessage($value) {
$matches = null;
preg_match_all('/T(\d+)/', $value, $matches);
if (empty($matches[0])) {
return array();
}
$task_ids = $matches[1];
$tasks = id(new ManiphestTask())
->loadAllWhere('id in (%Ld)', $task_ids);
$task_phids = array();
$invalid = array();
foreach ($task_ids as $task_id) {
$task = idx($tasks, $task_id);
if (empty($task)) {
$invalid[] = 'T'.$task_id;
} else {
$task_phids[] = $task->getPHID();
}
}
if ($invalid) {
$what = pht('Maniphest Task(s)', count($invalid));
$invalid = implode(', ', $invalid);
throw new DifferentialFieldParseException(
"Commit message references nonexistent {$what}: {$invalid}.");
}
return $task_phids;
}
public function renderValueForMail($phase) {
if ($phase == DifferentialMailPhase::COMMENT) {
return null;
}
if (!$this->maniphestTasks) {
return null;
}
$handles = id(new PhabricatorObjectHandleData($this->maniphestTasks))
->setViewer($this->getUser())
->loadHandles();
$body = array();
$body[] = 'MANIPHEST TASKS';
foreach ($handles as $handle) {
$body[] = ' '.PhabricatorEnv::getProductionURI($handle->getURI());
}
return implode("\n", $body);
}
}
diff --git a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php
index fedc06df6f..5ae0ad3f21 100644
--- a/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php
+++ b/src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php
@@ -1,194 +1,194 @@
<?php
final class DifferentialReviewersFieldSpecification
extends DifferentialFieldSpecification {
private $reviewers = array();
private $error;
public function shouldAppearOnRevisionView() {
return true;
}
public function getRequiredHandlePHIDsForRevisionView() {
return $this->getReviewerPHIDs();
}
public function renderLabelForRevisionView() {
return 'Reviewers:';
}
public function renderValueForRevisionView() {
return $this->renderUserList($this->getReviewerPHIDs());
}
private function getReviewerPHIDs() {
$revision = $this->getRevision();
return $revision->getReviewers();
}
public function shouldAppearOnEdit() {
return true;
}
protected function didSetRevision() {
$this->reviewers = $this->getReviewerPHIDs();
}
public function getRequiredHandlePHIDsForRevisionEdit() {
return $this->reviewers;
}
public function setValueFromRequest(AphrontRequest $request) {
$this->reviewers = $request->getArr('reviewers');
return $this;
}
public function validateField() {
if (!$this->hasRevision()) {
return;
}
$self = PhabricatorEnv::getEnvConfig('differential.allow-self-accept');
if ($self) {
return;
}
$author_phid = $this->getRevision()->getAuthorPHID();
if (!in_array($author_phid, $this->reviewers)) {
return;
}
$this->error = 'Invalid';
throw new DifferentialFieldValidationException(
"The owner of a revision may not be a reviewer.");
}
public function renderEditControl() {
$reviewer_map = array();
foreach ($this->reviewers as $phid) {
$reviewer_map[$phid] = $this->getHandle($phid)->getFullName();
}
return id(new AphrontFormTokenizerControl())
->setLabel('Reviewers')
->setName('reviewers')
->setUser($this->getUser())
->setDatasource('/typeahead/common/users/')
->setValue($reviewer_map)
->setError($this->error);
}
public function willWriteRevision(DifferentialRevisionEditor $editor) {
$editor->setReviewers($this->reviewers);
}
public function shouldAppearOnCommitMessage() {
return true;
}
public function getCommitMessageKey() {
return 'reviewerPHIDs';
}
public function setValueFromParsedCommitMessage($value) {
- $this->reviewers = array_unique(nonempty($value), array());
+ $this->reviewers = array_unique(nonempty($value, array()));
return $this;
}
public function renderLabelForCommitMessage() {
return 'Reviewers';
}
public function getRequiredHandlePHIDsForCommitMessage() {
return $this->reviewers;
}
public function renderValueForCommitMessage($is_edit) {
if (!$this->reviewers) {
return null;
}
$names = array();
foreach ($this->reviewers as $phid) {
$names[] = $this->getHandle($phid)->getName();
}
return implode(', ', $names);
}
public function getSupportedCommitMessageLabels() {
return array(
'Reviewer',
'Reviewers',
);
}
public function parseValueFromCommitMessage($value) {
return $this->parseCommitMessageUserList($value);
}
public function shouldAppearOnRevisionList() {
return true;
}
public function renderHeaderForRevisionList() {
return 'Reviewers';
}
public function renderValueForRevisionList(DifferentialRevision $revision) {
$primary_reviewer = $revision->getPrimaryReviewer();
if ($primary_reviewer) {
$other_reviewers = array_flip($revision->getReviewers());
unset($other_reviewers[$primary_reviewer]);
if ($other_reviewers) {
$names = array();
foreach ($other_reviewers as $reviewer => $_) {
$names[] = $this->getHandle($reviewer)->getLinkName();
}
$suffix = javelin_tag(
'abbr',
array(
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => implode(', ', $names),
'align' => 'E',
),
),
'(+'.(count($names)).')');
} else {
$suffix = null;
}
return hsprintf(
'%s %s',
$this->getHandle($primary_reviewer)->renderLink(),
$suffix);
} else {
return phutil_tag('em', array(), 'None');
}
}
public function getRequiredHandlePHIDsForRevisionList(
DifferentialRevision $revision) {
return $revision->getReviewers();
}
public function renderValueForMail($phase) {
if ($phase == DifferentialMailPhase::COMMENT) {
return null;
}
if (!$this->reviewers) {
return null;
}
$handles = id(new PhabricatorObjectHandleData($this->reviewers))
->setViewer($this->getUser())
->loadHandles();
$handles = array_select_keys(
$handles,
array($this->getRevision()->getPrimaryReviewer())) + $handles;
$names = mpull($handles, 'getName');
return 'Reviewers: '.implode(', ', $names);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 19:06 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127687
Default Alt Text
(13 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment