2011-03-22 22:34:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-14 00:24:56 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-03-22 22:34:38 +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.
|
|
|
|
*/
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class HeraldNewController extends HeraldController {
|
2011-03-22 22:34:38 +01:00
|
|
|
|
2012-01-14 00:24:56 +01:00
|
|
|
private $contentType;
|
2011-03-22 22:34:38 +01:00
|
|
|
|
2011-12-16 22:29:32 +01:00
|
|
|
public function getFilter() {
|
|
|
|
return 'new';
|
|
|
|
}
|
|
|
|
|
2011-03-22 22:34:38 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
2012-01-14 00:24:56 +01:00
|
|
|
$this->contentType = idx($data, 'type');
|
2011-03-22 22:34:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2012-01-14 00:24:56 +01:00
|
|
|
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
|
|
|
|
if (empty($content_type_map[$this->contentType])) {
|
|
|
|
reset($content_type_map);
|
|
|
|
$this->contentType = key($content_type_map);
|
2011-03-22 22:34:38 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 00:24:56 +01:00
|
|
|
$rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap();
|
|
|
|
|
Improve Herald personal/global UI/UX
Summary:
- Default "personal" vs "global" choice to "personal".
- Don't show global rules under "My Rules".
- After editing or creating a global rule, redirect back to global rule list.
- Use radio buttons for "personal" vs "global" and add captions explaining the
difference.
- For "global" rules, don't show the owner/author in the rule detail view --
they effectively have no owner (see also D1387).
- For "global" rules, don't show the owner/author in the rule list view, as
above.
- For admin views, show rule type (global vs personal).
Test Plan:
- Created and edited new global and personal rules.
- Viewed "my", "global" and "admin" views.
Reviewers: btrahan, jungejason, nh, xela
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1518
2012-01-31 21:09:29 +01:00
|
|
|
// Reorder array to put "personal" first.
|
|
|
|
$rule_type_map = array_select_keys(
|
|
|
|
$rule_type_map,
|
|
|
|
array(
|
|
|
|
HeraldRuleTypeConfig::RULE_TYPE_PERSONAL,
|
|
|
|
)) + $rule_type_map;
|
|
|
|
|
|
|
|
$captions = array(
|
|
|
|
HeraldRuleTypeConfig::RULE_TYPE_PERSONAL =>
|
|
|
|
'Personal rules notify you about events. You own them, but they can '.
|
|
|
|
'only affect you.',
|
|
|
|
HeraldRuleTypeConfig::RULE_TYPE_GLOBAL =>
|
|
|
|
'Global rules notify anyone about events. No one owns them, and '.
|
|
|
|
'anyone can edit them. Usually, Global rules are used to notify '.
|
|
|
|
'mailing lists.',
|
|
|
|
);
|
|
|
|
|
|
|
|
$radio = id(new AphrontFormRadioButtonControl())
|
|
|
|
->setLabel('Type')
|
|
|
|
->setName('rule_type')
|
|
|
|
->setValue(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
|
|
|
|
|
|
|
|
foreach ($rule_type_map as $value => $name) {
|
|
|
|
$radio->addButton(
|
|
|
|
$value,
|
|
|
|
$name,
|
|
|
|
idx($captions, $value));
|
|
|
|
}
|
|
|
|
|
2011-03-22 22:34:38 +01:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
|
|
|
->setAction('/herald/rule/')
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel('New rule for')
|
2012-01-14 00:24:56 +01:00
|
|
|
->setName('content_type')
|
|
|
|
->setValue($this->contentType)
|
|
|
|
->setOptions($content_type_map))
|
Improve Herald personal/global UI/UX
Summary:
- Default "personal" vs "global" choice to "personal".
- Don't show global rules under "My Rules".
- After editing or creating a global rule, redirect back to global rule list.
- Use radio buttons for "personal" vs "global" and add captions explaining the
difference.
- For "global" rules, don't show the owner/author in the rule detail view --
they effectively have no owner (see also D1387).
- For "global" rules, don't show the owner/author in the rule list view, as
above.
- For admin views, show rule type (global vs personal).
Test Plan:
- Created and edited new global and personal rules.
- Viewed "my", "global" and "admin" views.
Reviewers: btrahan, jungejason, nh, xela
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1518
2012-01-31 21:09:29 +01:00
|
|
|
->appendChild($radio)
|
2011-03-22 22:34:38 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue('Create Rule')
|
2012-01-14 00:24:56 +01:00
|
|
|
->addCancelButton('/herald/view/'.$this->contentType.'/'));
|
2011-03-22 22:34:38 +01:00
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setHeader('Create New Herald Rule');
|
2011-12-16 22:29:32 +01:00
|
|
|
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
2011-03-22 22:34:38 +01:00
|
|
|
$panel->appendChild($form);
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
$panel,
|
|
|
|
array(
|
|
|
|
'title' => 'Create Herald Rule',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|