• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP PhabricatorSubscribersQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中PhabricatorSubscribersQuery的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorSubscribersQuery类的具体用法?PHP PhabricatorSubscribersQuery怎么用?PHP PhabricatorSubscribersQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PhabricatorSubscribersQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     // NOTE: We require CAN_EDIT to view this page.
     $document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needDocumentBodies(true)->needContributors(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$document) {
         return new Aphront404Response();
     }
     $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($document->getPHID());
     $document_body = $document->getDocumentBody();
     $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
     $engine->addObject($document_body, LegalpadDocumentBody::MARKUP_FIELD_TEXT);
     $timeline = $this->buildTransactionTimeline($document, new LegalpadTransactionQuery(), $engine);
     $title = $document_body->getTitle();
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($document);
     $actions = $this->buildActionView($document);
     $properties = $this->buildPropertyView($document, $engine, $actions);
     $comment_form_id = celerity_generate_unique_node_id();
     $add_comment = $this->buildAddCommentView($document, $comment_form_id);
     $crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
     $crumbs->addTextCrumb($document->getMonogram(), '/' . $document->getMonogram());
     $crumbs->addTextCrumb(pht('Manage'));
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties)->addPropertyList($this->buildDocument($engine, $document_body));
     $content = array($crumbs, $object_box, $timeline, $add_comment);
     return $this->buildApplicationPage($content, array('title' => $title, 'pageObjects' => array($document->getPHID())));
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:27,代码来源:LegalpadDocumentManageController.php


示例2: handlePropertyEvent

 private function handlePropertyEvent($event)
 {
     $user = $event->getUser();
     $object = $event->getValue('object');
     if (!$object || !$object->getPHID()) {
         // No object, or the object has no PHID yet..
         return;
     }
     if (!$object instanceof PhabricatorSubscribableInterface) {
         // This object isn't subscribable.
         return;
     }
     if (!$object->shouldShowSubscribersProperty()) {
         // This object doesn't render subscribers in its property list.
         return;
     }
     $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($object->getPHID());
     if ($subscribers) {
         $handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs($subscribers)->execute();
     } else {
         $handles = array();
     }
     $sub_view = id(new SubscriptionListStringBuilder())->setObjectPHID($object->getPHID())->setHandles($handles)->buildPropertyString();
     $view = $event->getValue('view');
     $view->addProperty(pht('Subscribers'), $sub_view);
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:26,代码来源:PhabricatorSubscriptionsUIEventListener.php


示例3: performMerge

 private function performMerge(ManiphestTask $task, PhabricatorObjectHandle $handle, array $phids)
 {
     $user = $this->getRequest()->getUser();
     $response = id(new AphrontReloadResponse())->setURI($handle->getURI());
     $phids = array_fill_keys($phids, true);
     unset($phids[$task->getPHID()]);
     // Prevent merging a task into itself.
     if (!$phids) {
         return $response;
     }
     $targets = id(new ManiphestTaskQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withPHIDs(array_keys($phids))->needSubscriberPHIDs(true)->needProjectPHIDs(true)->execute();
     if (empty($targets)) {
         return $response;
     }
     $editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($this->getRequest())->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
     $cc_vector = array();
     // since we loaded this via a generic object query, go ahead and get the
     // attach the subscriber and project phids now
     $task->attachSubscriberPHIDs(PhabricatorSubscribersQuery::loadSubscribersForPHID($task->getPHID()));
     $task->attachProjectPHIDs(PhabricatorEdgeQuery::loadDestinationPHIDs($task->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST));
     $cc_vector[] = $task->getSubscriberPHIDs();
     foreach ($targets as $target) {
         $cc_vector[] = $target->getSubscriberPHIDs();
         $cc_vector[] = array($target->getAuthorPHID(), $target->getOwnerPHID());
         $merged_into_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)->setNewValue($task->getPHID());
         $editor->applyTransactions($target, array($merged_into_txn));
     }
     $all_ccs = array_mergev($cc_vector);
     $all_ccs = array_filter($all_ccs);
     $all_ccs = array_unique($all_ccs);
     $add_ccs = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('=' => $all_ccs));
     $merged_from_txn = id(new ManiphestTransaction())->setTransactionType(ManiphestTransaction::TYPE_MERGED_FROM)->setNewValue(mpull($targets, 'getPHID'));
     $editor->applyTransactions($task, array($add_ccs, $merged_from_txn));
     return $response;
 }
