Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/editor/ManiphestTransactionEditor.php
Show First 20 Lines • Show All 873 Lines • ▼ Show 20 Lines | if ($send_notifications) { | ||||
// We want to emit update notifications for all old and new tagged | // We want to emit update notifications for all old and new tagged | ||||
// projects, and all parents of those projects. For example, if an | // projects, and all parents of those projects. For example, if an | ||||
// edit removes project "A > B" from a task, the "A" workboard should | // edit removes project "A > B" from a task, the "A" workboard should | ||||
// receive an update event. | // receive an update event. | ||||
$project_phids = array_fuse($old_phids) + array_fuse($new_phids); | $project_phids = array_fuse($old_phids) + array_fuse($new_phids); | ||||
$project_phids = array_keys($project_phids); | $project_phids = array_keys($project_phids); | ||||
if ($project_phids) { | |||||
$projects = id(new PhabricatorProjectQuery()) | $projects = id(new PhabricatorProjectQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withPHIDs($project_phids) | ->withPHIDs($project_phids) | ||||
->execute(); | ->execute(); | ||||
$notify_projects = array(); | $notify_projects = array(); | ||||
foreach ($projects as $project) { | foreach ($projects as $project) { | ||||
$notify_projects[$project->getPHID()] = $project; | $notify_projects[$project->getPHID()] = $project; | ||||
foreach ($project->getAncestorProjects() as $ancestor) { | foreach ($project->getAncestorProjects() as $ancestor) { | ||||
$notify_projects[$ancestor->getPHID()] = $ancestor; | $notify_projects[$ancestor->getPHID()] = $ancestor; | ||||
} | } | ||||
} | } | ||||
foreach ($notify_projects as $key => $project) { | foreach ($notify_projects as $key => $project) { | ||||
if (!$project->getHasWorkboard()) { | if (!$project->getHasWorkboard()) { | ||||
unset($notify_projects[$key]); | unset($notify_projects[$key]); | ||||
} | } | ||||
} | } | ||||
$notify_phids = array_keys($notify_projects); | $notify_phids = array_keys($notify_projects); | ||||
if ($notify_phids) { | if ($notify_phids) { | ||||
$data = array( | $data = array( | ||||
'type' => 'workboards', | 'type' => 'workboards', | ||||
'subscribers' => $notify_phids, | 'subscribers' => $notify_phids, | ||||
); | ); | ||||
PhabricatorNotificationClient::tryToPostMessage($data); | PhabricatorNotificationClient::tryToPostMessage($data); | ||||
} | } | ||||
} | } | ||||
} | |||||
return $xactions; | return $xactions; | ||||
} | } | ||||
private function loadProjectPHIDs(ManiphestTask $task) { | private function loadProjectPHIDs(ManiphestTask $task) { | ||||
if (!$task->getPHID()) { | if (!$task->getPHID()) { | ||||
return array(); | return array(); | ||||
} | } | ||||
Show All 14 Lines |