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/almanac/servicetype/AlmanacClusterRepositoryServiceType.php
src/applications/almanac/servicetype/AlmanacClusterRepositoryServiceType.php
<?php final class AlmanacClusterRepositoryServiceType extends AlmanacClusterServiceType { const SERVICETYPE = 'cluster.repository'; public function getServiceTypeShortName() { return pht('Cluster Repository'); } public function getServiceTypeName() { return pht('Cluster: Repository'); } public function getServiceTypeDescription() { return pht( 'Defines a repository service for use in a cluster.'); } public function getFieldSpecifications() { return array( 'closed' => id(new PhabricatorBoolEditField()) ->setOptions( pht('Allow New Repositories'), pht('Prevent New Repositories')) ->setValue(false), ); } public function getBindingFieldSpecifications(AlmanacBinding $binding) { $protocols = array( array( 'value' => 'http', 'port' => 80, ), array( 'value' => 'https', 'port' => 443, ), array( 'value' => 'ssh', 'port' => 22, ), ); $default_value = 'http'; if ($binding->hasInterface()) { $interface = $binding->getInterface(); $port = $interface->getPort(); $default_ports = ipull($protocols, 'value', 'port'); $default_value = idx($default_ports, $port, $default_value); } return array( 'protocol' => id(new PhabricatorSelectEditField()) ->setOptions(ipull($protocols, 'value', 'value')) ->setValue($default_value), 'writable' => id(new PhabricatorBoolEditField()) ->setOptions( pht('Prevent Writes'), pht('Allow Writes')) ->setValue(true), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/servicetype/__tests__/AlmanacServiceTypeTestCase.php
src/applications/almanac/servicetype/__tests__/AlmanacServiceTypeTestCase.php
<?php final class AlmanacServiceTypeTestCase extends PhabricatorTestCase { public function testGetAllServiceTypes() { AlmanacServiceType::getAllServiceTypes(); $this->assertTrue(true); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/application/PhabricatorAlmanacApplication.php
src/applications/almanac/application/PhabricatorAlmanacApplication.php
<?php final class PhabricatorAlmanacApplication extends PhabricatorApplication { public function getBaseURI() { return '/almanac/'; } public function getName() { return pht('Almanac'); } public function getShortDescription() { return pht('Service Directory'); } public function getIcon() { return 'fa-server'; } public function getTitleGlyph() { return "\xE2\x98\x82"; } public function getApplicationGroup() { return self::GROUP_UTILITIES; } public function getHelpDocumentationArticles(PhabricatorUser $viewer) { return array( array( 'name' => pht('Almanac User Guide'), 'href' => PhabricatorEnv::getDoclink('Almanac User Guide'), ), ); } public function getRoutes() { return array( '/almanac/' => array( '' => 'AlmanacConsoleController', '(?P<objectType>service)/' => array( $this->getQueryRoutePattern() => 'AlmanacServiceListController', $this->getEditRoutePattern('edit/') => 'AlmanacServiceEditController', 'view/(?P<name>[^/]+)/' => 'AlmanacServiceViewController', ), '(?P<objectType>device)/' => array( $this->getQueryRoutePattern() => 'AlmanacDeviceListController', $this->getEditRoutePattern('edit/') => 'AlmanacDeviceEditController', 'view/(?P<name>[^/]+)/' => 'AlmanacDeviceViewController', ), 'interface/' => array( 'edit/(?:(?P<id>\d+)/)?' => 'AlmanacInterfaceEditController', 'delete/(?:(?P<id>\d+)/)?' => 'AlmanacInterfaceDeleteController', ), 'binding/' => array( 'edit/(?:(?P<id>\d+)/)?' => 'AlmanacBindingEditController', 'disable/(?:(?P<id>\d+)/)?' => 'AlmanacBindingDisableController', '(?P<id>\d+)/' => 'AlmanacBindingViewController', ), 'network/' => array( $this->getQueryRoutePattern() => 'AlmanacNetworkListController', 'edit/(?:(?P<id>\d+)/)?' => 'AlmanacNetworkEditController', '(?P<id>\d+)/' => 'AlmanacNetworkViewController', ), 'namespace/' => array( $this->getQueryRoutePattern() => 'AlmanacNamespaceListController', $this->getEditRoutePattern('edit/') => 'AlmanacNamespaceEditController', '(?P<id>\d+)/' => 'AlmanacNamespaceViewController', ), 'property/' => array( 'delete/' => 'AlmanacPropertyDeleteController', 'update/' => 'AlmanacPropertyEditController', ), ), ); } protected function getCustomCapabilities() { $cluster_caption = pht( 'This permission is very dangerous. %s', phutil_tag( 'a', array( 'href' => PhabricatorEnv::getDoclink('Clustering Introduction'), 'target' => '_blank', ), pht('Learn More'))); return array( AlmanacCreateServicesCapability::CAPABILITY => array( 'default' => PhabricatorPolicies::POLICY_ADMIN, ), AlmanacCreateDevicesCapability::CAPABILITY => array( 'default' => PhabricatorPolicies::POLICY_ADMIN, ), AlmanacCreateNetworksCapability::CAPABILITY => array( 'default' => PhabricatorPolicies::POLICY_ADMIN, ), AlmanacCreateNamespacesCapability::CAPABILITY => array( 'default' => PhabricatorPolicies::POLICY_ADMIN, ), AlmanacManageClusterServicesCapability::CAPABILITY => array( 'default' => PhabricatorPolicies::POLICY_NOONE, 'caption' => $cluster_caption, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/property/AlmanacPropertyInterface.php
src/applications/almanac/property/AlmanacPropertyInterface.php
<?php interface AlmanacPropertyInterface { public function attachAlmanacProperties(array $properties); public function getAlmanacProperties(); public function hasAlmanacProperty($key); public function getAlmanacProperty($key); public function getAlmanacPropertyValue($key, $default = null); public function getAlmanacPropertyFieldSpecifications(); public function newAlmanacPropertyEditEngine(); public function getAlmanacPropertySetTransactionType(); public function getAlmanacPropertyDeleteTransactionType(); }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/view/AlmanacBindingTableView.php
src/applications/almanac/view/AlmanacBindingTableView.php
<?php final class AlmanacBindingTableView extends AphrontView { private $bindings; private $noDataString; private $hideServiceColumn; public function setNoDataString($no_data_string) { $this->noDataString = $no_data_string; return $this; } public function getNoDataString() { return $this->noDataString; } public function setBindings(array $bindings) { $this->bindings = $bindings; return $this; } public function getBindings() { return $this->bindings; } public function setHideServiceColumn($hide_service_column) { $this->hideServiceColumn = $hide_service_column; return $this; } public function getHideServiceColumn() { return $this->hideServiceColumn; } public function render() { $bindings = $this->getBindings(); $viewer = $this->getUser(); $phids = array(); foreach ($bindings as $binding) { $phids[] = $binding->getServicePHID(); $phids[] = $binding->getDevicePHID(); $phids[] = $binding->getInterface()->getNetworkPHID(); } $handles = $viewer->loadHandles($phids); $icon_disabled = id(new PHUIIconView()) ->setIcon('fa-ban') ->addSigil('has-tooltip') ->setMetadata( array( 'tip' => pht('Disabled'), )); $icon_active = id(new PHUIIconView()) ->setIcon('fa-check') ->setColor('green') ->addSigil('has-tooltip') ->setMetadata( array( 'tip' => pht('Active'), )); $icon_device_disabled = id(new PHUIIconView()) ->setIcon('fa-times') ->setColor('grey') ->addSigil('has-tooltip') ->setMetadata( array( 'tip' => pht('Device Disabled'), )); $rows = array(); foreach ($bindings as $binding) { $addr = $binding->getInterface()->getAddress(); $port = $binding->getInterface()->getPort(); $device = $binding->getDevice(); if ($device->isDisabled()) { $binding_icon = $icon_device_disabled; } else if ($binding->getIsDisabled()) { $binding_icon = $icon_disabled; } else { $binding_icon = $icon_active; } $rows[] = array( $binding->getID(), $binding_icon, $handles->renderHandle($binding->getServicePHID()), $handles->renderHandle($binding->getDevicePHID()), $handles->renderHandle($binding->getInterface()->getNetworkPHID()), $binding->getInterface()->renderDisplayAddress(), phutil_tag( 'a', array( 'class' => 'small button button-grey', 'href' => '/almanac/binding/'.$binding->getID().'/', ), pht('Details')), ); } $table = id(new AphrontTableView($rows)) ->setNoDataString($this->getNoDataString()) ->setHeaders( array( pht('ID'), null, pht('Service'), pht('Device'), pht('Network'), pht('Interface'), null, )) ->setColumnClasses( array( '', 'icon', '', '', '', 'wide', 'action', )) ->setColumnVisibility( array( true, true, !$this->getHideServiceColumn(), )); return $table; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/view/AlmanacInterfaceTableView.php
src/applications/almanac/view/AlmanacInterfaceTableView.php
<?php final class AlmanacInterfaceTableView extends AphrontView { private $interfaces; private $canEdit; public function setInterfaces(array $interfaces) { $this->interfaces = $interfaces; return $this; } public function getInterfaces() { return $this->interfaces; } public function setCanEdit($can_edit) { $this->canEdit = $can_edit; return $this; } public function getCanEdit() { return $this->canEdit; } public function render() { $interfaces = $this->getInterfaces(); $viewer = $this->getUser(); $can_edit = $this->getCanEdit(); if ($can_edit) { $button_class = 'small button button-grey'; } else { $button_class = 'small button button-grey disabled'; } $handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID')); $rows = array(); foreach ($interfaces as $interface) { $rows[] = array( $interface->getID(), $handles->renderHandle($interface->getNetworkPHID()), $interface->getAddress(), $interface->getPort(), javelin_tag( 'a', array( 'class' => $button_class, 'href' => '/almanac/interface/edit/'.$interface->getID().'/', 'sigil' => ($can_edit ? null : 'workflow'), ), pht('Edit')), javelin_tag( 'a', array( 'class' => $button_class, 'href' => '/almanac/interface/delete/'.$interface->getID().'/', 'sigil' => 'workflow', ), pht('Delete')), ); } $table = id(new AphrontTableView($rows)) ->setHeaders( array( pht('ID'), pht('Network'), pht('Address'), pht('Port'), null, null, )) ->setColumnClasses( array( '', 'wide', '', '', 'action', 'action', )); return $table; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/phid/AlmanacNetworkPHIDType.php
src/applications/almanac/phid/AlmanacNetworkPHIDType.php
<?php final class AlmanacNetworkPHIDType extends PhabricatorPHIDType { const TYPECONST = 'ANET'; public function getTypeName() { return pht('Almanac Network'); } public function newObject() { return new AlmanacNetwork(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorAlmanacApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new AlmanacNetworkQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $network = $objects[$phid]; $id = $network->getID(); $name = $network->getName(); $handle->setObjectName(pht('Network %d', $id)); $handle->setName($name); $handle->setURI($network->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/phid/AlmanacServicePHIDType.php
src/applications/almanac/phid/AlmanacServicePHIDType.php
<?php final class AlmanacServicePHIDType extends PhabricatorPHIDType { const TYPECONST = 'ASRV'; public function getTypeName() { return pht('Almanac Service'); } public function newObject() { return new AlmanacService(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorAlmanacApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new AlmanacServiceQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $service = $objects[$phid]; $id = $service->getID(); $name = $service->getName(); $handle->setObjectName(pht('Service %d', $id)); $handle->setName($name); $handle->setURI($service->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/phid/AlmanacDevicePHIDType.php
src/applications/almanac/phid/AlmanacDevicePHIDType.php
<?php final class AlmanacDevicePHIDType extends PhabricatorPHIDType { const TYPECONST = 'ADEV'; public function getTypeName() { return pht('Almanac Device'); } public function newObject() { return new AlmanacDevice(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorAlmanacApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new AlmanacDeviceQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $device = $objects[$phid]; $id = $device->getID(); $name = $device->getName(); $handle->setObjectName(pht('Device %d', $id)); $handle->setName($name); $handle->setURI($device->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/phid/AlmanacBindingPHIDType.php
src/applications/almanac/phid/AlmanacBindingPHIDType.php
<?php final class AlmanacBindingPHIDType extends PhabricatorPHIDType { const TYPECONST = 'ABND'; public function getTypeName() { return pht('Almanac Binding'); } public function newObject() { return new AlmanacBinding(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorAlmanacApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new AlmanacBindingQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $binding = $objects[$phid]; $id = $binding->getID(); $handle->setObjectName(pht('Binding %d', $id)); $handle->setName(pht('Binding %d', $id)); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/phid/AlmanacInterfacePHIDType.php
src/applications/almanac/phid/AlmanacInterfacePHIDType.php
<?php final class AlmanacInterfacePHIDType extends PhabricatorPHIDType { const TYPECONST = 'AINT'; public function getTypeName() { return pht('Almanac Interface'); } public function newObject() { return new AlmanacInterface(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorAlmanacApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new AlmanacInterfaceQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $interface = $objects[$phid]; $id = $interface->getID(); $device = $interface->getDevice(); $device_name = $device->getName(); $address = $interface->getAddress(); $port = $interface->getPort(); $network = $interface->getNetwork()->getName(); $name = pht( '%s:%s (%s on %s)', $device_name, $port, $address, $network); $handle->setObjectName(pht('Interface %d', $id)); $handle->setName($name); if ($device->isDisabled()) { $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); } } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/phid/AlmanacNamespacePHIDType.php
src/applications/almanac/phid/AlmanacNamespacePHIDType.php
<?php final class AlmanacNamespacePHIDType extends PhabricatorPHIDType { const TYPECONST = 'ANAM'; public function getTypeName() { return pht('Almanac Namespace'); } public function newObject() { return new AlmanacNamespace(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorAlmanacApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new AlmanacNamespaceQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $namespace = $objects[$phid]; $id = $namespace->getID(); $name = $namespace->getName(); $handle->setObjectName(pht('Namespace %d', $id)); $handle->setName($name); $handle->setURI($namespace->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacBindingSearchConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacBindingSearchConduitAPIMethod.php
<?php final class AlmanacBindingSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'almanac.binding.search'; } public function newSearchEngine() { return new AlmanacBindingSearchEngine(); } public function getMethodSummary() { return pht('Read information about Almanac bindings.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacBindingEditConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacBindingEditConduitAPIMethod.php
<?php final class AlmanacBindingEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'almanac.binding.edit'; } public function newEditEngine() { return new AlmanacBindingEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new binding or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacNamespaceEditConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacNamespaceEditConduitAPIMethod.php
<?php final class AlmanacNamespaceEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'almanac.namespace.edit'; } public function newEditEngine() { return new AlmanacNamespaceEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new namespace or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacInterfaceEditConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacInterfaceEditConduitAPIMethod.php
<?php final class AlmanacInterfaceEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'almanac.interface.edit'; } public function newEditEngine() { return new AlmanacInterfaceEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new interface or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacNetworkEditConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacNetworkEditConduitAPIMethod.php
<?php final class AlmanacNetworkEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'almanac.network.edit'; } public function newEditEngine() { return new AlmanacNetworkEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new network or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacInterfaceSearchConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacInterfaceSearchConduitAPIMethod.php
<?php final class AlmanacInterfaceSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'almanac.interface.search'; } public function newSearchEngine() { return new AlmanacInterfaceSearchEngine(); } public function getMethodSummary() { return pht('Read information about Almanac interfaces.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacDeviceSearchConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacDeviceSearchConduitAPIMethod.php
<?php final class AlmanacDeviceSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'almanac.device.search'; } public function newSearchEngine() { return new AlmanacDeviceSearchEngine(); } public function getMethodSummary() { return pht('Read information about Almanac devices.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacDeviceEditConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacDeviceEditConduitAPIMethod.php
<?php final class AlmanacDeviceEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'almanac.device.edit'; } public function newEditEngine() { return new AlmanacDeviceEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new device or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacServiceSearchConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacServiceSearchConduitAPIMethod.php
<?php final class AlmanacServiceSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'almanac.service.search'; } public function newSearchEngine() { return new AlmanacServiceSearchEngine(); } public function getMethodSummary() { return pht('Read information about Almanac services.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacNetworkSearchConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacNetworkSearchConduitAPIMethod.php
<?php final class AlmanacNetworkSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'almanac.network.search'; } public function newSearchEngine() { return new AlmanacNetworkSearchEngine(); } public function getMethodSummary() { return pht('Read information about Almanac networks.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacNamespaceSearchConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacNamespaceSearchConduitAPIMethod.php
<?php final class AlmanacNamespaceSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'almanac.namespace.search'; } public function newSearchEngine() { return new AlmanacNamespaceSearchEngine(); } public function getMethodSummary() { return pht('Read information about Almanac namespaces.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/conduit/AlmanacServiceEditConduitAPIMethod.php
src/applications/almanac/conduit/AlmanacServiceEditConduitAPIMethod.php
<?php final class AlmanacServiceEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'almanac.service.edit'; } public function newEditEngine() { return new AlmanacServiceEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new service or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/typeahead/AlmanacInterfaceDatasource.php
src/applications/almanac/typeahead/AlmanacInterfaceDatasource.php
<?php final class AlmanacInterfaceDatasource extends PhabricatorTypeaheadDatasource { public function getBrowseTitle() { return pht('Browse Interfaces'); } public function getPlaceholderText() { return pht('Type an interface name...'); } public function getDatasourceApplicationClass() { return 'PhabricatorAlmanacApplication'; } public function loadResults() { $viewer = $this->getViewer(); $raw_query = $this->getRawQuery(); $devices = id(new AlmanacDeviceQuery()) ->setViewer($viewer) ->withNamePrefix($raw_query) ->execute(); if ($devices) { $interface_query = id(new AlmanacInterfaceQuery()) ->setViewer($viewer) ->withDevicePHIDs(mpull($devices, 'getPHID')) ->setOrder('name'); $interfaces = $this->executeQuery($interface_query); } else { $interfaces = array(); } if ($interfaces) { $handles = id(new PhabricatorHandleQuery()) ->setViewer($viewer) ->withPHIDs(mpull($interfaces, 'getPHID')) ->execute(); } else { $handles = array(); } $results = array(); foreach ($handles as $handle) { if ($handle->isClosed()) { $closed = pht('Disabled'); } else { $closed = null; } $results[] = id(new PhabricatorTypeaheadResult()) ->setName($handle->getName()) ->setPHID($handle->getPHID()) ->setClosed($closed); } 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/almanac/typeahead/AlmanacServiceDatasource.php
src/applications/almanac/typeahead/AlmanacServiceDatasource.php
<?php final class AlmanacServiceDatasource extends PhabricatorTypeaheadDatasource { public function getBrowseTitle() { return pht('Browse Services'); } public function getPlaceholderText() { return pht('Type a service name...'); } public function getDatasourceApplicationClass() { return 'PhabricatorAlmanacApplication'; } public function loadResults() { $viewer = $this->getViewer(); $raw_query = $this->getRawQuery(); $services = id(new AlmanacServiceQuery()) ->withNamePrefix($raw_query) ->setOrder('name'); // TODO: When service classes are restricted, it might be nice to customize // the title and placeholder text to show which service types can be // selected, or show all services but mark the invalid ones disabled and // prevent their selection. $service_types = $this->getParameter('serviceTypes'); if ($service_types) { $services->withServiceTypes($service_types); } $services = $this->executeQuery($services); if ($services) { $handles = id(new PhabricatorHandleQuery()) ->setViewer($viewer) ->withPHIDs(mpull($services, 'getPHID')) ->execute(); } else { $handles = array(); } $results = array(); foreach ($handles as $handle) { $results[] = id(new PhabricatorTypeaheadResult()) ->setName($handle->getName()) ->setPHID($handle->getPHID()); } 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/almanac/typeahead/AlmanacServiceTypeDatasource.php
src/applications/almanac/typeahead/AlmanacServiceTypeDatasource.php
<?php final class AlmanacServiceTypeDatasource extends PhabricatorTypeaheadDatasource { public function getBrowseTitle() { return pht('Browse Service Types'); } public function getPlaceholderText() { return pht('Type a service type name...'); } public function getDatasourceApplicationClass() { return 'PhabricatorAlmanacApplication'; } public function loadResults() { $results = $this->buildResults(); return $this->filterResultsAgainstTokens($results); } protected function renderSpecialTokens(array $values) { return $this->renderTokensFromResults($this->buildResults(), $values); } private function buildResults() { $results = array(); $types = AlmanacServiceType::getAllServiceTypes(); $results = array(); foreach ($types as $key => $type) { $results[$key] = id(new PhabricatorTypeaheadResult()) ->setName($type->getServiceTypeName()) ->setIcon($type->getServiceTypeIcon()) ->setPHID($key); } 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/almanac/capability/AlmanacManageClusterServicesCapability.php
src/applications/almanac/capability/AlmanacManageClusterServicesCapability.php
<?php final class AlmanacManageClusterServicesCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'almanac.cluster'; public function getCapabilityName() { return pht('Can Manage Cluster Services'); } public function describeCapabilityRejection() { return pht( 'You do not have permission to manage Almanac cluster services.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/capability/AlmanacCreateNamespacesCapability.php
src/applications/almanac/capability/AlmanacCreateNamespacesCapability.php
<?php final class AlmanacCreateNamespacesCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'almanac.namespaces'; public function getCapabilityName() { return pht('Can Create Namespaces'); } public function describeCapabilityRejection() { return pht('You do not have permission to create Almanac namespaces.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/capability/AlmanacCreateNetworksCapability.php
src/applications/almanac/capability/AlmanacCreateNetworksCapability.php
<?php final class AlmanacCreateNetworksCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'almanac.networks'; public function getCapabilityName() { return pht('Can Create Networks'); } public function describeCapabilityRejection() { return pht('You do not have permission to create Almanac networks.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/capability/AlmanacCreateDevicesCapability.php
src/applications/almanac/capability/AlmanacCreateDevicesCapability.php
<?php final class AlmanacCreateDevicesCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'almanac.devices'; public function getCapabilityName() { return pht('Can Create Devices'); } public function describeCapabilityRejection() { return pht('You do not have permission to create Almanac devices.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/capability/AlmanacCreateServicesCapability.php
src/applications/almanac/capability/AlmanacCreateServicesCapability.php
<?php final class AlmanacCreateServicesCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'almanac.services'; public function getCapabilityName() { return pht('Can Create Services'); } public function describeCapabilityRejection() { return pht('You do not have permission to create Almanac services.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/constants/AlmanacDeviceStatus.php
src/applications/almanac/constants/AlmanacDeviceStatus.php
<?php final class AlmanacDeviceStatus extends Phobject { const ACTIVE = 'active'; const DISABLED = 'disabled'; private $value; public static function newStatusFromValue($value) { $status = new self(); $status->value = $value; return $status; } public function getValue() { return $this->value; } public function getName() { $name = $this->getDeviceStatusProperty('name'); if ($name === null) { $name = pht('Unknown Almanac Device Status ("%s")', $this->getValue()); } return $name; } public function getIconIcon() { return $this->getDeviceStatusProperty('icon.icon'); } public function getIconColor() { return $this->getDeviceStatusProperty('icon.color'); } public function isDisabled() { return ($this->getValue() === self::DISABLED); } public function hasStatusTag() { return ($this->getStatusTagIcon() !== null); } public function getStatusTagIcon() { return $this->getDeviceStatusProperty('status-tag.icon'); } public function getStatusTagColor() { return $this->getDeviceStatusProperty('status-tag.color'); } public static function getStatusMap() { $result = array(); foreach (self::newDeviceStatusMap() as $status_value => $ignored) { $result[$status_value] = self::newStatusFromValue($status_value); } return $result; } public static function getActiveStatusList() { $results = array(); foreach (self::newDeviceStatusMap() as $status_value => $status) { if (empty($status['disabled'])) { $results[] = $status_value; } } return $results; } public static function getDisabledStatusList() { $results = array(); foreach (self::newDeviceStatusMap() as $status_value => $status) { if (!empty($status['disabled'])) { $results[] = $status_value; } } return $results; } private function getDeviceStatusProperty($key, $default = null) { $map = self::newDeviceStatusMap(); $properties = idx($map, $this->getValue(), array()); return idx($properties, $key, $default); } private static function newDeviceStatusMap() { return array( self::ACTIVE => array( 'name' => pht('Active'), 'icon.icon' => 'fa-server', 'icon.color' => 'green', ), self::DISABLED => array( 'name' => pht('Disabled'), 'icon.icon' => 'fa-times', 'icon.color' => 'grey', 'status-tag.icon' => 'fa-times', 'status-tag.color' => 'indigo', 'disabled' => true, ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleInviteSendController.php
src/applications/people/controller/PhabricatorPeopleInviteSendController.php
<?php final class PhabricatorPeopleInviteSendController extends PhabricatorPeopleInviteController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $this->requireApplicationCapability( PeopleCreateUsersCapability::CAPABILITY); $is_confirm = false; $errors = array(); $confirm_errors = array(); $e_emails = true; $message = $request->getStr('message'); $emails = $request->getStr('emails'); $severity = PHUIInfoView::SEVERITY_ERROR; if ($request->isFormPost()) { // NOTE: We aren't using spaces as a delimiter here because email // addresses with names often include spaces. $email_list = preg_split('/[,;\n]+/', $emails); foreach ($email_list as $key => $email) { if (!strlen(trim($email))) { unset($email_list[$key]); } } if ($email_list) { $e_emails = null; } else { $e_emails = pht('Required'); $errors[] = pht( 'To send invites, you must enter at least one email address.'); } if (!$errors) { $is_confirm = true; $actions = PhabricatorAuthInviteAction::newActionListFromAddresses( $viewer, $email_list); $any_valid = false; $all_valid = true; foreach ($actions as $action) { if ($action->willSend()) { $any_valid = true; } else { $all_valid = false; } } if (!$any_valid) { $confirm_errors[] = pht( 'None of the provided addresses are valid invite recipients. '. 'Review the table below for details. Revise the address list '. 'to continue.'); } else if ($all_valid) { $confirm_errors[] = pht( 'All of the addresses appear to be valid invite recipients. '. 'Confirm the actions below to continue.'); $severity = PHUIInfoView::SEVERITY_NOTICE; } else { $confirm_errors[] = pht( 'Some of the addresses you entered do not appear to be '. 'valid recipients. Review the table below. You can revise '. 'the address list, or ignore these errors and continue.'); $severity = PHUIInfoView::SEVERITY_WARNING; } if ($any_valid && $request->getBool('confirm')) { // TODO: The copywriting on this mail could probably be more // engaging and we could have a fancy HTML version. $template = array(); $template[] = pht( '%s has invited you to join %s.', $viewer->getFullName(), PlatformSymbols::getPlatformServerName()); if (strlen(trim($message))) { $template[] = $message; } $template[] = pht( 'To register an account and get started, follow this link:'); // This isn't a variable; it will be replaced later on in the // daemons once they generate the URI. $template[] = '{$INVITE_URI}'; $template[] = pht( 'If you already have an account, you can follow the link to '. 'quickly verify this email address.'); $template = implode("\n\n", $template); foreach ($actions as $action) { if ($action->willSend()) { $action->sendInvite($viewer, $template); } } // TODO: This is a bit anticlimactic. We don't really have anything // to show the user because the action is happening in the background // and the invites won't exist yet. After T5166 we can show a // better progress bar. return id(new AphrontRedirectResponse()) ->setURI($this->getApplicationURI()); } } } if ($is_confirm) { $title = pht('Confirm Invites'); } else { $title = pht('Invite Users'); } $crumbs = $this->buildApplicationCrumbs(); if ($is_confirm) { $crumbs->addTextCrumb(pht('Confirm')); } else { $crumbs->addTextCrumb(pht('Invite Users')); } $crumbs->setBorder(true); $confirm_box = null; $info_view = null; if ($is_confirm) { $handles = array(); if ($actions) { $handles = $this->loadViewerHandles(mpull($actions, 'getUserPHID')); } $invite_table = id(new PhabricatorAuthInviteActionTableView()) ->setUser($viewer) ->setInviteActions($actions) ->setHandles($handles); $confirm_form = null; if ($any_valid) { $confirm_form = id(new AphrontFormView()) ->setUser($viewer) ->addHiddenInput('message', $message) ->addHiddenInput('emails', $emails) ->addHiddenInput('confirm', true) ->appendRemarkupInstructions( pht( 'If everything looks good, click **Send Invitations** to '. 'deliver email invitations these users. Otherwise, edit the '. 'email list or personal message at the bottom of the page to '. 'revise the invitations.')) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Send Invitations'))); } $info_view = id(new PHUIInfoView()) ->setErrors($confirm_errors) ->setSeverity($severity); $confirm_box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Confirm Invites')) ->setTable($invite_table) ->appendChild($confirm_form) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); } $form = id(new AphrontFormView()) ->setUser($viewer) ->appendRemarkupInstructions( pht( 'To invite users, enter their email addresses below. '. 'Separate addresses with commas or newlines.')) ->appendChild( id(new AphrontFormTextAreaControl()) ->setLabel(pht('Email Addresses')) ->setName(pht('emails')) ->setValue($emails) ->setError($e_emails) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)) ->appendRemarkupInstructions( pht( 'You can optionally include a heartfelt personal message in '. 'the email.')) ->appendChild( id(new AphrontFormTextAreaControl()) ->setLabel(pht('Message')) ->setName(pht('message')) ->setValue($message)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue( $is_confirm ? pht('Update Preview') : pht('Continue')) ->addCancelButton($this->getApplicationURI('invite/'))); $header = id(new PHUIHeaderView()) ->setHeader($title) ->setHeaderIcon('fa-group'); $box = id(new PHUIObjectBoxView()) ->setHeaderText( $is_confirm ? pht('Revise Invites') : pht('Invite Users')) ->setFormErrors($errors) ->setForm($form) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setFooter(array( $info_view, $confirm_box, $box, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleDisableController.php
src/applications/people/controller/PhabricatorPeopleDisableController.php
<?php final class PhabricatorPeopleDisableController extends PhabricatorPeopleController { public function shouldRequireAdmin() { return false; } public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $via = $request->getURIData('via'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$user) { return new Aphront404Response(); } // NOTE: We reach this controller via the administrative "Disable User" // on profiles and also via the "X" action on the approval queue. We do // things slightly differently depending on the context the actor is in. // In particular, disabling via "Disapprove" requires you be an // administrator (and bypasses the "Can Disable Users" permission). // Disabling via "Disable" requires the permission only. $is_disapprove = ($via == 'disapprove'); if ($is_disapprove) { $done_uri = $this->getApplicationURI('query/approval/'); if (!$viewer->getIsAdmin()) { return $this->newDialog() ->setTitle(pht('No Permission')) ->appendParagraph(pht('Only administrators can disapprove users.')) ->addCancelButton($done_uri); } if ($user->getIsApproved()) { return $this->newDialog() ->setTitle(pht('Already Approved')) ->appendParagraph(pht('This user has already been approved.')) ->addCancelButton($done_uri); } // On the "Disapprove" flow, bypass the "Can Disable Users" permission. $actor = PhabricatorUser::getOmnipotentUser(); $should_disable = true; } else { $this->requireApplicationCapability( PeopleDisableUsersCapability::CAPABILITY); $actor = $viewer; $done_uri = $this->getApplicationURI("manage/{$id}/"); $should_disable = !$user->getIsDisabled(); } if ($viewer->getPHID() == $user->getPHID()) { return $this->newDialog() ->setTitle(pht('Something Stays Your Hand')) ->appendParagraph( pht( 'Try as you might, you find you can not disable your own account.')) ->addCancelButton($done_uri, pht('Curses!')); } if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorUserTransaction()) ->setTransactionType(PhabricatorUserDisableTransaction::TRANSACTIONTYPE) ->setNewValue($should_disable); id(new PhabricatorUserTransactionEditor()) ->setActor($actor) ->setActingAsPHID($viewer->getPHID()) ->setContentSourceFromRequest($request) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->applyTransactions($user, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } if ($should_disable) { $title = pht('Disable User?'); $short_title = pht('Disable User'); $body = pht( 'Disable %s? They will no longer be able to access this server or '. 'receive email.', phutil_tag('strong', array(), $user->getUsername())); $submit = pht('Disable User'); } else { $title = pht('Enable User?'); $short_title = pht('Enable User'); $body = pht( 'Enable %s? They will be able to access this server and receive '. 'email again.', phutil_tag('strong', array(), $user->getUsername())); $submit = pht('Enable User'); } return $this->newDialog() ->setTitle($title) ->setShortTitle($short_title) ->appendParagraph($body) ->addCancelButton($done_uri) ->addSubmitButton($submit); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleInviteController.php
src/applications/people/controller/PhabricatorPeopleInviteController.php
<?php abstract class PhabricatorPeopleInviteController extends PhabricatorPeopleController { protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); $crumbs->addTextCrumb( pht('Invites'), $this->getApplicationURI('invite/')); return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleLogsController.php
src/applications/people/controller/PhabricatorPeopleLogsController.php
<?php final class PhabricatorPeopleLogsController extends PhabricatorPeopleController { public function handleRequest(AphrontRequest $request) { $controller = id(new PhabricatorApplicationSearchController()) ->setQueryKey($request->getURIData('queryKey')) ->setSearchEngine(new PhabricatorPeopleLogSearchEngine()) ->setNavigation($this->buildSideNavView()); return $this->delegateToController($controller); } public function buildSideNavView($for_app = false) { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $viewer = $this->getRequest()->getUser(); id(new PhabricatorPeopleLogSearchEngine()) ->setViewer($viewer) ->addNavigationItems($nav->getMenu()); 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/people/controller/PhabricatorPeopleProfileViewController.php
src/applications/people/controller/PhabricatorPeopleProfileViewController.php
<?php final class PhabricatorPeopleProfileViewController extends PhabricatorPeopleProfileController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $username = $request->getURIData('username'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withUsernames(array($username)) ->needProfileImage(true) ->needAvailability(true) ->executeOne(); if (!$user) { return new Aphront404Response(); } $this->setUser($user); $header = $this->buildProfileHeader(); $properties = $this->buildPropertyView($user); $name = $user->getUsername(); $feed = $this->buildPeopleFeed($user, $viewer); $view_all = id(new PHUIButtonView()) ->setTag('a') ->setIcon( id(new PHUIIconView()) ->setIcon('fa-list-ul')) ->setText(pht('View All')) ->setHref('/feed/?userPHIDs='.$user->getPHID()); $feed_header = id(new PHUIHeaderView()) ->setHeader(pht('Recent Activity')) ->addActionLink($view_all); $feed = id(new PHUIObjectBoxView()) ->setHeader($feed_header) ->addClass('project-view-feed') ->appendChild($feed); $projects = $this->buildProjectsView($user); $calendar = $this->buildCalendarDayView($user); $home = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setMainColumn( array( $properties, $feed, )) ->setSideColumn( array( $projects, $calendar, )); $navigation = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_PROFILE); $crumbs = $this->buildApplicationCrumbs(); $crumbs->setBorder(true); return $this->newPage() ->setTitle($user->getUsername()) ->setNavigation($navigation) ->setCrumbs($crumbs) ->setPageObjectPHIDs( array( $user->getPHID(), )) ->appendChild( array( $home, )); } private function buildPropertyView( PhabricatorUser $user) { $viewer = $this->getRequest()->getUser(); $view = id(new PHUIPropertyListView()) ->setUser($viewer) ->setObject($user); $field_list = PhabricatorCustomField::getObjectFields( $user, PhabricatorCustomField::ROLE_VIEW); $field_list->appendFieldsToPropertyList($user, $viewer, $view); if (!$view->hasAnyProperties()) { return null; } $header = id(new PHUIHeaderView()) ->setHeader(pht('User Details')); $view = id(new PHUIObjectBoxView()) ->appendChild($view) ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->addClass('project-view-properties'); return $view; } private function buildProjectsView( PhabricatorUser $user) { $viewer = $this->getViewer(); $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withMemberPHIDs(array($user->getPHID())) ->needImages(true) ->withStatuses( array( PhabricatorProjectStatus::STATUS_ACTIVE, )) ->execute(); $header = id(new PHUIHeaderView()) ->setHeader(pht('Projects')); if (!empty($projects)) { $limit = 5; $render_phids = array_slice($projects, 0, $limit); $list = id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($render_phids); if (count($projects) > $limit) { $header_text = pht( 'Projects (%s)', phutil_count($projects)); $header = id(new PHUIHeaderView()) ->setHeader($header_text) ->addActionLink( id(new PHUIButtonView()) ->setTag('a') ->setIcon('fa-list-ul') ->setText(pht('View All')) ->setHref('/project/?member='.$user->getPHID())); } } else { $list = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_NODATA) ->appendChild(pht('User does not belong to any projects.')); } $box = id(new PHUIObjectBoxView()) ->setHeader($header) ->appendChild($list) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); return $box; } private function buildCalendarDayView(PhabricatorUser $user) { $viewer = $this->getViewer(); $class = 'PhabricatorCalendarApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return null; } // Don't show calendar information for disabled users, since it's probably // not useful or accurate and may be misleading. if ($user->getIsDisabled()) { return null; } $midnight = PhabricatorTime::getTodayMidnightDateTime($viewer); $week_end = clone $midnight; $week_end = $week_end->modify('+3 days'); $range_start = $midnight->format('U'); $range_end = $week_end->format('U'); $events = id(new PhabricatorCalendarEventQuery()) ->setViewer($viewer) ->withDateRange($range_start, $range_end) ->withInvitedPHIDs(array($user->getPHID())) ->withIsCancelled(false) ->needRSVPs(array($viewer->getPHID())) ->execute(); $event_views = array(); foreach ($events as $event) { $viewer_is_invited = $event->isRSVPInvited($viewer->getPHID()); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $event, PhabricatorPolicyCapability::CAN_EDIT); $epoch_min = $event->getStartDateTimeEpoch(); $epoch_max = $event->getEndDateTimeEpoch(); $event_view = id(new AphrontCalendarEventView()) ->setCanEdit($can_edit) ->setEventID($event->getID()) ->setEpochRange($epoch_min, $epoch_max) ->setIsAllDay($event->getIsAllDay()) ->setIcon($event->getIcon()) ->setViewerIsInvited($viewer_is_invited) ->setName($event->getName()) ->setDatetimeSummary($event->renderEventDate($viewer, true)) ->setURI($event->getURI()); $event_views[] = $event_view; } $event_views = msort($event_views, 'getEpochStart'); $day_view = id(new PHUICalendarWeekView()) ->setViewer($viewer) ->setView('week') ->setEvents($event_views) ->setWeekLength(3) ->render(); $header = id(new PHUIHeaderView()) ->setHeader(pht('Calendar')) ->setHref( urisprintf( '/calendar/?invited=%s#R', $user->getUsername())); $box = id(new PHUIObjectBoxView()) ->setHeader($header) ->appendChild($day_view) ->addClass('calendar-profile-box') ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); return $box; } private function buildPeopleFeed( PhabricatorUser $user, $viewer) { $query = id(new PhabricatorFeedQuery()) ->setViewer($viewer) ->withFilterPHIDs(array($user->getPHID())) ->setLimit(100) ->setReturnPartialResultsOnOverheat(true); $stories = $query->execute(); $overheated_view = null; $is_overheated = $query->getIsOverheated(); if ($is_overheated) { $overheated_message = PhabricatorApplicationSearchController::newOverheatedError( (bool)$stories); $overheated_view = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_WARNING) ->setTitle(pht('Query Overheated')) ->setErrors( array( $overheated_message, )); } $builder = new PhabricatorFeedBuilder($stories); $builder->setUser($viewer); $builder->setShowHovercards(true); $builder->setNoDataString(pht('To begin on such a grand journey, '. 'requires but just a single step.')); $view = $builder->buildView(); return array( $overheated_view, $view->render(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleDeleteController.php
src/applications/people/controller/PhabricatorPeopleDeleteController.php
<?php final class PhabricatorPeopleDeleteController extends PhabricatorPeopleController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$user) { return new Aphront404Response(); } $manage_uri = $this->getApplicationURI("manage/{$id}/"); $doc_uri = PhabricatorEnv::getDoclink( 'Permanently Destroying Data'); return $this->newDialog() ->setTitle(pht('Delete User')) ->appendParagraph( pht( 'To permanently destroy this user, run this command from the '. 'command line:')) ->appendCommand( csprintf( 'phabricator/ $ ./bin/remove destroy %R', $user->getMonogram())) ->appendParagraph( pht( 'Unless you have a very good reason to delete this user, consider '. 'disabling them instead.')) ->appendParagraph( pht( 'Users can not be permanently destroyed from the web interface. '. 'See %s in the documentation for more information.', phutil_tag( 'a', array( 'href' => $doc_uri, 'target' => '_blank', ), pht('Permanently Destroying Data')))) ->addCancelButton($manage_uri, pht('Close')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleApproveController.php
src/applications/people/controller/PhabricatorPeopleApproveController.php
<?php final class PhabricatorPeopleApproveController extends PhabricatorPeopleController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$user) { return new Aphront404Response(); } $via = $request->getURIData('via'); switch ($via) { case 'profile': $done_uri = urisprintf('/people/manage/%d/', $user->getID()); break; default: $done_uri = $this->getApplicationURI('query/approval/'); break; } if ($user->getIsApproved()) { return $this->newDialog() ->setTitle(pht('Already Approved')) ->appendChild(pht('This user has already been approved.')) ->addCancelButton($done_uri); } if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorUserTransaction()) ->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE) ->setNewValue(true); id(new PhabricatorUserTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->applyTransactions($user, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } return $this->newDialog() ->setTitle(pht('Confirm Approval')) ->appendChild( pht( 'Allow %s to access this server?', phutil_tag('strong', array(), $user->getUsername()))) ->addCancelButton($done_uri) ->addSubmitButton(pht('Approve Account')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php
src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php
<?php final class PhabricatorPeopleProfileCommitsController extends PhabricatorPeopleProfileController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfile(true) ->needProfileImage(true) ->needAvailability(true) ->executeOne(); if (!$user) { return new Aphront404Response(); } $class = 'PhabricatorDiffusionApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return new Aphront404Response(); } $this->setUser($user); $title = array(pht('Recent Commits'), $user->getUsername()); $header = $this->buildProfileHeader(); $commits = $this->buildCommitsView($user); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Recent Commits')); $crumbs->setBorder(true); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_COMMITS); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setFooter(array( $commits, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($view); } private function buildCommitsView(PhabricatorUser $user) { $viewer = $this->getViewer(); $commits = id(new DiffusionCommitQuery()) ->setViewer($viewer) ->withAuthorPHIDs(array($user->getPHID())) ->needCommitData(true) ->needIdentities(true) ->setLimit(100) ->execute(); $list = id(new DiffusionCommitGraphView()) ->setViewer($viewer) ->setCommits($commits); return $list; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileTasksController.php
src/applications/people/controller/PhabricatorPeopleProfileTasksController.php
<?php final class PhabricatorPeopleProfileTasksController extends PhabricatorPeopleProfileController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfile(true) ->needProfileImage(true) ->needAvailability(true) ->executeOne(); if (!$user) { return new Aphront404Response(); } $class = 'PhabricatorManiphestApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return new Aphront404Response(); } $this->setUser($user); $title = array(pht('Assigned Tasks'), $user->getUsername()); $header = $this->buildProfileHeader(); $tasks = $this->buildTasksView($user); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Assigned Tasks')); $crumbs->setBorder(true); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_TASKS); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setFooter(array( $tasks, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($view); } private function buildTasksView(PhabricatorUser $user) { $viewer = $this->getViewer(); $open = ManiphestTaskStatus::getOpenStatusConstants(); $tasks = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withOwners(array($user->getPHID())) ->withStatuses($open) ->needProjectPHIDs(true) ->setLimit(100) ->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY) ->execute(); $handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks); $list = id(new ManiphestTaskListView()) ->setUser($viewer) ->setHandles($handles) ->setTasks($tasks) ->setNoDataString(pht('No open, assigned tasks.')); $view = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Assigned Tasks')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($list); 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/people/controller/PhabricatorPeopleEmpowerController.php
src/applications/people/controller/PhabricatorPeopleEmpowerController.php
<?php final class PhabricatorPeopleEmpowerController extends PhabricatorPeopleController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$user) { return new Aphront404Response(); } $done_uri = $this->getApplicationURI("manage/{$id}/"); $validation_exception = null; if ($request->isFormOrHisecPost()) { $xactions = array(); $xactions[] = id(new PhabricatorUserTransaction()) ->setTransactionType( PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE) ->setNewValue(!$user->getIsAdmin()); $editor = id(new PhabricatorUserTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnMissingFields(true) ->setCancelURI($done_uri); try { $editor->applyTransactions($user, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; } } if ($user->getIsAdmin()) { $title = pht('Remove as Administrator?'); $short = pht('Remove Administrator'); $body = pht( 'Remove %s as an administrator? They will no longer be able to '. 'perform administrative functions on this server.', phutil_tag('strong', array(), $user->getUsername())); $submit = pht('Remove Administrator'); } else { $title = pht('Make Administrator?'); $short = pht('Make Administrator'); $body = pht( 'Empower %s as an administrator? They will be able to create users, '. 'approve users, make and remove administrators, delete accounts, and '. 'perform other administrative functions on this server.', phutil_tag('strong', array(), $user->getUsername())); $submit = pht('Make Administrator'); } return $this->newDialog() ->setValidationException($validation_exception) ->setTitle($title) ->setShortTitle($short) ->appendParagraph($body) ->addCancelButton($done_uri) ->addSubmitButton($submit); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileRevisionsController.php
src/applications/people/controller/PhabricatorPeopleProfileRevisionsController.php
<?php final class PhabricatorPeopleProfileRevisionsController extends PhabricatorPeopleProfileController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfile(true) ->needProfileImage(true) ->needAvailability(true) ->executeOne(); if (!$user) { return new Aphront404Response(); } $class = 'PhabricatorDifferentialApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return new Aphront404Response(); } $this->setUser($user); $title = array(pht('Recent Revisions'), $user->getUsername()); $header = $this->buildProfileHeader(); $commits = $this->buildRevisionsView($user); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Recent Revisions')); $crumbs->setBorder(true); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_REVISIONS); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setFooter(array( $commits, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($view); } private function buildRevisionsView(PhabricatorUser $user) { $viewer = $this->getViewer(); $revisions = id(new DifferentialRevisionQuery()) ->setViewer($viewer) ->withAuthors(array($user->getPHID())) ->needFlags(true) ->needDrafts(true) ->needReviewers(true) ->setLimit(100) ->execute(); $list = id(new DifferentialRevisionListView()) ->setViewer($viewer) ->setNoBox(true) ->setRevisions($revisions) ->setNoDataString(pht('No recent revisions.')); $view = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Recent Revisions')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($list); 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/people/controller/PhabricatorPeopleRenameController.php
src/applications/people/controller/PhabricatorPeopleRenameController.php
<?php final class PhabricatorPeopleRenameController extends PhabricatorPeopleController { public function shouldRequireAdmin() { return false; } public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$user) { return new Aphront404Response(); } $done_uri = $this->getApplicationURI("manage/{$id}/"); if (!$viewer->getIsAdmin()) { $dialog = $this->newDialog() ->setTitle(pht('Change Username')) ->appendParagraph( pht( 'You can not change usernames because you are not an '. 'administrator. Only administrators can change usernames.')) ->addCancelButton($done_uri, pht('Okay')); $message_body = PhabricatorAuthMessage::loadMessageText( $viewer, PhabricatorAuthChangeUsernameMessageType::MESSAGEKEY); if (strlen($message_body)) { $dialog->appendRemarkup($message_body); } return $dialog; } $validation_exception = null; $username = $user->getUsername(); if ($request->isFormOrHisecPost()) { $username = $request->getStr('username'); $xactions = array(); $xactions[] = id(new PhabricatorUserTransaction()) ->setTransactionType( PhabricatorUserUsernameTransaction::TRANSACTIONTYPE) ->setNewValue($username); $editor = id(new PhabricatorUserTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setCancelURI($done_uri) ->setContinueOnMissingFields(true); try { $editor->applyTransactions($user, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; } } $instructions = array(); $instructions[] = pht( 'If you rename this user, the old username will no longer be tied '. 'to the user account. Anything which uses the old username in raw '. 'text (like old commit messages) may no longer associate correctly.'); $instructions[] = pht( 'It is generally safe to rename users, but changing usernames may '. 'create occasional minor complications or confusion with text that '. 'contains the old username.'); $instructions[] = pht( 'The user will receive an email notifying them that you changed their '. 'username.'); $instructions[] = null; $form = id(new AphrontFormView()) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel(pht('Old Username')) ->setValue($user->getUsername())) ->appendChild( id(new AphrontFormTextControl()) ->setLabel(pht('New Username')) ->setValue($username) ->setName('username')); $dialog = $this->newDialog() ->setTitle(pht('Change Username')) ->setValidationException($validation_exception); foreach ($instructions as $instruction) { $dialog->appendParagraph($instruction); } $dialog ->appendForm($form) ->addSubmitButton(pht('Rename User')) ->addCancelButton($done_uri); return $dialog; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
<?php final class PhabricatorPeopleProfilePictureController extends PhabricatorPeopleProfileController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfileImage(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$user) { return new Aphront404Response(); } $this->setUser($user); $name = $user->getUserName(); $done_uri = '/p/'.$name.'/'; $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 profile 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) { $user->setProfileImagePHID(null); } else { $user->setProfileImagePHID($xformed->getPHID()); $xformed->attachToObject($user->getPHID()); } $user->save(); return id(new AphrontRedirectResponse())->setURI($done_uri); } } $title = pht('Edit Profile Picture'); $form = id(new PHUIFormLayoutView()) ->setUser($viewer); $default_image = $user->getDefaultProfileImagePHID(); if ($default_image) { $default_image = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($default_image)) ->executeOne(); } if (!$default_image) { $default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png'); } $images = array(); $current = $user->getProfileImagePHID(); $has_current = false; if ($current) { $files = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($current)) ->execute(); if ($files) { $file = head($files); if ($file->isTransformableImage()) { $has_current = true; $images[$current] = array( 'uri' => $file->getBestURI(), 'tip' => pht('Current Picture'), ); } } } $builtins = array( 'user1.png', 'user2.png', 'user3.png', 'user4.png', 'user5.png', 'user6.png', 'user7.png', 'user8.png', 'user9.png', ); foreach ($builtins as $builtin) { $file = PhabricatorFile::loadBuiltin($viewer, $builtin); $images[$file->getPHID()] = array( 'uri' => $file->getBestURI(), 'tip' => pht('Builtin Image'), ); } // Try to add external account images for any associated external accounts. $accounts = id(new PhabricatorExternalAccountQuery()) ->setViewer($viewer) ->withUserPHIDs(array($user->getPHID())) ->needImages(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->execute(); foreach ($accounts as $account) { $file = $account->getProfileImageFile(); if ($account->getProfileImagePHID() != $file->getPHID()) { // This is a default image, just skip it. continue; } $config = $account->getProviderConfig(); $provider = $config->getProvider(); $tip = pht('Picture From %s', $provider->getProviderName()); if ($file->isTransformableImage()) { $images[$file->getPHID()] = array( 'uri' => $file->getBestURI(), 'tip' => $tip, ); } } $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) { $style = null; if (isset($spec['style'])) { $style = $spec['style']; } $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($done_uri) ->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(pht('Edit Profile Picture')); $crumbs->setBorder(true); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_MANAGE); $header = $this->buildProfileHeader(); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setFooter(array( $form_box, $upload_box, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleCreateController.php
src/applications/people/controller/PhabricatorPeopleCreateController.php
<?php final class PhabricatorPeopleCreateController extends PhabricatorPeopleController { public function handleRequest(AphrontRequest $request) { $admin = $request->getUser(); id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( $admin, $request, $this->getApplicationURI()); $v_type = 'standard'; if ($request->isFormPost()) { $v_type = $request->getStr('type'); if ($v_type == 'standard' || $v_type == 'bot' || $v_type == 'list') { return id(new AphrontRedirectResponse())->setURI( $this->getApplicationURI('new/'.$v_type.'/')); } } $title = pht('Create New User'); $standard_caption = pht( 'Create a standard user account. These users can log in, '. 'use the web interface and API, and receive email.'); $standard_admin = pht( 'Administrators are limited in their ability to access or edit these '. 'accounts after account creation.'); $bot_caption = pht( 'Create a bot/script user account, to automate interactions with other '. 'systems. These users can not use the web interface, but can use the '. 'API.'); $bot_admin = pht( 'Administrators have greater access to edit these accounts.'); $types = array(); $can_create = $this->hasApplicationCapability( PeopleCreateUsersCapability::CAPABILITY); if ($can_create) { $types[] = array( 'type' => 'standard', 'name' => pht('Create Standard User'), 'help' => pht('Create a standard user account.'), ); } $types[] = array( 'type' => 'bot', 'name' => pht('Create Bot User'), 'help' => pht('Create a new user for use with automated scripts.'), ); $types[] = array( 'type' => 'list', 'name' => pht('Create Mailing List User'), 'help' => pht( 'Create a mailing list user to represent an existing, external '. 'mailing list like a Google Group or a Mailman list.'), ); $buttons = id(new AphrontFormRadioButtonControl()) ->setLabel(pht('Account Type')) ->setName('type') ->setValue($v_type); foreach ($types as $type) { $buttons->addButton($type['type'], $type['name'], $type['help']); } $form = id(new AphrontFormView()) ->setUser($admin) ->appendRemarkupInstructions( pht( 'Choose the type of user account to create. For a detailed '. 'explanation of user account types, see [[ %s | User Guide: '. 'Account Roles ]].', PhabricatorEnv::getDoclink('User Guide: Account Roles'))) ->appendChild($buttons) ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton($this->getApplicationURI()) ->setValue(pht('Continue'))); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $box = id(new PHUIObjectBoxView()) ->setHeaderText($title) ->setBackground(PHUIObjectBoxView::WHITE_CONFIG) ->setForm($form); $guidance_context = new PhabricatorPeopleCreateGuidanceContext(); $guidance = id(new PhabricatorGuidanceEngine()) ->setViewer($admin) ->setGuidanceContext($guidance_context) ->newInfoView(); $view = id(new PHUITwoColumnView()) ->setFooter( array( $guidance, $box, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleInviteListController.php
src/applications/people/controller/PhabricatorPeopleInviteListController.php
<?php final class PhabricatorPeopleInviteListController extends PhabricatorPeopleInviteController { public function handleRequest(AphrontRequest $request) { $controller = id(new PhabricatorApplicationSearchController()) ->setQueryKey($request->getURIData('queryKey')) ->setSearchEngine(new PhabricatorAuthInviteSearchEngine()) ->setNavigation($this->buildSideNavView()); return $this->delegateToController($controller); } public function buildSideNavView($for_app = false) { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $viewer = $this->getRequest()->getUser(); id(new PhabricatorAuthInviteSearchEngine()) ->setViewer($viewer) ->addNavigationItems($nav->getMenu()); return $nav; } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); $can_invite = $this->hasApplicationCapability( PeopleCreateUsersCapability::CAPABILITY); $crumbs->addAction( id(new PHUIListItemView()) ->setName(pht('Invite Users')) ->setHref($this->getApplicationURI('invite/send/')) ->setIcon('fa-plus-square') ->setDisabled(!$can_invite) ->setWorkflow(!$can_invite)); return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileEditController.php
src/applications/people/controller/PhabricatorPeopleProfileEditController.php
<?php final class PhabricatorPeopleProfileEditController extends PhabricatorPeopleProfileController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfileImage(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$user) { return new Aphront404Response(); } $this->setUser($user); $done_uri = $this->getApplicationURI("manage/{$id}/"); $field_list = PhabricatorCustomField::getObjectFields( $user, PhabricatorCustomField::ROLE_EDIT); $field_list ->setViewer($viewer) ->readFieldsFromStorage($user); $validation_exception = null; if ($request->isFormPost()) { $xactions = $field_list->buildFieldTransactionsFromRequest( new PhabricatorUserTransaction(), $request); $editor = id(new PhabricatorUserTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true); try { $editor->applyTransactions($user, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; } } $title = pht('Edit Profile'); $form = id(new AphrontFormView()) ->setUser($viewer); $field_list->appendFieldsToForm($form); $form ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton($done_uri) ->setValue(pht('Save Profile'))); $allow_public = PhabricatorEnv::getEnvConfig('policy.allow-public'); $note = null; if ($allow_public) { $note = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_WARNING) ->appendChild(pht( 'Information on user profiles on this install is publicly '. 'visible.')); } $form_box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Profile')) ->setValidationException($validation_exception) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setForm($form); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Edit Profile')); $crumbs->setBorder(true); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_MANAGE); $header = id(new PHUIHeaderView()) ->setHeader(pht('Edit Profile: %s', $user->getFullName())) ->setHeaderIcon('fa-pencil'); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setFooter(array( $note, $form_box, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileManageController.php
src/applications/people/controller/PhabricatorPeopleProfileManageController.php
<?php final class PhabricatorPeopleProfileManageController extends PhabricatorPeopleProfileController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfile(true) ->needProfileImage(true) ->needAvailability(true) ->executeOne(); if (!$user) { return new Aphront404Response(); } $this->setUser($user); $header = $this->buildProfileHeader(); $curtain = $this->buildCurtain($user); $properties = $this->buildPropertyView($user); $name = $user->getUsername(); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_MANAGE); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Manage')); $crumbs->setBorder(true); $timeline = $this->buildTransactionTimeline( $user, new PhabricatorPeopleTransactionQuery()); $timeline->setShouldTerminate(true); $manage = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setCurtain($curtain) ->addPropertySection(pht('Details'), $properties) ->setMainColumn($timeline); return $this->newPage() ->setTitle( array( pht('Manage User'), $user->getUsername(), )) ->setNavigation($nav) ->setCrumbs($crumbs) ->appendChild($manage); } private function buildPropertyView(PhabricatorUser $user) { $viewer = $this->getRequest()->getUser(); $view = id(new PHUIPropertyListView()) ->setUser($viewer) ->setObject($user); $field_list = PhabricatorCustomField::getObjectFields( $user, PhabricatorCustomField::ROLE_VIEW); $field_list->appendFieldsToPropertyList($user, $viewer, $view); return $view; } private function buildCurtain(PhabricatorUser $user) { $viewer = $this->getViewer(); $is_self = ($user->getPHID() === $viewer->getPHID()); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $user, PhabricatorPolicyCapability::CAN_EDIT); $is_admin = $viewer->getIsAdmin(); $can_admin = ($is_admin && !$is_self); $has_disable = $this->hasApplicationCapability( PeopleDisableUsersCapability::CAPABILITY); $can_disable = ($has_disable && !$is_self); $id = $user->getID(); $welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine()) ->setSender($viewer) ->setRecipient($user); $can_welcome = $welcome_engine->canSendMail(); $curtain = $this->newCurtainView($user); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-pencil') ->setName(pht('Edit Profile')) ->setHref($this->getApplicationURI('editprofile/'.$id.'/')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-picture-o') ->setName(pht('Edit Profile Picture')) ->setHref($this->getApplicationURI('picture/'.$id.'/')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-wrench') ->setName(pht('Edit Settings')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit) ->setHref('/settings/user/'.$user->getUsername().'/')); if ($user->getIsAdmin()) { $empower_icon = 'fa-arrow-circle-o-down'; $empower_name = pht('Remove Administrator'); } else { $empower_icon = 'fa-arrow-circle-o-up'; $empower_name = pht('Make Administrator'); } $curtain->addAction( id(new PhabricatorActionView()) ->setIcon($empower_icon) ->setName($empower_name) ->setDisabled(!$can_admin) ->setWorkflow(true) ->setHref($this->getApplicationURI('empower/'.$id.'/'))); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-tag') ->setName(pht('Change Username')) ->setDisabled(!$is_admin) ->setWorkflow(true) ->setHref($this->getApplicationURI('rename/'.$id.'/'))); if ($user->getIsDisabled()) { $disable_icon = 'fa-check-circle-o'; $disable_name = pht('Enable User'); } else { $disable_icon = 'fa-ban'; $disable_name = pht('Disable User'); } $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-envelope') ->setName(pht('Send Welcome Email')) ->setWorkflow(true) ->setDisabled(!$can_welcome) ->setHref($this->getApplicationURI('welcome/'.$id.'/'))); $curtain->addAction( id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER)); if (!$user->getIsApproved()) { $approve_action = id(new PhabricatorActionView()) ->setIcon('fa-thumbs-up') ->setName(pht('Approve User')) ->setWorkflow(true) ->setDisabled(!$is_admin) ->setHref("/people/approve/{$id}/via/profile/"); if ($is_admin) { $approve_action->setColor(PhabricatorActionView::GREEN); } $curtain->addAction($approve_action); } $curtain->addAction( id(new PhabricatorActionView()) ->setIcon($disable_icon) ->setName($disable_name) ->setDisabled(!$can_disable) ->setWorkflow(true) ->setHref($this->getApplicationURI('disable/'.$id.'/'))); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-times') ->setName(pht('Delete User')) ->setDisabled(!$can_admin) ->setWorkflow(true) ->setHref($this->getApplicationURI('delete/'.$id.'/'))); $curtain->addAction( id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER)); return $curtain; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleWelcomeController.php
src/applications/people/controller/PhabricatorPeopleWelcomeController.php
<?php final class PhabricatorPeopleWelcomeController extends PhabricatorPeopleController { public function shouldRequireAdmin() { // You need to be an administrator to actually send welcome email, but // we let anyone hit this page so they can get a nice error dialog // explaining the issue. return false; } public function handleRequest(AphrontRequest $request) { $admin = $this->getViewer(); $user = id(new PhabricatorPeopleQuery()) ->setViewer($admin) ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$user) { return new Aphront404Response(); } $id = $user->getID(); $profile_uri = "/people/manage/{$id}/"; $welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine()) ->setSender($admin) ->setRecipient($user); try { $welcome_engine->validateMail(); } catch (PhabricatorPeopleMailEngineException $ex) { return $this->newDialog() ->setTitle($ex->getTitle()) ->appendParagraph($ex->getBody()) ->addCancelButton($profile_uri, pht('Done')); } $v_message = $request->getStr('message'); if ($request->isFormPost()) { if (strlen($v_message)) { $welcome_engine->setWelcomeMessage($v_message); } $welcome_engine->sendMail(); return id(new AphrontRedirectResponse())->setURI($profile_uri); } $default_message = PhabricatorAuthMessage::loadMessage( $admin, PhabricatorAuthWelcomeMailMessageType::MESSAGEKEY); if ($default_message && strlen($default_message->getMessageText())) { $message_instructions = pht( 'The email will identify you as the sender. You may optionally '. 'replace the [[ %s | default custom mail body ]] with different text '. 'by providing a message below.', $default_message->getURI()); } else { $message_instructions = pht( 'The email will identify you as the sender. You may optionally '. 'include additional text in the mail body by specifying it below.'); } $form = id(new AphrontFormView()) ->setViewer($admin) ->appendRemarkupInstructions( pht( 'This workflow will send this user ("%s") a copy of the "Welcome to '. '%s" email that users normally receive when their '. 'accounts are created by an administrator.', $user->getUsername(), PlatformSymbols::getPlatformServerName())) ->appendRemarkupInstructions( pht( 'The email will contain a link that the user may use to log in '. 'to their account. This link bypasses authentication requirements '. 'and allows them to log in without credentials. Sending a copy of '. 'this email can be useful if the original was lost or never sent.')) ->appendRemarkupInstructions($message_instructions) ->appendControl( id(new PhabricatorRemarkupControl()) ->setName('message') ->setLabel(pht('Custom Message')) ->setValue($v_message)); return $this->newDialog() ->setTitle(pht('Send Welcome Email')) ->setWidth(AphrontDialogView::WIDTH_FORM) ->appendForm($form) ->addSubmitButton(pht('Send Email')) ->addCancelButton($profile_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleController.php
src/applications/people/controller/PhabricatorPeopleController.php
<?php abstract class PhabricatorPeopleController extends PhabricatorController { public function shouldRequireAdmin() { return true; } public function buildSideNavView($for_app = false) { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $name = null; if ($for_app) { $name = $this->getRequest()->getURIData('username'); if ($name) { $nav->setBaseURI(new PhutilURI('/p/')); $nav->addFilter("{$name}/", $name); $nav->addFilter("{$name}/calendar/", pht('Calendar')); } } if (!$name) { $viewer = $this->getRequest()->getUser(); id(new PhabricatorPeopleSearchEngine()) ->setViewer($viewer) ->addNavigationItems($nav->getMenu()); if ($viewer->getIsAdmin()) { $nav->addLabel(pht('User Administration')); $nav->addFilter('logs', pht('Activity Logs')); $nav->addFilter('invite', pht('Email Invitations')); } } return $nav; } public function buildApplicationMenu() { return $this->buildSideNavView(true)->getMenu(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleLogViewController.php
src/applications/people/controller/PhabricatorPeopleLogViewController.php
<?php final class PhabricatorPeopleLogViewController extends PhabricatorPeopleController { public function shouldRequireAdmin() { return false; } public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $log = id(new PhabricatorPeopleLogQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$log) { return new Aphront404Response(); } $logs_uri = $this->getApplicationURI('logs/'); $crumbs = $this->buildApplicationCrumbs() ->addTextCrumb(pht('Activity Logs'), $logs_uri) ->addTextCrumb($log->getObjectName()) ->setBorder(true); $header = $this->buildHeaderView($log); $properties = $this->buildPropertiesView($log); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addPropertySection(pht('Details'), $properties); return $this->newPage() ->setCrumbs($crumbs) ->setTitle($log->getObjectName()) ->appendChild($view); } private function buildHeaderView(PhabricatorUserLog $log) { $viewer = $this->getViewer(); $view = id(new PHUIHeaderView()) ->setViewer($viewer) ->setHeader($log->getObjectName()); return $view; } private function buildPropertiesView(PhabricatorUserLog $log) { $viewer = $this->getViewer(); $view = id(new PHUIPropertyListView()) ->setViewer($viewer); $type_map = PhabricatorUserLogType::getAllLogTypes(); $type_map = mpull($type_map, 'getLogTypeName', 'getLogTypeKey'); $action = $log->getAction(); $type_name = idx($type_map, $action, $action); $view->addProperty(pht('Event Type'), $type_name); $view->addProperty( pht('Event Date'), phabricator_datetime($log->getDateCreated(), $viewer)); $actor_phid = $log->getActorPHID(); if ($actor_phid) { $view->addProperty( pht('Acting User'), $viewer->renderHandle($actor_phid)); } $user_phid = $log->getUserPHID(); if ($user_phid) { $view->addProperty( pht('Affected User'), $viewer->renderHandle($user_phid)); } $remote_address = $log->getRemoteAddressForViewer($viewer); if ($remote_address !== null) { $view->addProperty(pht('Remote Address'), $remote_address); } 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/people/controller/PhabricatorPeopleListController.php
src/applications/people/controller/PhabricatorPeopleListController.php
<?php final class PhabricatorPeopleListController extends PhabricatorPeopleController { public function shouldAllowPublic() { return true; } public function shouldRequireAdmin() { return false; } public function handleRequest(AphrontRequest $request) { $this->requireApplicationCapability( PeopleBrowseUserDirectoryCapability::CAPABILITY); $controller = id(new PhabricatorApplicationSearchController()) ->setQueryKey($request->getURIData('queryKey')) ->setSearchEngine(new PhabricatorPeopleSearchEngine()) ->setNavigation($this->buildSideNavView()); return $this->delegateToController($controller); } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); $viewer = $this->getRequest()->getUser(); if ($viewer->getIsAdmin()) { $crumbs->addAction( id(new PHUIListItemView()) ->setName(pht('Create New User')) ->setHref($this->getApplicationURI('create/')) ->setIcon('fa-plus-square')); } return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileBadgesController.php
src/applications/people/controller/PhabricatorPeopleProfileBadgesController.php
<?php final class PhabricatorPeopleProfileBadgesController extends PhabricatorPeopleProfileController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $user = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfileImage(true) ->executeOne(); if (!$user) { return new Aphront404Response(); } $class = 'PhabricatorBadgesApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return new Aphront404Response(); } $this->setUser($user); $title = array(pht('Badges'), $user->getUsername()); $header = $this->buildProfileHeader(); $badges = $this->buildBadgesView($user); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Badges')); $crumbs->setBorder(true); $nav = $this->newNavigation( $user, PhabricatorPeopleProfileMenuEngine::ITEM_BADGES); $button = id(new PHUIButtonView()) ->setTag('a') ->setIcon('fa-plus') ->setText(pht('Award Badge')) ->setWorkflow(true) ->setHref('/badges/award/'.$user->getID().'/'); $header->addActionLink($button); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setFooter( array( $badges, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($view); } private function buildBadgesView(PhabricatorUser $user) { $viewer = $this->getViewer(); $request = $this->getRequest(); $pager = id(new AphrontCursorPagerView()) ->readFromRequest($request); $query = id(new PhabricatorBadgesAwardQuery()) ->setViewer($viewer) ->withRecipientPHIDs(array($user->getPHID())) ->withBadgeStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE)); $awards = $query->executeWithCursorPager($pager); if ($awards) { $flex = new PHUIBadgeBoxView(); foreach ($awards as $award) { $badge = $award->getBadge(); $awarder_info = array(); $awarder_phid = $award->getAwarderPHID(); $awarder_handle = $viewer->renderHandle($awarder_phid); $awarded_date = phabricator_date($award->getDateCreated(), $viewer); $awarder_info = pht( 'Awarded by %s', $awarder_handle->render()); $item = id(new PHUIBadgeView()) ->setIcon($badge->getIcon()) ->setHeader($badge->getName()) ->setSubhead($badge->getFlavor()) ->setQuality($badge->getQuality()) ->setHref($badge->getViewURI()) ->addByLine($awarder_info) ->addByLine($awarded_date); $flex->addItem($item); } } else { $flex = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ->appendChild(pht('User has not been awarded any badges.')); } return array( $flex, $pager, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleProfileController.php
src/applications/people/controller/PhabricatorPeopleProfileController.php
<?php abstract class PhabricatorPeopleProfileController extends PhabricatorPeopleController { private $user; public function shouldRequireAdmin() { return false; } public function setUser(PhabricatorUser $user) { $this->user = $user; return $this; } public function getUser() { return $this->user; } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); $user = $this->getUser(); if ($user) { $crumbs->addTextCrumb( $user->getUsername(), urisprintf('/p/%s/', $user->getUsername())); } return $crumbs; } public function buildProfileHeader() { $user = $this->user; $viewer = $this->getViewer(); $profile = $user->loadUserProfile(); $picture = $user->getProfileImageURI(); $profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon()); $profile_title = $profile->getDisplayTitle(); $tag = id(new PHUITagView()) ->setType(PHUITagView::TYPE_SHADE); $tags = array(); if ($user->getIsAdmin()) { $tags[] = id(clone $tag) ->setName(pht('Administrator')) ->setColor('blue'); } // "Disabled" gets a stronger status tag below. if (!$user->getIsApproved()) { $tags[] = id(clone $tag) ->setName('Not Approved') ->setColor('yellow'); } if ($user->getIsSystemAgent()) { $tags[] = id(clone $tag) ->setName(pht('Bot')) ->setColor('orange'); } if ($user->getIsMailingList()) { $tags[] = id(clone $tag) ->setName(pht('Mailing List')) ->setColor('orange'); } if (!$user->getIsEmailVerified()) { $tags[] = id(clone $tag) ->setName(pht('Email Not Verified')) ->setColor('violet'); } $header = id(new PHUIHeaderView()) ->setHeader($user->getFullName()) ->setImage($picture) ->setProfileHeader(true) ->addClass('people-profile-header'); foreach ($tags as $tag) { $header->addTag($tag); } require_celerity_resource('project-view-css'); if ($user->getIsDisabled()) { $header->setStatus('fa-ban', 'red', pht('Disabled')); } else { $header->setStatus($profile_icon, 'bluegrey', $profile_title); } $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $user, PhabricatorPolicyCapability::CAN_EDIT); if ($can_edit) { $id = $user->getID(); $header->setImageEditURL($this->getApplicationURI("picture/{$id}/")); } return $header; } final protected function newNavigation( PhabricatorUser $user, $item_identifier) { $viewer = $this->getViewer(); $engine = id(new PhabricatorPeopleProfileMenuEngine()) ->setViewer($viewer) ->setController($this) ->setProfileObject($user); $view_list = $engine->newProfileMenuItemViewList(); $view_list->setSelectedViewWithItemIdentifier($item_identifier); $navigation = $view_list->newNavigationView(); return $navigation; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/controller/PhabricatorPeopleNewController.php
src/applications/people/controller/PhabricatorPeopleNewController.php
<?php final class PhabricatorPeopleNewController extends PhabricatorPeopleController { public function handleRequest(AphrontRequest $request) { $type = $request->getURIData('type'); $admin = $request->getUser(); id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( $admin, $request, $this->getApplicationURI()); $is_bot = false; $is_list = false; switch ($type) { case 'standard': $this->requireApplicationCapability( PeopleCreateUsersCapability::CAPABILITY); break; case 'bot': $is_bot = true; break; case 'list': $is_list = true; break; default: return new Aphront404Response(); } $user = new PhabricatorUser(); $require_real_name = PhabricatorEnv::getEnvConfig('user.require-real-name'); $e_username = true; $e_realname = $require_real_name ? true : null; $e_email = true; $errors = array(); $welcome_checked = true; $new_email = null; if ($request->isFormPost()) { $welcome_checked = $request->getInt('welcome'); $user->setUsername($request->getStr('username')); $new_email = $request->getStr('email'); if (!strlen($new_email)) { $errors[] = pht('Email is required.'); $e_email = pht('Required'); } else if (!PhabricatorUserEmail::isValidAddress($new_email)) { $errors[] = PhabricatorUserEmail::describeValidAddresses(); $e_email = pht('Invalid'); } else if (!PhabricatorUserEmail::isAllowedAddress($new_email)) { $errors[] = PhabricatorUserEmail::describeAllowedAddresses(); $e_email = pht('Not Allowed'); } else { $e_email = null; } $user->setRealName($request->getStr('realname')); if (!strlen($user->getUsername())) { $errors[] = pht('Username is required.'); $e_username = pht('Required'); } else if (!PhabricatorUser::validateUsername($user->getUsername())) { $errors[] = PhabricatorUser::describeValidUsername(); $e_username = pht('Invalid'); } else { $e_username = null; } if (!strlen($user->getRealName()) && $require_real_name) { $errors[] = pht('Real name is required.'); $e_realname = pht('Required'); } else { $e_realname = null; } if (!$errors) { try { $email = id(new PhabricatorUserEmail()) ->setAddress($new_email) ->setIsVerified(0); // Automatically approve the user, since an admin is creating them. $user->setIsApproved(1); // If the user is a bot or list, approve their email too. if ($is_bot || $is_list) { $email->setIsVerified(1); } id(new PhabricatorUserEditor()) ->setActor($admin) ->createNewUser($user, $email); if ($is_bot) { id(new PhabricatorUserEditor()) ->setActor($admin) ->makeSystemAgentUser($user, true); } if ($is_list) { id(new PhabricatorUserEditor()) ->setActor($admin) ->makeMailingListUser($user, true); } if ($welcome_checked) { $welcome_engine = id(new PhabricatorPeopleWelcomeMailEngine()) ->setSender($admin) ->setRecipient($user); if ($welcome_engine->canSendMail()) { $welcome_engine->sendMail(); } } $response = id(new AphrontRedirectResponse()) ->setURI('/p/'.$user->getUsername().'/'); return $response; } catch (AphrontDuplicateKeyQueryException $ex) { $errors[] = pht('Username and email must be unique.'); $same_username = id(new PhabricatorUser()) ->loadOneWhere('username = %s', $user->getUsername()); $same_email = id(new PhabricatorUserEmail()) ->loadOneWhere('address = %s', $new_email); if ($same_username) { $e_username = pht('Duplicate'); } if ($same_email) { $e_email = pht('Duplicate'); } } } } $form = id(new AphrontFormView()) ->setUser($admin); if ($is_bot) { $title = pht('Create New Bot'); $form->appendRemarkupInstructions( pht('You are creating a new **bot** user account.')); } else if ($is_list) { $title = pht('Create New Mailing List'); $form->appendRemarkupInstructions( pht('You are creating a new **mailing list** user account.')); } else { $title = pht('Create New User'); $form->appendRemarkupInstructions( pht('You are creating a new **standard** user account.')); } $form ->appendChild( id(new AphrontFormTextControl()) ->setLabel(pht('Username')) ->setName('username') ->setValue($user->getUsername()) ->setError($e_username)) ->appendChild( id(new AphrontFormTextControl()) ->setLabel(pht('Real Name')) ->setName('realname') ->setValue($user->getRealName()) ->setError($e_realname)) ->appendChild( id(new AphrontFormTextControl()) ->setLabel(pht('Email')) ->setName('email') ->setValue($new_email) ->setCaption(PhabricatorUserEmail::describeAllowedAddresses()) ->setError($e_email)); if (!$is_bot && !$is_list) { $form->appendChild( id(new AphrontFormCheckboxControl()) ->addCheckbox( 'welcome', 1, pht( 'Send "Welcome to %s" email with login instructions.', PlatformSymbols::getPlatformServerName()), $welcome_checked)); } $form ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton($this->getApplicationURI()) ->setValue(pht('Create User'))); if ($is_bot) { $form ->appendChild(id(new AphrontFormDividerControl())) ->appendRemarkupInstructions( pht( '**Why do bot accounts need an email address?**'. "\n\n". 'Although bots do not normally receive email, they can interact '. 'with other systems which require an email address. Examples '. 'include:'. "\n\n". " - If the account takes actions which //send// email, we need ". " an address to use in the //From// header.\n". " - If the account creates commits, Git and Mercurial require ". " an email address for authorship.\n". " - If you send email //to// this server on behalf of the ". " account, the address can identify the sender.\n". " - Some internal authentication functions depend on accounts ". " having an email address.\n". "\n\n". "The address will automatically be verified, so you do not need ". "to be able to receive mail at this address, and can enter some ". "invalid or nonexistent (but correctly formatted) address like ". "`bot@yourcompany.com` if you prefer.")); } $box = id(new PHUIObjectBoxView()) ->setHeaderText($title) ->setFormErrors($errors) ->setBackground(PHUIObjectBoxView::WHITE_CONFIG) ->setForm($form); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $view = id(new PHUITwoColumnView()) ->setFooter($box); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/engineextension/PhabricatorPeopleDatasourceEngineExtension.php
src/applications/people/engineextension/PhabricatorPeopleDatasourceEngineExtension.php
<?php final class PhabricatorPeopleDatasourceEngineExtension extends PhabricatorDatasourceEngineExtension { public function newQuickSearchDatasources() { return array( new PhabricatorPeopleDatasource(), ); } public function newJumpURI($query) { $viewer = $this->getViewer(); // Send "u" to the user directory. if (preg_match('/^u\z/i', $query)) { return '/people/'; } // Send "u <string>" to the user's profile page. $matches = null; if (preg_match('/^u\s+(.+)\z/i', $query, $matches)) { $raw_query = $matches[1]; // TODO: We could test that this is a valid username and jump to // a search in the user directory if it isn't. return urisprintf( '/p/%s/', $raw_query); } 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/people/engineextension/PeopleHovercardEngineExtension.php
src/applications/people/engineextension/PeopleHovercardEngineExtension.php
<?php final class PeopleHovercardEngineExtension extends PhabricatorHovercardEngineExtension { const EXTENSIONKEY = 'people'; public function isExtensionEnabled() { return true; } public function getExtensionName() { return pht('User Accounts'); } public function canRenderObjectHovercard($object) { return ($object instanceof PhabricatorUser); } public function willRenderHovercards(array $objects) { $viewer = $this->getViewer(); $phids = mpull($objects, 'getPHID'); $users = id(new PhabricatorPeopleQuery()) ->setViewer($viewer) ->withPHIDs($phids) ->needAvailability(true) ->needProfileImage(true) ->needProfile(true) ->execute(); $users = mpull($users, null, 'getPHID'); return array( 'users' => $users, ); } public function renderHovercard( PHUIHovercardView $hovercard, PhabricatorObjectHandle $handle, $object, $data) { $viewer = $this->getViewer(); $user = idx($data['users'], $object->getPHID()); if (!$user) { return; } $is_exiled = $hovercard->getIsExiled(); $user_card = id(new PhabricatorUserCardView()) ->setProfile($user) ->setViewer($viewer) ->setIsExiled($is_exiled); $hovercard->appendChild($user_card); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/engineextension/PeopleMainMenuBarExtension.php
src/applications/people/engineextension/PeopleMainMenuBarExtension.php
<?php final class PeopleMainMenuBarExtension extends PhabricatorMainMenuBarExtension { const MAINMENUBARKEY = 'user'; public function isExtensionEnabledForViewer(PhabricatorUser $viewer) { return $viewer->isLoggedIn(); } public function shouldRequireFullSession() { return false; } public function getExtensionOrder() { return 1200; } public function buildMainMenus() { $viewer = $this->getViewer(); $application = $this->getApplication(); $dropdown_menu = $this->newDropdown($viewer, $application); $menu_id = celerity_generate_unique_node_id(); Javelin::initBehavior( 'user-menu', array( 'menuID' => $menu_id, 'menu' => $dropdown_menu->getDropdownMenuMetadata(), )); $image = $viewer->getProfileImageURI(); $profile_image = id(new PHUIIconView()) ->setImage($image) ->setHeadSize(PHUIIconView::HEAD_SMALL); $user_menu = id(new PHUIButtonView()) ->setID($menu_id) ->setTag('a') ->setHref('/p/'.$viewer->getUsername().'/') ->setIcon($profile_image) ->addClass('phabricator-core-user-menu') ->setHasCaret(true) ->setNoCSS(true) ->setAuralLabel(pht('Account Menu')); return array( $user_menu, ); } private function newDropdown( PhabricatorUser $viewer, $application) { $person_to_show = id(new PHUIObjectItemView()) ->setObjectName($viewer->getRealName()) ->setSubHead($viewer->getUsername()) ->setImageURI($viewer->getProfileImageURI()); $user_view = id(new PHUIObjectItemListView()) ->setViewer($viewer) ->setFlush(true) ->setSimple(true) ->addItem($person_to_show) ->addClass('phabricator-core-user-profile-object'); $view = id(new PhabricatorActionListView()) ->setViewer($viewer); if ($this->getIsFullSession()) { $view->addAction( id(new PhabricatorActionView()) ->appendChild($user_view)); $view->addAction( id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER)); $view->addAction( id(new PhabricatorActionView()) ->setName(pht('Profile')) ->setHref('/p/'.$viewer->getUsername().'/')); $view->addAction( id(new PhabricatorActionView()) ->setName(pht('Settings')) ->setHref('/settings/user/'.$viewer->getUsername().'/')); $view->addAction( id(new PhabricatorActionView()) ->setName(pht('Manage')) ->setHref('/people/manage/'.$viewer->getID().'/')); if ($application) { $help_links = $application->getHelpMenuItems($viewer); if ($help_links) { foreach ($help_links as $link) { $view->addAction($link); } } } $view->addAction( id(new PhabricatorActionView()) ->addSigil('logout-item') ->setType(PhabricatorActionView::TYPE_DIVIDER)); } $view->addAction( id(new PhabricatorActionView()) ->setName(pht('Log Out %s', $viewer->getUsername())) ->addSigil('logout-item') ->setHref('/logout/') ->setWorkflow(true)); 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/people/engineextension/PhabricatorPeopleAvailabilitySearchEngineAttachment.php
src/applications/people/engineextension/PhabricatorPeopleAvailabilitySearchEngineAttachment.php
<?php final class PhabricatorPeopleAvailabilitySearchEngineAttachment extends PhabricatorSearchEngineAttachment { public function getAttachmentName() { return pht('User Availability'); } public function getAttachmentDescription() { return pht('Get availability information for users.'); } public function willLoadAttachmentData($query, $spec) { $query->needAvailability(true); } public function getAttachmentForObject($object, $data, $spec) { $until = $object->getAwayUntil(); if ($until) { $until = (int)$until; } else { $until = null; } $value = $object->getDisplayAvailability(); if ($value === null) { $value = PhabricatorCalendarEventInvitee::AVAILABILITY_AVAILABLE; } $name = PhabricatorCalendarEventInvitee::getAvailabilityName($value); $color = PhabricatorCalendarEventInvitee::getAvailabilityColor($value); $event_phid = $object->getAvailabilityEventPHID(); return array( 'value' => $value, 'until' => $until, 'name' => $name, 'color' => $color, 'eventPHID' => $event_phid, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorReassignEmailUserLogType.php
src/applications/people/userlog/PhabricatorReassignEmailUserLogType.php
<?php final class PhabricatorReassignEmailUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'email-reassign'; public function getLogTypeName() { return pht('Email: Reassign'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorChangePasswordUserLogType.php
src/applications/people/userlog/PhabricatorChangePasswordUserLogType.php
<?php final class PhabricatorChangePasswordUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'change-password'; public function getLogTypeName() { return pht('Change Password'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorVerifyEmailUserLogType.php
src/applications/people/userlog/PhabricatorVerifyEmailUserLogType.php
<?php final class PhabricatorVerifyEmailUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'email-verify'; public function getLogTypeName() { return pht('Email: Verify Address'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorPartialLoginUserLogType.php
src/applications/people/userlog/PhabricatorPartialLoginUserLogType.php
<?php final class PhabricatorPartialLoginUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'login-partial'; public function getLogTypeName() { return pht('Login: Partial Login'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorRemoveMultifactorUserLogType.php
src/applications/people/userlog/PhabricatorRemoveMultifactorUserLogType.php
<?php final class PhabricatorRemoveMultifactorUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'multi-remove'; public function getLogTypeName() { return pht('Multi-Factor: Remove Factor'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorFailHisecUserLogType.php
src/applications/people/userlog/PhabricatorFailHisecUserLogType.php
<?php final class PhabricatorFailHisecUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'hisec-fail'; public function getLogTypeName() { return pht('Hisec: Failed Attempt'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorEnterHisecUserLogType.php
src/applications/people/userlog/PhabricatorEnterHisecUserLogType.php
<?php final class PhabricatorEnterHisecUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'hisec-enter'; public function getLogTypeName() { return pht('Hisec: Enter'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorFullLoginUserLogType.php
src/applications/people/userlog/PhabricatorFullLoginUserLogType.php
<?php final class PhabricatorFullLoginUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'login-full'; public function getLogTypeName() { return pht('Login: Upgrade to Full'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorLoginUserLogType.php
src/applications/people/userlog/PhabricatorLoginUserLogType.php
<?php final class PhabricatorLoginUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'login'; public function getLogTypeName() { return pht('Login'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorConduitCertificateFailureUserLogType.php
src/applications/people/userlog/PhabricatorConduitCertificateFailureUserLogType.php
<?php final class PhabricatorConduitCertificateFailureUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'conduit-cert-fail'; public function getLogTypeName() { return pht('Conduit: Read Certificate Failure'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorEmailLoginUserLogType.php
src/applications/people/userlog/PhabricatorEmailLoginUserLogType.php
<?php final class PhabricatorEmailLoginUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'email-login'; public function getLogTypeName() { return pht('Email: Recovery Link'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorAddEmailUserLogType.php
src/applications/people/userlog/PhabricatorAddEmailUserLogType.php
<?php final class PhabricatorAddEmailUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'email-add'; public function getLogTypeName() { return pht('Email: Add Address'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorLogoutUserLogType.php
src/applications/people/userlog/PhabricatorLogoutUserLogType.php
<?php final class PhabricatorLogoutUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'logout'; public function getLogTypeName() { return pht('Logout'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorUserLogType.php
src/applications/people/userlog/PhabricatorUserLogType.php
<?php abstract class PhabricatorUserLogType extends Phobject { final public function getLogTypeKey() { return $this->getPhobjectClassConstant('LOGTYPE', 32); } abstract public function getLogTypeName(); final public static function getAllLogTypes() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getLogTypeKey') ->execute(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorPrimaryEmailUserLogType.php
src/applications/people/userlog/PhabricatorPrimaryEmailUserLogType.php
<?php final class PhabricatorPrimaryEmailUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'email-primary'; public function getLogTypeName() { return pht('Email: Change Primary'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorLoginFailureUserLogType.php
src/applications/people/userlog/PhabricatorLoginFailureUserLogType.php
<?php final class PhabricatorLoginFailureUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'login-fail'; public function getLogTypeName() { return pht('Login: Failure'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorConduitCertificateUserLogType.php
src/applications/people/userlog/PhabricatorConduitCertificateUserLogType.php
<?php final class PhabricatorConduitCertificateUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'conduit-cert'; public function getLogTypeName() { return pht('Conduit: Read Certificate'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorResetPasswordUserLogType.php
src/applications/people/userlog/PhabricatorResetPasswordUserLogType.php
<?php final class PhabricatorResetPasswordUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'reset-pass'; public function getLogTypeName() { return pht('Reset Password'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorRemoveEmailUserLogType.php
src/applications/people/userlog/PhabricatorRemoveEmailUserLogType.php
<?php final class PhabricatorRemoveEmailUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'email-remove'; public function getLogTypeName() { return pht('Email: Remove Address'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorExitHisecUserLogType.php
src/applications/people/userlog/PhabricatorExitHisecUserLogType.php
<?php final class PhabricatorExitHisecUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'hisec-exit'; public function getLogTypeName() { return pht('Hisec: Exit'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorAddMultifactorUserLogType.php
src/applications/people/userlog/PhabricatorAddMultifactorUserLogType.php
<?php final class PhabricatorAddMultifactorUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'multi-add'; public function getLogTypeName() { return pht('Multi-Factor: Add Factor'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/userlog/PhabricatorSignDocumentsUserLogType.php
src/applications/people/userlog/PhabricatorSignDocumentsUserLogType.php
<?php final class PhabricatorSignDocumentsUserLogType extends PhabricatorUserLogType { const LOGTYPE = 'login-legalpad'; public function getLogTypeName() { return pht('Login: Signed Required Legalpad Documents'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserLog.php
src/applications/people/storage/PhabricatorUserLog.php
<?php final class PhabricatorUserLog extends PhabricatorUserDAO implements PhabricatorPolicyInterface { protected $actorPHID; protected $userPHID; protected $action; protected $oldValue; protected $newValue; protected $details = array(); protected $remoteAddr; protected $session; public static function initializeNewLog( PhabricatorUser $actor = null, $object_phid = null, $action = null) { $log = new PhabricatorUserLog(); if ($actor) { $log->setActorPHID($actor->getPHID()); if ($actor->hasSession()) { $session = $actor->getSession(); // NOTE: This is a hash of the real session value, so it's safe to // store it directly in the logs. $log->setSession($session->getSessionKey()); } } $log->setUserPHID((string)$object_phid); $log->setAction($action); $address = PhabricatorEnv::getRemoteAddress(); if ($address) { $log->remoteAddr = $address->getAddress(); } else { $log->remoteAddr = ''; } return $log; } public static function loadRecentEventsFromThisIP($action, $timespan) { $address = PhabricatorEnv::getRemoteAddress(); if (!$address) { return array(); } return id(new PhabricatorUserLog())->loadAllWhere( 'action = %s AND remoteAddr = %s AND dateCreated > %d ORDER BY dateCreated DESC', $action, $address->getAddress(), PhabricatorTime::getNow() - $timespan); } public function save() { $this->details['host'] = php_uname('n'); $this->details['user_agent'] = AphrontRequest::getHTTPHeader('User-Agent'); return parent::save(); } protected function getConfiguration() { return array( self::CONFIG_SERIALIZATION => array( 'oldValue' => self::SERIALIZATION_JSON, 'newValue' => self::SERIALIZATION_JSON, 'details' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'actorPHID' => 'phid?', 'action' => 'text64', 'remoteAddr' => 'text64', 'session' => 'text64?', ), self::CONFIG_KEY_SCHEMA => array( 'actorPHID' => array( 'columns' => array('actorPHID', 'dateCreated'), ), 'userPHID' => array( 'columns' => array('userPHID', 'dateCreated'), ), 'action' => array( 'columns' => array('action', 'dateCreated'), ), 'dateCreated' => array( 'columns' => array('dateCreated'), ), 'remoteAddr' => array( 'columns' => array('remoteAddr', 'dateCreated'), ), 'session' => array( 'columns' => array('session', 'dateCreated'), ), ), ) + parent::getConfiguration(); } public function getURI() { return urisprintf('/people/logs/%s/', $this->getID()); } public function getObjectName() { return pht('Activity Log %d', $this->getID()); } public function getRemoteAddressForViewer(PhabricatorUser $viewer) { $viewer_phid = $viewer->getPHID(); $actor_phid = $this->getActorPHID(); $user_phid = $this->getUserPHID(); if (!$viewer_phid) { $can_see_ip = false; } else if ($viewer->getIsAdmin()) { $can_see_ip = true; } else if ($viewer_phid == $actor_phid) { // You can see the address if you took the action. $can_see_ip = true; } else if (!$actor_phid && ($viewer_phid == $user_phid)) { // You can see the address if it wasn't authenticated and applied // to you (partial login). $can_see_ip = true; } else { // You can't see the address when an administrator disables your // account, since it's their address. $can_see_ip = false; } if (!$can_see_ip) { return null; } return $this->getRemoteAddr(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::POLICY_NOONE; } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { if ($viewer->getIsAdmin()) { return true; } $viewer_phid = $viewer->getPHID(); if ($viewer_phid) { $user_phid = $this->getUserPHID(); if ($viewer_phid == $user_phid) { return true; } $actor_phid = $this->getActorPHID(); if ($viewer_phid == $actor_phid) { return true; } } return false; } public function describeAutomaticCapability($capability) { return array( pht('Users can view their activity and activity that affects them.'), pht('Administrators can always view all activity.'), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorRegistrationProfile.php
src/applications/people/storage/PhabricatorRegistrationProfile.php
<?php final class PhabricatorRegistrationProfile extends Phobject { private $defaultUsername; private $defaultEmail; private $defaultRealName; private $canEditUsername; private $canEditEmail; private $canEditRealName; private $shouldVerifyEmail; public function setShouldVerifyEmail($should_verify_email) { $this->shouldVerifyEmail = $should_verify_email; return $this; } public function getShouldVerifyEmail() { return $this->shouldVerifyEmail; } public function setCanEditEmail($can_edit_email) { $this->canEditEmail = $can_edit_email; return $this; } public function getCanEditEmail() { return $this->canEditEmail; } public function setCanEditRealName($can_edit_real_name) { $this->canEditRealName = $can_edit_real_name; return $this; } public function getCanEditRealName() { return $this->canEditRealName; } public function setCanEditUsername($can_edit_username) { $this->canEditUsername = $can_edit_username; return $this; } public function getCanEditUsername() { return $this->canEditUsername; } public function setDefaultEmail($default_email) { $this->defaultEmail = $default_email; return $this; } public function getDefaultEmail() { return $this->defaultEmail; } public function setDefaultRealName($default_real_name) { $this->defaultRealName = $default_real_name; return $this; } public function getDefaultRealName() { return $this->defaultRealName; } public function setDefaultUsername($default_username) { $this->defaultUsername = $default_username; return $this; } public function getDefaultUsername() { return $this->defaultUsername; } public function getCanEditAnything() { return $this->getCanEditUsername() || $this->getCanEditEmail() || $this->getCanEditRealName(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserDAO.php
src/applications/people/storage/PhabricatorUserDAO.php
<?php abstract class PhabricatorUserDAO extends PhabricatorLiskDAO { public function getApplicationName() { return 'user'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorExternalAccountIdentifier.php
src/applications/people/storage/PhabricatorExternalAccountIdentifier.php
<?php final class PhabricatorExternalAccountIdentifier extends PhabricatorUserDAO implements PhabricatorPolicyInterface, PhabricatorDestructibleInterface { protected $externalAccountPHID; protected $providerConfigPHID; protected $identifierHash; protected $identifierRaw; public function getPHIDType() { return PhabricatorPeopleExternalIdentifierPHIDType::TYPECONST; } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'identifierHash' => 'bytes12', 'identifierRaw' => 'text', ), self::CONFIG_KEY_SCHEMA => array( 'key_identifier' => array( 'columns' => array('providerConfigPHID', 'identifierHash'), 'unique' => true, ), 'key_account' => array( 'columns' => array('externalAccountPHID'), ), ), ) + parent::getConfiguration(); } public function save() { $identifier_raw = $this->getIdentifierRaw(); $identifier_hash = PhabricatorHash::digestForIndex($identifier_raw); $this->setIdentifierHash($identifier_hash); return parent::save(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ // TODO: These permissions aren't very good. They should just be the same // as the associated ExternalAccount. See T13381. public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::getMostOpenPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return PhabricatorPolicies::POLICY_NOONE; } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->delete(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserConfiguredCustomFieldStorage.php
src/applications/people/storage/PhabricatorUserConfiguredCustomFieldStorage.php
<?php final class PhabricatorUserConfiguredCustomFieldStorage extends PhabricatorCustomFieldStorage { public function getApplicationName() { return 'user'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserTransaction.php
src/applications/people/storage/PhabricatorUserTransaction.php
<?php final class PhabricatorUserTransaction extends PhabricatorModularTransaction { public function getApplicationName() { return 'user'; } public function getApplicationTransactionType() { return PhabricatorPeopleUserPHIDType::TYPECONST; } public function getBaseTransactionClass() { return 'PhabricatorUserTransactionType'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserSchemaSpec.php
src/applications/people/storage/PhabricatorUserSchemaSpec.php
<?php final class PhabricatorUserSchemaSpec extends PhabricatorConfigSchemaSpec { public function buildSchemata() { $this->buildEdgeSchemata(new PhabricatorUser()); $this->buildRawSchema( id(new PhabricatorUser())->getApplicationName(), PhabricatorUser::NAMETOKEN_TABLE, array( 'token' => 'sort255', 'userID' => 'id', ), array( 'token' => array( 'columns' => array('token(128)'), ), 'userID' => array( 'columns' => array('userID'), ), )); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserEmail.php
src/applications/people/storage/PhabricatorUserEmail.php
<?php /** * @task restrictions Domain Restrictions * @task email Email About Email */ final class PhabricatorUserEmail extends PhabricatorUserDAO implements PhabricatorDestructibleInterface, PhabricatorPolicyInterface { protected $userPHID; protected $address; protected $isVerified; protected $isPrimary; protected $verificationCode; private $user = self::ATTACHABLE; const MAX_ADDRESS_LENGTH = 128; protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'address' => 'sort128', 'isVerified' => 'bool', 'isPrimary' => 'bool', 'verificationCode' => 'text64?', ), self::CONFIG_KEY_SCHEMA => array( 'address' => array( 'columns' => array('address'), 'unique' => true, ), 'userPHID' => array( 'columns' => array('userPHID', 'isPrimary'), ), ), ) + parent::getConfiguration(); } public function getPHIDType() { return PhabricatorPeopleUserEmailPHIDType::TYPECONST; } public function getVerificationURI() { return '/emailverify/'.$this->getVerificationCode().'/'; } public function save() { if (!$this->verificationCode) { $this->setVerificationCode(Filesystem::readRandomCharacters(24)); } return parent::save(); } public function attachUser(PhabricatorUser $user) { $this->user = $user; return $this; } public function getUser() { return $this->assertAttached($this->user); } /* -( Domain Restrictions )------------------------------------------------ */ /** * @task restrictions */ public static function isValidAddress($address) { if (strlen($address) > self::MAX_ADDRESS_LENGTH) { return false; } // Very roughly validate that this address isn't so mangled that a // reasonable piece of code might completely misparse it. In particular, // the major risks are: // // - `PhutilEmailAddress` needs to be able to extract the domain portion // from it. // - Reasonable mail adapters should be hard-pressed to interpret one // address as several addresses. // // To this end, we're roughly verifying that there's some normal text, an // "@" symbol, and then some more normal text. $email_regex = '(^[a-z0-9_+.!-]+@[a-z0-9_+:.-]+\z)i'; if (!preg_match($email_regex, $address)) { return false; } return true; } /** * @task restrictions */ public static function describeValidAddresses() { return pht( 'Email addresses should be in the form "user@domain.com". The maximum '. 'length of an email address is %s characters.', new PhutilNumber(self::MAX_ADDRESS_LENGTH)); } /** * @task restrictions */ public static function isAllowedAddress($address) { if (!self::isValidAddress($address)) { return false; } $allowed_domains = PhabricatorEnv::getEnvConfig('auth.email-domains'); if (!$allowed_domains) { return true; } $addr_obj = new PhutilEmailAddress($address); $domain = $addr_obj->getDomainName(); if (!$domain) { return false; } $lower_domain = phutil_utf8_strtolower($domain); foreach ($allowed_domains as $allowed_domain) { $lower_allowed = phutil_utf8_strtolower($allowed_domain); if ($lower_allowed === $lower_domain) { return true; } } return false; } /** * @task restrictions */ public static function describeAllowedAddresses() { $domains = PhabricatorEnv::getEnvConfig('auth.email-domains'); if (!$domains) { return null; } if (count($domains) == 1) { return pht('Email address must be @%s', head($domains)); } else { return pht( 'Email address must be at one of: %s', implode(', ', $domains)); } } /** * Check if this install requires email verification. * * @return bool True if email addresses must be verified. * * @task restrictions */ public static function isEmailVerificationRequired() { // NOTE: Configuring required email domains implies required verification. return PhabricatorEnv::getEnvConfig('auth.require-email-verification') || PhabricatorEnv::getEnvConfig('auth.email-domains'); } /* -( Email About Email )-------------------------------------------------- */ /** * Send a verification email from $user to this address. * * @param PhabricatorUser The user sending the verification. * @return this * @task email */ public function sendVerificationEmail(PhabricatorUser $user) { $username = $user->getUsername(); $address = $this->getAddress(); $link = PhabricatorEnv::getProductionURI($this->getVerificationURI()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $signature = null; if (!$is_serious) { $signature = pht( "Get Well Soon,\n%s", PlatformSymbols::getPlatformServerName()); } $body = sprintf( "%s\n\n%s\n\n %s\n\n%s", pht('Hi %s', $username), pht( 'Please verify that you own this email address (%s) by '. 'clicking this link:', $address), $link, $signature); id(new PhabricatorMetaMTAMail()) ->addRawTos(array($address)) ->setForceDelivery(true) ->setSubject( pht( '[%s] Email Verification', PlatformSymbols::getPlatformServerName())) ->setBody($body) ->setRelatedPHID($user->getPHID()) ->saveAndSend(); return $this; } /** * Send a notification email from $user to this address, informing the * recipient that this is no longer their account's primary address. * * @param PhabricatorUser The user sending the notification. * @param PhabricatorUserEmail New primary email address. * @return this * @task email */ public function sendOldPrimaryEmail( PhabricatorUser $user, PhabricatorUserEmail $new) { $username = $user->getUsername(); $old_address = $this->getAddress(); $new_address = $new->getAddress(); $body = sprintf( "%s\n\n%s\n", pht('Hi %s', $username), pht( 'This email address (%s) is no longer your primary email address. '. 'Going forward, all email will be sent to your new primary email '. 'address (%s).', $old_address, $new_address)); id(new PhabricatorMetaMTAMail()) ->addRawTos(array($old_address)) ->setForceDelivery(true) ->setSubject( pht( '[%s] Primary Address Changed', PlatformSymbols::getPlatformServerName())) ->setBody($body) ->setFrom($user->getPHID()) ->setRelatedPHID($user->getPHID()) ->saveAndSend(); } /** * Send a notification email from $user to this address, informing the * recipient that this is now their account's new primary email address. * * @param PhabricatorUser The user sending the verification. * @return this * @task email */ public function sendNewPrimaryEmail(PhabricatorUser $user) { $username = $user->getUsername(); $new_address = $this->getAddress(); $body = sprintf( "%s\n\n%s\n", pht('Hi %s', $username), pht( 'This is now your primary email address (%s). Going forward, '. 'all email will be sent here.', $new_address)); id(new PhabricatorMetaMTAMail()) ->addRawTos(array($new_address)) ->setForceDelivery(true) ->setSubject( pht( '[%s] Primary Address Changed', PlatformSymbols::getPlatformServerName())) ->setBody($body) ->setFrom($user->getPHID()) ->setRelatedPHID($user->getPHID()) ->saveAndSend(); return $this; } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->delete(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { $user = $this->getUser(); if ($this->getIsSystemAgent() || $this->getIsMailingList()) { return PhabricatorPolicies::POLICY_ADMIN; } return $user->getPHID(); } 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/people/storage/PhabricatorUser.php
src/applications/people/storage/PhabricatorUser.php
<?php /** * @task availability Availability * @task image-cache Profile Image Cache * @task factors Multi-Factor Authentication * @task handles Managing Handles * @task settings Settings * @task cache User Cache */ final class PhabricatorUser extends PhabricatorUserDAO implements PhutilPerson, PhabricatorPolicyInterface, PhabricatorCustomFieldInterface, PhabricatorDestructibleInterface, PhabricatorSSHPublicKeyInterface, PhabricatorFlaggableInterface, PhabricatorApplicationTransactionInterface, PhabricatorFulltextInterface, PhabricatorFerretInterface, PhabricatorConduitResultInterface, PhabricatorAuthPasswordHashInterface { const SESSION_TABLE = 'phabricator_session'; const NAMETOKEN_TABLE = 'user_nametoken'; const MAXIMUM_USERNAME_LENGTH = 64; protected $userName; protected $realName; protected $profileImagePHID; protected $defaultProfileImagePHID; protected $defaultProfileImageVersion; protected $availabilityCache; protected $availabilityCacheTTL; protected $conduitCertificate; protected $isSystemAgent = 0; protected $isMailingList = 0; protected $isAdmin = 0; protected $isDisabled = 0; protected $isEmailVerified = 0; protected $isApproved = 0; protected $isEnrolledInMultiFactor = 0; protected $accountSecret; private $profile = null; private $availability = self::ATTACHABLE; private $preferences = null; private $omnipotent = false; private $customFields = self::ATTACHABLE; private $badgePHIDs = self::ATTACHABLE; private $alternateCSRFString = self::ATTACHABLE; private $session = self::ATTACHABLE; private $rawCacheData = array(); private $usableCacheData = array(); private $handlePool; private $csrfSalt; private $settingCacheKeys = array(); private $settingCache = array(); private $allowInlineCacheGeneration; private $conduitClusterToken = self::ATTACHABLE; protected function readField($field) { switch ($field) { // Make sure these return booleans. case 'isAdmin': return (bool)$this->isAdmin; case 'isDisabled': return (bool)$this->isDisabled; case 'isSystemAgent': return (bool)$this->isSystemAgent; case 'isMailingList': return (bool)$this->isMailingList; case 'isEmailVerified': return (bool)$this->isEmailVerified; case 'isApproved': return (bool)$this->isApproved; default: return parent::readField($field); } } /** * Is this a live account which has passed required approvals? Returns true * if this is an enabled, verified (if required), approved (if required) * account, and false otherwise. * * @return bool True if this is a standard, usable account. */ public function isUserActivated() { if (!$this->isLoggedIn()) { return false; } if ($this->isOmnipotent()) { return true; } if ($this->getIsDisabled()) { return false; } if (!$this->getIsApproved()) { return false; } if (PhabricatorUserEmail::isEmailVerificationRequired()) { if (!$this->getIsEmailVerified()) { return false; } } return true; } /** * Is this a user who we can reasonably expect to respond to requests? * * This is used to provide a grey "disabled/unresponsive" dot cue when * rendering handles and tags, so it isn't a surprise if you get ignored * when you ask things of users who will not receive notifications or could * not respond to them (because they are disabled, unapproved, do not have * verified email addresses, etc). * * @return bool True if this user can receive and respond to requests from * other humans. */ public function isResponsive() { if (!$this->isUserActivated()) { return false; } if (!$this->getIsEmailVerified()) { return false; } return true; } public function canEstablishWebSessions() { if ($this->getIsMailingList()) { return false; } if ($this->getIsSystemAgent()) { return false; } return true; } public function canEstablishAPISessions() { if ($this->getIsDisabled()) { return false; } // Intracluster requests are permitted even if the user is logged out: // in particular, public users are allowed to issue intracluster requests // when browsing Diffusion. if (PhabricatorEnv::isClusterRemoteAddress()) { if (!$this->isLoggedIn()) { return true; } } if (!$this->isUserActivated()) { return false; } if ($this->getIsMailingList()) { return false; } return true; } public function canEstablishSSHSessions() { if (!$this->isUserActivated()) { return false; } if ($this->getIsMailingList()) { return false; } return true; } /** * Returns `true` if this is a standard user who is logged in. Returns `false` * for logged out, anonymous, or external users. * * @return bool `true` if the user is a standard user who is logged in with * a normal session. */ public function getIsStandardUser() { $type_user = PhabricatorPeopleUserPHIDType::TYPECONST; return $this->getPHID() && (phid_get_type($this->getPHID()) == $type_user); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'userName' => 'sort64', 'realName' => 'text128', 'profileImagePHID' => 'phid?', 'conduitCertificate' => 'text255', 'isSystemAgent' => 'bool', 'isMailingList' => 'bool', 'isDisabled' => 'bool', 'isAdmin' => 'bool', 'isEmailVerified' => 'uint32', 'isApproved' => 'uint32', 'accountSecret' => 'bytes64', 'isEnrolledInMultiFactor' => 'bool', 'availabilityCache' => 'text255?', 'availabilityCacheTTL' => 'uint32?', 'defaultProfileImagePHID' => 'phid?', 'defaultProfileImageVersion' => 'text64?', ), self::CONFIG_KEY_SCHEMA => array( 'key_phid' => null, 'phid' => array( 'columns' => array('phid'), 'unique' => true, ), 'userName' => array( 'columns' => array('userName'), 'unique' => true, ), 'realName' => array( 'columns' => array('realName'), ), 'key_approved' => array( 'columns' => array('isApproved'), ), ), self::CONFIG_NO_MUTATE => array( 'availabilityCache' => true, 'availabilityCacheTTL' => true, ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorPeopleUserPHIDType::TYPECONST); } public function getMonogram() { return '@'.$this->getUsername(); } public function isLoggedIn() { return !($this->getPHID() === null); } public function saveWithoutIndex() { return parent::save(); } public function save() { if (!$this->getConduitCertificate()) { $this->setConduitCertificate($this->generateConduitCertificate()); } $secret = $this->getAccountSecret(); if (($secret === null) || !strlen($secret)) { $this->setAccountSecret(Filesystem::readRandomCharacters(64)); } $result = $this->saveWithoutIndex(); if ($this->profile) { $this->profile->save(); } $this->updateNameTokens(); PhabricatorSearchWorker::queueDocumentForIndexing($this->getPHID()); return $result; } public function attachSession(PhabricatorAuthSession $session) { $this->session = $session; return $this; } public function getSession() { return $this->assertAttached($this->session); } public function hasSession() { return ($this->session !== self::ATTACHABLE); } public function hasHighSecuritySession() { if (!$this->hasSession()) { return false; } return $this->getSession()->isHighSecuritySession(); } private function generateConduitCertificate() { return Filesystem::readRandomCharacters(255); } const EMAIL_CYCLE_FREQUENCY = 86400; const EMAIL_TOKEN_LENGTH = 24; public function getUserProfile() { return $this->assertAttached($this->profile); } public function attachUserProfile(PhabricatorUserProfile $profile) { $this->profile = $profile; return $this; } public function loadUserProfile() { if ($this->profile) { return $this->profile; } $profile_dao = new PhabricatorUserProfile(); $this->profile = $profile_dao->loadOneWhere('userPHID = %s', $this->getPHID()); if (!$this->profile) { $this->profile = PhabricatorUserProfile::initializeNewProfile($this); } return $this->profile; } public function loadPrimaryEmailAddress() { $email = $this->loadPrimaryEmail(); if (!$email) { throw new Exception(pht('User has no primary email address!')); } return $email->getAddress(); } public function loadPrimaryEmail() { return id(new PhabricatorUserEmail())->loadOneWhere( 'userPHID = %s AND isPrimary = 1', $this->getPHID()); } /* -( Settings )----------------------------------------------------------- */ public function getUserSetting($key) { // NOTE: We store available keys and cached values separately to make it // faster to check for `null` in the cache, which is common. if (isset($this->settingCacheKeys[$key])) { return $this->settingCache[$key]; } $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; if ($this->getPHID()) { $settings = $this->requireCacheData($settings_key); } else { $settings = $this->loadGlobalSettings(); } if (array_key_exists($key, $settings)) { $value = $settings[$key]; return $this->writeUserSettingCache($key, $value); } $cache = PhabricatorCaches::getRuntimeCache(); $cache_key = "settings.defaults({$key})"; $cache_map = $cache->getKeys(array($cache_key)); if ($cache_map) { $value = $cache_map[$cache_key]; } else { $defaults = PhabricatorSetting::getAllSettings(); if (isset($defaults[$key])) { $value = id(clone $defaults[$key]) ->setViewer($this) ->getSettingDefaultValue(); } else { $value = null; } $cache->setKey($cache_key, $value); } return $this->writeUserSettingCache($key, $value); } /** * Test if a given setting is set to a particular value. * * @param const Setting key. * @param wild Value to compare. * @return bool True if the setting has the specified value. * @task settings */ public function compareUserSetting($key, $value) { $actual = $this->getUserSetting($key); return ($actual == $value); } private function writeUserSettingCache($key, $value) { $this->settingCacheKeys[$key] = true; $this->settingCache[$key] = $value; return $value; } public function getTranslation() { return $this->getUserSetting(PhabricatorTranslationSetting::SETTINGKEY); } public function getTimezoneIdentifier() { return $this->getUserSetting(PhabricatorTimezoneSetting::SETTINGKEY); } public static function getGlobalSettingsCacheKey() { return 'user.settings.globals.v1'; } private function loadGlobalSettings() { $cache_key = self::getGlobalSettingsCacheKey(); $cache = PhabricatorCaches::getMutableStructureCache(); $settings = $cache->getKey($cache_key); if (!$settings) { $preferences = PhabricatorUserPreferences::loadGlobalPreferences($this); $settings = $preferences->getPreferences(); $cache->setKey($cache_key, $settings); } return $settings; } /** * Override the user's timezone identifier. * * This is primarily useful for unit tests. * * @param string New timezone identifier. * @return this * @task settings */ public function overrideTimezoneIdentifier($identifier) { $timezone_key = PhabricatorTimezoneSetting::SETTINGKEY; $this->settingCacheKeys[$timezone_key] = true; $this->settingCache[$timezone_key] = $identifier; return $this; } public function getGender() { return $this->getUserSetting(PhabricatorPronounSetting::SETTINGKEY); } /** * Populate the nametoken table, which used to fetch typeahead results. When * a user types "linc", we want to match "Abraham Lincoln" from on-demand * typeahead sources. To do this, we need a separate table of name fragments. */ public function updateNameTokens() { $table = self::NAMETOKEN_TABLE; $conn_w = $this->establishConnection('w'); $tokens = PhabricatorTypeaheadDatasource::tokenizeString( $this->getUserName().' '.$this->getRealName()); $sql = array(); foreach ($tokens as $token) { $sql[] = qsprintf( $conn_w, '(%d, %s)', $this->getID(), $token); } queryfx( $conn_w, 'DELETE FROM %T WHERE userID = %d', $table, $this->getID()); if ($sql) { queryfx( $conn_w, 'INSERT INTO %T (userID, token) VALUES %LQ', $table, $sql); } } public static function describeValidUsername() { return pht( 'Usernames must contain only numbers, letters, period, underscore, and '. 'hyphen, and can not end with a period. They must have no more than %d '. 'characters.', new PhutilNumber(self::MAXIMUM_USERNAME_LENGTH)); } public static function validateUsername($username) { // NOTE: If you update this, make sure to update: // // - Remarkup rule for @mentions. // - Routing rule for "/p/username/". // - Unit tests, obviously. // - describeValidUsername() method, above. if (strlen($username) > self::MAXIMUM_USERNAME_LENGTH) { return false; } return (bool)preg_match('/^[a-zA-Z0-9._-]*[a-zA-Z0-9_-]\z/', $username); } public static function getDefaultProfileImageURI() { return celerity_get_resource_uri('/rsrc/image/avatar.png'); } public function getProfileImageURI() { $uri_key = PhabricatorUserProfileImageCacheType::KEY_URI; return $this->requireCacheData($uri_key); } public function getUnreadNotificationCount() { $notification_key = PhabricatorUserNotificationCountCacheType::KEY_COUNT; return $this->requireCacheData($notification_key); } public function getUnreadMessageCount() { $message_key = PhabricatorUserMessageCountCacheType::KEY_COUNT; return $this->requireCacheData($message_key); } public function getRecentBadgeAwards() { $badges_key = PhabricatorUserBadgesCacheType::KEY_BADGES; return $this->requireCacheData($badges_key); } public function getFullName() { if (strlen($this->getRealName())) { return $this->getUsername().' ('.$this->getRealName().')'; } else { return $this->getUsername(); } } public function getTimeZone() { return new DateTimeZone($this->getTimezoneIdentifier()); } public function getTimeZoneOffset() { $timezone = $this->getTimeZone(); $now = new DateTime('@'.PhabricatorTime::getNow()); $offset = $timezone->getOffset($now); // Javascript offsets are in minutes and have the opposite sign. $offset = -(int)($offset / 60); return $offset; } public function getTimeZoneOffsetInHours() { $offset = $this->getTimeZoneOffset(); $offset = (int)round($offset / 60); $offset = -$offset; return $offset; } public function formatShortDateTime($when, $now = null) { if ($now === null) { $now = PhabricatorTime::getNow(); } try { $when = new DateTime('@'.$when); $now = new DateTime('@'.$now); } catch (Exception $ex) { return null; } $zone = $this->getTimeZone(); $when->setTimeZone($zone); $now->setTimeZone($zone); if ($when->format('Y') !== $now->format('Y')) { // Different year, so show "Feb 31 2075". $format = 'M j Y'; } else if ($when->format('Ymd') !== $now->format('Ymd')) { // Same year but different month and day, so show "Feb 31". $format = 'M j'; } else { // Same year, month and day so show a time of day. $pref_time = PhabricatorTimeFormatSetting::SETTINGKEY; $format = $this->getUserSetting($pref_time); } return $when->format($format); } public function __toString() { return $this->getUsername(); } public static function loadOneWithEmailAddress($address) { $email = id(new PhabricatorUserEmail())->loadOneWhere( 'address = %s', $address); if (!$email) { return null; } return id(new PhabricatorUser())->loadOneWhere( 'phid = %s', $email->getUserPHID()); } public function getDefaultSpacePHID() { // TODO: We might let the user switch which space they're "in" later on; // for now just use the global space if one exists. // If the viewer has access to the default space, use that. $spaces = PhabricatorSpacesNamespaceQuery::getViewerActiveSpaces($this); foreach ($spaces as $space) { if ($space->getIsDefaultNamespace()) { return $space->getPHID(); } } // Otherwise, use the space with the lowest ID that they have access to. // This just tends to keep the default stable and predictable over time, // so adding a new space won't change behavior for users. if ($spaces) { $spaces = msort($spaces, 'getID'); return head($spaces)->getPHID(); } return null; } public function hasConduitClusterToken() { return ($this->conduitClusterToken !== self::ATTACHABLE); } public function attachConduitClusterToken(PhabricatorConduitToken $token) { $this->conduitClusterToken = $token; return $this; } public function getConduitClusterToken() { return $this->assertAttached($this->conduitClusterToken); } /* -( Availability )------------------------------------------------------- */ /** * @task availability */ public function attachAvailability(array $availability) { $this->availability = $availability; return $this; } /** * Get the timestamp the user is away until, if they are currently away. * * @return int|null Epoch timestamp, or `null` if the user is not away. * @task availability */ public function getAwayUntil() { $availability = $this->availability; $this->assertAttached($availability); if (!$availability) { return null; } return idx($availability, 'until'); } public function getDisplayAvailability() { $availability = $this->availability; $this->assertAttached($availability); if (!$availability) { return null; } $busy = PhabricatorCalendarEventInvitee::AVAILABILITY_BUSY; return idx($availability, 'availability', $busy); } public function getAvailabilityEventPHID() { $availability = $this->availability; $this->assertAttached($availability); if (!$availability) { return null; } return idx($availability, 'eventPHID'); } /** * Get cached availability, if present. * * @return wild|null Cache data, or null if no cache is available. * @task availability */ public function getAvailabilityCache() { $now = PhabricatorTime::getNow(); if ($this->availabilityCacheTTL <= $now) { return null; } try { return phutil_json_decode($this->availabilityCache); } catch (Exception $ex) { return null; } } /** * Write to the availability cache. * * @param wild Availability cache data. * @param int|null Cache TTL. * @return this * @task availability */ public function writeAvailabilityCache(array $availability, $ttl) { if (PhabricatorEnv::isReadOnly()) { return $this; } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $this->establishConnection('w'), 'UPDATE %T SET availabilityCache = %s, availabilityCacheTTL = %nd WHERE id = %d', $this->getTableName(), phutil_json_encode($availability), $ttl, $this->getID()); unset($unguarded); return $this; } /* -( Multi-Factor Authentication )---------------------------------------- */ /** * Update the flag storing this user's enrollment in multi-factor auth. * * With certain settings, we need to check if a user has MFA on every page, * so we cache MFA enrollment on the user object for performance. Calling this * method synchronizes the cache by examining enrollment records. After * updating the cache, use @{method:getIsEnrolledInMultiFactor} to check if * the user is enrolled. * * This method should be called after any changes are made to a given user's * multi-factor configuration. * * @return void * @task factors */ public function updateMultiFactorEnrollment() { $factors = id(new PhabricatorAuthFactorConfigQuery()) ->setViewer($this) ->withUserPHIDs(array($this->getPHID())) ->withFactorProviderStatuses( array( PhabricatorAuthFactorProviderStatus::STATUS_ACTIVE, PhabricatorAuthFactorProviderStatus::STATUS_DEPRECATED, )) ->execute(); $enrolled = count($factors) ? 1 : 0; if ($enrolled !== $this->isEnrolledInMultiFactor) { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $this->establishConnection('w'), 'UPDATE %T SET isEnrolledInMultiFactor = %d WHERE id = %d', $this->getTableName(), $enrolled, $this->getID()); unset($unguarded); $this->isEnrolledInMultiFactor = $enrolled; } } /** * Check if the user is enrolled in multi-factor authentication. * * Enrolled users have one or more multi-factor authentication sources * attached to their account. For performance, this value is cached. You * can use @{method:updateMultiFactorEnrollment} to update the cache. * * @return bool True if the user is enrolled. * @task factors */ public function getIsEnrolledInMultiFactor() { return $this->isEnrolledInMultiFactor; } /* -( Omnipotence )-------------------------------------------------------- */ /** * Returns true if this user is omnipotent. Omnipotent users bypass all policy * checks. * * @return bool True if the user bypasses policy checks. */ public function isOmnipotent() { return $this->omnipotent; } /** * Get an omnipotent user object for use in contexts where there is no acting * user, notably daemons. * * @return PhabricatorUser An omnipotent user. */ public static function getOmnipotentUser() { static $user = null; if (!$user) { $user = new PhabricatorUser(); $user->omnipotent = true; $user->makeEphemeral(); } return $user; } /** * Get a scalar string identifying this user. * * This is similar to using the PHID, but distinguishes between omnipotent * and public users explicitly. This allows safe construction of cache keys * or cache buckets which do not conflate public and omnipotent users. * * @return string Scalar identifier. */ public function getCacheFragment() { if ($this->isOmnipotent()) { return 'u.omnipotent'; } $phid = $this->getPHID(); if ($phid) { return 'u.'.$phid; } return 'u.public'; } /* -( Managing Handles )--------------------------------------------------- */ /** * Get a @{class:PhabricatorHandleList} which benefits from this viewer's * internal handle pool. * * @param list<phid> List of PHIDs to load. * @return PhabricatorHandleList Handle list object. * @task handle */ public function loadHandles(array $phids) { if ($this->handlePool === null) { $this->handlePool = id(new PhabricatorHandlePool()) ->setViewer($this); } return $this->handlePool->newHandleList($phids); } /** * Get a @{class:PHUIHandleView} for a single handle. * * This benefits from the viewer's internal handle pool. * * @param phid PHID to render a handle for. * @return PHUIHandleView View of the handle. * @task handle */ public function renderHandle($phid) { return $this->loadHandles(array($phid))->renderHandle($phid); } /** * Get a @{class:PHUIHandleListView} for a list of handles. * * This benefits from the viewer's internal handle pool. * * @param list<phid> List of PHIDs to render. * @return PHUIHandleListView View of the handles. * @task handle */ public function renderHandleList(array $phids) { return $this->loadHandles($phids)->renderList(); } public function attachBadgePHIDs(array $phids) { $this->badgePHIDs = $phids; return $this; } public function getBadgePHIDs() { return $this->assertAttached($this->badgePHIDs); } /* -( CSRF )--------------------------------------------------------------- */ public function getCSRFToken() { if ($this->isOmnipotent()) { // We may end up here when called from the daemons. The omnipotent user // has no meaningful CSRF token, so just return `null`. return null; } return $this->newCSRFEngine() ->newToken(); } public function validateCSRFToken($token) { return $this->newCSRFengine() ->isValidToken($token); } public function getAlternateCSRFString() { return $this->assertAttached($this->alternateCSRFString); } public function attachAlternateCSRFString($string) { $this->alternateCSRFString = $string; return $this; } private function newCSRFEngine() { if ($this->getPHID()) { $vec = $this->getPHID().$this->getAccountSecret(); } else { $vec = $this->getAlternateCSRFString(); } if ($this->hasSession()) { $vec = $vec.$this->getSession()->getSessionKey(); } $engine = new PhabricatorAuthCSRFEngine(); if ($this->csrfSalt === null) { $this->csrfSalt = $engine->newSalt(); } $engine ->setSalt($this->csrfSalt) ->setSecret(new PhutilOpaqueEnvelope($vec)); return $engine; } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::POLICY_PUBLIC; case PhabricatorPolicyCapability::CAN_EDIT: if ($this->getIsSystemAgent() || $this->getIsMailingList()) { return PhabricatorPolicies::POLICY_ADMIN; } else { return PhabricatorPolicies::POLICY_NOONE; } } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return $this->getPHID() && ($viewer->getPHID() === $this->getPHID()); } public function describeAutomaticCapability($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_EDIT: return pht('Only you can edit your information.'); default: return null; } } /* -( PhabricatorCustomFieldInterface )------------------------------------ */ public function getCustomFieldSpecificationForRole($role) { return PhabricatorEnv::getEnvConfig('user.fields'); } public function getCustomFieldBaseClass() { return 'PhabricatorUserCustomField'; } public function getCustomFields() { return $this->assertAttached($this->customFields); } public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { $this->customFields = $fields; return $this; } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $viewer = $engine->getViewer(); $this->openTransaction(); $this->delete(); $externals = id(new PhabricatorExternalAccountQuery()) ->setViewer($viewer) ->withUserPHIDs(array($this->getPHID())) ->newIterator(); foreach ($externals as $external) { $engine->destroyObject($external); } $prefs = id(new PhabricatorUserPreferencesQuery()) ->setViewer($viewer) ->withUsers(array($this)) ->execute(); foreach ($prefs as $pref) { $engine->destroyObject($pref); } $profiles = id(new PhabricatorUserProfile())->loadAllWhere( 'userPHID = %s', $this->getPHID()); foreach ($profiles as $profile) { $profile->delete(); } $keys = id(new PhabricatorAuthSSHKeyQuery()) ->setViewer($viewer) ->withObjectPHIDs(array($this->getPHID())) ->execute(); foreach ($keys as $key) { $engine->destroyObject($key); } $emails = id(new PhabricatorUserEmail())->loadAllWhere( 'userPHID = %s', $this->getPHID()); foreach ($emails as $email) { $engine->destroyObject($email); } $sessions = id(new PhabricatorAuthSession())->loadAllWhere( 'userPHID = %s', $this->getPHID()); foreach ($sessions as $session) { $session->delete(); } $factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere( 'userPHID = %s', $this->getPHID()); foreach ($factors as $factor) { $factor->delete(); } $this->saveTransaction(); } /* -( PhabricatorSSHPublicKeyInterface )----------------------------------- */ public function getSSHPublicKeyManagementURI(PhabricatorUser $viewer) { if ($viewer->getPHID() == $this->getPHID()) { // If the viewer is managing their own keys, take them to the normal // panel. return '/settings/panel/ssh/'; } else { // Otherwise, take them to the administrative panel for this user. return '/settings/user/'.$this->getUsername().'/page/ssh/'; } } public function getSSHKeyDefaultName() { return 'id_rsa_phabricator'; } public function getSSHKeyNotifyPHIDs() { return array( $this->getPHID(), ); } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new PhabricatorUserTransactionEditor(); } public function getApplicationTransactionTemplate() { return new PhabricatorUserTransaction(); } /* -( PhabricatorFulltextInterface )--------------------------------------- */ public function newFulltextEngine() { return new PhabricatorUserFulltextEngine(); } /* -( PhabricatorFerretInterface )----------------------------------------- */ public function newFerretEngine() { return new PhabricatorUserFerretEngine(); } /* -( PhabricatorConduitResultInterface )---------------------------------- */ public function getFieldSpecificationsForConduit() { return array( id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('username') ->setType('string') ->setDescription(pht("The user's username.")), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('realName') ->setType('string') ->setDescription(pht("The user's real name.")), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('roles') ->setType('list<string>') ->setDescription(pht('List of account roles.')), ); } public function getFieldValuesForConduit() { $roles = array(); if ($this->getIsDisabled()) { $roles[] = 'disabled'; } if ($this->getIsSystemAgent()) { $roles[] = 'bot'; } if ($this->getIsMailingList()) { $roles[] = 'list'; } if ($this->getIsAdmin()) { $roles[] = 'admin'; } if ($this->getIsEmailVerified()) { $roles[] = 'verified'; } if ($this->getIsApproved()) { $roles[] = 'approved'; } if ($this->isUserActivated()) { $roles[] = 'activated'; } return array( 'username' => $this->getUsername(), 'realName' => $this->getRealName(), 'roles' => $roles, ); } public function getConduitSearchAttachments() { return array( id(new PhabricatorPeopleAvailabilitySearchEngineAttachment()) ->setAttachmentKey('availability'), ); }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
true
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserCache.php
src/applications/people/storage/PhabricatorUserCache.php
<?php final class PhabricatorUserCache extends PhabricatorUserDAO { protected $userPHID; protected $cacheIndex; protected $cacheKey; protected $cacheData; protected $cacheType; protected function getConfiguration() { return array( self::CONFIG_TIMESTAMPS => false, self::CONFIG_COLUMN_SCHEMA => array( 'cacheIndex' => 'bytes12', 'cacheKey' => 'text255', 'cacheData' => 'text', 'cacheType' => 'text32', ), self::CONFIG_KEY_SCHEMA => array( 'key_usercache' => array( 'columns' => array('userPHID', 'cacheIndex'), 'unique' => true, ), 'key_cachekey' => array( 'columns' => array('cacheIndex'), ), 'key_cachetype' => array( 'columns' => array('cacheType'), ), ), ) + parent::getConfiguration(); } public function save() { $this->cacheIndex = Filesystem::digestForIndex($this->getCacheKey()); return parent::save(); } public static function writeCache( PhabricatorUserCacheType $type, $key, $user_phid, $raw_value) { self::writeCaches( array( array( 'type' => $type, 'key' => $key, 'userPHID' => $user_phid, 'value' => $raw_value, ), )); } public static function writeCaches(array $values) { if (PhabricatorEnv::isReadOnly()) { return; } if (!$values) { return; } $table = new self(); $conn_w = $table->establishConnection('w'); $sql = array(); foreach ($values as $value) { $key = $value['key']; $sql[] = qsprintf( $conn_w, '(%s, %s, %s, %s, %s)', $value['userPHID'], PhabricatorHash::digestForIndex($key), $key, $value['value'], $value['type']->getUserCacheType()); } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { queryfx( $conn_w, 'INSERT INTO %T (userPHID, cacheIndex, cacheKey, cacheData, cacheType) VALUES %LQ ON DUPLICATE KEY UPDATE cacheData = VALUES(cacheData), cacheType = VALUES(cacheType)', $table->getTableName(), $chunk); } unset($unguarded); } public static function readCaches( PhabricatorUserCacheType $type, $key, array $user_phids) { $table = new self(); $conn = $table->establishConnection('r'); $rows = queryfx_all( $conn, 'SELECT userPHID, cacheData FROM %T WHERE userPHID IN (%Ls) AND cacheType = %s AND cacheIndex = %s', $table->getTableName(), $user_phids, $type->getUserCacheType(), PhabricatorHash::digestForIndex($key)); return ipull($rows, 'cacheData', 'userPHID'); } public static function clearCache($key, $user_phid) { return self::clearCaches($key, array($user_phid)); } public static function clearCaches($key, array $user_phids) { if (PhabricatorEnv::isReadOnly()) { return; } if (!$user_phids) { return; } $table = new self(); $conn_w = $table->establishConnection('w'); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $conn_w, 'DELETE FROM %T WHERE cacheIndex = %s AND userPHID IN (%Ls)', $table->getTableName(), PhabricatorHash::digestForIndex($key), $user_phids); unset($unguarded); } public static function clearCacheForAllUsers($key) { if (PhabricatorEnv::isReadOnly()) { return; } $table = new self(); $conn_w = $table->establishConnection('w'); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $conn_w, 'DELETE FROM %T WHERE cacheIndex = %s', $table->getTableName(), PhabricatorHash::digestForIndex($key)); unset($unguarded); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorExternalAccount.php
src/applications/people/storage/PhabricatorExternalAccount.php
<?php final class PhabricatorExternalAccount extends PhabricatorUserDAO implements PhabricatorPolicyInterface, PhabricatorDestructibleInterface { protected $userPHID; protected $accountSecret; protected $displayName; protected $username; protected $realName; protected $email; protected $emailVerified = 0; protected $accountURI; protected $profileImagePHID; protected $properties = array(); protected $providerConfigPHID; // TODO: Remove these (see T13493). These columns are obsolete and have // no readers and only trivial writers. protected $accountType; protected $accountDomain; protected $accountID; private $profileImageFile = self::ATTACHABLE; private $providerConfig = self::ATTACHABLE; private $accountIdentifiers = self::ATTACHABLE; public function getProfileImageFile() { return $this->assertAttached($this->profileImageFile); } public function attachProfileImageFile(PhabricatorFile $file) { $this->profileImageFile = $file; return $this; } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorPeopleExternalPHIDType::TYPECONST); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'properties' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'userPHID' => 'phid?', 'accountType' => 'text16', 'accountDomain' => 'text64', 'accountSecret' => 'text?', 'accountID' => 'text64', 'displayName' => 'text255?', 'username' => 'text255?', 'realName' => 'text255?', 'email' => 'text255?', 'emailVerified' => 'bool', 'profileImagePHID' => 'phid?', 'accountURI' => 'text255?', ), self::CONFIG_KEY_SCHEMA => array( 'key_user' => array( 'columns' => array('userPHID'), ), 'key_provider' => array( 'columns' => array('providerConfigPHID', 'userPHID'), ), ), ) + parent::getConfiguration(); } public function save() { if (!$this->getAccountSecret()) { $this->setAccountSecret(Filesystem::readRandomCharacters(32)); } $this->openTransaction(); $result = parent::save(); $account_phid = $this->getPHID(); $config_phid = $this->getProviderConfigPHID(); if ($this->accountIdentifiers !== self::ATTACHABLE) { foreach ($this->getAccountIdentifiers() as $identifier) { $identifier ->setExternalAccountPHID($account_phid) ->setProviderConfigPHID($config_phid) ->save(); } } $this->saveTransaction(); return $result; } public function unlinkAccount() { // When unlinking an account, we disassociate it from the user and // remove all the identifying information. We retain the PHID, the // object itself, and the "ExternalAccountIdentifier" objects in the // external table. // TODO: This unlinks (but does not destroy) any profile image. return $this ->setUserPHID(null) ->setDisplayName(null) ->setUsername(null) ->setRealName(null) ->setEmail(null) ->setEmailVerified(0) ->setProfileImagePHID(null) ->setAccountURI(null) ->setProperties(array()) ->save(); } public function setProperty($key, $value) { $this->properties[$key] = $value; return $this; } public function getProperty($key, $default = null) { return idx($this->properties, $key, $default); } public function isUsableForLogin() { $config = $this->getProviderConfig(); if (!$config->getIsEnabled()) { return false; } $provider = $config->getProvider(); if (!$provider->shouldAllowLogin()) { return false; } return true; } public function attachProviderConfig(PhabricatorAuthProviderConfig $config) { $this->providerConfig = $config; return $this; } public function getProviderConfig() { return $this->assertAttached($this->providerConfig); } public function getAccountIdentifiers() { $raw = $this->assertAttached($this->accountIdentifiers); return array_values($raw); } public function attachAccountIdentifiers(array $identifiers) { assert_instances_of($identifiers, 'PhabricatorExternalAccountIdentifier'); $this->accountIdentifiers = mpull($identifiers, null, 'getIdentifierRaw'); return $this; } public function appendIdentifier( PhabricatorExternalAccountIdentifier $identifier) { $this->assertAttached($this->accountIdentifiers); $map = $this->accountIdentifiers; $raw = $identifier->getIdentifierRaw(); $old = idx($map, $raw); $new = $identifier; if ($old === null) { $result = $new; } else { // Here, we already know about an identifier and have rediscovered it. // We could copy properties from the new version of the identifier here, // or merge them in some other way (for example, update a "last seen // from the provider" timestamp), but no such properties currently exist. $result = $old; } $this->accountIdentifiers[$raw] = $result; return $this; } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::getMostOpenPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return PhabricatorPolicies::POLICY_NOONE; } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return ($viewer->getPHID() == $this->getUserPHID()); } public function describeAutomaticCapability($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return null; case PhabricatorPolicyCapability::CAN_EDIT: return pht( 'External accounts can only be edited by the account owner.'); } } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $viewer = $engine->getViewer(); $identifiers = id(new PhabricatorExternalAccountIdentifierQuery()) ->setViewer($viewer) ->withExternalAccountPHIDs(array($this->getPHID())) ->newIterator(); foreach ($identifiers as $identifier) { $engine->destroyObject($identifier); } // TODO: This may leave a profile image behind. $this->delete(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserProfile.php
src/applications/people/storage/PhabricatorUserProfile.php
<?php final class PhabricatorUserProfile extends PhabricatorUserDAO { protected $userPHID; protected $title; protected $blurb; protected $profileImagePHID; protected $icon; public static function initializeNewProfile(PhabricatorUser $user) { $default_icon = PhabricatorPeopleIconSet::getDefaultIconKey(); return id(new self()) ->setUserPHID($user->getPHID()) ->setIcon($default_icon) ->setTitle('') ->setBlurb(''); } protected function getConfiguration() { return array( self::CONFIG_COLUMN_SCHEMA => array( 'title' => 'text255', 'blurb' => 'text', 'profileImagePHID' => 'phid?', 'icon' => 'text32', ), self::CONFIG_KEY_SCHEMA => array( 'userPHID' => array( 'columns' => array('userPHID'), 'unique' => true, ), ), ) + parent::getConfiguration(); } public function getDisplayTitle() { $title = $this->getTitle(); if (strlen($title)) { return $title; } $icon_key = $this->getIcon(); return PhabricatorPeopleIconSet::getIconName($icon_key); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserCustomFieldStringIndex.php
src/applications/people/storage/PhabricatorUserCustomFieldStringIndex.php
<?php final class PhabricatorUserCustomFieldStringIndex extends PhabricatorCustomFieldStringIndexStorage { public function getApplicationName() { return 'user'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/PhabricatorUserCustomFieldNumericIndex.php
src/applications/people/storage/PhabricatorUserCustomFieldNumericIndex.php
<?php final class PhabricatorUserCustomFieldNumericIndex extends PhabricatorCustomFieldNumericIndexStorage { public function getApplicationName() { return 'user'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php
src/applications/people/storage/__tests__/PhabricatorUserEmailTestCase.php
<?php final class PhabricatorUserEmailTestCase extends PhabricatorTestCase { public function testEmailValidation() { $tests = array( 'alincoln@whitehouse.gov' => true, '_-.@.-_' => true, '.@.com' => true, 'user+suffix@gmail.com' => true, 'IAMIMPORTANT@BUSINESS.COM' => true, '1@22.33.44.55' => true, '999@999.999' => true, 'user@2001:0db8:85a3:0042:1000:8a2e:0370:7334' => true, '!..!@o.O' => true, '' => false, str_repeat('a', 256).'@example.com' => false, 'quack' => false, '@gmail.com' => false, 'usergmail.com' => false, '"user" user@gmail.com' => false, 'a,b@evil.com' => false, 'a;b@evil.com' => false, 'ab@evil.com;cd@evil.com' => false, 'x@y@z.com' => false, '@@' => false, '@' => false, 'user@' => false, "user@domain.com\n" => false, "user@\ndomain.com" => false, "\nuser@domain.com" => false, "user@domain.com\r" => false, "user@\rdomain.com" => false, "\ruser@domain.com" => false, ); foreach ($tests as $input => $expect) { $actual = PhabricatorUserEmail::isValidAddress($input); $this->assertEqual( $expect, $actual, $input); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/storage/__tests__/PhabricatorUserTestCase.php
src/applications/people/storage/__tests__/PhabricatorUserTestCase.php
<?php final class PhabricatorUserTestCase extends PhabricatorTestCase { public function testUsernameValidation() { $map = array( 'alincoln' => true, 'alincoln69' => true, 'hd3' => true, 'Alincoln' => true, 'a.lincoln' => true, 'alincoln!' => false, '' => false, // These are silly, but permitted. '7' => true, '0' => true, '____' => true, '-' => true, // These are not permitted because they make capturing @mentions // ambiguous. 'joe.' => false, // We can never allow these because they invalidate usernames as tokens // in commit messages ("Reviewers: alincoln, usgrant"), or as parameters // in URIs ("/p/alincoln/", "?user=alincoln"), or make them unsafe in // HTML. Theoretically we escape all the HTML/URI stuff, but these // restrictions make attacks more difficult and are generally reasonable, // since usernames like "<^, ,^>" don't seem very important to support. '<script>' => false, 'a lincoln' => false, ' alincoln' => false, 'alincoln ' => false, 'a,lincoln' => false, 'a&lincoln' => false, 'a/lincoln' => false, "username\n" => false, "user\nname" => false, "\nusername" => false, "username\r" => false, "user\rname" => false, "\rusername" => false, ); foreach ($map as $name => $expect) { $this->assertEqual( $expect, PhabricatorUser::validateUsername($name), pht("Validity of '%s'.", $name)); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/management/PhabricatorPeopleManagementEnableWorkflow.php
src/applications/people/management/PhabricatorPeopleManagementEnableWorkflow.php
<?php final class PhabricatorPeopleManagementEnableWorkflow extends PhabricatorPeopleManagementWorkflow { protected function didConstruct() { $arguments = array_merge( $this->getUserSelectionArguments(), array()); $this ->setName('enable') ->setExamples('**enable** --user __username__') ->setSynopsis(pht('Enable a disabled user account.')) ->setArguments($arguments); } public function execute(PhutilArgumentParser $args) { $user = $this->selectUser($args); $display_name = $user->getUsername(); if (!$user->getIsDisabled()) { throw new PhutilArgumentUsageException( pht( 'User account "%s" is not disabled. You can only enable accounts '. 'that are disabled.', $display_name)); } $xactions = array(); $xactions[] = $user->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorUserDisableTransaction::TRANSACTIONTYPE) ->setNewValue(false); $this->applyTransactions($user, $xactions); $this->logOkay( pht('DONE'), pht('Enabled user account "%s".', $display_name)); return 0; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false