diff --git a/resources/celerity/map.php b/resources/celerity/map.php index d7ad426263..afa1f20dc8 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -9,7 +9,7 @@ return array( 'names' => array( 'conpherence.pkg.css' => 'b5ee2073', 'conpherence.pkg.js' => '281b1a73', - 'core.pkg.css' => '476a4ec7', + 'core.pkg.css' => '30a64ed6', 'core.pkg.js' => 'fbc1c380', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '90b30783', @@ -167,7 +167,7 @@ return array( 'rsrc/css/phui/phui-spacing.css' => '042804d6', 'rsrc/css/phui/phui-status.css' => 'd5263e49', 'rsrc/css/phui/phui-tag-view.css' => '84d65f26', - 'rsrc/css/phui/phui-timeline-view.css' => 'bf45789e', + 'rsrc/css/phui/phui-timeline-view.css' => '1d7ef61d', 'rsrc/css/phui/phui-two-column-view.css' => 'ce9fa0b7', 'rsrc/css/phui/workboards/phui-workboard-color.css' => '783cdff5', 'rsrc/css/phui/workboards/phui-workboard.css' => '3bc85455', @@ -877,7 +877,7 @@ return array( 'phui-status-list-view-css' => 'd5263e49', 'phui-tag-view-css' => '84d65f26', 'phui-theme-css' => '9f261c6b', - 'phui-timeline-view-css' => 'bf45789e', + 'phui-timeline-view-css' => '1d7ef61d', 'phui-two-column-view-css' => 'ce9fa0b7', 'phui-workboard-color-css' => '783cdff5', 'phui-workboard-view-css' => '3bc85455', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4ef610fd7e..f6ca7a0010 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -320,11 +320,15 @@ phutil_register_library_map(array( 'ConpherenceThreadListView' => 'applications/conpherence/view/ConpherenceThreadListView.php', 'ConpherenceThreadMailReceiver' => 'applications/conpherence/mail/ConpherenceThreadMailReceiver.php', 'ConpherenceThreadMembersPolicyRule' => 'applications/conpherence/policyrule/ConpherenceThreadMembersPolicyRule.php', + 'ConpherenceThreadPictureTransaction' => 'applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php', 'ConpherenceThreadQuery' => 'applications/conpherence/query/ConpherenceThreadQuery.php', 'ConpherenceThreadRemarkupRule' => 'applications/conpherence/remarkup/ConpherenceThreadRemarkupRule.php', 'ConpherenceThreadSearchController' => 'applications/conpherence/controller/ConpherenceThreadSearchController.php', 'ConpherenceThreadSearchEngine' => 'applications/conpherence/query/ConpherenceThreadSearchEngine.php', 'ConpherenceThreadTitleNgrams' => 'applications/conpherence/storage/ConpherenceThreadTitleNgrams.php', + 'ConpherenceThreadTitleTransaction' => 'applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php', + 'ConpherenceThreadTopicTransaction' => 'applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php', + 'ConpherenceThreadTransactionType' => 'applications/conpherence/xaction/ConpherenceThreadTransactionType.php', 'ConpherenceTransaction' => 'applications/conpherence/storage/ConpherenceTransaction.php', 'ConpherenceTransactionComment' => 'applications/conpherence/storage/ConpherenceTransactionComment.php', 'ConpherenceTransactionQuery' => 'applications/conpherence/query/ConpherenceTransactionQuery.php', @@ -5099,12 +5103,16 @@ phutil_register_library_map(array( 'ConpherenceThreadListView' => 'AphrontView', 'ConpherenceThreadMailReceiver' => 'PhabricatorObjectMailReceiver', 'ConpherenceThreadMembersPolicyRule' => 'PhabricatorPolicyRule', + 'ConpherenceThreadPictureTransaction' => 'ConpherenceThreadTransactionType', 'ConpherenceThreadQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ConpherenceThreadRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'ConpherenceThreadSearchController' => 'ConpherenceController', 'ConpherenceThreadSearchEngine' => 'PhabricatorApplicationSearchEngine', 'ConpherenceThreadTitleNgrams' => 'PhabricatorSearchNgrams', - 'ConpherenceTransaction' => 'PhabricatorApplicationTransaction', + 'ConpherenceThreadTitleTransaction' => 'ConpherenceThreadTransactionType', + 'ConpherenceThreadTopicTransaction' => 'ConpherenceThreadTransactionType', + 'ConpherenceThreadTransactionType' => 'PhabricatorModularTransactionType', + 'ConpherenceTransaction' => 'PhabricatorModularTransaction', 'ConpherenceTransactionComment' => 'PhabricatorApplicationTransactionComment', 'ConpherenceTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'ConpherenceTransactionRenderer' => 'Phobject', diff --git a/src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php b/src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php index f34dd25110..1fb4dbabaa 100644 --- a/src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php +++ b/src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php @@ -123,7 +123,8 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase { ->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS) ->setNewValue(array('+' => $participant_phids)); $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TITLE) + ->setTransactionType( + ConpherenceThreadTitleTransaction::TRANSACTIONTYPE) ->setNewValue(pht('Test')); id(new ConpherenceEditor()) diff --git a/src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php b/src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php index 01b86f9a42..c92cc464ed 100644 --- a/src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php +++ b/src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php @@ -83,7 +83,8 @@ final class ConpherenceUpdateThreadConduitAPIMethod } if ($title) { $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TITLE) + ->setTransactionType( + ConpherenceThreadTitleTransaction::TRANSACTIONTYPE) ->setNewValue($title); } if ($message) { diff --git a/src/applications/conpherence/controller/ConpherenceNewRoomController.php b/src/applications/conpherence/controller/ConpherenceNewRoomController.php index 347c81f1e1..1f27a6807e 100644 --- a/src/applications/conpherence/controller/ConpherenceNewRoomController.php +++ b/src/applications/conpherence/controller/ConpherenceNewRoomController.php @@ -16,7 +16,7 @@ final class ConpherenceNewRoomController extends ConpherenceController { $xactions = array(); $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TITLE) + ->setTransactionType(ConpherenceThreadTitleTransaction::TRANSACTIONTYPE) ->setNewValue($request->getStr('title')); $participants = $request->getArr('participants'); @@ -26,7 +26,7 @@ final class ConpherenceNewRoomController extends ConpherenceController { ->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS) ->setNewValue(array('+' => $participants)); $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TOPIC) + ->setTransactionType(ConpherenceThreadTopicTransaction::TRANSACTIONTYPE) ->setNewValue($request->getStr('topic')); $xactions[] = id(new ConpherenceTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) @@ -50,7 +50,8 @@ final class ConpherenceNewRoomController extends ConpherenceController { } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; - $e_title = $ex->getShortMessage(ConpherenceTransaction::TYPE_TITLE); + $e_title = $ex->getShortMessage( + ConpherenceThreadTitleTransaction::TRANSACTIONTYPE); $conpherence->setViewPolicy($request->getStr('viewPolicy')); $conpherence->setEditPolicy($request->getStr('editPolicy')); diff --git a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php index 8ddeae7098..6a39481377 100644 --- a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php +++ b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php @@ -76,7 +76,8 @@ final class ConpherenceRoomPictureController $xactions = array(); $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_PICTURE) + ->setTransactionType( + ConpherenceThreadPictureTransaction::TRANSACTIONTYPE) ->setNewValue($new_value); $editor = id(new ConpherenceEditor()) diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 724b802566..44e6c3cf4b 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -140,10 +140,12 @@ final class ConpherenceUpdateController $title = $request->getStr('title'); $topic = $request->getStr('topic'); $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TITLE) + ->setTransactionType( + ConpherenceThreadTitleTransaction::TRANSACTIONTYPE) ->setNewValue($title); $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TOPIC) + ->setTransactionType( + ConpherenceThreadTopicTransaction::TRANSACTIONTYPE) ->setNewValue($topic); $xactions[] = id(new ConpherenceTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index 2a57711840..3ffb193c86 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -41,12 +41,14 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { ->setNewValue(array('+' => $participant_phids)); if ($title) { $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TITLE) + ->setTransactionType( + ConpherenceThreadTitleTransaction::TRANSACTIONTYPE) ->setNewValue($title); } if (strlen($topic)) { $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransaction::TYPE_TOPIC) + ->setTransactionType( + ConpherenceThreadTopicTransaction::TRANSACTIONTYPE) ->setNewValue($topic); } @@ -87,10 +89,7 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { $types[] = PhabricatorTransactions::TYPE_COMMENT; - $types[] = ConpherenceTransaction::TYPE_TITLE; - $types[] = ConpherenceTransaction::TYPE_TOPIC; $types[] = ConpherenceTransaction::TYPE_PARTICIPANTS; - $types[] = ConpherenceTransaction::TYPE_PICTURE; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; $types[] = PhabricatorTransactions::TYPE_JOIN_POLICY; @@ -98,17 +97,34 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { return $types; } + public function getCreateObjectTitle($author, $object) { + return pht('%s created this room.', $author); + } + + protected function shouldPublishFeedStory( + PhabricatorLiskDAO $object, + array $xactions) { + + foreach ($xactions as $xaction) { + switch ($xaction->getTransactionType()) { + case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE: + case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE: + case ConpherenceThreadPictureTransaction::TRANSACTIONTYPE: + return true; + default: + return false; + } + } + return true; + } + + + protected function getCustomTransactionOldValue( PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { switch ($xaction->getTransactionType()) { - case ConpherenceTransaction::TYPE_TITLE: - return $object->getTitle(); - case ConpherenceTransaction::TYPE_TOPIC: - return $object->getTopic(); - case ConpherenceTransaction::TYPE_PICTURE: - return $object->getProfileImagePHID(); case ConpherenceTransaction::TYPE_PARTICIPANTS: if ($this->getIsNewObject()) { return array(); @@ -122,10 +138,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { PhabricatorApplicationTransaction $xaction) { switch ($xaction->getTransactionType()) { - case ConpherenceTransaction::TYPE_TITLE: - case ConpherenceTransaction::TYPE_TOPIC: - case ConpherenceTransaction::TYPE_PICTURE: - return $xaction->getNewValue(); case ConpherenceTransaction::TYPE_PARTICIPANTS: return $this->getPHIDTransactionNewValue($xaction); } @@ -211,15 +223,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { $make_author_recent_participant = true; switch ($xaction->getTransactionType()) { - case ConpherenceTransaction::TYPE_TITLE: - $object->setTitle($xaction->getNewValue()); - break; - case ConpherenceTransaction::TYPE_TOPIC: - $object->setTopic($xaction->getNewValue()); - break; - case ConpherenceTransaction::TYPE_PICTURE: - $object->setProfileImagePHID($xaction->getNewValue()); - break; case ConpherenceTransaction::TYPE_PARTICIPANTS: if (!$this->getIsNewObject()) { $old_map = array_fuse($xaction->getOldValue()); @@ -418,8 +421,8 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { PhabricatorPolicyCapability::CAN_EDIT); } break; - case ConpherenceTransaction::TYPE_TITLE: - case ConpherenceTransaction::TYPE_TOPIC: + case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE: + case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE: PhabricatorPolicyFilter::requireCapability( $this->requireActor(), $object, @@ -434,8 +437,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { $type = $u->getTransactionType(); switch ($type) { - case ConpherenceTransaction::TYPE_TITLE: - return $v; case ConpherenceTransaction::TYPE_PARTICIPANTS: return $this->mergePHIDOrEdgeTransactions($u, $v); } @@ -541,23 +542,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { return PhabricatorEnv::getEnvConfig('metamta.conpherence.subject-prefix'); } - protected function shouldPublishFeedStory( - PhabricatorLiskDAO $object, - array $xactions) { - - foreach ($xactions as $xaction) { - switch ($xaction->getTransactionType()) { - case ConpherenceTransaction::TYPE_TITLE: - case ConpherenceTransaction::TYPE_TOPIC: - case ConpherenceTransaction::TYPE_PICTURE: - return true; - default: - return false; - } - } - return false; - } - protected function supportsSearch() { return true; } @@ -570,26 +554,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { $errors = parent::validateTransaction($object, $type, $xactions); switch ($type) { - case ConpherenceTransaction::TYPE_TITLE: - if (empty($xactions)) { - break; - } - $missing = $this->validateIsEmptyTextField( - $object->getTitle(), - $xactions); - - if ($missing) { - $detail = pht('Room title is required.'); - $error = new PhabricatorApplicationTransactionValidationError( - $type, - pht('Required'), - $detail, - last($xactions)); - - $error->setIsMissingFieldError(true); - $errors[] = $error; - } - break; case ConpherenceTransaction::TYPE_PARTICIPANTS: foreach ($xactions as $xaction) { $new_phids = $this->getPHIDTransactionNewValue($xaction, array()); diff --git a/src/applications/conpherence/storage/ConpherenceThread.php b/src/applications/conpherence/storage/ConpherenceThread.php index e912f52591..b8d5a8dce0 100644 --- a/src/applications/conpherence/storage/ConpherenceThread.php +++ b/src/applications/conpherence/storage/ConpherenceThread.php @@ -268,9 +268,9 @@ final class ConpherenceThread extends ConpherenceDAO case PhabricatorTransactions::TYPE_COMMENT: $message_transaction = $transaction; break; - case ConpherenceTransaction::TYPE_TITLE: - case ConpherenceTransaction::TYPE_TOPIC: - case ConpherenceTransaction::TYPE_PICTURE: + case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE: + case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE: + case ConpherenceThreadPictureTransaction::TRANSACTIONTYPE: case ConpherenceTransaction::TYPE_PARTICIPANTS: $action_transaction = $transaction; break; diff --git a/src/applications/conpherence/storage/ConpherenceTransaction.php b/src/applications/conpherence/storage/ConpherenceTransaction.php index 3706b4a210..b449037235 100644 --- a/src/applications/conpherence/storage/ConpherenceTransaction.php +++ b/src/applications/conpherence/storage/ConpherenceTransaction.php @@ -1,12 +1,10 @@ getTransactionType()) { case self::TYPE_PARTICIPANTS: @@ -37,9 +39,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { switch ($this->getTransactionType()) { case self::TYPE_PARTICIPANTS: return ($old === null); - case self::TYPE_TITLE: - case self::TYPE_TOPIC: - case self::TYPE_PICTURE: case self::TYPE_DATE_MARKER: return false; } @@ -54,12 +53,9 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { $new = $this->getNewValue(); switch ($this->getTransactionType()) { - case self::TYPE_TITLE: - case self::TYPE_TOPIC: case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY: - case self::TYPE_PICTURE: return $this->getRoomTitle(); break; case self::TYPE_PARTICIPANTS: @@ -94,55 +90,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { return parent::getTitle(); } - public function getTitleForFeed() { - $author_phid = $this->getAuthorPHID(); - $object_phid = $this->getObjectPHID(); - - $old = $this->getOldValue(); - $new = $this->getNewValue(); - - $type = $this->getTransactionType(); - switch ($type) { - case self::TYPE_TITLE: - if (strlen($old) && strlen($new)) { - return pht( - '%s renamed %s from "%s" to "%s".', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid), - $old, - $new); - } else { - return pht( - '%s created the room %s.', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid)); - } - break; - break; - case self::TYPE_TOPIC: - if (strlen($new)) { - return pht( - '%s set the topic of %s to "%s".', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid), - $new); - } else if (strlen($old)) { - return pht( - '%s deleted the topic in %s', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid)); - } - break; - case self::TYPE_PICTURE: - return pht( - '%s updated the room image for %s.', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid)); - break; - } - return parent::getTitleForFeed(); - } - private function getRoomTitle() { $author_phid = $this->getAuthorPHID(); @@ -150,45 +97,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { $new = $this->getNewValue(); switch ($this->getTransactionType()) { - case self::TYPE_TITLE: - if ($old && $new) { - $title = pht( - '%s renamed this room from "%s" to "%s".', - $this->renderHandleLink($author_phid), - $old, - $new); - } else if ($old) { - $title = pht( - '%s deleted the room name "%s".', - $this->renderHandleLink($author_phid), - $old); - } else { - $title = pht( - '%s named this room "%s".', - $this->renderHandleLink($author_phid), - $new); - } - return $title; - break; - case self::TYPE_TOPIC: - if ($new) { - $title = pht( - '%s set the topic of this room to "%s".', - $this->renderHandleLink($author_phid), - $new); - } else if ($old) { - $title = pht( - '%s deleted the room topic "%s"', - $this->renderHandleLink($author_phid), - $old); - } - return $title; - break; - case self::TYPE_PICTURE: - return pht( - '%s updated the room image.', - $this->renderHandleLink($author_phid)); - break; case PhabricatorTransactions::TYPE_VIEW_POLICY: return pht( '%s changed the visibility of this room from "%s" to "%s".', @@ -221,8 +129,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction { $phids[] = $this->getAuthorPHID(); switch ($this->getTransactionType()) { - case self::TYPE_TITLE: - case self::TYPE_PICTURE: case self::TYPE_DATE_MARKER: break; case self::TYPE_PARTICIPANTS: diff --git a/src/applications/conpherence/view/ConpherenceTransactionView.php b/src/applications/conpherence/view/ConpherenceTransactionView.php index c18a672ca2..28dcf5c361 100644 --- a/src/applications/conpherence/view/ConpherenceTransactionView.php +++ b/src/applications/conpherence/view/ConpherenceTransactionView.php @@ -216,17 +216,6 @@ final class ConpherenceTransactionView extends AphrontView { $content = null; $handles = $this->getHandles(); switch ($transaction->getTransactionType()) { - case ConpherenceTransaction::TYPE_TITLE: - case ConpherenceTransaction::TYPE_TOPIC: - case ConpherenceTransaction::TYPE_PICTURE: - case ConpherenceTransaction::TYPE_PARTICIPANTS: - case PhabricatorTransactions::TYPE_VIEW_POLICY: - case PhabricatorTransactions::TYPE_EDIT_POLICY: - case PhabricatorTransactions::TYPE_JOIN_POLICY: - case PhabricatorTransactions::TYPE_EDGE: - $content = $transaction->getTitle(); - $this->addClass('conpherence-edited'); - break; case PhabricatorTransactions::TYPE_COMMENT: $this->addClass('conpherence-comment'); $author = $handles[$transaction->getAuthorPHID()]; @@ -236,6 +225,10 @@ final class ConpherenceTransactionView extends AphrontView { PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); $content_class = 'conpherence-message'; break; + default: + $content = $transaction->getTitle(); + $this->addClass('conpherence-edited'); + break; } $view = phutil_tag( diff --git a/src/applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php b/src/applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php new file mode 100644 index 0000000000..65f7deac5e --- /dev/null +++ b/src/applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php @@ -0,0 +1,29 @@ +getProfileImagePHID(); + } + + public function applyInternalEffects($object, $value) { + $object->setProfileImagePHID($value); + } + + public function getTitle() { + return pht( + '%s updated the room image.', + $this->renderAuthor()); + } + + public function getTitleForFeed() { + return pht( + '%s updated the room image for %s.', + $this->renderAuthor(), + $this->renderObject()); + } + +} diff --git a/src/applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php b/src/applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php new file mode 100644 index 0000000000..130a841a23 --- /dev/null +++ b/src/applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php @@ -0,0 +1,75 @@ +getTitle(); + } + + public function applyInternalEffects($object, $value) { + $object->setTitle($value); + } + + public function getTitle() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + if (strlen($old) && strlen($new)) { + return pht( + '%s renamed this room from %s to %s.', + $this->renderAuthor(), + $this->renderOldValue(), + $this->renderNewValue()); + } else { + return pht( + '%s created this room.', + $this->renderAuthor()); + } + } + + public function getTitleForFeed() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + if (strlen($old) && strlen($new)) { + return pht( + '%s renamed %s from %s to %s.', + $this->renderAuthor(), + $this->renderObject(), + $this->renderOldValue(), + $this->renderNewValue()); + } else { + return pht( + '%s created %s.', + $this->renderAuthor(), + $this->renderObject()); + } + } + + + public function validateTransactions($object, array $xactions) { + $errors = array(); + + if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) { + $errors[] = $this->newRequiredError( + pht('Rooms must have a title.')); + } + + $max_length = $object->getColumnMaximumByteLength('title'); + foreach ($xactions as $xaction) { + $new_value = $xaction->getNewValue(); + $new_length = strlen($new_value); + if ($new_length > $max_length) { + $errors[] = $this->newInvalidError( + pht('The title can be no longer than %s characters.', + new PhutilNumber($max_length))); + } + } + + return $errors; + } + +} diff --git a/src/applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php b/src/applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php new file mode 100644 index 0000000000..23c590f409 --- /dev/null +++ b/src/applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php @@ -0,0 +1,69 @@ +getTopic(); + } + + public function applyInternalEffects($object, $value) { + $object->setTopic($value); + } + + public function getTitle() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + if (strlen($new)) { + return pht( + '%s set the room topic to %s.', + $this->renderAuthor(), + $this->renderNewValue()); + } else { + return pht( + '%s removed the room topic.', + $this->renderAuthor()); + } + + } + + public function getTitleForFeed() { + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + if (strlen($new)) { + return pht( + '%s set the room topic to %s in %s.', + $this->renderAuthor(), + $this->renderNewValue(), + $this->renderObject()); + } else { + return pht( + '%s removed the room topic for %s.', + $this->renderAuthor(), + $this->renderObject()); + } + + } + + public function validateTransactions($object, array $xactions) { + $errors = array(); + + $max_length = $object->getColumnMaximumByteLength('topic'); + foreach ($xactions as $xaction) { + $new_value = $xaction->getNewValue(); + $new_length = strlen($new_value); + if ($new_length > $max_length) { + $errors[] = $this->newInvalidError( + pht('The topic can be no longer than %s characters.', + new PhutilNumber($max_length))); + } + } + + return $errors; + } + +} diff --git a/src/applications/conpherence/xaction/ConpherenceThreadTransactionType.php b/src/applications/conpherence/xaction/ConpherenceThreadTransactionType.php new file mode 100644 index 0000000000..82f4f63d4e --- /dev/null +++ b/src/applications/conpherence/xaction/ConpherenceThreadTransactionType.php @@ -0,0 +1,4 @@ +