2013-03-26 21:30:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorSettingsPanelConpherencePreferences
|
|
|
|
extends PhabricatorSettingsPanel {
|
|
|
|
|
|
|
|
public function isEnabled() {
|
2013-04-06 20:39:59 +02:00
|
|
|
return PhabricatorApplication::isClassInstalled(
|
2013-03-26 21:30:35 +01:00
|
|
|
'PhabricatorApplicationConpherence');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelKey() {
|
|
|
|
return 'conpherence';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelName() {
|
|
|
|
return pht('Conpherence Preferences');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelGroup() {
|
|
|
|
return pht('Application Settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest(AphrontRequest $request) {
|
|
|
|
$user = $request->getUser();
|
|
|
|
$preferences = $user->loadPreferences();
|
|
|
|
|
|
|
|
$pref = PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS;
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$notifications = $request->getInt($pref);
|
|
|
|
$preferences->setPreference($pref, $notifications);
|
|
|
|
$preferences->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($this->getPanelURI('?saved=true'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Conpherence Notifications'))
|
|
|
|
->setName($pref)
|
|
|
|
->setValue($preferences->getPreference($pref))
|
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
ConpherenceSettings::EMAIL_ALWAYS
|
|
|
|
=> pht('Email Always'),
|
|
|
|
ConpherenceSettings::NOTIFICATIONS_ONLY
|
|
|
|
=> pht('Notifications Only'),
|
|
|
|
))
|
|
|
|
->setCaption(
|
|
|
|
pht('Should Conpherence send emails for updates or '.
|
|
|
|
'notifications only? This global setting can be overridden '.
|
|
|
|
'on a per-thread basis within Conpherence.')))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue(pht('Save Preferences')));
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText(pht('Conpherence Preferences'))
|
2014-01-10 20:58:52 +01:00
|
|
|
->setForm($form)
|
|
|
|
->setFormSaved($request->getBool('saved'));
|
2014-01-10 18:17:37 +01:00
|
|
|
|
2013-03-26 21:30:35 +01:00
|
|
|
return array(
|
2013-08-26 20:53:11 +02:00
|
|
|
$form_box,
|
2013-03-26 21:30:35 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|