1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-19 10:18:38 +01:00
phorge-phorge/src/applications/project/storage/PhabricatorProjectColumnPosition.php
epriestley 706c21375e Remove empty implementations of describeAutomaticCapabilities()
Summary:
This has been replaced by `PolicyCodex` after D16830. Also:

  - Rebuild Celerity map to fix grumpy unit test.
  - Fix one issue on the policy exception workflow to accommodate the new code.

Test Plan:
  - `arc unit --everything`
  - Viewed policy explanations.
  - Viewed policy errors.

Reviewers: chad

Reviewed By: chad

Subscribers: hach-que, PHID-OPKG-gm6ozazyms6q6i22gyam

Differential Revision: https://secure.phabricator.com/D16831
2016-11-09 15:24:22 -08:00

90 lines
2.4 KiB
PHP

<?php
final class PhabricatorProjectColumnPosition extends PhabricatorProjectDAO
implements PhabricatorPolicyInterface {
protected $boardPHID;
protected $columnPHID;
protected $objectPHID;
protected $sequence;
private $column = self::ATTACHABLE;
private $viewSequence = 0;
protected function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'sequence' => 'uint32',
),
self::CONFIG_KEY_SCHEMA => array(
'boardPHID' => array(
'columns' => array('boardPHID', 'columnPHID', 'objectPHID'),
'unique' => true,
),
'objectPHID' => array(
'columns' => array('objectPHID', 'boardPHID'),
),
'boardPHID_2' => array(
'columns' => array('boardPHID', 'columnPHID', 'sequence'),
),
),
) + parent::getConfiguration();
}
public function getColumn() {
return $this->assertAttached($this->column);
}
public function attachColumn(PhabricatorProjectColumn $column) {
$this->column = $column;
return $this;
}
public function setViewSequence($view_sequence) {
$this->viewSequence = $view_sequence;
return $this;
}
public function getOrderingKey() {
// We're ordering both real positions and "virtual" positions which we have
// created but not saved yet.
// Low sequence numbers go above high sequence numbers. Virtual positions
// will have sequence number 0.
// High virtual sequence numbers go above low virtual sequence numbers.
// The layout engine gets objects in ID order, and this puts them in
// reverse ID order.
// High IDs go above low IDs.
// Broadly, this collectively makes newly added stuff float to the top.
return sprintf(
'~%012d%012d%012d',
$this->getSequence(),
((1 << 31) - $this->viewSequence),
((1 << 31) - $this->getID()));
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return PhabricatorPolicies::getMostOpenPolicy();
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
}