@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorProjectColumnPosition extends PhabricatorProjectDAO
4 implements PhabricatorPolicyInterface {
5
6 protected $boardPHID;
7 protected $columnPHID;
8 protected $objectPHID;
9 protected $sequence;
10
11 private $column = self::ATTACHABLE;
12 private $viewSequence = 0;
13
14 protected function getConfiguration() {
15 return array(
16 self::CONFIG_TIMESTAMPS => false,
17 self::CONFIG_COLUMN_SCHEMA => array(
18 'sequence' => 'uint32',
19 ),
20 self::CONFIG_KEY_SCHEMA => array(
21 'boardPHID' => array(
22 'columns' => array('boardPHID', 'columnPHID', 'objectPHID'),
23 'unique' => true,
24 ),
25 'objectPHID' => array(
26 'columns' => array('objectPHID', 'boardPHID'),
27 ),
28 'boardPHID_2' => array(
29 'columns' => array('boardPHID', 'columnPHID', 'sequence'),
30 ),
31 ),
32 ) + parent::getConfiguration();
33 }
34
35 public function getColumn() {
36 return $this->assertAttached($this->column);
37 }
38
39 public function attachColumn(PhabricatorProjectColumn $column) {
40 $this->column = $column;
41 return $this;
42 }
43
44 public function setViewSequence($view_sequence) {
45 $this->viewSequence = $view_sequence;
46 return $this;
47 }
48
49 public function newColumnPositionOrderVector() {
50 // We're ordering both real positions and "virtual" positions which we have
51 // created but not saved yet.
52
53 // Low sequence numbers go above high sequence numbers. Virtual positions
54 // will have sequence number 0.
55
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.
59
60 // High IDs go above low IDs.
61
62 // Broadly, this collectively makes newly added stuff float to the top.
63
64 return id(new PhutilSortVector())
65 ->addInt($this->getSequence())
66 ->addInt(-1 * $this->viewSequence)
67 ->addInt(-1 * $this->getID());
68 }
69
70/* -( PhabricatorPolicyInterface )----------------------------------------- */
71
72 public function getCapabilities() {
73 return array(
74 PhabricatorPolicyCapability::CAN_VIEW,
75 );
76 }
77
78 public function getPolicy($capability) {
79 switch ($capability) {
80 case PhabricatorPolicyCapability::CAN_VIEW:
81 return PhabricatorPolicies::getMostOpenPolicy();
82 }
83 }
84
85 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
86 return false;
87 }
88
89}