repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorDiffusionBlameSetting.php | src/applications/settings/setting/PhabricatorDiffusionBlameSetting.php | <?php
final class PhabricatorDiffusionBlameSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'diffusion-blame';
public function getSettingName() {
return pht('Diffusion Blame');
}
public function getSettingDefaultValue() {
return false;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorInternalSetting.php | src/applications/settings/setting/PhabricatorInternalSetting.php | <?php
abstract class PhabricatorInternalSetting
extends PhabricatorSetting {}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorEmailStampsSetting.php | src/applications/settings/setting/PhabricatorEmailStampsSetting.php | <?php
final class PhabricatorEmailStampsSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'stamps';
const VALUE_BODY_STAMPS = 'body';
const VALUE_HEADER_STAMPS = 'header';
public function getSettingName() {
return pht('Send Stamps');
}
public function getSettingPanelKey() {
return PhabricatorEmailFormatSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 400;
}
protected function getControlInstructions() {
return pht(<<<EOREMARKUP
Outgoing mail is stamped with labels like `actor(alice)` which can be used to
write client mail rules to organize mail. By default, these stamps are sent
in an `X-Phabricator-Stamps` header.
If you use a client which can not use headers to route mail (like Gmail),
you can also include the stamps in the message body so mail rules based on
body content can route messages.
EOREMARKUP
);
}
public function getSettingDefaultValue() {
return self::VALUE_HEADER_STAMPS;
}
protected function getSelectOptions() {
return array(
self::VALUE_HEADER_STAMPS => pht('Mail Headers'),
self::VALUE_BODY_STAMPS => pht('Mail Headers and Body'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorDarkConsoleSetting.php | src/applications/settings/setting/PhabricatorDarkConsoleSetting.php | <?php
final class PhabricatorDarkConsoleSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'dark_console';
const VALUE_DARKCONSOLE_DISABLED = '0';
const VALUE_DARKCONSOLE_ENABLED = '1';
public function getSettingName() {
return pht('DarkConsole');
}
public function getSettingPanelKey() {
return PhabricatorDeveloperPreferencesSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 100;
}
protected function isEnabledForViewer(PhabricatorUser $viewer) {
return PhabricatorEnv::getEnvConfig('darkconsole.enabled');
}
protected function getControlInstructions() {
return pht(
'DarkConsole is a debugging console for developing and troubleshooting '.
'applications. After enabling DarkConsole, press the '.
'{nav `} key on your keyboard to toggle it on or off.');
}
public function getSettingDefaultValue() {
return self::VALUE_DARKCONSOLE_DISABLED;
}
protected function getSelectOptions() {
return array(
self::VALUE_DARKCONSOLE_DISABLED => pht('Disable DarkConsole'),
self::VALUE_DARKCONSOLE_ENABLED => pht('Enable DarkConsole'),
);
}
public function expandSettingTransaction($object, $xaction) {
// If the user has hidden the DarkConsole UI, forget their setting when
// they enable or disable it.
return array(
$xaction,
$this->newSettingTransaction(
$object,
PhabricatorDarkConsoleVisibleSetting::SETTINGKEY,
1),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorEditorSetting.php | src/applications/settings/setting/PhabricatorEditorSetting.php | <?php
final class PhabricatorEditorSetting
extends PhabricatorStringSetting {
const SETTINGKEY = 'editor';
public function getSettingName() {
return pht('Editor Link');
}
public function getSettingPanelKey() {
return PhabricatorExternalEditorSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 300;
}
protected function getControlInstructions() {
return pht(
"Many text editors can be configured as URI handlers for special ".
"protocols like `editor://`. If you have installed and configured ".
"such an editor, some applications can generate links that you can ".
"click to open files locally.".
"\n\n".
"Provide a URI pattern for building external editor URIs in your ".
"environment. For example, if you use TextMate on macOS, the pattern ".
"for your machine may look something like this:".
"\n\n".
"```name=\"Example: TextMate on macOS\"\n".
"%s\n".
"```\n".
"\n\n".
"For complete instructions on editor configuration, ".
"see **[[ %s | %s ]]**.".
"\n\n".
"See the tables below for a list of supported variables and protocols.",
'txmt://open/?url=file:///Users/alincoln/editor_links/%n/%f&line=%l',
PhabricatorEnv::getDoclink('User Guide: Configuring an External Editor'),
pht('User Guide: Configuring an External Editor'));
}
public function validateTransactionValue($value) {
if (!phutil_nonempty_string($value)) {
return;
}
id(new PhabricatorEditorURIEngine())
->setPattern($value)
->validatePattern();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorEmailSelfActionsSetting.php | src/applications/settings/setting/PhabricatorEmailSelfActionsSetting.php | <?php
final class PhabricatorEmailSelfActionsSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'self-mail';
const VALUE_SEND_SELF = '0';
const VALUE_NO_SELF = '1';
public function getSettingName() {
return pht('Self Actions');
}
public function getSettingPanelKey() {
return PhabricatorEmailDeliverySettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 200;
}
protected function getControlInstructions() {
return pht(
'If you disable **Self Actions**, this server will not notify '.
'you about actions you take.');
}
public function getSettingDefaultValue() {
return self::VALUE_SEND_SELF;
}
protected function getSelectOptions() {
return array(
self::VALUE_SEND_SELF => pht('Enable Self Action Mail'),
self::VALUE_NO_SELF => pht('Disable Self Action Mail'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorTitleGlyphsSetting.php | src/applications/settings/setting/PhabricatorTitleGlyphsSetting.php | <?php
final class PhabricatorTitleGlyphsSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'titles';
const VALUE_TITLE_GLYPHS = 'glyph';
const VALUE_TITLE_TEXT = 'text';
public function getSettingName() {
return pht('Page Titles');
}
public function getSettingPanelKey() {
return PhabricatorDisplayPreferencesSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 200;
}
protected function getControlInstructions() {
return pht(
'Some applications use unicode glyphs in page titles to provide a '.
'compact representation of the current application. You can '.
'substitute plain text instead if these glyphs do not display on '.
'your system.');
}
public function getSettingDefaultValue() {
return self::VALUE_TITLE_GLYPHS;
}
protected function getSelectOptions() {
return array(
self::VALUE_TITLE_GLYPHS => pht("Use Unicode Glyphs: \xE2\x9A\x99"),
self::VALUE_TITLE_TEXT => pht('Use Plain Text: [Differential]'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorDateFormatSetting.php | src/applications/settings/setting/PhabricatorDateFormatSetting.php | <?php
final class PhabricatorDateFormatSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'date-format';
const VALUE_FORMAT_ISO = 'Y-m-d';
const VALUE_FORMAT_US = 'n/j/Y';
const VALUE_FORMAT_EUROPE = 'd-m-Y';
public function getSettingName() {
return pht('Date Format');
}
public function getSettingPanelKey() {
return PhabricatorDateTimeSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 200;
}
protected function getControlInstructions() {
return pht(
'Select the format you prefer for editing dates.');
}
public function getSettingDefaultValue() {
return self::VALUE_FORMAT_ISO;
}
protected function getSelectOptions() {
return array(
self::VALUE_FORMAT_ISO => pht('ISO 8601: 2000-02-28'),
self::VALUE_FORMAT_US => pht('US: 2/28/2000'),
self::VALUE_FORMAT_EUROPE => pht('Europe: 28-02-2000'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorTimeFormatSetting.php | src/applications/settings/setting/PhabricatorTimeFormatSetting.php | <?php
final class PhabricatorTimeFormatSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'time-format';
const VALUE_FORMAT_12HOUR = 'g:i A';
const VALUE_FORMAT_24HOUR = 'H:i';
public function getSettingName() {
return pht('Time Format');
}
public function getSettingPanelKey() {
return PhabricatorDateTimeSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 300;
}
protected function getControlInstructions() {
return pht(
'Select the format you prefer for editing and displaying time.');
}
public function getSettingDefaultValue() {
return self::VALUE_FORMAT_12HOUR;
}
protected function getSelectOptions() {
return array(
self::VALUE_FORMAT_12HOUR => pht('12 Hour, 2:34 PM'),
self::VALUE_FORMAT_24HOUR => pht('24 Hour, 14:34'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorTimezoneIgnoreOffsetSetting.php | src/applications/settings/setting/PhabricatorTimezoneIgnoreOffsetSetting.php | <?php
final class PhabricatorTimezoneIgnoreOffsetSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'time.offset.ignore';
public function getSettingName() {
return pht('Timezone Ignored Offset');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorEmailFormatSetting.php | src/applications/settings/setting/PhabricatorEmailFormatSetting.php | <?php
final class PhabricatorEmailFormatSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'html-emails';
const VALUE_HTML_EMAIL = 'html';
const VALUE_TEXT_EMAIL = 'text';
public function getSettingName() {
return pht('HTML Email');
}
public function getSettingPanelKey() {
return PhabricatorEmailFormatSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 100;
}
protected function getControlInstructions() {
return pht(
'You can opt to receive plain text email instead of HTML email. '.
'Plain text email works better with some clients.');
}
public function getSettingDefaultValue() {
return self::VALUE_HTML_EMAIL;
}
protected function getSelectOptions() {
return array(
self::VALUE_HTML_EMAIL => pht('Send HTML Email'),
self::VALUE_TEXT_EMAIL => pht('Send Plain Text Email'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorStringSetting.php | src/applications/settings/setting/PhabricatorStringSetting.php | <?php
abstract class PhabricatorStringSetting
extends PhabricatorSetting {
final protected function newCustomEditField($object) {
return $this->newEditField($object, new PhabricatorTextEditField());
}
public function getTransactionNewValue($value) {
if (!strlen($value)) {
return null;
}
return (string)$value;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorNotificationsSetting.php | src/applications/settings/setting/PhabricatorNotificationsSetting.php | <?php
final class PhabricatorNotificationsSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'desktop-notifications';
const WEB_ONLY = 0;
const WEB_AND_DESKTOP = 1;
const DESKTOP_ONLY = 2;
const NONE = 3;
public function getSettingName() {
return pht('Notifications');
}
public static function getOptionsMap() {
return array(
self::WEB_ONLY => pht('Web Only'),
self::WEB_AND_DESKTOP => pht('Web and Desktop'),
self::DESKTOP_ONLY => pht('Desktop Only'),
self::NONE => pht('No Notifications'),
);
}
public static function desktopReady($option) {
switch ($option) {
case self::WEB_AND_DESKTOP:
case self::DESKTOP_ONLY:
return true;
}
return false;
}
public static function webReady($option) {
switch ($option) {
case self::WEB_AND_DESKTOP:
case self::WEB_ONLY:
return true;
}
return false;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorWeekStartDaySetting.php | src/applications/settings/setting/PhabricatorWeekStartDaySetting.php | <?php
final class PhabricatorWeekStartDaySetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'week-start-day';
public function getSettingName() {
return pht('Week Starts On');
}
public function getSettingPanelKey() {
return PhabricatorDateTimeSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 400;
}
protected function getControlInstructions() {
return pht(
'Choose which day a calendar week should begin on.');
}
public function getSettingDefaultValue() {
return 0;
}
protected function getSelectOptions() {
return array(
0 => pht('Sunday'),
1 => pht('Monday'),
2 => pht('Tuesday'),
3 => pht('Wednesday'),
4 => pht('Thursday'),
5 => pht('Friday'),
6 => pht('Saturday'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php | src/applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php | <?php
final class PhabricatorConpherenceWidgetVisibleSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'conpherence-widget';
public function getSettingName() {
return pht('Conpherence Widget Pane Visible');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorConpherenceColumnVisibleSetting.php | src/applications/settings/setting/PhabricatorConpherenceColumnVisibleSetting.php | <?php
final class PhabricatorConpherenceColumnVisibleSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'conpherence-column';
public function getSettingName() {
return pht('Conpherence Column Visible');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorFiletreeVisibleSetting.php | src/applications/settings/setting/PhabricatorFiletreeVisibleSetting.php | <?php
final class PhabricatorFiletreeVisibleSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'nav-collapsed';
public function getSettingName() {
return pht('Filetree Visible');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorOlderInlinesSetting.php | src/applications/settings/setting/PhabricatorOlderInlinesSetting.php | <?php
final class PhabricatorOlderInlinesSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'diff-ghosts';
const VALUE_GHOST_INLINES_ENABLED = 'default';
const VALUE_GHOST_INLINES_DISABLED = 'disabled';
public function getSettingName() {
return pht('Show Older Inlines');
}
protected function getSettingOrder() {
return 200;
}
public function getSettingPanelKey() {
return PhabricatorDiffPreferencesSettingsPanel::PANELKEY;
}
protected function getControlInstructions() {
return pht(
'When a revision is updated, this software attempts to bring inline '.
'comments on the older version forward to the new changes. You can '.
'disable this behavior if you prefer comments stay anchored in one '.
'place.');
}
public function getSettingDefaultValue() {
return self::VALUE_GHOST_INLINES_ENABLED;
}
protected function getSelectOptions() {
return array(
self::VALUE_GHOST_INLINES_ENABLED => pht('Enabled'),
self::VALUE_GHOST_INLINES_DISABLED => pht('Disabled'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorOptionGroupSetting.php | src/applications/settings/setting/PhabricatorOptionGroupSetting.php | <?php
abstract class PhabricatorOptionGroupSetting
extends PhabricatorSetting {
abstract protected function getSelectOptionGroups();
final protected function getSelectOptionMap() {
$groups = $this->getSelectOptionGroups();
$map = array();
foreach ($groups as $group) {
$map += $group['options'];
}
return $map;
}
final protected function newCustomEditField($object) {
$setting_key = $this->getSettingKey();
$default_value = $object->getDefaultValue($setting_key);
$options = $this->getSelectOptionGroups();
$map = $this->getSelectOptionMap();
if (isset($map[$default_value])) {
$default_label = pht('Default (%s)', $map[$default_value]);
} else {
$default_label = pht('Default (Unknown, "%s")', $default_value);
}
$head_key = head_key($options);
$options[$head_key]['options'] = array(
'' => $default_label,
) + $options[$head_key]['options'];
$flat_options = array();
foreach ($options as $group) {
$flat_options[$group['label']] = $group['options'];
}
return $this->newEditField($object, new PhabricatorSelectEditField())
->setOptions($flat_options);
}
final public function validateTransactionValue($value) {
if (!strlen($value)) {
return;
}
$map = $this->getSelectOptionMap();
if (!isset($map[$value])) {
throw new Exception(
pht(
'Value "%s" is not valid for setting "%s": valid values are %s.',
$value,
$this->getSettingName(),
implode(', ', array_keys($map))));
}
return;
}
public function getTransactionNewValue($value) {
if (!strlen($value)) {
return null;
}
return (string)$value;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorPinnedApplicationsSetting.php | src/applications/settings/setting/PhabricatorPinnedApplicationsSetting.php | <?php
final class PhabricatorPinnedApplicationsSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'app-pinned';
public function getSettingName() {
return pht('Pinned Applications');
}
public function getSettingDefaultValue() {
$viewer = PhabricatorUser::getOmnipotentUser();
$applications = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withInstalled(true)
->withUnlisted(false)
->withLaunchable(true)
->execute();
$pinned = array();
foreach ($applications as $application) {
if ($application->isPinnedByDefault($viewer)) {
$pinned[] = get_class($application);
}
}
return $pinned;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorFiletreeWidthSetting.php | src/applications/settings/setting/PhabricatorFiletreeWidthSetting.php | <?php
final class PhabricatorFiletreeWidthSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'filetree.width';
public function getSettingName() {
return pht('Filetree Width');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorTranslationSetting.php | src/applications/settings/setting/PhabricatorTranslationSetting.php | <?php
final class PhabricatorTranslationSetting
extends PhabricatorOptionGroupSetting {
const SETTINGKEY = 'translation';
public function getSettingName() {
return pht('Translation');
}
public function getSettingPanelKey() {
return PhabricatorLanguageSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 100;
}
public function getSettingDefaultValue() {
return 'en_US';
}
protected function getControlInstructions() {
return pht(
'Choose which language you would like the UI to use.');
}
public function assertValidValue($value) {
$locales = PhutilLocale::loadAllLocales();
return isset($locales[$value]);
}
protected function getSelectOptionGroups() {
$locales = PhutilLocale::loadAllLocales();
$group_labels = array(
'normal' => pht('Translations'),
'limited' => pht('Limited Translations'),
'silly' => pht('Silly Translations'),
'test' => pht('Developer/Test Translations'),
);
$groups = array_fill_keys(array_keys($group_labels), array());
$translations = array();
foreach ($locales as $locale) {
$code = $locale->getLocaleCode();
// Get the locale's localized name if it's available. For example,
// "Deutsch" instead of "German". This helps users who do not speak the
// current language to find the correct setting.
$raw_scope = PhabricatorEnv::beginScopedLocale($code);
$name = $locale->getLocaleName();
unset($raw_scope);
if ($locale->isSillyLocale()) {
$groups['silly'][$code] = $name;
continue;
}
if ($locale->isTestLocale()) {
$groups['test'][$code] = $name;
continue;
}
$strings = PhutilTranslation::getTranslationMapForLocale($code);
$size = count($strings);
// If a translation is English, assume it can fall back to the default
// strings and don't caveat its completeness.
$is_english = (substr($code, 0, 3) == 'en_');
// Arbitrarily pick some number of available strings to promote a
// translation out of the "limited" group. The major goal is just to
// keep locales with very few strings out of the main group, so users
// aren't surprised if a locale has no upstream translations available.
if ($size > 512 || $is_english) {
$type = 'normal';
} else {
$type = 'limited';
}
$groups[$type][$code] = $name;
}
// Omit silly locales on serious business installs.
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
if ($is_serious) {
unset($groups['silly']);
}
// Omit limited and test translations if Phabricator is not in developer
// mode.
$is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
if (!$is_dev) {
unset($groups['limited']);
unset($groups['test']);
}
$results = array();
foreach ($groups as $key => $group) {
$label = $group_labels[$key];
if (!$group) {
continue;
}
asort($group);
$results[] = array(
'label' => $label,
'options' => $group,
);
}
return $results;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorEmailVarySubjectsSetting.php | src/applications/settings/setting/PhabricatorEmailVarySubjectsSetting.php | <?php
final class PhabricatorEmailVarySubjectsSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'vary-subject';
const VALUE_VARY_SUBJECTS = 'vary';
const VALUE_STATIC_SUBJECTS = 'static';
public function getSettingName() {
return pht('Vary Subjects');
}
public function getSettingPanelKey() {
return PhabricatorEmailFormatSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 300;
}
protected function getControlInstructions() {
return pht(
'With **Vary Subjects** enabled, most mail subject lines will include '.
'a brief description of their content, like `[Closed]` for a '.
'notification about someone closing a task.'.
"\n\n".
"| Setting | Example Mail Subject\n".
"|----------------------|----------------\n".
"| Vary Subjects | ".
"`[Maniphest] [Closed] T123: Example Task`\n".
"| Do Not Vary Subjects | ".
"`[Maniphest] T123: Example Task`\n".
"\n".
'This can make mail more useful, but some clients have difficulty '.
'threading these messages. Disabling this option may improve '.
'threading at the cost of making subject lines less useful.');
}
public function getSettingDefaultValue() {
return self::VALUE_VARY_SUBJECTS;
}
protected function getSelectOptions() {
return array(
self::VALUE_VARY_SUBJECTS => pht('Enable Vary Subjects'),
self::VALUE_STATIC_SUBJECTS => pht('Disable Vary Subjects'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorAccessibilitySetting.php | src/applications/settings/setting/PhabricatorAccessibilitySetting.php | <?php
final class PhabricatorAccessibilitySetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'resource-postprocessor';
public function getSettingName() {
return pht('Accessibility');
}
public function getSettingPanelKey() {
return PhabricatorDisplayPreferencesSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 100;
}
protected function getControlInstructions() {
return pht(
'If you have difficulty reading the UI, this setting '.
'may help.');
}
public function getSettingDefaultValue() {
return CelerityDefaultPostprocessor::POSTPROCESSOR_KEY;
}
protected function getSelectOptions() {
$postprocessor_map = CelerityPostprocessor::getAllPostprocessors();
$postprocessor_map = mpull($postprocessor_map, 'getPostprocessorName');
asort($postprocessor_map);
$postprocessor_order = array(
CelerityDefaultPostprocessor::POSTPROCESSOR_KEY,
);
$postprocessor_map = array_select_keys(
$postprocessor_map,
$postprocessor_order) + $postprocessor_map;
return $postprocessor_map;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorPolicyFavoritesSetting.php | src/applications/settings/setting/PhabricatorPolicyFavoritesSetting.php | <?php
final class PhabricatorPolicyFavoritesSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'policy.favorites';
public function getSettingName() {
return pht('Policy Favorites');
}
public function getSettingDefaultValue() {
return array();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorTimezoneSetting.php | src/applications/settings/setting/PhabricatorTimezoneSetting.php | <?php
final class PhabricatorTimezoneSetting
extends PhabricatorOptionGroupSetting {
const SETTINGKEY = 'timezone';
public function getSettingName() {
return pht('Timezone');
}
public function getSettingPanelKey() {
return PhabricatorDateTimeSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 100;
}
protected function getControlInstructions() {
return pht('Select your local timezone.');
}
public function getSettingDefaultValue() {
return date_default_timezone_get();
}
public function assertValidValue($value) {
// NOTE: This isn't doing anything fancy, it's just a much faster
// validator than doing all the timezone calculations to build the full
// list of options.
if (!$value) {
return;
}
static $identifiers;
if ($identifiers === null) {
$identifiers = DateTimeZone::listIdentifiers();
$identifiers = array_fuse($identifiers);
}
if (isset($identifiers[$value])) {
return;
}
throw new Exception(
pht(
'Timezone "%s" is not a valid timezone identifier.',
$value));
}
protected function getSelectOptionGroups() {
$timezones = DateTimeZone::listIdentifiers();
$now = new DateTime('@'.PhabricatorTime::getNow());
$groups = array();
foreach ($timezones as $timezone) {
$zone = new DateTimeZone($timezone);
$offset = ($zone->getOffset($now) / 60);
$groups[$offset][] = $timezone;
}
ksort($groups);
$option_groups = array(
array(
'label' => pht('Default'),
'options' => array(),
),
);
foreach ($groups as $offset => $group) {
$hours = $offset / 60;
$minutes = abs($offset % 60);
if ($offset % 60) {
$label = pht('UTC%+d:%02d', $hours, $minutes);
} else {
$label = pht('UTC%+d', $hours);
}
sort($group);
$group_map = array();
foreach ($group as $identifier) {
$name = PhabricatorTime::getTimezoneDisplayName($identifier);
$group_map[$identifier] = $name;
}
$option_groups[] = array(
'label' => $label,
'options' => $group_map,
);
}
return $option_groups;
}
public function expandSettingTransaction($object, $xaction) {
// When the user changes their timezone, we also clear any ignored
// timezone offset.
return array(
$xaction,
$this->newSettingTransaction(
$object,
PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY,
null),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorDarkConsoleVisibleSetting.php | src/applications/settings/setting/PhabricatorDarkConsoleVisibleSetting.php | <?php
final class PhabricatorDarkConsoleVisibleSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'darkconsole.visible';
public function getSettingName() {
return pht('DarkConsole Visible');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php | src/applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php | <?php
final class PhabricatorConpherenceNotificationsSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'conph-notifications';
const VALUE_CONPHERENCE_EMAIL = '0';
const VALUE_CONPHERENCE_NOTIFY = '1';
public function getSettingName() {
return pht('Conpherence Notifications');
}
public function getSettingPanelKey() {
return PhabricatorConpherencePreferencesSettingsPanel::PANELKEY;
}
protected function getControlInstructions() {
return pht(
'Choose the default notification behavior for Conpherence rooms.');
}
protected function isEnabledForViewer(PhabricatorUser $viewer) {
return PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorConpherenceApplication',
$viewer);
}
public function getSettingDefaultValue() {
return self::VALUE_CONPHERENCE_EMAIL;
}
protected function getSelectOptions() {
return self::getOptionsMap();
}
public static function getSettingLabel($key) {
$labels = self::getOptionsMap();
return idx($labels, $key, pht('Unknown ("%s")', $key));
}
private static function getOptionsMap() {
return array(
self::VALUE_CONPHERENCE_EMAIL => pht('Send Email'),
self::VALUE_CONPHERENCE_NOTIFY => pht('Send Notifications'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/settings/setting/PhabricatorMonospacedTextareasSetting.php | src/applications/settings/setting/PhabricatorMonospacedTextareasSetting.php | <?php
final class PhabricatorMonospacedTextareasSetting
extends PhabricatorSelectSetting {
const SETTINGKEY = 'monospaced-textareas';
const VALUE_TEXT_VARIABLE_WIDTH = 'disabled';
const VALUE_TEXT_MONOSPACED = 'enabled';
public function getSettingName() {
return pht('Monospaced Textareas');
}
public function getSettingPanelKey() {
return PhabricatorDisplayPreferencesSettingsPanel::PANELKEY;
}
protected function getSettingOrder() {
return 600;
}
protected function getControlInstructions() {
return pht(
'You can choose to use either a monospaced or variable-width font '.
'in textareas in the UI. Textareas are used for editing descriptions '.
'and writing comments, among other things.');
}
public function getSettingDefaultValue() {
return self::VALUE_TEXT_VARIABLE_WIDTH;
}
protected function getSelectOptions() {
return array(
self::VALUE_TEXT_VARIABLE_WIDTH => pht('Use Variable-Width Font'),
self::VALUE_TEXT_MONOSPACED => pht('Use Monospaced Font'),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/controller/PhabricatorChatLogChannelLogController.php | src/applications/chatlog/controller/PhabricatorChatLogChannelLogController.php | <?php
final class PhabricatorChatLogChannelLogController
extends PhabricatorChatLogController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('channelID');
$uri = new PhutilURI($request->getPath());
$pager = new AphrontCursorPagerView();
$pager->setURI($uri);
$pager->setPageSize(250);
$query = id(new PhabricatorChatLogQuery())
->setViewer($viewer)
->withChannelIDs(array($id));
$channel = id(new PhabricatorChatLogChannelQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$channel) {
return new Aphront404Response();
}
list($after, $before, $map) = $this->getPagingParameters($request, $query);
$pager->setAfterID($after);
$pager->setBeforeID($before);
$logs = $query->executeWithCursorPager($pager);
// Show chat logs oldest-first.
$logs = array_reverse($logs);
// Divide all the logs into blocks, where a block is the same author saying
// several things in a row. A block ends when another user speaks, or when
// two minutes pass without the author speaking.
$blocks = array();
$block = null;
$last_author = null;
$last_epoch = null;
foreach ($logs as $log) {
$this_author = $log->getAuthor();
$this_epoch = $log->getEpoch();
// Decide whether we should start a new block or not.
$new_block = ($this_author !== $last_author) ||
($this_epoch - (60 * 2) > $last_epoch);
if ($new_block) {
if ($block) {
$blocks[] = $block;
}
$block = array(
'id' => $log->getID(),
'epoch' => $this_epoch,
'author' => $this_author,
'logs' => array($log),
);
} else {
$block['logs'][] = $log;
}
$last_author = $this_author;
$last_epoch = $this_epoch;
}
if ($block) {
$blocks[] = $block;
}
// Figure out CSS classes for the blocks. We alternate colors between
// lines, and highlight the entire block which contains the target ID or
// date, if applicable.
foreach ($blocks as $key => $block) {
$classes = array();
if ($key % 2) {
$classes[] = 'alternate';
}
$ids = mpull($block['logs'], 'getID', 'getID');
if (array_intersect_key($ids, $map)) {
$classes[] = 'highlight';
}
$blocks[$key]['class'] = $classes ? implode(' ', $classes) : null;
}
require_celerity_resource('phabricator-chatlog-css');
$out = array();
foreach ($blocks as $block) {
$author = $block['author'];
$author = id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(18)
->truncateString($author);
$author = phutil_tag('td', array('class' => 'author'), $author);
$href = $uri->alter('at', $block['id']);
$timestamp = $block['epoch'];
$timestamp = phabricator_datetime($timestamp, $viewer);
$timestamp = phutil_tag(
'a',
array(
'href' => $href,
'class' => 'timestamp',
),
$timestamp);
$message = mpull($block['logs'], 'getMessage');
$message = implode("\n", $message);
$message = phutil_tag(
'td',
array(
'class' => 'message',
),
array(
$timestamp,
$message,
));
$out[] = phutil_tag(
'tr',
array(
'class' => $block['class'],
),
array(
$author,
$message,
));
}
$links = array();
$first_uri = $pager->getFirstPageURI();
if ($first_uri) {
$links[] = phutil_tag(
'a',
array(
'href' => $first_uri,
),
"\xC2\xAB ".pht('Newest'));
}
$prev_uri = $pager->getPrevPageURI();
if ($prev_uri) {
$links[] = phutil_tag(
'a',
array(
'href' => $prev_uri,
),
"\xE2\x80\xB9 ".pht('Newer'));
}
$next_uri = $pager->getNextPageURI();
if ($next_uri) {
$links[] = phutil_tag(
'a',
array(
'href' => $next_uri,
),
pht('Older')." \xE2\x80\xBA");
}
$pager_bottom = phutil_tag(
'div',
array('class' => 'phabricator-chat-log-pager-bottom'),
$links);
$crumbs = $this
->buildApplicationCrumbs()
->addTextCrumb($channel->getChannelName(), $uri);
$form = id(new AphrontFormView())
->setUser($viewer)
->setMethod('GET')
->setAction($uri)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Date'))
->setName('date')
->setValue($request->getStr('date')))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Jump')));
$table = phutil_tag(
'table',
array(
'class' => 'phabricator-chat-log',
),
$out);
$log = phutil_tag(
'div',
array(
'class' => 'phabricator-chat-log-panel',
),
$table);
$jump_link = id(new PHUIButtonView())
->setTag('a')
->setHref('#latest')
->setText(pht('Jump to Bottom'))
->setIcon('fa-arrow-circle-down');
$jump_target = phutil_tag(
'div',
array(
'id' => 'latest',
));
$content = phutil_tag(
'div',
array(
'class' => 'phabricator-chat-log-wrap',
),
array(
$log,
$jump_target,
$pager_bottom,
));
$header = id(new PHUIHeaderView())
->setHeader($channel->getChannelName())
->setSubHeader($channel->getServiceName())
->addActionLink($jump_link);
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->setCollapsed(true)
->appendChild($content);
$box->setShowHide(
pht('Search Dates'),
pht('Hide Dates'),
$form,
'#');
return $this->newPage()
->setTitle(pht('Channel Log'))
->setCrumbs($crumbs)
->appendChild($box);
}
/**
* From request parameters, figure out where we should jump to in the log.
* We jump to either a date or log ID, but load a few lines of context before
* it so the user can see the nearby conversation.
*/
private function getPagingParameters(
AphrontRequest $request,
PhabricatorChatLogQuery $query) {
$viewer = $request->getViewer();
$at_id = $request->getInt('at');
$at_date = $request->getStr('date');
$context_log = null;
$map = array();
$query = clone $query;
$query->setLimit(8);
if ($at_id) {
// Jump to the log in question, and load a few lines of context before
// it.
$context_logs = $query
->setAfterID($at_id)
->execute();
$context_log = last($context_logs);
$map = array(
$at_id => true,
);
} else if ($at_date) {
$timestamp = PhabricatorTime::parseLocalTime($at_date, $viewer);
if ($timestamp) {
$context_logs = $query
->withMaximumEpoch($timestamp)
->execute();
$context_log = last($context_logs);
$target_log = head($context_logs);
if ($target_log) {
$map = array(
$target_log->getID() => true,
);
}
}
}
if ($context_log) {
$after = null;
$before = $context_log->getID() - 1;
} else {
$after = $request->getInt('after');
$before = $request->getInt('before');
}
return array($after, $before, $map);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/controller/PhabricatorChatLogChannelListController.php | src/applications/chatlog/controller/PhabricatorChatLogChannelListController.php | <?php
final class PhabricatorChatLogChannelListController
extends PhabricatorChatLogController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$channels = id(new PhabricatorChatLogChannelQuery())
->setViewer($viewer)
->execute();
$list = new PHUIObjectItemListView();
foreach ($channels as $channel) {
$item = id(new PHUIObjectItemView())
->setHeader($channel->getChannelName())
->setHref('/chatlog/channel/'.$channel->getID().'/')
->addAttribute($channel->getServiceName())
->addAttribute($channel->getServiceType());
$list->addItem($item);
}
$crumbs = $this
->buildApplicationCrumbs()
->addTextCrumb(pht('Channel List'), $this->getApplicationURI());
$box = id(new PHUIObjectBoxView())
->setHeaderText('Channel List')
->setObjectList($list);
return $this->newPage()
->setTitle(pht('Channel List'))
->setCrumbs($crumbs)
->appendChild($box);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/controller/PhabricatorChatLogController.php | src/applications/chatlog/controller/PhabricatorChatLogController.php | <?php
abstract class PhabricatorChatLogController extends PhabricatorController {}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/storage/PhabricatorChatLogDAO.php | src/applications/chatlog/storage/PhabricatorChatLogDAO.php | <?php
abstract class PhabricatorChatLogDAO extends PhabricatorLiskDAO {
public function getApplicationName() {
return 'chatlog';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/storage/PhabricatorChatLogChannel.php | src/applications/chatlog/storage/PhabricatorChatLogChannel.php | <?php
final class PhabricatorChatLogChannel
extends PhabricatorChatLogDAO
implements PhabricatorPolicyInterface {
protected $serviceName;
protected $serviceType;
protected $channelName;
protected $viewPolicy;
protected $editPolicy;
protected function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'serviceName' => 'text64',
'serviceType' => 'text32',
'channelName' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_channel' => array(
'columns' => array('channelName', 'serviceType', 'serviceName'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->viewPolicy;
break;
case PhabricatorPolicyCapability::CAN_EDIT:
return $this->editPolicy;
break;
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/storage/PhabricatorChatLogEvent.php | src/applications/chatlog/storage/PhabricatorChatLogEvent.php | <?php
final class PhabricatorChatLogEvent
extends PhabricatorChatLogDAO
implements PhabricatorPolicyInterface {
protected $channelID;
protected $epoch;
protected $author;
protected $type;
protected $message;
protected $loggedByPHID;
private $channel = self::ATTACHABLE;
protected function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'author' => 'text64',
'type' => 'text4',
'message' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'channel' => array(
'columns' => array('epoch'),
),
),
) + parent::getConfiguration();
}
public function attachChannel(PhabricatorChatLogChannel $channel) {
$this->channel = $channel;
return $this;
}
public function getChannel() {
return $this->assertAttached($this->channel);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
return $this->getChannel()->getPolicy($capability);
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return $this->getChannel()->hasAutomaticCapability($capability, $viewer);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php | src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php | <?php
final class PhabricatorChatLogChannelQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $channels;
private $channelIDs;
public function withChannelNames(array $channels) {
$this->channels = $channels;
return $this;
}
public function withIDs(array $channel_ids) {
$this->channelIDs = $channel_ids;
return $this;
}
protected function loadPage() {
$table = new PhabricatorChatLogChannel();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T c %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
$logs = $table->loadAllFromArray($data);
return $logs;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn);
if ($this->channelIDs) {
$where[] = qsprintf(
$conn,
'id IN (%Ld)',
$this->channelIDs);
}
if ($this->channels) {
$where[] = qsprintf(
$conn,
'channelName IN (%Ls)',
$this->channels);
}
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {
return 'PhabricatorChatLogApplication';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/query/PhabricatorChatLogQuery.php | src/applications/chatlog/query/PhabricatorChatLogQuery.php | <?php
final class PhabricatorChatLogQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $channelIDs;
private $maximumEpoch;
public function withChannelIDs(array $channel_ids) {
$this->channelIDs = $channel_ids;
return $this;
}
public function withMaximumEpoch($epoch) {
$this->maximumEpoch = $epoch;
return $this;
}
protected function loadPage() {
$table = new PhabricatorChatLogEvent();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T e %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
$logs = $table->loadAllFromArray($data);
return $logs;
}
protected function willFilterPage(array $events) {
$channel_ids = mpull($events, 'getChannelID', 'getChannelID');
$channels = id(new PhabricatorChatLogChannelQuery())
->setViewer($this->getViewer())
->withIDs($channel_ids)
->execute();
$channels = mpull($channels, null, 'getID');
foreach ($events as $key => $event) {
$channel = idx($channels, $event->getChannelID());
if (!$channel) {
unset($events[$key]);
continue;
}
$event->attachChannel($channel);
}
return $events;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
$where[] = $this->buildPagingClause($conn);
if ($this->maximumEpoch !== null) {
$where[] = qsprintf(
$conn,
'epoch <= %d',
$this->maximumEpoch);
}
if ($this->channelIDs !== null) {
$where[] = qsprintf(
$conn,
'channelID IN (%Ld)',
$this->channelIDs);
}
return $this->formatWhereClause($conn, $where);
}
public function getQueryApplicationClass() {
return 'PhabricatorChatLogApplication';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/application/PhabricatorChatLogApplication.php | src/applications/chatlog/application/PhabricatorChatLogApplication.php | <?php
final class PhabricatorChatLogApplication extends PhabricatorApplication {
public function getBaseURI() {
return '/chatlog/';
}
public function getName() {
return pht('ChatLog');
}
public function getShortDescription() {
return pht('(Deprecated)');
}
public function getIcon() {
return 'fa-coffee';
}
public function isPrototype() {
return true;
}
public function getTitleGlyph() {
return "\xE0\xBC\x84";
}
public function getApplicationGroup() {
return self::GROUP_UTILITIES;
}
public function getRoutes() {
return array(
'/chatlog/' => array(
'' => 'PhabricatorChatLogChannelListController',
'channel/(?P<channelID>[^/]+)/'
=> 'PhabricatorChatLogChannelLogController',
),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/conduit/ChatLogRecordConduitAPIMethod.php | src/applications/chatlog/conduit/ChatLogRecordConduitAPIMethod.php | <?php
final class ChatLogRecordConduitAPIMethod extends ChatLogConduitAPIMethod {
public function getAPIMethodName() {
return 'chatlog.record';
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return pht('Record chatter.');
}
protected function defineParamTypes() {
return array(
'logs' => 'required list<dict>',
);
}
protected function defineReturnType() {
return 'list<id>';
}
protected function execute(ConduitAPIRequest $request) {
$logs = $request->getValue('logs');
if (!is_array($logs)) {
$logs = array();
}
$template = new PhabricatorChatLogEvent();
$template->setLoggedByPHID($request->getUser()->getPHID());
$objs = array();
foreach ($logs as $log) {
$channel_name = idx($log, 'channel');
$service_name = idx($log, 'serviceName');
$service_type = idx($log, 'serviceType');
$channel = id(new PhabricatorChatLogChannel())->loadOneWhere(
'channelName = %s AND serviceName = %s AND serviceType = %s',
$channel_name,
$service_name,
$service_type);
if (!$channel) {
$channel = id(new PhabricatorChatLogChannel())
->setChannelName($channel_name)
->setserviceName($service_name)
->setServiceType($service_type)
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
->save();
}
$obj = clone $template;
$obj->setChannelID($channel->getID());
$obj->setType(idx($log, 'type'));
$obj->setAuthor(idx($log, 'author'));
$obj->setEpoch(idx($log, 'epoch'));
$obj->setMessage(idx($log, 'message'));
$obj->save();
$objs[] = $obj;
}
return array_values(mpull($objs, 'getID'));
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/conduit/ChatLogConduitAPIMethod.php | src/applications/chatlog/conduit/ChatLogConduitAPIMethod.php | <?php
abstract class ChatLogConduitAPIMethod extends ConduitAPIMethod {
final public function getApplication() {
return PhabricatorApplication::getByClass('PhabricatorChatLogApplication');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/chatlog/conduit/ChatLogQueryConduitAPIMethod.php | src/applications/chatlog/conduit/ChatLogQueryConduitAPIMethod.php | <?php
final class ChatLogQueryConduitAPIMethod extends ChatLogConduitAPIMethod {
public function getAPIMethodName() {
return 'chatlog.query';
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return pht('Retrieve chatter.');
}
protected function defineParamTypes() {
return array(
'channels' => 'optional list<string>',
'limit' => 'optional int (default = 100)',
);
}
protected function defineReturnType() {
return 'nonempty list<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$query = new PhabricatorChatLogQuery();
$channel_ids = $request->getValue('channelIDs');
if ($channel_ids) {
$query->withChannelIDs($channel_ids);
}
$limit = $request->getValue('limit');
if (!$limit) {
$limit = 100;
}
$query->setLimit($limit);
$logs = $query->execute();
$results = array();
foreach ($logs as $log) {
$results[] = array(
'channelID' => $log->getChannelID(),
'epoch' => $log->getEpoch(),
'author' => $log->getAuthor(),
'type' => $log->getType(),
'message' => $log->getMessage(),
'loggedByPHID' => $log->getLoggedByPHID(),
);
}
return $results;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php | <?php
final class PhabricatorAphlictManagementDebugWorkflow
extends PhabricatorAphlictManagementWorkflow {
protected function didConstruct() {
$this
->setName('debug')
->setSynopsis(
pht(
'Start the notifications server in the foreground and print large '.
'volumes of diagnostic information to the console.'))
->setArguments($this->getLaunchArguments());
}
public function execute(PhutilArgumentParser $args) {
$this->parseLaunchArguments($args);
$this->setDebug(true);
$this->willLaunch();
return $this->launch();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementRestartWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementRestartWorkflow.php | <?php
final class PhabricatorAphlictManagementRestartWorkflow
extends PhabricatorAphlictManagementWorkflow {
protected function didConstruct() {
$this
->setName('restart')
->setSynopsis(pht('Stop, then start the notification server.'))
->setArguments($this->getLaunchArguments());
}
public function execute(PhutilArgumentParser $args) {
$this->parseLaunchArguments($args);
$err = $this->executeStopCommand();
if ($err) {
return $err;
}
return $this->executeStartCommand();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php | <?php
final class PhabricatorAphlictManagementStartWorkflow
extends PhabricatorAphlictManagementWorkflow {
protected function didConstruct() {
$this
->setName('start')
->setSynopsis(pht('Start the notifications server.'))
->setArguments($this->getLaunchArguments());
}
public function execute(PhutilArgumentParser $args) {
$this->parseLaunchArguments($args);
return $this->executeStartCommand();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementStatusWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementStatusWorkflow.php | <?php
final class PhabricatorAphlictManagementStatusWorkflow
extends PhabricatorAphlictManagementWorkflow {
protected function didConstruct() {
$this
->setName('status')
->setSynopsis(pht('Show the status of the notification server.'))
->setArguments($this->getLaunchArguments());
}
public function execute(PhutilArgumentParser $args) {
$this->parseLaunchArguments($args);
$console = PhutilConsole::getConsole();
$pid = $this->getPID();
if (!$pid) {
$console->writeErr("%s\n", pht('Aphlict is not running.'));
return 1;
}
$console->writeOut("%s\n", pht('Aphlict (%s) is running.', $pid));
return 0;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementNotifyWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementNotifyWorkflow.php | <?php
final class PhabricatorAphlictManagementNotifyWorkflow
extends PhabricatorAphlictManagementWorkflow {
protected function didConstruct() {
$this
->setName('notify')
->setSynopsis(pht('Send a notification to a user.'))
->setArguments(
array(
array(
'name' => 'user',
'param' => 'username',
'help' => pht('User to notify.'),
),
array(
'name' => 'message',
'param' => 'text',
'help' => pht('Message to send.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$viewer = $this->getViewer();
$username = $args->getArg('user');
if (!strlen($username)) {
throw new PhutilArgumentUsageException(
pht(
'Specify a user to notify with "--user".'));
}
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withUsernames(array($username))
->executeOne();
if (!$user) {
throw new PhutilArgumentUsageException(
pht(
'No user with username "%s" exists.',
$username));
}
$message = $args->getArg('message');
if (!strlen($message)) {
throw new PhutilArgumentUsageException(
pht(
'Specify a message to send with "--message".'));
}
$application_phid = id(new PhabricatorNotificationsApplication())
->getPHID();
$content_source = $this->newContentSource();
$xactions = array();
$xactions[] = id(new PhabricatorUserTransaction())
->setTransactionType(
PhabricatorUserNotifyTransaction::TRANSACTIONTYPE)
->setNewValue($message)
->setForceNotifyPHIDs(array($user->getPHID()));
$editor = id(new PhabricatorUserTransactionEditor())
->setActor($viewer)
->setActingAsPHID($application_phid)
->setContentSource($content_source);
$editor->applyTransactions($user, $xactions);
echo tsprintf(
"%s\n",
pht('Sent notification.'));
return 0;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php | <?php
abstract class PhabricatorAphlictManagementWorkflow
extends PhabricatorManagementWorkflow {
private $debug = false;
private $configData;
private $configPath;
final protected function setDebug($debug) {
$this->debug = $debug;
return $this;
}
protected function getLaunchArguments() {
return array(
array(
'name' => 'config',
'param' => 'file',
'help' => pht(
'Use a specific configuration file instead of the default '.
'configuration.'),
),
);
}
protected function parseLaunchArguments(PhutilArgumentParser $args) {
$config_file = $args->getArg('config');
if ($config_file) {
$full_path = Filesystem::resolvePath($config_file);
$show_path = $full_path;
} else {
$root = dirname(dirname(phutil_get_library_root('phabricator')));
$try = array(
'phabricator/conf/aphlict/aphlict.custom.json',
'phabricator/conf/aphlict/aphlict.default.json',
);
foreach ($try as $config) {
$full_path = $root.'/'.$config;
$show_path = $config;
if (Filesystem::pathExists($full_path)) {
break;
}
}
}
echo tsprintf(
"%s\n",
pht(
'Reading configuration from: %s',
$show_path));
try {
$data = Filesystem::readFile($full_path);
} catch (Exception $ex) {
throw new PhutilArgumentUsageException(
pht(
'Failed to read configuration file. %s',
$ex->getMessage()));
}
try {
$data = phutil_json_decode($data);
} catch (Exception $ex) {
throw new PhutilArgumentUsageException(
pht(
'Configuration file is not properly formatted JSON. %s',
$ex->getMessage()));
}
try {
PhutilTypeSpec::checkMap(
$data,
array(
'servers' => 'list<wild>',
'logs' => 'optional list<wild>',
'cluster' => 'optional list<wild>',
'pidfile' => 'string',
'memory.hint' => 'optional int',
));
} catch (Exception $ex) {
throw new PhutilArgumentUsageException(
pht(
'Configuration file has improper configuration keys at top '.
'level. %s',
$ex->getMessage()));
}
$servers = $data['servers'];
$has_client = false;
$has_admin = false;
$port_map = array();
foreach ($servers as $index => $server) {
PhutilTypeSpec::checkMap(
$server,
array(
'type' => 'string',
'port' => 'int',
'listen' => 'optional string|null',
'ssl.key' => 'optional string|null',
'ssl.cert' => 'optional string|null',
'ssl.chain' => 'optional string|null',
));
$port = $server['port'];
if (!isset($port_map[$port])) {
$port_map[$port] = $index;
} else {
throw new PhutilArgumentUsageException(
pht(
'Two servers (at indexes "%s" and "%s") both bind to the same '.
'port ("%s"). Each server must bind to a unique port.',
$port_map[$port],
$index,
$port));
}
$type = $server['type'];
switch ($type) {
case 'admin':
$has_admin = true;
break;
case 'client':
$has_client = true;
break;
default:
throw new PhutilArgumentUsageException(
pht(
'A specified server (at index "%s", on port "%s") has an '.
'invalid type ("%s"). Valid types are: admin, client.',
$index,
$port,
$type));
}
$ssl_key = idx($server, 'ssl.key');
$ssl_cert = idx($server, 'ssl.cert');
if (($ssl_key && !$ssl_cert) || ($ssl_cert && !$ssl_key)) {
throw new PhutilArgumentUsageException(
pht(
'A specified server (at index "%s", on port "%s") specifies '.
'only one of "%s" and "%s". Each server must specify neither '.
'(to disable SSL) or specify both (to enable it).',
$index,
$port,
'ssl.key',
'ssl.cert'));
}
$ssl_chain = idx($server, 'ssl.chain');
if ($ssl_chain && (!$ssl_key && !$ssl_cert)) {
throw new PhutilArgumentUsageException(
pht(
'A specified server (at index "%s", on port "%s") specifies '.
'a value for "%s", but no value for "%s" or "%s". Servers '.
'should only provide an SSL chain if they also provide an SSL '.
'key and SSL certificate.',
$index,
$port,
'ssl.chain',
'ssl.key',
'ssl.cert'));
}
}
if (!$servers) {
throw new PhutilArgumentUsageException(
pht(
'Configuration file does not specify any servers. This service '.
'will not be able to interact with the outside world if it does '.
'not listen on any ports. You must specify at least one "%s" '.
'server and at least one "%s" server.',
'admin',
'client'));
}
if (!$has_client) {
throw new PhutilArgumentUsageException(
pht(
'Configuration file does not specify any client servers. This '.
'service will be unable to transmit any notifications without a '.
'client server. You must specify at least one server with '.
'type "%s".',
'client'));
}
if (!$has_admin) {
throw new PhutilArgumentUsageException(
pht(
'Configuration file does not specify any administrative '.
'servers. This service will be unable to receive messages. '.
'You must specify at least one server with type "%s".',
'admin'));
}
$logs = idx($data, 'logs', array());
foreach ($logs as $index => $log) {
PhutilTypeSpec::checkMap(
$log,
array(
'path' => 'string',
));
$path = $log['path'];
try {
$dir = dirname($path);
if (!Filesystem::pathExists($dir)) {
Filesystem::createDirectory($dir, 0755, true);
}
} catch (FilesystemException $ex) {
throw new PhutilArgumentUsageException(
pht(
'Failed to create directory "%s" for specified log file (with '.
'index "%s"). You should manually create this directory or '.
'choose a different logfile location. %s',
$dir,
$index,
$ex->getMessage()));
}
}
$peer_map = array();
$cluster = idx($data, 'cluster', array());
foreach ($cluster as $index => $peer) {
PhutilTypeSpec::checkMap(
$peer,
array(
'host' => 'string',
'port' => 'int',
'protocol' => 'string',
));
$host = $peer['host'];
$port = $peer['port'];
$protocol = $peer['protocol'];
switch ($protocol) {
case 'http':
case 'https':
break;
default:
throw new PhutilArgumentUsageException(
pht(
'Configuration file specifies cluster peer ("%s", at index '.
'"%s") with an invalid protocol, "%s". Valid protocols are '.
'"%s" or "%s".',
$host,
$index,
$protocol,
'http',
'https'));
}
$peer_key = "{$host}:{$port}";
if (!isset($peer_map[$peer_key])) {
$peer_map[$peer_key] = $index;
} else {
throw new PhutilArgumentUsageException(
pht(
'Configuration file specifies cluster peer "%s" more than '.
'once (at indexes "%s" and "%s"). Each peer must have a '.
'unique host and port combination.',
$peer_key,
$peer_map[$peer_key],
$index));
}
}
$this->configData = $data;
$this->configPath = $full_path;
$pid_path = $this->getPIDPath();
try {
$dir = dirname($pid_path);
if (!Filesystem::pathExists($dir)) {
Filesystem::createDirectory($dir, 0755, true);
}
} catch (FilesystemException $ex) {
throw new PhutilArgumentUsageException(
pht(
'Failed to create directory "%s" for specified PID file. You '.
'should manually create this directory or choose a different '.
'PID file location. %s',
$dir,
$ex->getMessage()));
}
}
final public function getPIDPath() {
return $this->configData['pidfile'];
}
final public function getPID() {
$pid = null;
if (Filesystem::pathExists($this->getPIDPath())) {
$pid = (int)Filesystem::readFile($this->getPIDPath());
}
return $pid;
}
final public function cleanup($signo = null) {
global $g_future;
if ($g_future) {
$g_future->resolveKill();
$g_future = null;
}
Filesystem::remove($this->getPIDPath());
if ($signo !== null) {
$signame = phutil_get_signal_name($signo);
error_log("Caught signal {$signame}, exiting.");
}
exit(1);
}
public static function requireExtensions() {
self::mustHaveExtension('pcntl');
self::mustHaveExtension('posix');
}
private static function mustHaveExtension($ext) {
if (!extension_loaded($ext)) {
echo pht(
"ERROR: The PHP extension '%s' is not installed. You must ".
"install it to run Aphlict on this machine.",
$ext)."\n";
exit(1);
}
$extension = new ReflectionExtension($ext);
foreach ($extension->getFunctions() as $function) {
$function = $function->name;
if (!function_exists($function)) {
echo pht(
'ERROR: The PHP function %s is disabled. You must '.
'enable it to run Aphlict on this machine.',
$function.'()')."\n";
exit(1);
}
}
}
final protected function willLaunch() {
$console = PhutilConsole::getConsole();
$pid = $this->getPID();
if ($pid) {
throw new PhutilArgumentUsageException(
pht(
'Unable to start notifications server because it is already '.
'running. Use `%s` to restart it.',
'aphlict restart'));
}
if (posix_getuid() == 0) {
throw new PhutilArgumentUsageException(
pht('The notification server should not be run as root.'));
}
// Make sure we can write to the PID file.
if (!$this->debug) {
Filesystem::writeFile($this->getPIDPath(), '');
}
// First, start the server in configuration test mode with --test. This
// will let us error explicitly if there are missing modules, before we
// fork and lose access to the console.
$test_argv = $this->getServerArgv();
$test_argv[] = '--test=true';
execx('%C', $this->getStartCommand($test_argv));
}
private function getServerArgv() {
$server_argv = array();
$server_argv[] = '--config='.$this->configPath;
return $server_argv;
}
final protected function launch() {
$console = PhutilConsole::getConsole();
if ($this->debug) {
$console->writeOut(
"%s\n",
pht('Starting Aphlict server in foreground...'));
} else {
Filesystem::writeFile($this->getPIDPath(), getmypid());
}
$command = $this->getStartCommand($this->getServerArgv());
if (!$this->debug) {
declare(ticks = 1);
pcntl_signal(SIGINT, array($this, 'cleanup'));
pcntl_signal(SIGTERM, array($this, 'cleanup'));
}
register_shutdown_function(array($this, 'cleanup'));
if ($this->debug) {
$console->writeOut(
"%s\n\n $ %s\n\n",
pht('Launching server:'),
$command);
$err = phutil_passthru('%C', $command);
$console->writeOut(">>> %s\n", pht('Server exited!'));
exit($err);
} else {
while (true) {
global $g_future;
$g_future = new ExecFuture('exec %C', $command);
// Discard all output the subprocess produces: it writes to the log on
// disk, so we don't need to send the output anywhere and can just
// throw it away.
$g_future
->setStdoutSizeLimit(0)
->setStderrSizeLimit(0);
$g_future->resolve();
// If the server exited, wait a couple of seconds and restart it.
unset($g_future);
sleep(2);
}
}
}
/* -( Commands )----------------------------------------------------------- */
final protected function executeStartCommand() {
$console = PhutilConsole::getConsole();
$this->willLaunch();
$log = $this->getOverseerLogPath();
if ($log !== null) {
echo tsprintf(
"%s\n",
pht(
'Writing logs to: %s',
$log));
}
$pid = pcntl_fork();
if ($pid < 0) {
throw new Exception(
pht(
'Failed to %s!',
'fork()'));
} else if ($pid) {
$console->writeErr("%s\n", pht('Aphlict Server started.'));
exit(0);
}
// Redirect process errors to the error log. If we do not do this, any
// error the `aphlict` process itself encounters vanishes into thin air.
if ($log !== null) {
ini_set('error_log', $log);
}
// When we fork, the child process will inherit its parent's set of open
// file descriptors. If the parent process of bin/aphlict is waiting for
// bin/aphlict's file descriptors to close, it will be stuck waiting on
// the daemonized process. (This happens if e.g. bin/aphlict is started
// in another script using passthru().)
fclose(STDOUT);
fclose(STDERR);
$this->launch();
return 0;
}
final protected function executeStopCommand() {
$console = PhutilConsole::getConsole();
$pid = $this->getPID();
if (!$pid) {
$console->writeErr("%s\n", pht('Aphlict is not running.'));
return 0;
}
$console->writeErr("%s\n", pht('Stopping Aphlict Server (%s)...', $pid));
posix_kill($pid, SIGINT);
$start = time();
do {
if (!PhabricatorDaemonReference::isProcessRunning($pid)) {
$console->writeOut(
"%s\n",
pht('Aphlict Server (%s) exited normally.', $pid));
$pid = null;
break;
}
usleep(100000);
} while (time() < $start + 5);
if ($pid) {
$console->writeErr("%s\n", pht('Sending %s a SIGKILL.', $pid));
posix_kill($pid, SIGKILL);
unset($pid);
}
Filesystem::remove($this->getPIDPath());
return 0;
}
private function getNodeBinary() {
if (Filesystem::binaryExists('nodejs')) {
return 'nodejs';
}
if (Filesystem::binaryExists('node')) {
return 'node';
}
throw new PhutilArgumentUsageException(
pht(
'No `%s` or `%s` binary was found in %s. You must install '.
'Node.js to start the Aphlict server.',
'nodejs',
'node',
'$PATH'));
}
private function getAphlictScriptPath() {
$root = dirname(phutil_get_library_root('phabricator'));
return $root.'/support/aphlict/server/aphlict_server.js';
}
private function getNodeArgv() {
$argv = array();
$hint = idx($this->configData, 'memory.hint');
$hint = nonempty($hint, 256);
$argv[] = sprintf('--max-old-space-size=%d', $hint);
return $argv;
}
private function getStartCommand(array $server_argv) {
$launch_argv = array();
if ($this->debug) {
$launch_argv[] = '--debug=1';
}
return csprintf(
'%R %Ls -- %s %Ls %Ls',
$this->getNodeBinary(),
$this->getNodeArgv(),
$this->getAphlictScriptPath(),
$launch_argv,
$server_argv);
}
private function getOverseerLogPath() {
// For now, just return the first log. We could refine this eventually.
$logs = idx($this->configData, 'logs', array());
foreach ($logs as $log) {
return $log['path'];
}
return null;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/management/PhabricatorAphlictManagementStopWorkflow.php | src/applications/aphlict/management/PhabricatorAphlictManagementStopWorkflow.php | <?php
final class PhabricatorAphlictManagementStopWorkflow
extends PhabricatorAphlictManagementWorkflow {
protected function didConstruct() {
$this
->setName('stop')
->setSynopsis(pht('Stop the notification server.'))
->setArguments($this->getLaunchArguments());
}
public function execute(PhutilArgumentParser $args) {
$this->parseLaunchArguments($args);
return $this->executeStopCommand();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/aphlict/query/AphlictDropdownDataQuery.php | src/applications/aphlict/query/AphlictDropdownDataQuery.php | <?php
final class AphlictDropdownDataQuery extends Phobject {
private $viewer;
private $notificationData;
private $conpherenceData;
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function getViewer() {
return $this->viewer;
}
private function setNotificationData(array $data) {
$this->notificationData = $data;
return $this;
}
public function getNotificationData() {
if ($this->notificationData === null) {
throw new Exception(pht('You must %s first!', 'execute()'));
}
return $this->notificationData;
}
private function setConpherenceData(array $data) {
$this->conpherenceData = $data;
return $this;
}
public function getConpherenceData() {
if ($this->conpherenceData === null) {
throw new Exception(pht('You must %s first!', 'execute()'));
}
return $this->conpherenceData;
}
public function execute() {
$viewer = $this->getViewer();
$conpherence_app = 'PhabricatorConpherenceApplication';
$is_c_installed = PhabricatorApplication::isClassInstalledForViewer(
$conpherence_app,
$viewer);
if ($is_c_installed) {
$raw_message_count_number = $viewer->getUnreadMessageCount();
$message_count_number = $this->formatNumber($raw_message_count_number);
} else {
$raw_message_count_number = null;
$message_count_number = null;
}
$conpherence_data = array(
'isInstalled' => $is_c_installed,
'countType' => 'messages',
'count' => $message_count_number,
'rawCount' => $raw_message_count_number,
);
$this->setConpherenceData($conpherence_data);
$notification_app = 'PhabricatorNotificationsApplication';
$is_n_installed = PhabricatorApplication::isClassInstalledForViewer(
$notification_app,
$viewer);
if ($is_n_installed) {
$raw_notification_count_number = $viewer->getUnreadNotificationCount();
$notification_count_number = $this->formatNumber(
$raw_notification_count_number);
} else {
$notification_count_number = null;
$raw_notification_count_number = null;
}
$notification_data = array(
'isInstalled' => $is_n_installed,
'countType' => 'notifications',
'count' => $notification_count_number,
'rawCount' => $raw_notification_count_number,
);
$this->setNotificationData($notification_data);
return array(
$notification_app => $this->getNotificationData(),
$conpherence_app => $this->getConpherenceData(),
);
}
private function formatNumber($number) {
$formatted = $number;
if ($number > 999) {
$formatted = "\xE2\x88\x9E";
}
return $formatted;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/ConpherenceTransactionRenderer.php | src/applications/conpherence/ConpherenceTransactionRenderer.php | <?php
final class ConpherenceTransactionRenderer extends Phobject {
public static function renderTransactions(
PhabricatorUser $user,
ConpherenceThread $conpherence,
$marker_type = 'older') {
$transactions = $conpherence->getTransactions();
$oldest_transaction_id = 0;
$newest_transaction_id = 0;
$too_many = ConpherenceThreadQuery::TRANSACTION_LIMIT + 1;
if (count($transactions) == $too_many) {
if ($marker_type == 'olderandnewer') {
$last_transaction = end($transactions);
$first_transaction = reset($transactions);
unset($transactions[$last_transaction->getID()]);
unset($transactions[$first_transaction->getID()]);
$oldest_transaction_id = $last_transaction->getID();
$newest_transaction_id = $first_transaction->getID();
} else if ($marker_type == 'newer') {
$first_transaction = reset($transactions);
unset($transactions[$first_transaction->getID()]);
$newest_transaction_id = $first_transaction->getID();
} else if ($marker_type == 'older') {
$last_transaction = end($transactions);
unset($transactions[$last_transaction->getID()]);
$oldest_transaction = end($transactions);
$oldest_transaction_id = $oldest_transaction->getID();
}
// we need **at least** the newer marker in this mode even if
// we didn't get a full set of transactions
} else if ($marker_type == 'olderandnewer') {
$first_transaction = reset($transactions);
unset($transactions[$first_transaction->getID()]);
$newest_transaction_id = $first_transaction->getID();
}
$transactions = array_reverse($transactions);
$handles = $conpherence->getHandles();
$rendered_transactions = array();
$engine = id(new PhabricatorMarkupEngine())
->setViewer($user)
->setContextObject($conpherence);
foreach ($transactions as $key => $transaction) {
if ($transaction->shouldHide()) {
unset($transactions[$key]);
continue;
}
if ($transaction->getComment()) {
$engine->addObject(
$transaction->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
}
$engine->process();
// we're going to insert a dummy date marker transaction for breaks
// between days. some setup required!
$previous_transaction = null;
$date_marker_transaction = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadDateMarkerTransaction::TRANSACTIONTYPE)
->makeEphemeral();
$date_marker_transaction_view = id(new ConpherenceTransactionView())
->setUser($user)
->setConpherenceTransaction($date_marker_transaction)
->setConpherenceThread($conpherence)
->setHandles($handles)
->setMarkupEngine($engine);
$transaction_view_template = id(new ConpherenceTransactionView())
->setUser($user)
->setConpherenceThread($conpherence)
->setHandles($handles)
->setMarkupEngine($engine);
foreach ($transactions as $transaction) {
$collapsed = false;
if ($previous_transaction) {
$previous_day = phabricator_format_local_time(
$previous_transaction->getDateCreated(),
$user,
'Ymd');
$current_day = phabricator_format_local_time(
$transaction->getDateCreated(),
$user,
'Ymd');
// See if same user / time
$previous_author = $previous_transaction->getAuthorPHID();
$current_author = $transaction->getAuthorPHID();
$previous_time = $previous_transaction->getDateCreated();
$current_time = $transaction->getDateCreated();
$previous_type = $previous_transaction->getTransactionType();
$current_type = $transaction->getTransactionType();
if (($previous_author == $current_author) &&
($previous_type == $current_type)) {
// Group messages within the last x seconds
if (($current_time - $previous_time) < 120) {
$collapsed = true;
}
}
// date marker transaction time!
if ($previous_day != $current_day) {
$date_marker_transaction->setDateCreated(
$transaction->getDateCreated());
$date_marker_transaction->setID($previous_transaction->getID());
$rendered_transactions[] = $date_marker_transaction_view->render();
}
}
$transaction_view = id(clone $transaction_view_template)
->setConpherenceTransaction($transaction);
if ($collapsed) {
$transaction_view->addClass('conpherence-transaction-collapsed');
}
$rendered_transactions[] = $transaction_view->render();
$previous_transaction = $transaction;
}
$latest_transaction_id = $transaction->getID();
return array(
'transactions' => $rendered_transactions,
'latest_transaction' => $transaction,
'latest_transaction_id' => $latest_transaction_id,
'oldest_transaction_id' => $oldest_transaction_id,
'newest_transaction_id' => $newest_transaction_id,
);
}
public static function renderMessagePaneContent(
array $transactions,
$oldest_transaction_id,
$newest_transaction_id) {
$oldscrollbutton = '';
if ($oldest_transaction_id) {
$oldscrollbutton = javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'show-older-messages',
'class' => 'conpherence-show-more-messages',
'meta' => array(
'oldest_transaction_id' => $oldest_transaction_id,
),
),
pht('Show Older Messages'));
$oldscrollbutton = javelin_tag(
'div',
array(
'sigil' => 'conpherence-transaction-view',
'meta' => array(
'id' => $oldest_transaction_id - 0.5,
),
),
$oldscrollbutton);
}
$newscrollbutton = '';
if ($newest_transaction_id) {
$newscrollbutton = javelin_tag(
'a',
array(
'href' => '#',
'mustcapture' => true,
'sigil' => 'show-newer-messages',
'class' => 'conpherence-show-more-messages',
'meta' => array(
'newest_transaction_id' => $newest_transaction_id,
),
),
pht('Show Newer Messages'));
$newscrollbutton = javelin_tag(
'div',
array(
'sigil' => 'conpherence-transaction-view',
'meta' => array(
'id' => $newest_transaction_id + 0.5,
),
),
$newscrollbutton);
}
return hsprintf(
'%s%s%s',
$oldscrollbutton,
$transactions,
$newscrollbutton);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceParticipantController.php | src/applications/conpherence/controller/ConpherenceParticipantController.php | <?php
final class ConpherenceParticipantController extends ConpherenceController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$conpherence_id = $request->getURIData('id');
if (!$conpherence_id) {
return new Aphront404Response();
}
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($conpherence_id))
->needParticipants(true)
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
$content = id(new ConpherenceParticipantView())
->setUser($this->getViewer())
->setConpherence($conpherence)
->setUpdateURI($uri);
$content = array('widgets' => $content);
return id(new AphrontAjaxResponse())->setContent($content);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceRoomEditController.php | src/applications/conpherence/controller/ConpherenceRoomEditController.php | <?php
final class ConpherenceRoomEditController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
return id(new ConpherenceEditEngine())
->setController($this)
->buildResponse();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceUpdateController.php | src/applications/conpherence/controller/ConpherenceUpdateController.php | <?php
final class ConpherenceUpdateController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$conpherence_id = $request->getURIData('id');
if (!$conpherence_id) {
return new Aphront404Response();
}
$need_participants = false;
$needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
$action = $request->getStr('action');
switch ($action) {
case ConpherenceUpdateActions::REMOVE_PERSON:
$person_phid = $request->getStr('remove_person');
if ($person_phid != $user->getPHID()) {
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
}
break;
case ConpherenceUpdateActions::ADD_PERSON:
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
break;
case ConpherenceUpdateActions::LOAD:
break;
}
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
->needParticipants($need_participants)
->requireCapabilities($needed_capabilities)
->executeOne();
$latest_transaction_id = null;
$response_mode = $request->isAjax() ? 'ajax' : 'redirect';
$error_view = null;
$e_file = array();
$errors = array();
$delete_draft = false;
$xactions = array();
if ($request->isFormPost() || ($action == ConpherenceUpdateActions::LOAD)) {
$editor = id(new ConpherenceEditor())
->setContinueOnNoEffect($request->isContinueRequest())
->setContentSourceFromRequest($request)
->setActor($user);
switch ($action) {
case ConpherenceUpdateActions::DRAFT:
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$draft->setDraft($request->getStr('text'));
$draft->replaceOrDelete();
return new AphrontAjaxResponse();
case ConpherenceUpdateActions::JOIN_ROOM:
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => array($user->getPHID())));
$delete_draft = true;
$message = $request->getStr('text');
if ($message) {
$message_xactions = $editor->generateTransactionsFromText(
$user,
$conpherence,
$message);
$xactions = array_merge($xactions, $message_xactions);
}
// for now, just redirect back to the conpherence so everything
// will work okay...!
$response_mode = 'redirect';
break;
case ConpherenceUpdateActions::MESSAGE:
$message = $request->getStr('text');
if (strlen($message)) {
$xactions = $editor->generateTransactionsFromText(
$user,
$conpherence,
$message);
$delete_draft = true;
} else {
$action = ConpherenceUpdateActions::LOAD;
$updated = false;
$response_mode = 'ajax';
}
break;
case ConpherenceUpdateActions::ADD_PERSON:
$person_phids = $request->getArr('add_person');
if (!empty($person_phids)) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => $person_phids));
}
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
if (!$request->isContinueRequest()) {
// do nothing; we'll display a confirmation dialog instead
break;
}
$person_phid = $request->getStr('remove_person');
if ($person_phid) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('-' => array($person_phid)));
$response_mode = 'go-home';
}
break;
case ConpherenceUpdateActions::LOAD:
$updated = false;
$response_mode = 'ajax';
break;
default:
throw new Exception(pht('Unknown action: %s', $action));
break;
}
if ($xactions) {
try {
$xactions = $editor->applyTransactions($conpherence, $xactions);
if ($delete_draft) {
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$draft->delete();
}
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())
->setCancelURI($this->getApplicationURI($conpherence_id.'/'))
->setException($ex);
}
// xactions had no effect...!
if (empty($xactions)) {
$errors[] = pht(
'That was a non-update. Try cancel.');
}
}
if ($xactions || ($action == ConpherenceUpdateActions::LOAD)) {
switch ($response_mode) {
case 'ajax':
$latest_transaction_id = $request->getInt('latest_transaction_id');
$content = $this->loadAndRenderUpdates(
$action,
$conpherence_id,
$latest_transaction_id);
return id(new AphrontAjaxResponse())
->setContent($content);
break;
case 'go-home':
$content = array(
'href' => $this->getApplicationURI(),
);
return id(new AphrontAjaxResponse())
->setContent($content);
break;
case 'redirect':
default:
return id(new AphrontRedirectResponse())
->setURI('/'.$conpherence->getMonogram());
break;
}
}
}
if ($errors) {
$error_view = id(new PHUIInfoView())
->setErrors($errors);
}
switch ($action) {
case ConpherenceUpdateActions::ADD_PERSON:
$dialog = $this->renderAddPersonDialog($conpherence);
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
$dialog = $this->renderRemovePersonDialog($conpherence);
break;
}
return
$dialog
->setUser($user)
->setWidth(AphrontDialogView::WIDTH_FORM)
->setSubmitURI($this->getApplicationURI('update/'.$conpherence_id.'/'))
->addSubmitButton()
->addCancelButton($this->getApplicationURI($conpherence->getID().'/'));
}
private function renderAddPersonDialog(
ConpherenceThread $conpherence) {
$request = $this->getRequest();
$user = $request->getUser();
$add_person = $request->getStr('add_person');
$form = id(new AphrontFormView())
->setUser($user)
->setFullWidth(true)
->appendControl(
id(new AphrontFormTokenizerControl())
->setName('add_person')
->setUser($user)
->setDatasource(new PhabricatorPeopleDatasource()));
$view = id(new AphrontDialogView())
->setTitle(pht('Add Participants'))
->addHiddenInput('action', 'add_person')
->addHiddenInput(
'latest_transaction_id',
$request->getInt('latest_transaction_id'))
->appendForm($form);
return $view;
}
private function renderRemovePersonDialog(
ConpherenceThread $conpherence) {
$request = $this->getRequest();
$viewer = $request->getUser();
$remove_person = $request->getStr('remove_person');
$participants = $conpherence->getParticipants();
$removed_user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withPHIDs(array($remove_person))
->executeOne();
if (!$removed_user) {
return new Aphront404Response();
}
$is_self = ($viewer->getPHID() == $removed_user->getPHID());
$is_last = (count($participants) == 1);
$test_conpherence = clone $conpherence;
$test_conpherence->attachParticipants(array());
$still_visible = PhabricatorPolicyFilter::hasCapability(
$removed_user,
$test_conpherence,
PhabricatorPolicyCapability::CAN_VIEW);
$body = array();
if ($is_self) {
$title = pht('Leave Room');
$body[] = pht(
'Are you sure you want to leave this room?');
} else {
$title = pht('Remove Participant');
$body[] = pht(
'Remove %s from this room?',
phutil_tag('strong', array(), $removed_user->getUsername()));
}
if ($still_visible) {
if ($is_self) {
$body[] = pht(
'You will be able to rejoin the room later.');
} else {
$body[] = pht(
'They will be able to rejoin the room later.');
}
} else {
if ($is_self) {
if ($is_last) {
$body[] = pht(
'You are the last member, so you will never be able to rejoin '.
'the room.');
} else {
$body[] = pht(
'You will not be able to rejoin the room on your own, but '.
'someone else can invite you later.');
}
} else {
$body[] = pht(
'They will not be able to rejoin the room unless invited '.
'again.');
}
}
$dialog = id(new AphrontDialogView())
->setTitle($title)
->addHiddenInput('action', 'remove_person')
->addHiddenInput('remove_person', $remove_person)
->addHiddenInput(
'latest_transaction_id',
$request->getInt('latest_transaction_id'))
->addHiddenInput('__continue__', true);
foreach ($body as $paragraph) {
$dialog->appendParagraph($paragraph);
}
return $dialog;
}
private function loadAndRenderUpdates(
$action,
$conpherence_id,
$latest_transaction_id) {
$need_transactions = false;
switch ($action) {
case ConpherenceUpdateActions::LOAD:
$need_transactions = true;
break;
case ConpherenceUpdateActions::MESSAGE:
case ConpherenceUpdateActions::ADD_PERSON:
$need_transactions = true;
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
default:
break;
}
$user = $this->getRequest()->getUser();
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->setAfterTransactionID($latest_transaction_id)
->needProfileImage(true)
->needParticipants(true)
->needTransactions($need_transactions)
->withIDs(array($conpherence_id))
->executeOne();
$non_update = false;
$participant = $conpherence->getParticipant($user->getPHID());
if ($need_transactions && $conpherence->getTransactions()) {
$data = ConpherenceTransactionRenderer::renderTransactions(
$user,
$conpherence);
$key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY;
$minimized = $user->getUserSetting($key);
if (!$minimized) {
$participant->markUpToDate($conpherence);
}
} else if ($need_transactions) {
$non_update = true;
$data = array();
} else {
$data = array();
}
$rendered_transactions = idx($data, 'transactions');
$new_latest_transaction_id = idx($data, 'latest_transaction_id');
$update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
$nav_item = null;
$header = null;
$people_widget = null;
switch ($action) {
case ConpherenceUpdateActions::ADD_PERSON:
$people_widget = id(new ConpherenceParticipantView())
->setUser($user)
->setConpherence($conpherence)
->setUpdateURI($update_uri);
$people_widget = hsprintf('%s', $people_widget->render());
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
default:
break;
}
$data = $conpherence->getDisplayData($user);
$dropdown_query = id(new AphlictDropdownDataQuery())
->setViewer($user);
$dropdown_query->execute();
$map = ConpherenceRoomSettings::getSoundMap();
$default_receive = ConpherenceRoomSettings::DEFAULT_RECEIVE_SOUND;
$receive_sound = $map[$default_receive]['rsrc'];
$mention_sound = null;
// Get the user's defaults if logged in
if ($participant) {
$sounds = $this->getSoundForParticipant($user, $participant);
$receive_sound = $sounds[ConpherenceRoomSettings::SOUND_RECEIVE];
$mention_sound = $sounds[ConpherenceRoomSettings::SOUND_MENTION];
}
$content = array(
'non_update' => $non_update,
'transactions' => hsprintf('%s', $rendered_transactions),
'conpherence_title' => (string)$data['title'],
'latest_transaction_id' => $new_latest_transaction_id,
'nav_item' => $nav_item,
'conpherence_phid' => $conpherence->getPHID(),
'header' => $header,
'people_widget' => $people_widget,
'aphlictDropdownData' => array(
$dropdown_query->getNotificationData(),
$dropdown_query->getConpherenceData(),
),
'sound' => array(
'receive' => $receive_sound,
'mention' => $mention_sound,
),
);
return $content;
}
protected function getSoundForParticipant(
PhabricatorUser $user,
ConpherenceParticipant $participant) {
$sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY;
$sound_default = $user->getUserSetting($sound_key);
$settings = $participant->getSettings();
$sounds = idx($settings, 'sounds', array());
$map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default);
$receive = idx($sounds,
ConpherenceRoomSettings::SOUND_RECEIVE,
$map[ConpherenceRoomSettings::SOUND_RECEIVE]);
$mention = idx($sounds,
ConpherenceRoomSettings::SOUND_MENTION,
$map[ConpherenceRoomSettings::SOUND_MENTION]);
$sound_map = ConpherenceRoomSettings::getSoundMap();
return array(
ConpherenceRoomSettings::SOUND_RECEIVE => $sound_map[$receive]['rsrc'],
ConpherenceRoomSettings::SOUND_MENTION => $sound_map[$mention]['rsrc'],
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceRoomPictureController.php | src/applications/conpherence/controller/ConpherenceRoomPictureController.php | <?php
final class ConpherenceRoomPictureController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($id))
->needProfileImage(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$monogram = $conpherence->getMonogram();
$supported_formats = PhabricatorFile::getTransformableImageFormats();
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new room picture.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
$errors[] = pht(
'This server only supports these image formats: %s.',
implode(', ', $supported_formats));
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$xformed->attachToObject($conpherence->getPHID());
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadPictureTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new ConpherenceEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($conpherence, $xactions);
return id(new AphrontRedirectResponse())->setURI('/'.$monogram);
}
}
$title = pht('Edit Room Picture');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
$images = array();
$current = $conpherence->getProfileImagePHID();
$has_current = false;
if ($current) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->executeOne();
if ($file) {
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture'))
->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
->setCaption(
pht('Supported formats: %s', implode(', ', $supported_formats))))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/'.$monogram)
->setValue(pht('Upload Picture')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Picture'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($conpherence->getTitle(), '/'.$monogram);
$crumbs->addTextCrumb(pht('Room Picture'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Room Picture'))
->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$form_box,
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceRoomListController.php | src/applications/conpherence/controller/ConpherenceRoomListController.php | <?php
final class ConpherenceRoomListController extends ConpherenceController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine(
new ConpherenceThreadSearchEngine())
->setNavigation($this->buildRoomsSideNavView());
return $this->delegateToController($controller);
}
public function buildApplicationMenu() {
return $this->buildRoomsSideNavView(true)->getMenu();
}
private function buildRoomsSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('new/', pht('Create Room'));
}
id(new ConpherenceThreadSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceListController.php | src/applications/conpherence/controller/ConpherenceListController.php | <?php
final class ConpherenceListController extends ConpherenceController {
const SELECTED_MODE = 'selected';
const UNSELECTED_MODE = 'unselected';
/**
* Two main modes of operation...
*
* 1 - /conpherence/ - UNSELECTED_MODE
* 2 - /conpherence/<id>/ - SELECTED_MODE
*
* UNSELECTED_MODE is not an Ajax request while the other two are Ajax
* requests.
*/
private function determineMode() {
$request = $this->getRequest();
$mode = self::UNSELECTED_MODE;
if ($request->isAjax()) {
$mode = self::SELECTED_MODE;
}
return $mode;
}
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$title = pht('Conpherence');
$conpherence = null;
$limit = ConpherenceThreadListView::SEE_ALL_LIMIT + 1;
$all_participation = array();
$mode = $this->determineMode();
switch ($mode) {
case self::SELECTED_MODE:
$conpherence_id = $request->getURIData('id');
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
if ($conpherence->getTitle()) {
$title = $conpherence->getTitle();
}
$cursor = $conpherence->getParticipantIfExists($user->getPHID());
$data = $this->loadDefaultParticipation($limit);
$all_participation = $data['all_participation'];
if (!$cursor) {
$menu_participation = id(new ConpherenceParticipant())
->makeEphemeral()
->setConpherencePHID($conpherence->getPHID())
->setParticipantPHID($user->getPHID());
} else {
$menu_participation = $cursor;
}
// check to see if the loaded conpherence is going to show up
// within the SEE_ALL_LIMIT amount of conpherences.
// If its not there, then we just pre-pend it as the "first"
// conpherence so folks have a navigation item in the menu.
$count = 0;
$found = false;
foreach ($all_participation as $phid => $curr_participation) {
if ($conpherence->getPHID() == $phid) {
$found = true;
break;
}
$count++;
if ($count > ConpherenceThreadListView::SEE_ALL_LIMIT) {
break;
}
}
if (!$found) {
$all_participation =
array($conpherence->getPHID() => $menu_participation) +
$all_participation;
}
break;
case self::UNSELECTED_MODE:
default:
$data = $this->loadDefaultParticipation($limit);
$all_participation = $data['all_participation'];
if ($all_participation) {
$conpherence_id = head($all_participation)->getConpherencePHID();
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array($conpherence_id))
->needProfileImage(true)
->executeOne();
}
// If $conpherence is null, NUX state will render
break;
}
$threads = $this->loadConpherenceThreadData($all_participation);
$thread_view = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->setThreads($threads);
switch ($mode) {
case self::SELECTED_MODE:
$response = id(new AphrontAjaxResponse())->setContent($thread_view);
break;
case self::UNSELECTED_MODE:
default:
$layout = id(new ConpherenceLayoutView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->setThreadView($thread_view)
->setRole('list');
if ($conpherence) {
$layout->setThread($conpherence);
} else {
// make a dummy conpherence so we can render something
$conpherence = ConpherenceThread::initializeNewRoom($user);
$conpherence->attachHandles(array());
$conpherence->attachTransactions(array());
$conpherence->makeEphemeral();
}
$policy_objects = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$layout->setHeader($this->buildHeaderPaneContent(
$conpherence,
$policy_objects));
$response = $this->newPage()
->setTitle($title)
->appendChild($layout);
break;
}
return $response;
}
private function loadDefaultParticipation($limit) {
$viewer = $this->getRequest()->getUser();
$all_participation = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($viewer->getPHID()))
->setLimit($limit)
->execute();
$all_participation = mpull($all_participation, null, 'getConpherencePHID');
return array(
'all_participation' => $all_participation,
);
}
private function loadConpherenceThreadData($participation) {
$user = $this->getRequest()->getUser();
$conpherence_phids = array_keys($participation);
$conpherences = array();
if ($conpherence_phids) {
$conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs($conpherence_phids)
->needProfileImage(true)
->execute();
// this will re-sort by participation data
$conpherences = array_select_keys($conpherences, $conpherence_phids);
}
return $conpherences;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceViewController.php | src/applications/conpherence/controller/ConpherenceViewController.php | <?php
final class ConpherenceViewController extends
ConpherenceController {
const OLDER_FETCH_LIMIT = 5;
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$conpherence_id = $request->getURIData('id');
if (!$conpherence_id) {
return new Aphront404Response();
}
$query = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit($this->getMainQueryLimit());
$before_transaction_id = $request->getInt('oldest_transaction_id');
$after_transaction_id = $request->getInt('newest_transaction_id');
$old_message_id = $request->getURIData('messageID');
if ($before_transaction_id && ($old_message_id || $after_transaction_id)) {
throw new Aphront400Response();
}
if ($old_message_id && $after_transaction_id) {
throw new Aphront400Response();
}
$marker_type = 'older';
if ($before_transaction_id) {
$query
->setBeforeTransactionID($before_transaction_id);
}
if ($old_message_id) {
$marker_type = 'olderandnewer';
$query
->setAfterTransactionID($old_message_id - 1);
}
if ($after_transaction_id) {
$marker_type = 'newer';
$query
->setAfterTransactionID($after_transaction_id);
}
$conpherence = $query->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$this->setConpherence($conpherence);
$participant = $conpherence->getParticipantIfExists($user->getPHID());
$theme = ConpherenceRoomSettings::COLOR_LIGHT;
if ($participant) {
$settings = $participant->getSettings();
$theme = idx($settings, 'theme', ConpherenceRoomSettings::COLOR_LIGHT);
if (!$participant->isUpToDate($conpherence)) {
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$participant->markUpToDate($conpherence);
$user->clearCacheData(PhabricatorUserMessageCountCacheType::KEY_COUNT);
unset($write_guard);
}
}
$data = ConpherenceTransactionRenderer::renderTransactions(
$user,
$conpherence,
$marker_type);
$messages = ConpherenceTransactionRenderer::renderMessagePaneContent(
$data['transactions'],
$data['oldest_transaction_id'],
$data['newest_transaction_id']);
if ($before_transaction_id || $after_transaction_id) {
$header = null;
$form = null;
$content = array('transactions' => $messages);
} else {
$header = $this->buildHeaderPaneContent($conpherence);
$search = $this->buildSearchForm();
$form = $this->renderFormContent();
$content = array(
'header' => $header,
'search' => $search,
'transactions' => $messages,
'form' => $form,
);
}
$d_data = $conpherence->getDisplayData($user);
$content['title'] = $title = $d_data['title'];
if ($request->isAjax()) {
$dropdown_query = id(new AphlictDropdownDataQuery())
->setViewer($user);
$dropdown_query->execute();
$content['threadID'] = $conpherence->getID();
$content['threadPHID'] = $conpherence->getPHID();
$content['latestTransactionID'] = $data['latest_transaction_id'];
$content['canEdit'] = PhabricatorPolicyFilter::hasCapability(
$user,
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
$content['aphlictDropdownData'] = array(
$dropdown_query->getNotificationData(),
$dropdown_query->getConpherenceData(),
);
return id(new AphrontAjaxResponse())->setContent($content);
}
$layout = id(new ConpherenceLayoutView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->setThread($conpherence)
->setHeader($header)
->setSearch($search)
->setMessages($messages)
->setReplyForm($form)
->setTheme($theme)
->setLatestTransactionID($data['latest_transaction_id'])
->setRole('thread');
$participating = $conpherence->getParticipantIfExists($user->getPHID());
if (!$user->isLoggedIn()) {
$layout->addClass('conpherence-no-pontificate');
}
return $this->newPage()
->setTitle($title)
->setPageObjectPHIDs(array($conpherence->getPHID()))
->appendChild($layout);
}
private function renderFormContent() {
$conpherence = $this->getConpherence();
$user = $this->getRequest()->getUser();
$participating = $conpherence->getParticipantIfExists($user->getPHID());
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
if ($user->isLoggedIn()) {
$this->initBehavior('conpherence-pontificate');
if ($participating) {
$action = ConpherenceUpdateActions::MESSAGE;
$status = new PhabricatorNotificationStatusView();
} else {
$action = ConpherenceUpdateActions::JOIN_ROOM;
$status = pht('Sending a message will also join the room.');
}
$form = id(new AphrontFormView())
->setUser($user)
->setAction($update_uri)
->addSigil('conpherence-pontificate')
->setWorkflow(true)
->addHiddenInput('action', $action)
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('text')
->setSendOnEnter(true)
->setValue($draft->getDraft()));
$status_view = phutil_tag(
'div',
array(
'class' => 'conpherence-room-status',
'id' => 'conpherence-room-status',
),
$status);
$view = phutil_tag_div(
'pontificate-container', array($form, $status_view));
return $view;
} else {
// user not logged in so give them a login button.
$login_href = id(new PhutilURI('/auth/start/'))
->replaceQueryParam('next', '/'.$conpherence->getMonogram());
return id(new PHUIFormLayoutView())
->addClass('login-to-participate')
->appendInstructions(pht('Log in to join this room and participate.'))
->appendChild(
id(new PHUIButtonView())
->setTag('a')
->setText(pht('Log In to Participate'))
->setHref((string)$login_href));
}
}
private function getMainQueryLimit() {
$request = $this->getRequest();
$base_limit = ConpherenceThreadQuery::TRANSACTION_LIMIT;
if ($request->getURIData('messageID')) {
$base_limit = $base_limit - self::OLDER_FETCH_LIMIT;
}
return $base_limit;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceRoomPreferencesController.php | src/applications/conpherence/controller/ConpherenceRoomPreferencesController.php | <?php
final class ConpherenceRoomPreferencesController
extends ConpherenceController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$conpherence_id = $request->getURIData('id');
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($conpherence_id))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$view_uri = $conpherence->getURI();
$participant = $conpherence->getParticipantIfExists($viewer->getPHID());
if (!$participant) {
if ($viewer->isLoggedIn()) {
$text = pht(
'Notification settings are available after joining the room.');
} else {
$text = pht(
'Notification settings are available after logging in and joining '.
'the room.');
}
return $this->newDialog()
->setTitle(pht('Room Preferences'))
->addCancelButton($view_uri)
->appendParagraph($text);
}
// Save the data and redirect
if ($request->isFormPost()) {
$notifications = $request->getStr('notifications');
$sounds = $request->getArr('sounds');
$theme = $request->getStr('theme');
$participant->setSettings(array(
'notifications' => $notifications,
'sounds' => $sounds,
'theme' => $theme,
));
$participant->save();
return id(new AphrontRedirectResponse())
->setURI($view_uri);
}
$notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY;
$notification_default = $viewer->getUserSetting($notification_key);
$sound_key = PhabricatorConpherenceSoundSetting::SETTINGKEY;
$sound_default = $viewer->getUserSetting($sound_key);
$settings = $participant->getSettings();
$notifications = idx($settings, 'notifications', $notification_default);
$theme = idx($settings, 'theme', ConpherenceRoomSettings::COLOR_LIGHT);
$sounds = idx($settings, 'sounds', array());
$map = PhabricatorConpherenceSoundSetting::getDefaultSound($sound_default);
$receive = idx($sounds,
ConpherenceRoomSettings::SOUND_RECEIVE,
$map[ConpherenceRoomSettings::SOUND_RECEIVE]);
$mention = idx($sounds,
ConpherenceRoomSettings::SOUND_MENTION,
$map[ConpherenceRoomSettings::SOUND_MENTION]);
$form = id(new AphrontFormView())
->setUser($viewer)
->appendControl(
id(new AphrontFormRadioButtonControl())
->setLabel(pht('Notify'))
->addButton(
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL,
PhabricatorConpherenceNotificationsSetting::getSettingLabel(
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL),
'')
->addButton(
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY,
PhabricatorConpherenceNotificationsSetting::getSettingLabel(
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY),
'')
->setName('notifications')
->setValue($notifications))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('New Message'))
->setName('sounds['.ConpherenceRoomSettings::SOUND_RECEIVE.']')
->setOptions(ConpherenceRoomSettings::getDropdownSoundMap())
->setValue($receive))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Theme'))
->setName('theme')
->setOptions(ConpherenceRoomSettings::getThemeMap())
->setValue($theme));
return $this->newDialog()
->setTitle(pht('Room Preferences'))
->appendForm($form)
->addCancelButton($view_uri)
->addSubmitButton(pht('Save'));
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceColumnViewController.php | src/applications/conpherence/controller/ConpherenceColumnViewController.php | <?php
final class ConpherenceColumnViewController extends
ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$latest_conpherences = array();
$latest_participant = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($user->getPHID()))
->setLimit(8)
->execute();
if ($latest_participant) {
$conpherence_phids = mpull($latest_participant, 'getConpherencePHID');
$latest_conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs($conpherence_phids)
->needProfileImage(true)
->execute();
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
$latest_conpherences = array_select_keys(
$latest_conpherences,
$conpherence_phids);
}
$conpherence = null;
$should_404 = false;
if ($request->getInt('id')) {
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($request->getInt('id')))
->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
->executeOne();
$should_404 = true;
} else if ($latest_participant) {
$participant = head($latest_participant);
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array($participant->getConpherencePHID()))
->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
->executeOne();
$should_404 = true;
}
$durable_column = id(new ConpherenceDurableColumnView())
->setUser($user)
->setVisible(true);
if (!$conpherence) {
if ($should_404) {
return new Aphront404Response();
}
$conpherence_id = null;
$conpherence_phid = null;
$latest_transaction_id = null;
$can_edit = false;
} else {
$this->setConpherence($conpherence);
$participant = $conpherence->getParticipant($user->getPHID());
$transactions = $conpherence->getTransactions();
$latest_transaction = head($transactions);
$write_guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$participant->markUpToDate($conpherence);
unset($write_guard);
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$durable_column
->setDraft($draft)
->setSelectedConpherence($conpherence)
->setConpherences($latest_conpherences);
$conpherence_id = $conpherence->getID();
$conpherence_phid = $conpherence->getPHID();
$latest_transaction_id = $latest_transaction->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
}
$dropdown_query = id(new AphlictDropdownDataQuery())
->setViewer($user);
$dropdown_query->execute();
$response = array(
'content' => hsprintf('%s', $durable_column),
'threadID' => $conpherence_id,
'threadPHID' => $conpherence_phid,
'latestTransactionID' => $latest_transaction_id,
'canEdit' => $can_edit,
'aphlictDropdownData' => array(
$dropdown_query->getNotificationData(),
$dropdown_query->getConpherenceData(),
),
);
return id(new AphrontAjaxResponse())->setContent($response);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php | src/applications/conpherence/controller/ConpherenceNotificationPanelController.php | <?php
final class ConpherenceNotificationPanelController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$conpherences = array();
require_celerity_resource('conpherence-notification-css');
$participant_data = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($user->getPHID()))
->setLimit(5)
->execute();
$participant_data = mpull($participant_data, null, 'getConpherencePHID');
if ($participant_data) {
$conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array_keys($participant_data))
->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit(100)
->execute();
}
if ($conpherences) {
// re-order the conpherences based on participation data
$conpherences = array_select_keys(
$conpherences, array_keys($participant_data));
$view = new AphrontNullView();
foreach ($conpherences as $conpherence) {
$p_data = $participant_data[$conpherence->getPHID()];
$d_data = $conpherence->getDisplayData($user);
$classes = array(
'phabricator-notification',
'conpherence-notification',
);
if (!$p_data->isUpToDate($conpherence)) {
$classes[] = 'phabricator-notification-unread';
}
$uri = $this->getApplicationURI($conpherence->getID().'/');
$title = $d_data['title'];
$subtitle = $d_data['subtitle'];
$unread_count = $d_data['unread_count'];
$epoch = $d_data['epoch'];
$image = $d_data['image'];
$msg_view = id(new ConpherenceMenuItemView())
->setUser($user)
->setTitle($title)
->setSubtitle($subtitle)
->setHref($uri)
->setEpoch($epoch)
->setImageURI($image)
->setUnreadCount($unread_count);
$view->appendChild(javelin_tag(
'div',
array(
'class' => implode(' ', $classes),
'sigil' => 'notification',
'meta' => array(
'href' => $uri,
),
),
$msg_view));
}
$content = $view->render();
} else {
$rooms_uri = phutil_tag(
'a',
array(
'href' => '/conpherence/',
'class' => 'no-room-notification',
),
pht('You have joined no rooms.'));
$content = phutil_tag_div(
'phabricator-notification no-notifications', $rooms_uri);
}
$content = hsprintf(
'<div class="phabricator-notification-header grouped">%s%s</div>'.
'%s',
phutil_tag(
'a',
array(
'href' => '/conpherence/',
),
pht('Rooms')),
$this->renderPersistentOption(),
$content);
$unread = id(new ConpherenceParticipantCountQuery())
->withParticipantPHIDs(array($user->getPHID()))
->withUnread(true)
->execute();
$unread_count = idx($unread, $user->getPHID(), 0);
$json = array(
'content' => $content,
'number' => (int)$unread_count,
);
return id(new AphrontAjaxResponse())->setContent($json);
}
private function renderPersistentOption() {
$viewer = $this->getViewer();
$column_key = PhabricatorConpherenceColumnVisibleSetting::SETTINGKEY;
$show = (bool)$viewer->getUserSetting($column_key, false);
$view = phutil_tag(
'div',
array(
'class' => 'persistent-option',
),
array(
javelin_tag(
'input',
array(
'type' => 'checkbox',
'checked' => ($show) ? 'checked' : null,
'value' => !$show,
'sigil' => 'conpherence-persist-column',
)),
phutil_tag(
'span',
array(),
pht('Persistent Chat')),
));
return $view;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceThreadSearchController.php | src/applications/conpherence/controller/ConpherenceThreadSearchController.php | <?php
final class ConpherenceThreadSearchController
extends ConpherenceController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$conpherence_id = $request->getURIData('id');
$fulltext = $request->getStr('fulltext');
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($conpherence_id))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$engine = new ConpherenceThreadSearchEngine();
$engine->setViewer($viewer);
$saved = $engine->buildSavedQueryFromBuiltin('all')
->setParameter('phids', array($conpherence->getPHID()))
->setParameter('fulltext', $fulltext);
$pager = $engine->newPagerForSavedQuery($saved);
$pager->setPageSize(15);
$query = $engine->buildQueryFromSavedQuery($saved);
$results = $engine->executeQuery($query, $pager);
$view = $engine->renderResults($results, $saved);
return id(new AphrontAjaxResponse())
->setContent($view->getContent());
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/controller/ConpherenceController.php | src/applications/conpherence/controller/ConpherenceController.php | <?php
abstract class ConpherenceController extends PhabricatorController {
private $conpherence;
public function setConpherence(ConpherenceThread $conpherence) {
$this->conpherence = $conpherence;
return $this;
}
public function getConpherence() {
return $this->conpherence;
}
public function buildApplicationMenu() {
$nav = new PHUIListView();
$conpherence = $this->conpherence;
// Local Links
if ($conpherence) {
$nav->addMenuItem(
id(new PHUIListItemView())
->setName(pht('Joined Rooms'))
->setType(PHUIListItemView::TYPE_LINK)
->setHref($this->getApplicationURI()));
$nav->addMenuItem(
id(new PHUIListItemView())
->setName(pht('Edit Room'))
->setType(PHUIListItemView::TYPE_LINK)
->setHref(
$this->getApplicationURI('update/'.$conpherence->getID()).'/')
->setWorkflow(true));
$nav->addMenuItem(
id(new PHUIListItemView())
->setName(pht('Add Participants'))
->setType(PHUIListItemView::TYPE_LINK)
->setHref('#')
->addSigil('conpherence-widget-adder')
->setMetadata(array('widget' => 'widgets-people')));
}
// Global Links
$nav->newLabel(pht('Conpherence'));
$nav->newLink(
pht('New Room'),
$this->getApplicationURI('new/'));
$nav->newLink(
pht('Search Rooms'),
$this->getApplicationURI('search/'));
return $nav;
}
protected function buildHeaderPaneContent(
ConpherenceThread $conpherence) {
$viewer = $this->getViewer();
$header = null;
$id = $conpherence->getID();
if ($id) {
$data = $conpherence->getDisplayData($this->getViewer());
$header = id(new PHUIHeaderView())
->setViewer($viewer)
->setHeader($data['title'])
->setPolicyObject($conpherence)
->setImage($data['image']);
if (strlen($data['topic'])) {
$topic = id(new PHUITagView())
->setName($data['topic'])
->setColor(PHUITagView::COLOR_VIOLET)
->setType(PHUITagView::TYPE_SHADE)
->addClass('conpherence-header-topic');
$header->addTag($topic);
}
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
if ($can_edit) {
$header->setImageURL(
$this->getApplicationURI("picture/{$id}/"));
}
$participating = $conpherence->getParticipantIfExists($viewer->getPHID());
$header->addActionItem(
id(new PHUIIconCircleView())
->setHref(
$this->getApplicationURI('edit/'.$conpherence->getID()).'/')
->setIcon('fa-pencil')
->addClass('hide-on-device')
->setColor('violet')
->setWorkflow(true));
$header->addActionItem(
id(new PHUIIconCircleView())
->setHref($this->getApplicationURI("preferences/{$id}/"))
->setIcon('fa-gear')
->addClass('hide-on-device')
->setColor('pink')
->setWorkflow(true));
$widget_key = PhabricatorConpherenceWidgetVisibleSetting::SETTINGKEY;
$widget_view = (bool)$viewer->getUserSetting($widget_key, false);
Javelin::initBehavior(
'toggle-widget',
array(
'show' => (int)$widget_view,
'settingsURI' => '/settings/adjust/?key='.$widget_key,
));
$header->addActionItem(
id(new PHUIIconCircleView())
->addSigil('conpherence-widget-toggle')
->setIcon('fa-group')
->setHref('#')
->addClass('conpherence-participant-toggle'));
Javelin::initBehavior('conpherence-search');
$header->addActionItem(
id(new PHUIIconCircleView())
->addSigil('conpherence-search-toggle')
->setIcon('fa-search')
->setHref('#')
->setColor('green')
->addClass('conpherence-search-toggle'));
if (!$participating) {
$action = ConpherenceUpdateActions::JOIN_ROOM;
$uri = $this->getApplicationURI("update/{$id}/");
$button = phutil_tag(
'button',
array(
'type' => 'SUBMIT',
'class' => 'button button-green mlr',
),
pht('Join Room'));
$hidden = phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'action',
'value' => ConpherenceUpdateActions::JOIN_ROOM,
));
$form = phabricator_form(
$viewer,
array(
'method' => 'POST',
'action' => (string)$uri,
),
array(
$hidden,
$button,
));
$header->addActionItem($form);
}
}
return $header;
}
public function buildSearchForm() {
$viewer = $this->getViewer();
$conpherence = $this->conpherence;
$name = $conpherence->getTitle();
$bar = javelin_tag(
'input',
array(
'type' => 'text',
'id' => 'conpherence-search-input',
'name' => 'fulltext',
'class' => 'conpherence-search-input',
'sigil' => 'conpherence-search-input',
'placeholder' => pht('Search %s...', $name),
));
$id = $conpherence->getID();
$form = phabricator_form(
$viewer,
array(
'method' => 'POST',
'action' => '/conpherence/threadsearch/'.$id.'/',
'sigil' => 'conpherence-search-form',
'class' => 'conpherence-search-form',
'id' => 'conpherence-search-form',
),
array(
$bar,
));
$form_view = phutil_tag(
'div',
array(
'class' => 'conpherence-search-form-view',
),
$form);
$results = phutil_tag(
'div',
array(
'id' => 'conpherence-search-results',
'class' => 'conpherence-search-results',
));
$view = phutil_tag(
'div',
array(
'class' => 'conpherence-search-window',
),
array(
$form_view,
$results,
));
return $view;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/engineextension/ConpherenceThreadIndexEngineExtension.php | src/applications/conpherence/engineextension/ConpherenceThreadIndexEngineExtension.php | <?php
final class ConpherenceThreadIndexEngineExtension
extends PhabricatorIndexEngineExtension {
const EXTENSIONKEY = 'conpherence.thread';
public function getExtensionName() {
return pht('Conpherence Threads');
}
public function shouldIndexObject($object) {
return ($object instanceof ConpherenceThread);
}
public function indexObject(
PhabricatorIndexEngine $engine,
$object) {
$force = $this->shouldForceFullReindex();
if (!$force) {
$xaction_phids = $this->getParameter('transactionPHIDs');
if (!$xaction_phids) {
return;
}
}
$query = id(new ConpherenceTransactionQuery())
->setViewer($this->getViewer())
->withObjectPHIDs(array($object->getPHID()))
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
->needComments(true);
if (!$force) {
$query->withPHIDs($xaction_phids);
}
$xactions = $query->execute();
if (!$xactions) {
return;
}
foreach ($xactions as $xaction) {
$this->indexComment($object, $xaction);
}
}
private function indexComment(
ConpherenceThread $thread,
ConpherenceTransaction $xaction) {
$pager = id(new AphrontCursorPagerView())
->setPageSize(1)
->setAfterID($xaction->getID());
$previous_xactions = id(new ConpherenceTransactionQuery())
->setViewer($this->getViewer())
->withObjectPHIDs(array($thread->getPHID()))
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
->executeWithCursorPager($pager);
$previous = head($previous_xactions);
$index = id(new ConpherenceIndex())
->setThreadPHID($thread->getPHID())
->setTransactionPHID($xaction->getPHID())
->setPreviousTransactionPHID($previous ? $previous->getPHID() : null)
->setCorpus($xaction->getComment()->getContent());
queryfx(
$index->establishConnection('w'),
'INSERT INTO %T
(threadPHID, transactionPHID, previousTransactionPHID, corpus)
VALUES (%s, %s, %ns, %s)
ON DUPLICATE KEY UPDATE corpus = VALUES(corpus)',
$index->getTableName(),
$index->getThreadPHID(),
$index->getTransactionPHID(),
$index->getPreviousTransactionPHID(),
$index->getCorpus());
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceDAO.php | src/applications/conpherence/storage/ConpherenceDAO.php | <?php
abstract class ConpherenceDAO extends PhabricatorLiskDAO {
public function getApplicationName() {
return 'conpherence';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceParticipant.php | src/applications/conpherence/storage/ConpherenceParticipant.php | <?php
final class ConpherenceParticipant extends ConpherenceDAO {
protected $participantPHID;
protected $conpherencePHID;
protected $seenMessageCount;
protected $settings = array();
protected function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(
'settings' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'seenMessageCount' => 'uint64',
),
self::CONFIG_KEY_SCHEMA => array(
'conpherencePHID' => array(
'columns' => array('conpherencePHID', 'participantPHID'),
'unique' => true,
),
'key_thread' => array(
'columns' => array('participantPHID', 'conpherencePHID'),
),
),
) + parent::getConfiguration();
}
public function getSettings() {
return nonempty($this->settings, array());
}
public function markUpToDate(ConpherenceThread $conpherence) {
if (!$this->isUpToDate($conpherence)) {
$this->setSeenMessageCount($conpherence->getMessageCount());
$this->save();
PhabricatorUserCache::clearCache(
PhabricatorUserMessageCountCacheType::KEY_COUNT,
$this->getParticipantPHID());
}
return $this;
}
public function isUpToDate(ConpherenceThread $conpherence) {
return ($this->getSeenMessageCount() == $conpherence->getMessageCount());
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceTransactionComment.php | src/applications/conpherence/storage/ConpherenceTransactionComment.php | <?php
final class ConpherenceTransactionComment
extends PhabricatorApplicationTransactionComment {
protected $conpherencePHID;
public function getApplicationTransactionObject() {
return new ConpherenceTransaction();
}
protected function getConfiguration() {
$config = parent::getConfiguration();
$config[self::CONFIG_COLUMN_SCHEMA] = array(
'conpherencePHID' => 'phid?',
) + $config[self::CONFIG_COLUMN_SCHEMA];
$config[self::CONFIG_KEY_SCHEMA] = array(
'key_draft' => array(
'columns' => array('authorPHID', 'conpherencePHID', 'transactionPHID'),
'unique' => true,
),
) + $config[self::CONFIG_KEY_SCHEMA];
return $config;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceIndex.php | src/applications/conpherence/storage/ConpherenceIndex.php | <?php
final class ConpherenceIndex
extends ConpherenceDAO {
protected $threadPHID;
protected $transactionPHID;
protected $previousTransactionPHID;
protected $corpus;
protected function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'previousTransactionPHID' => 'phid?',
'corpus' => 'fulltext',
),
self::CONFIG_KEY_SCHEMA => array(
'key_thread' => array(
'columns' => array('threadPHID'),
),
'key_transaction' => array(
'columns' => array('transactionPHID'),
'unique' => true,
),
'key_previous' => array(
'columns' => array('previousTransactionPHID'),
'unique' => true,
),
'key_corpus' => array(
'columns' => array('corpus'),
'type' => 'FULLTEXT',
),
),
) + parent::getConfiguration();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceThreadTitleNgrams.php | src/applications/conpherence/storage/ConpherenceThreadTitleNgrams.php | <?php
final class ConpherenceThreadTitleNgrams
extends PhabricatorSearchNgrams {
public function getNgramKey() {
return 'threadtitle';
}
public function getColumnName() {
return 'title';
}
public function getApplicationName() {
return 'conpherence';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceTransaction.php | src/applications/conpherence/storage/ConpherenceTransaction.php | <?php
final class ConpherenceTransaction
extends PhabricatorModularTransaction {
public function getApplicationName() {
return 'conpherence';
}
public function getApplicationTransactionType() {
return PhabricatorConpherenceThreadPHIDType::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return new ConpherenceTransactionComment();
}
public function getBaseTransactionClass() {
return 'ConpherenceThreadTransactionType';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceSchemaSpec.php | src/applications/conpherence/storage/ConpherenceSchemaSpec.php | <?php
final class ConpherenceSchemaSpec
extends PhabricatorConfigSchemaSpec {
public function buildSchemata() {
$this->buildEdgeSchemata(new ConpherenceThread());
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/storage/ConpherenceThread.php | src/applications/conpherence/storage/ConpherenceThread.php | <?php
final class ConpherenceThread extends ConpherenceDAO
implements
PhabricatorPolicyInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorMentionableInterface,
PhabricatorDestructibleInterface,
PhabricatorNgramsInterface {
protected $title;
protected $topic;
protected $profileImagePHID;
protected $messageCount;
protected $mailKey;
protected $viewPolicy;
protected $editPolicy;
protected $joinPolicy;
private $participants = self::ATTACHABLE;
private $transactions = self::ATTACHABLE;
private $profileImageFile = self::ATTACHABLE;
private $handles = self::ATTACHABLE;
public static function initializeNewRoom(PhabricatorUser $sender) {
$default_policy = id(new ConpherenceThreadMembersPolicyRule())
->getObjectPolicyFullKey();
return id(new ConpherenceThread())
->setMessageCount(0)
->setTitle('')
->setTopic('')
->attachParticipants(array())
->setViewPolicy($default_policy)
->setEditPolicy($default_policy)
->setJoinPolicy('');
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'title' => 'text255?',
'topic' => 'text255',
'messageCount' => 'uint64',
'mailKey' => 'text20',
'joinPolicy' => 'policy',
'profileImagePHID' => 'phid?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorConpherenceThreadPHIDType::TYPECONST);
}
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
}
return parent::save();
}
public function getMonogram() {
return 'Z'.$this->getID();
}
public function getURI() {
return '/'.$this->getMonogram();
}
public function attachParticipants(array $participants) {
assert_instances_of($participants, 'ConpherenceParticipant');
$this->participants = $participants;
return $this;
}
public function getParticipants() {
return $this->assertAttached($this->participants);
}
public function getParticipant($phid) {
$participants = $this->getParticipants();
return $participants[$phid];
}
public function getParticipantIfExists($phid, $default = null) {
$participants = $this->getParticipants();
return idx($participants, $phid, $default);
}
public function getParticipantPHIDs() {
$participants = $this->getParticipants();
return array_keys($participants);
}
public function attachHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function getHandles() {
return $this->assertAttached($this->handles);
}
public function attachTransactions(array $transactions) {
assert_instances_of($transactions, 'ConpherenceTransaction');
$this->transactions = $transactions;
return $this;
}
public function getTransactions($assert_attached = true) {
return $this->assertAttached($this->transactions);
}
public function hasAttachedTransactions() {
return $this->transactions !== self::ATTACHABLE;
}
public function getTransactionsFrom($begin = 0, $amount = null) {
$length = count($this->transactions);
return array_slice(
$this->getTransactions(),
$length - $begin - $amount,
$amount);
}
public function getProfileImageURI() {
return $this->getProfileImageFile()->getBestURI();
}
public function attachProfileImageFile(PhabricatorFile $file) {
$this->profileImageFile = $file;
return $this;
}
public function getProfileImageFile() {
return $this->assertAttached($this->profileImageFile);
}
/**
* Get a thread title which doesn't require handles to be attached.
*
* This is a less rich title than @{method:getDisplayTitle}, but does not
* require handles to be attached. We use it to build thread handles without
* risking cycles or recursion while querying.
*
* @return string Lower quality human-readable title.
*/
public function getStaticTitle() {
$title = $this->getTitle();
if (strlen($title)) {
return $title;
}
return pht('Private Room');
}
public function getDisplayData(PhabricatorUser $viewer) {
$handles = $this->getHandles();
if ($this->hasAttachedTransactions()) {
$transactions = $this->getTransactions();
} else {
$transactions = array();
}
$img_src = $this->getProfileImageURI();
$message_transaction = null;
foreach ($transactions as $transaction) {
if ($message_transaction) {
break;
}
switch ($transaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
$message_transaction = $transaction;
break;
default:
break;
}
}
if ($message_transaction) {
$message_handle = $handles[$message_transaction->getAuthorPHID()];
$subtitle = sprintf(
'%s: %s',
$message_handle->getName(),
id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(60)
->truncateString(
$message_transaction->getComment()->getContent()));
} else {
// Kinda lame, but maybe add last message to cache?
$subtitle = pht('No recent messages');
}
$user_participation = $this->getParticipantIfExists($viewer->getPHID());
$theme = ConpherenceRoomSettings::COLOR_LIGHT;
if ($user_participation) {
$user_seen_count = $user_participation->getSeenMessageCount();
$participant = $this->getParticipant($viewer->getPHID());
$settings = $participant->getSettings();
$theme = idx($settings, 'theme', $theme);
} else {
$user_seen_count = 0;
}
$unread_count = $this->getMessageCount() - $user_seen_count;
$theme_class = ConpherenceRoomSettings::getThemeClass($theme);
$title = $this->getTitle();
$topic = $this->getTopic();
return array(
'title' => $title,
'topic' => $topic,
'subtitle' => $subtitle,
'unread_count' => $unread_count,
'epoch' => $this->getDateModified(),
'image' => $img_src,
'theme' => $theme_class,
);
}
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy();
}
return PhabricatorPolicies::POLICY_NOONE;
}
public function hasAutomaticCapability($capability, PhabricatorUser $user) {
// this bad boy isn't even created yet so go nuts $user
if (!$this->getID()) {
return true;
}
switch ($capability) {
case PhabricatorPolicyCapability::CAN_EDIT:
return false;
}
$participants = $this->getParticipants();
return isset($participants[$user->getPHID()]);
}
public function describeAutomaticCapability($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
return pht('Participants in a room can always view it.');
break;
}
}
public static function loadViewPolicyObjects(
PhabricatorUser $viewer,
array $conpherences) {
assert_instances_of($conpherences, __CLASS__);
$policies = array();
foreach ($conpherences as $room) {
$policies[$room->getViewPolicy()] = 1;
}
$policy_objects = array();
if ($policies) {
$policy_objects = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
->withPHIDs(array_keys($policies))
->execute();
}
return $policy_objects;
}
public function getPolicyIconName(array $policy_objects) {
assert_instances_of($policy_objects, 'PhabricatorPolicy');
$icon = $policy_objects[$this->getViewPolicy()]->getIcon();
return $icon;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new ConpherenceEditor();
}
public function getApplicationTransactionTemplate() {
return new ConpherenceTransaction();
}
/* -( PhabricatorNgramInterface )------------------------------------------ */
public function newNgrams() {
return array(
id(new ConpherenceThreadTitleNgrams())
->setValue($this->getTitle()),
);
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$participants = id(new ConpherenceParticipant())
->loadAllWhere('conpherencePHID = %s', $this->getPHID());
foreach ($participants as $participant) {
$participant->delete();
}
$this->saveTransaction();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/query/ConpherenceTransactionQuery.php | src/applications/conpherence/query/ConpherenceTransactionQuery.php | <?php
final class ConpherenceTransactionQuery
extends PhabricatorApplicationTransactionQuery {
public function getTemplateApplicationTransaction() {
return new ConpherenceTransaction();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/query/ConpherenceThreadSearchEngine.php | src/applications/conpherence/query/ConpherenceThreadSearchEngine.php | <?php
final class ConpherenceThreadSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getResultTypeDescription() {
return pht('Conpherence Rooms');
}
public function getApplicationClassName() {
return 'PhabricatorConpherenceApplication';
}
public function newQuery() {
return id(new ConpherenceThreadQuery())
->needProfileImage(true);
}
protected function buildCustomSearchFields() {
return array(
id(new PhabricatorUsersSearchField())
->setLabel(pht('Participants'))
->setKey('participants')
->setAliases(array('participant')),
id(new PhabricatorSearchDatasourceField())
->setLabel(pht('Rooms'))
->setKey('phids')
->setDescription(pht('Search by room titles.'))
->setDatasource(id(new ConpherenceThreadDatasource())),
id(new PhabricatorSearchTextField())
->setLabel(pht('Room Contains Words'))
->setKey('fulltext'),
);
}
protected function getDefaultFieldOrder() {
return array(
'participants',
'...',
);
}
protected function shouldShowOrderField() {
return false;
}
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
if ($map['participants']) {
$query->withParticipantPHIDs($map['participants']);
}
if ($map['fulltext']) {
$query->withFulltext($map['fulltext']);
}
if ($map['phids']) {
$query->withPHIDs($map['phids']);
}
return $query;
}
protected function getURI($path) {
return '/conpherence/search/'.$path;
}
protected function getBuiltinQueryNames() {
$names = array();
$names['all'] = pht('All Rooms');
if ($this->requireViewer()->isLoggedIn()) {
$names['participant'] = pht('Joined Rooms');
}
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
case 'participant':
return $query->setParameter(
'participants',
array($this->requireViewer()->getPHID()));
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $conpherences,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($conpherences, 'ConpherenceThread');
$viewer = $this->requireViewer();
$policy_objects = ConpherenceThread::loadViewPolicyObjects(
$viewer,
$conpherences);
$engines = array();
$fulltext = $query->getParameter('fulltext');
if ($fulltext !== null && strlen($fulltext) && $conpherences) {
$context = $this->loadContextMessages($conpherences, $fulltext);
$author_phids = array();
foreach ($context as $phid => $messages) {
$conpherence = $conpherences[$phid];
$engine = id(new PhabricatorMarkupEngine())
->setViewer($viewer)
->setContextObject($conpherence);
foreach ($messages as $group) {
foreach ($group as $message) {
$xaction = $message['xaction'];
if ($xaction) {
$author_phids[] = $xaction->getAuthorPHID();
$engine->addObject(
$xaction->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
}
}
$engine->process();
$engines[$phid] = $engine;
}
$handles = $viewer->loadHandles($author_phids);
$handles = iterator_to_array($handles);
} else {
$context = array();
}
$content = array();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($conpherences as $conpherence_phid => $conpherence) {
$created = phabricator_date($conpherence->getDateCreated(), $viewer);
$title = $conpherence->getTitle();
$monogram = $conpherence->getMonogram();
$icon_name = $conpherence->getPolicyIconName($policy_objects);
$icon = id(new PHUIIconView())
->setIcon($icon_name);
if ($fulltext === null || !strlen($fulltext)) {
$item = id(new PHUIObjectItemView())
->setObjectName($conpherence->getMonogram())
->setHeader($title)
->setHref('/'.$conpherence->getMonogram())
->setObject($conpherence)
->setImageURI($conpherence->getProfileImageURI())
->addIcon('none', $created)
->addIcon(
'none',
pht('Messages: %d', $conpherence->getMessageCount()))
->addAttribute(
array(
$icon,
' ',
pht(
'Last updated %s',
phabricator_datetime($conpherence->getDateModified(), $viewer)),
));
$list->addItem($item);
} else {
$messages = idx($context, $conpherence_phid);
$box = array();
$list = null;
if ($messages) {
foreach ($messages as $group) {
$rows = array();
foreach ($group as $message) {
$xaction = $message['xaction'];
if (!$xaction) {
continue;
}
$view = id(new ConpherenceTransactionView())
->setUser($viewer)
->setHandles($handles)
->setMarkupEngine($engines[$conpherence_phid])
->setConpherenceThread($conpherence)
->setConpherenceTransaction($xaction)
->setSearchResult(true)
->addClass('conpherence-fulltext-result');
if ($message['match']) {
$view->addClass('conpherence-fulltext-match');
}
$rows[] = $view;
}
$box[] = id(new PHUIBoxView())
->appendChild($rows)
->addClass('conpherence-fulltext-results');
}
}
$header = id(new PHUIHeaderView())
->setHeader($title)
->setHeaderIcon($icon_name)
->setHref('/'.$monogram);
$content[] = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($box);
}
}
if ($list) {
$content = $list;
} else {
$content = id(new PHUIBoxView())
->addClass('conpherence-search-room-results')
->appendChild($content);
}
$result = new PhabricatorApplicationSearchResultView();
$result->setContent($content);
$result->setNoDataString(pht('No results found.'));
return $result;
}
private function loadContextMessages(array $threads, $fulltext) {
$phids = mpull($threads, 'getPHID');
// We want to load a few messages for each thread in the result list, to
// show some of the actual content hits to help the user find what they
// are looking for.
// This method is trying to batch this lookup in most cases, so we do
// between one and "a handful" of queries instead of one per thread in
// most cases. To do this:
//
// - Load a big block of results for all of the threads.
// - If we didn't get a full block back, we have everything that matches
// the query. Sort it out and exit.
// - Otherwise, some threads had a ton of hits, so we might not be
// getting everything we want (we could be getting back 1,000 hits for
// the first thread). Remove any threads which we have enough results
// for and try again.
// - Repeat until we have everything or every thread has enough results.
//
// In the worst case, we could end up degrading to one query per thread,
// but this is incredibly unlikely on real data.
// Size of the result blocks we're going to load.
$limit = 1000;
// Number of messages we want for each thread.
$want = 3;
$need = $phids;
$hits = array();
while ($need) {
$rows = id(new ConpherenceFulltextQuery())
->withThreadPHIDs($need)
->withFulltext($fulltext)
->setLimit($limit)
->execute();
foreach ($rows as $row) {
$hits[$row['threadPHID']][] = $row;
}
if (count($rows) < $limit) {
break;
}
foreach ($need as $key => $phid) {
if (count($hits[$phid]) >= $want) {
unset($need[$key]);
}
}
}
// Now that we have all the fulltext matches, throw away any extras that we
// aren't going to render so we don't need to do lookups on them.
foreach ($hits as $phid => $rows) {
if (count($rows) > $want) {
$hits[$phid] = array_slice($rows, 0, $want);
}
}
// For each fulltext match, we want to render a message before and after
// the match to give it some context. We already know the transactions
// before each match because the rows have a "previousTransactionPHID",
// but we need to do one more query to figure out the transactions after
// each match.
// Collect the transactions we want to find the next transactions for.
$after = array();
foreach ($hits as $phid => $rows) {
foreach ($rows as $row) {
$after[] = $row['transactionPHID'];
}
}
// Look up the next transactions.
if ($after) {
$after_rows = id(new ConpherenceFulltextQuery())
->withPreviousTransactionPHIDs($after)
->execute();
} else {
$after_rows = array();
}
// Build maps from PHIDs to the previous and next PHIDs.
$prev_map = array();
$next_map = array();
foreach ($after_rows as $row) {
$next_map[$row['previousTransactionPHID']] = $row['transactionPHID'];
}
foreach ($hits as $phid => $rows) {
foreach ($rows as $row) {
$prev = $row['previousTransactionPHID'];
if ($prev) {
$prev_map[$row['transactionPHID']] = $prev;
$next_map[$prev] = $row['transactionPHID'];
}
}
}
// Now we're going to collect the actual transaction PHIDs, in order, that
// we want to show for each thread.
$groups = array();
foreach ($hits as $thread_phid => $rows) {
$rows = ipull($rows, null, 'transactionPHID');
$done = array();
foreach ($rows as $phid => $row) {
if (isset($done[$phid])) {
continue;
}
$done[$phid] = true;
$group = array();
// Walk backward, finding all the previous results. We can just keep
// going until we run out of results because we've only loaded things
// that we want to show.
$prev = $phid;
while (true) {
if (!isset($prev_map[$prev])) {
// No previous transaction, so we're done.
break;
}
$prev = $prev_map[$prev];
if (isset($rows[$prev])) {
$match = true;
$done[$prev] = true;
} else {
$match = false;
}
$group[] = array(
'phid' => $prev,
'match' => $match,
);
}
if (count($group) > 1) {
$group = array_reverse($group);
}
$group[] = array(
'phid' => $phid,
'match' => true,
);
$next = $phid;
while (true) {
if (!isset($next_map[$next])) {
break;
}
$next = $next_map[$next];
if (isset($rows[$next])) {
$match = true;
$done[$next] = true;
} else {
$match = false;
}
$group[] = array(
'phid' => $next,
'match' => $match,
);
}
$groups[$thread_phid][] = $group;
}
}
// Load all the actual transactions we need.
$xaction_phids = array();
foreach ($groups as $thread_phid => $group) {
foreach ($group as $list) {
foreach ($list as $item) {
$xaction_phids[] = $item['phid'];
}
}
}
if ($xaction_phids) {
$xactions = id(new ConpherenceTransactionQuery())
->setViewer($this->requireViewer())
->withPHIDs($xaction_phids)
->needComments(true)
->execute();
$xactions = mpull($xactions, null, 'getPHID');
} else {
$xactions = array();
}
foreach ($groups as $thread_phid => $group) {
foreach ($group as $key => $list) {
foreach ($list as $lkey => $item) {
$xaction = idx($xactions, $item['phid']);
if ($xaction->shouldHide()) {
continue;
}
$groups[$thread_phid][$key][$lkey]['xaction'] = $xaction;
}
}
}
// TODO: Sort the groups chronologically?
return $groups;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/query/ConpherenceFulltextQuery.php | src/applications/conpherence/query/ConpherenceFulltextQuery.php | <?php
final class ConpherenceFulltextQuery
extends PhabricatorOffsetPagedQuery {
private $threadPHIDs;
private $previousTransactionPHIDs;
private $fulltext;
public function withThreadPHIDs(array $phids) {
$this->threadPHIDs = $phids;
return $this;
}
public function withPreviousTransactionPHIDs(array $phids) {
$this->previousTransactionPHIDs = $phids;
return $this;
}
public function withFulltext($fulltext) {
$this->fulltext = $fulltext;
return $this;
}
public function execute() {
$table = new ConpherenceIndex();
$conn_r = $table->establishConnection('r');
$rows = queryfx_all(
$conn_r,
'SELECT threadPHID, transactionPHID, previousTransactionPHID
FROM %T i %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderByClause($conn_r),
$this->buildLimitClause($conn_r));
return $rows;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->threadPHIDs !== null) {
$where[] = qsprintf(
$conn,
'i.threadPHID IN (%Ls)',
$this->threadPHIDs);
}
if ($this->previousTransactionPHIDs !== null) {
$where[] = qsprintf(
$conn,
'i.previousTransactionPHID IN (%Ls)',
$this->previousTransactionPHIDs);
}
if (strlen($this->fulltext)) {
$compiler = PhabricatorSearchDocument::newQueryCompiler();
$tokens = $compiler->newTokens($this->fulltext);
$compiled_query = $compiler->compileQuery($tokens);
$where[] = qsprintf(
$conn,
'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)',
$compiled_query);
}
return $this->formatWhereClause($conn, $where);
}
private function buildOrderByClause(AphrontDatabaseConnection $conn_r) {
if (strlen($this->fulltext)) {
return qsprintf(
$conn_r,
'ORDER BY MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE) DESC',
$this->fulltext);
} else {
return qsprintf(
$conn_r,
'ORDER BY id DESC');
}
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/query/ConpherenceParticipantQuery.php | src/applications/conpherence/query/ConpherenceParticipantQuery.php | <?php
final class ConpherenceParticipantQuery extends PhabricatorOffsetPagedQuery {
private $participantPHIDs;
public function withParticipantPHIDs(array $phids) {
$this->participantPHIDs = $phids;
return $this;
}
public function execute() {
$table = new ConpherenceParticipant();
$thread = new ConpherenceThread();
$conn = $table->establishConnection('r');
$data = queryfx_all(
$conn,
'SELECT * FROM %T participant JOIN %T thread
ON participant.conpherencePHID = thread.phid %Q %Q %Q',
$table->getTableName(),
$thread->getTableName(),
$this->buildWhereClause($conn),
$this->buildOrderClause($conn),
$this->buildLimitClause($conn));
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->participantPHIDs !== null) {
$where[] = qsprintf(
$conn,
'participantPHID IN (%Ls)',
$this->participantPHIDs);
}
return $this->formatWhereClause($conn, $where);
}
private function buildOrderClause(AphrontDatabaseConnection $conn) {
return qsprintf(
$conn,
'ORDER BY thread.dateModified DESC, thread.id DESC, participant.id DESC');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/query/ConpherenceParticipantCountQuery.php | src/applications/conpherence/query/ConpherenceParticipantCountQuery.php | <?php
final class ConpherenceParticipantCountQuery
extends PhabricatorOffsetPagedQuery {
private $participantPHIDs;
private $unread;
public function withParticipantPHIDs(array $phids) {
$this->participantPHIDs = $phids;
return $this;
}
public function withUnread($unread) {
$this->unread = $unread;
return $this;
}
public function execute() {
$thread = new ConpherenceThread();
$table = new ConpherenceParticipant();
$conn = $table->establishConnection('r');
$rows = queryfx_all(
$conn,
'SELECT COUNT(*) as count, participantPHID
FROM %T participant JOIN %T thread
ON participant.conpherencePHID = thread.phid %Q %Q %Q',
$table->getTableName(),
$thread->getTableName(),
$this->buildWhereClause($conn),
$this->buildGroupByClause($conn),
$this->buildLimitClause($conn));
return ipull($rows, 'count', 'participantPHID');
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->participantPHIDs !== null) {
$where[] = qsprintf(
$conn,
'participant.participantPHID IN (%Ls)',
$this->participantPHIDs);
}
if ($this->unread !== null) {
if ($this->unread) {
$where[] = qsprintf(
$conn,
'participant.seenMessageCount < thread.messageCount');
} else {
$where[] = qsprintf(
$conn,
'participant.seenMessageCount >= thread.messageCount');
}
}
return $this->formatWhereClause($conn, $where);
}
private function buildGroupByClause(AphrontDatabaseConnection $conn) {
return qsprintf(
$conn,
'GROUP BY participantPHID');
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/query/ConpherenceThreadQuery.php | src/applications/conpherence/query/ConpherenceThreadQuery.php | <?php
final class ConpherenceThreadQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
const TRANSACTION_LIMIT = 100;
private $phids;
private $ids;
private $participantPHIDs;
private $needParticipants;
private $needTransactions;
private $afterTransactionID;
private $beforeTransactionID;
private $transactionLimit;
private $fulltext;
private $needProfileImage;
public function needParticipants($need) {
$this->needParticipants = $need;
return $this;
}
public function needProfileImage($need) {
$this->needProfileImage = $need;
return $this;
}
public function needTransactions($need_transactions) {
$this->needTransactions = $need_transactions;
return $this;
}
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function withPHIDs(array $phids) {
$this->phids = $phids;
return $this;
}
public function withParticipantPHIDs(array $phids) {
$this->participantPHIDs = $phids;
return $this;
}
public function setAfterTransactionID($id) {
$this->afterTransactionID = $id;
return $this;
}
public function setBeforeTransactionID($id) {
$this->beforeTransactionID = $id;
return $this;
}
public function setTransactionLimit($transaction_limit) {
$this->transactionLimit = $transaction_limit;
return $this;
}
public function getTransactionLimit() {
return $this->transactionLimit;
}
public function withFulltext($query) {
$this->fulltext = $query;
return $this;
}
public function withTitleNgrams($ngrams) {
return $this->withNgramsConstraint(
id(new ConpherenceThreadTitleNgrams()),
$ngrams);
}
protected function loadPage() {
$table = new ConpherenceThread();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT thread.* FROM %T thread %Q %Q %Q %Q %Q',
$table->getTableName(),
$this->buildJoinClause($conn_r),
$this->buildWhereClause($conn_r),
$this->buildGroupClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
$conpherences = $table->loadAllFromArray($data);
if ($conpherences) {
$conpherences = mpull($conpherences, null, 'getPHID');
$this->loadParticipantsAndInitHandles($conpherences);
if ($this->needParticipants) {
$this->loadCoreHandles($conpherences, 'getParticipantPHIDs');
}
if ($this->needTransactions) {
$this->loadTransactionsAndHandles($conpherences);
}
if ($this->needProfileImage) {
$default = null;
$file_phids = mpull($conpherences, 'getProfileImagePHID');
$file_phids = array_filter($file_phids);
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
->setParentQuery($this)
->setViewer($this->getViewer())
->withPHIDs($file_phids)
->execute();
$files = mpull($files, null, 'getPHID');
} else {
$files = array();
}
foreach ($conpherences as $conpherence) {
$file = idx($files, $conpherence->getProfileImagePHID());
if (!$file) {
if (!$default) {
$default = PhabricatorFile::loadBuiltin(
$this->getViewer(),
'conpherence.png');
}
$file = $default;
}
$conpherence->attachProfileImageFile($file);
}
}
}
return $conpherences;
}
protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
if ($this->participantPHIDs !== null
|| ($this->fulltext !== null && strlen($this->fulltext))) {
return qsprintf($conn_r, 'GROUP BY thread.id');
} else {
return $this->buildApplicationSearchGroupClause($conn_r);
}
}
protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
$joins = parent::buildJoinClauseParts($conn);
if ($this->participantPHIDs !== null) {
$joins[] = qsprintf(
$conn,
'JOIN %T p ON p.conpherencePHID = thread.phid',
id(new ConpherenceParticipant())->getTableName());
}
if ($this->fulltext !== null && strlen($this->fulltext)) {
$joins[] = qsprintf(
$conn,
'JOIN %T idx ON idx.threadPHID = thread.phid',
id(new ConpherenceIndex())->getTableName());
}
// See note in buildWhereClauseParts() about this optimization.
$viewer = $this->getViewer();
if (!$viewer->isOmnipotent() && $viewer->isLoggedIn()) {
$joins[] = qsprintf(
$conn,
'LEFT JOIN %T vp ON vp.conpherencePHID = thread.phid
AND vp.participantPHID = %s',
id(new ConpherenceParticipant())->getTableName(),
$viewer->getPHID());
}
return $joins;
}
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
// Optimize policy filtering of private rooms. If we are not looking for
// particular rooms by ID or PHID, we can just skip over any rooms with
// "View Policy: Room Participants" if the viewer isn't a participant: we
// know they won't be able to see the room.
// This avoids overheating browse/search queries, since it's common for
// a large number of rooms to be private and have this view policy.
$viewer = $this->getViewer();
$can_optimize =
!$viewer->isOmnipotent() &&
($this->ids === null) &&
($this->phids === null);
if ($can_optimize) {
$members_policy = id(new ConpherenceThreadMembersPolicyRule())
->getObjectPolicyFullKey();
$policies = array(
$members_policy,
PhabricatorPolicies::POLICY_USER,
PhabricatorPolicies::POLICY_ADMIN,
PhabricatorPolicies::POLICY_NOONE,
);
if ($viewer->isLoggedIn()) {
$where[] = qsprintf(
$conn,
'thread.viewPolicy NOT IN (%Ls) OR vp.participantPHID = %s',
$policies,
$viewer->getPHID());
} else {
$where[] = qsprintf(
$conn,
'thread.viewPolicy NOT IN (%Ls)',
$policies);
}
}
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'thread.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
'thread.phid IN (%Ls)',
$this->phids);
}
if ($this->participantPHIDs !== null) {
$where[] = qsprintf(
$conn,
'p.participantPHID IN (%Ls)',
$this->participantPHIDs);
}
if ($this->fulltext !== null && strlen($this->fulltext)) {
$where[] = qsprintf(
$conn,
'MATCH(idx.corpus) AGAINST (%s IN BOOLEAN MODE)',
$this->fulltext);
}
return $where;
}
private function loadParticipantsAndInitHandles(array $conpherences) {
$participants = id(new ConpherenceParticipant())
->loadAllWhere('conpherencePHID IN (%Ls)', array_keys($conpherences));
$map = mgroup($participants, 'getConpherencePHID');
foreach ($conpherences as $current_conpherence) {
$conpherence_phid = $current_conpherence->getPHID();
$conpherence_participants = idx(
$map,
$conpherence_phid,
array());
$conpherence_participants = mpull(
$conpherence_participants,
null,
'getParticipantPHID');
$current_conpherence->attachParticipants($conpherence_participants);
$current_conpherence->attachHandles(array());
}
return $this;
}
private function loadCoreHandles(
array $conpherences,
$method) {
$handle_phids = array();
foreach ($conpherences as $conpherence) {
$handle_phids[$conpherence->getPHID()] =
$conpherence->$method();
}
$flat_phids = array_mergev($handle_phids);
$viewer = $this->getViewer();
$handles = $viewer->loadHandles($flat_phids);
$handles = iterator_to_array($handles);
foreach ($handle_phids as $conpherence_phid => $phids) {
$conpherence = $conpherences[$conpherence_phid];
$conpherence->attachHandles(
$conpherence->getHandles() + array_select_keys($handles, $phids));
}
return $this;
}
private function loadTransactionsAndHandles(array $conpherences) {
// NOTE: This is older code which has been modernized to the minimum
// standard required by T13266. It probably isn't the best available
// approach to the problems it solves.
$limit = $this->getTransactionLimit();
if ($limit) {
// fetch an extra for "show older" scenarios
$limit = $limit + 1;
} else {
$limit = 0xFFFF;
}
$pager = id(new AphrontCursorPagerView())
->setPageSize($limit);
// We have to flip these for the underlying query class. The semantics of
// paging are tricky business.
if ($this->afterTransactionID) {
$pager->setBeforeID($this->afterTransactionID);
} else if ($this->beforeTransactionID) {
$pager->setAfterID($this->beforeTransactionID);
}
$transactions = id(new ConpherenceTransactionQuery())
->setViewer($this->getViewer())
->withObjectPHIDs(array_keys($conpherences))
->needHandles(true)
->executeWithCursorPager($pager);
$transactions = mgroup($transactions, 'getObjectPHID');
foreach ($conpherences as $phid => $conpherence) {
$current_transactions = idx($transactions, $phid, array());
$handles = array();
foreach ($current_transactions as $transaction) {
$handles += $transaction->getHandles();
}
$conpherence->attachHandles($conpherence->getHandles() + $handles);
$conpherence->attachTransactions($current_transactions);
}
return $this;
}
public function getQueryApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
protected function getPrimaryTableAlias() {
return 'thread';
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/mail/ConpherenceReplyHandler.php | src/applications/conpherence/mail/ConpherenceReplyHandler.php | <?php
final class ConpherenceReplyHandler extends PhabricatorMailReplyHandler {
private $mailAddedParticipantPHIDs;
public function setMailAddedParticipantPHIDs(array $phids) {
$this->mailAddedParticipantPHIDs = $phids;
return $this;
}
public function getMailAddedParticipantPHIDs() {
return $this->mailAddedParticipantPHIDs;
}
public function validateMailReceiver($mail_receiver) {
if (!($mail_receiver instanceof ConpherenceThread)) {
throw new Exception(
pht(
'Mail receiver is not a %s!', '
ConpherenceThread'));
}
}
public function getPrivateReplyHandlerEmailAddress(PhabricatorUser $user) {
return $this->getDefaultPrivateReplyHandlerEmailAddress($user, 'Z');
}
public function getPublicReplyHandlerEmailAddress() {
return $this->getDefaultPublicReplyHandlerEmailAddress('Z');
}
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) {
$conpherence = $this->getMailReceiver();
$user = $this->getActor();
if (!$conpherence->getPHID()) {
$conpherence
->attachParticipants(array());
} else {
$participants = id(new ConpherenceParticipant())
->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
$participants = mpull($participants, null, 'getParticipantPHID');
$conpherence->attachParticipants($participants);
}
$content_source = $mail->newContentSource();
$editor = id(new ConpherenceEditor())
->setActor($user)
->setContentSource($content_source)
->setParentMessageID($mail->getMessageID());
$body = $mail->getCleanTextBody();
$body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments());
$xactions = array();
if ($this->getMailAddedParticipantPHIDs()) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => $this->getMailAddedParticipantPHIDs()));
}
$xactions = array_merge(
$xactions,
$editor->generateTransactionsFromText(
$user,
$conpherence,
$body));
$editor->applyTransactions($conpherence, $xactions);
return $conpherence;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/mail/ConpherenceThreadMailReceiver.php | src/applications/conpherence/mail/ConpherenceThreadMailReceiver.php | <?php
final class ConpherenceThreadMailReceiver
extends PhabricatorObjectMailReceiver {
public function isEnabled() {
$app_class = 'PhabricatorConpherenceApplication';
return PhabricatorApplication::isClassInstalled($app_class);
}
protected function getObjectPattern() {
return 'Z[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)substr($pattern, 1);
return id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
protected function getTransactionReplyHandler() {
return new ConpherenceReplyHandler();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/editor/ConpherenceEditEngine.php | src/applications/conpherence/editor/ConpherenceEditEngine.php | <?php
final class ConpherenceEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'conpherence.thread';
public function getEngineName() {
return pht('Conpherence');
}
public function getEngineApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
public function getSummaryHeader() {
return pht('Configure Conpherence Forms');
}
public function getSummaryText() {
return pht('Configure creation and editing forms in Conpherence.');
}
protected function newEditableObject() {
return ConpherenceThread::initializeNewRoom($this->getViewer());
}
protected function newObjectQuery() {
return new ConpherenceThreadQuery();
}
protected function getObjectCreateTitleText($object) {
return pht('Create New Room');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Room: %s', $object->getTitle());
}
protected function getObjectEditShortText($object) {
return $object->getTitle();
}
protected function getObjectCreateShortText() {
return pht('Create Room');
}
protected function getObjectName() {
return pht('Room');
}
protected function getObjectCreateCancelURI($object) {
return $this->getApplication()->getApplicationURI('/');
}
protected function getEditorURI() {
return $this->getApplication()->getApplicationURI('edit/');
}
protected function getObjectViewURI($object) {
return $object->getURI();
}
public function isEngineConfigurable() {
return false;
}
protected function buildCustomEditFields($object) {
$viewer = $this->getViewer();
if ($this->getIsCreate()) {
$participant_phids = array($viewer->getPHID());
$initial_phids = array();
} else {
$participant_phids = $object->getParticipantPHIDs();
$initial_phids = $participant_phids;
}
// Only show participants on create or conduit, not edit.
$show_participants = (bool)$this->getIsCreate();
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Room name.'))
->setConduitTypeDescription(pht('New Room name.'))
->setIsRequired(true)
->setTransactionType(
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
->setValue($object->getTitle()),
id(new PhabricatorTextEditField())
->setKey('topic')
->setLabel(pht('Topic'))
->setDescription(pht('Room topic.'))
->setConduitTypeDescription(pht('New Room topic.'))
->setTransactionType(
ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
->setValue($object->getTopic()),
id(new PhabricatorUsersEditField())
->setKey('participants')
->setValue($participant_phids)
->setInitialValue($initial_phids)
->setIsFormField($show_participants)
->setAliases(array('users', 'members', 'participants', 'userPHID'))
->setDescription(pht('Room participants.'))
->setUseEdgeTransactions(true)
->setConduitTypeDescription(pht('New Room participants.'))
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setLabel(pht('Initial Participants')),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/editor/ConpherenceEditor.php | src/applications/conpherence/editor/ConpherenceEditor.php | <?php
final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
const ERROR_EMPTY_PARTICIPANTS = 'error-empty-participants';
const ERROR_EMPTY_MESSAGE = 'error-empty-message';
public function getEditorApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
public function getEditorObjectsDescription() {
return pht('Conpherence Rooms');
}
public static function createThread(
PhabricatorUser $creator,
array $participant_phids,
$title,
$message,
PhabricatorContentSource $source,
$topic) {
$conpherence = ConpherenceThread::initializeNewRoom($creator);
$errors = array();
if (empty($participant_phids)) {
$errors[] = self::ERROR_EMPTY_PARTICIPANTS;
} else {
$participant_phids[] = $creator->getPHID();
$participant_phids = array_unique($participant_phids);
}
if (empty($message)) {
$errors[] = self::ERROR_EMPTY_MESSAGE;
}
if (!$errors) {
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => $participant_phids));
if ($title) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
->setNewValue($title);
}
if (strlen($topic)) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
->setNewValue($topic);
}
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment(
id(new ConpherenceTransactionComment())
->setContent($message)
->setConpherencePHID($conpherence->getPHID()));
id(new ConpherenceEditor())
->setActor($creator)
->setContentSource($source)
->setContinueOnNoEffect(true)
->applyTransactions($conpherence, $xactions);
}
return array($errors, $conpherence);
}
public function generateTransactionsFromText(
PhabricatorUser $viewer,
ConpherenceThread $conpherence,
$text) {
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment(
id(new ConpherenceTransactionComment())
->setContent($text)
->setConpherencePHID($conpherence->getPHID()));
return $xactions;
}
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
return $types;
}
public function getCreateObjectTitle($author, $object) {
return pht('%s created this room.', $author);
}
protected function applyBuiltinInternalTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
$object->setMessageCount((int)$object->getMessageCount() + 1);
break;
}
return parent::applyBuiltinInternalTransaction($object, $xaction);
}
protected function applyFinalEffects(
PhabricatorLiskDAO $object,
array $xactions) {
$acting_phid = $this->getActingAsPHID();
$participants = $object->getParticipants();
foreach ($participants as $participant) {
if ($participant->getParticipantPHID() == $acting_phid) {
$participant->markUpToDate($object);
}
}
if ($participants) {
PhabricatorUserCache::clearCaches(
PhabricatorUserMessageCountCacheType::KEY_COUNT,
array_keys($participants));
}
if ($xactions) {
$data = array(
'type' => 'message',
'threadPHID' => $object->getPHID(),
'messageID' => last($xactions)->getID(),
'subscribers' => array($object->getPHID()),
);
PhabricatorNotificationClient::tryToPostMessage($data);
}
return $xactions;
}
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
return id(new ConpherenceReplyHandler())
->setActor($this->getActor())
->setMailReceiver($object);
}
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
$id = $object->getID();
$title = $object->getTitle();
if (!$title) {
$title = pht(
'%s sent you a message.',
$this->getActor()->getUserName());
}
return id(new PhabricatorMetaMTAMail())
->setSubject("Z{$id}: {$title}");
}
protected function getMailTo(PhabricatorLiskDAO $object) {
$to_phids = array();
$participants = $object->getParticipants();
if (!$participants) {
return $to_phids;
}
$participant_phids = mpull($participants, 'getParticipantPHID');
$users = id(new PhabricatorPeopleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs($participant_phids)
->needUserSettings(true)
->execute();
$users = mpull($users, null, 'getPHID');
$notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY;
$notification_email =
PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL;
foreach ($participants as $phid => $participant) {
$user = idx($users, $phid);
if ($user) {
$default = $user->getUserSetting($notification_key);
} else {
$default = $notification_email;
}
$settings = $participant->getSettings();
$notifications = idx($settings, 'notifications', $default);
if ($notifications == $notification_email) {
$to_phids[] = $phid;
}
}
return $to_phids;
}
protected function getMailCC(PhabricatorLiskDAO $object) {
return array();
}
protected function buildMailBody(
PhabricatorLiskDAO $object,
array $xactions) {
$body = parent::buildMailBody($object, $xactions);
$body->addLinkSection(
pht('CONPHERENCE DETAIL'),
PhabricatorEnv::getProductionURI('/'.$object->getMonogram()));
return $body;
}
protected function addEmailPreferenceSectionToMailBody(
PhabricatorMetaMTAMailBody $body,
PhabricatorLiskDAO $object,
array $xactions) {
$href = PhabricatorEnv::getProductionURI(
'/'.$object->getMonogram().'?settings');
$label = pht('EMAIL PREFERENCES FOR THIS ROOM');
$body->addLinkSection($label, $href);
}
protected function getMailSubjectPrefix() {
return pht('[Conpherence]');
}
protected function supportsSearch() {
return true;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/xaction/ConpherenceThreadDateMarkerTransaction.php | src/applications/conpherence/xaction/ConpherenceThreadDateMarkerTransaction.php | <?php
final class ConpherenceThreadDateMarkerTransaction
extends ConpherenceThreadTransactionType {
const TRANSACTIONTYPE = 'date-marker';
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php | src/applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php | <?php
final class ConpherenceThreadPictureTransaction
extends ConpherenceThreadTransactionType {
const TRANSACTIONTYPE = 'picture';
public function generateOldValue($object) {
return $object->getProfileImagePHID();
}
public function applyInternalEffects($object, $value) {
$object->setProfileImagePHID($value);
}
public function getTitle() {
return pht(
'%s updated the room image.',
$this->renderAuthor());
}
public function getTitleForFeed() {
return pht(
'%s updated the room image for %s.',
$this->renderAuthor(),
$this->renderObject());
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php | src/applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php | <?php
final class ConpherenceThreadTitleTransaction
extends ConpherenceThreadTransactionType {
const TRANSACTIONTYPE = 'title';
public function generateOldValue($object) {
return $object->getTitle();
}
public function applyInternalEffects($object, $value) {
$object->setTitle($value);
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if (strlen($old) && strlen($new)) {
return pht(
'%s renamed this room from %s to %s.',
$this->renderAuthor(),
$this->renderOldValue(),
$this->renderNewValue());
} else {
return pht(
'%s created this room.',
$this->renderAuthor());
}
}
public function getTitleForFeed() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if (strlen($old) && strlen($new)) {
return pht(
'%s renamed %s from %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderOldValue(),
$this->renderNewValue());
} else {
return pht(
'%s created %s.',
$this->renderAuthor(),
$this->renderObject());
}
}
public function validateTransactions($object, array $xactions) {
$errors = array();
if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
$errors[] = $this->newRequiredError(
pht('Rooms must have a title.'));
}
$max_length = $object->getColumnMaximumByteLength('title');
foreach ($xactions as $xaction) {
$new_value = $xaction->getNewValue();
$new_length = strlen($new_value);
if ($new_length > $max_length) {
$errors[] = $this->newInvalidError(
pht('The title can be no longer than %s characters.',
new PhutilNumber($max_length)));
}
}
return $errors;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/xaction/ConpherenceThreadTransactionType.php | src/applications/conpherence/xaction/ConpherenceThreadTransactionType.php | <?php
abstract class ConpherenceThreadTransactionType
extends PhabricatorModularTransactionType {}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/xaction/ConpherenceThreadParticipantsTransaction.php | src/applications/conpherence/xaction/ConpherenceThreadParticipantsTransaction.php | <?php
final class ConpherenceThreadParticipantsTransaction
extends ConpherenceThreadTransactionType {
const TRANSACTIONTYPE = 'participants';
public function generateOldValue($object) {
return $object->getParticipantPHIDs();
}
public function generateNewValue($object, $value) {
$old = $this->generateOldValue($object);
return $this->getPHIDList($old, $value);
}
public function applyExternalEffects($object, $value) {
$participants = $object->getParticipants();
$old = array_keys($participants);
$new = $value;
$add_map = array_fuse(array_diff($new, $old));
$rem_map = array_fuse(array_diff($old, $new));
foreach ($rem_map as $phid) {
$remove_participant = $participants[$phid];
$remove_participant->delete();
unset($participants[$phid]);
}
foreach ($add_map as $phid) {
if (isset($participants[$phid])) {
continue;
}
$participants[$phid] = id(new ConpherenceParticipant())
->setConpherencePHID($object->getPHID())
->setParticipantPHID($phid)
->setSeenMessageCount(0)
->save();
}
$object->attachParticipants($participants);
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
$author_phid = $this->getAuthorPHID();
if ($add && $rem) {
return pht(
'%s edited participant(s), added %d: %s; removed %d: %s.',
$this->renderAuthor(),
count($add),
$this->renderHandleList($add),
count($rem),
$this->renderHandleList($rem));
} else if ((in_array($author_phid, $add)) && (count($add) == 1)) {
return pht(
'%s joined the room.',
$this->renderAuthor());
} else if ((in_array($author_phid, $rem)) && (count($rem) == 1)) {
return pht(
'%s left the room.',
$this->renderAuthor());
} else if ($add) {
return pht(
'%s added %d participant(s): %s.',
$this->renderAuthor(),
count($add),
$this->renderHandleList($add));
} else {
return pht(
'%s removed %d participant(s): %s.',
$this->renderAuthor(),
count($rem),
$this->renderHandleList($rem));
}
}
public function validateTransactions($object, array $xactions) {
$errors = array();
foreach ($xactions as $xaction) {
$old = $object->getParticipantPHIDs();
$new = $xaction->getNewValue();
$new = $this->getPHIDList($old, $new);
$add_map = array_fuse(array_diff($new, $old));
$rem_map = array_fuse(array_diff($old, $new));
foreach ($add_map as $user_phid) {
$user = id(new PhabricatorPeopleQuery())
->setViewer($this->getActor())
->withPHIDs(array($user_phid))
->executeOne();
if (!$user) {
$errors[] = $this->newInvalidError(
pht(
'Participant PHID "%s" is not a valid user PHID.',
$user_phid));
continue;
}
}
}
return $errors;
}
public function getRequiredCapabilities(
$object,
PhabricatorApplicationTransaction $xaction) {
$old_map = array_fuse($xaction->getOldValue());
$new_map = array_fuse($xaction->getNewValue());
$add = array_keys(array_diff_key($new_map, $old_map));
$rem = array_keys(array_diff_key($old_map, $new_map));
$actor_phid = $this->getActingAsPHID();
$is_join = (($add === array($actor_phid)) && !$rem);
$is_leave = (($rem === array($actor_phid)) && !$add);
if ($is_join) {
// Anyone can join a thread they can see.
return null;
}
if ($is_leave) {
// Anyone can leave a thread.
return null;
}
// You need CAN_EDIT to add or remove participants. For additional
// discussion, see D17696 and T4411.
return PhabricatorPolicyCapability::CAN_EDIT;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php | src/applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php | <?php
final class ConpherenceThreadTopicTransaction
extends ConpherenceThreadTransactionType {
const TRANSACTIONTYPE = 'topic';
public function generateOldValue($object) {
return $object->getTopic();
}
public function applyInternalEffects($object, $value) {
$object->setTopic($value);
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if (strlen($new)) {
return pht(
'%s set the room topic to %s.',
$this->renderAuthor(),
$this->renderNewValue());
} else {
return pht(
'%s removed the room topic.',
$this->renderAuthor());
}
}
public function getTitleForFeed() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if (strlen($new)) {
return pht(
'%s set the room topic to %s in %s.',
$this->renderAuthor(),
$this->renderNewValue(),
$this->renderObject());
} else {
return pht(
'%s removed the room topic for %s.',
$this->renderAuthor(),
$this->renderObject());
}
}
public function validateTransactions($object, array $xactions) {
$errors = array();
$max_length = $object->getColumnMaximumByteLength('topic');
foreach ($xactions as $xaction) {
$new_value = $xaction->getNewValue();
$new_length = strlen($new_value);
if ($new_length > $max_length) {
$errors[] = $this->newInvalidError(
pht('The topic can be no longer than %s characters.',
new PhutilNumber($max_length)));
}
}
return $errors;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/application/PhabricatorConpherenceApplication.php | src/applications/conpherence/application/PhabricatorConpherenceApplication.php | <?php
final class PhabricatorConpherenceApplication extends PhabricatorApplication {
public function getBaseURI() {
return '/conpherence/';
}
public function getName() {
return pht('Conpherence');
}
public function getShortDescription() {
return pht('Chat with Others');
}
public function getIcon() {
return 'fa-comments';
}
public function getTitleGlyph() {
return "\xE2\x9C\x86";
}
public function getRemarkupRules() {
return array(
new ConpherenceThreadRemarkupRule(),
);
}
public function getRoutes() {
return array(
'/Z(?P<id>[1-9]\d*)'
=> 'ConpherenceViewController',
'/conpherence/' => array(
''
=> 'ConpherenceListController',
'thread/(?P<id>[1-9]\d*)/'
=> 'ConpherenceListController',
'threadsearch/(?P<id>[1-9]\d*)/'
=> 'ConpherenceThreadSearchController',
'(?P<id>[1-9]\d*)/'
=> 'ConpherenceViewController',
'(?P<id>[1-9]\d*)/(?P<messageID>[1-9]\d*)/'
=> 'ConpherenceViewController',
'columnview/'
=> 'ConpherenceColumnViewController',
$this->getEditRoutePattern('new/')
=> 'ConpherenceRoomEditController',
$this->getEditRoutePattern('edit/')
=> 'ConpherenceRoomEditController',
'picture/(?P<id>[1-9]\d*)/'
=> 'ConpherenceRoomPictureController',
'search/(?:query/(?P<queryKey>[^/]+)/)?'
=> 'ConpherenceRoomListController',
'panel/'
=> 'ConpherenceNotificationPanelController',
'participant/(?P<id>[1-9]\d*)/'
=> 'ConpherenceParticipantController',
'preferences/(?P<id>[1-9]\d*)/'
=> 'ConpherenceRoomPreferencesController',
'update/(?P<id>[1-9]\d*)/'
=> 'ConpherenceUpdateController',
),
);
}
public function getQuicksandURIPatternBlacklist() {
return array(
'/conpherence/.*',
'/Z\d+',
);
}
public function getMailCommandObjects() {
// TODO: Conpherence threads don't currently support any commands directly,
// so the documentation page we end up generating is empty and funny
// looking. Add support here once we support "!add", "!leave", "!topic",
// or whatever else.
return array();
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/__tests__/ConpherenceTestCase.php | src/applications/conpherence/__tests__/ConpherenceTestCase.php | <?php
abstract class ConpherenceTestCase extends PhabricatorTestCase {
protected function addParticipants(
PhabricatorUser $actor,
ConpherenceThread $conpherence,
array $participant_phids) {
$xactions = array(
id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => $participant_phids)),
);
$editor = id(new ConpherenceEditor())
->setActor($actor)
->setContentSource($this->newContentSource())
->applyTransactions($conpherence, $xactions);
}
protected function removeParticipants(
PhabricatorUser $actor,
ConpherenceThread $conpherence,
array $participant_phids) {
$xactions = array(
id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('-' => $participant_phids)),
);
$editor = id(new ConpherenceEditor())
->setActor($actor)
->setContentSource($this->newContentSource())
->applyTransactions($conpherence, $xactions);
}
protected function addMessageWithFile(
PhabricatorUser $actor,
ConpherenceThread $conpherence) {
$file = $this->generateTestFile($actor);
$message = Filesystem::readRandomCharacters(64).
sprintf(' {%s} ', $file->getMonogram());
$editor = id(new ConpherenceEditor())
->setActor($actor)
->setContentSource($this->newContentSource());
$xactions = $editor->generateTransactionsFromText(
$actor,
$conpherence,
$message);
return $editor->applyTransactions($conpherence, $xactions);
}
private function generateTestFile(PhabricatorUser $actor) {
$engine = new PhabricatorTestStorageEngine();
$data = Filesystem::readRandomCharacters(64);
$params = array(
'name' => 'test.'.$actor->getPHID(),
'viewPolicy' => $actor->getPHID(),
'authorPHID' => $actor->getPHID(),
'storageEngines' => array(
$engine,
),
);
$file = PhabricatorFile::newFromFileData($data, $params);
$file->save();
return $file;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php | src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php | <?php
final class ConpherenceRoomTestCase extends ConpherenceTestCase {
protected function getPhabricatorTestCaseConfiguration() {
return array(
self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
);
}
public function testOneUserRoomCreate() {
$creator = $this->generateNewTestUser();
$participant_phids = array($creator->getPHID());
$conpherence = $this->createRoom($creator, $participant_phids);
$this->assertTrue((bool)$conpherence->getID());
$this->assertEqual(1, count($conpherence->getParticipants()));
}
public function testNUserRoomCreate() {
$creator = $this->generateNewTestUser();
$friend_1 = $this->generateNewTestUser();
$friend_2 = $this->generateNewTestUser();
$friend_3 = $this->generateNewTestUser();
$participant_phids = array(
$creator->getPHID(),
$friend_1->getPHID(),
$friend_2->getPHID(),
$friend_3->getPHID(),
);
$conpherence = $this->createRoom($creator, $participant_phids);
$this->assertTrue((bool)$conpherence->getID());
$this->assertEqual(4, count($conpherence->getParticipants()));
}
public function testRoomParticipantAddition() {
$creator = $this->generateNewTestUser();
$friend_1 = $this->generateNewTestUser();
$friend_2 = $this->generateNewTestUser();
$friend_3 = $this->generateNewTestUser();
$participant_phids = array(
$creator->getPHID(),
$friend_1->getPHID(),
);
$conpherence = $this->createRoom($creator, $participant_phids);
$this->assertTrue((bool)$conpherence->getID());
$this->assertEqual(2, count($conpherence->getParticipants()));
// test add by creator
$participant_phids[] = $friend_2->getPHID();
$this->addParticipants($creator, $conpherence, array($friend_2->getPHID()));
$this->assertEqual(3, count($conpherence->getParticipants()));
// test add by other participant, so recent participation should
// meaningfully change
$participant_phids = array(
$friend_2->getPHID(), // actor
$creator->getPHID(), // last actor
$friend_1->getPHID(),
$friend_3->getPHID(), // new addition
);
$this->addParticipants(
$friend_2,
$conpherence,
array($friend_3->getPHID()));
$this->assertEqual(4, count($conpherence->getParticipants()));
}
public function testRoomParticipantDeletion() {
$creator = $this->generateNewTestUser();
$friend_1 = $this->generateNewTestUser();
$friend_2 = $this->generateNewTestUser();
$friend_3 = $this->generateNewTestUser();
$participant_map = array(
$creator->getPHID() => $creator,
$friend_1->getPHID() => $friend_1,
$friend_2->getPHID() => $friend_2,
$friend_3->getPHID() => $friend_3,
);
$conpherence = $this->createRoom(
$creator,
array_keys($participant_map));
foreach ($participant_map as $phid => $user) {
$this->removeParticipants($user, $conpherence, array($phid));
unset($participant_map[$phid]);
$this->assertEqual(
count($participant_map),
count($conpherence->getParticipants()));
}
}
private function createRoom(
PhabricatorUser $creator,
array $participant_phids) {
$conpherence = ConpherenceThread::initializeNewRoom($creator);
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => $participant_phids));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
->setNewValue(pht('Test'));
id(new ConpherenceEditor())
->setActor($creator)
->setContentSource($this->newContentSource())
->setContinueOnNoEffect(true)
->applyTransactions($conpherence, $xactions);
return $conpherence;
}
private function changeEditPolicy(
PhabricatorUser $actor,
ConpherenceThread $room,
$policy) {
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($policy);
id(new ConpherenceEditor())
->setActor($actor)
->setContentSource($this->newContentSource())
->setContinueOnNoEffect(true)
->applyTransactions($room, $xactions);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/policyrule/ConpherenceThreadMembersPolicyRule.php | src/applications/conpherence/policyrule/ConpherenceThreadMembersPolicyRule.php | <?php
final class ConpherenceThreadMembersPolicyRule
extends PhabricatorPolicyRule {
public function getObjectPolicyKey() {
return 'conpherence.members';
}
public function getObjectPolicyName() {
return pht('Room Participants');
}
public function getPolicyExplanation() {
return pht('Participants in this room can take this action.');
}
public function getRuleDescription() {
return pht('room participants');
}
public function getObjectPolicyIcon() {
return 'fa-comments';
}
public function canApplyToObject(PhabricatorPolicyInterface $object) {
return ($object instanceof ConpherenceThread);
}
public function applyRule(
PhabricatorUser $viewer,
$value,
PhabricatorPolicyInterface $object) {
$viewer_phid = $viewer->getPHID();
if (!$viewer_phid) {
return false;
}
return (bool)$object->getParticipantIfExists($viewer_phid);
}
public function getValueControlType() {
return self::CONTROL_TYPE_NONE;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/lipsum/PhabricatorConpherenceRoomTestDataGenerator.php | src/applications/conpherence/lipsum/PhabricatorConpherenceRoomTestDataGenerator.php | <?php
final class PhabricatorConpherenceRoomTestDataGenerator
extends PhabricatorTestDataGenerator {
const GENERATORKEY = 'conpherence';
public function getGeneratorName() {
return pht('Conpherence');
}
public function generateObject() {
$author = $this->loadRandomUser();
$name = $this->newRoomName();
$participants = array();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$rando_phids = array();
$rando_phids[] = $author->getPHID();
foreach ($participants as $actor) {
$rando_phids[] = $actor->getPHID();
}
$xactions = array();
$xactions[] = array(
'type' => 'name',
'value' => $name,
);
$xactions[] = array(
'type' => 'participants.set',
'value' => $rando_phids,
);
$xactions[] = array(
'type' => 'view',
'value' => 'users',
);
$xactions[] = array(
'type' => 'edit',
'value' => 'users',
);
$params = array(
'transactions' => $xactions,
);
$result = id(new ConduitCall('conpherence.edit', $params))
->setUser($author)
->execute();
return $result['object']['phid'];
}
protected function newRoomName() {
$generator = new PhabricatorConpherenceRoomContextFreeGrammar();
$name = $generator->generate();
return $name;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/lipsum/PhabricatorConpherenceRoomContextFreeGrammar.php | src/applications/conpherence/lipsum/PhabricatorConpherenceRoomContextFreeGrammar.php | <?php
final class PhabricatorConpherenceRoomContextFreeGrammar
extends PhutilContextFreeGrammar {
protected function getRules() {
return array(
'start' => array(
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept] ([city])',
'[dept] ([city])',
'[dept] - [city]',
'[dept] - [room]',
'[dept] / [room]',
'[dept] [room]',
'[city] ([dept]) - [room]',
'[dept] ([city]) - [room]',
'[dept] ([city]) [room]',
),
'dept' => array(
'Eng',
'Engineering',
'User Interface',
'Design',
'Data Science',
'Database',
'Marketing',
'Content',
'Ads',
'Operations',
'Network Ops',
'Ops',
'Server Ops',
'IT',
'Information Technology',
'i18n',
'Internationalization',
'Human Resources',
'HR',
'Research & Development',
'R&D',
'Management',
'Directors',
'Managers',
'Support',
'Customer Support',
'Finance',
'Sales',
'Purchasing',
'Education',
'Hardware Engineering',
'Software',
'Supply Management',
'Logistics',
'Growth',
'Content Strategy',
'Developer Relations',
'Accounting',
'Production',
),
'city' => array(
'Palo Alto',
'Mtn View',
'Cupertino',
'Los Altos',
'Menlo Park',
'Santa Cruz',
'S.F.',
'San Francisco',
'Seattle',
'London',
'New York',
'Dublin',
'Tokyo',
),
'room' => array(
'General',
'Announcements',
'Staff',
'Interns',
'Managers',
'Book Club',
'Parking',
'Sports',
'Social',
'Commuting',
'For Sale',
'Parents@',
),
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/view/ConpherenceTransactionView.php | src/applications/conpherence/view/ConpherenceTransactionView.php | <?php
final class ConpherenceTransactionView extends AphrontView {
private $conpherenceThread;
private $conpherenceTransaction;
private $handles;
private $markupEngine;
private $classes = array();
private $searchResult;
private $timeOnly;
public function setConpherenceThread(ConpherenceThread $t) {
$this->conpherenceThread = $t;
return $this;
}
private function getConpherenceThread() {
return $this->conpherenceThread;
}
public function setConpherenceTransaction(ConpherenceTransaction $tx) {
$this->conpherenceTransaction = $tx;
return $this;
}
private function getConpherenceTransaction() {
return $this->conpherenceTransaction;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function getHandles() {
return $this->handles;
}
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
$this->markupEngine = $markup_engine;
return $this;
}
private function getMarkupEngine() {
return $this->markupEngine;
}
public function addClass($class) {
$this->classes[] = $class;
return $this;
}
public function setSearchResult($result) {
$this->searchResult = $result;
return $this;
}
public function render() {
$viewer = $this->getUser();
if (!$viewer) {
throw new PhutilInvalidStateException('setUser');
}
require_celerity_resource('conpherence-transaction-css');
$transaction = $this->getConpherenceTransaction();
switch ($transaction->getTransactionType()) {
case ConpherenceThreadDateMarkerTransaction::TRANSACTIONTYPE:
return javelin_tag(
'div',
array(
'class' => 'conpherence-transaction-view date-marker',
'sigil' => 'conpherence-transaction-view',
'meta' => array(
'id' => $transaction->getID() + 0.5,
),
),
array(
phutil_tag(
'span',
array(
'class' => 'date',
),
phabricator_format_local_time(
$transaction->getDateCreated(),
$viewer,
'M jS, Y')),
));
break;
}
$info = $this->renderTransactionInfo();
$actions = $this->renderTransactionActions();
$image = $this->renderTransactionImage();
$content = $this->renderTransactionContent();
$classes = implode(' ', $this->classes);
$transaction_dom_id = 'anchor-'.$transaction->getID();
$header = phutil_tag_div(
'conpherence-transaction-header grouped',
array($actions, $info));
return javelin_tag(
'div',
array(
'class' => 'conpherence-transaction-view '.$classes,
'id' => $transaction_dom_id,
'sigil' => 'conpherence-transaction-view',
'meta' => array(
'id' => $transaction->getID(),
),
),
array(
$image,
phutil_tag_div('conpherence-transaction-detail grouped',
array($header, $content)),
));
}
private function renderTransactionInfo() {
$viewer = $this->getUser();
$thread = $this->getConpherenceThread();
$transaction = $this->getConpherenceTransaction();
$info = array();
Javelin::initBehavior('phabricator-tooltips');
$tip = phabricator_datetime($transaction->getDateCreated(), $viewer);
$label = phabricator_time($transaction->getDateCreated(), $viewer);
$width = 360;
Javelin::initBehavior('phabricator-watch-anchor');
$anchor = id(new PhabricatorAnchorView())
->setAnchorName($transaction->getID())
->render();
if ($this->searchResult) {
$uri = $thread->getMonogram();
$info[] = hsprintf(
'%s',
javelin_tag(
'a',
array(
'href' => '/'.$uri.'#'.$transaction->getID(),
'class' => 'transaction-date',
'sigil' => 'conpherence-search-result-jump',
),
$tip));
} else {
$info[] = hsprintf(
'%s%s',
$anchor,
javelin_tag(
'a',
array(
'href' => '#'.$transaction->getID(),
'class' => 'transaction-date anchor-link',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $tip,
'size' => $width,
),
),
$label));
}
return phutil_tag(
'span',
array(
'class' => 'conpherence-transaction-info',
),
$info);
}
private function renderTransactionActions() {
$transaction = $this->getConpherenceTransaction();
switch ($transaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
$handles = $this->getHandles();
$author = $handles[$transaction->getAuthorPHID()];
$actions = array($author->renderLink());
break;
default:
$actions = null;
break;
}
return $actions;
}
private function renderTransactionImage() {
$image = null;
$transaction = $this->getConpherenceTransaction();
switch ($transaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
$handles = $this->getHandles();
$author = $handles[$transaction->getAuthorPHID()];
$image_uri = $author->getImageURI();
$image = phutil_tag(
'span',
array(
'class' => 'conpherence-transaction-image',
'style' => 'background-image: url('.$image_uri.');',
));
break;
}
return $image;
}
private function renderTransactionContent() {
$transaction = $this->getConpherenceTransaction();
$content = null;
$content_class = null;
$content = null;
$handles = $this->getHandles();
switch ($transaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
$this->addClass('conpherence-comment');
$author = $handles[$transaction->getAuthorPHID()];
$comment = $transaction->getComment();
$content = $this->getMarkupEngine()->getOutput(
$comment,
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
$content_class = 'conpherence-message';
break;
default:
$content = $transaction->getTitle();
$this->addClass('conpherence-edited');
break;
}
$view = phutil_tag(
'div',
array(
'class' => $content_class,
),
$content);
return phutil_tag_div('conpherence-transaction-content', $view);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/view/ConpherenceThreadListView.php | src/applications/conpherence/view/ConpherenceThreadListView.php | <?php
final class ConpherenceThreadListView extends AphrontView {
const SEE_ALL_LIMIT = 16;
private $baseURI;
private $threads;
public function setThreads(array $threads) {
assert_instances_of($threads, 'ConpherenceThread');
$this->threads = $threads;
return $this;
}
public function setBaseURI($base_uri) {
$this->baseURI = $base_uri;
return $this;
}
public function render() {
require_celerity_resource('conpherence-menu-css');
$menu = id(new PHUIListView())
->addClass('conpherence-menu')
->setID('conpherence-menu');
$header = $this->buildHeaderItemView();
$menu->addMenuItem($header);
// Blank State NUX
if (empty($this->threads)) {
$join_item = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_LINK)
->setHref('/conpherence/search/')
->setName(pht('Join a Room'));
$menu->addMenuItem($join_item);
$create_item = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_LINK)
->setHref('/conpherence/new/')
->setWorkflow(true)
->setName(pht('Create a Room'));
$menu->addMenuItem($create_item);
}
$rooms = $this->buildRoomItems($this->threads);
foreach ($rooms as $room) {
$menu->addMenuItem($room);
}
$menu = phutil_tag_div('phabricator-side-menu', $menu);
$menu = phutil_tag_div('phui-basic-nav', $menu);
return $menu;
}
private function renderThreadItem(
ConpherenceThread $thread) {
$user = $this->getUser();
$data = $thread->getDisplayData($user);
$dom_id = $thread->getPHID().'-nav-item';
return id(new PHUIListItemView())
->setName($data['title'])
->setHref('/'.$thread->getMonogram())
->setProfileImage($data['image'])
->setCount($data['unread_count'])
->setType(PHUIListItemView::TYPE_CUSTOM)
->setID($thread->getPHID().'-nav-item')
->addSigil('conpherence-menu-click')
->setMetadata(
array(
'title' => $data['title'],
'id' => $dom_id,
'threadID' => $thread->getID(),
'theme' => $data['theme'],
));
}
private function buildRoomItems(array $threads) {
$items = array();
$show_threads = $threads;
$all_threads = false;
if (count($threads) > self::SEE_ALL_LIMIT) {
$show_threads = array_slice($threads, 0, self::SEE_ALL_LIMIT);
$all_threads = true;
}
foreach ($show_threads as $thread) {
$items[] = $this->renderThreadItem($thread);
}
// Send them to application search here
if ($all_threads) {
$items[] = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_LINK)
->setHref('/conpherence/search/query/participant/')
->setIcon('fa-external-link')
->setName(pht('See All Joined'));
}
return $items;
}
private function buildHeaderItemView() {
$rooms = phutil_tag(
'a',
array(
'class' => 'room-list-href',
'href' => '/conpherence/search/',
),
pht('Rooms'));
$new_icon = id(new PHUIIconView())
->setIcon('fa-plus-square')
->addSigil('has-tooltip')
->setHref('/conpherence/edit/')
->setWorkflow(true)
->setMetaData(array(
'tip' => pht('New Room'),
));
$search_icon = id(new PHUIIconView())
->setIcon('fa-search')
->addSigil('has-tooltip')
->setHref('/conpherence/search/')
->setMetaData(array(
'tip' => pht('Search Rooms'),
));
$icons = phutil_tag(
'span',
array(
'class' => 'room-list-icons',
),
array(
$new_icon,
$search_icon,
));
$new_icon = id(new PHUIIconView())
->setIcon('fa-plus-square')
->setHref('/conpherence/new/')
->setWorkflow(true);
$custom = phutil_tag_div('grouped', array($rooms, $icons));
$item = id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_CUSTOM)
->setName($custom)
->addClass('conpherence-room-list-header');
return $item;
}
private function getNoRoomsMenuItem() {
$message = phutil_tag(
'div',
array(
'class' => 'no-conpherences-menu-item',
),
pht('No Rooms'));
return id(new PHUIListItemView())
->setType(PHUIListItemView::TYPE_CUSTOM)
->setName($message);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/view/ConpherenceParticipantView.php | src/applications/conpherence/view/ConpherenceParticipantView.php | <?php
final class ConpherenceParticipantView extends AphrontView {
private $conpherence;
private $updateURI;
public function setConpherence(ConpherenceThread $conpherence) {
$this->conpherence = $conpherence;
return $this;
}
public function setUpdateURI($uri) {
$this->updateURI = $uri;
return $this;
}
public function render() {
$conpherence = $this->conpherence;
$viewer = $this->getViewer();
$participants = $conpherence->getParticipants();
$count = new PhutilNumber(count($participants));
$handles = $conpherence->getHandles();
$handles = array_intersect_key($handles, $participants);
$head_handles = array_select_keys($handles, array($viewer->getPHID()));
$handle_list = mpull($handles, 'getName');
natcasesort($handle_list);
$handles = mpull($handles, null, 'getName');
$handles = array_select_keys($handles, $handle_list);
$head_handles = mpull($head_handles, null, 'getName');
$handles = $head_handles + $handles;
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
$body = array();
foreach ($handles as $handle) {
$user_phid = $handle->getPHID();
if (($user_phid == $viewer->getPHID()) || $can_edit) {
$icon = id(new PHUIIconView())
->setIcon('fa-times')
->addClass('lightbluetext');
$remove_html = javelin_tag(
'a',
array(
'class' => 'remove',
'sigil' => 'remove-person',
'meta' => array(
'remove_person' => $user_phid,
'action' => 'remove_person',
),
),
$icon);
} else {
$remove_html = null;
}
$body[] = phutil_tag(
'div',
array(
'class' => 'person-entry grouped',
),
array(
phutil_tag(
'a',
array(
'class' => 'pic',
'href' => $handle->getURI(),
),
phutil_tag(
'img',
array(
'src' => $handle->getImageURI(),
),
'')),
$handle->renderLink(),
$remove_html,
));
}
$new_icon = id(new PHUIIconView())
->setIcon('fa-plus-square')
->setHref($this->updateURI)
->setMetadata(array('widget' => null))
->addSigil('conpherence-widget-adder');
$header = id(new PHUIHeaderView())
->setHeader(pht('Participants (%d)', $count))
->addClass('widgets-header')
->addActionItem($new_icon);
$content = javelin_tag(
'div',
array(
'class' => 'widgets-body',
'id' => 'widgets-people',
'sigil' => 'widgets-people',
),
array(
$header,
$body,
));
return $content;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/view/ConpherenceMenuItemView.php | src/applications/conpherence/view/ConpherenceMenuItemView.php | <?php
final class ConpherenceMenuItemView extends AphrontTagView {
private $title;
private $subtitle;
private $imageURI;
private $href;
private $epoch;
private $unreadCount;
public function setUnreadCount($unread_count) {
$this->unreadCount = $unread_count;
return $this;
}
public function getUnreadCount() {
return $this->unreadCount;
}
public function setEpoch($epoch) {
$this->epoch = $epoch;
return $this;
}
public function getEpoch() {
return $this->epoch;
}
public function setHref($href) {
$this->href = $href;
return $this;
}
public function getHref() {
return $this->href;
}
public function setImageURI($image_uri) {
$this->imageURI = $image_uri;
return $this;
}
public function getImageURI() {
return $this->imageURI;
}
public function setSubtitle($subtitle) {
$this->subtitle = $subtitle;
return $this;
}
public function getSubtitle() {
return $this->subtitle;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function getTitle() {
return $this->title;
}
protected function getTagName() {
return 'a';
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'conpherence-menu-item-view';
$classes[] = 'phui-list-item-href';
return array(
'class' => implode(' ', $classes),
'href' => $this->href,
);
}
protected function getTagContent() {
$image = null;
if ($this->imageURI) {
$image = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-image',
'style' => 'background-image: url('.$this->imageURI.');',
),
'');
}
$title = null;
if ($this->title) {
$title = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-title',
),
$this->title);
}
$subtitle = null;
if ($this->subtitle) {
$subtitle = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-subtitle',
),
$this->subtitle);
}
$unread_count = null;
if ($this->unreadCount) {
$unread_count = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-unread-count',
),
(int)$this->unreadCount);
}
return array(
$image,
$title,
$subtitle,
$unread_count,
);
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/view/ConpherenceDurableColumnView.php | src/applications/conpherence/view/ConpherenceDurableColumnView.php | <?php
final class ConpherenceDurableColumnView extends AphrontTagView {
private $conpherences = array();
private $draft;
private $selectedConpherence;
private $transactions;
private $visible;
private $minimize;
private $initialLoad = false;
private $policyObjects;
private $quicksandConfig = array();
public function setConpherences(array $conpherences) {
assert_instances_of($conpherences, 'ConpherenceThread');
$this->conpherences = $conpherences;
return $this;
}
public function getConpherences() {
return $this->conpherences;
}
public function setDraft(PhabricatorDraft $draft) {
$this->draft = $draft;
return $this;
}
public function getDraft() {
return $this->draft;
}
public function setSelectedConpherence(
ConpherenceThread $conpherence = null) {
$this->selectedConpherence = $conpherence;
return $this;
}
public function getSelectedConpherence() {
return $this->selectedConpherence;
}
public function setTransactions(array $transactions) {
assert_instances_of($transactions, 'ConpherenceTransaction');
$this->transactions = $transactions;
return $this;
}
public function getTransactions() {
return $this->transactions;
}
public function setVisible($visible) {
$this->visible = $visible;
return $this;
}
public function getVisible() {
return $this->visible;
}
public function setMinimize($minimize) {
$this->minimize = $minimize;
return $this;
}
public function getMinimize() {
return $this->minimize;
}
public function setInitialLoad($bool) {
$this->initialLoad = $bool;
return $this;
}
public function getInitialLoad() {
return $this->initialLoad;
}
public function setPolicyObjects(array $objects) {
assert_instances_of($objects, 'PhabricatorPolicy');
$this->policyObjects = $objects;
return $this;
}
public function getPolicyObjects() {
return $this->policyObjects;
}
public function setQuicksandConfig(array $config) {
$this->quicksandConfig = $config;
return $this;
}
public function getQuicksandConfig() {
return $this->quicksandConfig;
}
protected function getTagAttributes() {
if ($this->getVisible()) {
$style = null;
} else {
$style = 'display: none;';
}
$classes = array('conpherence-durable-column');
if ($this->getInitialLoad()) {
$classes[] = 'loading';
}
return array(
'id' => 'conpherence-durable-column',
'class' => implode(' ', $classes),
'style' => $style,
'sigil' => 'conpherence-durable-column',
);
}
protected function getTagContent() {
$column_key = PhabricatorConpherenceColumnVisibleSetting::SETTINGKEY;
$minimize_key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY;
Javelin::initBehavior(
'durable-column',
array(
'visible' => $this->getVisible(),
'minimize' => $this->getMinimize(),
'visibleURI' => '/settings/adjust/?key='.$column_key,
'minimizeURI' => '/settings/adjust/?key='.$minimize_key,
'quicksandConfig' => $this->getQuicksandConfig(),
));
$policy_objects = ConpherenceThread::loadViewPolicyObjects(
$this->getUser(),
$this->getConpherences());
$this->setPolicyObjects($policy_objects);
$classes = array();
$classes[] = 'conpherence-durable-column-header';
$classes[] = 'grouped';
$header = phutil_tag(
'div',
array(
'class' => implode(' ', $classes),
'data-sigil' => 'conpherence-minimize-window',
),
$this->buildHeader());
$icon_bar = null;
if ($this->conpherences) {
$icon_bar = $this->buildIconBar();
}
$icon_bar = phutil_tag(
'div',
array(
'class' => 'conpherence-durable-column-icon-bar',
),
$icon_bar);
$transactions = $this->buildTransactions();
$content = javelin_tag(
'div',
array(
'class' => 'conpherence-durable-column-main',
'sigil' => 'conpherence-durable-column-main',
),
phutil_tag(
'div',
array(
'id' => 'conpherence-durable-column-content',
'class' => 'conpherence-durable-column-frame',
),
javelin_tag(
'div',
array(
'class' => 'conpherence-durable-column-transactions',
'sigil' => 'conpherence-durable-column-transactions',
),
$transactions)));
$input = $this->buildTextInput();
return array(
$header,
javelin_tag(
'div',
array(
'class' => 'conpherence-durable-column-body',
'sigil' => 'conpherence-durable-column-body',
),
array(
$icon_bar,
$content,
$input,
)),
);
}
private function buildIconBar() {
$icons = array();
$selected_conpherence = $this->getSelectedConpherence();
$conpherences = $this->getConpherences();
foreach ($conpherences as $conpherence) {
$classes = array('conpherence-durable-column-thread-icon');
if ($selected_conpherence->getID() == $conpherence->getID()) {
$classes[] = 'selected';
}
$data = $conpherence->getDisplayData($this->getUser());
$thread_title = phutil_tag(
'span',
array(),
array(
$data['title'],
));
$image = $data['image'];
Javelin::initBehavior('phabricator-tooltips');
$icons[] =
javelin_tag(
'a',
array(
'href' => '/conpherence/columnview/',
'class' => implode(' ', $classes),
'sigil' => 'conpherence-durable-column-thread-icon has-tooltip',
'meta' => array(
'threadID' => $conpherence->getID(),
'threadTitle' => hsprintf('%s', $thread_title),
'tip' => $data['title'],
'align' => 'W',
),
),
phutil_tag(
'span',
array(
'style' => 'background-image: url('.$image.')',
),
''));
}
return $icons;
}
private function buildHeader() {
$conpherence = $this->getSelectedConpherence();
$bubble_id = celerity_generate_unique_node_id();
$dropdown_id = celerity_generate_unique_node_id();
$settings_list = new PHUIListView();
$header_actions = $this->getHeaderActionsConfig($conpherence);
foreach ($header_actions as $action) {
$settings_list->addMenuItem(
id(new PHUIListItemView())
->setHref($action['href'])
->setName($action['name'])
->setIcon($action['icon'])
->setDisabled($action['disabled'])
->addSigil('conpherence-durable-column-header-action')
->setMetadata(array(
'action' => $action['key'],
)));
}
$settings_menu = phutil_tag(
'div',
array(
'id' => $dropdown_id,
'class' => 'phabricator-main-menu-dropdown phui-list-sidenav '.
'conpherence-settings-dropdown',
'sigil' => 'phabricator-notification-menu',
'style' => 'display: none',
),
$settings_list);
Javelin::initBehavior(
'aphlict-dropdown',
array(
'bubbleID' => $bubble_id,
'dropdownID' => $dropdown_id,
'local' => true,
'containerDivID' => 'conpherence-durable-column',
));
$bars = id(new PHUIListItemView())
->setName(pht('Room Actions'))
->setIcon('fa-gear')
->addClass('core-menu-item')
->addClass('conpherence-settings-icon')
->addSigil('conpherence-settings-menu')
->setID($bubble_id)
->setHref('#')
->setAural(pht('Room Actions'))
->setOrder(400);
$minimize = id(new PHUIListItemView())
->setName(pht('Minimize Window'))
->setIcon('fa-toggle-down')
->addClass('core-menu-item')
->addClass('conpherence-minimize-icon')
->addSigil('conpherence-minimize-window')
->setHref('#')
->setAural(pht('Minimize Window'))
->setOrder(300);
$settings_button = id(new PHUIListView())
->addMenuItem($bars)
->addMenuItem($minimize)
->addClass('phabricator-application-menu');
if ($conpherence) {
$data = $conpherence->getDisplayData($this->getUser());
$header = phutil_tag(
'span',
array(),
$data['title']);
} else {
$header = phutil_tag(
'span',
array(),
pht('Conpherence'));
}
$status = new PhabricatorNotificationStatusView();
return
phutil_tag(
'div',
array(
'class' => 'conpherence-durable-column-header-inner',
),
array(
$status,
javelin_tag(
'div',
array(
'sigil' => 'conpherence-durable-column-header-text',
'class' => 'conpherence-durable-column-header-text',
),
$header),
$settings_button,
$settings_menu,
));
}
private function getHeaderActionsConfig($conpherence) {
$actions = array();
if ($conpherence) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
$this->getUser(),
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
$actions[] = array(
'name' => pht('Add Participants'),
'disabled' => !$can_edit,
'href' => '/conpherence/update/'.$conpherence->getID().'/',
'icon' => 'fa-plus',
'key' => ConpherenceUpdateActions::ADD_PERSON,
);
$actions[] = array(
'name' => pht('Edit Room'),
'disabled' => !$can_edit,
'href' => '/conpherence/edit/'.$conpherence->getID().'/',
'icon' => 'fa-pencil',
'key' => 'go_edit',
);
$actions[] = array(
'name' => pht('View in Conpherence'),
'disabled' => false,
'href' => '/'.$conpherence->getMonogram(),
'icon' => 'fa-comments',
'key' => 'go_conpherence',
);
}
$actions[] = array(
'name' => pht('Hide Window'),
'disabled' => false,
'href' => '#',
'icon' => 'fa-times',
'key' => 'hide_column',
);
return $actions;
}
private function buildTransactions() {
$conpherence = $this->getSelectedConpherence();
if (!$conpherence) {
if (!$this->getVisible() || $this->getInitialLoad()) {
return pht('Loading...');
}
$view = array(
phutil_tag(
'div',
array(
'class' => 'column-no-rooms-text',
),
pht('You have not joined any rooms yet.')),
javelin_tag(
'a',
array(
'href' => '/conpherence/search/',
'class' => 'button button-grey',
),
pht('Find Rooms')),
);
return phutil_tag_div('column-no-rooms', $view);
}
$data = ConpherenceTransactionRenderer::renderTransactions(
$this->getUser(),
$conpherence);
$messages = ConpherenceTransactionRenderer::renderMessagePaneContent(
$data['transactions'],
$data['oldest_transaction_id'],
$data['newest_transaction_id']);
return $messages;
}
private function buildTextInput() {
$conpherence = $this->getSelectedConpherence();
if (!$conpherence) {
return null;
}
$draft = $this->getDraft();
$draft_value = null;
if ($draft) {
$draft_value = $draft->getDraft();
}
$textarea_id = celerity_generate_unique_node_id();
$textarea = javelin_tag(
'textarea',
array(
'id' => $textarea_id,
'name' => 'text',
'class' => 'conpherence-durable-column-textarea',
'sigil' => 'conpherence-durable-column-textarea',
'placeholder' => pht('Send a message...'),
),
$draft_value);
Javelin::initBehavior(
'aphront-drag-and-drop-textarea',
array(
'target' => $textarea_id,
'activatedClass' => 'aphront-textarea-drag-and-drop',
'uri' => '/file/dropupload/',
));
$id = $conpherence->getID();
return phabricator_form(
$this->getUser(),
array(
'method' => 'POST',
'action' => '/conpherence/update/'.$id.'/',
'sigil' => 'conpherence-message-form',
),
array(
$textarea,
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'action',
'value' => ConpherenceUpdateActions::MESSAGE,
)),
));
}
private function buildStatusText() {
return null;
}
private function buildSendButton() {
$conpherence = $this->getSelectedConpherence();
if (!$conpherence) {
return null;
}
return javelin_tag(
'button',
array(
'class' => 'grey',
'sigil' => 'conpherence-send-message',
),
pht('Send'));
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/view/ConpherenceLayoutView.php | src/applications/conpherence/view/ConpherenceLayoutView.php | <?php
final class ConpherenceLayoutView extends AphrontTagView {
private $thread;
private $baseURI;
private $threadView;
private $role;
private $header;
private $search;
private $messages;
private $replyForm;
private $theme = ConpherenceRoomSettings::COLOR_LIGHT;
private $latestTransactionID;
public function setMessages($messages) {
$this->messages = $messages;
return $this;
}
public function setReplyForm($reply_form) {
$this->replyForm = $reply_form;
return $this;
}
public function setHeader($header) {
$this->header = $header;
return $this;
}
public function setSearch($search) {
$this->search = $search;
return $this;
}
public function setRole($role) {
$this->role = $role;
return $this;
}
public function getThreadView() {
return $this->threadView;
}
public function setBaseURI($base_uri) {
$this->baseURI = $base_uri;
return $this;
}
public function setThread(ConpherenceThread $thread) {
$this->thread = $thread;
return $this;
}
public function setThreadView(ConpherenceThreadListView $thead_view) {
$this->threadView = $thead_view;
return $this;
}
public function setTheme($theme) {
$this->theme = $theme;
return $this;
}
public function setLatestTransactionID($id) {
$this->latestTransactionID = $id;
return $this;
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'conpherence-layout';
$classes[] = 'hide-widgets';
$classes[] = 'conpherence-role-'.$this->role;
$classes[] = ConpherenceRoomSettings::getThemeClass($this->theme);
return array(
'id' => 'conpherence-main-layout',
'sigil' => 'conpherence-layout',
'class' => implode(' ', $classes),
);
}
protected function getTagContent() {
require_celerity_resource('conpherence-menu-css');
require_celerity_resource('conpherence-message-pane-css');
require_celerity_resource('conpherence-participant-pane-css');
$selected_id = null;
$selected_thread_id = null;
$selected_thread_phid = null;
$can_edit_selected = null;
$nux = null;
if ($this->thread) {
$selected_id = $this->thread->getPHID().'-nav-item';
$selected_thread_id = $this->thread->getID();
$selected_thread_phid = $this->thread->getPHID();
$can_edit_selected = PhabricatorPolicyFilter::hasCapability(
$this->getUser(),
$this->thread,
PhabricatorPolicyCapability::CAN_EDIT);
} else {
$nux = $this->buildNUXView();
}
$this->initBehavior('conpherence-menu',
array(
'baseURI' => $this->baseURI,
'layoutID' => 'conpherence-main-layout',
'selectedID' => $selected_id,
'selectedThreadID' => $selected_thread_id,
'selectedThreadPHID' => $selected_thread_phid,
'canEditSelectedThread' => $can_edit_selected,
'latestTransactionID' => $this->latestTransactionID,
'role' => $this->role,
'theme' => ConpherenceRoomSettings::getThemeClass($this->theme),
'hasThreadList' => (bool)$this->threadView,
'hasThread' => (bool)$this->messages,
'hasWidgets' => false,
));
$this->initBehavior('conpherence-participant-pane');
return
array(
javelin_tag(
'div',
array(
'id' => 'conpherence-menu-pane',
'class' => 'conpherence-menu-pane phabricator-side-menu',
'sigil' => 'conpherence-menu-pane',
),
$this->threadView),
javelin_tag(
'div',
array(
'class' => 'conpherence-content-pane',
),
array(
phutil_tag(
'div',
array(
'class' => 'conpherence-loading-mask',
),
''),
javelin_tag(
'div',
array(
'class' => 'conpherence-header-pane',
'id' => 'conpherence-header-pane',
'sigil' => 'conpherence-header-pane',
),
nonempty($this->header, '')),
javelin_tag(
'div',
array(
'class' => 'conpherence-no-threads',
'sigil' => 'conpherence-no-threads',
'style' => 'display: none;',
),
$nux),
javelin_tag(
'div',
array(
'class' => 'conpherence-participant-pane',
'id' => 'conpherence-participant-pane',
'sigil' => 'conpherence-participant-pane',
),
array(
phutil_tag(
'div',
array(
'class' => 'widgets-loading-mask',
),
''),
javelin_tag(
'div',
array(
'sigil' => 'conpherence-widgets-holder',
),
''),
)),
javelin_tag(
'div',
array(
'class' => 'conpherence-message-pane',
'id' => 'conpherence-message-pane',
'sigil' => 'conpherence-message-pane',
),
array(
javelin_tag(
'div',
array(
'class' => 'conpherence-messages',
'id' => 'conpherence-messages',
'sigil' => 'conpherence-messages',
),
nonempty($this->messages, '')),
javelin_tag(
'div',
array(
'class' => 'conpherence-search-main',
'id' => 'conpherence-search-main',
'sigil' => 'conpherence-search-main',
),
nonempty($this->search, '')),
phutil_tag(
'div',
array(
'class' => 'messages-loading-mask',
),
''),
javelin_tag(
'div',
array(
'id' => 'conpherence-form',
'sigil' => 'conpherence-form',
),
nonempty($this->replyForm, '')),
)),
)),
);
}
private function buildNUXView() {
$viewer = $this->getViewer();
$engine = id(new ConpherenceThreadSearchEngine())
->setViewer($viewer);
$saved = $engine->buildSavedQueryFromBuiltin('all');
$query = $engine->buildQueryFromSavedQuery($saved);
$pager = $engine->newPagerForSavedQuery($saved)
->setPageSize(10);
$results = $engine->executeQuery($query, $pager);
$view = $engine->renderResults($results, $saved);
$create_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('New Room'))
->setHref('/conpherence/new/')
->setWorkflow(true)
->setColor(PHUIButtonView::GREEN);
if ($results) {
$create_button->setIcon('fa-comments');
$header = id(new PHUIHeaderView())
->setHeader(pht('Joinable Rooms'))
->addActionLink($create_button);
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->setObjectList($view->getContent());
return $box;
} else {
$view = id(new PHUIBigInfoView())
->setIcon('fa-comments')
->setTitle(pht('Welcome to Conpherence'))
->setDescription(
pht('Conpherence lets you create public or private rooms to '.
'communicate with others.'))
->addAction($create_button);
return $view;
}
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
phacility/phabricator | https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php | src/applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php | <?php
final class PhabricatorConpherenceThreadPHIDType extends PhabricatorPHIDType {
const TYPECONST = 'CONP';
public function getTypeName() {
return pht('Conpherence Room');
}
public function newObject() {
return new ConpherenceThread();
}
public function getPHIDTypeApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new ConpherenceThreadQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$thread = $objects[$phid];
$title = $thread->getStaticTitle();
$monogram = $thread->getMonogram();
$handle->setName($title);
$handle->setFullName(pht('%s: %s', $monogram, $title));
$handle->setURI('/'.$monogram);
}
}
public function canLoadNamedObject($name) {
return preg_match('/^Z\d*[1-9]\d*$/i', $name);
}
public function loadNamedObjects(
PhabricatorObjectQuery $query,
array $names) {
$id_map = array();
foreach ($names as $name) {
$id = (int)substr($name, 1);
$id_map[$id][] = $name;
}
$objects = id(new ConpherenceThreadQuery())
->setViewer($query->getViewer())
->withIDs(array_keys($id_map))
->execute();
$objects = mpull($objects, null, 'getID');
$results = array();
foreach ($objects as $id => $object) {
foreach (idx($id_map, $id, array()) as $name) {
$results[$name] = $object;
}
}
return $results;
}
}
| php | Apache-2.0 | 5720a38cfe95b00ca4be5016dd0d2f3195f4fa04 | 2026-01-04T15:03:23.651835Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.