Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phid/PhabricatorObjectHandle.php
<?php | <?php | ||||
final class PhabricatorObjectHandle | final class PhabricatorObjectHandle | ||||
implements PhabricatorPolicyInterface { | implements PhabricatorPolicyInterface { | ||||
const AVAILABILITY_FULL = 'full'; | |||||
const AVAILABILITY_NONE = 'none'; | |||||
const AVAILABILITY_PARTIAL = 'partial'; | |||||
const AVAILABILITY_DISABLED = 'disabled'; | |||||
const STATUS_OPEN = 'open'; | |||||
const STATUS_CLOSED = 'closed'; | |||||
private $uri; | private $uri; | ||||
private $phid; | private $phid; | ||||
private $type; | private $type; | ||||
private $name; | private $name; | ||||
private $fullName; | private $fullName; | ||||
private $title; | private $title; | ||||
private $imageURI; | private $imageURI; | ||||
private $icon; | private $icon; | ||||
private $tagColor; | private $tagColor; | ||||
private $timestamp; | private $timestamp; | ||||
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN; | private $status = self::STATUS_OPEN; | ||||
private $availability = self::AVAILABILITY_FULL; | |||||
private $complete; | private $complete; | ||||
private $disabled; | |||||
private $objectName; | private $objectName; | ||||
private $policyFiltered; | private $policyFiltered; | ||||
public function setIcon($icon) { | public function setIcon($icon) { | ||||
$this->icon = $icon; | $this->icon = $icon; | ||||
return $this; | return $this; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if ($this->name === null) { | ||||
return pht('Restricted %s', $this->getTypeName()); | return pht('Restricted %s', $this->getTypeName()); | ||||
} else { | } else { | ||||
return pht('Unknown Object (%s)', $this->getTypeName()); | return pht('Unknown Object (%s)', $this->getTypeName()); | ||||
} | } | ||||
} | } | ||||
return $this->name; | return $this->name; | ||||
} | } | ||||
public function setAvailability($availability) { | |||||
$this->availability = $availability; | |||||
return $this; | |||||
} | |||||
public function getAvailability() { | |||||
return $this->availability; | |||||
} | |||||
public function isDisabled() { | |||||
return ($this->getAvailability() == self::AVAILABILITY_DISABLED); | |||||
} | |||||
public function setStatus($status) { | public function setStatus($status) { | ||||
$this->status = $status; | $this->status = $status; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getStatus() { | public function getStatus() { | ||||
return $this->status; | return $this->status; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | final class PhabricatorObjectHandle | ||||
* | * | ||||
* @return bool True if the handle represents a complete object. | * @return bool True if the handle represents a complete object. | ||||
*/ | */ | ||||
public function isComplete() { | public function isComplete() { | ||||
return $this->complete; | return $this->complete; | ||||
} | } | ||||
/** | |||||
* Set whether or not the underlying object is disabled. See | |||||
* @{method:isDisabled} for an explanation of what it means to be disabled. | |||||
* | |||||
* @param bool True if the handle represents a disabled object. | |||||
* @return this | |||||
*/ | |||||
public function setDisabled($disabled) { | |||||
$this->disabled = $disabled; | |||||
return $this; | |||||
} | |||||
/** | |||||
* Determine if the handle represents an object which has been disabled -- | |||||
* for example, disabled users, archived projects, etc. These objects are | |||||
* complete and exist, but should be excluded from some system interactions | |||||
* (for instance, they usually should not appear in typeaheads, and should | |||||
* not have mail/notifications delivered to or about them). | |||||
epriestley: I suppose I could keep most of this around if it suits your fancy. | |||||
* | |||||
* @return bool True if the handle represents a disabled object. | |||||
*/ | |||||
public function isDisabled() { | |||||
return $this->disabled; | |||||
} | |||||
public function renderLink($name = null) { | public function renderLink($name = null) { | ||||
if ($name === null) { | if ($name === null) { | ||||
$name = $this->getLinkName(); | $name = $this->getLinkName(); | ||||
} | } | ||||
$classes = array(); | $classes = array(); | ||||
$classes[] = 'phui-handle'; | $classes[] = 'phui-handle'; | ||||
$title = $this->title; | $title = $this->title; | ||||
if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) { | if ($this->status != self::STATUS_OPEN) { | ||||
$classes[] = 'handle-status-'.$this->status; | $classes[] = 'handle-status-'.$this->status; | ||||
$title = $title ? $title : $this->status; | |||||
} | } | ||||
if ($this->disabled) { | if ($this->availability != self::AVAILABILITY_FULL) { | ||||
$classes[] = 'handle-disabled'; | $classes[] = 'handle-availability-'.$this->availability; | ||||
$title = pht('Disabled'); // Overwrite status. | |||||
} | } | ||||
if ($this->getType() == PhabricatorPeopleUserPHIDType::TYPECONST) { | if ($this->getType() == PhabricatorPeopleUserPHIDType::TYPECONST) { | ||||
$classes[] = 'phui-link-person'; | $classes[] = 'phui-link-person'; | ||||
} | } | ||||
$uri = $this->getURI(); | $uri = $this->getURI(); | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |
I suppose I could keep most of this around if it suits your fancy.