[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorProjectWatchController 4 extends PhabricatorProjectController { 5 6 private $id; 7 private $action; 8 9 public function willProcessRequest(array $data) { 10 $this->id = $data['id']; 11 $this->action = $data['action']; 12 } 13 14 public function processRequest() { 15 $request = $this->getRequest(); 16 $viewer = $request->getUser(); 17 18 $project = id(new PhabricatorProjectQuery()) 19 ->setViewer($viewer) 20 ->withIDs(array($this->id)) 21 ->needMembers(true) 22 ->needWatchers(true) 23 ->executeOne(); 24 if (!$project) { 25 return new Aphront404Response(); 26 } 27 28 $project_uri = '/project/view/'.$project->getID().'/'; 29 30 // You must be a member of a project to 31 if (!$project->isUserMember($viewer->getPHID())) { 32 return new Aphront400Response(); 33 } 34 35 if ($request->isDialogFormPost()) { 36 $edge_action = null; 37 switch ($this->action) { 38 case 'watch': 39 $edge_action = '+'; 40 $force_subscribe = true; 41 break; 42 case 'unwatch': 43 $edge_action = '-'; 44 $force_subscribe = false; 45 break; 46 } 47 48 $type_member = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_WATCHER; 49 $member_spec = array( 50 $edge_action => array($viewer->getPHID() => $viewer->getPHID()), 51 ); 52 53 $xactions = array(); 54 $xactions[] = id(new PhabricatorProjectTransaction()) 55 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 56 ->setMetadataValue('edge:type', $type_member) 57 ->setNewValue($member_spec); 58 59 $editor = id(new PhabricatorProjectTransactionEditor($project)) 60 ->setActor($viewer) 61 ->setContentSourceFromRequest($request) 62 ->setContinueOnNoEffect(true) 63 ->setContinueOnMissingFields(true) 64 ->applyTransactions($project, $xactions); 65 66 return id(new AphrontRedirectResponse())->setURI($project_uri); 67 } 68 69 $dialog = null; 70 switch ($this->action) { 71 case 'watch': 72 $title = pht('Watch Project?'); 73 $body = pht( 74 'Watching a project will let you monitor it closely. You will '. 75 'receive email and notifications about changes to every object '. 76 'associated with projects you watch.'); 77 $submit = pht('Watch Project'); 78 break; 79 case 'unwatch': 80 $title = pht('Unwatch Project?'); 81 $body = pht( 82 'You will no longer receive email or notifications about every '. 83 'object associated with this project.'); 84 $submit = pht('Unwatch Project'); 85 break; 86 default: 87 return new Aphront404Response(); 88 } 89 90 return $this->newDialog() 91 ->setTitle($title) 92 ->appendParagraph($body) 93 ->addCancelButton($project_uri) 94 ->addSubmitButton($submit); 95 } 96 97 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |