@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Conpherence - add back in custom images

Summary: Fixes T7254. This reverts the previous functionality, but makes pertinent updates like scaling the images to 35 x 35. Codebase had moved on quite a bit so far from a straight revert but nothing too tricky relative to the code that was here before. This does not allow for changing the images from the conpherence durable column view -- that would require some JS trickery, but also doesn't fit into the current notion of the column being "light". Can always modify this later.

Test Plan:
- from full conpherence, uploaded a square pic and things looked nice
- from full conpherence, uploaded a rectangular pic and wasnt happy, so reinvoked edit dialog and used crop control to make it better
- noted could not update picture from conpherence durable column
- used different user and noted could see custom picture

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: CodeMouse92, Korvin, epriestley

Maniphest Tasks: T7254

Differential Revision: https://secure.phabricator.com/D12648

+447 -8
+8
resources/celerity/map.php
··· 356 356 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 357 357 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', 358 358 'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '6709c934', 359 + 'rsrc/js/application/conpherence/behavior-drag-and-drop-photo.js' => 'cf86d16a', 359 360 'rsrc/js/application/conpherence/behavior-durable-column.js' => '657c2b50', 360 361 'rsrc/js/application/conpherence/behavior-menu.js' => '804b0773', 361 362 'rsrc/js/application/conpherence/behavior-pontificate.js' => '21ba5861', ··· 561 562 'javelin-behavior-audit-preview' => 'd835b03a', 562 563 'javelin-behavior-choose-control' => '6153c708', 563 564 'javelin-behavior-config-reorder-fields' => '14a827de', 565 + 'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a', 564 566 'javelin-behavior-conpherence-menu' => '804b0773', 565 567 'javelin-behavior-conpherence-pontificate' => '21ba5861', 566 568 'javelin-behavior-conpherence-widget-pane' => '93568464', ··· 1788 1790 'javelin-dom', 1789 1791 'javelin-stratcom', 1790 1792 'phabricator-phtize', 1793 + ), 1794 + 'cf86d16a' => array( 1795 + 'javelin-behavior', 1796 + 'javelin-dom', 1797 + 'javelin-workflow', 1798 + 'phabricator-drag-and-drop-file-upload', 1791 1799 ), 1792 1800 'd19198c8' => array( 1793 1801 'javelin-install',
+5
resources/sql/autopatches/20150501.conpherencepics.sql
··· 1 + ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread 2 + ADD imagePHIDs LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL AFTER title; 3 + 4 + UPDATE {$NAMESPACE}_conpherence.conpherence_thread 5 + SET imagePHIDS = '[]';
+6
src/__phutil_library_map__.php
··· 230 230 'ConpherenceDurableColumnView' => 'applications/conpherence/view/ConpherenceDurableColumnView.php', 231 231 'ConpherenceEditor' => 'applications/conpherence/editor/ConpherenceEditor.php', 232 232 'ConpherenceFileWidgetView' => 'applications/conpherence/view/ConpherenceFileWidgetView.php', 233 + 'ConpherenceFormDragAndDropUploadControl' => 'applications/conpherence/view/ConpherenceFormDragAndDropUploadControl.php', 233 234 'ConpherenceFulltextQuery' => 'applications/conpherence/query/ConpherenceFulltextQuery.php', 234 235 'ConpherenceHovercardEventListener' => 'applications/conpherence/events/ConpherenceHovercardEventListener.php', 236 + 'ConpherenceImageData' => 'applications/conpherence/constants/ConpherenceImageData.php', 235 237 'ConpherenceIndex' => 'applications/conpherence/storage/ConpherenceIndex.php', 236 238 'ConpherenceLayoutView' => 'applications/conpherence/view/ConpherenceLayoutView.php', 237 239 'ConpherenceListController' => 'applications/conpherence/controller/ConpherenceListController.php', ··· 244 246 'ConpherenceParticipantQuery' => 'applications/conpherence/query/ConpherenceParticipantQuery.php', 245 247 'ConpherenceParticipationStatus' => 'applications/conpherence/constants/ConpherenceParticipationStatus.php', 246 248 'ConpherencePeopleWidgetView' => 'applications/conpherence/view/ConpherencePeopleWidgetView.php', 249 + 'ConpherencePicCropControl' => 'applications/conpherence/view/ConpherencePicCropControl.php', 247 250 'ConpherenceQueryThreadConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceQueryThreadConduitAPIMethod.php', 248 251 'ConpherenceQueryTransactionConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceQueryTransactionConduitAPIMethod.php', 249 252 'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php', ··· 3467 3470 'ConpherenceDurableColumnView' => 'AphrontTagView', 3468 3471 'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor', 3469 3472 'ConpherenceFileWidgetView' => 'ConpherenceWidgetView', 3473 + 'ConpherenceFormDragAndDropUploadControl' => 'AphrontFormControl', 3470 3474 'ConpherenceFulltextQuery' => 'PhabricatorOffsetPagedQuery', 3471 3475 'ConpherenceHovercardEventListener' => 'PhabricatorEventListener', 3476 + 'ConpherenceImageData' => 'ConpherenceConstants', 3472 3477 'ConpherenceIndex' => 'ConpherenceDAO', 3473 3478 'ConpherenceLayoutView' => 'AphrontView', 3474 3479 'ConpherenceListController' => 'ConpherenceController', ··· 3481 3486 'ConpherenceParticipantQuery' => 'PhabricatorOffsetPagedQuery', 3482 3487 'ConpherenceParticipationStatus' => 'ConpherenceConstants', 3483 3488 'ConpherencePeopleWidgetView' => 'ConpherenceWidgetView', 3489 + 'ConpherencePicCropControl' => 'AphrontFormControl', 3484 3490 'ConpherenceQueryThreadConduitAPIMethod' => 'ConpherenceConduitAPIMethod', 3485 3491 'ConpherenceQueryTransactionConduitAPIMethod' => 'ConpherenceConduitAPIMethod', 3486 3492 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler',
+11
src/applications/conpherence/constants/ConpherenceImageData.php
··· 1 + <?php 2 + 3 + final class ConpherenceImageData extends ConpherenceConstants { 4 + 5 + const SIZE_ORIG = 'original'; 6 + const SIZE_CROP = 'crop'; 7 + 8 + const CROP_WIDTH = 35; 9 + const CROP_HEIGHT = 35; 10 + 11 + }
-2
src/applications/conpherence/constants/ConpherenceTransactionType.php
··· 6 6 const TYPE_TITLE = 'title'; 7 7 const TYPE_PARTICIPANTS = 'participants'; 8 8 const TYPE_DATE_MARKER = 'date-marker'; 9 - 10 - /* these two are deprecated but keep them around for legacy installs */ 11 9 const TYPE_PICTURE = 'picture'; 12 10 const TYPE_PICTURE_CROP = 'picture-crop'; 13 11
+3
src/applications/conpherence/controller/ConpherenceColumnViewController.php
··· 16 16 $latest_conpherences = id(new ConpherenceThreadQuery()) 17 17 ->setViewer($user) 18 18 ->withPHIDs($conpherence_phids) 19 + ->needCropPics(true) 19 20 ->needParticipantCache(true) 20 21 ->execute(); 21 22 $latest_conpherences = mpull($latest_conpherences, null, 'getPHID'); ··· 30 31 $conpherence = id(new ConpherenceThreadQuery()) 31 32 ->setViewer($user) 32 33 ->withIDs(array($request->getInt('id'))) 34 + ->needCropPics(true) 33 35 ->needTransactions(true) 34 36 ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT) 35 37 ->executeOne(); ··· 39 41 $conpherence = id(new ConpherenceThreadQuery()) 40 42 ->setViewer($user) 41 43 ->withPHIDs(array($participant->getConpherencePHID())) 44 + ->needCropPics(true) 42 45 ->needTransactions(true) 43 46 ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT) 44 47 ->executeOne();
+1
src/applications/conpherence/controller/ConpherenceListController.php
··· 138 138 $conpherences = id(new ConpherenceThreadQuery()) 139 139 ->setViewer($user) 140 140 ->withPHIDs($conpherence_phids) 141 + ->needCropPics(true) 141 142 ->needParticipantCache(true) 142 143 ->execute(); 143 144
+1
src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
··· 17 17 $conpherences = id(new ConpherenceThreadQuery()) 18 18 ->setViewer($user) 19 19 ->withPHIDs(array_keys($participant_data)) 20 + ->needCropPics(true) 20 21 ->needTransactions(true) 21 22 ->setTransactionLimit(3 * 5) 22 23 ->needParticipantCache(true)
+78 -1
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 37 37 ->setViewer($user) 38 38 ->withIDs(array($conpherence_id)) 39 39 ->needFilePHIDs(true) 40 + ->needOrigPics(true) 41 + ->needCropPics(true) 40 42 ->needParticipants($need_participants) 41 43 ->requireCapabilities($needed_capabilities) 42 44 ->executeOne(); ··· 132 134 ->setContent($result); 133 135 break; 134 136 case ConpherenceUpdateActions::METADATA: 135 - // all metadata updates are continue requests 137 + $top = $request->getInt('image_y'); 138 + $left = $request->getInt('image_x'); 139 + $file_id = $request->getInt('file_id'); 140 + $title = $request->getStr('title'); 141 + if ($file_id) { 142 + $orig_file = id(new PhabricatorFileQuery()) 143 + ->setViewer($user) 144 + ->withIDs(array($file_id)) 145 + ->executeOne(); 146 + $xactions[] = id(new ConpherenceTransaction()) 147 + ->setTransactionType(ConpherenceTransactionType::TYPE_PICTURE) 148 + ->setNewValue($orig_file); 149 + $okay = $orig_file->isTransformableImage(); 150 + if ($okay) { 151 + $xformer = new PhabricatorImageTransformer(); 152 + $crop_file = $xformer->executeConpherenceTransform( 153 + $orig_file, 154 + 0, 155 + 0, 156 + ConpherenceImageData::CROP_WIDTH, 157 + ConpherenceImageData::CROP_HEIGHT); 158 + $xactions[] = id(new ConpherenceTransaction()) 159 + ->setTransactionType( 160 + ConpherenceTransactionType::TYPE_PICTURE_CROP) 161 + ->setNewValue($crop_file->getPHID()); 162 + } 163 + $response_mode = 'redirect'; 164 + } 165 + 166 + // all other metadata updates are continue requests 136 167 if (!$request->isContinueRequest()) { 137 168 break; 138 169 } 139 170 171 + if ($top !== null || $left !== null) { 172 + $file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG); 173 + $xformer = new PhabricatorImageTransformer(); 174 + $xformed = $xformer->executeConpherenceTransform( 175 + $file, 176 + $top, 177 + $left, 178 + ConpherenceImageData::CROP_WIDTH, 179 + ConpherenceImageData::CROP_HEIGHT); 180 + $image_phid = $xformed->getPHID(); 181 + 182 + $xactions[] = id(new ConpherenceTransaction()) 183 + ->setTransactionType( 184 + ConpherenceTransactionType::TYPE_PICTURE_CROP) 185 + ->setNewValue($image_phid); 186 + } 140 187 $title = $request->getStr('title'); 141 188 $xactions[] = id(new ConpherenceTransaction()) 142 189 ->setTransactionType(ConpherenceTransactionType::TYPE_TITLE) ··· 323 370 ->setName('title') 324 371 ->setValue($conpherence->getTitle())); 325 372 373 + $nopic = $this->getRequest()->getExists('nopic'); 374 + $image = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG); 375 + if ($nopic) { 376 + // do not render any pic related controls 377 + } else if ($image) { 378 + $crop_uri = $conpherence->loadImageURI(ConpherenceImageData::SIZE_CROP); 379 + $form 380 + ->appendChild( 381 + id(new AphrontFormMarkupControl()) 382 + ->setLabel(pht('Image')) 383 + ->setValue(phutil_tag( 384 + 'img', 385 + array( 386 + 'src' => $crop_uri, 387 + )))) 388 + ->appendChild( 389 + id(new ConpherencePicCropControl()) 390 + ->setLabel(pht('Crop Image')) 391 + ->setValue($image)) 392 + ->appendChild( 393 + id(new ConpherenceFormDragAndDropUploadControl()) 394 + ->setLabel(pht('Change Image'))); 395 + } else { 396 + $form 397 + ->appendChild( 398 + id(new ConpherenceFormDragAndDropUploadControl()) 399 + ->setLabel(pht('Image'))); 400 + } 401 + 326 402 if ($conpherence->getIsRoom()) { 327 403 $title = pht('Update Room'); 328 404 $policies = id(new PhabricatorPolicyQuery()) ··· 400 476 $conpherence = id(new ConpherenceThreadQuery()) 401 477 ->setViewer($user) 402 478 ->setAfterTransactionID($latest_transaction_id) 479 + ->needCropPics(true) 403 480 ->needParticipantCache($need_participant_cache) 404 481 ->needWidgetData($need_widget_data) 405 482 ->needTransactions($need_transactions)
+1
src/applications/conpherence/controller/ConpherenceViewController.php
··· 15 15 $query = id(new ConpherenceThreadQuery()) 16 16 ->setViewer($user) 17 17 ->withIDs(array($conpherence_id)) 18 + ->needCropPics(true) 18 19 ->needParticipantCache(true) 19 20 ->needTransactions(true) 20 21 ->setTransactionLimit($this->getMainQueryLimit());
+49
src/applications/conpherence/editor/ConpherenceEditor.php
··· 120 120 $types[] = ConpherenceTransactionType::TYPE_TITLE; 121 121 $types[] = ConpherenceTransactionType::TYPE_PARTICIPANTS; 122 122 $types[] = ConpherenceTransactionType::TYPE_FILES; 123 + $types[] = ConpherenceTransactionType::TYPE_PICTURE; 124 + $types[] = ConpherenceTransactionType::TYPE_PICTURE_CROP; 123 125 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 124 126 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 125 127 $types[] = PhabricatorTransactions::TYPE_JOIN_POLICY; ··· 134 136 switch ($xaction->getTransactionType()) { 135 137 case ConpherenceTransactionType::TYPE_TITLE: 136 138 return $object->getTitle(); 139 + case ConpherenceTransactionType::TYPE_PICTURE: 140 + return $object->getImagePHID(ConpherenceImageData::SIZE_ORIG); 141 + case ConpherenceTransactionType::TYPE_PICTURE_CROP: 142 + return $object->getImagePHID(ConpherenceImageData::SIZE_CROP); 137 143 case ConpherenceTransactionType::TYPE_PARTICIPANTS: 138 144 if ($this->getIsNewObject()) { 139 145 return array(); ··· 150 156 151 157 switch ($xaction->getTransactionType()) { 152 158 case ConpherenceTransactionType::TYPE_TITLE: 159 + case ConpherenceTransactionType::TYPE_PICTURE_CROP: 153 160 return $xaction->getNewValue(); 161 + case ConpherenceTransactionType::TYPE_PICTURE: 162 + $file = $xaction->getNewValue(); 163 + return $file->getPHID(); 154 164 case ConpherenceTransactionType::TYPE_PARTICIPANTS: 155 165 case ConpherenceTransactionType::TYPE_FILES: 156 166 return $this->getPHIDTransactionNewValue($xaction); ··· 242 252 break; 243 253 case ConpherenceTransactionType::TYPE_TITLE: 244 254 $object->setTitle($xaction->getNewValue()); 255 + break; 256 + case ConpherenceTransactionType::TYPE_PICTURE: 257 + $object->setImagePHID( 258 + $xaction->getNewValue(), 259 + ConpherenceImageData::SIZE_ORIG); 260 + break; 261 + case ConpherenceTransactionType::TYPE_PICTURE_CROP: 262 + $object->setImagePHID( 263 + $xaction->getNewValue(), 264 + ConpherenceImageData::SIZE_CROP); 245 265 break; 246 266 case ConpherenceTransactionType::TYPE_PARTICIPANTS: 247 267 if (!$this->getIsNewObject()) { ··· 576 596 ); 577 597 } 578 598 599 + protected function extractFilePHIDsFromCustomTransaction( 600 + PhabricatorLiskDAO $object, 601 + PhabricatorApplicationTransaction $xaction) { 602 + 603 + switch ($xaction->getTransactionType()) { 604 + case ConpherenceTransactionType::TYPE_PICTURE: 605 + return array($xaction->getNewValue()->getPHID()); 606 + case ConpherenceTransactionType::TYPE_PICTURE_CROP: 607 + return array($xaction->getNewValue()); 608 + } 609 + 610 + return parent::extractFilePHIDsFromCustomTransaction($object, $xaction); 611 + } 612 + 579 613 protected function validateTransaction( 580 614 PhabricatorLiskDAO $object, 581 615 $type, ··· 606 640 607 641 $error->setIsMissingFieldError(true); 608 642 $errors[] = $error; 643 + } 644 + break; 645 + case ConpherenceTransactionType::TYPE_PICTURE: 646 + foreach ($xactions as $xaction) { 647 + $file = $xaction->getNewValue(); 648 + if (!$file->isTransformableImage()) { 649 + $detail = pht('This server only supports these image formats: %s.', 650 + implode(', ', PhabricatorFile::getTransformableImageFormats())); 651 + $error = new PhabricatorApplicationTransactionValidationError( 652 + $type, 653 + pht('Invalid'), 654 + $detail, 655 + last($xactions)); 656 + $errors[] = $error; 657 + } 609 658 } 610 659 break; 611 660 case ConpherenceTransactionType::TYPE_PARTICIPANTS:
+65
src/applications/conpherence/query/ConpherenceThreadQuery.php
··· 11 11 private $isRoom; 12 12 private $needParticipants; 13 13 private $needWidgetData; 14 + private $needCropPics; 15 + private $needOrigPics; 14 16 private $needTransactions; 15 17 private $needParticipantCache; 16 18 private $needFilePHIDs; ··· 36 38 37 39 public function needWidgetData($need_widget_data) { 38 40 $this->needWidgetData = $need_widget_data; 41 + return $this; 42 + } 43 + 44 + public function needCropPics($need) { 45 + $this->needCropPics = $need; 46 + return $this; 47 + } 48 + 49 + public function needOrigPics($need_widget_data) { 50 + $this->needOrigPics = $need_widget_data; 39 51 return $this; 40 52 } 41 53 ··· 121 133 } 122 134 if ($this->needWidgetData) { 123 135 $this->loadWidgetData($conpherences); 136 + } 137 + if ($this->needOrigPics || $this->needCropPics) { 138 + $this->initImages($conpherences); 139 + } 140 + if ($this->needOrigPics) { 141 + $this->loadOrigPics($conpherences); 142 + } 143 + if ($this->needCropPics) { 144 + $this->loadCropPics($conpherences); 124 145 } 125 146 } 126 147 ··· 390 411 'files_authors' => $files_authors, 391 412 ); 392 413 $conpherence->attachWidgetData($widget_data); 414 + } 415 + 416 + return $this; 417 + } 418 + 419 + private function loadOrigPics(array $conpherences) { 420 + return $this->loadPics( 421 + $conpherences, 422 + ConpherenceImageData::SIZE_ORIG); 423 + } 424 + 425 + private function loadCropPics(array $conpherences) { 426 + return $this->loadPics( 427 + $conpherences, 428 + ConpherenceImageData::SIZE_CROP); 429 + } 430 + 431 + private function initImages($conpherences) { 432 + foreach ($conpherences as $conpherence) { 433 + $conpherence->attachImages(array()); 434 + } 435 + } 436 + 437 + private function loadPics(array $conpherences, $size) { 438 + $conpherence_pic_phids = array(); 439 + foreach ($conpherences as $conpherence) { 440 + $phid = $conpherence->getImagePHID($size); 441 + if ($phid) { 442 + $conpherence_pic_phids[$conpherence->getPHID()] = $phid; 443 + } 444 + } 445 + 446 + if (!$conpherence_pic_phids) { 447 + return $this; 448 + } 449 + 450 + $files = id(new PhabricatorFileQuery()) 451 + ->setViewer($this->getViewer()) 452 + ->withPHIDs($conpherence_pic_phids) 453 + ->execute(); 454 + $files = mpull($files, null, 'getPHID'); 455 + 456 + foreach ($conpherence_pic_phids as $conpherence_phid => $pic_phid) { 457 + $conpherences[$conpherence_phid]->setImage($files[$pic_phid], $size); 393 458 } 394 459 395 460 return $this;
+47 -2
src/applications/conpherence/storage/ConpherenceThread.php
··· 8 8 PhabricatorDestructibleInterface { 9 9 10 10 protected $title; 11 + protected $imagePHIDs = array(); 11 12 protected $isRoom = 0; 12 13 protected $messageCount; 13 14 protected $recentParticipantPHIDs = array(); ··· 21 22 private $handles = self::ATTACHABLE; 22 23 private $filePHIDs = self::ATTACHABLE; 23 24 private $widgetData = self::ATTACHABLE; 24 - private $images = array(); 25 + private $images = self::ATTACHABLE; 25 26 26 27 public static function initializeNewThread(PhabricatorUser $sender) { 27 28 return id(new ConpherenceThread()) ··· 29 30 ->setTitle('') 30 31 ->attachParticipants(array()) 31 32 ->attachFilePHIDs(array()) 33 + ->attachImages(array()) 32 34 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 33 35 ->setEditPolicy(PhabricatorPolicies::POLICY_USER) 34 36 ->setJoinPolicy(PhabricatorPolicies::POLICY_USER); ··· 42 44 ->setTitle('') 43 45 ->attachParticipants(array()) 44 46 ->attachFilePHIDs(array()) 47 + ->attachImages(array()) 45 48 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 46 49 ->setEditPolicy($creator->getPHID()) 47 50 ->setJoinPolicy(PhabricatorPolicies::POLICY_USER); ··· 52 55 self::CONFIG_AUX_PHID => true, 53 56 self::CONFIG_SERIALIZATION => array( 54 57 'recentParticipantPHIDs' => self::SERIALIZATION_JSON, 58 + 'imagePHIDs' => self::SERIALIZATION_JSON, 55 59 ), 56 60 self::CONFIG_COLUMN_SCHEMA => array( 57 61 'title' => 'text255?', ··· 89 93 return 'Z'.$this->getID(); 90 94 } 91 95 96 + public function getImagePHID($size) { 97 + $image_phids = $this->getImagePHIDs(); 98 + return idx($image_phids, $size); 99 + } 100 + public function setImagePHID($phid, $size) { 101 + $image_phids = $this->getImagePHIDs(); 102 + $image_phids[$size] = $phid; 103 + return $this->setImagePHIDs($image_phids); 104 + } 105 + 106 + public function getImage($size) { 107 + $images = $this->getImages(); 108 + return idx($images, $size); 109 + } 110 + public function setImage(PhabricatorFile $file, $size) { 111 + $files = $this->getImages(); 112 + $files[$size] = $file; 113 + return $this->attachImages($files); 114 + } 115 + public function attachImages(array $files) { 116 + assert_instances_of($files, 'PhabricatorFile'); 117 + $this->images = $files; 118 + return $this; 119 + } 120 + private function getImages() { 121 + return $this->assertAttached($this->images); 122 + } 123 + 92 124 public function attachParticipants(array $participants) { 93 125 assert_instances_of($participants, 'ConpherenceParticipant'); 94 126 $this->participants = $participants; ··· 157 189 return $this->assertAttached($this->widgetData); 158 190 } 159 191 192 + public function loadImageURI($size) { 193 + $file = $this->getImage($size); 194 + 195 + if ($file) { 196 + return $file->getBestURI(); 197 + } 198 + 199 + return PhabricatorUser::getDefaultProfileImageURI(); 200 + } 201 + 160 202 public function getDisplayData(PhabricatorUser $user) { 161 203 if ($this->hasAttachedTransactions()) { 162 204 $transactions = $this->getTransactions(); ··· 201 243 } 202 244 203 245 $img_src = null; 204 - if ($lucky_handle) { 246 + $size = ConpherenceImageData::SIZE_CROP; 247 + if ($this->getImagePHID($size)) { 248 + $img_src = $this->getImage($size)->getBestURI(); 249 + } else if ($lucky_handle) { 205 250 $img_src = $lucky_handle->getImageURI(); 206 251 } 207 252
+13 -2
src/applications/conpherence/storage/ConpherenceTransaction.php
··· 32 32 case ConpherenceTransactionType::TYPE_PARTICIPANTS: 33 33 return ($old === null); 34 34 case ConpherenceTransactionType::TYPE_TITLE: 35 + case ConpherenceTransactionType::TYPE_PICTURE: 35 36 case ConpherenceTransactionType::TYPE_DATE_MARKER: 36 37 return false; 37 38 case ConpherenceTransactionType::TYPE_FILES: 38 39 return true; 39 - // we used to have them so just always hide 40 - case ConpherenceTransactionType::TYPE_PICTURE: 41 40 case ConpherenceTransactionType::TYPE_PICTURE_CROP: 42 41 return true; 43 42 } ··· 56 55 case PhabricatorTransactions::TYPE_VIEW_POLICY: 57 56 case PhabricatorTransactions::TYPE_EDIT_POLICY: 58 57 case PhabricatorTransactions::TYPE_JOIN_POLICY: 58 + case ConpherenceTransactionType::TYPE_PICTURE: 59 59 if ($this->getObject()->getIsRoom()) { 60 60 return $this->getRoomTitle(); 61 61 } else { ··· 144 144 } 145 145 return $title; 146 146 break; 147 + case ConpherenceTransactionType::TYPE_PICTURE: 148 + return pht( 149 + '%s updated the room image.', 150 + $this->renderHandleLink($author_phid)); 151 + break; 147 152 case PhabricatorTransactions::TYPE_VIEW_POLICY: 148 153 return pht( 149 154 '%s changed the visibility of this room from "%s" to "%s".', ··· 195 200 } 196 201 return $title; 197 202 break; 203 + case ConpherenceTransactionType::TYPE_PICTURE: 204 + return pht( 205 + '%s updated the room image.', 206 + $this->renderHandleLink($author_phid)); 207 + break; 198 208 case PhabricatorTransactions::TYPE_VIEW_POLICY: 199 209 return pht( 200 210 '%s changed the visibility of this thread from "%s" to "%s".', ··· 228 238 $phids[] = $this->getAuthorPHID(); 229 239 switch ($this->getTransactionType()) { 230 240 case ConpherenceTransactionType::TYPE_TITLE: 241 + case ConpherenceTransactionType::TYPE_PICTURE: 231 242 case ConpherenceTransactionType::TYPE_FILES: 232 243 case ConpherenceTransactionType::TYPE_DATE_MARKER: 233 244 break;
+1 -1
src/applications/conpherence/view/ConpherenceDurableColumnView.php
··· 412 412 array( 413 413 'name' => $rename_label, 414 414 'disabled' => !$can_edit, 415 - 'href' => '/conpherence/update/'.$conpherence->getID().'/', 415 + 'href' => '/conpherence/update/'.$conpherence->getID().'/?nopic', 416 416 'icon' => 'fa-pencil', 417 417 'key' => ConpherenceUpdateActions::METADATA, 418 418 ),
+40
src/applications/conpherence/view/ConpherenceFormDragAndDropUploadControl.php
··· 1 + <?php 2 + 3 + final class ConpherenceFormDragAndDropUploadControl extends AphrontFormControl { 4 + 5 + private $dropID; 6 + 7 + public function setDropID($drop_id) { 8 + $this->dropID = $drop_id; 9 + return $this; 10 + } 11 + public function getDropID() { 12 + return $this->dropID; 13 + } 14 + 15 + protected function getCustomControlClass() { 16 + return null; 17 + } 18 + 19 + protected function renderInput() { 20 + 21 + $drop_id = celerity_generate_unique_node_id(); 22 + Javelin::initBehavior('conpherence-drag-and-drop-photo', 23 + array( 24 + 'target' => $drop_id, 25 + 'form_pane' => 'conpherence-form', 26 + 'upload_uri' => '/file/dropupload/', 27 + 'activated_class' => 'conpherence-dialogue-upload-photo', 28 + )); 29 + require_celerity_resource('conpherence-update-css'); 30 + 31 + return phutil_tag( 32 + 'div', 33 + array( 34 + 'id' => $drop_id, 35 + 'class' => 'conpherence-dialogue-drag-photo', 36 + ), 37 + pht('Drag and drop an image here to upload it.')); 38 + } 39 + 40 + }
+78
src/applications/conpherence/view/ConpherencePicCropControl.php
··· 1 + <?php 2 + 3 + final class ConpherencePicCropControl extends AphrontFormControl { 4 + 5 + protected function getCustomControlClass() { 6 + return 'aphront-form-crop'; 7 + } 8 + 9 + protected function renderInput() { 10 + $width = ConpherenceImageData::CROP_WIDTH; 11 + $height = ConpherenceImageData::CROP_HEIGHT; 12 + 13 + $file = $this->getValue(); 14 + 15 + if ($file === null) { 16 + return phutil_tag( 17 + 'img', 18 + array( 19 + 'src' => PhabricatorUser::getDefaultProfileImageURI(), 20 + ), 21 + ''); 22 + } 23 + 24 + $c_id = celerity_generate_unique_node_id(); 25 + $metadata = $file->getMetadata(); 26 + $scale = PhabricatorImageTransformer::getScaleForCrop( 27 + $file, 28 + $width, 29 + $height); 30 + 31 + Javelin::initBehavior( 32 + 'aphront-crop', 33 + array( 34 + 'cropBoxID' => $c_id, 35 + 'width' => $width, 36 + 'height' => $height, 37 + 'scale' => $scale, 38 + 'imageH' => $metadata[PhabricatorFile::METADATA_IMAGE_HEIGHT], 39 + 'imageW' => $metadata[PhabricatorFile::METADATA_IMAGE_WIDTH], 40 + )); 41 + 42 + return javelin_tag( 43 + 'div', 44 + array( 45 + 'id' => $c_id, 46 + 'sigil' => 'crop-box', 47 + 'mustcapture' => true, 48 + 'class' => 'crop-box', 49 + ), 50 + array( 51 + javelin_tag( 52 + 'img', 53 + array( 54 + 'src' => $file->getBestURI(), 55 + 'class' => 'crop-image', 56 + 'sigil' => 'crop-image', 57 + ), 58 + ''), 59 + javelin_tag( 60 + 'input', 61 + array( 62 + 'type' => 'hidden', 63 + 'name' => 'image_x', 64 + 'sigil' => 'crop-x', 65 + ), 66 + ''), 67 + javelin_tag( 68 + 'input', 69 + array( 70 + 'type' => 'hidden', 71 + 'name' => 'image_y', 72 + 'sigil' => 'crop-y', 73 + ), 74 + ''), 75 + )); 76 + } 77 + 78 + }
+2
src/applications/conpherence/view/ConpherenceTransactionView.php
··· 256 256 $content = $transaction->getTitle(); 257 257 break; 258 258 case ConpherenceTransactionType::TYPE_TITLE: 259 + case ConpherenceTransactionType::TYPE_PICTURE: 260 + case ConpherenceTransactionType::TYPE_PICTURE_CROP: 259 261 case ConpherenceTransactionType::TYPE_PARTICIPANTS: 260 262 case PhabricatorTransactions::TYPE_VIEW_POLICY: 261 263 case PhabricatorTransactions::TYPE_EDIT_POLICY:
+38
webroot/rsrc/js/application/conpherence/behavior-drag-and-drop-photo.js
··· 1 + /** 2 + * @provides javelin-behavior-conpherence-drag-and-drop-photo 3 + * @requires javelin-behavior 4 + * javelin-dom 5 + * javelin-workflow 6 + * phabricator-drag-and-drop-file-upload 7 + */ 8 + 9 + JX.behavior('conpherence-drag-and-drop-photo', function(config) { 10 + 11 + var target = JX.$(config.target); 12 + var form_pane = JX.$(config.form_pane); 13 + 14 + function onupload(f) { 15 + var data = { 16 + 'file_id' : f.getID(), 17 + 'action' : 'metadata' 18 + }; 19 + 20 + var form = JX.DOM.find(form_pane, 'form'); 21 + var workflow = JX.Workflow.newFromForm(form, data); 22 + workflow.start(); 23 + } 24 + 25 + if (JX.PhabricatorDragAndDropFileUpload.isSupported()) { 26 + var drop = new JX.PhabricatorDragAndDropFileUpload(target) 27 + .setURI(config.upload_uri); 28 + drop.listen('didBeginDrag', function() { 29 + JX.DOM.alterClass(target, config.activated_class, true); 30 + }); 31 + drop.listen('didEndDrag', function() { 32 + JX.DOM.alterClass(target, config.activated_class, false); 33 + }); 34 + drop.listen('didUpload', onupload); 35 + drop.start(); 36 + } 37 + 38 + });