[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PackageModifyMail extends PackageMail { 4 5 protected $addOwners; 6 protected $removeOwners; 7 protected $allOwners; 8 protected $touchedRepos; 9 protected $addPaths; 10 protected $removePaths; 11 12 public function __construct( 13 PhabricatorOwnersPackage $package, 14 $add_owners, 15 $remove_owners, 16 $all_owners, 17 $touched_repos, 18 $add_paths, 19 $remove_paths) { 20 21 $this->package = $package; 22 23 $this->addOwners = $add_owners; 24 $this->removeOwners = $remove_owners; 25 $this->allOwners = $all_owners; 26 $this->touchedRepos = $touched_repos; 27 $this->addPaths = $add_paths; 28 $this->removePaths = $remove_paths; 29 } 30 31 protected function getVerb() { 32 return 'Modified'; 33 } 34 35 protected function isNewThread() { 36 return false; 37 } 38 39 protected function needSend() { 40 $package = $this->getPackage(); 41 if ($package->getOldPrimaryOwnerPHID() !== $package->getPrimaryOwnerPHID() 42 || $package->getOldAuditingEnabled() != $package->getAuditingEnabled() 43 || $this->addOwners 44 || $this->removeOwners 45 || $this->addPaths 46 || $this->removePaths) { 47 return true; 48 } else { 49 return false; 50 } 51 } 52 53 protected function loadData() { 54 $this->mailTo = $this->allOwners; 55 56 $phids = array_merge( 57 $this->allOwners, 58 $this->touchedRepos, 59 array( 60 $this->getPackage()->getActorPHID(), 61 )); 62 $this->handles = id(new PhabricatorHandleQuery()) 63 ->setViewer($this->getActor()) 64 ->withPHIDs($phids) 65 ->execute(); 66 } 67 68 protected function renderDescriptionSection() { 69 return null; 70 } 71 72 protected function renderPrimaryOwnerSection() { 73 $package = $this->getPackage(); 74 $handles = $this->getHandles(); 75 76 $old_primary_owner_phid = $package->getOldPrimaryOwnerPHID(); 77 $primary_owner_phid = $package->getPrimaryOwnerPHID(); 78 if ($old_primary_owner_phid == $primary_owner_phid) { 79 return null; 80 } 81 82 $section = array(); 83 $section[] = 'PRIMARY OWNER CHANGE'; 84 $section[] = ' Old owner: '. 85 $handles[$old_primary_owner_phid]->getName(); 86 $section[] = ' New owner: '. 87 $handles[$primary_owner_phid]->getName(); 88 89 return implode("\n", $section); 90 } 91 92 protected function renderOwnersSection() { 93 $section = array(); 94 $add_owners = $this->addOwners; 95 $remove_owners = $this->removeOwners; 96 $handles = $this->getHandles(); 97 98 if ($add_owners) { 99 $add_owners = array_select_keys($handles, $add_owners); 100 $add_owners = mpull($add_owners, 'getName'); 101 $section[] = 'ADDED OWNERS'; 102 $section[] = ' '.implode(', ', $add_owners); 103 } 104 105 if ($remove_owners) { 106 if ($add_owners) { 107 $section[] = ''; 108 } 109 $remove_owners = array_select_keys($handles, $remove_owners); 110 $remove_owners = mpull($remove_owners, 'getName'); 111 $section[] = 'REMOVED OWNERS'; 112 $section[] = ' '.implode(', ', $remove_owners); 113 } 114 115 if ($section) { 116 return implode("\n", $section); 117 } else { 118 return null; 119 } 120 } 121 122 protected function renderAuditingEnabledSection() { 123 $package = $this->getPackage(); 124 $old_auditing_enabled = $package->getOldAuditingEnabled(); 125 $auditing_enabled = $package->getAuditingEnabled(); 126 if ($old_auditing_enabled == $auditing_enabled) { 127 return null; 128 } 129 130 $section = array(); 131 $section[] = 'AUDITING ENABLED STATUS CHANGE'; 132 $section[] = ' Old value: '. 133 ($old_auditing_enabled ? 'Enabled' : 'Disabled'); 134 $section[] = ' New value: '. 135 ($auditing_enabled ? 'Enabled' : 'Disabled'); 136 return implode("\n", $section); 137 } 138 139 protected function renderPathsSection() { 140 $section = array(); 141 if ($this->addPaths) { 142 $section[] = 'ADDED PATHS'; 143 foreach ($this->addPaths as $repository_phid => $paths) { 144 $section[] = $this->renderRepoSubSection($repository_phid, $paths); 145 } 146 } 147 148 if ($this->removePaths) { 149 if ($this->addPaths) { 150 $section[] = ''; 151 } 152 $section[] = 'REMOVED PATHS'; 153 foreach ($this->removePaths as $repository_phid => $paths) { 154 $section[] = $this->renderRepoSubSection($repository_phid, $paths); 155 } 156 } 157 return implode("\n", $section); 158 } 159 160 }
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 |