@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 108 lines 3.5 kB view raw
1<?php 2 3final class ConpherenceColumnViewController extends 4 ConpherenceController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $user = $request->getUser(); 8 9 $latest_conpherences = array(); 10 $latest_participant = id(new ConpherenceParticipantQuery()) 11 ->withParticipantPHIDs(array($user->getPHID())) 12 ->setLimit(8) 13 ->execute(); 14 if ($latest_participant) { 15 $conpherence_phids = mpull($latest_participant, 'getConpherencePHID'); 16 $latest_conpherences = id(new ConpherenceThreadQuery()) 17 ->setViewer($user) 18 ->withPHIDs($conpherence_phids) 19 ->needProfileImage(true) 20 ->execute(); 21 $latest_conpherences = mpull($latest_conpherences, null, 'getPHID'); 22 $latest_conpherences = array_select_keys( 23 $latest_conpherences, 24 $conpherence_phids); 25 } 26 27 $conpherence = null; 28 $should_404 = false; 29 if ($request->getInt('id')) { 30 $conpherence = id(new ConpherenceThreadQuery()) 31 ->setViewer($user) 32 ->withIDs(array($request->getInt('id'))) 33 ->needProfileImage(true) 34 ->needTransactions(true) 35 ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT) 36 ->executeOne(); 37 $should_404 = true; 38 } else if ($latest_participant) { 39 $participant = head($latest_participant); 40 $conpherence = id(new ConpherenceThreadQuery()) 41 ->setViewer($user) 42 ->withPHIDs(array($participant->getConpherencePHID())) 43 ->needProfileImage(true) 44 ->needTransactions(true) 45 ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT) 46 ->executeOne(); 47 $should_404 = true; 48 } 49 50 $durable_column = id(new ConpherenceDurableColumnView()) 51 ->setUser($user) 52 ->setVisible(true); 53 if (!$conpherence) { 54 if ($should_404) { 55 return new Aphront404Response(); 56 } 57 58 $conpherence_id = null; 59 $conpherence_phid = null; 60 $latest_transaction_id = null; 61 $can_edit = false; 62 63 } else { 64 $this->setConpherence($conpherence); 65 66 $participant = $conpherence->getParticipant($user->getPHID()); 67 $transactions = $conpherence->getTransactions(); 68 $latest_transaction = head($transactions); 69 $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites(); 70 $participant->markUpToDate($conpherence); 71 unset($write_guard); 72 73 $draft = PhabricatorDraft::newFromUserAndKey( 74 $user, 75 $conpherence->getPHID()); 76 77 $durable_column 78 ->setDraft($draft) 79 ->setSelectedConpherence($conpherence) 80 ->setConpherences($latest_conpherences); 81 $conpherence_id = $conpherence->getID(); 82 $conpherence_phid = $conpherence->getPHID(); 83 $latest_transaction_id = $latest_transaction->getID(); 84 $can_edit = PhabricatorPolicyFilter::hasCapability( 85 $user, 86 $conpherence, 87 PhabricatorPolicyCapability::CAN_EDIT); 88 } 89 90 $dropdown_query = id(new AphlictDropdownDataQuery()) 91 ->setViewer($user); 92 $dropdown_query->execute(); 93 $response = array( 94 'content' => hsprintf('%s', $durable_column), 95 'threadID' => $conpherence_id, 96 'threadPHID' => $conpherence_phid, 97 'latestTransactionID' => $latest_transaction_id, 98 'canEdit' => $can_edit, 99 'aphlictDropdownData' => array( 100 $dropdown_query->getNotificationData(), 101 $dropdown_query->getConpherenceData(), 102 ), 103 ); 104 105 return id(new AphrontAjaxResponse())->setContent($response); 106 } 107 108}