33final class PhabricatorSubscriptionsEditController
44 extends PhabricatorController {
55
6- private $ phid ;
7- private $ action ;
8-
9- public function willProcessRequest (array $ data ) {
10- $ this ->phid = idx ($ data , 'phid ' );
11- $ this ->action = idx ($ data , 'action ' );
12- }
13-
14- public function processRequest () {
15- $ request = $ this ->getRequest ();
6+ public function handleRequest (AphrontRequest $ request ) {
7+ $ viewer = $ request ->getViewer ();
8+ $ phid = $ request ->getURIData ('phid ' );
9+ $ action = $ request ->getURIData ('action ' );
1610
1711 if (!$ request ->isFormPost ()) {
1812 return new Aphront400Response ();
1913 }
2014
21- switch ($ this -> action ) {
15+ switch ($ action ) {
2216 case 'add ' :
2317 $ is_add = true ;
2418 break ;
@@ -29,11 +23,8 @@ public function processRequest() {
2923 return new Aphront400Response ();
3024 }
3125
32- $ user = $ request ->getUser ();
33- $ phid = $ this ->phid ;
34-
3526 $ handle = id (new PhabricatorHandleQuery ())
36- ->setViewer ($ user )
27+ ->setViewer ($ viewer )
3728 ->withPHIDs (array ($ phid ))
3829 ->executeOne ();
3930
@@ -45,13 +36,13 @@ public function processRequest() {
4536 // to become more clear?
4637
4738 $ object = id (new PhabricatorProjectQuery ())
48- ->setViewer ($ user )
39+ ->setViewer ($ viewer )
4940 ->withPHIDs (array ($ phid ))
5041 ->needWatchers (true )
5142 ->executeOne ();
5243 } else {
5344 $ object = id (new PhabricatorObjectQuery ())
54- ->setViewer ($ user )
45+ ->setViewer ($ viewer )
5546 ->withPHIDs (array ($ phid ))
5647 ->executeOne ();
5748 }
@@ -63,14 +54,14 @@ public function processRequest() {
6354 $ handle ->getURI ());
6455 }
6556
66- if ($ object ->isAutomaticallySubscribed ($ user ->getPHID ())) {
57+ if ($ object ->isAutomaticallySubscribed ($ viewer ->getPHID ())) {
6758 return $ this ->buildErrorResponse (
6859 pht ('Automatically Subscribed ' ),
6960 pht ('You are automatically subscribed to this object. ' ),
7061 $ handle ->getURI ());
7162 }
7263
73- if (!$ object ->shouldAllowSubscription ($ user ->getPHID ())) {
64+ if (!$ object ->shouldAllowSubscription ($ viewer ->getPHID ())) {
7465 return $ this ->buildErrorResponse (
7566 pht ('You Can Not Subscribe ' ),
7667 pht ('You can not subscribe to this object. ' ),
@@ -80,11 +71,11 @@ public function processRequest() {
8071 if ($ object instanceof PhabricatorApplicationTransactionInterface) {
8172 if ($ is_add ) {
8273 $ xaction_value = array (
83- '+ ' => array ($ user ->getPHID ()),
74+ '+ ' => array ($ viewer ->getPHID ()),
8475 );
8576 } else {
8677 $ xaction_value = array (
87- '- ' => array ($ user ->getPHID ()),
78+ '- ' => array ($ viewer ->getPHID ()),
8879 );
8980 }
9081
@@ -93,7 +84,7 @@ public function processRequest() {
9384 ->setNewValue ($ xaction_value );
9485
9586 $ editor = id ($ object ->getApplicationTransactionEditor ())
96- ->setActor ($ user )
87+ ->setActor ($ viewer )
9788 ->setContinueOnNoEffect (true )
9889 ->setContinueOnMissingFields (true )
9990 ->setContentSourceFromRequest ($ request );
@@ -107,13 +98,13 @@ public function processRequest() {
10798 // PhabriatorApplicationTransactionInterface.
10899
109100 $ editor = id (new PhabricatorSubscriptionsEditor ())
110- ->setActor ($ user )
101+ ->setActor ($ viewer )
111102 ->setObject ($ object );
112103
113104 if ($ is_add ) {
114- $ editor ->subscribeExplicit (array ($ user ->getPHID ()), $ explicit = true );
105+ $ editor ->subscribeExplicit (array ($ viewer ->getPHID ()), $ explicit = true );
115106 } else {
116- $ editor ->unsubscribe (array ($ user ->getPHID ()));
107+ $ editor ->unsubscribe (array ($ viewer ->getPHID ()));
117108 }
118109
119110 $ editor ->save ();
@@ -126,10 +117,10 @@ public function processRequest() {
126117
127118 private function buildErrorResponse ($ title , $ message , $ uri ) {
128119 $ request = $ this ->getRequest ();
129- $ user = $ request ->getUser ();
120+ $ viewer = $ request ->getUser ();
130121
131122 $ dialog = id (new AphrontDialogView ())
132- ->setUser ($ user )
123+ ->setUser ($ viewer )
133124 ->setTitle ($ title )
134125 ->appendChild ($ message )
135126 ->addCancelButton ($ uri );
0 commit comments