[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/project/storage/ -> PhabricatorProjectColumn.php (source)

   1  <?php
   2  
   3  final class PhabricatorProjectColumn
   4    extends PhabricatorProjectDAO
   5    implements
   6      PhabricatorPolicyInterface,
   7      PhabricatorDestructibleInterface {
   8  
   9    const STATUS_ACTIVE = 0;
  10    const STATUS_HIDDEN = 1;
  11  
  12    const DEFAULT_ORDER = 'natural';
  13    const ORDER_NATURAL = 'natural';
  14    const ORDER_PRIORITY = 'priority';
  15  
  16    protected $name;
  17    protected $status;
  18    protected $projectPHID;
  19    protected $sequence;
  20    protected $properties = array();
  21  
  22    private $project = self::ATTACHABLE;
  23  
  24    public static function initializeNewColumn(PhabricatorUser $user) {
  25      return id(new PhabricatorProjectColumn())
  26        ->setName('')
  27        ->setStatus(self::STATUS_ACTIVE);
  28    }
  29  
  30    public function getConfiguration() {
  31      return array(
  32        self::CONFIG_AUX_PHID => true,
  33        self::CONFIG_SERIALIZATION => array(
  34          'properties' => self::SERIALIZATION_JSON,
  35        ),
  36        self::CONFIG_COLUMN_SCHEMA => array(
  37          'name' => 'text255',
  38          'status' => 'uint32',
  39          'sequence' => 'uint32',
  40        ),
  41        self::CONFIG_KEY_SCHEMA => array(
  42          'key_status' => array(
  43            'columns' => array('projectPHID', 'status', 'sequence'),
  44          ),
  45          'key_sequence' => array(
  46            'columns' => array('projectPHID', 'sequence'),
  47          ),
  48        ),
  49      ) + parent::getConfiguration();
  50    }
  51  
  52    public function generatePHID() {
  53      return PhabricatorPHID::generateNewPHID(
  54        PhabricatorProjectColumnPHIDType::TYPECONST);
  55    }
  56  
  57    public function attachProject(PhabricatorProject $project) {
  58      $this->project = $project;
  59      return $this;
  60    }
  61  
  62    public function getProject() {
  63      return $this->assertAttached($this->project);
  64    }
  65  
  66    public function isDefaultColumn() {
  67      return (bool)$this->getProperty('isDefault');
  68    }
  69  
  70    public function isHidden() {
  71      return ($this->getStatus() == self::STATUS_HIDDEN);
  72    }
  73  
  74    public function getDisplayName() {
  75      $name = $this->getName();
  76      if (strlen($name)) {
  77        return $name;
  78      }
  79  
  80      if ($this->isDefaultColumn()) {
  81        return pht('Backlog');
  82      }
  83  
  84      return pht('Unnamed Column');
  85    }
  86  
  87    public function getDisplayType() {
  88      if ($this->isDefaultColumn()) {
  89        return pht('(Default)');
  90      }
  91      if ($this->isHidden()) {
  92        return pht('(Hidden)');
  93      }
  94  
  95      return null;
  96    }
  97  
  98    public function getHeaderIcon() {
  99      $icon = null;
 100  
 101      if ($this->isHidden()) {
 102        $icon = 'fa-eye-slash';
 103        $text = pht('Hidden');
 104      }
 105  
 106      if ($icon) {
 107        return id(new PHUIIconView())
 108          ->setIconFont($icon)
 109          ->addSigil('has-tooltip')
 110          ->setMetadata(
 111            array(
 112              'tip' => $text,
 113            ));;
 114      }
 115  
 116      return null;
 117    }
 118  
 119    public function getProperty($key, $default = null) {
 120      return idx($this->properties, $key, $default);
 121    }
 122  
 123    public function setProperty($key, $value) {
 124      $this->properties[$key] = $value;
 125      return $this;
 126    }
 127  
 128    public function getPointLimit() {
 129      return $this->getProperty('pointLimit');
 130    }
 131  
 132    public function setPointLimit($limit) {
 133      $this->setProperty('pointLimit', $limit);
 134      return $this;
 135    }
 136  
 137  
 138  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
 139  
 140  
 141    public function getCapabilities() {
 142      return array(
 143        PhabricatorPolicyCapability::CAN_VIEW,
 144        PhabricatorPolicyCapability::CAN_EDIT,
 145      );
 146    }
 147  
 148    public function getPolicy($capability) {
 149      return $this->getProject()->getPolicy($capability);
 150    }
 151  
 152    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
 153      return $this->getProject()->hasAutomaticCapability(
 154        $capability,
 155        $viewer);
 156    }
 157  
 158    public function describeAutomaticCapability($capability) {
 159      return pht('Users must be able to see a project to see its board.');
 160    }
 161  
 162  
 163  /* -(  PhabricatorDestructibleInterface  )----------------------------------- */
 164  
 165    public function destroyObjectPermanently(
 166      PhabricatorDestructionEngine $engine) {
 167  
 168      $this->openTransaction();
 169      $this->delete();
 170      $this->saveTransaction();
 171    }
 172  
 173  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1