1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00
phorge-phorge/src/applications/project/storage/PhabricatorProjectColumn.php
epriestley f1c638d231 Allow the Default/Backlog column to be renamed
Summary: Fixes T5101. There's no technical reason not to allow this, it just took a little extra work so I didn't do it originally.

Test Plan: Renamed "Backlog", un-renamed it. Tried to hide it.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5101

Differential Revision: https://secure.phabricator.com/D9721
2014-06-25 12:30:43 -07:00

112 lines
2.5 KiB
PHP

<?php
final class PhabricatorProjectColumn
extends PhabricatorProjectDAO
implements PhabricatorPolicyInterface,
PhabricatorDestructableInterface {
const STATUS_ACTIVE = 0;
const STATUS_HIDDEN = 1;
protected $name;
protected $status;
protected $projectPHID;
protected $sequence;
private $project = self::ATTACHABLE;
public static function initializeNewColumn(PhabricatorUser $user) {
return id(new PhabricatorProjectColumn())
->setName('')
->setStatus(self::STATUS_ACTIVE);
}
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorProjectPHIDTypeColumn::TYPECONST);
}
public function attachProject(PhabricatorProject $project) {
$this->project = $project;
return $this;
}
public function getProject() {
return $this->assertAttached($this->project);
}
public function isDefaultColumn() {
return ($this->getSequence() == 0);
}
public function isHidden() {
return ($this->getStatus() == self::STATUS_HIDDEN);
}
public function getDisplayName() {
$name = $this->getName();
if (strlen($name)) {
return $name;
}
if ($this->isDefaultColumn()) {
return pht('Backlog');
}
return pht('Unnamed Column');
}
public function getHeaderColor() {
if ($this->isHidden()) {
return PHUIActionHeaderView::HEADER_LIGHTRED;
}
if ($this->isDefaultColumn()) {
return PHUIActionHeaderView::HEADER_DARK_GREY;
}
return PHUIActionHeaderView::HEADER_GREY;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
return $this->getProject()->getPolicy($capability);
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return $this->getProject()->hasAutomaticCapability(
$capability,
$viewer);
}
public function describeAutomaticCapability($capability) {
return pht('Users must be able to see a project to see its board.');
}
/* -( PhabricatorDestructableInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}