Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conpherence - add per thread notification setting
Summary: Introduces a new settings panel for Conpherence specific settings. Test Plan: started a thread with a test user, thus two participants total. Replied to conpherence, toggling notification settings in between. Verified 1 or 2 emails were sent as appropos to the current toggle. Toggled global setting and verified setting was updated in conpherences where nothing was specified. Verified setting conpherence setting overrides global setting. Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2521 Differential Revision: https://secure.phabricator.com/D5391
- Loading branch information
Showing
14 changed files
with
284 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE {$NAMESPACE}_conpherence.conpherence_participant | ||
ADD settings LONGTEXT NOT NULL COLLATE utf8_bin AFTER behindTransactionPHID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/applications/conpherence/constants/ConpherenceSettings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
final class ConpherenceSettings extends ConpherenceConstants { | ||
|
||
const EMAIL_ALWAYS = 0; | ||
const NOTIFICATIONS_ONLY = 1; | ||
|
||
public static function getHumanString($constant) { | ||
$string = pht('Unknown setting.'); | ||
|
||
switch ($constant) { | ||
case self::EMAIL_ALWAYS: | ||
$string = pht('Email me every update.'); | ||
break; | ||
case self::NOTIFICATIONS_ONLY: | ||
$string = pht('Notifications only.'); | ||
break; | ||
} | ||
|
||
return $string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/applications/settings/panel/PhabricatorSettingsPanelConpherencePreferences.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
final class PhabricatorSettingsPanelConpherencePreferences | ||
extends PhabricatorSettingsPanel { | ||
|
||
public function isEnabled() { | ||
// TODO - epriestley - resolve isBeta and isInstalled for | ||
// PhabricatorApplication | ||
$app = PhabricatorApplication::getByClass( | ||
'PhabricatorApplicationConpherence'); | ||
$is_prod = !$app->isBeta(); | ||
$allow_beta = | ||
PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications'); | ||
return ($is_prod || $allow_beta) && $app->isInstalled(); | ||
} | ||
|
||
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'))); | ||
|
||
$panel = new AphrontPanelView(); | ||
$panel->setHeader(pht('Conpherence Preferences')); | ||
$panel->appendChild($form); | ||
$panel->setNoBackground(); | ||
|
||
$error_view = null; | ||
if ($request->getBool('saved')) { | ||
$error_view = id(new AphrontErrorView()) | ||
->setTitle(pht('Preferences Saved')) | ||
->setSeverity(AphrontErrorView::SEVERITY_NOTICE) | ||
->setErrors(array(pht('Your preferences have been saved.'))); | ||
} | ||
|
||
return array( | ||
$error_view, | ||
$panel, | ||
); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.