public static function createThread(PhabricatorUser $creator, array $participant_phids, $title, $message, PhabricatorContentSource $source) { $conpherence = ConpherenceThread::initializeNewThread($creator); $files = array(); $errors = array(); if (empty($participant_phids)) { $errors[] = self::ERROR_EMPTY_PARTICIPANTS; } else { $participant_phids[] = $creator->getPHID(); $participant_phids = array_unique($participant_phids); } if (empty($message)) { $errors[] = self::ERROR_EMPTY_MESSAGE; } $file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles($creator, array($message)); if ($file_phids) { $files = id(new PhabricatorFileQuery())->setViewer($creator)->withPHIDs($file_phids)->execute(); } if (!$errors) { $xactions = array(); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => $participant_phids)); if ($files) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_FILES)->setNewValue(array('+' => mpull($files, 'getPHID'))); } if ($title) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_TITLE)->setNewValue($title); } $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new ConpherenceTransactionComment())->setContent($message)->setConpherencePHID($conpherence->getPHID())); id(new ConpherenceEditor())->setActor($creator)->setContentSource($source)->setContinueOnNoEffect(true)->applyTransactions($conpherence, $xactions); } return array($errors, $conpherence); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $title = pht('Conpherence'); $conpherence = null; $limit = ConpherenceThreadListView::SEE_MORE_LIMIT * 5; $all_participation = array(); $mode = $this->determineMode(); switch ($mode) { case self::SELECTED_MODE: $conpherence_id = $request->getURIData('id'); $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($conpherence_id))->executeOne(); if (!$conpherence) { return new Aphront404Response(); } if ($conpherence->getTitle()) { $title = $conpherence->getTitle(); } $cursor = $conpherence->getParticipantIfExists($user->getPHID()); $data = $this->loadDefaultParticipation($limit); $all_participation = $data['all_participation']; if (!$cursor) { $menu_participation = id(new ConpherenceParticipant())->makeEphemeral()->setConpherencePHID($conpherence->getPHID())->setParticipantPHID($user->getPHID()); } else { $menu_participation = $cursor; } $all_participation = array($conpherence->getPHID() => $menu_participation) + $all_participation; break; case self::UNSELECTED_MODE: default: $data = $this->loadDefaultParticipation($limit); $all_participation = $data['all_participation']; break; } $threads = $this->loadConpherenceThreadData($all_participation); $thread_view = id(new ConpherenceThreadListView())->setUser($user)->setBaseURI($this->getApplicationURI())->setThreads($threads); switch ($mode) { case self::SELECTED_MODE: $response = id(new AphrontAjaxResponse())->setContent($thread_view); break; case self::UNSELECTED_MODE: default: $layout = id(new ConpherenceLayoutView())->setUser($user)->setBaseURI($this->getApplicationURI())->setThreadView($thread_view)->setRole('list'); if ($conpherence) { $policy_objects = id(new PhabricatorPolicyQuery())->setViewer($user)->setObject($conpherence)->execute(); $layout->setHeader($this->buildHeaderPaneContent($conpherence, $policy_objects)); $layout->setThread($conpherence); } else { $thread = ConpherenceThread::initializeNewThread($user); $thread->attachHandles(array()); $thread->attachTransactions(array()); $thread->makeEphemeral(); $layout->setHeader($this->buildHeaderPaneContent($thread, array())); } $response = $this->buildApplicationPage($layout, array('title' => $title)); break; } return $response; }
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender) { $users = $this->loadMailUsers($mail); $phids = mpull($users, 'getPHID'); $conpherence = id(new ConpherenceReplyHandler())->setMailReceiver(ConpherenceThread::initializeNewThread($sender))->setMailAddedParticipantPHIDs($phids)->setActor($sender)->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs())->processEmail($mail); if ($conpherence) { $mail->setRelatedPHID($conpherence->getPHID()); } }