diff --git a/src/applications/auth/controller/PhabricatorAuthRegisterController.php b/src/applications/auth/controller/PhabricatorAuthRegisterController.php index 6f75a51555..563f256cc5 100644 --- a/src/applications/auth/controller/PhabricatorAuthRegisterController.php +++ b/src/applications/auth/controller/PhabricatorAuthRegisterController.php @@ -144,8 +144,10 @@ final class PhabricatorAuthRegisterController $errors = array(); + $require_real_name = PhabricatorEnv::getEnvConfig('user.require-real-name'); + $e_username = strlen($value_username) ? null : true; - $e_realname = strlen($value_realname) ? null : true; + $e_realname = $require_real_name ? true : null; $e_email = strlen($value_email) ? null : true; $e_password = true; $e_captcha = true; @@ -224,7 +226,7 @@ final class PhabricatorAuthRegisterController if ($can_edit_realname) { $value_realname = $request->getStr('realName'); - if (!strlen($value_realname)) { + if (!strlen($value_realname) && $require_real_name) { $e_realname = pht('Required'); $errors[] = pht('Real name is required.'); } else { diff --git a/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php index ad94b9ff31..ff5689d44e 100644 --- a/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php +++ b/src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php @@ -177,7 +177,8 @@ final class PhabricatorMetaMTAActorQuery extends PhabricatorQuery { $name = $user->getUserName(); break; case 'real': - $name = $user->getRealName(); + $name = strlen($user->getRealName()) ? + $user->getRealName() : $user->getUserName(); break; case 'full': default: diff --git a/src/applications/people/config/PhabricatorUserConfigOptions.php b/src/applications/people/config/PhabricatorUserConfigOptions.php index 0795ba67e5..5c83312fcc 100644 --- a/src/applications/people/config/PhabricatorUserConfigOptions.php +++ b/src/applications/people/config/PhabricatorUserConfigOptions.php @@ -36,6 +36,13 @@ final class PhabricatorUserConfigOptions ->setDescription(pht("Select and reorder user profile fields.")), $this->newOption('user.custom-field-definitions', 'map', array()) ->setDescription(pht("Add new simple fields to user profiles.")), + $this->newOption('user.require-real-name', 'bool', true) + ->setDescription(pht("Always require real name for user profiles.")) + ->setBoolOptions( + array( + pht('Make real names required'), + pht('Make real names optional'), + )), ); } diff --git a/src/applications/people/controller/PhabricatorPeopleNewController.php b/src/applications/people/controller/PhabricatorPeopleNewController.php index c789747fff..5769c3aca7 100644 --- a/src/applications/people/controller/PhabricatorPeopleNewController.php +++ b/src/applications/people/controller/PhabricatorPeopleNewController.php @@ -25,9 +25,10 @@ final class PhabricatorPeopleNewController } $user = new PhabricatorUser(); + $require_real_name = PhabricatorEnv::getEnvConfig('user.require-real-name'); $e_username = true; - $e_realname = true; + $e_realname = $require_real_name ? true : null; $e_email = true; $errors = array(); @@ -64,7 +65,7 @@ final class PhabricatorPeopleNewController $e_username = null; } - if (!strlen($user->getRealName())) { + if (!strlen($user->getRealName()) && $require_real_name) { $errors[] = pht('Real name is required.'); $e_realname = pht('Required'); } else { diff --git a/src/applications/people/controller/PhabricatorPeopleProfileController.php b/src/applications/people/controller/PhabricatorPeopleProfileController.php index 0413127dce..c75ae8088e 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfileController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfileController.php @@ -33,7 +33,7 @@ final class PhabricatorPeopleProfileController $picture = $user->loadProfileImageURI(); $header = id(new PHUIHeaderView()) - ->setHeader($user->getUserName().' ('.$user->getRealName().')') + ->setHeader($user->getFullName()) ->setSubheader($profile->getTitle()) ->setImage($picture); diff --git a/src/applications/people/phid/PhabricatorPeoplePHIDTypeUser.php b/src/applications/people/phid/PhabricatorPeoplePHIDTypeUser.php index 49ddf01ed4..db6295006f 100644 --- a/src/applications/people/phid/PhabricatorPeoplePHIDTypeUser.php +++ b/src/applications/people/phid/PhabricatorPeoplePHIDTypeUser.php @@ -41,10 +41,11 @@ final class PhabricatorPeoplePHIDTypeUser extends PhabricatorPHIDType { foreach ($handles as $phid => $handle) { $user = $objects[$phid]; + $realname = $user->getRealName(); + $handle->setName($user->getUsername()); $handle->setURI('/p/'.$user->getUsername().'/'); - $handle->setFullName( - $user->getUsername().' ('.$user->getRealName().')'); + $handle->setFullName($user->getFullName()); $handle->setImageURI($user->loadProfileImageURI()); $handle->setDisabled(!$user->isUserActivated()); if ($user->hasStatus()) { diff --git a/src/applications/people/search/PhabricatorUserSearchIndexer.php b/src/applications/people/search/PhabricatorUserSearchIndexer.php index bb0a2a337c..da591d7f7d 100644 --- a/src/applications/people/search/PhabricatorUserSearchIndexer.php +++ b/src/applications/people/search/PhabricatorUserSearchIndexer.php @@ -13,7 +13,7 @@ final class PhabricatorUserSearchIndexer $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($user->getPHID()); $doc->setDocumentType(PhabricatorPeoplePHIDTypeUser::TYPECONST); - $doc->setDocumentTitle($user->getUserName().' ('.$user->getRealName().')'); + $doc->setDocumentTitle($user->getFullName()); $doc->setDocumentCreated($user->getDateCreated()); $doc->setDocumentModified($user->getDateModified()); diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 051a77f2b8..f5da21efd4 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -711,7 +711,11 @@ EOBODY; } public function getFullName() { - return $this->getUsername().' ('.$this->getRealName().')'; + if (strlen($this->getRealName())) { + return $this->getUsername().' ('.$this->getRealName().')'; + } else { + return $this->getUsername(); + } } public function __toString() {