Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/storage/PonderQuestion.php
Show All 15 Lines | final class PonderQuestion extends PonderDAO | ||||
protected $title; | protected $title; | ||||
protected $phid; | protected $phid; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $status; | protected $status; | ||||
protected $content; | protected $content; | ||||
protected $contentSource; | protected $contentSource; | ||||
protected $viewPolicy; | |||||
protected $editPolicy; | |||||
protected $voteCount; | protected $voteCount; | ||||
protected $answerCount; | protected $answerCount; | ||||
protected $heat; | protected $heat; | ||||
protected $mailKey; | protected $mailKey; | ||||
private $answers; | private $answers; | ||||
private $vote; | private $vote; | ||||
private $comments; | private $comments; | ||||
public static function initializeNewQuestion(PhabricatorUser $actor) { | |||||
$app = id(new PhabricatorApplicationQuery()) | |||||
->setViewer($actor) | |||||
->withClasses(array('PhabricatorPonderApplication')) | |||||
->executeOne(); | |||||
$view_policy = $app->getPolicy( | |||||
PonderQuestionDefaultViewCapability::CAPABILITY); | |||||
$edit_policy = $app->getPolicy( | |||||
PonderQuestionDefaultEditCapability::CAPABILITY); | |||||
return id(new PonderQuestion()) | |||||
->setAuthorPHID($actor->getPHID()) | |||||
->setViewPolicy($view_policy) | |||||
->setEditPolicy($edit_policy) | |||||
->setStatus(PonderQuestionStatus::STATUS_OPEN) | |||||
->setVoteCount(0) | |||||
->setAnswerCount(0) | |||||
->setHeat(0.0); | |||||
} | |||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'title' => 'text255', | 'title' => 'text255', | ||||
'voteCount' => 'sint32', | 'voteCount' => 'sint32', | ||||
'status' => 'uint32', | 'status' => 'uint32', | ||||
'content' => 'text', | 'content' => 'text', | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
); | ); | ||||
} | } | ||||
public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
$policy = PhabricatorPolicies::POLICY_NOONE; | |||||
switch ($capability) { | switch ($capability) { | ||||
case PhabricatorPolicyCapability::CAN_VIEW: | case PhabricatorPolicyCapability::CAN_VIEW: | ||||
$policy = PhabricatorPolicies::POLICY_USER; | return $this->getViewPolicy(); | ||||
break; | case PhabricatorPolicyCapability::CAN_EDIT: | ||||
return $this->getEditPolicy(); | |||||
} | } | ||||
return $policy; | |||||
} | } | ||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
return ($viewer->getPHID() == $this->getAuthorPHID()); | return ($viewer->getPHID() == $this->getAuthorPHID()); | ||||
} | } | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |