8 files changed +57
-8
lines changed Original file line number Diff line number Diff line change
1
+ ALTER TABLE {$NAMESPACE}_slowvote .slowvote_poll
2
+ CHANGE responseVisibility
3
+ responseVisibility VARCHAR (32 ) NOT NULL COLLATE {$COLLATE_TEXT};
Original file line number Diff line number Diff line change
1
+ UPDATE {$NAMESPACE}_slowvote .slowvote_poll
2
+ SET responseVisibility = ' visible' WHERE responseVisibility = ' 0' ;
3
+
4
+ UPDATE {$NAMESPACE}_slowvote .slowvote_poll
5
+ SET responseVisibility = ' voters' WHERE responseVisibility = ' 1' ;
6
+
7
+ UPDATE {$NAMESPACE}_slowvote .slowvote_poll
8
+ SET responseVisibility = ' owner' WHERE responseVisibility = ' 2' ;
Original file line number Diff line number Diff line change
1
+ UPDATE {$NAMESPACE}_slowvote .slowvote_transaction
2
+ SET oldValue = ' "visible"' WHERE
3
+ transactionType = ' vote:responses' AND oldValue IN (' 0' , ' "0"' );
4
+
5
+ UPDATE {$NAMESPACE}_slowvote .slowvote_transaction
6
+ SET newValue = ' "visible"' WHERE
7
+ transactionType = ' vote:responses' AND newValue IN (' 0' , ' "0"' );
8
+
9
+ UPDATE {$NAMESPACE}_slowvote .slowvote_transaction
10
+ SET oldValue = ' "voters"' WHERE
11
+ transactionType = ' vote:responses' AND oldValue IN (' 1' , ' "1"' );
12
+
13
+ UPDATE {$NAMESPACE}_slowvote .slowvote_transaction
14
+ SET newValue = ' "voters"' WHERE
15
+ transactionType = ' vote:responses' AND newValue IN (' 1' , ' "1"' );
16
+
17
+ UPDATE {$NAMESPACE}_slowvote .slowvote_transaction
18
+ SET oldValue = ' "owner"' WHERE
19
+ transactionType = ' vote:responses' AND oldValue IN (' 2' , ' "2"' );
20
+
21
+ UPDATE {$NAMESPACE}_slowvote .slowvote_transaction
22
+ SET newValue = ' "owner"' WHERE
23
+ transactionType = ' vote:responses' AND newValue IN (' 2' , ' "2"' );
Original file line number Diff line number Diff line change 3
3
final class SlowvotePollResponseVisibility
4
4
extends Phobject {
5
5
6
- const RESPONSES_VISIBLE = 0 ;
7
- const RESPONSES_VOTERS = 1 ;
8
- const RESPONSES_OWNER = 2 ;
6
+ const RESPONSES_VISIBLE = ' visible ' ;
7
+ const RESPONSES_VOTERS = ' voters ' ;
8
+ const RESPONSES_OWNER = ' owner ' ;
9
9
10
10
private $ key ;
11
11
@@ -51,7 +51,7 @@ public function getNameForEdit() {
51
51
}
52
52
53
53
private function getProperty ($ key , $ default = null ) {
54
- $ spec = idx (self ::getMap (), $ this ->getKey ());
54
+ $ spec = idx (self ::getMap (), $ this ->getKey (), array () );
55
55
return idx ($ spec , $ key , $ default );
56
56
}
57
57
Original file line number Diff line number Diff line change @@ -199,6 +199,17 @@ public function handleRequest(AphrontRequest $request) {
199
199
$ response_type_map = SlowvotePollResponseVisibility::getAll ();
200
200
$ response_type_options = mpull ($ response_type_map , 'getNameForEdit ' );
201
201
202
+ $ visibility = $ poll ->getResponseVisibility ();
203
+ if (!isset ($ response_type_options [$ visibility ])) {
204
+ $ visibility_object =
205
+ SlowvotePollResponseVisibility::newResponseVisibilityObject (
206
+ $ visibility );
207
+
208
+ $ response_type_options = array (
209
+ $ visibility => $ visibility_object ->getNameForEdit (),
210
+ ) + $ response_type_options ;
211
+ }
212
+
202
213
if ($ is_new ) {
203
214
$ form ->appendChild (
204
215
id (new AphrontFormSelectControl ())
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ protected function getConfiguration() {
53
53
self ::CONFIG_AUX_PHID => true ,
54
54
self ::CONFIG_COLUMN_SCHEMA => array (
55
55
'question ' => 'text255 ' ,
56
- 'responseVisibility ' => 'uint32 ' ,
56
+ 'responseVisibility ' => 'text32 ' ,
57
57
'shuffle ' => 'bool ' ,
58
58
'method ' => 'uint32 ' ,
59
59
'description ' => 'text ' ,
Original file line number Diff line number Diff line change @@ -75,12 +75,12 @@ public function render() {
75
75
$ description ,
76
76
);
77
77
78
+ $ quip = pht ('Voting improves cardiovascular endurance. ' );
79
+
78
80
$ vis = $ poll ->getResponseVisibility ();
79
81
if ($ this ->areResultsVisible ()) {
80
82
if ($ vis == SlowvotePollResponseVisibility::RESPONSES_OWNER ) {
81
83
$ quip = pht ('Only you can see the results. ' );
82
- } else {
83
- $ quip = pht ('Voting improves cardiovascular endurance. ' );
84
84
}
85
85
} else if ($ vis == SlowvotePollResponseVisibility::RESPONSES_VOTERS ) {
86
86
$ quip = pht ('You must vote to see the results. ' );
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ final class PhabricatorSlowvoteResponsesTransaction
6
6
const TRANSACTIONTYPE = 'vote:responses ' ;
7
7
8
8
public function generateOldValue ($ object ) {
9
- return $ object ->getResponseVisibility ();
9
+ return (string )$ object ->getResponseVisibility ();
10
+ }
11
+
12
+ public function generateNewValue ($ object , $ value ) {
13
+ return (string )$ value ;
10
14
}
11
15
12
16
public function applyInternalEffects ($ object , $ value ) {
0 commit comments