mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Add config to require real name, respect config when creating new users, drop real name from full name if not provided.
Summary: Fixes T4728, first pass, Make real name optional on user accounts Test Plan: Default real name config should be false (not required). Create new user, real name should not be required. Toggle config, real name should be required. Users with no real name should be always listed by their usernames. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4728 Differential Revision: https://secure.phabricator.com/D9027
This commit is contained in:
parent
1687ffcd9e
commit
dfcccd4cb8
8 changed files with 26 additions and 10 deletions
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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'),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue