当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorSubscribersQuery类代码示例

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


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


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