mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 12:42:43 +01:00
112 lines
2.9 KiB
PHP
112 lines
2.9 KiB
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
* Copyright 2012 Facebook, Inc.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* @group pholio
|
||
|
*/
|
||
|
final class PholioTransaction extends PholioDAO
|
||
|
implements PhabricatorMarkupInterface {
|
||
|
|
||
|
const MARKUP_FIELD_COMMENT = 'markup:comment';
|
||
|
|
||
|
protected $mockID;
|
||
|
protected $authorPHID;
|
||
|
protected $transactionType;
|
||
|
protected $oldValue;
|
||
|
protected $newValue;
|
||
|
protected $comment;
|
||
|
protected $metadata = array();
|
||
|
protected $contentSource;
|
||
|
|
||
|
public function getConfiguration() {
|
||
|
return array(
|
||
|
self::CONFIG_SERIALIZATION => array(
|
||
|
'oldValue' => self::SERIALIZATION_JSON,
|
||
|
'newValue' => self::SERIALIZATION_JSON,
|
||
|
'metadata' => self::SERIALIZATION_JSON,
|
||
|
),
|
||
|
) + parent::getConfiguration();
|
||
|
}
|
||
|
|
||
|
public function setContentSource(PhabricatorContentSource $content_source) {
|
||
|
$this->contentSource = $content_source->serialize();
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function getContentSource() {
|
||
|
return PhabricatorContentSource::newFromSerialized($this->contentSource);
|
||
|
}
|
||
|
|
||
|
|
||
|
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
|
||
|
|
||
|
|
||
|
public function isAutomaticallySubscribed($phid) {
|
||
|
return ($this->authorPHID == $phid);
|
||
|
}
|
||
|
|
||
|
|
||
|
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
||
|
|
||
|
|
||
|
public function getCapabilities() {
|
||
|
return array(
|
||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function getPolicy($capability) {
|
||
|
switch ($capability) {
|
||
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
||
|
return $this->getViewPolicy();
|
||
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
||
|
return PhabricatorPolicies::POLICY_NOONE;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function hasAutomaticCapbility($capability, PhabricatorUser $viewer) {
|
||
|
return ($viewer->getPHID() == $this->getAuthorPHID());
|
||
|
}
|
||
|
|
||
|
|
||
|
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||
|
|
||
|
|
||
|
public function getMarkupFieldKey($field) {
|
||
|
return 'MX:'.$this->getID();
|
||
|
}
|
||
|
|
||
|
public function newMarkupEngine($field) {
|
||
|
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
||
|
}
|
||
|
|
||
|
public function getMarkupText($field) {
|
||
|
return $this->getComment();
|
||
|
}
|
||
|
|
||
|
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||
|
return $output;
|
||
|
}
|
||
|
|
||
|
public function shouldUseMarkupCache($field) {
|
||
|
return (bool)$this->getID();
|
||
|
}
|
||
|
|
||
|
}
|