2011-02-06 07:36:21 +01:00
|
|
|
<?php
|
|
|
|
|
2012-08-13 21:37:18 +02:00
|
|
|
final class PhabricatorSettingsMainController
|
|
|
|
extends PhabricatorController {
|
2011-02-06 07:36:21 +01:00
|
|
|
|
2014-04-02 21:06:05 +02:00
|
|
|
private $id;
|
2012-08-13 21:37:26 +02:00
|
|
|
private $key;
|
2014-04-02 21:06:05 +02:00
|
|
|
private $user;
|
|
|
|
|
|
|
|
private function getUser() {
|
|
|
|
return $this->user;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function isSelf() {
|
|
|
|
$viewer_phid = $this->getRequest()->getUser()->getPHID();
|
|
|
|
$user_phid = $this->getUser()->getPHID();
|
|
|
|
return ($viewer_phid == $user_phid);
|
|
|
|
}
|
2011-02-06 07:36:21 +01:00
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
2014-04-02 21:06:05 +02:00
|
|
|
$this->id = idx($data, 'id');
|
2012-08-13 21:37:26 +02:00
|
|
|
$this->key = idx($data, 'key');
|
2011-02-06 07:36:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2014-04-02 21:06:05 +02:00
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
if ($this->id) {
|
|
|
|
$user = id(new PhabricatorPeopleQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$user) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->user = $user;
|
|
|
|
} else {
|
|
|
|
$this->user = $viewer;
|
|
|
|
}
|
2011-02-06 07:36:21 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$panels = $this->buildPanels();
|
|
|
|
$nav = $this->renderSideNav($panels);
|
|
|
|
|
|
|
|
$key = $nav->selectFilter($this->key, head($panels)->getPanelKey());
|
|
|
|
|
2011-02-06 07:36:21 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$panel = $panels[$key];
|
2014-04-02 21:06:05 +02:00
|
|
|
$panel->setUser($this->getUser());
|
|
|
|
$panel->setViewer($viewer);
|
2011-02-06 07:36:21 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$response = $panel->processRequest($request);
|
|
|
|
if ($response instanceof AphrontResponse) {
|
2011-07-18 17:02:00 +02:00
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
2014-04-02 21:06:05 +02:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
if (!$this->isSelf()) {
|
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
$this->getUser()->getUsername(),
|
|
|
|
'/p/'.$this->getUser()->getUsername().'/');
|
|
|
|
}
|
|
|
|
$crumbs->addTextCrumb($panel->getPanelName());
|
|
|
|
$nav->appendChild(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$response,
|
|
|
|
));
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$nav,
|
|
|
|
array(
|
|
|
|
'title' => $panel->getPanelName(),
|
2013-05-08 03:08:12 +02:00
|
|
|
'device' => true,
|
2012-08-13 21:37:26 +02:00
|
|
|
));
|
|
|
|
}
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
private function buildPanels() {
|
|
|
|
$panel_specs = id(new PhutilSymbolLoader())
|
|
|
|
->setAncestorClass('PhabricatorSettingsPanel')
|
|
|
|
->setConcreteOnly(true)
|
|
|
|
->selectAndLoadSymbols();
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$panels = array();
|
|
|
|
foreach ($panel_specs as $spec) {
|
|
|
|
$class = newv($spec['name'], array());
|
|
|
|
$panels[] = $class->buildPanels();
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
}
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$panels = array_mergev($panels);
|
|
|
|
$panels = mpull($panels, null, 'getPanelKey');
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$result = array();
|
|
|
|
foreach ($panels as $key => $panel) {
|
|
|
|
if (!$panel->isEnabled()) {
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
continue;
|
|
|
|
}
|
2014-04-02 21:06:05 +02:00
|
|
|
|
|
|
|
if (!$this->isSelf()) {
|
|
|
|
if (!$panel->isEditableByAdministrators()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
if (!empty($result[$key])) {
|
2013-03-03 15:52:42 +01:00
|
|
|
throw new Exception(pht(
|
|
|
|
"Two settings panels share the same panel key ('%s'): %s, %s.",
|
|
|
|
$key,
|
|
|
|
get_class($panel),
|
|
|
|
get_class($result[$key])));
|
2012-08-13 21:37:26 +02:00
|
|
|
}
|
2014-04-02 21:06:05 +02:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$result[$key] = $panel;
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
}
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
$result = msort($result, 'getPanelSortKey');
|
|
|
|
|
2014-04-02 21:06:05 +02:00
|
|
|
if (!$result) {
|
|
|
|
throw new Exception(pht('No settings panels are available.'));
|
|
|
|
}
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
return $result;
|
|
|
|
}
|
2012-06-13 17:52:05 +02:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
private function renderSideNav(array $panels) {
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
2014-04-02 21:06:05 +02:00
|
|
|
|
|
|
|
if ($this->isSelf()) {
|
|
|
|
$base_uri = 'panel/';
|
|
|
|
} else {
|
|
|
|
$base_uri = $this->getUser()->getID().'/panel/';
|
|
|
|
}
|
|
|
|
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI($base_uri)));
|
2012-08-13 21:37:26 +02:00
|
|
|
|
|
|
|
$group = null;
|
|
|
|
foreach ($panels as $panel) {
|
|
|
|
if ($panel->getPanelGroup() != $group) {
|
|
|
|
$group = $panel->getPanelGroup();
|
|
|
|
$nav->addLabel($group);
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
}
|
2012-08-13 21:37:26 +02:00
|
|
|
|
|
|
|
$nav->addFilter($panel->getPanelKey(), $panel->getPanelName());
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-18 05:32:28 +01:00
|
|
|
}
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
return $nav;
|
2011-02-22 07:51:34 +01:00
|
|
|
}
|
2012-08-13 21:37:26 +02:00
|
|
|
|
2013-05-08 03:08:12 +02:00
|
|
|
public function buildApplicationMenu() {
|
|
|
|
$panels = $this->buildPanels();
|
|
|
|
return $this->renderSideNav($panels)->getMenu();
|
|
|
|
}
|
|
|
|
|
2011-06-18 22:07:02 +02:00
|
|
|
}
|