Path: blob/master/src/applications/conpherence/controller/ConpherenceColumnViewController.php
12256 views
<?php12final class ConpherenceColumnViewController extends3ConpherenceController {45public function handleRequest(AphrontRequest $request) {6$user = $request->getUser();78$latest_conpherences = array();9$latest_participant = id(new ConpherenceParticipantQuery())10->withParticipantPHIDs(array($user->getPHID()))11->setLimit(8)12->execute();13if ($latest_participant) {14$conpherence_phids = mpull($latest_participant, 'getConpherencePHID');15$latest_conpherences = id(new ConpherenceThreadQuery())16->setViewer($user)17->withPHIDs($conpherence_phids)18->needProfileImage(true)19->execute();20$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');21$latest_conpherences = array_select_keys(22$latest_conpherences,23$conpherence_phids);24}2526$conpherence = null;27$should_404 = false;28if ($request->getInt('id')) {29$conpherence = id(new ConpherenceThreadQuery())30->setViewer($user)31->withIDs(array($request->getInt('id')))32->needProfileImage(true)33->needTransactions(true)34->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)35->executeOne();36$should_404 = true;37} else if ($latest_participant) {38$participant = head($latest_participant);39$conpherence = id(new ConpherenceThreadQuery())40->setViewer($user)41->withPHIDs(array($participant->getConpherencePHID()))42->needProfileImage(true)43->needTransactions(true)44->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)45->executeOne();46$should_404 = true;47}4849$durable_column = id(new ConpherenceDurableColumnView())50->setUser($user)51->setVisible(true);52if (!$conpherence) {53if ($should_404) {54return new Aphront404Response();55}5657$conpherence_id = null;58$conpherence_phid = null;59$latest_transaction_id = null;60$can_edit = false;6162} else {63$this->setConpherence($conpherence);6465$participant = $conpherence->getParticipant($user->getPHID());66$transactions = $conpherence->getTransactions();67$latest_transaction = head($transactions);68$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();69$participant->markUpToDate($conpherence);70unset($write_guard);7172$draft = PhabricatorDraft::newFromUserAndKey(73$user,74$conpherence->getPHID());7576$durable_column77->setDraft($draft)78->setSelectedConpherence($conpherence)79->setConpherences($latest_conpherences);80$conpherence_id = $conpherence->getID();81$conpherence_phid = $conpherence->getPHID();82$latest_transaction_id = $latest_transaction->getID();83$can_edit = PhabricatorPolicyFilter::hasCapability(84$user,85$conpherence,86PhabricatorPolicyCapability::CAN_EDIT);87}8889$dropdown_query = id(new AphlictDropdownDataQuery())90->setViewer($user);91$dropdown_query->execute();92$response = array(93'content' => hsprintf('%s', $durable_column),94'threadID' => $conpherence_id,95'threadPHID' => $conpherence_phid,96'latestTransactionID' => $latest_transaction_id,97'canEdit' => $can_edit,98'aphlictDropdownData' => array(99$dropdown_query->getNotificationData(),100$dropdown_query->getConpherenceData(),101),102);103104return id(new AphrontAjaxResponse())->setContent($response);105}106107}108109110