Page MenuHomePhabricator

D16669.id40127.diff
No OneTemporary

D16669.id40127.diff

diff --git a/resources/builtin/conpherence.png b/resources/builtin/conpherence.png
new file mode 100644
index 0000000000000000000000000000000000000000..78bb8bdc0548f41a4121e2ed5fb2d11cc6d6c429
GIT binary patch
literal 2186
zc$|Hf`#;l*AIF!LY`JU;jhvH7mP^MaxmD(T&S<7aBVkKS7jm1+PVRFX%_S>yZz3&G
zkz6VnVJwx15UZJ6ZaI~;+={RB2Yk;D@AvzM*W>Z};rV_%Uhg;4iEvB-styH#KnnIa
zEOB$5`?us|H#>Da#{~qEJ86&o(<S1@0*7>3h*Py|X>@B~1P;F^%R|70$)=JGddF+$
z>Ve;`&qAKEs8WT1VO(Wpq!Vt2FO#!Rc)r(D-_SsS8zBx<gb^T%H|a_$CK(BD)<7of
z_Bwnc6I9AIh;hd8E8gb-`Mo<S$O2gVi)5tT|B=KJ>v)m{`eC39eoH6B0xi}kVaLO4
zbZwvvO;Dl@N=`W$oKlqxlUT2Q&o6?#fuz|chB9tBX}*|-1dzTYoPr|dwPPGxX)3F+
zkf9t_D1Q6Vtrzt8kL2_eZ69=c3CEmSU?85T%XT9v(mzE)tMuQ_;>c3%M6VjXcL(9)
z7RplDqzR*5-5!rzTQ7I{0lg#`lyen(Z(nbVXNKTHB``-z$vKt6<*x7*GvKD`@|m*j
z(t7@idwkGPfU)zx4!euU(S&@RDHGeL0b{H9@mG1Eq=W(rQKikY_0z$tc1hfo`U+x|
zQ&W|j#bE_%jK=FVY8>hiYRaS|ougr(Ka4%9KR9UlQYEcy@1DI$9{of$XIED>&jr$s
zy%Va!I~Eo%$~+ET^gR)y-K}u-!2`0oz+{))mN;RpQ+1K?YaK*iKxjY!vi7|rf735l
zfn`#|isE?tNJ3sbIe!tIN{no7AHufq+_WQVYM->fi~YRd&O9h*pO1SH9PK(H@RrZm
z^6Z)9*>D}>zPaV%N=MqAaNX1UE9+NYqdfo%w6EEop(c2TWLjeBcmQ?pUcaMaVd8nX
zfngRM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pkg.css' => '3c08b01f',
+ 'conpherence.pkg.css' => '4601645d',
'conpherence.pkg.js' => '11f3e07e',
'core.pkg.css' => '3fa66cb3',
'core.pkg.js' => '30185d95',
@@ -47,7 +47,7 @@
'rsrc/css/application/config/setup-issue.css' => 'f794cfc3',
'rsrc/css/application/config/unhandled-exception.css' => '4c96257a',
'rsrc/css/application/conpherence/durable-column.css' => '44bcaa19',
- 'rsrc/css/application/conpherence/header-pane.css' => '6a032d4c',
+ 'rsrc/css/application/conpherence/header-pane.css' => '20a7028c',
'rsrc/css/application/conpherence/menu.css' => '4f51db5a',
'rsrc/css/application/conpherence/message-pane.css' => '0d7dff02',
'rsrc/css/application/conpherence/notification.css' => '965db05b',
@@ -618,7 +618,7 @@
'config-options-css' => '0ede4c9b',
'config-page-css' => '8798e14f',
'conpherence-durable-column-view' => '44bcaa19',
- 'conpherence-header-pane-css' => '6a032d4c',
+ 'conpherence-header-pane-css' => '20a7028c',
'conpherence-menu-css' => '4f51db5a',
'conpherence-message-pane-css' => '0d7dff02',
'conpherence-notification-css' => '965db05b',
diff --git a/resources/sql/autopatches/20161005.conpherence.image.1.sql b/resources/sql/autopatches/20161005.conpherence.image.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161005.conpherence.image.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread
+ ADD profileImagePHID VARBINARY(64);
diff --git a/resources/sql/autopatches/20161005.conpherence.image.2.php b/resources/sql/autopatches/20161005.conpherence.image.2.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161005.conpherence.image.2.php
@@ -0,0 +1,35 @@
+<?php
+
+// Rebuild all Conpherence Room images to profile standards
+//
+$table = new ConpherenceThread();
+$conn = $table->establishConnection('w');
+$table_name = 'conpherence_thread';
+
+foreach (new LiskRawMigrationIterator($conn, $table_name) as $row) {
+
+ $images = $row->getImagePHIDs();
+ if (!strlen($images)) {
+ return;
+ }
+
+ $images = phutil_json_decode($images);
+ $file_phid = idx($images, 'original');
+
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs(array($file_phid))
+ ->execute();
+
+ $xform = PhabricatorFileTransform::getTransformByKey(
+ PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
+ $xformed = $xform->executeTransform(PhabricatorUser::getOmnipotentUser());
+ $new_phid = $xformed->getPHID();
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET profileImage = %s WHERE id = %d',
+ $table->getTableName(),
+ $new_phid,
+ $row->getID());
+}
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
@@ -292,7 +292,6 @@
'ConpherenceEditor' => 'applications/conpherence/editor/ConpherenceEditor.php',
'ConpherenceFormDragAndDropUploadControl' => 'applications/conpherence/view/ConpherenceFormDragAndDropUploadControl.php',
'ConpherenceFulltextQuery' => 'applications/conpherence/query/ConpherenceFulltextQuery.php',
- 'ConpherenceImageData' => 'applications/conpherence/constants/ConpherenceImageData.php',
'ConpherenceIndex' => 'applications/conpherence/storage/ConpherenceIndex.php',
'ConpherenceLayoutView' => 'applications/conpherence/view/ConpherenceLayoutView.php',
'ConpherenceListController' => 'applications/conpherence/controller/ConpherenceListController.php',
@@ -309,6 +308,7 @@
'ConpherenceQueryTransactionConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceQueryTransactionConduitAPIMethod.php',
'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php',
'ConpherenceRoomListController' => 'applications/conpherence/controller/ConpherenceRoomListController.php',
+ 'ConpherenceRoomPictureController' => 'applications/conpherence/controller/ConpherenceRoomPictureController.php',
'ConpherenceRoomTestCase' => 'applications/conpherence/__tests__/ConpherenceRoomTestCase.php',
'ConpherenceSchemaSpec' => 'applications/conpherence/storage/ConpherenceSchemaSpec.php',
'ConpherenceTestCase' => 'applications/conpherence/__tests__/ConpherenceTestCase.php',
@@ -4768,7 +4768,6 @@
'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor',
'ConpherenceFormDragAndDropUploadControl' => 'AphrontFormControl',
'ConpherenceFulltextQuery' => 'PhabricatorOffsetPagedQuery',
- 'ConpherenceImageData' => 'ConpherenceConstants',
'ConpherenceIndex' => 'ConpherenceDAO',
'ConpherenceLayoutView' => 'AphrontTagView',
'ConpherenceListController' => 'ConpherenceController',
@@ -4785,6 +4784,7 @@
'ConpherenceQueryTransactionConduitAPIMethod' => 'ConpherenceConduitAPIMethod',
'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler',
'ConpherenceRoomListController' => 'ConpherenceController',
+ 'ConpherenceRoomPictureController' => 'ConpherenceController',
'ConpherenceRoomTestCase' => 'ConpherenceTestCase',
'ConpherenceSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'ConpherenceTestCase' => 'PhabricatorTestCase',
diff --git a/src/applications/conpherence/application/PhabricatorConpherenceApplication.php b/src/applications/conpherence/application/PhabricatorConpherenceApplication.php
--- a/src/applications/conpherence/application/PhabricatorConpherenceApplication.php
+++ b/src/applications/conpherence/application/PhabricatorConpherenceApplication.php
@@ -30,20 +30,31 @@
public function getRoutes() {
return array(
- '/Z(?P<id>[1-9]\d*)' => 'ConpherenceViewController',
+ '/Z(?P<id>[1-9]\d*)'
+ => 'ConpherenceViewController',
'/conpherence/' => array(
- '' => 'ConpherenceListController',
- 'thread/(?P<id>[1-9]\d*)/' => 'ConpherenceListController',
- '(?P<id>[1-9]\d*)/' => 'ConpherenceViewController',
+ ''
+ => 'ConpherenceListController',
+ 'thread/(?P<id>[1-9]\d*)/'
+ => 'ConpherenceListController',
+ '(?P<id>[1-9]\d*)/'
+ => 'ConpherenceViewController',
'(?P<id>[1-9]\d*)/(?P<messageID>[1-9]\d*)/'
- => 'ConpherenceViewController',
- 'columnview/' => 'ConpherenceColumnViewController',
- 'new/' => 'ConpherenceNewRoomController',
+ => 'ConpherenceViewController',
+ 'columnview/'
+ => 'ConpherenceColumnViewController',
+ 'new/'
+ => 'ConpherenceNewRoomController',
+ 'picture/(?P<id>[1-9]\d*)/'
+ => 'ConpherenceRoomPictureController',
'search/(?:query/(?P<queryKey>[^/]+)/)?'
- => 'ConpherenceRoomListController',
- 'panel/' => 'ConpherenceNotificationPanelController',
- 'participant/(?P<id>[1-9]\d*)/' => 'ConpherenceParticipantController',
- 'update/(?P<id>[1-9]\d*)/' => 'ConpherenceUpdateController',
+ => 'ConpherenceRoomListController',
+ 'panel/'
+ => 'ConpherenceNotificationPanelController',
+ 'participant/(?P<id>[1-9]\d*)/'
+ => 'ConpherenceParticipantController',
+ 'update/(?P<id>[1-9]\d*)/'
+ => 'ConpherenceUpdateController',
),
);
}
diff --git a/src/applications/conpherence/constants/ConpherenceImageData.php b/src/applications/conpherence/constants/ConpherenceImageData.php
deleted file mode 100644
--- a/src/applications/conpherence/constants/ConpherenceImageData.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-final class ConpherenceImageData extends ConpherenceConstants {
-
- const SIZE_ORIG = 'original';
- const SIZE_CROP = 'crop';
-
- const CROP_WIDTH = 200;
- const CROP_HEIGHT = 200;
-
-}
diff --git a/src/applications/conpherence/controller/ConpherenceColumnViewController.php b/src/applications/conpherence/controller/ConpherenceColumnViewController.php
--- a/src/applications/conpherence/controller/ConpherenceColumnViewController.php
+++ b/src/applications/conpherence/controller/ConpherenceColumnViewController.php
@@ -16,7 +16,7 @@
$latest_conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs($conpherence_phids)
- ->needCropPics(true)
+ ->needProfileImage(true)
->needParticipantCache(true)
->execute();
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
@@ -31,7 +31,7 @@
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($request->getInt('id')))
- ->needCropPics(true)
+ ->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
->executeOne();
@@ -41,7 +41,7 @@
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array($participant->getConpherencePHID()))
- ->needCropPics(true)
+ ->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT)
->executeOne();
diff --git a/src/applications/conpherence/controller/ConpherenceController.php b/src/applications/conpherence/controller/ConpherenceController.php
--- a/src/applications/conpherence/controller/ConpherenceController.php
+++ b/src/applications/conpherence/controller/ConpherenceController.php
@@ -66,6 +66,11 @@
$conpherence,
PhabricatorPolicyCapability::CAN_EDIT);
+ if ($can_edit) {
+ $header->setImageURL(
+ $this->getApplicationURI('picture/'.$conpherence->getID()).'/');
+ }
+
$participating = $conpherence->getParticipantIfExists($viewer->getPHID());
$can_join = PhabricatorPolicyFilter::hasCapability(
$viewer,
diff --git a/src/applications/conpherence/controller/ConpherenceListController.php b/src/applications/conpherence/controller/ConpherenceListController.php
--- a/src/applications/conpherence/controller/ConpherenceListController.php
+++ b/src/applications/conpherence/controller/ConpherenceListController.php
@@ -158,7 +158,7 @@
$conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs($conpherence_phids)
- ->needCropPics(true)
+ ->needProfileImage(true)
->needParticipantCache(true)
->execute();
diff --git a/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php b/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
--- a/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
+++ b/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
@@ -18,7 +18,7 @@
$conpherences = id(new ConpherenceThreadQuery())
->setViewer($user)
->withPHIDs(array_keys($participant_data))
- ->needCropPics(true)
+ ->needProfileImage(true)
->needTransactions(true)
->setTransactionLimit(3 * 5)
->needParticipantCache(true)
diff --git a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
@@ -0,0 +1,236 @@
+<?php
+
+final class ConpherenceRoomPictureController
+ extends ConpherenceController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ $conpherence = id(new ConpherenceThreadQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->needProfileImage(true)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$conpherence) {
+ return new Aphront404Response();
+ }
+
+ $conpherence_uri = '/conpherence/'.$id.'/';
+ $monogram = $conpherence->getMonogram();
+
+ $supported_formats = PhabricatorFile::getTransformableImageFormats();
+ $e_file = true;
+ $errors = array();
+
+ if ($request->isFormPost()) {
+ $phid = $request->getStr('phid');
+ $is_default = false;
+ if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
+ $phid = null;
+ $is_default = true;
+ } else if ($phid) {
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($phid))
+ ->executeOne();
+ } else {
+ if ($request->getFileExists('picture')) {
+ $file = PhabricatorFile::newFromPHPUpload(
+ $_FILES['picture'],
+ array(
+ 'authorPHID' => $viewer->getPHID(),
+ 'canCDN' => true,
+ ));
+ } else {
+ $e_file = pht('Required');
+ $errors[] = pht(
+ 'You must choose a file when uploading a new room picture.');
+ }
+ }
+
+ if (!$errors && !$is_default) {
+ if (!$file->isTransformableImage()) {
+ $e_file = pht('Not Supported');
+ $errors[] = pht(
+ 'This server only supports these image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $xform = PhabricatorFileTransform::getTransformByKey(
+ PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
+ $xformed = $xform->executeTransform($file);
+ }
+ }
+
+ if (!$errors) {
+ if ($is_default) {
+ $new_value = null;
+ } else {
+ $xformed->attachToObject($conpherence->getPHID());
+ $new_value = $xformed->getPHID();
+ }
+
+ $xactions = array();
+ $xactions[] = id(new ConpherenceTransaction())
+ ->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)
+ ->setNewValue($new_value);
+
+ $editor = id(new ConpherenceEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnMissingFields(true)
+ ->setContinueOnNoEffect(true);
+
+ $editor->applyTransactions($conpherence, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($conpherence_uri);
+ }
+ }
+
+ $title = pht('Edit Room Picture');
+
+ $form = id(new PHUIFormLayoutView())
+ ->setUser($viewer);
+
+ $default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
+
+ $images = array();
+
+ $current = $conpherence->getProfileImagePHID();
+ $has_current = false;
+ if ($current) {
+ $files = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($current))
+ ->execute();
+ if ($files) {
+ $file = head($files);
+ if ($file->isTransformableImage()) {
+ $has_current = true;
+ $images[$current] = array(
+ 'uri' => $file->getBestURI(),
+ 'tip' => pht('Current Picture'),
+ );
+ }
+ }
+ }
+
+ $images[PhabricatorPHIDConstants::PHID_VOID] = array(
+ 'uri' => $default_image->getBestURI(),
+ 'tip' => pht('Default Picture'),
+ );
+
+ require_celerity_resource('people-profile-css');
+ Javelin::initBehavior('phabricator-tooltips', array());
+
+ $buttons = array();
+ foreach ($images as $phid => $spec) {
+ $button = javelin_tag(
+ 'button',
+ array(
+ 'class' => 'grey profile-image-button',
+ 'sigil' => 'has-tooltip',
+ 'meta' => array(
+ 'tip' => $spec['tip'],
+ 'size' => 300,
+ ),
+ ),
+ phutil_tag(
+ 'img',
+ array(
+ 'height' => 50,
+ 'width' => 50,
+ 'src' => $spec['uri'],
+ )));
+
+ $button = array(
+ phutil_tag(
+ 'input',
+ array(
+ 'type' => 'hidden',
+ 'name' => 'phid',
+ 'value' => $phid,
+ )),
+ $button,
+ );
+
+ $button = phabricator_form(
+ $viewer,
+ array(
+ 'class' => 'profile-image-form',
+ 'method' => 'POST',
+ ),
+ $button);
+
+ $buttons[] = $button;
+ }
+
+ if ($has_current) {
+ $form->appendChild(
+ id(new AphrontFormMarkupControl())
+ ->setLabel(pht('Current Picture'))
+ ->setValue(array_shift($buttons)));
+ }
+
+ $form->appendChild(
+ id(new AphrontFormMarkupControl())
+ ->setLabel(pht('Use Picture'))
+ ->setValue($buttons));
+
+ $form_box = id(new PHUIObjectBoxView())
+ ->setHeaderText($title)
+ ->setFormErrors($errors)
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+ ->setForm($form);
+
+ $upload_form = id(new AphrontFormView())
+ ->setUser($viewer)
+ ->setEncType('multipart/form-data')
+ ->appendChild(
+ id(new AphrontFormFileControl())
+ ->setName('picture')
+ ->setLabel(pht('Upload Picture'))
+ ->setError($e_file)
+ ->setCaption(
+ pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->addCancelButton('/'.$monogram)
+ ->setValue(pht('Upload Picture')));
+
+ $upload_box = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Upload New Picture'))
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+ ->setForm($upload_form);
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb($conpherence->getTitle(), '/'.$monogram);
+ $crumbs->addTextCrumb(pht('Room Picture'));
+ $crumbs->setBorder(true);
+
+ $header = id(new PHUIHeaderView())
+ ->setHeader(pht('Edit Room Picture'))
+ ->setHeaderIcon('fa-camera');
+
+ $view = id(new PHUITwoColumnView())
+ ->setHeader($header)
+ ->setFooter(array(
+ $form_box,
+ $upload_box,
+ ));
+
+ return $this->newPage()
+ ->setTitle($title)
+ ->setCrumbs($crumbs)
+ ->appendChild(
+ array(
+ $view,
+ ));
+
+ }
+}
diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php
--- a/src/applications/conpherence/controller/ConpherenceUpdateController.php
+++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php
@@ -36,8 +36,6 @@
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
- ->needOrigPics(true)
- ->needCropPics(true)
->needParticipants($need_participants)
->requireCapabilities($needed_capabilities)
->executeOne();
@@ -131,57 +129,14 @@
break;
case ConpherenceUpdateActions::METADATA:
- $top = $request->getInt('image_y');
- $left = $request->getInt('image_x');
- $file_id = $request->getInt('file_id');
$title = $request->getStr('title');
$topic = $request->getStr('topic');
- if ($file_id) {
- $orig_file = id(new PhabricatorFileQuery())
- ->setViewer($user)
- ->withIDs(array($file_id))
- ->executeOne();
- $xactions[] = id(new ConpherenceTransaction())
- ->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)
- ->setNewValue($orig_file);
- $okay = $orig_file->isTransformableImage();
- if ($okay) {
- $xformer = new PhabricatorImageTransformer();
- $crop_file = $xformer->executeConpherenceTransform(
- $orig_file,
- 0,
- 0,
- ConpherenceImageData::CROP_WIDTH,
- ConpherenceImageData::CROP_HEIGHT);
- $xactions[] = id(new ConpherenceTransaction())
- ->setTransactionType(
- ConpherenceTransaction::TYPE_PICTURE_CROP)
- ->setNewValue($crop_file->getPHID());
- }
- $response_mode = 'redirect';
- }
// all other metadata updates are continue requests
if (!$request->isContinueRequest()) {
break;
}
- if ($top !== null || $left !== null) {
- $file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG);
- $xformer = new PhabricatorImageTransformer();
- $xformed = $xformer->executeConpherenceTransform(
- $file,
- $top,
- $left,
- ConpherenceImageData::CROP_WIDTH,
- ConpherenceImageData::CROP_HEIGHT);
- $image_phid = $xformed->getPHID();
-
- $xactions[] = id(new ConpherenceTransaction())
- ->setTransactionType(
- ConpherenceTransaction::TYPE_PICTURE_CROP)
- ->setNewValue($image_phid);
- }
$title = $request->getStr('title');
$topic = $request->getStr('topic');
$xactions[] = id(new ConpherenceTransaction())
@@ -491,31 +446,6 @@
->setName('topic')
->setValue($conpherence->getTopic()));
- $nopic = $this->getRequest()->getExists('nopic');
- $image = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG);
- if ($nopic) {
- // do not render any pic related controls
- } else if ($image) {
- $crop_uri = $conpherence->loadImageURI(ConpherenceImageData::SIZE_CROP);
- $form
- ->appendChild(
- id(new AphrontFormMarkupControl())
- ->setLabel(pht('Image'))
- ->setValue(phutil_tag(
- 'img',
- array(
- 'src' => $crop_uri,
- ))))
- ->appendChild(
- id(new ConpherenceFormDragAndDropUploadControl())
- ->setLabel(pht('Change Image')));
- } else {
- $form
- ->appendChild(
- id(new ConpherenceFormDragAndDropUploadControl())
- ->setLabel(pht('Image')));
- }
-
$policies = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
@@ -567,7 +497,6 @@
$latest_transaction_id) {
$minimal_display = $this->getRequest()->getExists('minimal_display');
- $need_widget_data = false;
$need_transactions = false;
$need_participant_cache = true;
switch ($action) {
@@ -578,7 +507,6 @@
case ConpherenceUpdateActions::MESSAGE:
case ConpherenceUpdateActions::ADD_PERSON:
$need_transactions = true;
- $need_widget_data = !$minimal_display;
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
case ConpherenceUpdateActions::NOTIFICATIONS:
@@ -590,7 +518,7 @@
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->setAfterTransactionID($latest_transaction_id)
- ->needCropPics(true)
+ ->needProfileImage(true)
->needParticipantCache($need_participant_cache)
->needParticipants(true)
->needTransactions($need_transactions)
diff --git a/src/applications/conpherence/controller/ConpherenceViewController.php b/src/applications/conpherence/controller/ConpherenceViewController.php
--- a/src/applications/conpherence/controller/ConpherenceViewController.php
+++ b/src/applications/conpherence/controller/ConpherenceViewController.php
@@ -19,7 +19,7 @@
$query = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
- ->needCropPics(true)
+ ->needProfileImage(true)
->needParticipantCache(true)
->needTransactions(true)
->setTransactionLimit($this->getMainQueryLimit());
diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php
--- a/src/applications/conpherence/editor/ConpherenceEditor.php
+++ b/src/applications/conpherence/editor/ConpherenceEditor.php
@@ -91,7 +91,6 @@
$types[] = ConpherenceTransaction::TYPE_TOPIC;
$types[] = ConpherenceTransaction::TYPE_PARTICIPANTS;
$types[] = ConpherenceTransaction::TYPE_PICTURE;
- $types[] = ConpherenceTransaction::TYPE_PICTURE_CROP;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
@@ -109,9 +108,7 @@
case ConpherenceTransaction::TYPE_TOPIC:
return $object->getTopic();
case ConpherenceTransaction::TYPE_PICTURE:
- return $object->getImagePHID(ConpherenceImageData::SIZE_ORIG);
- case ConpherenceTransaction::TYPE_PICTURE_CROP:
- return $object->getImagePHID(ConpherenceImageData::SIZE_CROP);
+ return $object->getProfileImagePHID();
case ConpherenceTransaction::TYPE_PARTICIPANTS:
if ($this->getIsNewObject()) {
return array();
@@ -127,11 +124,8 @@
switch ($xaction->getTransactionType()) {
case ConpherenceTransaction::TYPE_TITLE:
case ConpherenceTransaction::TYPE_TOPIC:
- case ConpherenceTransaction::TYPE_PICTURE_CROP:
- return $xaction->getNewValue();
case ConpherenceTransaction::TYPE_PICTURE:
- $file = $xaction->getNewValue();
- return $file->getPHID();
+ return $xaction->getNewValue();
case ConpherenceTransaction::TYPE_PARTICIPANTS:
return $this->getPHIDTransactionNewValue($xaction);
}
@@ -224,14 +218,7 @@
$object->setTopic($xaction->getNewValue());
break;
case ConpherenceTransaction::TYPE_PICTURE:
- $object->setImagePHID(
- $xaction->getNewValue(),
- ConpherenceImageData::SIZE_ORIG);
- break;
- case ConpherenceTransaction::TYPE_PICTURE_CROP:
- $object->setImagePHID(
- $xaction->getNewValue(),
- ConpherenceImageData::SIZE_CROP);
+ $object->setProfileImagePHID($xaction->getNewValue());
break;
case ConpherenceTransaction::TYPE_PARTICIPANTS:
if (!$this->getIsNewObject()) {
@@ -571,19 +558,6 @@
return true;
}
- protected function extractFilePHIDsFromCustomTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case ConpherenceTransaction::TYPE_PICTURE:
- case ConpherenceTransaction::TYPE_PICTURE_CROP:
- return array($xaction->getNewValue());
- }
-
- return parent::extractFilePHIDsFromCustomTransaction($object, $xaction);
- }
-
protected function validateTransaction(
PhabricatorLiskDAO $object,
$type,
@@ -612,21 +586,6 @@
$errors[] = $error;
}
break;
- case ConpherenceTransaction::TYPE_PICTURE:
- foreach ($xactions as $xaction) {
- $file = $xaction->getNewValue();
- if (!$file->isTransformableImage()) {
- $detail = pht('This server only supports these image formats: %s.',
- implode(', ', PhabricatorFile::getTransformableImageFormats()));
- $error = new PhabricatorApplicationTransactionValidationError(
- $type,
- pht('Invalid'),
- $detail,
- last($xactions));
- $errors[] = $error;
- }
- }
- break;
case ConpherenceTransaction::TYPE_PARTICIPANTS:
foreach ($xactions as $xaction) {
$new_phids = $this->getPHIDTransactionNewValue($xaction, array());
diff --git a/src/applications/conpherence/query/ConpherenceThreadQuery.php b/src/applications/conpherence/query/ConpherenceThreadQuery.php
--- a/src/applications/conpherence/query/ConpherenceThreadQuery.php
+++ b/src/applications/conpherence/query/ConpherenceThreadQuery.php
@@ -9,14 +9,13 @@
private $ids;
private $participantPHIDs;
private $needParticipants;
- private $needCropPics;
- private $needOrigPics;
private $needTransactions;
private $needParticipantCache;
private $afterTransactionID;
private $beforeTransactionID;
private $transactionLimit;
private $fulltext;
+ private $needProfileImage;
public function needParticipantCache($participant_cache) {
$this->needParticipantCache = $participant_cache;
@@ -28,13 +27,8 @@
return $this;
}
- public function needCropPics($need) {
- $this->needCropPics = $need;
- return $this;
- }
-
- public function needOrigPics($need_widget_data) {
- $this->needOrigPics = $need_widget_data;
+ public function needProfileImage($need) {
+ $this->needProfileImage = $need;
return $this;
}
@@ -110,14 +104,33 @@
if ($this->needTransactions) {
$this->loadTransactionsAndHandles($conpherences);
}
- if ($this->needOrigPics || $this->needCropPics) {
- $this->initImages($conpherences);
- }
- if ($this->needOrigPics) {
- $this->loadOrigPics($conpherences);
- }
- if ($this->needCropPics) {
- $this->loadCropPics($conpherences);
+ if ($this->needProfileImage) {
+ $default = null;
+ $file_phids = mpull($conpherences, 'getProfileImagePHID');
+ $file_phids = array_filter($file_phids);
+ if ($file_phids) {
+ $files = id(new PhabricatorFileQuery())
+ ->setParentQuery($this)
+ ->setViewer($this->getViewer())
+ ->withPHIDs($file_phids)
+ ->execute();
+ $files = mpull($files, null, 'getPHID');
+ } else {
+ $files = array();
+ }
+
+ foreach ($conpherences as $conpherence) {
+ $file = idx($files, $conpherence->getProfileImagePHID());
+ if (!$file) {
+ if (!$default) {
+ $default = PhabricatorFile::loadBuiltin(
+ $this->getViewer(),
+ 'conpherence.png');
+ }
+ $file = $default;
+ }
+ $conpherence->attachProfileImageFile($file);
+ }
}
}
@@ -266,50 +279,6 @@
return $this;
}
- private function loadOrigPics(array $conpherences) {
- return $this->loadPics(
- $conpherences,
- ConpherenceImageData::SIZE_ORIG);
- }
-
- private function loadCropPics(array $conpherences) {
- return $this->loadPics(
- $conpherences,
- ConpherenceImageData::SIZE_CROP);
- }
-
- private function initImages($conpherences) {
- foreach ($conpherences as $conpherence) {
- $conpherence->attachImages(array());
- }
- }
-
- private function loadPics(array $conpherences, $size) {
- $conpherence_pic_phids = array();
- foreach ($conpherences as $conpherence) {
- $phid = $conpherence->getImagePHID($size);
- if ($phid) {
- $conpherence_pic_phids[$conpherence->getPHID()] = $phid;
- }
- }
-
- if (!$conpherence_pic_phids) {
- return $this;
- }
-
- $files = id(new PhabricatorFileQuery())
- ->setViewer($this->getViewer())
- ->withPHIDs($conpherence_pic_phids)
- ->execute();
- $files = mpull($files, null, 'getPHID');
-
- foreach ($conpherence_pic_phids as $conpherence_phid => $pic_phid) {
- $conpherences[$conpherence_phid]->setImage($files[$pic_phid], $size);
- }
-
- return $this;
- }
-
public function getQueryApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
diff --git a/src/applications/conpherence/storage/ConpherenceThread.php b/src/applications/conpherence/storage/ConpherenceThread.php
--- a/src/applications/conpherence/storage/ConpherenceThread.php
+++ b/src/applications/conpherence/storage/ConpherenceThread.php
@@ -10,6 +10,7 @@
protected $title;
protected $topic;
protected $imagePHIDs = array();
+ protected $profileImagePHID;
protected $messageCount;
protected $recentParticipantPHIDs = array();
protected $mailKey;
@@ -19,8 +20,8 @@
private $participants = self::ATTACHABLE;
private $transactions = self::ATTACHABLE;
+ private $profileImageFile = self::ATTACHABLE;
private $handles = self::ATTACHABLE;
- private $images = self::ATTACHABLE;
public static function initializeNewRoom(PhabricatorUser $sender) {
$default_policy = id(new ConpherenceThreadMembersPolicyRule())
@@ -30,7 +31,6 @@
->setTitle('')
->setTopic('')
->attachParticipants(array())
- ->attachImages(array())
->setViewPolicy($default_policy)
->setEditPolicy($default_policy)
->setJoinPolicy($default_policy);
@@ -49,6 +49,7 @@
'messageCount' => 'uint64',
'mailKey' => 'text20',
'joinPolicy' => 'policy',
+ 'profileImagePHID' => 'phid?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
@@ -76,46 +77,21 @@
return 'Z'.$this->getID();
}
- public function getImagePHID($size) {
- $image_phids = $this->getImagePHIDs();
- return idx($image_phids, $size);
- }
- public function setImagePHID($phid, $size) {
- $image_phids = $this->getImagePHIDs();
- $image_phids[$size] = $phid;
- return $this->setImagePHIDs($image_phids);
- }
-
- public function getImage($size) {
- $images = $this->getImages();
- return idx($images, $size);
- }
- public function setImage(PhabricatorFile $file, $size) {
- $files = $this->getImages();
- $files[$size] = $file;
- return $this->attachImages($files);
- }
- public function attachImages(array $files) {
- assert_instances_of($files, 'PhabricatorFile');
- $this->images = $files;
- return $this;
- }
- private function getImages() {
- return $this->assertAttached($this->images);
- }
-
public function attachParticipants(array $participants) {
assert_instances_of($participants, 'ConpherenceParticipant');
$this->participants = $participants;
return $this;
}
+
public function getParticipants() {
return $this->assertAttached($this->participants);
}
+
public function getParticipant($phid) {
$participants = $this->getParticipants();
return $participants[$phid];
}
+
public function getParticipantIfExists($phid, $default = null) {
$participants = $this->getParticipants();
return idx($participants, $phid, $default);
@@ -131,6 +107,7 @@
$this->handles = $handles;
return $this;
}
+
public function getHandles() {
return $this->assertAttached($this->handles);
}
@@ -140,9 +117,11 @@
$this->transactions = $transactions;
return $this;
}
+
public function getTransactions($assert_attached = true) {
return $this->assertAttached($this->transactions);
}
+
public function hasAttachedTransactions() {
return $this->transactions !== self::ATTACHABLE;
}
@@ -156,14 +135,17 @@
$amount);
}
- public function loadImageURI($size) {
- $file = $this->getImage($size);
+ public function getProfileImageURI() {
+ return $this->getProfileImageFile()->getBestURI();
+ }
- if ($file) {
- return $file->getBestURI();
- }
+ public function attachProfileImageFile(PhabricatorFile $file) {
+ $this->profileImageFile = $file;
+ return $this;
+ }
- return PhabricatorUser::getDefaultProfileImageURI();
+ public function getProfileImageFile() {
+ return $this->assertAttached($this->profileImageFile);
}
/**
@@ -273,13 +255,7 @@
$lucky_handle = reset($handles);
}
- $img_src = null;
- $size = ConpherenceImageData::SIZE_CROP;
- if ($this->getImagePHID($size)) {
- $img_src = $this->getImage($size)->getBestURI();
- } else if ($lucky_handle) {
- $img_src = $lucky_handle->getImageURI();
- }
+ $img_src = $this->getProfileImageURI();
$message_title = null;
if ($subtitle_mode == 'message') {
diff --git a/src/applications/conpherence/storage/ConpherenceTransaction.php b/src/applications/conpherence/storage/ConpherenceTransaction.php
--- a/src/applications/conpherence/storage/ConpherenceTransaction.php
+++ b/src/applications/conpherence/storage/ConpherenceTransaction.php
@@ -7,7 +7,7 @@
const TYPE_PARTICIPANTS = 'participants';
const TYPE_DATE_MARKER = 'date-marker';
const TYPE_PICTURE = 'picture';
- const TYPE_PICTURE_CROP = 'picture-crop';
+ const TYPE_PICTURE_CROP = 'picture-crop'; // TODO: Nuke these from DB.
public function getApplicationName() {
return 'conpherence';
diff --git a/src/applications/conpherence/view/ConpherenceTransactionView.php b/src/applications/conpherence/view/ConpherenceTransactionView.php
--- a/src/applications/conpherence/view/ConpherenceTransactionView.php
+++ b/src/applications/conpherence/view/ConpherenceTransactionView.php
@@ -228,7 +228,6 @@
case ConpherenceTransaction::TYPE_TITLE:
case ConpherenceTransaction::TYPE_TOPIC:
case ConpherenceTransaction::TYPE_PICTURE:
- case ConpherenceTransaction::TYPE_PICTURE_CROP:
case ConpherenceTransaction::TYPE_PARTICIPANTS:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
diff --git a/webroot/rsrc/css/application/conpherence/header-pane.css b/webroot/rsrc/css/application/conpherence/header-pane.css
--- a/webroot/rsrc/css/application/conpherence/header-pane.css
+++ b/webroot/rsrc/css/application/conpherence/header-pane.css
@@ -34,6 +34,10 @@
left: 0;
}
+.conpherence-header-pane .phui-header-image-href {
+ position: inherit;
+}
+
.conpherence-header-pane .phui-header-col2 {
height: 40px;
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 9:09 PM (15 h, 25 m ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/iw/mc/dbtfpfeut3zwbta4
Default Alt Text
D16669.id40127.diff (40 KB)

Event Timeline