1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 11:12:42 +01:00
phorge-phorge/src/applications/conpherence/storage/ConpherenceTransaction.php

201 lines
5.8 KiB
PHP
Raw Normal View History

<?php
final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
const TYPE_FILES = 'files';
const TYPE_TITLE = 'title';
const TYPE_PARTICIPANTS = 'participants';
const TYPE_DATE_MARKER = 'date-marker';
const TYPE_PICTURE = 'picture';
const TYPE_PICTURE_CROP = 'picture-crop';
public function getApplicationName() {
return 'conpherence';
}
public function getApplicationTransactionType() {
return PhabricatorConpherenceThreadPHIDType::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return new ConpherenceTransactionComment();
}
public function getNoEffectDescription() {
switch ($this->getTransactionType()) {
case self::TYPE_PARTICIPANTS:
return pht(
'You can not add a participant who has already been added.');
break;
}
return parent::getNoEffectDescription();
}
public function shouldHide() {
$old = $this->getOldValue();
switch ($this->getTransactionType()) {
case self::TYPE_PARTICIPANTS:
return ($old === null);
case self::TYPE_TITLE:
case self::TYPE_PICTURE:
case self::TYPE_DATE_MARKER:
return false;
case self::TYPE_FILES:
return true;
case self::TYPE_PICTURE_CROP:
return true;
}
return parent::shouldHide();
}
public function getTitle() {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_TITLE:
Conpherence - get lots of rooms stuff hooked up nicely Summary: Ref T7566. This does a big chunk of what's left - Main view - "Rooms" sub header - 5 Rooms shown at a time, with room you're looking at in the top on page load - e.g. viewing /conpherence/x/ the room x is at top always - solves corner case of when you have yet to "join" the room - "See More" link takes you to application search for rooms you have participated in - if no rooms, there is a "Create Room" and "Find Rooms" links. - "Messages" sub header - same as before - policy icons showing up in the menu - Durable column view - still just the latest N, no changes really there - Transactions - special cased rendering to try to say room vs thread as appropos - Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that. Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely. Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7566 Differential Revision: https://secure.phabricator.com/D12178
2015-03-27 00:37:32 +01:00
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
case self::TYPE_PICTURE:
return $this->getRoomTitle();
Conpherence - get lots of rooms stuff hooked up nicely Summary: Ref T7566. This does a big chunk of what's left - Main view - "Rooms" sub header - 5 Rooms shown at a time, with room you're looking at in the top on page load - e.g. viewing /conpherence/x/ the room x is at top always - solves corner case of when you have yet to "join" the room - "See More" link takes you to application search for rooms you have participated in - if no rooms, there is a "Create Room" and "Find Rooms" links. - "Messages" sub header - same as before - policy icons showing up in the menu - Durable column view - still just the latest N, no changes really there - Transactions - special cased rendering to try to say room vs thread as appropos - Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that. Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely. Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7566 Differential Revision: https://secure.phabricator.com/D12178
2015-03-27 00:37:32 +01:00
break;
case self::TYPE_FILES:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
if ($add && $rem) {
$title = pht(
'%s edited files(s), added %d and removed %d.',
$this->renderHandleLink($author_phid),
count($add),
count($rem));
} else if ($add) {
$title = pht(
'%s added %d files(s).',
$this->renderHandleLink($author_phid),
count($add));
} else {
$title = pht(
'%s removed %d file(s).',
$this->renderHandleLink($author_phid),
count($rem));
}
return $title;
break;
case self::TYPE_PARTICIPANTS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
if ($add && $rem) {
$title = pht(
'%s edited participant(s), added %d: %s; removed %d: %s.',
$this->renderHandleLink($author_phid),
count($add),
$this->renderHandleList($add),
count($rem),
$this->renderHandleList($rem));
} else if ($add) {
$title = pht(
'%s added %d participant(s): %s.',
$this->renderHandleLink($author_phid),
count($add),
$this->renderHandleList($add));
} else {
$title = pht(
'%s removed %d participant(s): %s.',
$this->renderHandleLink($author_phid),
count($rem),
$this->renderHandleList($rem));
}
return $title;
break;
}
return parent::getTitle();
}
Conpherence - get lots of rooms stuff hooked up nicely Summary: Ref T7566. This does a big chunk of what's left - Main view - "Rooms" sub header - 5 Rooms shown at a time, with room you're looking at in the top on page load - e.g. viewing /conpherence/x/ the room x is at top always - solves corner case of when you have yet to "join" the room - "See More" link takes you to application search for rooms you have participated in - if no rooms, there is a "Create Room" and "Find Rooms" links. - "Messages" sub header - same as before - policy icons showing up in the menu - Durable column view - still just the latest N, no changes really there - Transactions - special cased rendering to try to say room vs thread as appropos - Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that. Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely. Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7566 Differential Revision: https://secure.phabricator.com/D12178
2015-03-27 00:37:32 +01:00
private function getRoomTitle() {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_TITLE:
Conpherence - get lots of rooms stuff hooked up nicely Summary: Ref T7566. This does a big chunk of what's left - Main view - "Rooms" sub header - 5 Rooms shown at a time, with room you're looking at in the top on page load - e.g. viewing /conpherence/x/ the room x is at top always - solves corner case of when you have yet to "join" the room - "See More" link takes you to application search for rooms you have participated in - if no rooms, there is a "Create Room" and "Find Rooms" links. - "Messages" sub header - same as before - policy icons showing up in the menu - Durable column view - still just the latest N, no changes really there - Transactions - special cased rendering to try to say room vs thread as appropos - Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that. Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely. Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7566 Differential Revision: https://secure.phabricator.com/D12178
2015-03-27 00:37:32 +01:00
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_PICTURE:
return pht(
'%s updated the room image.',
$this->renderHandleLink($author_phid));
break;
Conpherence - get lots of rooms stuff hooked up nicely Summary: Ref T7566. This does a big chunk of what's left - Main view - "Rooms" sub header - 5 Rooms shown at a time, with room you're looking at in the top on page load - e.g. viewing /conpherence/x/ the room x is at top always - solves corner case of when you have yet to "join" the room - "See More" link takes you to application search for rooms you have participated in - if no rooms, there is a "Create Room" and "Find Rooms" links. - "Messages" sub header - same as before - policy icons showing up in the menu - Durable column view - still just the latest N, no changes really there - Transactions - special cased rendering to try to say room vs thread as appropos - Bug fix - we weren't recording the initial participants transaction post D12177 / D12163. This fixes that. Should probably test pagination, and if you want to show more than 5 rooms of have it behave more like messages (where you can wind up in the middle of a paginated list) that will be more work. Also, if lots of messages / rooms (100 is the limit) we might not display rooms if we're supposed to. Yay whale usage! :D Test Plan: made a new room - success. made a new message - success. viewed a room from /conpherenece/room/ i wasn't a participant in and noted it showed up at the top of the five rooms. clicked around rooms and stuff loaded nicely. Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7566 Differential Revision: https://secure.phabricator.com/D12178
2015-03-27 00:37:32 +01:00
case PhabricatorTransactions::TYPE_VIEW_POLICY:
return pht(
'%s changed the visibility of this room from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
break;
case PhabricatorTransactions::TYPE_EDIT_POLICY:
return pht(
'%s changed the edit policy of this room from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
break;
case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht(
'%s changed the join policy of this room from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
break;
}
}
public function getRequiredHandlePHIDs() {
$phids = parent::getRequiredHandlePHIDs();
$old = $this->getOldValue();
$new = $this->getNewValue();
$phids[] = $this->getAuthorPHID();
switch ($this->getTransactionType()) {
case self::TYPE_TITLE:
case self::TYPE_PICTURE:
case self::TYPE_FILES:
case self::TYPE_DATE_MARKER:
break;
case self::TYPE_PARTICIPANTS:
$phids = array_merge($phids, $this->getOldValue());
$phids = array_merge($phids, $this->getNewValue());
break;
}
return $phids;
}
}