Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / storage / PhabricatorProjectColumnPosition.php
blob1a094dec374d7784d67508db226851224729acc9
1 <?php
3 final class PhabricatorProjectColumnPosition extends PhabricatorProjectDAO
4 implements PhabricatorPolicyInterface {
6 protected $boardPHID;
7 protected $columnPHID;
8 protected $objectPHID;
9 protected $sequence;
11 private $column = self::ATTACHABLE;
12 private $viewSequence = 0;
14 protected function getConfiguration() {
15 return array(
16 self::CONFIG_TIMESTAMPS => false,
17 self::CONFIG_COLUMN_SCHEMA => array(
18 'sequence' => 'uint32',
20 self::CONFIG_KEY_SCHEMA => array(
21 'boardPHID' => array(
22 'columns' => array('boardPHID', 'columnPHID', 'objectPHID'),
23 'unique' => true,
25 'objectPHID' => array(
26 'columns' => array('objectPHID', 'boardPHID'),
28 'boardPHID_2' => array(
29 'columns' => array('boardPHID', 'columnPHID', 'sequence'),
32 ) + parent::getConfiguration();
35 public function getColumn() {
36 return $this->assertAttached($this->column);
39 public function attachColumn(PhabricatorProjectColumn $column) {
40 $this->column = $column;
41 return $this;
44 public function setViewSequence($view_sequence) {
45 $this->viewSequence = $view_sequence;
46 return $this;
49 public function newColumnPositionOrderVector() {
50 // We're ordering both real positions and "virtual" positions which we have
51 // created but not saved yet.
53 // Low sequence numbers go above high sequence numbers. Virtual positions
54 // will have sequence number 0.
56 // High virtual sequence numbers go above low virtual sequence numbers.
57 // The layout engine gets objects in ID order, and this puts them in
58 // reverse ID order.
60 // High IDs go above low IDs.
62 // Broadly, this collectively makes newly added stuff float to the top.
64 return id(new PhutilSortVector())
65 ->addInt($this->getSequence())
66 ->addInt(-1 * $this->viewSequence)
67 ->addInt(-1 * $this->getID());
70 /* -( PhabricatorPolicyInterface )----------------------------------------- */
72 public function getCapabilities() {
73 return array(
74 PhabricatorPolicyCapability::CAN_VIEW,
78 public function getPolicy($capability) {
79 switch ($capability) {
80 case PhabricatorPolicyCapability::CAN_VIEW:
81 return PhabricatorPolicies::getMostOpenPolicy();
85 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
86 return false;