开发者ID:barcelonascience,项目名称:phabricator,代码行数:35,代码来源:PhabricatorSearchAttachController.php


示例4: readValueFromRevision

 protected function readValueFromRevision(DifferentialRevision $revision)
 {
     if (!$revision->getPHID()) {
         return array();
     }
     return PhabricatorSubscribersQuery::loadSubscribersForPHID($revision->getPHID());
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:DifferentialSubscribersField.php


示例5: getHeraldFieldValue

 public function getHeraldFieldValue($object)
 {
     $revision = $this->getAdapter()->getRevision();
     if (!$revision) {
         return array();
     }
     $phid = $revision->getPHID();
     return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
 }
开发者ID:ThomasWo,项目名称:phabricator,代码行数:9,代码来源:DiffusionPreCommitContentRevisionSubscribersHeraldField.php


示例6: indexSubscribers

 protected function indexSubscribers(PhabricatorSearchAbstractDocument $doc)
 {
     $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($doc->getPHID());
     $handles = id(new PhabricatorHandleQuery())->setViewer($this->getViewer())->withPHIDs($subscribers)->execute();
     foreach ($handles as $phid => $handle) {
         $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $phid, $handle->getType(), $doc->getDocumentModified());
         // Bogus timestamp.
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:9,代码来源:PhabricatorSearchDocumentIndexer.php


示例7: save

 public function save()
 {
     if (!$this->comment) {
         throw new Exception("Must set comment before saving it");
     }
     if (!$this->question) {
         throw new Exception("Must set question before saving comment");
     }
     if (!$this->targetPHID) {
         throw new Exception("Must set target before saving comment");
     }
     if (!$this->viewer) {
         throw new Exception("Must set viewer before saving comment");
     }
     $comment = $this->comment;
     $question = $this->question;
     $target = $this->targetPHID;
     $viewer = $this->viewer;
     $comment->save();
     $question->attachRelated();
     PhabricatorSearchPonderIndexer::indexQuestion($question);
     // subscribe author and @mentions
     $subeditor = id(new PhabricatorSubscriptionsEditor())->setObject($question)->setUser($viewer);
     $subeditor->subscribeExplicit(array($comment->getAuthorPHID()));
     $content = $comment->getContent();
     $at_mention_phids = PhabricatorMarkupEngine::extractPHIDsFromMentions(array($content));
     $subeditor->subscribeImplicit($at_mention_phids);
     $subeditor->save();
     if ($this->shouldEmail) {
         // now load subscribers, including implicitly-added @mention victims
         $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($question->getPHID());
         // @mention emails (but not for anyone who has explicitly unsubscribed)
         if (array_intersect($at_mention_phids, $subscribers)) {
             id(new PonderMentionMail($question, $comment, $viewer))->setToPHIDs($at_mention_phids)->send();
         }
         if ($target === $question->getPHID()) {
             $target = $question;
         } else {
             $answers_by_phid = mgroup($question->getAnswers(), 'getPHID');
             $target = head($answers_by_phid[$target]);
         }
         // only send emails to others in the same thread
         $thread = mpull($target->getComments(), 'getAuthorPHID');
         $thread[] = $target->getAuthorPHID();
         $thread[] = $question->getAuthorPHID();
         $other_subs = array_diff(array_intersect($thread, $subscribers), $at_mention_phids);
         // 'Comment' emails for subscribers who are in the same comment thread,
         // including the author of the parent question and/or answer, excluding
         // @mentions (and excluding the author, depending on their MetaMTA
         // settings).
         if ($other_subs) {
             id(new PonderCommentMail($question, $comment, $viewer))->setToPHIDs($other_subs)->send();
         }
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:55,代码来源:PonderCommentEditor.php


示例8: buildCurtainPanel

 public function buildCurtainPanel($object)
 {
     $viewer = $this->getViewer();
     $object_phid = $object->getPHID();
     $subscriber_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($object_phid);
     $handles = $viewer->loadHandles($subscriber_phids);
     // TODO: This class can't accept a HandleList yet.
     $handles = iterator_to_array($handles);
     $susbscribers_view = id(new SubscriptionListStringBuilder())->setObjectPHID($object_phid)->setHandles($handles)->buildPropertyString();
     return $this->newPanel()->setHeaderText(pht('Subscribers'))->setOrder(20000)->appendChild($susbscribers_view);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:11,代码来源:PhabricatorSubscriptionsCurtainExtension.php


示例9: buildCustomEditFields

 public function buildCustomEditFields(PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object)
 {
     $subscribers_type = PhabricatorTransactions::TYPE_SUBSCRIBERS;
     $object_phid = $object->getPHID();
     if ($object_phid) {
         $sub_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($object_phid);
     } else {
         $sub_phids = array();
     }
     $subscribers_field = id(new PhabricatorSubscribersEditField())->setKey('subscriberPHIDs')->setLabel(pht('Subscribers'))->setEditTypeKey('subscribers')->setDescription(pht('Manage subscribers.'))->setAliases(array('subscriber', 'subscribers'))->setIsCopyable(true)->setUseEdgeTransactions(true)->setEdgeTransactionDescriptions(pht('Add subscribers.'), pht('Remove subscribers.'), pht('Set subscribers, overwriting current value.'))->setCommentActionLabel(pht('Change Subscribers'))->setTransactionType($subscribers_type)->setValue($sub_phids);
     return array($subscribers_field);
 }
开发者ID:AceMood,项目名称:phabricator,代码行数:12,代码来源:PhabricatorSubscriptionsEditEngineExtension.php


示例10: indexFulltextObject

 public function indexFulltextObject($object, PhabricatorSearchAbstractDocument $document)
 {
     $subscriber_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($object->getPHID());
     if (!$subscriber_phids) {
         return;
     }
     $handles = id(new PhabricatorHandleQuery())->setViewer($this->getViewer())->withPHIDs($subscriber_phids)->execute();
     foreach ($handles as $phid => $handle) {
         $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $phid, $handle->getType(), $document->getDocumentModified());
         // Bogus timestamp.
     }
 }
开发者ID:phpengineer,项目名称:phabricator,代码行数:12,代码来源:PhabricatorSubscriptionsFulltextEngineExtension.php


示例11: saveAnswer

 public function saveAnswer()
 {
     if (!$this->viewer) {
         throw new Exception("Must set user before saving question");
     }
     if (!$this->question) {
         throw new Exception("Must set question before saving answer");
     }
     if (!$this->answer) {
         throw new Exception("Must set answer before saving it");
     }
     $question = $this->question;
     $answer = $this->answer;
     $viewer = $this->viewer;
     $conn = $answer->establishConnection('w');
     $trans = $conn->openTransaction();
     $trans->beginReadLocking();
     $question->reload();
     queryfx($conn, 'UPDATE %T as t
     SET t.`answerCount` = t.`answerCount` + 1
     WHERE t.`PHID` = %s', $question->getTableName(), $question->getPHID());
     $answer->setQuestionID($question->getID());
     $answer->save();
     $trans->endReadLocking();
     $trans->saveTransaction();
     $question->attachRelated();
     PhabricatorSearchPonderIndexer::indexQuestion($question);
     // subscribe author and @mentions
     $subeditor = id(new PhabricatorSubscriptionsEditor())->setObject($question)->setUser($viewer);
     $subeditor->subscribeExplicit(array($answer->getAuthorPHID()));
     $content = $answer->getContent();
     $at_mention_phids = PhabricatorMarkupEngine::extractPHIDsFromMentions(array($content));
     $subeditor->subscribeImplicit($at_mention_phids);
     $subeditor->save();
     if ($this->shouldEmail) {
         // now load subscribers, including implicitly-added @mention victims
         $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($question->getPHID());
         // @mention emails (but not for anyone who has explicitly unsubscribed)
         if (array_intersect($at_mention_phids, $subscribers)) {
             id(new PonderMentionMail($question, $answer, $viewer))->setToPHIDs($at_mention_phids)->send();
         }
         $other_subs = array_diff($subscribers, $at_mention_phids);
         // 'Answered' emails for subscribers who are not @mentiond (and excluding
         // author depending on their MetaMTA settings).
         if ($other_subs) {
             id(new PonderAnsweredMail($question, $answer, $viewer))->setToPHIDs($other_subs)->send();
         }
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:49,代码来源:PonderAnswerEditor.php


示例12: getHeraldField

 public function getHeraldField($field)
 {
     switch ($field) {
         case self::FIELD_TITLE:
             return $this->getMock()->getName();
         case self::FIELD_BODY:
             return $this->getMock()->getDescription();
         case self::FIELD_AUTHOR:
             return $this->getMock()->getAuthorPHID();
         case self::FIELD_CC:
             return PhabricatorSubscribersQuery::loadSubscribersForPHID($this->getMock()->getPHID());
         case self::FIELD_PROJECTS:
             return PhabricatorEdgeQuery::loadDestinationPHIDs($this->getMock()->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
     }
     return parent::getHeraldField($field);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:16,代码来源:HeraldPholioMockAdapter.php


示例13: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $phid = $this->phid;
     $object = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
     if ($object instanceof PhabricatorSubscribableInterface) {
         $subscriber_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
     }
     $handle_phids = $subscriber_phids;
     $handle_phids[] = $phid;
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($handle_phids)->execute();
     $object_handle = $handles[$phid];
     $dialog = id(new SubscriptionListDialogBuilder())->setViewer($viewer)->setTitle(pht('Subscribers'))->setObjectPHID($phid)->setHandles($handles)->buildDialog();
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:16,代码来源:PhabricatorSubscriptionsListController.php


示例14: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $object = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs(array($request->getURIData('phid')))->executeOne();
     if (!$object) {
         return new Aphront404Response();
     }
     if (!$object instanceof PhabricatorSubscribableInterface) {
         return new Aphront404Response();
     }
     $phid = $object->getPHID();
     $handle_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
     $handle_phids[] = $phid;
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($handle_phids)->execute();
     $object_handle = $handles[$phid];
     $dialog = id(new SubscriptionListDialogBuilder())->setViewer($viewer)->setTitle(pht('Subscribers'))->setObjectPHID($phid)->setHandles($handles)->buildDialog();
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:18,代码来源:PhabricatorSubscriptionsListController.php


示例15: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     // NOTE: We require CAN_EDIT to view this page.
     $document = id(new LegalpadDocumentQuery())->setViewer($user)->withIDs(array($this->id))->needDocumentBodies(true)->needContributors(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$document) {
         return new Aphront404Response();
     }
     $xactions = id(new LegalpadTransactionQuery())->setViewer($user)->withObjectPHIDs(array($document->getPHID()))->execute();
     $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($document->getPHID());
     $document_body = $document->getDocumentBody();
     $phids = array();
     $phids[] = $document_body->getCreatorPHID();
     foreach ($subscribers as $subscriber) {
         $phids[] = $subscriber;
     }
     foreach ($document->getContributors() as $contributor) {
         $phids[] = $contributor;
     }
     $this->loadHandles($phids);
     $engine = id(new PhabricatorMarkupEngine())->setViewer($user);
     $engine->addObject($document_body, LegalpadDocumentBody::MARKUP_FIELD_TEXT);
     foreach ($xactions as $xaction) {
         if ($xaction->getComment()) {
             $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
         }
     }
     $engine->process();
     $title = $document_body->getTitle();
     $header = id(new PHUIHeaderView())->setHeader($title)->setUser($user)->setPolicyObject($document);
     $actions = $this->buildActionView($document);
     $properties = $this->buildPropertyView($document, $engine, $actions);
     $comment_form_id = celerity_generate_unique_node_id();
     $xaction_view = id(new LegalpadTransactionView())->setUser($this->getRequest()->getUser())->setObjectPHID($document->getPHID())->setTransactions($xactions)->setMarkupEngine($engine);
     $add_comment = $this->buildAddCommentView($document, $comment_form_id);
     $crumbs = $this->buildApplicationCrumbs($this->buildSideNav());
     $crumbs->setActionList($actions);
     $crumbs->addTextCrumb($document->getMonogram(), '/' . $document->getMonogram());
     $crumbs->addTextCrumb(pht('Manage'));
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties)->addPropertyList($this->buildDocument($engine, $document_body));
     $content = array($crumbs, $object_box, $xaction_view, $add_comment);
     return $this->buildApplicationPage($content, array('title' => $title, 'pageObjects' => array($document->getPHID())));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:44,代码来源:LegalpadDocumentManageController.php


示例16: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $question = PonderQuestionQuery::loadSingle($user, $this->questionID);
     if (!$question) {
         return new Aphront404Response();
     }
     $question->attachRelated();
     $question->attachVotes($user->getPHID());
     $object_phids = array($user->getPHID(), $question->getAuthorPHID());
     $answers = $question->getAnswers();
     $comments = $question->getComments();
     foreach ($comments as $comment) {
         $object_phids[] = $comment->getAuthorPHID();
     }
     foreach ($answers as $answer) {
         $object_phids[] = $answer->getAuthorPHID();
         $comments = $answer->getComments();
         foreach ($comments as $comment) {
             $object_phids[] = $comment->getAuthorPHID();
         }
     }
     $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID($question->getPHID());
     $object_phids = array_merge($object_phids, $subscribers);
     $handles = $this->loadViewerHandles($object_phids);
     $this->loadHandles($object_phids);
     $detail_panel = new PonderQuestionDetailView();
     $detail_panel->setQuestion($question)->setUser($user)->setHandles($handles);
     $responses_panel = new PonderAnswerListView();
     $responses_panel->setQuestion($question)->setHandles($handles)->setUser($user)->setAnswers($answers);
     $answer_add_panel = new PonderAddAnswerView();
     $answer_add_panel->setQuestion($question)->setUser($user)->setActionURI("/ponder/answer/add/");
     $header = id(new PhabricatorHeaderView())->setObjectName('Q' . $question->getID())->setHeader($question->getTitle());
     $actions = $this->buildActionListView($question);
     $properties = $this->buildPropertyListView($question, $subscribers);
     $nav = $this->buildSideNavView($question);
     $nav->appendChild(array($header, $actions, $properties, $detail_panel, $responses_panel, $answer_add_panel));
     $nav->selectFilter(null);
     return $this->buildApplicationPage($nav, array('device' => true, 'title' => 'Q' . $question->getID() . ' ' . $question->getTitle()));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:41,代码来源:PonderQuestionViewController.php


示例17: loadSubscribers

 private function loadSubscribers(PhabricatorLiskDAO $object)
 {
     if ($object->getPHID() && $object instanceof PhabricatorSubscribableInterface) {
         $subs = PhabricatorSubscribersQuery::loadSubscribersForPHID($object->getPHID());
         $this->subscribers = array_fuse($subs);
     } else {
         $this->subscribers = array();
     }
 }
开发者ID:sethkontny,项目名称:phabricator,代码行数:9,代码来源:PhabricatorApplicationTransactionEditor.php


示例18: getUsersToNotifyOfTokenGiven

 public function getUsersToNotifyOfTokenGiven()
 {
     return PhabricatorSubscribersQuery::loadSubscribersForPHID($this->phid);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:4,代码来源:PhrictionDocument.php


示例19: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $current_version = null;
     if ($id) {
         $document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needContent(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
         if (!$document) {
             return new Aphront404Response();
         }
         $current_version = $document->getContent()->getVersion();
         $revert = $request->getInt('revert');
         if ($revert) {
             $content = id(new PhrictionContent())->loadOneWhere('documentID = %d AND version = %d', $document->getID(), $revert);
             if (!$content) {
                 return new Aphront404Response();
             }
         } else {
             $content = $document->getContent();
         }
     } else {
         $slug = $request->getStr('slug');
         $slug = PhabricatorSlug::normalize($slug);
         if (!$slug) {
             return new Aphront404Response();
         }
         $document = id(new PhrictionDocumentQuery())->setViewer($viewer)->withSlugs(array($slug))->needContent(true)->executeOne();
         if ($document) {
             $content = $document->getContent();
             $current_version = $content->getVersion();
         } else {
             $document = PhrictionDocument::initializeNewDocument($viewer, $slug);
             $content = $document->getContent();
         }
     }
     if ($request->getBool('nodraft')) {
         $draft = null;
         $draft_key = null;
     } else {
         if ($document->getPHID()) {
             $draft_key = $document->getPHID() . ':' . $content->getVersion();
         } else {
             $draft_key = 'phriction:' . $content->getSlug();
         }
         $draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $viewer->getPHID(), $draft_key);
     }
     if ($draft && strlen($draft->getDraft()) && $draft->getDraft() != $content->getContent()) {
         $content_text = $draft->getDraft();
         $discard = phutil_tag('a', array('href' => $request->getRequestURI()->alter('nodraft', true)), pht('discard this draft'));
         $draft_note = new PHUIInfoView();
         $draft_note->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
         $draft_note->setTitle(pht('Recovered Draft'));
         $draft_note->appendChild(hsprintf('<p>%s</p>', pht('Showing a saved draft of your edits, you can %s.', $discard)));
     } else {
         $content_text = $content->getContent();
         $draft_note = null;
     }
     require_celerity_resource('phriction-document-css');
     $e_title = true;
     $e_content = true;
     $validation_exception = null;
     $notes = null;
     $title = $content->getTitle();
     $overwrite = false;
     $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID($document->getPHID());
     if ($request->isFormPost()) {
         $title = $request->getStr('title');
         $content_text = $request->getStr('content');
         $notes = $request->getStr('description');
         $current_version = $request->getInt('contentVersion');
         $v_view = $request->getStr('viewPolicy');
         $v_edit = $request->getStr('editPolicy');
         $v_cc = $request->getArr('cc');
         $xactions = array();
         $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_TITLE)->setNewValue($title);
         $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhrictionTransaction::TYPE_CONTENT)->setNewValue($content_text);
         $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($v_view);
         $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($v_edit);
         $xactions[] = id(new PhrictionTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('=' => $v_cc));
         $editor = id(new PhrictionTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setDescription($notes)->setProcessContentVersionError(!$request->getBool('overwrite'))->setContentVersion($current_version);
         try {
             $editor->applyTransactions($document, $xactions);
             if ($draft) {
                 $draft->delete();
             }
             $uri = PhrictionDocument::getSlugURI($document->getSlug());
             return id(new AphrontRedirectResponse())->setURI($uri);
         } catch (PhabricatorApplicationTransactionValidationException $ex) {
             $validation_exception = $ex;
             $e_title = nonempty($ex->getShortMessage(PhrictionTransaction::TYPE_TITLE), true);
             $e_content = nonempty($ex->getShortMessage(PhrictionTransaction::TYPE_CONTENT), true);
             // if we're not supposed to process the content version error, then
             // overwrite that content...!
             if (!$editor->getProcessContentVersionError()) {
                 $overwrite = true;
             }
             $document->setViewPolicy($v_view);
             $document->setEditPolicy($v_edit);
         }
     }
//.........这里部分代码省略.........
开发者ID:rchicoli,项目名称:phabricator,代码行数:101,代码来源:PhrictionEditController.php


示例20: buildEditFields

 protected final function buildEditFields($object)
 {
     $viewer = $this->getViewer();
     $editor = $object->getApplicationTransactionEditor();
     $types = $editor->getTransactionTypesForObject($object);
     $types = array_fuse($types);
     $fields = $this->buildCustomEditFields($object);
     if ($object instanceof PhabricatorPolicyInterface) {
         $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($object)->execute();
         $map = array(PhabricatorTransactions::TYPE_VIEW_POLICY => array('key' => 'policy.view', 'aliases' => array('view'), 'capability' => PhabricatorPolicyCapability::CAN_VIEW, 'label' => pht('View Policy'), 'description' => pht('Controls who can view the object.'), 'edit' => 'view'), PhabricatorTransactions::TYPE_EDIT_POLICY => array('key' => 'policy.edit', 'aliases' => array('edit'), 'capability' => PhabricatorPolicyCapability::CAN_EDIT, 'label' => pht('Edit Policy'), 'description' => pht('Controls who can edit the object.'), 'edit' => 'edit'), PhabricatorTransactions::TYPE_JOIN_POLICY => array('key' => 'policy.join', 'aliases' => array('join'), 'capability' => PhabricatorPolicyCapability::CAN_JOIN, 'label' => pht('Join Policy'), 'description' => pht('Controls who can join the object.'), 'edit' => 'join'));
         foreach ($map as $type => $spec) {
             if (empty($types[$type])) {
                 continue;
             }
             $capability = $spec['capability'];
             $key = $spec['key'];
             $aliases = $spec['aliases'];
             $label = $spec['label'];
             $description = $spec['description'];
             $edit = $spec['edit'];
             $policy_field = id(new PhabricatorPolicyEditField())->setKey($key)->setLabel($label)->setDescription($description)->setAliases($aliases)->setCapability($capability)->setPolicies($policies)->setTransactionType($type)->setEditTypeKey($edit)->setValue($object->getPolicy($capability));
             $fields[] = $policy_field;
             if ($object instanceof PhabricatorSpacesInterface) {
                 if ($capability == PhabricatorPolicyCapability::CAN_VIEW) {
                     $type_space = PhabricatorTransactions::TYPE_SPACE;
                     if (isset($types[$type_space])) {
                         $space_field = id(new PhabricatorSpaceEditField())->setKey('spacePHID')->setLabel(pht('Space'))->setEditTypeKey('space')->setDescription(pht('Shifts the object in the Spaces application.'))->setAliases(array('space', 'policy.space'))->setTransactionType($type_space)->setValue($object->getSpacePHID());
                         $fields[] = $space_field;
                         $policy_field->setSpaceField($space_field);
                     }
                 }
             }
         }
     }
     $edge_type = PhabricatorTransactions::TYPE_EDGE;
     $object_phid = $object->getPHID();
     $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
     if ($object instanceof PhabricatorProjectInterface) {
         if (isset($types[$edge_type])) {
             if ($object_phid) {
                 $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($object_phid, $project_edge_type);
                 $project_phids = array_reverse($project_phids);
             } else {
                 $project_phids = array();
             }
             $edge_field = id(new PhabricatorProjectsEditField())->setKey('projectPHIDs')->setLabel(pht('Projects'))->setEditTypeKey('projects')->setDescription(pht('Add or remove associated projects.'))->setAliases(array('project', 'projects'))->setTransactionType($edge_type)->setMetadataValue('edge:type', $project_edge_type)->setValue($project_phids);
             $fields[] = $edge_field;
         }
     }
     $subscribers_type = PhabricatorTransactions::TYPE_SUBSCRIBERS;
     if ($object instanceof PhabricatorSubscribableInterface) {
         if (isset($types[$subscribers_type])) {
             if ($object_phid) {
                 $sub_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($object_phid);
             } else {
                 // TODO: Allow applications to provide default subscribers; Maniphest
                 // does this at a minimum.
                 $sub_phids = array();
             }
             $subscribers_field = id(new PhabricatorSubscribersEditField())->setKey('subscriberPHIDs')->setLabel(pht('Subscribers'))->setEditTypeKey('subscribers')->setDescription(pht('Manage subscribers.'))->setAliases(array('subscriber', 'subscribers'))->setTransactionType($subscribers_type)->setValue($sub_phids);
             $fields[] = $subscribers_field;
         }
     }
     foreach ($fields as $field) {
         $field->setViewer($viewer)->setObject($object);
     }
     return $fields;
 }
开发者ID:paladox,项目名称:phabricator,代码行数:68,代码来源:PhabricatorApplicationEditEngine.php



注:本文中的PhabricatorSubscribersQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP PhabricatorTime类代码示例发布时间:2022-05-23
下一篇:
PHP PhabricatorSpacesNamespaceQuery类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap