Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14356722
D17464.id41997.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D17464.id41997.diff
View Options
diff --git a/bin/people b/bin/people
new file mode 120000
--- /dev/null
+++ b/bin/people
@@ -0,0 +1 @@
+../scripts/people/manage_people.php
\ No newline at end of file
diff --git a/scripts/people/manage_people.php b/scripts/people/manage_people.php
new file mode 100755
--- /dev/null
+++ b/scripts/people/manage_people.php
@@ -0,0 +1,21 @@
+#!/usr/bin/env php
+<?php
+
+$root = dirname(dirname(dirname(__FILE__)));
+require_once $root.'/scripts/__init_script__.php';
+
+$args = new PhutilArgumentParser($argv);
+$args->setTagline(pht('build profile images'));
+$args->setSynopsis(<<<EOSYNOPSIS
+**people** __command__ [__options__]
+ Command line generation of custom profile images.
+
+EOSYNOPSIS
+ );
+$args->parseStandardArguments();
+
+$workflows = id(new PhutilClassMapQuery())
+ ->setAncestorClass('PhabricatorPeopleManagementWorkflow')
+ ->execute();
+$workflows[] = new PhutilHelpArgumentWorkflow();
+$args->parseWorkflows($workflows);
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3356,6 +3356,7 @@
'PhabricatorPeopleLogSearchEngine' => 'applications/people/query/PhabricatorPeopleLogSearchEngine.php',
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
'PhabricatorPeopleManageProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php',
+ 'PhabricatorPeopleManagementWorkflow' => 'applications/people/management/PhabricatorPeopleManagementWorkflow.php',
'PhabricatorPeopleNewController' => 'applications/people/controller/PhabricatorPeopleNewController.php',
'PhabricatorPeopleNoOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleNoOwnerDatasource.php',
'PhabricatorPeopleOwnerDatasource' => 'applications/people/typeahead/PhabricatorPeopleOwnerDatasource.php',
@@ -3363,6 +3364,7 @@
'PhabricatorPeopleProfileBadgesController' => 'applications/people/controller/PhabricatorPeopleProfileBadgesController.php',
'PhabricatorPeopleProfileController' => 'applications/people/controller/PhabricatorPeopleProfileController.php',
'PhabricatorPeopleProfileEditController' => 'applications/people/controller/PhabricatorPeopleProfileEditController.php',
+ 'PhabricatorPeopleProfileImageWorkflow' => 'applications/people/management/PhabricatorPeopleProfileImageWorkflow.php',
'PhabricatorPeopleProfileManageController' => 'applications/people/controller/PhabricatorPeopleProfileManageController.php',
'PhabricatorPeopleProfileMenuEngine' => 'applications/people/engine/PhabricatorPeopleProfileMenuEngine.php',
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
@@ -8536,6 +8538,7 @@
'PhabricatorPeopleLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
'PhabricatorPeopleManageProfileMenuItem' => 'PhabricatorProfileMenuItem',
+ 'PhabricatorPeopleManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorPeopleNewController' => 'PhabricatorPeopleController',
'PhabricatorPeopleNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorPeopleOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
@@ -8543,6 +8546,7 @@
'PhabricatorPeopleProfileBadgesController' => 'PhabricatorPeopleProfileController',
'PhabricatorPeopleProfileController' => 'PhabricatorPeopleController',
'PhabricatorPeopleProfileEditController' => 'PhabricatorPeopleProfileController',
+ 'PhabricatorPeopleProfileImageWorkflow' => 'PhabricatorPeopleManagementWorkflow',
'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController',
'PhabricatorPeopleProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
diff --git a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
--- a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
+++ b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
@@ -7,6 +7,8 @@
private $color;
private $border;
+ const VERSION = 'v1';
+
public function setIcon($icon) {
$this->icon = $icon;
return $this;
diff --git a/src/applications/people/management/PhabricatorPeopleManagementWorkflow.php b/src/applications/people/management/PhabricatorPeopleManagementWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/management/PhabricatorPeopleManagementWorkflow.php
@@ -0,0 +1,36 @@
+<?php
+
+abstract class PhabricatorPeopleManagementWorkflow
+ extends PhabricatorManagementWorkflow {
+
+ protected function buildIterator(PhutilArgumentParser $args) {
+ $usernames = $args->getArg('users');
+
+ if ($args->getArg('all')) {
+ if ($usernames) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Specify either a list of users or `%s`, but not both.',
+ '--all'));
+ }
+ return new LiskMigrationIterator(new PhabricatorUser());
+ }
+
+ if ($usernames) {
+ return $this->loadUsersWithUsernames($usernames);
+ }
+
+ return null;
+ }
+
+ protected function loadUsersWithUsernames(array $usernames) {
+ $query = id(new PhabricatorPeopleQuery())
+ ->setViewer($this->getViewer())
+ ->withUsernames($usernames)
+ ->execute();
+
+ return $query;
+ }
+
+
+}
diff --git a/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php b/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/people/management/PhabricatorPeopleProfileImageWorkflow.php
@@ -0,0 +1,94 @@
+<?php
+
+final class PhabricatorPeopleProfileImageWorkflow
+ extends PhabricatorPeopleManagementWorkflow {
+
+ protected function didConstruct() {
+ $this
+ ->setName('profileimage')
+ ->setExamples('**profileimage**')
+ ->setSynopsis(pht('Generate default profile images.'))
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'user',
+ 'help' => pht(
+ 'Generate a default profile image for a specific user'),
+ ),
+ array(
+ 'name' => 'all',
+ 'help' => pht(
+ 'Generate default profile images for all users.'),
+ ),
+ array(
+ 'name' => 'force',
+ 'short' => 'f',
+ 'help' => pht(
+ 'Force a default profile image to be replaced.'),
+ ),
+ array(
+ 'name' => 'users',
+ 'wildcard' => true,
+ ),
+ ));
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $console = PhutilConsole::getConsole();
+
+ $is_force = $args->getArg('force');
+ $is_all = $args->getArg('all');
+ $is_user = $args->getArg('user');
+
+ $gd = function_exists('imagecreatefromstring');
+ if (!$gd) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'GD is not installed for php-cli. Aborting.'));
+ }
+
+ $iterator = $this->buildIterator($args);
+ if (!$iterator) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Either specify a list of users to update, or use `%s` '.
+ 'to update all users.',
+ '--all'));
+ }
+
+ $version = PhabricatorFilesComposeAvatarBuiltinFile::VERSION;
+
+ foreach ($iterator as $user) {
+ $username = $user->getUsername();
+ $default_phid = $user->getDefaultProfileImagePHID();
+
+ if ($default_phid == null || $is_force) {
+ $file = id(new PhabricatorFilesComposeAvatarBuiltinFile())
+ ->getUserProfileImageFile($username);
+ if ($file) {
+ $user->setDefaultProfileImagePHID($file->getPHID());
+ $user->setDefaultProfileImageVersion($version);
+ $user->save();
+ $console->writeOut(
+ "%s\n",
+ pht(
+ 'Generating profile image for %s',
+ $username));
+ } else {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Error generating profile image for %s',
+ $username));
+ }
+ } else {
+ $console->writeOut(
+ "%s\n",
+ pht(
+ 'Default profile image "%s" already set for %s',
+ $version,
+ $username));
+ }
+ }
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 11:39 PM (16 h, 6 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6912250
Default Alt Text
D17464.id41997.diff (8 KB)
Attached To
Mode
D17464: Add a profileimage generation workflow for the cli
Attached
Detach File
Event Timeline
Log In to Comment