diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 0fc2fe7e95..07fe9c24c4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2575,7 +2575,7 @@ phutil_register_library_map(array( 'PonderQuestionDetailView' => 'AphrontView', 'PonderQuestionEditor' => 'PhabricatorEditor', 'PonderQuestionPreviewController' => 'PonderController', - 'PonderQuestionQuery' => 'PhabricatorOffsetPagedQuery', + 'PonderQuestionQuery' => 'PhabricatorCursorPagedPolicyQuery', 'PonderQuestionSummaryView' => 'AphrontView', 'PonderQuestionViewController' => 'PonderController', 'PonderReplyHandler' => 'PhabricatorMailReplyHandler', diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index e60a3b5226..730d9318a2 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -503,6 +503,7 @@ final class PhabricatorObjectHandleData { break; case PhabricatorPHIDConstants::PHID_TYPE_QUES: $questions = id(new PonderQuestionQuery()) + ->setViewer($this->viewer) ->withPHIDs($phids) ->execute(); $questions = mpull($questions, null, 'getPHID'); diff --git a/src/applications/ponder/controller/PonderFeedController.php b/src/applications/ponder/controller/PonderFeedController.php index baa14bea08..99fb4e4f83 100644 --- a/src/applications/ponder/controller/PonderFeedController.php +++ b/src/applications/ponder/controller/PonderFeedController.php @@ -34,7 +34,8 @@ final class PonderFeedController extends PonderController { $pager->setOffset($request->getStr('offset')); $pager->setURI($request->getRequestURI(), 'offset'); - $query = new PonderQuestionQuery(); + $query = id(new PonderQuestionQuery()) + ->setViewer($user); if ($this->page == 'feed') { $query diff --git a/src/applications/ponder/query/PonderQuestionQuery.php b/src/applications/ponder/query/PonderQuestionQuery.php index 713f9386fc..c942c1ad4c 100644 --- a/src/applications/ponder/query/PonderQuestionQuery.php +++ b/src/applications/ponder/query/PonderQuestionQuery.php @@ -1,6 +1,7 @@ setViewer($viewer) ->withIDs(array($id)) ->execute(), $id); } @@ -47,6 +49,7 @@ final class PonderQuestionQuery extends PhabricatorOffsetPagedQuery { return array_shift(id(new PonderQuestionQuery()) ->withPHIDs(array($phid)) + ->setViewer($viewer) ->execute()); } @@ -65,6 +68,8 @@ final class PonderQuestionQuery extends PhabricatorOffsetPagedQuery { $where[] = qsprintf($conn_r, 'q.authorPHID IN (%Ls)', $this->authorPHIDs); } + $where[] = $this->buildPagingClause($conn_r); + return $this->formatWhereClause($where); } @@ -79,7 +84,7 @@ final class PonderQuestionQuery extends PhabricatorOffsetPagedQuery { } } - public function execute() { + public function loadPage() { $question = new PonderQuestion(); $conn_r = $question->establishConnection('r'); diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index 09f20807ce..078d37f524 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -4,7 +4,8 @@ final class PonderQuestion extends PonderDAO implements PhabricatorMarkupInterface, PonderVotableInterface, - PhabricatorSubscribableInterface { + PhabricatorSubscribableInterface, + PhabricatorPolicyInterface { const MARKUP_FIELD_CONTENT = 'markup:content'; @@ -168,4 +169,26 @@ final class PonderQuestion extends PonderDAO return parent::save(); } + public function getCapabilities() { + return array( + PhabricatorPolicyCapability::CAN_VIEW, + ); + } + + public function getPolicy($capability) { + $policy = PhabricatorPolicies::POLICY_NOONE; + + switch ($capability) { + case PhabricatorPolicyCapability::CAN_VIEW: + $policy = PhabricatorPolicies::POLICY_USER; + break; + } + + return $policy; + } + + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { + return false; + } + }