Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/storage/PhrictionDocument.php
<?php | <?php | ||||
final class PhrictionDocument extends PhrictionDAO | final class PhrictionDocument extends PhrictionDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorSubscribableInterface, | PhabricatorSubscribableInterface, | ||||
PhabricatorFlaggableInterface, | PhabricatorFlaggableInterface, | ||||
PhabricatorTokenReceiverInterface, | PhabricatorTokenReceiverInterface, | ||||
PhabricatorDestructibleInterface, | PhabricatorDestructibleInterface, | ||||
PhabricatorFulltextInterface, | PhabricatorFulltextInterface, | ||||
PhabricatorFerretInterface, | PhabricatorFerretInterface, | ||||
PhabricatorProjectInterface, | PhabricatorProjectInterface, | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorConduitResultInterface, | PhabricatorConduitResultInterface, | ||||
PhabricatorPolicyCodexInterface { | PhabricatorPolicyCodexInterface, | ||||
PhabricatorSpacesInterface { | |||||
protected $slug; | protected $slug; | ||||
protected $depth; | protected $depth; | ||||
protected $contentID; | protected $contentID; | ||||
protected $status; | protected $status; | ||||
protected $mailKey; | protected $mailKey; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $spacePHID; | |||||
private $contentObject = self::ATTACHABLE; | private $contentObject = self::ATTACHABLE; | ||||
private $ancestors = array(); | private $ancestors = array(); | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_TIMESTAMPS => false, | self::CONFIG_TIMESTAMPS => false, | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if ($ancestral_slugs) { | ||||
$parent = end($ancestral_slugs); | $parent = end($ancestral_slugs); | ||||
$parent_doc = id(new PhrictionDocumentQuery()) | $parent_doc = id(new PhrictionDocumentQuery()) | ||||
->setViewer($actor) | ->setViewer($actor) | ||||
->withSlugs(array($parent)) | ->withSlugs(array($parent)) | ||||
->executeOne(); | ->executeOne(); | ||||
} | } | ||||
if ($parent_doc) { | if ($parent_doc) { | ||||
$document->setViewPolicy($parent_doc->getViewPolicy()); | $document | ||||
$document->setEditPolicy($parent_doc->getEditPolicy()); | ->setViewPolicy($parent_doc->getViewPolicy()) | ||||
->setEditPolicy($parent_doc->getEditPolicy()) | |||||
->setSpacePHID($parent_doc->getSpacePHID()); | |||||
} else { | } else { | ||||
$default_view_policy = PhabricatorPolicies::getMostOpenPolicy(); | $default_view_policy = PhabricatorPolicies::getMostOpenPolicy(); | ||||
$document->setViewPolicy($default_view_policy); | $document | ||||
$document->setEditPolicy(PhabricatorPolicies::POLICY_USER); | ->setViewPolicy($default_view_policy) | ||||
->setEditPolicy(PhabricatorPolicies::POLICY_USER) | |||||
->setSpacePHID($actor->getDefaultSpacePHID()); | |||||
} | } | ||||
return $document; | return $document; | ||||
} | } | ||||
public function save() { | public function save() { | ||||
if (!$this->getMailKey()) { | if (!$this->getMailKey()) { | ||||
$this->setMailKey(Filesystem::readRandomCharacters(20)); | $this->setMailKey(Filesystem::readRandomCharacters(20)); | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | public function getPolicy($capability) { | ||||
} | } | ||||
} | } | ||||
public function hasAutomaticCapability($capability, PhabricatorUser $user) { | public function hasAutomaticCapability($capability, PhabricatorUser $user) { | ||||
return false; | return false; | ||||
} | } | ||||
/* -( PhabricatorSpacesInterface )----------------------------------------- */ | |||||
public function getSpacePHID() { | |||||
return $this->spacePHID; | |||||
} | |||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */ | /* -( PhabricatorSubscribableInterface )----------------------------------- */ | ||||
public function isAutomaticallySubscribed($phid) { | public function isAutomaticallySubscribed($phid) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |