2012-03-27 05:54:26 +02:00
|
|
|
<?php
|
|
|
|
|
2013-12-26 21:30:17 +01:00
|
|
|
final class DrydockLog extends DrydockDAO
|
|
|
|
implements PhabricatorPolicyInterface {
|
2012-03-27 05:54:26 +02:00
|
|
|
|
|
|
|
protected $resourceID;
|
|
|
|
protected $leaseID;
|
|
|
|
protected $epoch;
|
|
|
|
protected $message;
|
|
|
|
|
2013-12-26 21:30:17 +01:00
|
|
|
private $resource = self::ATTACHABLE;
|
2013-12-27 22:15:19 +01:00
|
|
|
private $lease = self::ATTACHABLE;
|
2013-12-26 21:30:17 +01:00
|
|
|
|
2015-01-13 20:47:05 +01:00
|
|
|
protected function getConfiguration() {
|
2012-03-27 05:54:26 +02:00
|
|
|
return array(
|
|
|
|
self::CONFIG_TIMESTAMPS => false,
|
2014-09-18 20:15:49 +02:00
|
|
|
self::CONFIG_COLUMN_SCHEMA => array(
|
|
|
|
'resourceID' => 'id?',
|
|
|
|
'leaseID' => 'id?',
|
|
|
|
'message' => 'text',
|
|
|
|
),
|
2014-10-01 16:53:50 +02:00
|
|
|
self::CONFIG_KEY_SCHEMA => array(
|
|
|
|
'resourceID' => array(
|
|
|
|
'columns' => array('resourceID', 'epoch'),
|
|
|
|
),
|
|
|
|
'leaseID' => array(
|
|
|
|
'columns' => array('leaseID', 'epoch'),
|
|
|
|
),
|
|
|
|
'epoch' => array(
|
|
|
|
'columns' => array('epoch'),
|
|
|
|
),
|
|
|
|
),
|
2012-03-27 05:54:26 +02:00
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
2013-12-27 22:15:12 +01:00
|
|
|
public function attachResource(DrydockResource $resource = null) {
|
2013-12-26 21:30:17 +01:00
|
|
|
$this->resource = $resource;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getResource() {
|
|
|
|
return $this->assertAttached($this->resource);
|
|
|
|
}
|
|
|
|
|
2013-12-27 22:15:19 +01:00
|
|
|
public function attachLease(DrydockLease $lease = null) {
|
|
|
|
$this->lease = $lease;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLease() {
|
|
|
|
return $this->assertAttached($this->lease);
|
|
|
|
}
|
|
|
|
|
2013-12-26 21:30:17 +01:00
|
|
|
|
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
2013-12-27 22:15:19 +01:00
|
|
|
if ($this->getResource()) {
|
|
|
|
return $this->getResource()->getPolicy($capability);
|
2013-12-27 22:15:12 +01:00
|
|
|
}
|
2013-12-27 22:15:19 +01:00
|
|
|
return $this->getLease()->getPolicy($capability);
|
2013-12-26 21:30:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
2013-12-27 22:15:19 +01:00
|
|
|
if ($this->getResource()) {
|
|
|
|
return $this->getResource()->hasAutomaticCapability($capability, $viewer);
|
2013-12-27 22:15:12 +01:00
|
|
|
}
|
2013-12-27 22:15:19 +01:00
|
|
|
return $this->getLease()->hasAutomaticCapability($capability, $viewer);
|
2013-12-26 21:30:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function describeAutomaticCapability($capability) {
|
|
|
|
return pht('Logs inherit the policy of their resources.');
|
|
|
|
}
|
|
|
|
|
2012-03-27 05:54:26 +02:00
|
|
|
}
|