2011-01-30 21:08:40 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-14 07:22:27 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-01-30 21:08:40 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class DifferentialCommentSaveController extends DifferentialController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
if (!$request->isFormPost()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$revision_id = $request->getInt('revision_id');
|
|
|
|
$revision = id(new DifferentialRevision())->load($revision_id);
|
|
|
|
if (!$revision) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$comment = $request->getStr('comment');
|
|
|
|
$action = $request->getStr('action');
|
2011-02-01 05:03:43 +01:00
|
|
|
$reviewers = $request->getArr('reviewers');
|
2011-06-24 21:21:48 +02:00
|
|
|
$ccs = $request->getArr('ccs');
|
2011-01-30 21:08:40 +01:00
|
|
|
|
|
|
|
$editor = new DifferentialCommentEditor(
|
|
|
|
$revision,
|
|
|
|
$request->getUser()->getPHID(),
|
|
|
|
$action);
|
|
|
|
|
Track content sources (email, web, conduit, mobile) for replies
Summary:
When an object is updated, record the content source for the update. This mostly
isn't terribly useful but one concrete thing I want to do with it is let admins
audit via-email replies more easily since there are a bunch of options which let
you do hyjinx if you intentionally configure them insecurely. I think having a
little more auditability around this feature is generally good. At some point
I'm going to turn this into a link admins can click to see details.
It also allows us to see how frequently different mechanisms are used, and lets
you see if someone is at their desk or on a mobile or whatever, at least
indirectly.
The "tablet" and "mobile" sources are currently unused but I figured I'd throw
them in anyway. SMS support should definitely happen at some point.
Not 100% sure about the design for this, I might change it to plain text at some
point.
Test Plan: Updated objects and saw update sources rendered.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, epriestley, jungejason
Differential Revision: 844
2011-08-22 19:25:45 +02:00
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
|
|
array(
|
|
|
|
'ip' => $request->getRemoteAddr(),
|
|
|
|
));
|
|
|
|
|
2011-01-30 21:08:40 +01:00
|
|
|
$editor
|
|
|
|
->setMessage($comment)
|
Track content sources (email, web, conduit, mobile) for replies
Summary:
When an object is updated, record the content source for the update. This mostly
isn't terribly useful but one concrete thing I want to do with it is let admins
audit via-email replies more easily since there are a bunch of options which let
you do hyjinx if you intentionally configure them insecurely. I think having a
little more auditability around this feature is generally good. At some point
I'm going to turn this into a link admins can click to see details.
It also allows us to see how frequently different mechanisms are used, and lets
you see if someone is at their desk or on a mobile or whatever, at least
indirectly.
The "tablet" and "mobile" sources are currently unused but I figured I'd throw
them in anyway. SMS support should definitely happen at some point.
Not 100% sure about the design for this, I might change it to plain text at some
point.
Test Plan: Updated objects and saw update sources rendered.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, epriestley, jungejason
Differential Revision: 844
2011-08-22 19:25:45 +02:00
|
|
|
->setContentSource($content_source)
|
2011-01-30 21:08:40 +01:00
|
|
|
->setAttachInlineComments(true)
|
|
|
|
->setAddedReviewers($reviewers)
|
2011-06-24 21:21:48 +02:00
|
|
|
->setAddedCCs($ccs)
|
2011-01-30 21:08:40 +01:00
|
|
|
->save();
|
|
|
|
|
|
|
|
// TODO: Diff change detection?
|
2011-02-06 01:57:21 +01:00
|
|
|
|
|
|
|
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
|
|
|
'authorPHID = %s AND draftKey = %s',
|
|
|
|
$request->getUser()->getPHID(),
|
|
|
|
'differential-comment-'.$revision->getID());
|
|
|
|
if ($draft) {
|
|
|
|
$draft->delete();
|
|
|
|
}
|
2011-01-30 21:08:40 +01:00
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/D'.$revision->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|