mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
1f873572a4
Summary: - Use transactions to apply edits. - Use Editor to apply transactions. - Some special casing for tricky stuff I don't want to deal with yet (mock images). Test Plan: {F22368} Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Maniphest Tasks: T2097 Differential Revision: https://secure.phabricator.com/D3837
74 lines
2 KiB
PHP
74 lines
2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright 2012 Facebook, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
* @group pholio
|
|
*/
|
|
final class PholioMockCommentController extends PholioController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$mock = id(new PholioMockQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($this->id))
|
|
->executeOne();
|
|
|
|
if (!$mock) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$mock_uri = '/M'.$mock->getID();
|
|
|
|
$comment = $request->getStr('comment');
|
|
if (!strlen($comment)) {
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($user)
|
|
->setTitle(pht('Empty Comment'))
|
|
->appendChild('You did not provide a comment!')
|
|
->addCancelButton($mock_uri);
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
array(
|
|
'ip' => $request->getRemoteAddr(),
|
|
));
|
|
|
|
$xaction = id(new PholioTransaction())
|
|
->setTransactionType(PholioTransactionType::TYPE_NONE)
|
|
->setComment($comment);
|
|
|
|
id(new PholioMockEditor())
|
|
->setActor($user)
|
|
->setContentSource($content_source)
|
|
->applyTransactions($mock, array($xaction));
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($mock_uri);
|
|
}
|
|
|
|
}
|