Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/storage/AlmanacBinding.php
<?php | <?php | ||||
final class AlmanacBinding | final class AlmanacBinding | ||||
extends AlmanacDAO | extends AlmanacDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
AlmanacPropertyInterface, | AlmanacPropertyInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface, | ||||
PhabricatorExtendedPolicyInterface { | |||||
protected $servicePHID; | protected $servicePHID; | ||||
protected $devicePHID; | protected $devicePHID; | ||||
protected $interfacePHID; | protected $interfacePHID; | ||||
protected $mailKey; | protected $mailKey; | ||||
private $service = self::ATTACHABLE; | private $service = self::ATTACHABLE; | ||||
private $device = self::ATTACHABLE; | private $device = self::ATTACHABLE; | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
$notes = array( | $notes = array( | ||||
pht('A binding inherits the policies of its service.'), | pht('A binding inherits the policies of its service.'), | ||||
pht( | pht( | ||||
'To view a binding, you must also be able to view its device and '. | 'To view a binding, you must also be able to view its device and '. | ||||
'interface.'), | 'interface.'), | ||||
); | ); | ||||
if ($capability === PhabricatorPolicyCapability::CAN_EDIT) { | return $notes; | ||||
if ($this->getService()->getIsLocked()) { | |||||
$notes[] = pht( | |||||
'The service for this binding is locked, so it can not be edited.'); | |||||
} | |||||
} | } | ||||
return $notes; | |||||
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */ | |||||
public function getExtendedPolicy($capability, PhabricatorUser $viewer) { | |||||
switch ($capability) { | |||||
case PhabricatorPolicyCapability::CAN_EDIT: | |||||
if ($this->getService()->isClusterService()) { | |||||
return array( | |||||
array( | |||||
new PhabricatorAlmanacApplication(), | |||||
AlmanacManageClusterServicesCapability::CAPABILITY, | |||||
), | |||||
); | |||||
} | |||||
break; | |||||
} | } | ||||
return array(); | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | ||||
public function getApplicationTransactionEditor() { | public function getApplicationTransactionEditor() { | ||||
return new AlmanacBindingEditor(); | return new AlmanacBindingEditor(); | ||||
} | } | ||||
Show All 26 Lines |