public function processRequest() { $request = $this->getRequest(); $author_phid = $request->getUser()->getPHID(); $action = $request->getStr('action'); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); $comment = new DifferentialComment(); $comment->setContent($request->getStr('content')); $comment->setAction($action); $comment->setAuthorPHID($author_phid); $handles = array($author_phid); $reviewers = $request->getStr('reviewers'); if (($action == DifferentialAction::ACTION_ADDREVIEWERS || $action == DifferentialAction::ACTION_REQUEST) && $reviewers) { $reviewers = explode(',', $reviewers); $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_REVIEWERS => $reviewers)); $handles = array_merge($handles, $reviewers); } $ccs = $request->getStr('ccs'); if ($action == DifferentialAction::ACTION_ADDCCS && $ccs) { $ccs = explode(',', $ccs); $comment->setMetadata(array(DifferentialComment::METADATA_ADDED_CCS => $ccs)); $handles = array_merge($handles, $ccs); } $handles = id(new PhabricatorObjectHandleData($handles))->loadHandles(); $view = new DifferentialRevisionCommentView(); $view->setUser($request->getUser()); $view->setComment($comment); $view->setHandles($handles); $view->setMarkupEngine($engine); $view->setPreview(true); $view->setTargetDiff(null); $draft = new PhabricatorDraft(); $draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace(); return id(new AphrontAjaxResponse())->setContent($view->render()); }
public static function newFromUserAndKey(PhabricatorUser $user, $key) { if ($user->getPHID() && strlen($key)) { $draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $key); if ($draft) { return $draft; } } $draft = new PhabricatorDraft(); if ($user->getPHID()) { $draft->setAuthorPHID($user->getPHID())->setDraftKey($key); } return $draft; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $comments = $request->getStr('comments'); $task = id(new ManiphestTask())->load($this->id); if (!$task) { return new Aphront404Response(); } $draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $task->getPHID()); if (!$draft) { $draft = new PhabricatorDraft(); $draft->setAuthorPHID($user->getPHID()); $draft->setDraftKey($task->getPHID()); } $draft->setDraft($comments); $draft->save(); $phids = array($user->getPHID()); $action = $request->getStr('action'); $transaction = new ManiphestTransaction(); $transaction->setAuthorPHID($user->getPHID()); $transaction->setComments($comments); $transaction->setTransactionType($action); $value = $request->getStr('value'); switch ($action) { case ManiphestTransactionType::TYPE_OWNER: if (!$value) { $value = $user->getPHID(); } $phids[] = $value; break; case ManiphestTransactionType::TYPE_PRIORITY: $transaction->setOldValue($task->getPriority()); break; } $transaction->setNewValue($value); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $transactions = array(); $transactions[] = $transaction; $engine = PhabricatorMarkupEngine::newManiphestMarkupEngine(); $transaction_view = new ManiphestTransactionListView(); $transaction_view->setTransactions($transactions); $transaction_view->setHandles($handles); $transaction_view->setUser($user); $transaction_view->setMarkupEngine($engine); $transaction_view->setPreview(true); return id(new AphrontAjaxResponse())->setContent($transaction_view->render()); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $paste = id(new PhabricatorPasteQuery())->setViewer($viewer)->withIDs(array($id))->needContent(true)->executeOne(); if (!$paste) { return new Aphront404Response(); } $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($paste->getFilePHID()))->executeOne(); if (!$file) { return new Aphront400Response(); } $forks = id(new PhabricatorPasteQuery())->setViewer($viewer)->withParentPHIDs(array($paste->getPHID()))->execute(); $fork_phids = mpull($forks, 'getPHID'); $header = $this->buildHeaderView($paste); $actions = $this->buildActionView($viewer, $paste, $file); $properties = $this->buildPropertyView($paste, $fork_phids, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $source_code = $this->buildSourceCodeView($paste, null, $this->highlightMap); $source_code = id(new PHUIBoxView())->appendChild($source_code)->addMargin(PHUI::MARGIN_LARGE_LEFT)->addMargin(PHUI::MARGIN_LARGE_RIGHT)->addMargin(PHUI::MARGIN_LARGE_TOP); $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView())->addTextCrumb('P' . $paste->getID(), '/P' . $paste->getID()); $timeline = $this->buildTransactionTimeline($paste, new PhabricatorPasteTransactionQuery()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Eat Paste'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $paste->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($paste->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $paste->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); return $this->buildApplicationPage(array($crumbs, $object_box, $source_code, $timeline, $add_comment_form), array('title' => $paste->getFullName(), 'pageObjects' => array($paste->getPHID()))); }
private function buildCommentForm(PhamePost $post) { $viewer = $this->getViewer(); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $post->getPHID()); $box = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($post->getPHID())->setDraft($draft)->setHeaderText(pht('Add Comment'))->setAction($this->getApplicationURI('post/comment/' . $post->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); return phutil_tag_div('phui-document-view-pro-box', $box); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if (!$request->isFormPost()) { return new Aphront400Response(); } $poll = id(new PhabricatorSlowvoteQuery())->setViewer($user)->withIDs(array($this->id))->executeOne(); if (!$poll) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $view_uri = '/V' . $poll->getID(); $xactions = array(); $xactions[] = id(new PhabricatorSlowvoteTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorSlowvoteTransactionComment())->setContent($request->getStr('comment'))); $editor = id(new PhabricatorSlowvoteEditor())->setActor($user)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($poll, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex); } if ($draft) { $draft->replaceOrDelete(); } if ($request->isAjax() && $is_preview) { return id(new PhabricatorApplicationTransactionResponse())->setViewer($user)->setTransactions($xactions)->setIsPreview($is_preview)->setAnchorOffset($request->getStr('anchor')); } else { return id(new AphrontRedirectResponse())->setURI($view_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withIDs(array($id))->needFiles(true)->executeOne(); if (!$macro) { return new Aphront404Response(); } $title_short = pht('Macro "%s"', $macro->getName()); $title_long = pht('Image Macro "%s"', $macro->getName()); $curtain = $this->buildCurtain($macro); $subheader = $this->buildSubheaderView($macro); $file = $this->buildFileView($macro); $details = $this->buildPropertySectionView($macro); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($macro->getName()); $crumbs->setBorder(true); $timeline = $this->buildTransactionTimeline($macro, new PhabricatorMacroTransactionQuery()); $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($macro)->setHeader($macro->getName())->setHeaderIcon('fa-file-image-o'); if (!$macro->getIsDisabled()) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); $view = id(new PHUITwoColumnView())->setHeader($header)->setSubheader($subheader)->setCurtain($curtain)->setMainColumn(array($timeline, $add_comment_form))->addPropertySection(pht('Macro'), $file)->addPropertySection(pht('Details'), $details); return $this->newPage()->setTitle($title_short)->setCrumbs($crumbs)->setPageObjectPHIDs(array($macro->getPHID()))->appendChild($view); }
public function processRequest() { $request = $this->getRequest(); $document = $request->getStr('document'); $draft_key = $request->getStr('draftkey'); if ($draft_key) { $table = new PhabricatorDraft(); queryfx($table->establishConnection('w'), 'INSERT INTO %T (authorPHID, draftKey, draft) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE draft = VALUES(draft)', $table->getTableName(), $request->getUser()->getPHID(), $draft_key, $document); } $content_obj = new PhrictionContent(); $content_obj->setContent($document); $engine = PhabricatorMarkupEngine::newPhrictionMarkupEngine(); $content = $content_obj->renderContent(); return id(new AphrontAjaxResponse())->setContent($content); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $timeline = null; $url = id(new PhabricatorPhurlURLQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$url) { return new Aphront404Response(); } $title = $url->getMonogram(); $page_title = $title . ' ' . $url->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title, $url->getURI()); $timeline = $this->buildTransactionTimeline($url, new PhabricatorPhurlURLTransactionQuery()); $header = $this->buildHeaderView($url); $actions = $this->buildActionView($url); $properties = $this->buildPropertyView($url); $properties->setActionList($actions); $url_error = id(new PHUIInfoView())->setErrors(array(pht('This URL is invalid due to a bad protocol.')))->setIsHidden($url->isValid()); $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties)->setInfoView($url_error); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('More Cowbell'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $url->getPHID()); $comment_uri = $this->getApplicationURI('/phurl/comment/' . $url->getID() . '/'); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($url->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($comment_uri)->setSubmitButtonName(pht('Add Comment')); return $this->buildApplicationPage(array($crumbs, $box, $timeline, $add_comment_form), array('title' => $page_title, 'pageObjects' => array($url->getPHID()))); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); if (!$request->isFormPost()) { return new Aphront400Response(); } $document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needDocumentBodies(true)->executeOne(); if (!$document) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $document_uri = $this->getApplicationURI('view/' . $document->getID()); $comment = $request->getStr('comment'); $xactions = array(); if (strlen($comment)) { $xactions[] = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new LegalpadTransactionComment())->setDocumentID($document->getID())->setLineNumber(0)->setLineLength(0)->setContent($comment)); } $editor = id(new LegalpadDocumentEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($document, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($document_uri)->setException($ex); } if ($draft) { $draft->replaceOrDelete(); } if ($request->isAjax() && $is_preview) { return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview); } else { return id(new AphrontRedirectResponse())->setURI($document_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); if (!$request->isFormPost()) { return new Aphront400Response(); } $paste = id(new PhabricatorPasteQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$paste) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $view_uri = $paste->getURI(); $xactions = array(); $xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorPasteTransactionComment())->setContent($request->getStr('comment'))); $editor = id(new PhabricatorPasteEditor())->setActor($viewer)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($paste, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex); } if ($draft) { $draft->replaceOrDelete(); } if ($request->isAjax() && $is_preview) { return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview); } else { return id(new AphrontRedirectResponse())->setURI($view_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $sequence = $request->getURIData('sequence'); $timeline = null; $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$event) { return new Aphront404Response(); } if ($sequence) { $result = $this->getEventAtIndexForGhostPHID($viewer, $event->getPHID(), $sequence); if ($result) { $parent_event = $event; $event = $result; $event->attachParentEvent($parent_event); return id(new AphrontRedirectResponse())->setURI('/E' . $result->getID()); } else { if ($sequence && $event->getIsRecurring()) { $parent_event = $event; $event = $event->generateNthGhost($sequence, $viewer); $event->attachParentEvent($parent_event); } else { if ($sequence) { return new Aphront404Response(); } } } $title = $event->getMonogram() . ' (' . $sequence . ')'; $page_title = $title . ' ' . $event->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title, '/' . $event->getMonogram() . '/' . $sequence); } else { $title = 'E' . $event->getID(); $page_title = $title . ' ' . $event->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); } if (!$event->getIsGhostEvent()) { $timeline = $this->buildTransactionTimeline($event, new PhabricatorCalendarEventTransactionQuery()); } $header = $this->buildHeaderView($event); $actions = $this->buildActionView($event); $properties = $this->buildPropertyListView($event); $details = $this->buildPropertySection($event); $description = $this->buildDescriptionView($event); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Add To Plate'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID()); if ($sequence) { $comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/' . $sequence . '/'); } else { $comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/'); } $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($event->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($comment_uri)->setSubmitButtonName(pht('Add Comment')); $view = id(new PHUITwoColumnView())->setHeader($header)->setMainColumn($timeline)->setPropertyList($properties)->addPropertySection(pht('DETAILS'), $details)->addPropertySection(pht('DESCRIPTION'), $description)->setActionList($actions); return $this->newPage()->setTitle($page_title)->setCrumbs($crumbs)->setPageObjectPHIDs(array($event->getPHID()))->appendChild(array($view)); }
private function buildCommentForm(PhabricatorSlowvotePoll $poll) { $viewer = $this->getRequest()->getUser(); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Enter Deliberations'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $poll->getPHID()); return id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($poll->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $poll->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); }
private function buildCommentForm(PhabricatorBadgesBadge $badge) { $viewer = $this->getViewer(); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Render Honors'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $badge->getPHID()); return id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($badge->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $badge->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); }
private function buildAddCommentView(LegalpadDocument $document, $comment_form_id) { $viewer = $this->getViewer(); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $document->getPHID()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $title = $is_serious ? pht('Add Comment') : pht('Debate Legislation'); $form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($document->getPHID())->setFormID($comment_form_id)->setHeaderText($title)->setDraft($draft)->setSubmitButtonName(pht('Add Comment'))->setAction($this->getApplicationURI('/comment/' . $document->getID() . '/'))->setRequestURI($this->getRequest()->getRequestURI()); return $form; }
public function processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); $sequence = $request->getURIData('sequence'); $timeline = null; $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($this->id))->executeOne(); if (!$event) { return new Aphront404Response(); } if ($sequence) { $result = $this->getEventAtIndexForGhostPHID($viewer, $event->getPHID(), $sequence); if ($result) { $parent_event = $event; $event = $result; $event->attachParentEvent($parent_event); return id(new AphrontRedirectResponse())->setURI('/E' . $result->getID()); } else { if ($sequence && $event->getIsRecurring()) { $parent_event = $event; $event = $event->generateNthGhost($sequence, $viewer); $event->attachParentEvent($parent_event); } else { if ($sequence) { return new Aphront404Response(); } } } $title = $event->getMonogram() . ' (' . $sequence . ')'; $page_title = $title . ' ' . $event->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title, '/' . $event->getMonogram() . '/' . $sequence); } else { $title = 'E' . $event->getID(); $page_title = $title . ' ' . $event->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title, '/E' . $event->getID()); } if (!$event->getIsGhostEvent()) { $timeline = $this->buildTransactionTimeline($event, new PhabricatorCalendarEventTransactionQuery()); } $header = $this->buildHeaderView($event); $actions = $this->buildActionView($event); $properties = $this->buildPropertyView($event); $properties->setActionList($actions); $box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Add To Plate'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $event->getPHID()); if ($sequence) { $comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/' . $sequence . '/'); } else { $comment_uri = $this->getApplicationURI('/event/comment/' . $event->getID() . '/'); } $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($event->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($comment_uri)->setSubmitButtonName(pht('Add Comment')); return $this->buildApplicationPage(array($crumbs, $box, $timeline, $add_comment_form), array('title' => $page_title)); }
private function buildTransactionView(PhabricatorFile $file) { $viewer = $this->getViewer(); $timeline = $this->buildTransactionTimeline($file, new PhabricatorFileTransactionQuery()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Question File Integrity'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $file->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($file->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $file->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); return array($timeline, $add_comment_form); }
public function processRequest() { $request = $this->getRequest(); $author_phid = $request->getUser()->getPHID(); $handles = id(new PhabricatorObjectHandleData(array($author_phid)))->loadHandles(); $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); $comment = new DifferentialComment(); $comment->setContent($request->getStr('content')); $comment->setAction($request->getStr('action')); $comment->setAuthorPHID($author_phid); $view = new DifferentialRevisionCommentView(); $view->setUser($request->getUser()); $view->setComment($comment); $view->setHandles($handles); $view->setMarkupEngine($engine); $view->setPreview(true); $view->setTargetDiff(null); $draft = new PhabricatorDraft(); $draft->setAuthorPHID($author_phid)->setDraftKey('differential-comment-' . $this->id)->setDraft($comment->getContent())->replace(); return id(new AphrontAjaxResponse())->setContent($view->render()); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $latest_conpherences = array(); $latest_participant = id(new ConpherenceParticipantQuery())->withParticipantPHIDs(array($user->getPHID()))->setLimit(6)->execute(); if ($latest_participant) { $conpherence_phids = mpull($latest_participant, 'getConpherencePHID'); $latest_conpherences = id(new ConpherenceThreadQuery())->setViewer($user)->withPHIDs($conpherence_phids)->needCropPics(true)->needParticipantCache(true)->execute(); $latest_conpherences = mpull($latest_conpherences, null, 'getPHID'); $latest_conpherences = array_select_keys($latest_conpherences, $conpherence_phids); } $conpherence = null; $should_404 = false; if ($request->getInt('id')) { $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($request->getInt('id')))->needCropPics(true)->needTransactions(true)->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)->executeOne(); $should_404 = true; } else { if ($latest_participant) { $participant = head($latest_participant); $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withPHIDs(array($participant->getConpherencePHID()))->needCropPics(true)->needTransactions(true)->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)->executeOne(); $should_404 = true; } } $durable_column = id(new ConpherenceDurableColumnView())->setUser($user)->setVisible(true); if (!$conpherence) { if ($should_404) { return new Aphront404Response(); } $conpherence_id = null; $conpherence_phid = null; $latest_transaction_id = null; $can_edit = false; } else { $this->setConpherence($conpherence); $participant = $conpherence->getParticipant($user->getPHID()); $transactions = $conpherence->getTransactions(); $latest_transaction = head($transactions); $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites(); $participant->markUpToDate($conpherence, $latest_transaction); unset($write_guard); $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $durable_column->setDraft($draft)->setSelectedConpherence($conpherence)->setConpherences($latest_conpherences); $conpherence_id = $conpherence->getID(); $conpherence_phid = $conpherence->getPHID(); $latest_transaction_id = $latest_transaction->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_EDIT); } $dropdown_query = id(new AphlictDropdownDataQuery())->setViewer($user); $dropdown_query->execute(); $response = array('content' => hsprintf('%s', $durable_column), 'threadID' => $conpherence_id, 'threadPHID' => $conpherence_phid, 'latestTransactionID' => $latest_transaction_id, 'canEdit' => $can_edit, 'aphlictDropdownData' => array($dropdown_query->getNotificationData(), $dropdown_query->getConpherenceData())); return id(new AphrontAjaxResponse())->setContent($response); }
private function renderCommentForm(PhabricatorFile $file) { $viewer = $this->getViewer(); if (!$viewer->isLoggedIn()) { $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/' . $file->getMonogram()); return id(new PHUIFormLayoutView())->addClass('phui-comment-panel-empty')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Comment'))->setHref((string) $login_href)); } $draft = PhabricatorDraft::newFromUserAndKey($viewer, $file->getPHID()); $post_uri = $this->getApplicationURI('thread/' . $file->getPHID() . '/'); $form = id(new AphrontFormView())->setUser($viewer)->setAction($post_uri)->addSigil('lightbox-comment-form')->addClass('lightbox-comment-form')->setWorkflow(true)->appendChild(id(new PhabricatorRemarkupControl())->setUser($viewer)->setName('comment')->setValue($draft->getDraft()))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Comment'))); $view = phutil_tag_div('phui-comment-panel', $form); return $view; }
private function buildTransactionView(PhabricatorFile $file, array $xactions) { $user = $this->getRequest()->getUser(); $engine = id(new PhabricatorMarkupEngine())->setViewer($user); foreach ($xactions as $xaction) { if ($xaction->getComment()) { $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); } } $engine->process(); $timeline = id(new PhabricatorApplicationTransactionView())->setUser($user)->setObjectPHID($file->getPHID())->setTransactions($xactions)->setMarkupEngine($engine); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('Question File Integrity'); $draft = PhabricatorDraft::newFromUserAndKey($user, $file->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setObjectPHID($file->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/comment/' . $file->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); return array($timeline, $add_comment_form); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $macro = id(new PhabricatorMacroQuery())->setViewer($user)->withIDs(array($this->id))->needFiles(true)->executeOne(); if (!$macro) { return new Aphront404Response(); } $file = $macro->getFile(); $title_short = pht('Macro "%s"', $macro->getName()); $title_long = pht('Image Macro "%s"', $macro->getName()); $actions = $this->buildActionView($macro); $crumbs = $this->buildApplicationCrumbs(); $crumbs->setActionList($actions); $crumbs->addTextCrumb($title_short, $this->getApplicationURI('/view/' . $macro->getID() . '/')); $properties = $this->buildPropertyView($macro, $actions); if ($file) { $file_view = new PHUIPropertyListView(); $file_view->addImageContent(phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phabricator-image-macro-hero'))); } $xactions = id(new PhabricatorMacroTransactionQuery())->setViewer($request->getUser())->withObjectPHIDs(array($macro->getPHID()))->execute(); $engine = id(new PhabricatorMarkupEngine())->setViewer($user); foreach ($xactions as $xaction) { if ($xaction->getComment()) { $engine->addObject($xaction->getComment(), PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); } } $engine->process(); $timeline = id(new PhabricatorApplicationTransactionView())->setUser($user)->setObjectPHID($macro->getPHID())->setTransactions($xactions)->setMarkupEngine($engine); $header = id(new PHUIHeaderView())->setUser($user)->setPolicyObject($macro)->setHeader($title_long); if ($macro->getIsDisabled()) { $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setName(pht('Macro Disabled'))->setBackgroundColor(PHUITagView::COLOR_BLACK)); } $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe'); $draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); if ($file_view) { $object_box->addPropertyList($file_view); } return $this->buildApplicationPage(array($crumbs, $object_box, $timeline, $add_comment_form), array('title' => $title_short)); }
public function handleRequest(AphrontRequest $request) { $id = $request->getURIData('requestID'); $viewer = $request->getViewer(); $pull = id(new ReleephRequestQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$pull) { return new Aphront404Response(); } $this->setBranch($pull->getBranch()); // Redirect older URIs to new "Y" URIs. // TODO: Get rid of this eventually. $actual_path = $request->getRequestURI()->getPath(); $expect_path = '/' . $pull->getMonogram(); if ($actual_path != $expect_path) { return id(new AphrontRedirectResponse())->setURI($expect_path); } // TODO: Break this 1:1 stuff? $branch = $pull->getBranch(); $field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW); $field_list->setViewer($viewer)->readFieldsFromStorage($pull); // TODO: This should be more modern and general. $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer); foreach ($field_list->getFields() as $field) { if ($field->shouldMarkup()) { $field->setMarkupEngine($engine); } } $engine->process(); $pull_box = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull); $timeline = $this->buildTransactionTimeline($pull, new ReleephRequestTransactionQuery()); $add_comment_header = pht('Plea or Yield'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $pull->getPHID()); $title = hsprintf('%s %s', $pull->getMonogram(), $pull->getSummaryForDisplay()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($pull->getPHID())->setDraft($draft)->setHeaderText($add_comment_header)->setAction($this->getApplicationURI('/request/comment/' . $pull->getID() . '/'))->setSubmitButtonName(pht('Comment')); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($pull->getMonogram(), '/' . $pull->getMonogram()); $crumbs->setBorder(true); $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-flag-checkered'); $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($pull_box, $timeline, $add_comment_form)); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view); }
public function handleRequest(AphrontRequest $request) { if (!$request->isFormPost()) { return new Aphront400Response(); } $viewer = $request->getViewer(); $id = $request->getURIData('id'); $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne(); if (!$event) { return new Aphront404Response(); } $index = $request->getURIData('sequence'); if ($index && !$is_preview) { $result = $this->getEventAtIndexForGhostPHID($viewer, $event->getPHID(), $index); if ($result) { $event = $result; } else { $event = $this->createEventFromGhost($viewer, $event, $index); $event->applyViewerTimezone($viewer); } } $view_uri = '/' . $event->getMonogram(); $xactions = array(); $xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorCalendarEventTransactionComment())->setContent($request->getStr('comment'))); $editor = id(new PhabricatorCalendarEventEditor())->setActor($viewer)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($event, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex); } if ($draft) { $draft->replaceOrDelete(); } if ($request->isAjax() && $is_preview) { return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview); } else { return id(new AphrontRedirectResponse())->setURI($view_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); if (!$request->isFormPost()) { return new Aphront400Response(); } $mock = id(new PholioMockQuery())->setViewer($viewer)->withIDs(array($id))->needImages(true)->executeOne(); if (!$mock) { return new Aphront404Response(); } $is_preview = $request->isPreviewRequest(); $draft = PhabricatorDraft::buildFromRequest($request); $mock_uri = '/M' . $mock->getID(); $comment = $request->getStr('comment'); $xactions = array(); $inline_comments = id(new PholioTransactionComment())->loadAllWhere('authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)', $viewer->getPHID(), mpull($mock->getImages(), 'getID')); if (!$inline_comments || strlen($comment)) { $xactions[] = id(new PholioTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PholioTransactionComment())->setContent($comment)); } foreach ($inline_comments as $inline_comment) { $xactions[] = id(new PholioTransaction())->setTransactionType(PholioTransaction::TYPE_INLINE)->attachComment($inline_comment); } $editor = id(new PholioMockEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview); try { $xactions = $editor->applyTransactions($mock, $xactions); } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($mock_uri)->setException($ex); } if ($draft) { $draft->replaceOrDelete(); } if ($request->isAjax() && $is_preview) { $xaction_view = id(new PholioTransactionView())->setMock($mock); return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setTransactionView($xaction_view)->setIsPreview($is_preview); } else { return id(new AphrontRedirectResponse())->setURI($mock_uri); } }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $macro = id(new PhabricatorMacroQuery())->setViewer($viewer)->withIDs(array($id))->needFiles(true)->executeOne(); if (!$macro) { return new Aphront404Response(); } $file = $macro->getFile(); $title_short = pht('Macro "%s"', $macro->getName()); $title_long = pht('Image Macro "%s"', $macro->getName()); $actions = $this->buildActionView($macro); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title_short, $this->getApplicationURI('/view/' . $macro->getID() . '/')); $properties = $this->buildPropertyView($macro, $actions); if ($file) { $file_view = new PHUIPropertyListView(); $file_view->addImageContent(phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phabricator-image-macro-hero'))); } $timeline = $this->buildTransactionTimeline($macro, new PhabricatorMacroTransactionQuery()); $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($macro)->setHeader($title_long); if (!$macro->getIsDisabled()) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $comment_header = $is_serious ? pht('Add Comment') : pht('Grovel in Awe'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID()); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($macro->getPHID())->setDraft($draft)->setHeaderText($comment_header)->setAction($this->getApplicationURI('/comment/' . $macro->getID() . '/'))->setSubmitButtonName(pht('Add Comment')); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); if ($file_view) { $object_box->addPropertyList($file_view); } return $this->buildApplicationPage(array($crumbs, $object_box, $timeline, $add_comment_form), array('title' => $title_short, 'pageObjects' => array($macro->getPHID()))); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $comments = $request->getStr('comments'); $task = id(new ManiphestTask())->load($this->id); if (!$task) { return new Aphront404Response(); } $draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), $task->getPHID()); if (!$draft) { $draft = new PhabricatorDraft(); $draft->setAuthorPHID($user->getPHID()); $draft->setDraftKey($task->getPHID()); } $draft->setDraft($comments); $draft->save(); $action = $request->getStr('action'); $transaction = new ManiphestTransaction(); $transaction->setAuthorPHID($user->getPHID()); $transaction->setComments($comments); $transaction->setTransactionType($action); $value = $request->getStr('value'); // grab phids for handles and set transaction values based on action and // value (empty or control-specific format) coming in from the wire switch ($action) { case ManiphestTransactionType::TYPE_PRIORITY: $transaction->setOldValue($task->getPriority()); $transaction->setNewValue($value); break; case ManiphestTransactionType::TYPE_OWNER: if ($value) { $value = current(json_decode($value)); $phids = array($value); } else { $phids = array(); } $transaction->setNewValue($value); break; case ManiphestTransactionType::TYPE_CCS: if ($value) { $value = json_decode($value); $phids = $value; foreach ($task->getCCPHIDs() as $cc_phid) { $phids[] = $cc_phid; $value[] = $cc_phid; } $transaction->setNewValue($value); } else { $phids = array(); $transaction->setNewValue(array()); } $transaction->setOldValue($task->getCCPHIDs()); break; case ManiphestTransactionType::TYPE_PROJECTS: if ($value) { $value = json_decode($value); $phids = $value; foreach ($task->getProjectPHIDs() as $project_phid) { $phids[] = $project_phid; $value[] = $project_phid; } $transaction->setNewValue($value); } else { $phids = array(); $transaction->setNewValue(array()); } $transaction->setOldValue($task->getProjectPHIDs()); break; default: $phids = array(); $transaction->setNewValue($value); break; } $phids[] = $user->getPHID(); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $transactions = array(); $transactions[] = $transaction; $engine = new PhabricatorMarkupEngine(); $engine->addObject($transaction, ManiphestTransaction::MARKUP_FIELD_BODY); $engine->process(); $transaction_view = new ManiphestTransactionListView(); $transaction_view->setTransactions($transactions); $transaction_view->setHandles($handles); $transaction_view->setUser($user); $transaction_view->setMarkupEngine($engine); $transaction_view->setPreview(true); return id(new AphrontAjaxResponse())->setContent($transaction_view->render()); }
public function handleRequest(AphrontRequest $request) { $user = $request->getUser(); $conpherence_id = $request->getURIData('id'); if (!$conpherence_id) { return new Aphront404Response(); } $need_participants = false; $needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW); $action = $request->getStr('action', ConpherenceUpdateActions::METADATA); switch ($action) { case ConpherenceUpdateActions::REMOVE_PERSON: $person_phid = $request->getStr('remove_person'); if ($person_phid != $user->getPHID()) { $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; } break; case ConpherenceUpdateActions::ADD_PERSON: case ConpherenceUpdateActions::METADATA: $needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT; break; case ConpherenceUpdateActions::JOIN_ROOM: $needed_capabilities[] = PhabricatorPolicyCapability::CAN_JOIN; break; case ConpherenceUpdateActions::NOTIFICATIONS: $need_participants = true; break; case ConpherenceUpdateActions::LOAD: break; } $conpherence = id(new ConpherenceThreadQuery())->setViewer($user)->withIDs(array($conpherence_id))->needFilePHIDs(true)->needOrigPics(true)->needCropPics(true)->needParticipants($need_participants)->requireCapabilities($needed_capabilities)->executeOne(); $latest_transaction_id = null; $response_mode = $request->isAjax() ? 'ajax' : 'redirect'; $error_view = null; $e_file = array(); $errors = array(); $delete_draft = false; $xactions = array(); if ($request->isFormPost() || $action == ConpherenceUpdateActions::LOAD) { $editor = id(new ConpherenceEditor())->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setActor($user); switch ($action) { case ConpherenceUpdateActions::DRAFT: $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $draft->setDraft($request->getStr('text')); $draft->replaceOrDelete(); return new AphrontAjaxResponse(); case ConpherenceUpdateActions::JOIN_ROOM: $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => array($user->getPHID()))); $delete_draft = true; $message = $request->getStr('text'); if ($message) { $message_xactions = $editor->generateTransactionsFromText($user, $conpherence, $message); $xactions = array_merge($xactions, $message_xactions); } // for now, just redirect back to the conpherence so everything // will work okay...! $response_mode = 'redirect'; break; case ConpherenceUpdateActions::MESSAGE: $message = $request->getStr('text'); if (strlen($message)) { $xactions = $editor->generateTransactionsFromText($user, $conpherence, $message); $delete_draft = true; } else { $action = ConpherenceUpdateActions::LOAD; $updated = false; $response_mode = 'ajax'; } break; case ConpherenceUpdateActions::ADD_PERSON: $person_phids = $request->getArr('add_person'); if (!empty($person_phids)) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => $person_phids)); } break; case ConpherenceUpdateActions::REMOVE_PERSON: if (!$request->isContinueRequest()) { // do nothing; we'll display a confirmation dialogue instead break; } $person_phid = $request->getStr('remove_person'); if ($person_phid && $person_phid == $user->getPHID()) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('-' => array($person_phid))); $response_mode = 'go-home'; } break; case ConpherenceUpdateActions::NOTIFICATIONS: $notifications = $request->getStr('notifications'); $participant = $conpherence->getParticipantIfExists($user->getPHID()); if (!$participant) { return id(new Aphront404Response()); } $participant->setSettings(array('notifications' => $notifications)); $participant->save(); $result = pht('Updated notification settings to "%s".', ConpherenceSettings::getHumanString($notifications)); return id(new AphrontAjaxResponse())->setContent($result); break; case ConpherenceUpdateActions::METADATA: $top = $request->getInt('image_y'); $left = $request->getInt('image_x'); $file_id = $request->getInt('file_id'); $title = $request->getStr('title'); if ($file_id) { $orig_file = id(new PhabricatorFileQuery())->setViewer($user)->withIDs(array($file_id))->executeOne(); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)->setNewValue($orig_file); $okay = $orig_file->isTransformableImage(); if ($okay) { $xformer = new PhabricatorImageTransformer(); $crop_file = $xformer->executeConpherenceTransform($orig_file, 0, 0, ConpherenceImageData::CROP_WIDTH, ConpherenceImageData::CROP_HEIGHT); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE_CROP)->setNewValue($crop_file->getPHID()); } $response_mode = 'redirect'; } // all other metadata updates are continue requests if (!$request->isContinueRequest()) { break; } if ($top !== null || $left !== null) { $file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG); $xformer = new PhabricatorImageTransformer(); $xformed = $xformer->executeConpherenceTransform($file, $top, $left, ConpherenceImageData::CROP_WIDTH, ConpherenceImageData::CROP_HEIGHT); $image_phid = $xformed->getPHID(); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE_CROP)->setNewValue($image_phid); } $title = $request->getStr('title'); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_TITLE)->setNewValue($title); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)->setNewValue($request->getStr('viewPolicy')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)->setNewValue($request->getStr('editPolicy')); $xactions[] = id(new ConpherenceTransaction())->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)->setNewValue($request->getStr('joinPolicy')); if (!$request->getExists('force_ajax')) { $response_mode = 'redirect'; } break; case ConpherenceUpdateActions::LOAD: $updated = false; $response_mode = 'ajax'; break; default: throw new Exception(pht('Unknown action: %s', $action)); break; } if ($xactions) { try { $xactions = $editor->applyTransactions($conpherence, $xactions); if ($delete_draft) { $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $draft->delete(); } } catch (PhabricatorApplicationTransactionNoEffectException $ex) { return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($this->getApplicationURI($conpherence_id . '/'))->setException($ex); } // xactions had no effect...! if (empty($xactions)) { $errors[] = pht('That was a non-update. Try cancel.'); } } if ($xactions || $action == ConpherenceUpdateActions::LOAD) { switch ($response_mode) { case 'ajax': $latest_transaction_id = $request->getInt('latest_transaction_id'); $content = $this->loadAndRenderUpdates($action, $conpherence_id, $latest_transaction_id); return id(new AphrontAjaxResponse())->setContent($content); break; case 'go-home': $content = array('href' => $this->getApplicationURI()); return id(new AphrontAjaxResponse())->setContent($content); break; case 'redirect': default: return id(new AphrontRedirectResponse())->setURI('/' . $conpherence->getMonogram()); break; } } } if ($errors) { $error_view = id(new PHUIInfoView())->setErrors($errors); } switch ($action) { case ConpherenceUpdateActions::ADD_PERSON: $dialogue = $this->renderAddPersonDialogue($conpherence); break; case ConpherenceUpdateActions::REMOVE_PERSON: $dialogue = $this->renderRemovePersonDialogue($conpherence); break; case ConpherenceUpdateActions::METADATA: default: $dialogue = $this->renderMetadataDialogue($conpherence, $error_view); break; } return id(new AphrontDialogResponse())->setDialog($dialogue->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setSubmitURI($this->getApplicationURI('update/' . $conpherence_id . '/'))->addSubmitButton()->addCancelButton($this->getApplicationURI($conpherence->getID() . '/'))); }
private function renderFormContent() { $conpherence = $this->getConpherence(); $user = $this->getRequest()->getUser(); $can_join = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_JOIN); $participating = $conpherence->getParticipantIfExists($user->getPHID()); if (!$can_join && !$participating && $user->isLoggedIn()) { return null; } $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); if ($participating) { $action = ConpherenceUpdateActions::MESSAGE; $button_text = pht('Send'); } else { if ($user->isLoggedIn()) { $action = ConpherenceUpdateActions::JOIN_ROOM; $button_text = pht('Join Room'); } else { // user not logged in so give them a login button. $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/' . $conpherence->getMonogram()); return id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Participate'))->setHref((string) $login_href)); } } $update_uri = $this->getApplicationURI('update/' . $conpherence->getID() . '/'); $this->initBehavior('conpherence-pontificate'); $form = id(new AphrontFormView())->setUser($user)->setAction($update_uri)->addSigil('conpherence-pontificate')->setWorkflow(true)->addHiddenInput('action', $action)->appendChild(id(new PhabricatorRemarkupControl())->setUser($user)->setName('text')->setValue($draft->getDraft()))->appendChild(id(new AphrontFormSubmitControl())->setValue($button_text))->render(); return $form; }
private function renderFormContent() { $conpherence = $this->getConpherence(); $user = $this->getRequest()->getUser(); $can_join = PhabricatorPolicyFilter::hasCapability($user, $conpherence, PhabricatorPolicyCapability::CAN_JOIN); $participating = $conpherence->getParticipantIfExists($user->getPHID()); if (!$can_join && !$participating && $user->isLoggedIn()) { return null; } $draft = PhabricatorDraft::newFromUserAndKey($user, $conpherence->getPHID()); $update_uri = $this->getApplicationURI('update/' . $conpherence->getID() . '/'); if ($user->isLoggedIn()) { $this->initBehavior('conpherence-pontificate'); if ($participating) { $action = ConpherenceUpdateActions::MESSAGE; $status = new PhabricatorNotificationStatusView(); } else { $action = ConpherenceUpdateActions::JOIN_ROOM; $status = pht('Sending a message will also join the room.'); } $form = id(new AphrontFormView())->setUser($user)->setAction($update_uri)->addSigil('conpherence-pontificate')->setWorkflow(true)->addHiddenInput('action', $action)->appendChild(id(new PhabricatorRemarkupControl())->setUser($user)->setName('text')->setValue($draft->getDraft())); $status_view = phutil_tag('div', array('class' => 'conpherence-room-status', 'id' => 'conpherence-room-status'), $status); $view = phutil_tag_div('pontificate-container', array($form, $status_view)); return $view; } else { // user not logged in so give them a login button. $login_href = id(new PhutilURI('/auth/start/'))->setQueryParam('next', '/' . $conpherence->getMonogram()); return id(new PHUIFormLayoutView())->addClass('login-to-participate')->appendInstructions(pht('Log in to join this room and participate.'))->appendChild(id(new PHUIButtonView())->setTag('a')->setText(pht('Login to Participate'))->setHref((string) $login_href)); } }