Page MenuHomePhabricator

D16669.diff
No OneTemporary

D16669.diff

diff --git a/resources/builtin/conpherence.png b/resources/builtin/conpherence.png
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -7,7 +7,7 @@
*/
return array(
'names' => array(
- 'conpherence.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,34 @@
+<?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 = phutil_json_decode($row['imagePHIDs']);
+ if (!$images) {
+ return;
+ }
+
+ $file_phid = idx($images, 'original');
+
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs(array($file_phid))
+ ->executeOne();
+
+ $xform = PhabricatorFileTransform::getTransformByKey(
+ PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
+ $xformed = $xform->executeTransform($file);
+ $new_phid = $xformed->getPHID();
+
+ queryfx(
+ $conn,
+ 'UPDATE %T SET profileImagePHID = %s WHERE id = %d',
+ $table->getTableName(),
+ $new_phid,
+ $row['id']);
+}
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,234 @@
+<?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();
+ }
+
+ $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('/'.$monogram);
+ }
+ }
+
+ $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) {
+ $file = id(new PhabricatorFileQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($current))
+ ->executeOne();
+ if ($file) {
+ 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()) {
@@ -339,6 +326,10 @@
PhabricatorLiskDAO $object,
array $xactions) {
+ if (!$xactions) {
+ return $xactions;
+ }
+
$message_count = 0;
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
@@ -571,19 +562,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 +590,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
@@ -9,7 +9,8 @@
protected $title;
protected $topic;
- protected $imagePHIDs = array();
+ protected $imagePHIDs = array(); // TODO; nuke after migrations
+ 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
Tue, Oct 22, 7:05 AM (3 w, 6 d ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/3o/bz/rould25tyjvlwgdm
Default Alt Text
D16669.diff (37 KB)

Event Timeline