mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
Use a disk-based default avatar, not a database-based one
Summary: This is mostly in an effort to simplify D2323. Currently, we load one image into the database by default. This is a weird special case that makes things more complicated than necessary. Instead, use a disk-based default avatar. Test Plan: Verified that a user without an image appears with the default avatar as a handle, in profile settings, and on their person page. Reviewers: btrahan, vrana, edward, jungejason Reviewed By: vrana CC: aran Maniphest Tasks: T345 Differential Revision: https://secure.phabricator.com/D2331
This commit is contained in:
parent
d27a751339
commit
8ed48a89f4
15 changed files with 26 additions and 45 deletions
|
@ -31,10 +31,6 @@ return array(
|
|||
// you through setting up Phabricator.
|
||||
'phabricator.setup' => false,
|
||||
|
||||
// The default PHID for users who haven't uploaded a profile image. It should
|
||||
// be 50x50px.
|
||||
'user.default-profile-image-phid' => 'PHID-FILE-4d61229816cfe6f2b2a3',
|
||||
|
||||
// -- IMPORTANT! Security! -------------------------------------------------- //
|
||||
|
||||
// IMPORTANT: By default, Phabricator serves files from the same domain the
|
||||
|
|
|
@ -22,20 +22,12 @@
|
|||
abstract class ConduitAPI_user_Method extends ConduitAPIMethod {
|
||||
|
||||
protected function buildUserInformationDictionary(PhabricatorUser $user) {
|
||||
$src_phid = $user->getProfileImagePHID();
|
||||
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
|
||||
if ($file) {
|
||||
$picture = $file->getBestURI();
|
||||
} else {
|
||||
$picture = null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'phid' => $user->getPHID(),
|
||||
'userName' => $user->getUserName(),
|
||||
'realName' => $user->getRealName(),
|
||||
'email' => $user->getEmail(),
|
||||
'image' => $picture,
|
||||
'image' => $user->loadProfileImageURI(),
|
||||
'uri' => PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_user_Method.php');
|
||||
|
|
|
@ -116,13 +116,7 @@ final class PhabricatorPeopleProfileController
|
|||
throw new Exception("Unknown page '{$this->page}'!");
|
||||
}
|
||||
|
||||
$src_phid = $user->getProfileImagePHID();
|
||||
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
|
||||
if ($file) {
|
||||
$picture = $file->getBestURI();
|
||||
} else {
|
||||
$picture = null;
|
||||
}
|
||||
$picture = $user->loadProfileImageURI();
|
||||
|
||||
$header = new PhabricatorProfileHeaderView();
|
||||
$header
|
||||
|
|
|
@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'aphront/response/404');
|
|||
phutil_require_module('phabricator', 'applications/auth/oauth/provider/base');
|
||||
phutil_require_module('phabricator', 'applications/feed/builder/feed');
|
||||
phutil_require_module('phabricator', 'applications/feed/query');
|
||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||
phutil_require_module('phabricator', 'applications/people/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/profile');
|
||||
|
|
|
@ -107,14 +107,7 @@ final class PhabricatorUserProfileSettingsPanelController
|
|||
}
|
||||
}
|
||||
|
||||
$file = id(new PhabricatorFile())->loadOneWhere(
|
||||
'phid = %s',
|
||||
$user->getProfileImagePHID());
|
||||
if ($file) {
|
||||
$img_src = $file->getBestURI();
|
||||
} else {
|
||||
$img_src = null;
|
||||
}
|
||||
$img_src = $user->loadProfileImageURI();
|
||||
$profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/');
|
||||
|
||||
$sexes = array(
|
||||
|
|
|
@ -45,10 +45,6 @@ final class PhabricatorUser extends PhabricatorUserDAO {
|
|||
|
||||
protected function readField($field) {
|
||||
switch ($field) {
|
||||
case 'profileImagePHID':
|
||||
return nonempty(
|
||||
$this->profileImagePHID,
|
||||
PhabricatorEnv::getEnvConfig('user.default-profile-image-phid'));
|
||||
case 'timezoneIdentifier':
|
||||
// If the user hasn't set one, guess the server's time.
|
||||
return nonempty(
|
||||
|
@ -523,4 +519,19 @@ EOBODY;
|
|||
return (bool)preg_match('/^[a-zA-Z0-9]+$/', $username);
|
||||
}
|
||||
|
||||
public static function getDefaultProfileImageURI() {
|
||||
return celerity_get_resource_uri('/rsrc/image/avatar.png');
|
||||
}
|
||||
|
||||
public function loadProfileImageURI() {
|
||||
$src_phid = $this->getProfileImagePHID();
|
||||
|
||||
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
|
||||
if ($file) {
|
||||
return $file->getBestURI();
|
||||
}
|
||||
|
||||
return self::getDefaultProfileImageURI();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/writeguard');
|
||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/base');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/log');
|
||||
|
@ -14,6 +15,7 @@ phutil_require_module('phabricator', 'applications/people/storage/preferences');
|
|||
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
||||
phutil_require_module('phabricator', 'applications/search/index/indexer/user');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
phutil_require_module('phabricator', 'infrastructure/util/hash');
|
||||
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||
|
|
|
@ -169,6 +169,9 @@ final class PhabricatorObjectHandleData {
|
|||
$img_uri = idx($images, $user->getProfileImagePHID());
|
||||
if ($img_uri) {
|
||||
$handle->setImageURI($img_uri);
|
||||
} else {
|
||||
$handle->setImageURI(
|
||||
PhabricatorUser::getDefaultProfileImageURI());
|
||||
}
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('arcanist', 'differential/constants/revisionstatus');
|
|||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/constants/owner');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/const/status');
|
||||
|
|
|
@ -49,7 +49,7 @@ final class PhabricatorProjectProfileController
|
|||
if ($file) {
|
||||
$picture = $file->getBestURI();
|
||||
} else {
|
||||
$picture = null;
|
||||
$picture = PhabricatorUser::getDefaultProfileImageURI();
|
||||
}
|
||||
|
||||
$members = mpull($project->loadAffiliations(), null, 'getUserPHID');
|
||||
|
|
|
@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'applications/feed/query');
|
|||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/query');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'applications/project/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/project/storage/profile');
|
||||
|
|
|
@ -22,9 +22,4 @@ final class PhabricatorProjectProfile extends PhabricatorProjectDAO {
|
|||
protected $blurb;
|
||||
protected $profileImagePHID;
|
||||
|
||||
public function getProfileImagePHID() {
|
||||
return nonempty(
|
||||
$this->profileImagePHID,
|
||||
PhabricatorEnv::getEnvConfig('user.default-profile-image-phid'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/project/storage/base');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorProjectProfile.php');
|
||||
|
|
BIN
webroot/rsrc/image/avatar.png
Normal file
BIN
webroot/rsrc/image/avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 959 B |
Loading…
Reference in a new issue