Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14753608
D17467.id42008.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D17467.id42008.diff
View Options
diff --git a/src/applications/people/cache/PhabricatorUserProfileImageCacheType.php b/src/applications/people/cache/PhabricatorUserProfileImageCacheType.php
--- a/src/applications/people/cache/PhabricatorUserProfileImageCacheType.php
+++ b/src/applications/people/cache/PhabricatorUserProfileImageCacheType.php
@@ -24,8 +24,43 @@
public function newValueForUsers($key, array $users) {
$viewer = $this->getViewer();
- $file_phids = mpull($users, 'getProfileImagePHID');
- $file_phids = array_filter($file_phids);
+ $file_phids = array();
+ $generate_users = array();
+ foreach ($users as $user) {
+ $user_phid = $user->getPHID();
+ $custom_phid = $user->getProfileImagePHID();
+ $default_phid = $user->getDefaultProfileImagePHID();
+ $version = $user->getDefaultProfileImageVersion();
+
+ if ($custom_phid) {
+ $file_phids[$user_phid] = $custom_phid;
+ continue;
+ }
+ if ($default_phid) {
+ if ($version == PhabricatorFilesComposeAvatarBuiltinFile::VERSION) {
+ $file_phids[$user_phid] = $default_phid;
+ continue;
+ }
+ }
+ $generate_users[] = $user;
+ }
+
+ // Generate Files for anyone without a default
+ foreach ($generate_users as $generate_user) {
+ $generate_user_phid = $generate_user->getPHID();
+ $generate_username = $generate_user->getUsername();
+ $generate_version = PhabricatorFilesComposeAvatarBuiltinFile::VERSION;
+ $generate_file = id(new PhabricatorFilesComposeAvatarBuiltinFile())
+ ->getUserProfileImageFile($generate_username);
+
+ $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
+ $generate_user->setDefaultProfileImagePHID($generate_file->getPHID());
+ $generate_user->setDefaultProfileImageVersion($generate_version);
+ $generate_user->save();
+ unset($unguarded);
+
+ $file_phids[$generate_user_phid] = $generate_file->getPHID();
+ }
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
@@ -40,8 +75,11 @@
$results = array();
foreach ($users as $user) {
$image_phid = $user->getProfileImagePHID();
+ $default_phid = $user->getDefaultProfileImagePHID();
if (isset($files[$image_phid])) {
$image_uri = $files[$image_phid]->getBestURI();
+ } else if (isset($files[$default_phid])) {
+ $image_uri = $files[$default_phid]->getBestURI();
} else {
$image_uri = PhabricatorUser::getDefaultProfileImageURI();
}
diff --git a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
--- a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
@@ -30,22 +30,12 @@
$e_file = true;
$errors = array();
- // Verify install has GD extension, otherwise default to avatar.png
- $gd = function_exists('imagecreatefromstring');
-
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
- // Compose the builtin unique image
- if ($gd) {
- $file = id(new PhabricatorFilesComposeAvatarBuiltinFile())
- ->getUserProfileImageFile($name);
- } else {
- $phid = null;
- $is_default = true;
- }
-
+ $phid = null;
+ $is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
@@ -96,13 +86,15 @@
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
- if ($gd) {
- $unique_default = id(new PhabricatorFilesComposeAvatarBuiltinFile())
- ->getUniqueProfileImage($name);
- $default_image = PhabricatorFile::loadBuiltin(
- $viewer, $unique_default['icon']);
- } else {
- $unique_default = null;
+ $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');
}
@@ -181,21 +173,9 @@
}
}
- $default_style = array();
- if ($unique_default) {
- $border_color = implode(', ', $unique_default['border']);
- $default_style = array(
- 'background-color: '.$unique_default['color'].';',
- 'border: 4px solid rgba('.$border_color.');',
- 'height: 42px;',
- 'width: 42px',
- );
- }
-
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
- 'style' => implode(' ', $default_style),
);
require_celerity_resource('people-profile-css');
@@ -223,7 +203,6 @@
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
- 'style' => $style,
)));
$button = array(
diff --git a/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php b/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php
--- a/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php
+++ b/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php
@@ -55,8 +55,14 @@
foreach ($iterator as $user) {
$username = $user->getUsername();
$default_phid = $user->getDefaultProfileImagePHID();
+ $gen_version = $user->getDefaultProfileImageVersion();
- if ($default_phid == null || $is_force) {
+ $generate = false;
+ if ($gen_version != $version) {
+ $generate = true;
+ }
+
+ if ($default_phid == null || $is_force || $generate) {
$file = id(new PhabricatorFilesComposeAvatarBuiltinFile())
->getUserProfileImageFile($username);
$user->setDefaultProfileImagePHID($file->getPHID());
diff --git a/src/applications/people/storage/PhabricatorUserProfile.php b/src/applications/people/storage/PhabricatorUserProfile.php
--- a/src/applications/people/storage/PhabricatorUserProfile.php
+++ b/src/applications/people/storage/PhabricatorUserProfile.php
@@ -13,7 +13,9 @@
return id(new self())
->setUserPHID($user->getPHID())
- ->setIcon($default_icon);
+ ->setIcon($default_icon)
+ ->setTitle('')
+ ->setBlurb('');
}
protected function getConfiguration() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 22, 3:15 PM (8 h, 15 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7029180
Default Alt Text
D17467.id42008.diff (6 KB)
Attached To
Mode
D17467: Auto-generate profile images for sad psyducks
Attached
Detach File
Event Timeline
Log In to Comment