repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/capability/DrydockDefaultViewCapability.php
src/applications/drydock/capability/DrydockDefaultViewCapability.php
<?php final class DrydockDefaultViewCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'drydock.default.view'; public function getCapabilityName() { return pht('Default Blueprint View Policy'); } public function shouldAllowPublicPolicySetting() { return true; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/capability/DrydockDefaultEditCapability.php
src/applications/drydock/capability/DrydockDefaultEditCapability.php
<?php final class DrydockDefaultEditCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'drydock.default.edit'; public function getCapabilityName() { return pht('Default Blueprint Edit Policy'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/constants/DrydockResourceStatus.php
src/applications/drydock/constants/DrydockResourceStatus.php
<?php final class DrydockResourceStatus extends PhabricatorObjectStatus { const STATUS_PENDING = 'pending'; const STATUS_ACTIVE = 'active'; const STATUS_RELEASED = 'released'; const STATUS_BROKEN = 'broken'; const STATUS_DESTROYED = 'destroyed'; public static function newStatusObject($key) { return new self($key, id(new self())->getStatusSpecification($key)); } public static function getStatusMap() { $map = id(new self())->getStatusSpecifications(); return ipull($map, 'name', 'key'); } public static function getNameForStatus($status) { $map = id(new self())->getStatusSpecification($status); return $map['name']; } public static function getAllStatuses() { return array_keys(id(new self())->getStatusSpecifications()); } public function isActive() { return ($this->getKey() === self::STATUS_ACTIVE); } public function canRelease() { return $this->getStatusProperty('isReleasable'); } public function canReceiveCommands() { return $this->getStatusProperty('isCommandable'); } protected function newStatusSpecifications() { return array( array( 'key' => self::STATUS_PENDING, 'name' => pht('Pending'), 'icon' => 'fa-clock-o', 'color' => 'blue', 'isReleasable' => true, 'isCommandable' => true, ), array( 'key' => self::STATUS_ACTIVE, 'name' => pht('Active'), 'icon' => 'fa-check', 'color' => 'green', 'isReleasable' => true, 'isCommandable' => true, ), array( 'key' => self::STATUS_RELEASED, 'name' => pht('Released'), 'icon' => 'fa-circle-o', 'color' => 'blue', 'isReleasable' => false, 'isCommandable' => false, ), array( 'key' => self::STATUS_BROKEN, 'name' => pht('Broken'), 'icon' => 'fa-times', 'color' => 'indigo', 'isReleasable' => true, 'isCommandable' => false, ), array( 'key' => self::STATUS_DESTROYED, 'name' => pht('Destroyed'), 'icon' => 'fa-times', 'color' => 'grey', 'isReleasable' => false, 'isCommandable' => false, ), ); } protected function newUnknownStatusSpecification($status) { return array( 'isReleasable' => false, 'isCommandable' => false, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/constants/DrydockLeaseStatus.php
src/applications/drydock/constants/DrydockLeaseStatus.php
<?php final class DrydockLeaseStatus extends PhabricatorObjectStatus { const STATUS_PENDING = 'pending'; const STATUS_ACQUIRED = 'acquired'; const STATUS_ACTIVE = 'active'; const STATUS_RELEASED = 'released'; const STATUS_BROKEN = 'broken'; const STATUS_DESTROYED = 'destroyed'; public static function newStatusObject($key) { return new self($key, id(new self())->getStatusSpecification($key)); } public static function getStatusMap() { $map = id(new self())->getStatusSpecifications(); return ipull($map, 'name', 'key'); } public static function getNameForStatus($status) { $map = id(new self())->getStatusSpecification($status); return $map['name']; } public static function getAllStatuses() { return array_keys(id(new self())->getStatusSpecifications()); } public function isActivating() { return $this->getStatusProperty('isActivating'); } public function isActive() { return ($this->getKey() === self::STATUS_ACTIVE); } public function canRelease() { return $this->getStatusProperty('isReleasable'); } public function canReceiveCommands() { return $this->getStatusProperty('isCommandable'); } protected function newStatusSpecifications() { return array( array( 'key' => self::STATUS_PENDING, 'name' => pht('Pending'), 'icon' => 'fa-clock-o', 'color' => 'blue', 'isReleasable' => true, 'isCommandable' => true, 'isActivating' => true, ), array( 'key' => self::STATUS_ACQUIRED, 'name' => pht('Acquired'), 'icon' => 'fa-refresh', 'color' => 'blue', 'isReleasable' => true, 'isCommandable' => true, 'isActivating' => true, ), array( 'key' => self::STATUS_ACTIVE, 'name' => pht('Active'), 'icon' => 'fa-check', 'color' => 'green', 'isReleasable' => true, 'isCommandable' => true, 'isActivating' => false, ), array( 'key' => self::STATUS_RELEASED, 'name' => pht('Released'), 'icon' => 'fa-circle-o', 'color' => 'blue', 'isReleasable' => false, 'isCommandable' => false, 'isActivating' => false, ), array( 'key' => self::STATUS_BROKEN, 'name' => pht('Broken'), 'icon' => 'fa-times', 'color' => 'indigo', 'isReleasable' => true, 'isCommandable' => true, 'isActivating' => false, ), array( 'key' => self::STATUS_DESTROYED, 'name' => pht('Destroyed'), 'icon' => 'fa-times', 'color' => 'grey', 'isReleasable' => false, 'isCommandable' => false, 'isActivating' => false, ), ); } protected function newUnknownStatusSpecification($status) { return array( 'isReleasable' => false, 'isCommandable' => false, 'isActivating' => false, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectProfileController.php
src/applications/project/controller/PhabricatorProjectProfileController.php
<?php final class PhabricatorProjectProfileController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $response = $this->loadProject(); if ($response) { return $response; } $viewer = $request->getUser(); $project = $this->getProject(); $id = $project->getID(); $picture = $project->getProfileImageURI(); $icon = $project->getDisplayIconIcon(); $icon_name = $project->getDisplayIconName(); $tag = id(new PHUITagView()) ->setIcon($icon) ->setName($icon_name) ->addClass('project-view-header-tag') ->setType(PHUITagView::TYPE_SHADE); $header = id(new PHUIHeaderView()) ->setHeader(array($project->getDisplayName(), $tag)) ->setUser($viewer) ->setPolicyObject($project) ->setProfileHeader(true); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); if ($can_edit) { $header->setImageEditURL($this->getApplicationURI("picture/{$id}/")); } $properties = $this->buildPropertyListView($project); $watch_action = $this->renderWatchAction($project); $header->addActionLink($watch_action); $subtype = $project->newSubtypeObject(); if ($subtype && $subtype->hasTagView()) { $subtype_tag = $subtype->newTagView(); $header->addTag($subtype_tag); } $milestone_list = $this->buildMilestoneList($project); $subproject_list = $this->buildSubprojectList($project); $member_list = id(new PhabricatorProjectMemberListView()) ->setUser($viewer) ->setProject($project) ->setLimit(10) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setUserPHIDs($project->getMemberPHIDs()); $watcher_list = id(new PhabricatorProjectWatcherListView()) ->setUser($viewer) ->setProject($project) ->setLimit(10) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setUserPHIDs($project->getWatcherPHIDs()); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_PROFILE); $query = id(new PhabricatorFeedQuery()) ->setViewer($viewer) ->withFilterPHIDs(array($project->getPHID())) ->setLimit(50) ->setReturnPartialResultsOnOverheat(true); $stories = $query->execute(); $overheated_view = null; $is_overheated = $query->getIsOverheated(); if ($is_overheated) { $overheated_message = PhabricatorApplicationSearchController::newOverheatedError( (bool)$stories); $overheated_view = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_WARNING) ->setTitle(pht('Query Overheated')) ->setErrors( array( $overheated_message, )); } $view_all = id(new PHUIButtonView()) ->setTag('a') ->setIcon( id(new PHUIIconView()) ->setIcon('fa-list-ul')) ->setText(pht('View All')) ->setHref('/feed/?projectPHIDs='.$project->getPHID()); $feed_header = id(new PHUIHeaderView()) ->setHeader(pht('Recent Activity')) ->addActionLink($view_all); $feed = $this->renderStories($stories); $feed = id(new PHUIObjectBoxView()) ->setHeader($feed_header) ->addClass('project-view-feed') ->appendChild( array( $overheated_view, $feed, )); require_celerity_resource('project-view-css'); $home = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setMainColumn( array( $properties, $feed, )) ->setSideColumn( array( $milestone_list, $subproject_list, $member_list, $watcher_list, )); $crumbs = $this->buildApplicationCrumbs(); $crumbs->setBorder(true); return $this->newPage() ->setNavigation($nav) ->setCrumbs($crumbs) ->setTitle($project->getDisplayName()) ->setPageObjectPHIDs(array($project->getPHID())) ->appendChild($home); } private function buildPropertyListView( PhabricatorProject $project) { $request = $this->getRequest(); $viewer = $request->getUser(); $view = id(new PHUIPropertyListView()) ->setUser($viewer) ->setObject($project); $field_list = PhabricatorCustomField::getObjectFields( $project, PhabricatorCustomField::ROLE_VIEW); $field_list->appendFieldsToPropertyList($project, $viewer, $view); if (!$view->hasAnyProperties()) { return null; } $header = id(new PHUIHeaderView()) ->setHeader(pht('Details')); $view = id(new PHUIObjectBoxView()) ->setHeader($header) ->appendChild($view) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->addClass('project-view-properties'); return $view; } private function renderStories(array $stories) { assert_instances_of($stories, 'PhabricatorFeedStory'); $builder = new PhabricatorFeedBuilder($stories); $builder->setUser($this->getRequest()->getUser()); $builder->setShowHovercards(true); $view = $builder->buildView(); return $view; } private function renderWatchAction(PhabricatorProject $project) { $viewer = $this->getViewer(); $id = $project->getID(); if (!$viewer->isLoggedIn()) { $is_watcher = false; $is_ancestor = false; } else { $viewer_phid = $viewer->getPHID(); $is_watcher = $project->isUserWatcher($viewer_phid); $is_ancestor = $project->isUserAncestorWatcher($viewer_phid); } if ($is_ancestor && !$is_watcher) { $watch_icon = 'fa-eye'; $watch_text = pht('Watching Ancestor'); $watch_href = "/project/watch/{$id}/?via=profile"; $watch_disabled = true; } else if (!$is_watcher) { $watch_icon = 'fa-eye'; $watch_text = pht('Watch Project'); $watch_href = "/project/watch/{$id}/?via=profile"; $watch_disabled = false; } else { $watch_icon = 'fa-eye-slash'; $watch_text = pht('Unwatch Project'); $watch_href = "/project/unwatch/{$id}/?via=profile"; $watch_disabled = false; } $watch_icon = id(new PHUIIconView()) ->setIcon($watch_icon); return id(new PHUIButtonView()) ->setTag('a') ->setWorkflow(true) ->setIcon($watch_icon) ->setText($watch_text) ->setHref($watch_href) ->setDisabled($watch_disabled); } private function buildMilestoneList(PhabricatorProject $project) { if (!$project->getHasMilestones()) { return null; } $viewer = $this->getViewer(); $id = $project->getID(); $milestones = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) ->withIsMilestone(true) ->withStatuses( array( PhabricatorProjectStatus::STATUS_ACTIVE, )) ->setOrderVector(array('milestoneNumber', 'id')) ->execute(); if (!$milestones) { return null; } $milestone_list = id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($milestones) ->renderList(); $view_all = id(new PHUIButtonView()) ->setTag('a') ->setIcon( id(new PHUIIconView()) ->setIcon('fa-list-ul')) ->setText(pht('View All')) ->setHref("/project/subprojects/{$id}/"); $header = id(new PHUIHeaderView()) ->setHeader(pht('Milestones')) ->addActionLink($view_all); return id(new PHUIObjectBoxView()) ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setObjectList($milestone_list); } private function buildSubprojectList(PhabricatorProject $project) { if (!$project->getHasSubprojects()) { return null; } $viewer = $this->getViewer(); $id = $project->getID(); $limit = 25; $subprojects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) ->withStatuses( array( PhabricatorProjectStatus::STATUS_ACTIVE, )) ->withIsMilestone(false) ->setLimit($limit) ->execute(); if (!$subprojects) { return null; } $subproject_list = id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($subprojects) ->renderList(); $view_all = id(new PHUIButtonView()) ->setTag('a') ->setIcon( id(new PHUIIconView()) ->setIcon('fa-list-ul')) ->setText(pht('View All')) ->setHref("/project/subprojects/{$id}/"); $header = id(new PHUIHeaderView()) ->setHeader(pht('Subprojects')) ->addActionLink($view_all); return id(new PHUIObjectBoxView()) ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setObjectList($subproject_list); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnBulkMoveController.php
src/applications/project/controller/PhabricatorProjectColumnBulkMoveController.php
<?php final class PhabricatorProjectColumnBulkMoveController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } // See T13316. If we're operating in "column" mode, we're going to skip // the prompt for a project and just have the user select a target column. // In "project" mode, we prompt them for a project first. $is_column_mode = ($request->getURIData('mode') === 'column'); $src_project = $this->getProject(); $state = $this->getViewState(); $board_uri = $state->newWorkboardURI(); $layout_engine = $state->getLayoutEngine(); $board_phid = $src_project->getPHID(); $columns = $layout_engine->getColumns($board_phid); $columns = mpull($columns, null, 'getID'); $column_id = $request->getURIData('columnID'); $src_column = idx($columns, $column_id); if (!$src_column) { return new Aphront404Response(); } $move_task_phids = $layout_engine->getColumnObjectPHIDs( $board_phid, $src_column->getPHID()); $tasks = $state->getObjects(); $move_tasks = array_select_keys($tasks, $move_task_phids); $move_tasks = id(new PhabricatorPolicyFilter()) ->setViewer($viewer) ->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT)) ->apply($move_tasks); if (!$move_tasks) { return $this->newDialog() ->setTitle(pht('No Movable Tasks')) ->appendParagraph( pht( 'The selected column contains no visible tasks which you '. 'have permission to move.')) ->addCancelButton($board_uri); } $dst_project_phid = null; $dst_project = null; $has_project = false; if ($is_column_mode) { $has_project = true; $dst_project_phid = $src_project->getPHID(); } else { if ($request->isFormOrHiSecPost()) { $has_project = $request->getStr('hasProject'); if ($has_project) { // We may read this from a tokenizer input as an array, or from a // hidden input as a string. $dst_project_phid = head($request->getArr('dstProjectPHID')); if (!$dst_project_phid) { $dst_project_phid = $request->getStr('dstProjectPHID'); } } } } $errors = array(); $hidden = array(); if ($has_project) { if (!$dst_project_phid) { $errors[] = pht('Choose a project to move tasks to.'); } else { $dst_project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withPHIDs(array($dst_project_phid)) ->executeOne(); if (!$dst_project) { $errors[] = pht('Choose a valid project to move tasks to.'); } if (!$dst_project->getHasWorkboard()) { $errors[] = pht('You must choose a project with a workboard.'); $dst_project = null; } } } if ($dst_project) { $same_project = ($src_project->getID() === $dst_project->getID()); $layout_engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setBoardPHIDs(array($dst_project->getPHID())) ->setFetchAllBoards(true) ->executeLayout(); $dst_columns = $layout_engine->getColumns($dst_project->getPHID()); $dst_columns = mpull($dst_columns, null, 'getPHID'); // Prevent moves to milestones or subprojects by selecting their // columns, since the implications aren't obvious and this doesn't // work the same way as normal column moves. foreach ($dst_columns as $key => $dst_column) { if ($dst_column->getProxyPHID()) { unset($dst_columns[$key]); } } $has_column = false; $dst_column = null; // If we're performing a move on the same board, default the // control value to the current column. if ($same_project) { $dst_column_phid = $src_column->getPHID(); } else { $dst_column_phid = null; } if ($request->isFormOrHiSecPost()) { $has_column = $request->getStr('hasColumn'); if ($has_column) { $dst_column_phid = $request->getStr('dstColumnPHID'); } } if ($has_column) { $dst_column = idx($dst_columns, $dst_column_phid); if (!$dst_column) { $errors[] = pht('Choose a column to move tasks to.'); } else { if ($dst_column->isHidden()) { $errors[] = pht('You can not move tasks to a hidden column.'); $dst_column = null; } else if ($dst_column->getPHID() === $src_column->getPHID()) { $errors[] = pht('You can not move tasks from a column to itself.'); $dst_column = null; } } } if ($dst_column) { foreach ($move_tasks as $move_task) { $xactions = array(); // If we're switching projects, get out of the old project first // and move to the new project. if (!$same_project) { $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue( 'edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST) ->setNewValue( array( '-' => array( $src_project->getPHID() => $src_project->getPHID(), ), '+' => array( $dst_project->getPHID() => $dst_project->getPHID(), ), )); } $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_COLUMNS) ->setNewValue( array( array( 'columnPHID' => $dst_column->getPHID(), ), )); $editor = id(new ManiphestTransactionEditor()) ->setActor($viewer) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request) ->setCancelURI($board_uri); $editor->applyTransactions($move_task, $xactions); } // If we did a move on the same workboard, redirect and preserve the // state parameters. If we moved to a different workboard, go there // with clean default state. if ($same_project) { $done_uri = $board_uri; } else { $done_uri = $dst_project->getWorkboardURI(); } return id(new AphrontRedirectResponse())->setURI($done_uri); } $title = pht('Move Tasks to Column'); $form = id(new AphrontFormView()) ->setViewer($viewer); // If we're moving between projects, add a reminder about which project // you selected in the previous step. if (!$is_column_mode) { $form->appendControl( id(new AphrontFormStaticControl()) ->setLabel(pht('Project')) ->setValue($dst_project->getDisplayName())); } $column_options = array( 'visible' => array(), 'hidden' => array(), ); $any_hidden = false; foreach ($dst_columns as $column) { if (!$column->isHidden()) { $group = 'visible'; } else { $group = 'hidden'; } $phid = $column->getPHID(); $display_name = $column->getDisplayName(); $column_options[$group][$phid] = $display_name; } if ($column_options['hidden']) { $column_options = array( pht('Visible Columns') => $column_options['visible'], pht('Hidden Columns') => $column_options['hidden'], ); } else { $column_options = $column_options['visible']; } $form->appendControl( id(new AphrontFormSelectControl()) ->setName('dstColumnPHID') ->setLabel(pht('Move to Column')) ->setValue($dst_column_phid) ->setOptions($column_options)); $submit = pht('Move Tasks'); $hidden['dstProjectPHID'] = $dst_project->getPHID(); $hidden['hasColumn'] = true; $hidden['hasProject'] = true; } else { $title = pht('Move Tasks to Project'); if ($dst_project_phid) { $dst_project_phid_value = array($dst_project_phid); } else { $dst_project_phid_value = array(); } $form = id(new AphrontFormView()) ->setViewer($viewer) ->appendControl( id(new AphrontFormTokenizerControl()) ->setName('dstProjectPHID') ->setLimit(1) ->setLabel(pht('Move to Project')) ->setValue($dst_project_phid_value) ->setDatasource(new PhabricatorProjectDatasource())); $submit = pht('Continue'); $hidden['hasProject'] = true; } $dialog = $this->newWorkboardDialog() ->setWidth(AphrontDialogView::WIDTH_FORM) ->setTitle($title) ->setErrors($errors) ->appendForm($form) ->addSubmitButton($submit) ->addCancelButton($board_uri); foreach ($hidden as $key => $value) { $dialog->addHiddenInput($key, $value); } return $dialog; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectWatchController.php
src/applications/project/controller/PhabricatorProjectWatchController.php
<?php final class PhabricatorProjectWatchController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $action = $request->getURIData('action'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needMembers(true) ->needWatchers(true) ->executeOne(); if (!$project) { return new Aphront404Response(); } $via = $request->getStr('via'); if ($via == 'profile') { $done_uri = "/project/profile/{$id}/"; } else { $done_uri = "/project/members/{$id}/"; } $is_watcher = $project->isUserWatcher($viewer->getPHID()); $is_ancestor = $project->isUserAncestorWatcher($viewer->getPHID()); if ($is_ancestor && !$is_watcher) { $ancestor_phid = $project->getWatchedAncestorPHID($viewer->getPHID()); $handles = $viewer->loadHandles(array($ancestor_phid)); $ancestor_handle = $handles[$ancestor_phid]; return $this->newDialog() ->setTitle(pht('Watching Ancestor')) ->appendParagraph( pht( 'You are already watching %s, an ancestor of this project, and '. 'are thus watching all of its subprojects.', $ancestor_handle->renderTag()->render())) ->addCancelbutton($done_uri); } if ($request->isDialogFormPost()) { $edge_action = null; switch ($action) { case 'watch': $edge_action = '+'; break; case 'unwatch': $edge_action = '-'; break; } $type_watcher = PhabricatorObjectHasWatcherEdgeType::EDGECONST; $member_spec = array( $edge_action => array($viewer->getPHID() => $viewer->getPHID()), ); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $type_watcher) ->setNewValue($member_spec); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } $dialog = null; switch ($action) { case 'watch': $title = pht('Watch Project?'); $body = array(); $body[] = pht( 'Watching a project will let you monitor it closely. You will '. 'receive email and notifications about changes to every object '. 'tagged with projects you watch.'); $body[] = pht( 'Watching a project also watches all subprojects and milestones of '. 'that project.'); $submit = pht('Watch Project'); break; case 'unwatch': $title = pht('Unwatch Project?'); $body = pht( 'You will no longer receive email or notifications about every '. 'object associated with this project.'); $submit = pht('Unwatch Project'); break; default: return new Aphront404Response(); } $dialog = $this->newDialog() ->setTitle($title) ->addHiddenInput('via', $via) ->addCancelButton($done_uri) ->addSubmitButton($submit); foreach ((array)$body as $paragraph) { $dialog->appendParagraph($paragraph); } return $dialog; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardImportController.php
src/applications/project/controller/PhabricatorProjectBoardImportController.php
<?php final class PhabricatorProjectBoardImportController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $project_id = $request->getURIData('projectID'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->withIDs(array($project_id)) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $project_id = $project->getID(); $board_uri = $this->getApplicationURI("board/{$project_id}/"); // See PHI1025. We only want to prevent the import if the board already has // real columns. If it has proxy columns (for example, for milestones) you // can still import columns from another board. $columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withProjectPHIDs(array($project->getPHID())) ->withIsProxyColumn(false) ->execute(); if ($columns) { return $this->newDialog() ->setTitle(pht('Workboard Already Has Columns')) ->appendParagraph( pht( 'You can not import columns into this workboard because it '. 'already has columns. You can only import into an empty '. 'workboard.')) ->addCancelButton($board_uri); } if ($request->isFormPost()) { $import_phid = $request->getArr('importProjectPHID'); $import_phid = reset($import_phid); $import_columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withProjectPHIDs(array($import_phid)) ->withIsProxyColumn(false) ->execute(); if (!$import_columns) { return $this->newDialog() ->setTitle(pht('Source Workboard Has No Columns')) ->appendParagraph( pht( 'You can not import columns from that workboard because it has '. 'no importable columns.')) ->addCancelButton($board_uri); } $table = id(new PhabricatorProjectColumn()) ->openTransaction(); foreach ($import_columns as $import_column) { if ($import_column->isHidden()) { continue; } $new_column = PhabricatorProjectColumn::initializeNewColumn($viewer) ->setSequence($import_column->getSequence()) ->setProjectPHID($project->getPHID()) ->setName($import_column->getName()) ->setProperties($import_column->getProperties()) ->save(); } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE) ->setNewValue(1); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); $table->saveTransaction(); return id(new AphrontRedirectResponse())->setURI($board_uri); } $proj_selector = id(new AphrontFormTokenizerControl()) ->setName('importProjectPHID') ->setUser($viewer) ->setDatasource(id(new PhabricatorProjectDatasource()) ->setParameters(array('mustHaveColumns' => true)) ->setLimit(1)); return $this->newDialog() ->setTitle(pht('Import Columns')) ->setWidth(AphrontDialogView::WIDTH_FORM) ->appendParagraph(pht('Choose a project to import columns from:')) ->appendChild($proj_selector) ->addCancelButton($board_uri) ->addSubmitButton(pht('Import')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectEditPictureController.php
src/applications/project/controller/PhabricatorProjectEditPictureController.php
<?php final class PhabricatorProjectEditPictureController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needImages(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $manage_uri = $this->getApplicationURI('manage/'.$project->getID().'/'); $supported_formats = PhabricatorFile::getTransformableImageFormats(); $e_file = true; $errors = array(); if ($request->isFormPost()) { $phid = $request->getStr('phid'); $is_default = false; if ($phid == PhabricatorPHIDConstants::PHID_VOID) { $phid = null; $is_default = true; } else if ($phid) { $file = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($phid)) ->executeOne(); } else { if ($request->getFileExists('picture')) { $file = PhabricatorFile::newFromPHPUpload( $_FILES['picture'], array( 'authorPHID' => $viewer->getPHID(), 'canCDN' => true, )); } else { $e_file = pht('Required'); $errors[] = pht( 'You must choose a file when uploading a new project picture.'); } } if (!$errors && !$is_default) { if (!$file->isTransformableImage()) { $e_file = pht('Not Supported'); $errors[] = pht( 'This server only supports these image formats: %s.', implode(', ', $supported_formats)); } else { $xform = PhabricatorFileTransform::getTransformByKey( PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE); $xformed = $xform->executeTransform($file); } } if (!$errors) { if ($is_default) { $new_value = null; } else { $new_value = $xformed->getPHID(); } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectImageTransaction::TRANSACTIONTYPE) ->setNewValue($new_value); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true); $editor->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($manage_uri); } } $title = pht('Edit Project Picture'); $form = id(new PHUIFormLayoutView()) ->setUser($viewer); $builtin = PhabricatorProjectIconSet::getIconImage( $project->getIcon()); $default_image = PhabricatorFile::loadBuiltin($this->getViewer(), 'projects/'.$builtin); $images = array(); $current = $project->getProfileImagePHID(); $has_current = false; if ($current) { $files = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($current)) ->execute(); if ($files) { $file = head($files); if ($file->isTransformableImage()) { $has_current = true; $images[$current] = array( 'uri' => $file->getBestURI(), 'tip' => pht('Current Picture'), ); } } } $root = dirname(phutil_get_library_root('phabricator')); $root = $root.'/resources/builtin/projects/v3/'; $builtins = id(new FileFinder($root)) ->withType('f') ->withFollowSymlinks(true) ->find(); foreach ($builtins as $builtin) { $file = PhabricatorFile::loadBuiltin($viewer, 'projects/v3/'.$builtin); $images[$file->getPHID()] = array( 'uri' => $file->getBestURI(), 'tip' => pht('Builtin Image'), ); } $images[PhabricatorPHIDConstants::PHID_VOID] = array( 'uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'), ); require_celerity_resource('people-profile-css'); Javelin::initBehavior('phabricator-tooltips', array()); $buttons = array(); foreach ($images as $phid => $spec) { $button = javelin_tag( 'button', array( 'class' => 'button-grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array( 'tip' => $spec['tip'], 'size' => 300, ), ), phutil_tag( 'img', array( 'height' => 50, 'width' => 50, 'src' => $spec['uri'], ))); $button = array( phutil_tag( 'input', array( 'type' => 'hidden', 'name' => 'phid', 'value' => $phid, )), $button, ); $button = phabricator_form( $viewer, array( 'class' => 'profile-image-form', 'method' => 'POST', ), $button); $buttons[] = $button; } if ($has_current) { $form->appendChild( id(new AphrontFormMarkupControl()) ->setLabel(pht('Current Picture')) ->setValue(array_shift($buttons))); } $form->appendChild( id(new AphrontFormMarkupControl()) ->setLabel(pht('Use Picture')) ->setValue( array( $this->renderDefaultForm($project), $buttons, ))); $launch_id = celerity_generate_unique_node_id(); $input_id = celerity_generate_unique_node_id(); Javelin::initBehavior( 'launch-icon-composer', array( 'launchID' => $launch_id, 'inputID' => $input_id, )); $compose_button = javelin_tag( 'button', array( 'class' => 'button-grey', 'id' => $launch_id, 'sigil' => 'icon-composer', ), pht('Choose Icon and Color...')); $compose_input = javelin_tag( 'input', array( 'type' => 'hidden', 'id' => $input_id, 'name' => 'phid', )); $compose_form = phabricator_form( $viewer, array( 'class' => 'profile-image-form', 'method' => 'POST', ), array( $compose_input, $compose_button, )); $form->appendChild( id(new AphrontFormMarkupControl()) ->setLabel(pht('Custom')) ->setValue($compose_form)); $upload_form = id(new AphrontFormView()) ->setUser($viewer) ->setEncType('multipart/form-data') ->appendChild( id(new AphrontFormFileControl()) ->setName('picture') ->setLabel(pht('Upload Picture')) ->setError($e_file) ->setCaption( pht('Supported formats: %s', implode(', ', $supported_formats)))) ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton($manage_uri) ->setValue(pht('Upload Picture'))); $form_box = id(new PHUIObjectBoxView()) ->setHeaderText($title) ->setFormErrors($errors) ->setForm($form); $upload_box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Upload New Picture')) ->setForm($upload_form); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_MANAGE); return $this->newPage() ->setTitle($title) ->setNavigation($nav) ->appendChild( array( $form_box, $upload_box, )); } private function renderDefaultForm(PhabricatorProject $project) { $viewer = $this->getViewer(); $compose_color = $project->getDisplayIconComposeColor(); $compose_icon = $project->getDisplayIconComposeIcon(); $default_builtin = id(new PhabricatorFilesComposeIconBuiltinFile()) ->setColor($compose_color) ->setIcon($compose_icon); $file_builtins = PhabricatorFile::loadBuiltins( $viewer, array($default_builtin)); $file_builtin = head($file_builtins); $default_button = javelin_tag( 'button', array( 'class' => 'button-grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array( 'tip' => pht('Use Icon and Color'), 'size' => 300, ), ), phutil_tag( 'img', array( 'height' => 50, 'width' => 50, 'src' => $file_builtin->getBestURI(), ))); $inputs = array( 'projectPHID' => $project->getPHID(), 'icon' => $compose_icon, 'color' => $compose_color, ); foreach ($inputs as $key => $value) { $inputs[$key] = javelin_tag( 'input', array( 'type' => 'hidden', 'name' => $key, 'value' => $value, )); } $default_form = phabricator_form( $viewer, array( 'class' => 'profile-image-form', 'method' => 'POST', 'action' => '/file/compose/', ), array( $inputs, $default_button, )); return $default_form; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectReportsController.php
src/applications/project/controller/PhabricatorProjectReportsController.php
<?php final class PhabricatorProjectReportsController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $id = $project->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_REPORTS); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Reports')); $crumbs->setBorder(true); $chart_panel = id(new PhabricatorProjectBurndownChartEngine()) ->setViewer($viewer) ->setProjects(array($project)) ->buildChartPanel(); $chart_panel->setName(pht('%s: Burndown', $project->getName())); $chart_view = id(new PhabricatorDashboardPanelRenderingEngine()) ->setViewer($viewer) ->setPanel($chart_panel) ->setParentPanelPHIDs(array()) ->renderPanel(); $activity_panel = id(new PhabricatorProjectActivityChartEngine()) ->setViewer($viewer) ->setProjects(array($project)) ->buildChartPanel(); $activity_panel->setName(pht('%s: Activity', $project->getName())); $activity_view = id(new PhabricatorDashboardPanelRenderingEngine()) ->setViewer($viewer) ->setPanel($activity_panel) ->setParentPanelPHIDs(array()) ->renderPanel(); $view = id(new PHUITwoColumnView()) ->setFooter( array( $chart_view, $activity_view, )); return $this->newPage() ->setNavigation($nav) ->setCrumbs($crumbs) ->setTitle(array($project->getName(), pht('Reports'))) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardReloadController.php
src/applications/project/controller/PhabricatorProjectBoardReloadController.php
<?php final class PhabricatorProjectBoardReloadController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $order = $request->getStr('order'); if (!strlen($order)) { $order = PhabricatorProjectColumnNaturalOrder::ORDERKEY; } $ordering = PhabricatorProjectColumnOrder::getOrderByKey($order); $ordering = id(clone $ordering) ->setViewer($viewer); $project = $this->getProject(); $state = $this->getViewState(); $board_uri = $state->newWorkboardURI(); $layout_engine = $state->getLayoutEngine(); $board_phid = $project->getPHID(); $objects = $state->getObjects(); $objects = mpull($objects, null, 'getPHID'); try { $client_state = $request->getStr('state'); $client_state = phutil_json_decode($client_state); } catch (PhutilJSONParserException $ex) { $client_state = array(); } // Figure out which objects need to be updated: either the client has an // out-of-date version of them (objects which have been edited); or they // exist on the client but not on the server (objects which have been // removed from the board); or they exist on the server but not on the // client (objects which have been added to the board). $update_objects = array(); foreach ($objects as $object_phid => $object) { // TODO: For now, this is always hard-coded. $object_version = 2; $client_version = idx($client_state, $object_phid, 0); if ($object_version > $client_version) { $update_objects[$object_phid] = $object; } } $update_phids = array_keys($update_objects); $visible_phids = array_keys($client_state); $engine = id(new PhabricatorBoardResponseEngine()) ->setViewer($viewer) ->setBoardPHID($board_phid) ->setOrdering($ordering) ->setObjects($objects) ->setUpdatePHIDs($update_phids) ->setVisiblePHIDs($visible_phids); return $engine->buildResponse(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectManageController.php
src/applications/project/controller/PhabricatorProjectManageController.php
<?php final class PhabricatorProjectManageController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $response = $this->loadProject(); if ($response) { return $response; } $viewer = $request->getUser(); $project = $this->getProject(); $id = $project->getID(); $picture = $project->getProfileImageURI(); $header = id(new PHUIHeaderView()) ->setHeader(pht('Project History')) ->setUser($viewer) ->setPolicyObject($project); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $curtain = $this->buildCurtain($project); $properties = $this->buildPropertyListView($project); $timeline = $this->buildTransactionTimeline( $project, new PhabricatorProjectTransactionQuery()); $timeline->setShouldTerminate(true); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_MANAGE); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Manage')); $crumbs->setBorder(true); require_celerity_resource('project-view-css'); $manage = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->addPropertySection(pht('Details'), $properties) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setMainColumn( array( $timeline, )); return $this->newPage() ->setNavigation($nav) ->setCrumbs($crumbs) ->setTitle( array( $project->getDisplayName(), pht('Manage'), )) ->appendChild( array( $manage, )); } private function buildCurtain(PhabricatorProject $project) { $viewer = $this->getViewer(); $id = $project->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $curtain = $this->newCurtainView($project); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Details')) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI("edit/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Menu')) ->setIcon('fa-th-list') ->setHref($this->getApplicationURI("{$id}/item/configure/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Picture')) ->setIcon('fa-picture-o') ->setHref($this->getApplicationURI("picture/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); if ($project->isArchived()) { $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Activate Project')) ->setIcon('fa-check') ->setHref($this->getApplicationURI("archive/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(true)); } else { $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Archive Project')) ->setIcon('fa-ban') ->setHref($this->getApplicationURI("archive/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(true)); } return $curtain; } private function buildPropertyListView( PhabricatorProject $project) { $viewer = $this->getViewer(); $view = id(new PHUIPropertyListView()) ->setUser($viewer); $view->addProperty( pht('Looks Like'), $viewer->renderHandle($project->getPHID())->setAsTag(true)); $slugs = $project->getSlugs(); $tags = mpull($slugs, 'getSlug'); $view->addProperty( pht('Hashtags'), $this->renderHashtags($tags)); $field_list = PhabricatorCustomField::getObjectFields( $project, PhabricatorCustomField::ROLE_VIEW); $field_list->appendFieldsToPropertyList($project, $viewer, $view); return $view; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardFilterController.php
src/applications/project/controller/PhabricatorProjectBoardFilterController.php
<?php final class PhabricatorProjectBoardFilterController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $state = $this->getViewState(); $board_uri = $state->newWorkboardURI(); $search_engine = $state->getSearchEngine(); $is_submit = $request->isFormPost(); if ($is_submit) { $saved_query = $search_engine->buildSavedQueryFromRequest($request); $search_engine->saveQuery($saved_query); } else { $saved_query = $state->getSavedQuery(); if (!$saved_query) { return new Aphront404Response(); } } $filter_form = id(new AphrontFormView()) ->setUser($viewer); $search_engine->buildSearchForm($filter_form, $saved_query); $errors = $search_engine->getErrors(); if ($is_submit && !$errors) { $query_key = $saved_query->getQueryKey(); $state->setQueryKey($query_key); $board_uri = $state->newWorkboardURI(); return id(new AphrontRedirectResponse())->setURI($board_uri); } return $this->newWorkboardDialog() ->setWidth(AphrontDialogView::WIDTH_FULL) ->setTitle(pht('Advanced Filter')) ->appendChild($filter_form->buildLayoutView()) ->setErrors($errors) ->addSubmitButton(pht('Apply Filter')) ->addCancelButton($board_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardViewController.php
src/applications/project/controller/PhabricatorProjectBoardViewController.php
<?php final class PhabricatorProjectBoardViewController extends PhabricatorProjectBoardController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $state = $this->getViewState(); $board_uri = $project->getWorkboardURI(); $search_engine = $state->getSearchEngine(); $query_key = $state->getQueryKey(); $saved = $state->getSavedQuery(); if (!$saved) { return new Aphront404Response(); } if ($saved->getID()) { $custom_query = $saved; } else { $custom_query = null; } $layout_engine = $state->getLayoutEngine(); $board_phid = $project->getPHID(); $columns = $layout_engine->getColumns($board_phid); if (!$columns || !$project->getHasWorkboard()) { $has_normal_columns = false; foreach ($columns as $column) { if (!$column->getProxyPHID()) { $has_normal_columns = true; break; } } $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); if (!$has_normal_columns) { if (!$can_edit) { $content = $this->buildNoAccessContent($project); } else { $content = $this->buildInitializeContent($project); } } else { if (!$can_edit) { $content = $this->buildDisabledContent($project); } else { $content = $this->buildEnableContent($project); } } if ($content instanceof AphrontResponse) { return $content; } $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_WORKBOARD); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Workboard')); return $this->newPage() ->setTitle( array( $project->getDisplayName(), pht('Workboard'), )) ->setNavigation($nav) ->setCrumbs($crumbs) ->appendChild($content); } $tasks = $state->getObjects(); $task_can_edit_map = id(new PhabricatorPolicyFilter()) ->setViewer($viewer) ->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT)) ->apply($tasks); $board_id = celerity_generate_unique_node_id(); $board = id(new PHUIWorkboardView()) ->setUser($viewer) ->setID($board_id) ->addSigil('jx-workboard') ->setMetadata( array( 'boardPHID' => $project->getPHID(), )); $visible_columns = array(); $column_phids = array(); $visible_phids = array(); foreach ($columns as $column) { if (!$state->getShowHidden()) { if ($column->isHidden()) { continue; } } $proxy = $column->getProxy(); if ($proxy && !$proxy->isMilestone()) { // TODO: For now, don't show subproject columns because we can't // handle tasks with multiple positions yet. continue; } $task_phids = $layout_engine->getColumnObjectPHIDs( $board_phid, $column->getPHID()); $column_tasks = array_select_keys($tasks, $task_phids); $column_phid = $column->getPHID(); $visible_columns[$column_phid] = $column; $column_phids[$column_phid] = $column_tasks; foreach ($column_tasks as $phid => $task) { $visible_phids[$phid] = $phid; } } $container_phids = $state->getBoardContainerPHIDs(); $rendering_engine = id(new PhabricatorBoardRenderingEngine()) ->setViewer($viewer) ->setObjects(array_select_keys($tasks, $visible_phids)) ->setEditMap($task_can_edit_map) ->setExcludedProjectPHIDs($container_phids); $templates = array(); $all_tasks = array(); $column_templates = array(); $sounds = array(); foreach ($visible_columns as $column_phid => $column) { $column_tasks = $column_phids[$column_phid]; $panel = id(new PHUIWorkpanelView()) ->setHeader($column->getDisplayName()) ->setSubHeader($column->getDisplayType()) ->addSigil('workpanel'); $proxy = $column->getProxy(); if ($proxy) { $proxy_id = $proxy->getID(); $href = $this->getApplicationURI("view/{$proxy_id}/"); $panel->setHref($href); } $header_icon = $column->getHeaderIcon(); if ($header_icon) { $panel->setHeaderIcon($header_icon); } $display_class = $column->getDisplayClass(); if ($display_class) { $panel->addClass($display_class); } if ($column->isHidden()) { $panel->addClass('project-panel-hidden'); } $column_menu = $this->buildColumnMenu($project, $column); $panel->addHeaderAction($column_menu); if ($column->canHaveTrigger()) { $trigger = $column->getTrigger(); if ($trigger) { $trigger->setViewer($viewer); } $trigger_menu = $this->buildTriggerMenu($column); $panel->addHeaderAction($trigger_menu); } $count_tag = id(new PHUITagView()) ->setType(PHUITagView::TYPE_SHADE) ->setColor(PHUITagView::COLOR_BLUE) ->addSigil('column-points') ->setName( javelin_tag( 'span', array( 'sigil' => 'column-points-content', ), pht('-'))) ->setStyle('display: none'); $panel->setHeaderTag($count_tag); $cards = id(new PHUIObjectItemListView()) ->setUser($viewer) ->setFlush(true) ->setAllowEmptyList(true) ->addSigil('project-column') ->setItemClass('phui-workcard') ->setMetadata( array( 'columnPHID' => $column->getPHID(), 'pointLimit' => $column->getPointLimit(), )); $card_phids = array(); foreach ($column_tasks as $task) { $object_phid = $task->getPHID(); $card = $rendering_engine->renderCard($object_phid); $templates[$object_phid] = hsprintf('%s', $card->getItem()); $card_phids[] = $object_phid; $all_tasks[$object_phid] = $task; } $panel->setCards($cards); $board->addPanel($panel); $drop_effects = $column->getDropEffects(); $drop_effects = mpull($drop_effects, 'toDictionary'); $preview_effect = null; if ($column->canHaveTrigger()) { $trigger = $column->getTrigger(); if ($trigger) { $preview_effect = $trigger->getPreviewEffect() ->toDictionary(); foreach ($trigger->getSoundEffects() as $sound) { $sounds[] = $sound; } } } $column_templates[] = array( 'columnPHID' => $column_phid, 'effects' => $drop_effects, 'cardPHIDs' => $card_phids, 'triggerPreviewEffect' => $preview_effect, ); } $order_key = $state->getOrder(); $ordering_map = PhabricatorProjectColumnOrder::getEnabledOrders(); $ordering = id(clone $ordering_map[$order_key]) ->setViewer($viewer); $headers = $ordering->getHeadersForObjects($all_tasks); $headers = mpull($headers, 'toDictionary'); $vectors = $ordering->getSortVectorsForObjects($all_tasks); $vector_map = array(); foreach ($vectors as $task_phid => $vector) { $vector_map[$task_phid][$order_key] = $vector; } $header_keys = $ordering->getHeaderKeysForObjects($all_tasks); $order_maps = array(); $order_maps[] = $ordering->toDictionary(); $properties = array(); foreach ($all_tasks as $task) { $properties[$task->getPHID()] = PhabricatorBoardResponseEngine::newTaskProperties($task); } $behavior_config = array( 'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'), 'uploadURI' => '/file/dropupload/', 'coverURI' => $this->getApplicationURI('cover/'), 'reloadURI' => phutil_string_cast($state->newWorkboardURI('reload/')), 'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(), 'pointsEnabled' => ManiphestTaskPoints::getIsEnabled(), 'boardPHID' => $project->getPHID(), 'order' => $state->getOrder(), 'orders' => $order_maps, 'headers' => $headers, 'headerKeys' => $header_keys, 'templateMap' => $templates, 'orderMaps' => $vector_map, 'propertyMaps' => $properties, 'columnTemplates' => $column_templates, 'boardID' => $board_id, 'projectPHID' => $project->getPHID(), 'preloadSounds' => $sounds, ); $this->initBehavior('project-boards', $behavior_config); $sort_menu = $this->buildSortMenu( $viewer, $project, $state->getOrder(), $ordering_map); $filter_menu = $this->buildFilterMenu( $viewer, $project, $custom_query, $search_engine, $query_key); $manage_menu = $this->buildManageMenu($project, $state->getShowHidden()); $header_link = phutil_tag( 'a', array( 'href' => $this->getApplicationURI('profile/'.$project->getID().'/'), ), $project->getName()); $board_box = id(new PHUIBoxView()) ->appendChild($board) ->addClass('project-board-wrapper'); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_WORKBOARD); $divider = id(new PHUIListItemView()) ->setType(PHUIListItemView::TYPE_DIVIDER); $fullscreen = $this->buildFullscreenMenu(); $crumbs = $this->newWorkboardCrumbs(); $crumbs->addTextCrumb(pht('Workboard')); $crumbs->setBorder(true); $crumbs->addAction($sort_menu); $crumbs->addAction($filter_menu); $crumbs->addAction($divider); $crumbs->addAction($manage_menu); $crumbs->addAction($fullscreen); $page = $this->newPage() ->setTitle( array( $project->getDisplayName(), pht('Workboard'), )) ->setPageObjectPHIDs(array($project->getPHID())) ->setShowFooter(false) ->setNavigation($nav) ->setCrumbs($crumbs) ->addQuicksandConfig( array( 'boardConfig' => $behavior_config, )) ->appendChild( array( $board_box, )); $background = $project->getDisplayWorkboardBackgroundColor(); require_celerity_resource('phui-workboard-color-css'); if ($background !== null) { $background_color_class = "phui-workboard-{$background}"; $page->addClass('phui-workboard-color'); $page->addClass($background_color_class); } else { $page->addClass('phui-workboard-no-color'); } return $page; } private function buildSortMenu( PhabricatorUser $viewer, PhabricatorProject $project, $sort_key, array $ordering_map) { $state = $this->getViewState(); $base_uri = $state->newWorkboardURI(); $items = array(); foreach ($ordering_map as $key => $ordering) { // TODO: It would be desirable to build a real "PHUIIconView" here, but // the pathway for threading that through all the view classes ends up // being fairly complex, since some callers read the icon out of other // views. For now, just stick with a string. $ordering_icon = $ordering->getMenuIconIcon(); $ordering_name = $ordering->getDisplayName(); $is_selected = ($key === $sort_key); if ($is_selected) { $active_name = $ordering_name; $active_icon = $ordering_icon; } $item = id(new PhabricatorActionView()) ->setIcon($ordering_icon) ->setSelected($is_selected) ->setName($ordering_name); $uri = $base_uri->alter('order', $key); $item->setHref($uri); $items[] = $item; } $id = $project->getID(); $save_uri = $state->newWorkboardURI('default/sort/'); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $items[] = id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER); $items[] = id(new PhabricatorActionView()) ->setIcon('fa-floppy-o') ->setName(pht('Save as Default')) ->setHref($save_uri) ->setWorkflow(true) ->setDisabled(!$can_edit); $sort_menu = id(new PhabricatorActionListView()) ->setUser($viewer); foreach ($items as $item) { $sort_menu->addAction($item); } $sort_button = id(new PHUIListItemView()) ->setName($active_name) ->setIcon($active_icon) ->setHref('#') ->addSigil('boards-dropdown-menu') ->setMetadata( array( 'items' => hsprintf('%s', $sort_menu), )); return $sort_button; } private function buildFilterMenu( PhabricatorUser $viewer, PhabricatorProject $project, $custom_query, PhabricatorApplicationSearchEngine $engine, $query_key) { $state = $this->getViewState(); $named = array( 'open' => pht('Open Tasks'), 'all' => pht('All Tasks'), ); if ($viewer->isLoggedIn()) { $named['assigned'] = pht('Assigned to Me'); } if ($custom_query) { $named[$custom_query->getQueryKey()] = pht('Custom Filter'); } $items = array(); foreach ($named as $key => $name) { $is_selected = ($key == $query_key); if ($is_selected) { $active_filter = $name; } $is_custom = false; if ($custom_query) { $is_custom = ($key == $custom_query->getQueryKey()); } $item = id(new PhabricatorActionView()) ->setIcon('fa-search') ->setSelected($is_selected) ->setName($name); if ($is_custom) { // When you're using a custom filter already and you select "Custom // Filter", you get a dialog back to let you edit the filter. This is // equivalent to selecting "Advanced Filter..." to configure a new // filter. $filter_uri = $state->newWorkboardURI('filter/'); $item->setWorkflow(true); } else { $filter_uri = urisprintf('query/%s/', $key); $filter_uri = $state->newWorkboardURI($filter_uri); $filter_uri->removeQueryParam('filter'); } $item->setHref($filter_uri); $items[] = $item; } $id = $project->getID(); $filter_uri = $state->newWorkboardURI('filter/'); $items[] = id(new PhabricatorActionView()) ->setIcon('fa-cog') ->setHref($filter_uri) ->setWorkflow(true) ->setName(pht('Advanced Filter...')); $save_uri = $state->newWorkboardURI('default/filter/'); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $items[] = id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER); $items[] = id(new PhabricatorActionView()) ->setIcon('fa-floppy-o') ->setName(pht('Save as Default')) ->setHref($save_uri) ->setWorkflow(true) ->setDisabled(!$can_edit); $filter_menu = id(new PhabricatorActionListView()) ->setUser($viewer); foreach ($items as $item) { $filter_menu->addAction($item); } $filter_button = id(new PHUIListItemView()) ->setName($active_filter) ->setIcon('fa-search') ->setHref('#') ->addSigil('boards-dropdown-menu') ->setMetadata( array( 'items' => hsprintf('%s', $filter_menu), )); return $filter_button; } private function buildManageMenu( PhabricatorProject $project, $show_hidden) { $request = $this->getRequest(); $viewer = $request->getUser(); $state = $this->getViewState(); $id = $project->getID(); $manage_uri = $this->getApplicationURI("board/{$id}/manage/"); $add_uri = $this->getApplicationURI("board/{$id}/edit/"); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $manage_items = array(); $manage_items[] = id(new PhabricatorActionView()) ->setIcon('fa-plus') ->setName(pht('Add Column')) ->setHref($add_uri) ->setDisabled(!$can_edit) ->setWorkflow(true); $reorder_uri = $this->getApplicationURI("board/{$id}/reorder/"); $manage_items[] = id(new PhabricatorActionView()) ->setIcon('fa-exchange') ->setName(pht('Reorder Columns')) ->setHref($reorder_uri) ->setDisabled(!$can_edit) ->setWorkflow(true); if ($show_hidden) { $hidden_uri = $state->newWorkboardURI() ->removeQueryParam('hidden'); $hidden_icon = 'fa-eye-slash'; $hidden_text = pht('Hide Hidden Columns'); } else { $hidden_uri = $state->newWorkboardURI() ->replaceQueryParam('hidden', 'true'); $hidden_icon = 'fa-eye'; $hidden_text = pht('Show Hidden Columns'); } $manage_items[] = id(new PhabricatorActionView()) ->setIcon($hidden_icon) ->setName($hidden_text) ->setHref($hidden_uri); $manage_items[] = id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER); $background_uri = $this->getApplicationURI("board/{$id}/background/"); $manage_items[] = id(new PhabricatorActionView()) ->setIcon('fa-paint-brush') ->setName(pht('Change Background Color')) ->setHref($background_uri) ->setDisabled(!$can_edit) ->setWorkflow(false); $manage_uri = $this->getApplicationURI("board/{$id}/manage/"); $manage_items[] = id(new PhabricatorActionView()) ->setIcon('fa-gear') ->setName(pht('Manage Workboard')) ->setHref($manage_uri); $manage_menu = id(new PhabricatorActionListView()) ->setUser($viewer); foreach ($manage_items as $item) { $manage_menu->addAction($item); } $manage_button = id(new PHUIListItemView()) ->setIcon('fa-cog') ->setHref('#') ->addSigil('boards-dropdown-menu') ->addSigil('has-tooltip') ->setMetadata( array( 'tip' => pht('Manage'), 'align' => 'S', 'items' => hsprintf('%s', $manage_menu), )); return $manage_button; } private function buildFullscreenMenu() { $up = id(new PHUIListItemView()) ->setIcon('fa-arrows-alt') ->setHref('#') ->addClass('phui-workboard-expand-icon') ->addSigil('jx-toggle-class') ->addSigil('has-tooltip') ->setMetaData(array( 'tip' => pht('Fullscreen'), 'map' => array( 'phabricator-standard-page' => 'phui-workboard-fullscreen', ), )); return $up; } private function buildColumnMenu( PhabricatorProject $project, PhabricatorProjectColumn $column) { $request = $this->getRequest(); $viewer = $request->getUser(); $state = $this->getViewState(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $column_items = array(); if ($column->getProxyPHID()) { $default_phid = $column->getProxyPHID(); } else { $default_phid = $column->getProjectPHID(); } $specs = id(new ManiphestEditEngine()) ->setViewer($viewer) ->newCreateActionSpecifications(array()); foreach ($specs as $spec) { $column_items[] = id(new PhabricatorActionView()) ->setIcon($spec['icon']) ->setName($spec['name']) ->setHref($spec['uri']) ->setDisabled($spec['disabled']) ->addSigil('column-add-task') ->setMetadata( array( 'createURI' => $spec['uri'], 'columnPHID' => $column->getPHID(), 'boardPHID' => $project->getPHID(), 'projectPHID' => $default_phid, )); } $column_items[] = id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER); $query_uri = urisprintf('viewquery/%d/', $column->getID()); $query_uri = $state->newWorkboardURI($query_uri); $column_items[] = id(new PhabricatorActionView()) ->setName(pht('View Tasks as Query')) ->setIcon('fa-search') ->setHref($query_uri); $column_move_uri = urisprintf('bulkmove/%d/column/', $column->getID()); $column_move_uri = $state->newWorkboardURI($column_move_uri); $column_items[] = id(new PhabricatorActionView()) ->setIcon('fa-arrows-h') ->setName(pht('Move Tasks to Column...')) ->setHref($column_move_uri) ->setWorkflow(true); $project_move_uri = urisprintf('bulkmove/%d/project/', $column->getID()); $project_move_uri = $state->newWorkboardURI($project_move_uri); $column_items[] = id(new PhabricatorActionView()) ->setIcon('fa-arrows') ->setName(pht('Move Tasks to Project...')) ->setHref($project_move_uri) ->setWorkflow(true); $bulk_edit_uri = urisprintf('bulk/%d/', $column->getID()); $bulk_edit_uri = $state->newWorkboardURI($bulk_edit_uri); $can_bulk_edit = PhabricatorPolicyFilter::hasCapability( $viewer, PhabricatorApplication::getByClass('PhabricatorManiphestApplication'), ManiphestBulkEditCapability::CAPABILITY); $column_items[] = id(new PhabricatorActionView()) ->setIcon('fa-pencil-square-o') ->setName(pht('Bulk Edit Tasks...')) ->setHref($bulk_edit_uri) ->setDisabled(!$can_bulk_edit); $column_items[] = id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER); $edit_uri = 'board/'.$project->getID().'/edit/'.$column->getID().'/'; $column_items[] = id(new PhabricatorActionView()) ->setName(pht('Edit Column')) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI($edit_uri)) ->setDisabled(!$can_edit) ->setWorkflow(true); $can_hide = ($can_edit && !$column->isDefaultColumn()); $hide_uri = urisprintf('hide/%d/', $column->getID()); $hide_uri = $state->newWorkboardURI($hide_uri); if (!$column->isHidden()) { $column_items[] = id(new PhabricatorActionView()) ->setName(pht('Hide Column')) ->setIcon('fa-eye-slash') ->setHref($hide_uri) ->setDisabled(!$can_hide) ->setWorkflow(true); } else { $column_items[] = id(new PhabricatorActionView()) ->setName(pht('Show Column')) ->setIcon('fa-eye') ->setHref($hide_uri) ->setDisabled(!$can_hide) ->setWorkflow(true); } $column_menu = id(new PhabricatorActionListView()) ->setUser($viewer); foreach ($column_items as $item) { $column_menu->addAction($item); } $column_button = id(new PHUIIconView()) ->setIcon('fa-pencil') ->setHref('#') ->addSigil('boards-dropdown-menu') ->setMetadata( array( 'items' => hsprintf('%s', $column_menu), )); return $column_button; } private function buildTriggerMenu(PhabricatorProjectColumn $column) { $viewer = $this->getViewer(); $trigger = $column->getTrigger(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $column, PhabricatorPolicyCapability::CAN_EDIT); $trigger_items = array(); if (!$trigger) { $set_uri = $this->getApplicationURI( new PhutilURI( 'trigger/edit/', array( 'columnPHID' => $column->getPHID(), ))); $trigger_items[] = id(new PhabricatorActionView()) ->setIcon('fa-cogs') ->setName(pht('New Trigger...')) ->setHref($set_uri) ->setDisabled(!$can_edit); } else { $trigger_items[] = id(new PhabricatorActionView()) ->setIcon('fa-cogs') ->setName(pht('View Trigger')) ->setHref($trigger->getURI()) ->setDisabled(!$can_edit); } $remove_uri = $this->getApplicationURI( new PhutilURI( urisprintf( 'column/remove/%d/', $column->getID()))); $trigger_items[] = id(new PhabricatorActionView()) ->setIcon('fa-times') ->setName(pht('Remove Trigger')) ->setHref($remove_uri) ->setWorkflow(true) ->setDisabled(!$can_edit || !$trigger); $trigger_menu = id(new PhabricatorActionListView()) ->setUser($viewer); foreach ($trigger_items as $item) { $trigger_menu->addAction($item); } if ($trigger) { $trigger_icon = 'fa-cogs'; } else { $trigger_icon = 'fa-cogs grey'; } $trigger_button = id(new PHUIIconView()) ->setIcon($trigger_icon) ->setHref('#') ->addSigil('boards-dropdown-menu') ->addSigil('trigger-preview') ->setMetadata( array( 'items' => hsprintf('%s', $trigger_menu), 'columnPHID' => $column->getPHID(), )); return $trigger_button; } private function buildInitializeContent(PhabricatorProject $project) { $request = $this->getRequest(); $viewer = $this->getViewer(); $type = $request->getStr('initialize-type'); $id = $project->getID(); $profile_uri = $this->getApplicationURI("profile/{$id}/"); $board_uri = $this->getApplicationURI("board/{$id}/"); $import_uri = $this->getApplicationURI("board/{$id}/import/"); $set_default = $request->getBool('default'); if ($set_default) { $this ->getProfileMenuEngine() ->adjustDefault(PhabricatorProject::ITEM_WORKBOARD); } if ($request->isFormPost()) { if ($type == 'backlog-only') { $column = PhabricatorProjectColumn::initializeNewColumn($viewer) ->setSequence(0) ->setProperty('isDefault', true) ->setProjectPHID($project->getPHID()) ->save(); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE) ->setNewValue(1); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse()) ->setURI($board_uri); } else { return id(new AphrontRedirectResponse()) ->setURI($import_uri); } } // TODO: Tailor this UI if the project is already a parent project. We // should not offer options for creating a parent project workboard, since // they can't have their own columns. $new_selector = id(new AphrontFormRadioButtonControl()) ->setLabel(pht('Columns')) ->setName('initialize-type') ->setValue('backlog-only') ->addButton( 'backlog-only', pht('New Empty Board'), pht('Create a new board with just a backlog column.')) ->addButton( 'import', pht('Import Columns'), pht('Import board columns from another project.')); $default_checkbox = id(new AphrontFormCheckboxControl()) ->setLabel(pht('Make Default')) ->addCheckbox( 'default', 1, pht('Make the workboard the default view for this project.'), true); $form = id(new AphrontFormView()) ->setUser($viewer) ->addHiddenInput('initialize', 1) ->appendRemarkupInstructions( pht('The workboard for this project has not been created yet.')) ->appendControl($new_selector) ->appendControl($default_checkbox) ->appendControl( id(new AphrontFormSubmitControl()) ->addCancelButton($profile_uri) ->setValue(pht('Create Workboard'))); $box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Create Workboard')) ->setForm($form); return $box; } private function buildNoAccessContent(PhabricatorProject $project) { $viewer = $this->getViewer(); $id = $project->getID(); $profile_uri = $this->getApplicationURI("profile/{$id}/"); return $this->newDialog() ->setTitle(pht('Unable to Create Workboard')) ->appendParagraph( pht( 'The workboard for this project has not been created yet, '. 'but you do not have permission to create it. Only users '. 'who can edit this project can create a workboard for it.')) ->addCancelButton($profile_uri); } private function buildEnableContent(PhabricatorProject $project) { $request = $this->getRequest(); $viewer = $this->getViewer(); $id = $project->getID(); $profile_uri = $this->getApplicationURI("profile/{$id}/"); $board_uri = $this->getApplicationURI("board/{$id}/"); if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE) ->setNewValue(1); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse()) ->setURI($board_uri); } return $this->newDialog() ->setTitle(pht('Workboard Disabled')) ->addHiddenInput('initialize', 1) ->appendParagraph( pht( 'This workboard has been disabled, but can be restored to its '. 'former glory.')) ->addCancelButton($profile_uri) ->addSubmitButton(pht('Enable Workboard')); } private function buildDisabledContent(PhabricatorProject $project) { $viewer = $this->getViewer(); $id = $project->getID(); $profile_uri = $this->getApplicationURI("profile/{$id}/"); return $this->newDialog() ->setTitle(pht('Workboard Disabled')) ->appendParagraph( pht( 'This workboard has been disabled, and you do not have permission '. 'to enable it. Only users who can edit this project can restore '. 'the workboard.')) ->addCancelButton($profile_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectUpdateController.php
src/applications/project/controller/PhabricatorProjectUpdateController.php
<?php final class PhabricatorProjectUpdateController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $action = $request->getURIData('action'); $capabilities = array( PhabricatorPolicyCapability::CAN_VIEW, ); switch ($action) { case 'join': $capabilities[] = PhabricatorPolicyCapability::CAN_JOIN; break; case 'leave': break; default: return new Aphront404Response(); } $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needMembers(true) ->requireCapabilities($capabilities) ->executeOne(); if (!$project) { return new Aphront404Response(); } $done_uri = "/project/members/{$id}/"; if (!$project->supportsEditMembers()) { $copy = pht('Parent projects and milestones do not support adding '. 'members. You can add members directly to any non-parent subproject.'); return $this->newDialog() ->setTitle(pht('Unsupported Project')) ->appendParagraph($copy) ->addCancelButton($done_uri); } if ($request->isFormPost()) { $edge_action = null; switch ($action) { case 'join': $edge_action = '+'; break; case 'leave': $edge_action = '-'; break; } $type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $member_spec = array( $edge_action => array($viewer->getPHID() => $viewer->getPHID()), ); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $type_member) ->setNewValue($member_spec); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } $is_locked = $project->getIsMembershipLocked(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $can_leave = ($can_edit || !$is_locked); $button = null; if ($action == 'leave') { if ($can_leave) { $title = pht('Leave Project'); $body = pht( 'Your tremendous contributions to this project will be sorely '. 'missed. Are you sure you want to leave?'); $button = pht('Leave Project'); } else { $title = pht('Membership Locked'); $body = pht( 'Membership for this project is locked. You can not leave.'); } } else { $title = pht('Join Project'); $body = pht( 'Join this project? You will become a member and enjoy whatever '. 'benefits membership may confer.'); $button = pht('Join Project'); } $dialog = $this->newDialog() ->setTitle($title) ->appendParagraph($body) ->addCancelButton($done_uri); if ($button) { $dialog->addSubmitButton($button); } return $dialog; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardController.php
src/applications/project/controller/PhabricatorProjectBoardController.php
<?php abstract class PhabricatorProjectBoardController extends PhabricatorProjectController { private $viewState; final protected function getViewState() { if ($this->viewState === null) { $this->viewState = $this->newViewState(); } return $this->viewState; } private function newViewState() { $project = $this->getProject(); $request = $this->getRequest(); return id(new PhabricatorWorkboardViewState()) ->setProject($project) ->readFromRequest($request); } final protected function newWorkboardDialog() { $dialog = $this->newDialog(); $state = $this->getViewState(); foreach ($state->getQueryParameters() as $key => $value) { $dialog->addHiddenInput($key, $value); } return $dialog; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectSilenceController.php
src/applications/project/controller/PhabricatorProjectSilenceController.php
<?php final class PhabricatorProjectSilenceController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $action = $request->getURIData('action'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needMembers(true) ->executeOne(); if (!$project) { return new Aphront404Response(); } $edge_type = PhabricatorProjectSilencedEdgeType::EDGECONST; $done_uri = "/project/members/{$id}/"; $viewer_phid = $viewer->getPHID(); if (!$project->isUserMember($viewer_phid)) { return $this->newDialog() ->setTitle(pht('Not a Member')) ->appendParagraph( pht( 'You are not a project member, so you do not receive mail sent '. 'to members of this project.')) ->addCancelButton($done_uri); } $silenced = PhabricatorEdgeQuery::loadDestinationPHIDs( $project->getPHID(), $edge_type); $silenced = array_fuse($silenced); $is_silenced = isset($silenced[$viewer_phid]); if ($request->isDialogFormPost()) { if ($is_silenced) { $edge_action = '-'; } else { $edge_action = '+'; } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $edge_type) ->setNewValue( array( $edge_action => array($viewer_phid => $viewer_phid), )); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } if ($is_silenced) { $title = pht('Enable Mail'); $body = pht( 'When mail is sent to members of this project, you will receive a '. 'copy.'); $button = pht('Enable Project Mail'); } else { $title = pht('Disable Mail'); $body = pht( 'When mail is sent to members of this project, you will no longer '. 'receive a copy.'); $button = pht('Disable Project Mail'); } return $this->newDialog() ->setTitle($title) ->appendParagraph($body) ->addCancelButton($done_uri) ->addSubmitButton($button); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectMembersViewController.php
src/applications/project/controller/PhabricatorProjectMembersViewController.php
<?php final class PhabricatorProjectMembersViewController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needMembers(true) ->needWatchers(true) ->needImages(true) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $title = pht('Members and Watchers'); $curtain = $this->buildCurtainView($project); $member_list = id(new PhabricatorProjectMemberListView()) ->setUser($viewer) ->setProject($project) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setUserPHIDs($project->getMemberPHIDs()) ->setShowNote(true); $watcher_list = id(new PhabricatorProjectWatcherListView()) ->setUser($viewer) ->setProject($project) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setUserPHIDs($project->getWatcherPHIDs()) ->setShowNote(true); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_MEMBERS); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Members')); $crumbs->setBorder(true); $header = id(new PHUIHeaderView()) ->setHeader($title) ->setHeaderIcon('fa-group'); require_celerity_resource('project-view-css'); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setMainColumn(array( $member_list, $watcher_list, )); return $this->newPage() ->setNavigation($nav) ->setCrumbs($crumbs) ->setTitle(array($project->getName(), $title)) ->appendChild($view); } private function buildCurtainView(PhabricatorProject $project) { $viewer = $this->getViewer(); $id = $project->getID(); $curtain = $this->newCurtainView(); $is_locked = $project->getIsMembershipLocked(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $supports_edit = $project->supportsEditMembers(); $can_join = $supports_edit && PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_JOIN); $can_leave = $supports_edit && (!$is_locked || $can_edit); $viewer_phid = $viewer->getPHID(); if (!$project->isUserMember($viewer_phid)) { $curtain->addAction( id(new PhabricatorActionView()) ->setHref('/project/update/'.$project->getID().'/join/') ->setIcon('fa-plus') ->setDisabled(!$can_join) ->setWorkflow(true) ->setName(pht('Join Project'))); } else { $curtain->addAction( id(new PhabricatorActionView()) ->setHref('/project/update/'.$project->getID().'/leave/') ->setIcon('fa-times') ->setDisabled(!$can_leave) ->setWorkflow(true) ->setName(pht('Leave Project'))); } if (!$project->isUserWatcher($viewer->getPHID())) { $curtain->addAction( id(new PhabricatorActionView()) ->setWorkflow(true) ->setHref('/project/watch/'.$project->getID().'/') ->setIcon('fa-eye') ->setName(pht('Watch Project'))); } else { $curtain->addAction( id(new PhabricatorActionView()) ->setWorkflow(true) ->setHref('/project/unwatch/'.$project->getID().'/') ->setIcon('fa-eye-slash') ->setName(pht('Unwatch Project'))); } $can_silence = $project->isUserMember($viewer_phid); $is_silenced = $this->isProjectSilenced($project); if ($is_silenced) { $silence_text = pht('Enable Mail'); } else { $silence_text = pht('Disable Mail'); } $curtain->addAction( id(new PhabricatorActionView()) ->setName($silence_text) ->setIcon('fa-envelope-o') ->setHref("/project/silence/{$id}/") ->setWorkflow(true) ->setDisabled(!$can_silence)); $can_add = $can_edit && $supports_edit; $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Add Members')) ->setIcon('fa-user-plus') ->setHref("/project/members/{$id}/add/") ->setWorkflow(true) ->setDisabled(!$can_add)); $can_lock = $can_edit && $supports_edit && $this->hasApplicationCapability( ProjectCanLockProjectsCapability::CAPABILITY); if ($is_locked) { $lock_name = pht('Unlock Project'); $lock_icon = 'fa-unlock'; } else { $lock_name = pht('Lock Project'); $lock_icon = 'fa-lock'; } $curtain->addAction( id(new PhabricatorActionView()) ->setName($lock_name) ->setIcon($lock_icon) ->setHref($this->getApplicationURI("lock/{$id}/")) ->setDisabled(!$can_lock) ->setWorkflow(true)); if ($project->isMilestone()) { $icon_key = PhabricatorProjectIconSet::getMilestoneIconKey(); $header = PhabricatorProjectIconSet::getIconName($icon_key); $note = pht( 'Members of the parent project are members of this project.'); $show_join = false; } else if ($project->getHasSubprojects()) { $header = pht('Parent Project'); $note = pht( 'Members of all subprojects are members of this project.'); $show_join = false; } else if ($project->getIsMembershipLocked()) { $header = pht('Locked Project'); $note = pht( 'Users with access may join this project, but may not leave.'); $show_join = true; } else { $header = pht('Normal Project'); $note = pht('Users with access may join and leave this project.'); $show_join = true; } $curtain->newPanel() ->setHeaderText($header) ->appendChild($note); if ($show_join) { $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( $viewer, $project); $curtain->newPanel() ->setHeaderText(pht('Joinable By')) ->appendChild($descriptions[PhabricatorPolicyCapability::CAN_JOIN]); } return $curtain; } private function isProjectSilenced(PhabricatorProject $project) { $viewer = $this->getViewer(); $viewer_phid = $viewer->getPHID(); if (!$viewer_phid) { return false; } $edge_type = PhabricatorProjectSilencedEdgeType::EDGECONST; $silenced = PhabricatorEdgeQuery::loadDestinationPHIDs( $project->getPHID(), $edge_type); $silenced = array_fuse($silenced); return isset($silenced[$viewer_phid]); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectSubprojectsController.php
src/applications/project/controller/PhabricatorProjectSubprojectsController.php
<?php final class PhabricatorProjectSubprojectsController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $id = $project->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $allows_subprojects = $project->supportsSubprojects(); $allows_milestones = $project->supportsMilestones(); $subproject_list = null; $milestone_list = null; if ($allows_subprojects) { $subprojects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) ->withIsMilestone(false) ->execute(); $subproject_list = id(new PHUIObjectBoxView()) ->setHeaderText(pht('%s Subprojects', $project->getName())) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setObjectList( id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($subprojects) ->setNoDataString(pht('This project has no subprojects.')) ->renderList()); } else { $subprojects = array(); } if ($allows_milestones) { $milestones = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) ->withIsMilestone(true) ->setOrderVector(array('milestoneNumber', 'id')) ->execute(); $milestone_list = id(new PHUIObjectBoxView()) ->setHeaderText(pht('%s Milestones', $project->getName())) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setObjectList( id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($milestones) ->setNoDataString(pht('This project has no milestones.')) ->renderList()); } else { $milestones = array(); } $curtain = $this->buildCurtainView( $project, $milestones, $subprojects); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_SUBPROJECTS); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Subprojects')); $crumbs->setBorder(true); $header = id(new PHUIHeaderView()) ->setHeader(pht('Subprojects and Milestones')) ->setHeaderIcon('fa-sitemap'); require_celerity_resource('project-view-css'); // This page isn't reachable via UI, but make it pretty anyways. $info_view = null; if (!$milestone_list && !$subproject_list) { $info_view = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ->appendChild(pht('Milestone projects do not support subprojects '. 'or milestones.')); } $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setMainColumn(array( $info_view, $subproject_list, $milestone_list, )); return $this->newPage() ->setNavigation($nav) ->setCrumbs($crumbs) ->setTitle(array($project->getName(), pht('Subprojects'))) ->appendChild($view); } private function buildCurtainView( PhabricatorProject $project, array $milestones, array $subprojects) { $viewer = $this->getViewer(); $id = $project->getID(); $can_create = $this->hasApplicationCapability( ProjectCreateProjectsCapability::CAPABILITY); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); $allows_subprojects = $project->supportsSubprojects(); $allows_milestones = $project->supportsMilestones(); $curtain = $this->newCurtainView(); $can_subproject = ($can_create && $can_edit && $allows_subprojects); // If we're offering to create the first subproject, we're going to warn // the user about the effects before moving forward. if ($can_subproject && !$subprojects) { $subproject_href = "/project/warning/{$id}/"; $subproject_disabled = false; $subproject_workflow = true; } else { $subproject_href = "/project/edit/?parent={$id}"; $subproject_disabled = !$can_subproject; $subproject_workflow = !$can_subproject; } $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Create Subproject')) ->setIcon('fa-plus') ->setHref($subproject_href) ->setDisabled($subproject_disabled) ->setWorkflow($subproject_workflow)); if ($allows_milestones && $milestones) { $milestone_text = pht('Create Next Milestone'); } else { $milestone_text = pht('Create Milestone'); } $can_milestone = ($can_create && $can_edit && $allows_milestones); $milestone_href = "/project/edit/?milestone={$id}"; $curtain->addAction( id(new PhabricatorActionView()) ->setName($milestone_text) ->setIcon('fa-plus') ->setHref($milestone_href) ->setDisabled(!$can_milestone) ->setWorkflow(!$can_milestone)); if (!$project->supportsSubprojects()) { $note = pht( 'This project is a milestone, and milestones may not have '. 'subprojects.'); } else { if (!$subprojects) { $note = pht('Subprojects can be created for this project.'); } else { $note = pht('This project has subprojects.'); } } $curtain->newPanel() ->setHeaderText(pht('Subprojects')) ->appendChild($note); if (!$project->supportsSubprojects()) { $note = pht( 'This project is already a milestone, and milestones may not '. 'have their own milestones.'); } else { if (!$milestones) { $note = pht('Milestones can be created for this project.'); } else { $note = pht('This project has milestones.'); } } $curtain->newPanel() ->setHeaderText(pht('Milestones')) ->appendChild($note); return $curtain; } private function renderStatus($icon, $target, $note) { $item = id(new PHUIStatusItemView()) ->setIcon($icon) ->setTarget(phutil_tag('strong', array(), $target)) ->setNote($note); return id(new PHUIStatusListView()) ->addItem($item); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnHideController.php
src/applications/project/controller/PhabricatorProjectColumnHideController.php
<?php final class PhabricatorProjectColumnHideController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project_id = $request->getURIData('projectID'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->withIDs(array($project_id)) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $column = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$column) { return new Aphront404Response(); } $column_phid = $column->getPHID(); $view_uri = $project->getWorkboardURI(); $view_uri = new PhutilURI($view_uri); foreach ($request->getPassthroughRequestData() as $key => $value) { $view_uri->replaceQueryParam($key, $value); } if ($column->isDefaultColumn()) { return $this->newDialog() ->setTitle(pht('Can Not Hide Default Column')) ->appendParagraph( pht('You can not hide the default/backlog column on a board.')) ->addCancelButton($view_uri, pht('Okay')); } $proxy = $column->getProxy(); if ($request->isFormPost()) { if ($proxy) { if ($proxy->isArchived()) { $new_status = PhabricatorProjectStatus::STATUS_ACTIVE; } else { $new_status = PhabricatorProjectStatus::STATUS_ARCHIVED; } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectStatusTransaction::TRANSACTIONTYPE) ->setNewValue($new_status); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($proxy, $xactions); } else { if ($column->isHidden()) { $new_status = PhabricatorProjectColumn::STATUS_ACTIVE; } else { $new_status = PhabricatorProjectColumn::STATUS_HIDDEN; } $type_status = PhabricatorProjectColumnStatusTransaction::TRANSACTIONTYPE; $xactions = array( id(new PhabricatorProjectColumnTransaction()) ->setTransactionType($type_status) ->setNewValue($new_status), ); $editor = id(new PhabricatorProjectColumnTransactionEditor()) ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->setContentSourceFromRequest($request) ->applyTransactions($column, $xactions); } return id(new AphrontRedirectResponse())->setURI($view_uri); } if ($proxy) { if ($column->isHidden()) { $title = pht('Activate and Show Column'); $body = pht( 'This column is hidden because it represents an archived '. 'subproject. Do you want to activate the subproject so the '. 'column is visible again?'); $button = pht('Activate Subproject'); } else { $title = pht('Archive and Hide Column'); $body = pht( 'This column is visible because it represents an active '. 'subproject. Do you want to hide the column by archiving the '. 'subproject?'); $button = pht('Archive Subproject'); } } else { if ($column->isHidden()) { $title = pht('Show Column'); $body = pht('Are you sure you want to show this column?'); $button = pht('Show Column'); } else { $title = pht('Hide Column'); $body = pht( 'Are you sure you want to hide this column? It will no longer '. 'appear on the workboard.'); $button = pht('Hide Column'); } } $dialog = $this->newDialog() ->setWidth(AphrontDialogView::WIDTH_FORM) ->setTitle($title) ->appendChild($body) ->setDisableWorkflowOnCancel(true) ->addCancelButton($view_uri) ->addSubmitButton($button); foreach ($request->getPassthroughRequestData() as $key => $value) { $dialog->addHiddenInput($key, $value); } return $dialog; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardDefaultController.php
src/applications/project/controller/PhabricatorProjectBoardDefaultController.php
<?php final class PhabricatorProjectBoardDefaultController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProjectForEdit(); if ($response) { return $response; } $project = $this->getProject(); $state = $this->getViewState(); $board_uri = $state->newWorkboardURI(); $remove_param = null; $target = $request->getURIData('target'); switch ($target) { case 'filter': $title = pht('Set Board Default Filter'); $body = pht( 'Make the current filter the new default filter for this board? '. 'All users will see the new filter as the default when they view '. 'the board.'); $button = pht('Save Default Filter'); $xaction_value = $state->getQueryKey(); $xaction_type = PhabricatorProjectFilterTransaction::TRANSACTIONTYPE; $remove_param = 'filter'; break; case 'sort': $title = pht('Set Board Default Order'); $body = pht( 'Make the current sort order the new default order for this board? '. 'All users will see the new order as the default when they view '. 'the board.'); $button = pht('Save Default Order'); $xaction_value = $state->getOrder(); $xaction_type = PhabricatorProjectSortTransaction::TRANSACTIONTYPE; $remove_param = 'order'; break; default: return new Aphront404Response(); } $id = $project->getID(); if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType($xaction_type) ->setNewValue($xaction_value); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); // If the parameter we just modified is present in the query string, // throw it away so the user is redirected back to the default view of // the board, allowing them to see the new default behavior. $board_uri->removeQueryParam($remove_param); return id(new AphrontRedirectResponse())->setURI($board_uri); } return $this->newWorkboardDialog() ->setTitle($title) ->appendChild($body) ->addCancelButton($board_uri) ->addSubmitButton($title); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectViewController.php
src/applications/project/controller/PhabricatorProjectViewController.php
<?php final class PhabricatorProjectViewController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $request = $this->getRequest(); $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $engine = $this->getProfileMenuEngine(); $default = $engine->getDefaultMenuItemConfiguration(); // If defaults are broken somehow, serve the manage page. See T13033 for // discussion. if ($default) { $default_key = $default->getBuiltinKey(); } else { $default_key = PhabricatorProject::ITEM_MANAGE; } switch ($default_key) { case PhabricatorProject::ITEM_WORKBOARD: $controller_object = new PhabricatorProjectBoardViewController(); break; case PhabricatorProject::ITEM_PROFILE: $controller_object = new PhabricatorProjectProfileController(); break; case PhabricatorProject::ITEM_MANAGE: $controller_object = new PhabricatorProjectManageController(); break; default: return $engine->buildResponse(); } return $this->delegateToController($controller_object); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectLockController.php
src/applications/project/controller/PhabricatorProjectLockController.php
<?php final class PhabricatorProjectLockController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $this->requireApplicationCapability( ProjectCanLockProjectsCapability::CAPABILITY); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$project) { return new Aphront404Response(); } $done_uri = "/project/members/{$id}/"; if (!$project->supportsEditMembers()) { return $this->newDialog() ->setTitle(pht('Membership Immutable')) ->appendChild( pht('This project does not support editing membership.')) ->addCancelButton($done_uri); } $is_locked = $project->getIsMembershipLocked(); if ($request->isFormPost()) { $xactions = array(); if ($is_locked) { $new_value = 0; } else { $new_value = 1; } $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectLockTransaction::TRANSACTIONTYPE) ->setNewValue($new_value); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } if ($project->getIsMembershipLocked()) { $title = pht('Unlock Project'); $body = pht( 'If you unlock this project, members will be free to leave.'); $button = pht('Unlock Project'); } else { $title = pht('Lock Project'); $body = pht( 'If you lock this project, members will be prevented from '. 'leaving it.'); $button = pht('Lock Project'); } return $this->newDialog() ->setTitle($title) ->appendParagraph($body) ->addSubmitbutton($button) ->addCancelButton($done_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardBackgroundController.php
src/applications/project/controller/PhabricatorProjectBoardBackgroundController.php
<?php final class PhabricatorProjectBoardBackgroundController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $board_id = $request->getURIData('projectID'); $board = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($board_id)) ->needImages(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$board) { return new Aphront404Response(); } if (!$board->getHasWorkboard()) { return new Aphront404Response(); } $this->setProject($board); $id = $board->getID(); $view_uri = $this->getApplicationURI("board/{$id}/"); $manage_uri = $this->getApplicationURI("board/{$id}/manage/"); if ($request->isFormPost()) { $background_key = $request->getStr('backgroundKey'); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectWorkboardBackgroundTransaction::TRANSACTIONTYPE) ->setNewValue($background_key); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($board, $xactions); return id(new AphrontRedirectResponse()) ->setURI($view_uri); } $nav = $this->newNavigation( $board, PhabricatorProject::ITEM_WORKBOARD); $crumbs = id($this->buildApplicationCrumbs()) ->addTextCrumb(pht('Workboard'), $board->getWorkboardURI()) ->addTextCrumb(pht('Manage'), $manage_uri) ->addTextCrumb(pht('Background Color')); $form = id(new AphrontFormView()) ->setUser($viewer); $group_info = array( 'basic' => array( 'label' => pht('Basics'), ), 'solid' => array( 'label' => pht('Solid Colors'), ), 'gradient' => array( 'label' => pht('Gradients'), ), ); $groups = array(); $options = PhabricatorProjectWorkboardBackgroundColor::getOptions(); $option_groups = igroup($options, 'group'); require_celerity_resource('people-profile-css'); require_celerity_resource('phui-workboard-color-css'); Javelin::initBehavior('phabricator-tooltips', array()); foreach ($group_info as $group_key => $spec) { $buttons = array(); $available_options = idx($option_groups, $group_key, array()); foreach ($available_options as $option) { $buttons[] = $this->renderOptionButton($option); } $form->appendControl( id(new AphrontFormMarkupControl()) ->setLabel($spec['label']) ->setValue($buttons)); } // NOTE: Each button is its own form, so we can't wrap them in a normal // form. $layout_view = $form->buildLayoutView(); $form_box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Edit Background Color')) ->appendChild($layout_view); return $this->newPage() ->setTitle( array( pht('Edit Background Color'), $board->getDisplayName(), )) ->setCrumbs($crumbs) ->setNavigation($nav) ->appendChild($form_box); } private function renderOptionButton(array $option) { $viewer = $this->getViewer(); $icon = idx($option, 'icon'); if ($icon) { $preview_class = null; $preview_content = id(new PHUIIconView()) ->setIcon($icon, 'lightbluetext'); } else { $preview_class = 'phui-workboard-'.$option['key']; $preview_content = null; } $preview = phutil_tag( 'div', array( 'class' => 'phui-workboard-color-preview '.$preview_class, ), $preview_content); $button = javelin_tag( 'button', array( 'class' => 'button-grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array( 'tip' => $option['name'], 'size' => 300, ), ), $preview); $input = phutil_tag( 'input', array( 'type' => 'hidden', 'name' => 'backgroundKey', 'value' => $option['key'], )); return phabricator_form( $viewer, array( 'class' => 'profile-image-form', 'method' => 'POST', ), array( $button, $input, )); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectMoveController.php
src/applications/project/controller/PhabricatorProjectMoveController.php
<?php final class PhabricatorProjectMoveController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $request->validateCSRF(); $column_phid = $request->getStr('columnPHID'); $object_phid = $request->getStr('objectPHID'); $after_phids = $request->getStrList('afterPHIDs'); $before_phids = $request->getStrList('beforePHIDs'); $order = $request->getStr('order'); if ($order === null || !strlen($order)) { $order = PhabricatorProjectColumnNaturalOrder::ORDERKEY; } $ordering = PhabricatorProjectColumnOrder::getOrderByKey($order); $ordering = id(clone $ordering) ->setViewer($viewer); $edit_header = null; $raw_header = $request->getStr('header'); if ($raw_header !== null && strlen($raw_header)) { $edit_header = phutil_json_decode($raw_header); } else { $edit_header = array(); } $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, )) ->withIDs(array($id)) ->executeOne(); if (!$project) { return new Aphront404Response(); } $cancel_uri = $this->getApplicationURI( new PhutilURI( urisprintf('board/%d/', $project->getID()), array( 'order' => $order, ))); $board_phid = $project->getPHID(); $object = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withPHIDs(array($object_phid)) ->needProjectPHIDs(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$object) { return new Aphront404Response(); } $columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withProjectPHIDs(array($project->getPHID())) ->needTriggers(true) ->execute(); $columns = mpull($columns, null, 'getPHID'); $column = idx($columns, $column_phid); if (!$column) { // User is trying to drop this object into a nonexistent column, just kick // them out. return new Aphront404Response(); } $engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setBoardPHIDs(array($board_phid)) ->setObjectPHIDs(array($object_phid)) ->executeLayout(); $order_params = array( 'afterPHIDs' => $after_phids, 'beforePHIDs' => $before_phids, ); $xactions = array(); $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_COLUMNS) ->setNewValue( array( array( 'columnPHID' => $column->getPHID(), ) + $order_params, )); $header_xactions = $ordering->getColumnTransactions( $object, $edit_header); foreach ($header_xactions as $header_xaction) { $xactions[] = $header_xaction; } $sounds = array(); if ($column->canHaveTrigger()) { $trigger = $column->getTrigger(); if ($trigger) { $trigger_xactions = $trigger->newDropTransactions( $viewer, $column, $object); foreach ($trigger_xactions as $trigger_xaction) { $xactions[] = $trigger_xaction; } foreach ($trigger->getSoundEffects() as $effect) { $sounds[] = $effect; } } } $editor = id(new ManiphestTransactionEditor()) ->setActor($viewer) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request) ->setCancelURI($cancel_uri); $editor->applyTransactions($object, $xactions); return $this->newCardResponse( $board_phid, $object_phid, $ordering, $sounds); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectEditController.php
src/applications/project/controller/PhabricatorProjectEditController.php
<?php final class PhabricatorProjectEditController extends PhabricatorProjectController { private $engine; public function setEngine(PhabricatorProjectEditEngine $engine) { $this->engine = $engine; return $this; } public function getEngine() { return $this->engine; } public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $engine = id(new PhabricatorProjectEditEngine()) ->setController($this); $this->setEngine($engine); $id = $request->getURIData('id'); if (!$id) { // This capability is checked again later, but checking it here // explicitly gives us a better error message. $this->requireApplicationCapability( ProjectCreateProjectsCapability::CAPABILITY); $parent_id = head($request->getArr('parent')); if (!$parent_id) { $parent_id = $request->getStr('parent'); } if ($parent_id) { $is_milestone = false; } else { $parent_id = head($request->getArr('milestone')); if (!$parent_id) { $parent_id = $request->getStr('milestone'); } $is_milestone = true; } if ($parent_id) { $query = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->needImages(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )); if (ctype_digit($parent_id)) { $query->withIDs(array($parent_id)); } else { $query->withPHIDs(array($parent_id)); } $parent = $query->executeOne(); if ($is_milestone) { if (!$parent->supportsMilestones()) { $cancel_uri = "/project/subprojects/{$parent_id}/"; return $this->newDialog() ->setTitle(pht('No Milestones')) ->appendParagraph( pht('You can not add milestones to this project.')) ->addCancelButton($cancel_uri); } $engine->setMilestoneProject($parent); } else { if (!$parent->supportsSubprojects()) { $cancel_uri = "/project/subprojects/{$parent_id}/"; return $this->newDialog() ->setTitle(pht('No Subprojects')) ->appendParagraph( pht('You can not add subprojects to this project.')) ->addCancelButton($cancel_uri); } $engine->setParentProject($parent); } $this->setProject($parent); } } return $engine->buildResponse(); } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); $engine = $this->getEngine(); if ($engine) { $parent = $engine->getParentProject(); $milestone = $engine->getMilestoneProject(); if ($parent || $milestone) { $id = nonempty($parent, $milestone)->getID(); $crumbs->addTextCrumb( pht('Subprojects'), $this->getApplicationURI("subprojects/{$id}/")); } } return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardReorderController.php
src/applications/project/controller/PhabricatorProjectBoardReorderController.php
<?php final class PhabricatorProjectBoardReorderController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $projectid = $request->getURIData('projectID'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->withIDs(array($projectid)) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $project_id = $project->getID(); $view_uri = $this->getApplicationURI("board/{$project_id}/"); $reorder_uri = $this->getApplicationURI("board/{$project_id}/reorder/"); if ($request->isFormPost()) { // User clicked "Done", make sure the page reloads to show the new // column order. return id(new AphrontRedirectResponse())->setURI($view_uri); } $columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withProjectPHIDs(array($project->getPHID())) ->execute(); $columns = msort($columns, 'getSequence'); $column_phid = $request->getStr('columnPHID'); if ($column_phid && $request->validateCSRF()) { $columns = mpull($columns, null, 'getPHID'); if (empty($columns[$column_phid])) { return new Aphront404Response(); } $target_column = $columns[$column_phid]; $new_sequence = $request->getInt('sequence'); if ($new_sequence < 0) { return new Aphront404Response(); } // TODO: For now, we're not recording any transactions here. We probably // should, but this sort of edit is extremely trivial. // Resequence the columns so that the moved column has the correct // sequence number. Move columns after it up one place in the sequence. $new_map = array(); foreach ($columns as $phid => $column) { $value = $column->getSequence(); if ($column->getPHID() == $column_phid) { $value = $new_sequence; } else if ($column->getSequence() >= $new_sequence) { $value = $value + 1; } $new_map[$phid] = $value; } // Sort the columns into their new ordering. asort($new_map); // Now, compact the ordering and adjust any columns that need changes. $project->openTransaction(); $sequence = 0; foreach ($new_map as $phid => $ignored) { $new_value = $sequence++; $cur_value = $columns[$phid]->getSequence(); if ($new_value != $cur_value) { $columns[$phid]->setSequence($new_value)->save(); } } $project->saveTransaction(); return id(new AphrontAjaxResponse())->setContent( array( 'sequenceMap' => mpull($columns, 'getSequence', 'getPHID'), )); } $list_id = celerity_generate_unique_node_id(); $list = id(new PHUIObjectItemListView()) ->setUser($viewer) ->setID($list_id) ->setFlush(true) ->setDrag(true); foreach ($columns as $column) { // Don't allow milestone columns to be reordered. $proxy = $column->getProxy(); if ($proxy && $proxy->isMilestone()) { continue; } // At least for now, don't show subproject column. if ($proxy) { continue; } $item = id(new PHUIObjectItemView()) ->setHeader($column->getDisplayName()) ->addIcon($column->getHeaderIcon(), $column->getDisplayType()); if ($column->isHidden()) { $item->setDisabled(true); } $item->setGrippable(true); $item->addSigil('board-column'); $item->setMetadata( array( 'columnPHID' => $column->getPHID(), 'columnSequence' => $column->getSequence(), )); $list->addItem($item); } Javelin::initBehavior( 'reorder-columns', array( 'listID' => $list_id, 'reorderURI' => $reorder_uri, )); return $this->newDialog() ->setTitle(pht('Reorder Columns')) ->setWidth(AphrontDialogView::WIDTH_FORM) ->appendChild($list) ->addSubmitButton(pht('Done')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnViewQueryController.php
src/applications/project/controller/PhabricatorProjectColumnViewQueryController.php
<?php final class PhabricatorProjectColumnViewQueryController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $state = $this->getViewState(); $board_uri = $state->newWorkboardURI(); // NOTE: We're performing layout without handing the "LayoutEngine" any // object PHIDs. We only want to get access to the column object the user // is trying to query, so we do not need to actually position any cards on // the board. $board_phid = $project->getPHID(); $layout_engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setBoardPHIDs(array($board_phid)) ->setFetchAllBoards(true) ->executeLayout(); $columns = $layout_engine->getColumns($board_phid); $columns = mpull($columns, null, 'getID'); $column_id = $request->getURIData('columnID'); $column = idx($columns, $column_id); if (!$column) { return new Aphront404Response(); } // Create a saved query to combine the active filter on the workboard // with the column filter. If the user currently has constraints on the // board, we want to add a new column or project constraint, not // completely replace the constraints. $default_query = $state->getSavedQuery(); $saved_query = $default_query->newCopy(); if ($column->getProxyPHID()) { $project_phids = $saved_query->getParameter('projectPHIDs'); if (!$project_phids) { $project_phids = array(); } $project_phids[] = $column->getProxyPHID(); $saved_query->setParameter('projectPHIDs', $project_phids); } else { $saved_query->setParameter( 'columnPHIDs', array($column->getPHID())); } $search_engine = id(new ManiphestTaskSearchEngine()) ->setViewer($viewer); $search_engine->saveQuery($saved_query); $query_key = $saved_query->getQueryKey(); $query_uri = new PhutilURI("/maniphest/query/{$query_key}/#R"); return id(new AphrontRedirectResponse()) ->setURI($query_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectArchiveController.php
src/applications/project/controller/PhabricatorProjectArchiveController.php
<?php final class PhabricatorProjectArchiveController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$project) { return new Aphront404Response(); } $edit_uri = $this->getApplicationURI('manage/'.$project->getID().'/'); if ($request->isFormPost()) { if ($project->isArchived()) { $new_status = PhabricatorProjectStatus::STATUS_ACTIVE; } else { $new_status = PhabricatorProjectStatus::STATUS_ARCHIVED; } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectStatusTransaction::TRANSACTIONTYPE) ->setNewValue($new_status); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse())->setURI($edit_uri); } if ($project->isArchived()) { $title = pht('Really activate project?'); $body = pht('This project will become active again.'); $button = pht('Activate Project'); } else { $title = pht('Really archive project?'); $body = pht('This project will be moved to the archive.'); $button = pht('Archive Project'); } $dialog = id(new AphrontDialogView()) ->setUser($viewer) ->setTitle($title) ->appendChild($body) ->addCancelButton($edit_uri) ->addSubmitButton($button); return id(new AphrontDialogResponse())->setDialog($dialog); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectController.php
src/applications/project/controller/PhabricatorProjectController.php
<?php abstract class PhabricatorProjectController extends PhabricatorController { private $project; private $profileMenu; private $profileMenuEngine; protected function setProject(PhabricatorProject $project) { $this->project = $project; return $this; } protected function getProject() { return $this->project; } protected function loadProject() { return $this->loadProjectWithCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, )); } protected function loadProjectForEdit() { return $this->loadProjectWithCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )); } private function loadProjectWithCapabilities(array $capabilities) { $viewer = $this->getViewer(); $request = $this->getRequest(); $id = nonempty( $request->getURIData('projectID'), $request->getURIData('id')); $slug = $request->getURIData('slug'); if ($slug) { $normal_slug = PhabricatorSlug::normalizeProjectSlug($slug); $is_abnormal = ($slug !== $normal_slug); $normal_uri = "/tag/{$normal_slug}/"; } else { $is_abnormal = false; } $query = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities($capabilities) ->needMembers(true) ->needWatchers(true) ->needImages(true) ->needSlugs(true); if ($slug) { $query->withSlugs(array($slug)); } else { $query->withIDs(array($id)); } $policy_exception = null; try { $project = $query->executeOne(); } catch (PhabricatorPolicyException $ex) { $policy_exception = $ex; $project = null; } if (!$project) { // This project legitimately does not exist, so just 404 the user. if (!$policy_exception) { return new Aphront404Response(); } // Here, the project exists but the user can't see it. If they are // using a non-canonical slug to view the project, redirect to the // canonical slug. If they're already using the canonical slug, rethrow // the exception to give them the policy error. if ($is_abnormal) { return id(new AphrontRedirectResponse())->setURI($normal_uri); } else { throw $policy_exception; } } // The user can view the project, but is using a noncanonical slug. // Redirect to the canonical slug. $primary_slug = $project->getPrimarySlug(); if ($slug && ($slug !== $primary_slug)) { $primary_uri = "/tag/{$primary_slug}/"; return id(new AphrontRedirectResponse())->setURI($primary_uri); } $this->setProject($project); return null; } protected function buildApplicationCrumbs() { return $this->newApplicationCrumbs('profile'); } protected function newWorkboardCrumbs() { return $this->newApplicationCrumbs('workboard'); } private function newApplicationCrumbs($mode) { $crumbs = parent::buildApplicationCrumbs(); $project = $this->getProject(); if ($project) { $ancestors = $project->getAncestorProjects(); $ancestors = array_reverse($ancestors); $ancestors[] = $project; foreach ($ancestors as $ancestor) { if ($ancestor->getPHID() === $project->getPHID()) { // Link the current project's crumb to its profile no matter what, // since we're already on the right context page for it and linking // to the current page isn't helpful. $crumb_uri = $ancestor->getProfileURI(); } else { switch ($mode) { case 'workboard': if ($ancestor->getHasWorkboard()) { $crumb_uri = $ancestor->getWorkboardURI(); } else { $crumb_uri = $ancestor->getProfileURI(); } break; case 'profile': default: $crumb_uri = $ancestor->getProfileURI(); break; } } $crumbs->addTextCrumb($ancestor->getName(), $crumb_uri); } } return $crumbs; } protected function getProfileMenuEngine() { if (!$this->profileMenuEngine) { $viewer = $this->getViewer(); $project = $this->getProject(); if ($project) { $engine = id(new PhabricatorProjectProfileMenuEngine()) ->setViewer($viewer) ->setController($this) ->setProfileObject($project); $this->profileMenuEngine = $engine; } } return $this->profileMenuEngine; } protected function setProfileMenuEngine( PhabricatorProjectProfileMenuEngine $engine) { $this->profileMenuEngine = $engine; return $this; } protected function newCardResponse( $board_phid, $object_phid, PhabricatorProjectColumnOrder $ordering = null, $sounds = array()) { $viewer = $this->getViewer(); $request = $this->getRequest(); $visible_phids = $request->getStrList('visiblePHIDs'); if (!$visible_phids) { $visible_phids = array(); } $engine = id(new PhabricatorBoardResponseEngine()) ->setViewer($viewer) ->setBoardPHID($board_phid) ->setUpdatePHIDs(array($object_phid)) ->setVisiblePHIDs($visible_phids) ->setSounds($sounds); if ($ordering) { $engine->setOrdering($ordering); } return $engine->buildResponse(); } public function renderHashtags(array $tags) { $result = array(); foreach ($tags as $key => $tag) { $result[] = '#'.$tag; } return implode(', ', $result); } final protected function newNavigation( PhabricatorProject $project, $item_identifier) { $engine = $this->getProfileMenuEngine(); $view_list = $engine->newProfileMenuItemViewList(); // See PHI1247. If the "Workboard" item is removed from the menu, we will // not be able to select it. This can happen if a user removes the item, // then manually navigate to the workboard URI (or follows an older link). // In this case, just render the menu with no selected item. if ($view_list->getViewsWithItemIdentifier($item_identifier)) { $view_list->setSelectedViewWithItemIdentifier($item_identifier); } $navigation = $view_list->newNavigationView(); if ($item_identifier === PhabricatorProject::ITEM_WORKBOARD) { $navigation->addClass('project-board-nav'); } return $navigation; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnBulkEditController.php
src/applications/project/controller/PhabricatorProjectColumnBulkEditController.php
<?php final class PhabricatorProjectColumnBulkEditController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $state = $this->getViewState(); $board_uri = $state->newWorkboardURI(); $layout_engine = $state->getLayoutEngine(); $board_phid = $project->getPHID(); $columns = $layout_engine->getColumns($board_phid); $columns = mpull($columns, null, 'getID'); $column_id = $request->getURIData('columnID'); $bulk_column = idx($columns, $column_id); if (!$bulk_column) { return new Aphront404Response(); } $bulk_task_phids = $layout_engine->getColumnObjectPHIDs( $board_phid, $bulk_column->getPHID()); $tasks = $state->getObjects(); $bulk_tasks = array_select_keys($tasks, $bulk_task_phids); $bulk_tasks = id(new PhabricatorPolicyFilter()) ->setViewer($viewer) ->requireCapabilities(array(PhabricatorPolicyCapability::CAN_EDIT)) ->apply($bulk_tasks); if (!$bulk_tasks) { return $this->newDialog() ->setTitle(pht('No Editable Tasks')) ->appendParagraph( pht( 'The selected column contains no visible tasks which you '. 'have permission to edit.')) ->addCancelButton($board_uri); } // Create a saved query to hold the working set. This allows us to get // around URI length limitations with a long "?ids=..." query string. // For details, see T10268. $search_engine = id(new ManiphestTaskSearchEngine()) ->setViewer($viewer); $saved_query = $search_engine->newSavedQuery(); $saved_query->setParameter('ids', mpull($bulk_tasks, 'getID')); $search_engine->saveQuery($saved_query); $query_key = $saved_query->getQueryKey(); $bulk_uri = new PhutilURI("/maniphest/bulk/query/{$query_key}/"); $bulk_uri->replaceQueryParam('board', $project->getID()); return id(new AphrontRedirectResponse()) ->setURI($bulk_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnRemoveTriggerController.php
src/applications/project/controller/PhabricatorProjectColumnRemoveTriggerController.php
<?php final class PhabricatorProjectColumnRemoveTriggerController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $column = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$column) { return new Aphront404Response(); } $done_uri = $column->getWorkboardURI(); if (!$column->getTriggerPHID()) { return $this->newDialog() ->setTitle(pht('No Trigger')) ->appendParagraph( pht('This column does not have a trigger.')) ->addCancelButton($done_uri); } if ($request->isFormPost()) { $column_xactions = array(); $column_xactions[] = $column->getApplicationTransactionTemplate() ->setTransactionType( PhabricatorProjectColumnTriggerTransaction::TRANSACTIONTYPE) ->setNewValue(null); $column_editor = $column->getApplicationTransactionEditor() ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true); $column_editor->applyTransactions($column, $column_xactions); return id(new AphrontRedirectResponse())->setURI($done_uri); } $body = pht('Really remove the trigger from this column?'); return $this->newDialog() ->setTitle(pht('Remove Trigger')) ->appendParagraph($body) ->addSubmitButton(pht('Remove Trigger')) ->addCancelButton($done_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnDetailController.php
src/applications/project/controller/PhabricatorProjectColumnDetailController.php
<?php final class PhabricatorProjectColumnDetailController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project_id = $request->getURIData('projectID'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, )) ->withIDs(array($project_id)) ->needImages(true) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $project_id = $project->getID(); $column = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, )) ->executeOne(); if (!$column) { return new Aphront404Response(); } $timeline = $this->buildTransactionTimeline( $column, new PhabricatorProjectColumnTransactionQuery()); $timeline->setShouldTerminate(true); $title = $column->getDisplayName(); $header = $this->buildHeaderView($column); $properties = $this->buildPropertyView($column); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Workboard'), $project->getWorkboardURI()); $crumbs->addTextCrumb(pht('Column: %s', $title)); $crumbs->setBorder(true); $nav = $this->newNavigation( $project, PhabricatorProject::ITEM_WORKBOARD); require_celerity_resource('project-view-css'); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setMainColumn(array( $properties, $timeline, )); return $this->newPage() ->setTitle($title) ->setNavigation($nav) ->setCrumbs($crumbs) ->appendChild($view); } private function buildHeaderView(PhabricatorProjectColumn $column) { $viewer = $this->getViewer(); $header = id(new PHUIHeaderView()) ->setHeader(pht('Column: %s', $column->getDisplayName())) ->setUser($viewer); if ($column->isHidden()) { $header->setStatus('fa-ban', 'dark', pht('Hidden')); } return $header; } private function buildPropertyView( PhabricatorProjectColumn $column) { $viewer = $this->getViewer(); $properties = id(new PHUIPropertyListView()) ->setUser($viewer) ->setObject($column); $limit = $column->getPointLimit(); if ($limit === null) { $limit_text = pht('No Limit'); } else { $limit_text = $limit; } $properties->addProperty(pht('Point Limit'), $limit_text); $box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Details')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($properties); return $box; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectMembersAddController.php
src/applications/project/controller/PhabricatorProjectMembersAddController.php
<?php final class PhabricatorProjectMembersAddController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $done_uri = "/project/members/{$id}/"; if (!$project->supportsEditMembers()) { $copy = pht('Parent projects and milestones do not support adding '. 'members. You can add members directly to any non-parent subproject.'); return $this->newDialog() ->setTitle(pht('Unsupported Project')) ->appendParagraph($copy) ->addCancelButton($done_uri); } if ($request->isFormPost()) { $member_phids = $request->getArr('memberPHIDs'); $type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $type_member) ->setNewValue( array( '+' => array_fuse($member_phids), )); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse()) ->setURI($done_uri); } $form = id(new AphrontFormView()) ->setUser($viewer) ->appendControl( id(new AphrontFormTokenizerControl()) ->setName('memberPHIDs') ->setLabel(pht('Members')) ->setDatasource(new PhabricatorPeopleDatasource())); return $this->newDialog() ->setTitle(pht('Add Members')) ->appendForm($form) ->addCancelButton($done_uri) ->addSubmitButton(pht('Add Members')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectListController.php
src/applications/project/controller/PhabricatorProjectListController.php
<?php final class PhabricatorProjectListController extends PhabricatorProjectController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { return id(new PhabricatorProjectSearchEngine()) ->setController($this) ->buildResponse(); } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); id(new PhabricatorProjectEditEngine()) ->setViewer($this->getViewer()) ->addActionToCrumbs($crumbs); return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectCoverController.php
src/applications/project/controller/PhabricatorProjectCoverController.php
<?php final class PhabricatorProjectCoverController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $request->validateCSRF(); $board_phid = $request->getStr('boardPHID'); $object_phid = $request->getStr('objectPHID'); $file_phid = $request->getStr('filePHID'); $object = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withPHIDs(array($object_phid)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$object) { return new Aphront404Response(); } $file = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($file_phid)) ->executeOne(); if (!$file) { return new Aphront404Response(); } $xactions = array(); $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(ManiphestTaskCoverImageTransaction::TRANSACTIONTYPE) ->setNewValue($file->getPHID()); $editor = id(new ManiphestTransactionEditor()) ->setActor($viewer) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request); $editor->applyTransactions($object, $xactions); return $this->newCardResponse($board_phid, $object_phid); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectMenuItemController.php
src/applications/project/controller/PhabricatorProjectMenuItemController.php
<?php final class PhabricatorProjectMenuItemController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $response = $this->loadProject(); if ($response) { return $response; } $viewer = $this->getViewer(); $project = $this->getProject(); $engine = id(new PhabricatorProjectProfileMenuEngine()) ->setProfileObject($project) ->setController($this); $this->setProfileMenuEngine($engine); return $engine->buildResponse(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardManageController.php
src/applications/project/controller/PhabricatorProjectBoardManageController.php
<?php final class PhabricatorProjectBoardManageController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $board_id = $request->getURIData('projectID'); $board = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($board_id)) ->needImages(true) ->executeOne(); if (!$board) { return new Aphront404Response(); } $this->setProject($board); // Perform layout of no tasks to load and populate the columns in the // correct order. $layout_engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setBoardPHIDs(array($board->getPHID())) ->setObjectPHIDs(array()) ->setFetchAllBoards(true) ->executeLayout(); $columns = $layout_engine->getColumns($board->getPHID()); $board_id = $board->getID(); $header = $this->buildHeaderView($board); $curtain = $this->buildCurtainView($board); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Workboard'), $board->getWorkboardURI()); $crumbs->addTextCrumb(pht('Manage')); $crumbs->setBorder(true); $nav = $this->newNavigation( $board, PhabricatorProject::ITEM_WORKBOARD); $columns_list = $this->buildColumnsList($board, $columns); require_celerity_resource('project-view-css'); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->addClass('project-view-home') ->addClass('project-view-people-home') ->setCurtain($curtain) ->setMainColumn($columns_list); $title = array( pht('Manage Workboard'), $board->getDisplayName(), ); return $this->newPage() ->setTitle($title) ->setNavigation($nav) ->setCrumbs($crumbs) ->appendChild($view); } private function buildHeaderView(PhabricatorProject $board) { $viewer = $this->getViewer(); $header = id(new PHUIHeaderView()) ->setHeader(pht('Workboard: %s', $board->getDisplayName())) ->setUser($viewer); return $header; } private function buildCurtainView(PhabricatorProject $board) { $viewer = $this->getViewer(); $id = $board->getID(); $curtain = $this->newCurtainView(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $board, PhabricatorPolicyCapability::CAN_EDIT); $disable_uri = $this->getApplicationURI("board/{$id}/disable/"); $curtain->addAction( id(new PhabricatorActionView()) ->setIcon('fa-ban') ->setName(pht('Disable Workboard')) ->setHref($disable_uri) ->setDisabled(!$can_edit) ->setWorkflow(true)); return $curtain; } private function buildColumnsList( PhabricatorProject $board, array $columns) { assert_instances_of($columns, 'PhabricatorProjectColumn'); $board_id = $board->getID(); $view = id(new PHUIObjectItemListView()) ->setNoDataString(pht('This board has no columns.')); foreach ($columns as $column) { $column_id = $column->getID(); $proxy = $column->getProxy(); if ($proxy && !$proxy->isMilestone()) { continue; } $detail_uri = "/project/board/{$board_id}/column/{$column_id}/"; $item = id(new PHUIObjectItemView()) ->setHeader($column->getDisplayName()) ->setHref($detail_uri); if ($column->isHidden()) { $item->setDisabled(true); $item->addAttribute(pht('Hidden')); $item->setImageIcon('fa-columns grey'); } else { $item->addAttribute(pht('Visible')); $item->setImageIcon('fa-columns'); } $view->addItem($item); } return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Columns')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setObjectList($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectMembersRemoveController.php
src/applications/project/controller/PhabricatorProjectMembersRemoveController.php
<?php final class PhabricatorProjectMembersRemoveController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $type = $request->getURIData('type'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needMembers(true) ->needWatchers(true) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$project) { return new Aphront404Response(); } if ($type == 'watchers') { $is_watcher = true; $edge_type = PhabricatorObjectHasWatcherEdgeType::EDGECONST; } else { if (!$project->supportsEditMembers()) { return new Aphront404Response(); } $is_watcher = false; $edge_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; } $members_uri = $this->getApplicationURI('members/'.$project->getID().'/'); $remove_phid = $request->getStr('phid'); if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $edge_type) ->setNewValue( array( '-' => array($remove_phid => $remove_phid), )); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse()) ->setURI($members_uri); } $handle = id(new PhabricatorHandleQuery()) ->setViewer($viewer) ->withPHIDs(array($remove_phid)) ->executeOne(); $target_name = phutil_tag('strong', array(), $handle->getName()); $project_name = phutil_tag('strong', array(), $project->getName()); if ($is_watcher) { $title = pht('Remove Watcher'); $body = pht( 'Remove %s as a watcher of %s?', $target_name, $project_name); $button = pht('Remove Watcher'); } else { $title = pht('Remove Member'); $body = pht( 'Remove %s as a project member of %s?', $target_name, $project_name); $button = pht('Remove Member'); } return $this->newDialog() ->setTitle($title) ->addHiddenInput('phid', $remove_phid) ->appendParagraph($body) ->addCancelButton($members_uri) ->addSubmitButton($button); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectColumnEditController.php
src/applications/project/controller/PhabricatorProjectColumnEditController.php
<?php final class PhabricatorProjectColumnEditController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $project_id = $request->getURIData('projectID'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->withIDs(array($project_id)) ->needImages(true) ->executeOne(); if (!$project) { return new Aphront404Response(); } $this->setProject($project); $is_new = ($id ? false : true); if (!$is_new) { $column = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$column) { return new Aphront404Response(); } } else { $column = PhabricatorProjectColumn::initializeNewColumn($viewer); } $e_name = null; $e_limit = null; $v_limit = $column->getPointLimit(); $v_name = $column->getName(); $validation_exception = null; $view_uri = $project->getWorkboardURI(); if ($request->isFormPost()) { $v_name = $request->getStr('name'); $v_limit = $request->getStr('limit'); if ($is_new) { $column->setProjectPHID($project->getPHID()); $column->attachProject($project); $columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withProjectPHIDs(array($project->getPHID())) ->execute(); $new_sequence = 1; if ($columns) { $values = mpull($columns, 'getSequence'); $new_sequence = max($values) + 1; } $column->setSequence($new_sequence); } $xactions = array(); $type_name = PhabricatorProjectColumnNameTransaction::TRANSACTIONTYPE; $type_limit = PhabricatorProjectColumnLimitTransaction::TRANSACTIONTYPE; if (!$column->getProxy()) { $xactions[] = id(new PhabricatorProjectColumnTransaction()) ->setTransactionType($type_name) ->setNewValue($v_name); } $xactions[] = id(new PhabricatorProjectColumnTransaction()) ->setTransactionType($type_limit) ->setNewValue($v_limit); try { $editor = id(new PhabricatorProjectColumnTransactionEditor()) ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request) ->applyTransactions($column, $xactions); return id(new AphrontRedirectResponse())->setURI($view_uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $e_name = $ex->getShortMessage($type_name); $e_limit = $ex->getShortMessage($type_limit); $validation_exception = $ex; } } $form = id(new AphrontFormView()) ->setUser($request->getUser()); if (!$column->getProxy()) { $form->appendChild( id(new AphrontFormTextControl()) ->setValue($v_name) ->setLabel(pht('Name')) ->setName('name') ->setError($e_name)); } $form->appendChild( id(new AphrontFormTextControl()) ->setValue($v_limit) ->setLabel(pht('Point Limit')) ->setName('limit') ->setError($e_limit) ->setCaption( pht('Maximum number of points of tasks allowed in the column.'))); if ($is_new) { $title = pht('Create Column'); $submit = pht('Create Column'); } else { $title = pht('Edit %s', $column->getDisplayName()); $submit = pht('Save Column'); } return $this->newDialog() ->setWidth(AphrontDialogView::WIDTH_FORM) ->setTitle($title) ->appendForm($form) ->setValidationException($validation_exception) ->addCancelButton($view_uri) ->addSubmitButton($submit); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectBoardDisableController.php
src/applications/project/controller/PhabricatorProjectBoardDisableController.php
<?php final class PhabricatorProjectBoardDisableController extends PhabricatorProjectBoardController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getUser(); $project_id = $request->getURIData('projectID'); $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->withIDs(array($project_id)) ->executeOne(); if (!$project) { return new Aphront404Response(); } if (!$project->getHasWorkboard()) { return new Aphront404Response(); } $this->setProject($project); $id = $project->getID(); $board_uri = $this->getApplicationURI("board/{$id}/"); if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE) ->setNewValue(0); id(new PhabricatorProjectTransactionEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($project, $xactions); return id(new AphrontRedirectResponse()) ->setURI($board_uri); } return $this->newDialog() ->setTitle(pht('Disable Workboard')) ->appendParagraph( pht( 'Disabling a workboard hides the board. Objects on the board '. 'will no longer be annotated with column names in other '. 'applications. You can restore the workboard later.')) ->addCancelButton($board_uri) ->addSubmitButton(pht('Disable Workboard')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/PhabricatorProjectSubprojectWarningController.php
src/applications/project/controller/PhabricatorProjectSubprojectWarningController.php
<?php final class PhabricatorProjectSubprojectWarningController extends PhabricatorProjectController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadProject(); if ($response) { return $response; } $project = $this->getProject(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); if (!$can_edit) { return new Aphront404Response(); } $id = $project->getID(); $cancel_uri = "/project/subprojects/{$id}/"; $done_uri = "/project/edit/?parent={$id}"; if ($request->isFormPost()) { return id(new AphrontRedirectResponse()) ->setURI($done_uri); } $doc_href = PhabricatorEnv::getDoclink('Projects User Guide'); $conversion_help = pht( "Creating a project's first subproject **moves all ". "members** to become members of the subproject instead.". "\n\n". "See [[ %s | Projects User Guide ]] in the documentation for details. ". "This process can not be undone.", $doc_href); return $this->newDialog() ->setTitle(pht('Convert to Parent Project')) ->appendChild(new PHUIRemarkupView($viewer, $conversion_help)) ->addCancelButton($cancel_uri) ->addSubmitButton(pht('Convert Project')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/trigger/PhabricatorProjectTriggerController.php
src/applications/project/controller/trigger/PhabricatorProjectTriggerController.php
<?php abstract class PhabricatorProjectTriggerController extends PhabricatorProjectController { protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); $crumbs->addTextCrumb( pht('Triggers'), $this->getApplicationURI('trigger/')); return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/trigger/PhabricatorProjectTriggerViewController.php
src/applications/project/controller/trigger/PhabricatorProjectTriggerViewController.php
<?php final class PhabricatorProjectTriggerViewController extends PhabricatorProjectTriggerController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $request = $this->getRequest(); $viewer = $request->getViewer(); $id = $request->getURIData('id'); $trigger = id(new PhabricatorProjectTriggerQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$trigger) { return new Aphront404Response(); } $trigger->setViewer($viewer); $rules_view = $this->newRulesView($trigger); $columns_view = $this->newColumnsView($trigger); $title = $trigger->getObjectName(); $header = id(new PHUIHeaderView()) ->setHeader($trigger->getDisplayName()); $timeline = $this->buildTransactionTimeline( $trigger, new PhabricatorProjectTriggerTransactionQuery()); $timeline->setShouldTerminate(true); $curtain = $this->newCurtain($trigger); $column_view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->setMainColumn( array( $rules_view, $columns_view, $timeline, )); $crumbs = $this->buildApplicationCrumbs() ->addTextCrumb($trigger->getObjectName()) ->setBorder(true); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($column_view); } private function newColumnsView(PhabricatorProjectTrigger $trigger) { $viewer = $this->getViewer(); // NOTE: When showing columns which use this trigger, we want to represent // all columns the trigger is used by: even columns the user can't see. // If we hide columns the viewer can't see, they might think that the // trigger isn't widely used and is safe to edit, when it may actually // be in use on workboards they don't have access to. // Query the columns with the omnipotent viewer first, then pull out their // PHIDs and throw the actual objects away. Re-query with the real viewer // so we load only the columns they can actually see, but have a list of // all the impacted column PHIDs. // (We're also exposing the status of columns the user might not be able // to see. This technically violates policy, but the trigger usage table // hints at it anyway and it seems unlikely to ever have any security // impact, but is useful in assessing whether a trigger is really in use // or not.) $omnipotent_viewer = PhabricatorUser::getOmnipotentUser(); $all_columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($omnipotent_viewer) ->withTriggerPHIDs(array($trigger->getPHID())) ->execute(); $column_map = mpull($all_columns, 'getStatus', 'getPHID'); if ($column_map) { $visible_columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withPHIDs(array_keys($column_map)) ->execute(); $visible_columns = mpull($visible_columns, null, 'getPHID'); } else { $visible_columns = array(); } $rows = array(); foreach ($column_map as $column_phid => $column_status) { $column = idx($visible_columns, $column_phid); if ($column) { $project = $column->getProject(); $project_name = phutil_tag( 'a', array( 'href' => $project->getURI(), ), $project->getDisplayName()); $column_name = phutil_tag( 'a', array( 'href' => $column->getWorkboardURI(), ), $column->getDisplayName()); } else { $project_name = null; $column_name = phutil_tag('em', array(), pht('Restricted Column')); } if ($column_status == PhabricatorProjectColumn::STATUS_ACTIVE) { $status_icon = id(new PHUIIconView()) ->setIcon('fa-columns', 'blue') ->setTooltip(pht('Active Column')); } else { $status_icon = id(new PHUIIconView()) ->setIcon('fa-eye-slash', 'grey') ->setTooltip(pht('Hidden Column')); } $rows[] = array( $status_icon, $project_name, $column_name, ); } $table_view = id(new AphrontTableView($rows)) ->setNoDataString(pht('This trigger is not used by any columns.')) ->setHeaders( array( null, pht('Project'), pht('Column'), )) ->setColumnClasses( array( null, null, 'wide pri', )); $header_view = id(new PHUIHeaderView()) ->setHeader(pht('Used by Columns')); return id(new PHUIObjectBoxView()) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setHeader($header_view) ->setTable($table_view); } private function newRulesView(PhabricatorProjectTrigger $trigger) { $viewer = $this->getViewer(); $rules = $trigger->getTriggerRules(); $rows = array(); foreach ($rules as $rule) { $value = $rule->getRecord()->getValue(); $rows[] = array( $rule->getRuleViewIcon($value), $rule->getRuleViewLabel(), $rule->getRuleViewDescription($value), ); } $table_view = id(new AphrontTableView($rows)) ->setNoDataString(pht('This trigger has no rules.')) ->setHeaders( array( null, pht('Rule'), pht('Action'), )) ->setColumnClasses( array( null, 'pri', 'wide', )); $header_view = id(new PHUIHeaderView()) ->setHeader(pht('Trigger Rules')) ->setSubheader( pht( 'When a card is dropped into a column that uses this trigger, '. 'these actions will be taken.')); return id(new PHUIObjectBoxView()) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setHeader($header_view) ->setTable($table_view); } private function newCurtain(PhabricatorProjectTrigger $trigger) { $viewer = $this->getViewer(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $trigger, PhabricatorPolicyCapability::CAN_EDIT); $curtain = $this->newCurtainView($trigger); $edit_uri = $this->getApplicationURI( urisprintf( 'trigger/edit/%d/', $trigger->getID())); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Trigger')) ->setIcon('fa-pencil') ->setHref($edit_uri) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); return $curtain; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/trigger/PhabricatorProjectTriggerListController.php
src/applications/project/controller/trigger/PhabricatorProjectTriggerListController.php
<?php final class PhabricatorProjectTriggerListController extends PhabricatorProjectTriggerController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { return id(new PhabricatorProjectTriggerSearchEngine()) ->setController($this) ->buildResponse(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/controller/trigger/PhabricatorProjectTriggerEditController.php
src/applications/project/controller/trigger/PhabricatorProjectTriggerEditController.php
<?php final class PhabricatorProjectTriggerEditController extends PhabricatorProjectTriggerController { public function handleRequest(AphrontRequest $request) { $request = $this->getRequest(); $viewer = $request->getViewer(); $id = $request->getURIData('id'); if ($id) { $trigger = id(new PhabricatorProjectTriggerQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$trigger) { return new Aphront404Response(); } } else { $trigger = PhabricatorProjectTrigger::initializeNewTrigger(); } $trigger->setViewer($viewer); $column_phid = $request->getStr('columnPHID'); if ($column_phid) { $column = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withPHIDs(array($column_phid)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$column) { return new Aphront404Response(); } $board_uri = $column->getWorkboardURI(); } else { $column = null; $board_uri = null; } if ($board_uri) { $cancel_uri = $board_uri; } else if ($trigger->getID()) { $cancel_uri = $trigger->getURI(); } else { $cancel_uri = $this->getApplicationURI('trigger/'); } $v_name = $trigger->getName(); $v_edit = $trigger->getEditPolicy(); $v_rules = $trigger->getTriggerRules(); $e_name = null; $e_edit = null; $validation_exception = null; if ($request->isFormPost()) { try { $v_name = $request->getStr('name'); $v_edit = $request->getStr('editPolicy'); // Read the JSON rules from the request and convert them back into // "TriggerRule" objects so we can render the correct form state // if the user is modifying the rules $raw_rules = $request->getStr('rules'); $raw_rules = phutil_json_decode($raw_rules); $copy = clone $trigger; $copy->setRuleset($raw_rules); $v_rules = $copy->getTriggerRules(); $xactions = array(); if (!$trigger->getID()) { $xactions[] = $trigger->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorTransactions::TYPE_CREATE) ->setNewValue(true); } $xactions[] = $trigger->getApplicationTransactionTemplate() ->setTransactionType( PhabricatorProjectTriggerNameTransaction::TRANSACTIONTYPE) ->setNewValue($v_name); $xactions[] = $trigger->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) ->setNewValue($v_edit); $xactions[] = $trigger->getApplicationTransactionTemplate() ->setTransactionType( PhabricatorProjectTriggerRulesetTransaction::TRANSACTIONTYPE) ->setNewValue($raw_rules); $editor = $trigger->getApplicationTransactionEditor() ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true); $editor->applyTransactions($trigger, $xactions); $next_uri = $trigger->getURI(); if ($column) { $column_xactions = array(); $column_xactions[] = $column->getApplicationTransactionTemplate() ->setTransactionType( PhabricatorProjectColumnTriggerTransaction::TRANSACTIONTYPE) ->setNewValue($trigger->getPHID()); $column_editor = $column->getApplicationTransactionEditor() ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true); $column_editor->applyTransactions($column, $column_xactions); $next_uri = $column->getWorkboardURI(); } return id(new AphrontRedirectResponse())->setURI($next_uri); } catch (PhabricatorApplicationTransactionValidationException $ex) { $validation_exception = $ex; $e_name = $ex->getShortMessage( PhabricatorProjectTriggerNameTransaction::TRANSACTIONTYPE); $e_edit = $ex->getShortMessage( PhabricatorTransactions::TYPE_EDIT_POLICY); $trigger->setEditPolicy($v_edit); } } if ($trigger->getID()) { $title = $trigger->getObjectName(); $submit = pht('Save Trigger'); $header = pht('Edit Trigger: %s', $trigger->getObjectName()); } else { $title = pht('New Trigger'); $submit = pht('Create Trigger'); $header = pht('New Trigger'); } $form_id = celerity_generate_unique_node_id(); $table_id = celerity_generate_unique_node_id(); $create_id = celerity_generate_unique_node_id(); $input_id = celerity_generate_unique_node_id(); $form = id(new AphrontFormView()) ->setViewer($viewer) ->setID($form_id); if ($column) { $form->addHiddenInput('columnPHID', $column->getPHID()); } $form->appendControl( id(new AphrontFormTextControl()) ->setLabel(pht('Name')) ->setName('name') ->setValue($v_name) ->setError($e_name) ->setPlaceholder($trigger->getDefaultName())); $policies = id(new PhabricatorPolicyQuery()) ->setViewer($viewer) ->setObject($trigger) ->execute(); $form->appendControl( id(new AphrontFormPolicyControl()) ->setName('editPolicy') ->setPolicyObject($trigger) ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) ->setPolicies($policies) ->setError($e_edit)); $form->appendChild( phutil_tag( 'input', array( 'type' => 'hidden', 'name' => 'rules', 'id' => $input_id, ))); $form->appendChild( id(new PHUIFormInsetView()) ->setTitle(pht('Rules')) ->setDescription( pht( 'When a card is dropped into a column which uses this trigger:')) ->setRightButton( javelin_tag( 'a', array( 'href' => '#', 'class' => 'button button-green', 'id' => $create_id, 'mustcapture' => true, ), pht('New Rule'))) ->setContent( javelin_tag( 'table', array( 'id' => $table_id, 'class' => 'trigger-rules-table', )))); $this->setupEditorBehavior( $trigger, $v_rules, $form_id, $table_id, $create_id, $input_id); $form->appendControl( id(new AphrontFormSubmitControl()) ->setValue($submit) ->addCancelButton($cancel_uri)); $header = id(new PHUIHeaderView()) ->setHeader($header); $box_view = id(new PHUIObjectBoxView()) ->setHeader($header) ->setValidationException($validation_exception) ->appendChild($form); $column_view = id(new PHUITwoColumnView()) ->setFooter($box_view); $crumbs = $this->buildApplicationCrumbs() ->setBorder(true); if ($column) { $crumbs->addTextCrumb( pht( '%s: %s', $column->getProject()->getDisplayName(), $column->getName()), $board_uri); } $crumbs->addTextCrumb($title); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($column_view); } private function setupEditorBehavior( PhabricatorProjectTrigger $trigger, array $rule_list, $form_id, $table_id, $create_id, $input_id) { $rule_list = mpull($rule_list, 'toDictionary'); $rule_list = array_values($rule_list); $type_list = PhabricatorProjectTriggerRule::getAllTriggerRules(); foreach ($type_list as $rule) { $rule->setViewer($this->getViewer()); } $type_list = mpull($type_list, 'newTemplate'); $type_list = array_values($type_list); require_celerity_resource('project-triggers-css'); Javelin::initBehavior( 'trigger-rule-editor', array( 'formNodeID' => $form_id, 'tableNodeID' => $table_id, 'createNodeID' => $create_id, 'inputNodeID' => $input_id, 'rules' => $rule_list, 'types' => $type_list, )); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php
<?php final class PhabricatorProjectHovercardEngineExtension extends PhabricatorHovercardEngineExtension { const EXTENSIONKEY = 'project.card'; public function isExtensionEnabled() { return true; } public function getExtensionName() { return pht('Project Card'); } public function canRenderObjectHovercard($object) { return ($object instanceof PhabricatorProject); } public function willRenderHovercards(array $objects) { $viewer = $this->getViewer(); $phids = mpull($objects, 'getPHID'); $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withPHIDs($phids) ->needImages(true) ->execute(); $projects = mpull($projects, null, 'getPHID'); return array( 'projects' => $projects, ); } public function renderHovercard( PHUIHovercardView $hovercard, PhabricatorObjectHandle $handle, $object, $data) { $viewer = $this->getViewer(); $project = idx($data['projects'], $object->getPHID()); if (!$project) { return; } $project_card = id(new PhabricatorProjectCardView()) ->setProject($project) ->setViewer($viewer); $hovercard->appendChild($project_card); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php
<?php final class PhabricatorProjectsFulltextEngineExtension extends PhabricatorFulltextEngineExtension { const EXTENSIONKEY = 'projects'; public function getExtensionName() { return pht('Projects'); } public function shouldEnrichFulltextObject($object) { return ($object instanceof PhabricatorProjectInterface); } public function enrichFulltextObject( $object, PhabricatorSearchAbstractDocument $document) { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if (!$project_phids) { return; } foreach ($project_phids as $project_phid) { $document->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $project_phid, PhabricatorProjectProjectPHIDType::TYPECONST, $document->getDocumentModified()); // Bogus timestamp. } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php
<?php final class PhabricatorProjectsSearchEngineExtension extends PhabricatorSearchEngineExtension { const EXTENSIONKEY = 'projects'; public function isExtensionEnabled() { return PhabricatorApplication::isClassInstalled( 'PhabricatorProjectApplication'); } public function getExtensionName() { return pht('Support for Projects'); } public function getExtensionOrder() { return 3000; } public function supportsObject($object) { return ($object instanceof PhabricatorProjectInterface); } public function applyConstraintsToQuery( $object, $query, PhabricatorSavedQuery $saved, array $map) { if (!empty($map['projectPHIDs'])) { $query->withEdgeLogicConstraints( PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $map['projectPHIDs']); } } public function getSearchFields($object) { $fields = array(); $fields[] = id(new PhabricatorProjectSearchField()) ->setKey('projectPHIDs') ->setConduitKey('projects') ->setAliases(array('project', 'projects', 'tag', 'tags')) ->setLabel(pht('Tags')) ->setDescription( pht('Search for objects tagged with given projects.')); return $fields; } public function getSearchAttachments($object) { return array( id(new PhabricatorProjectsSearchEngineAttachment()) ->setAttachmentKey('projects'), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php
src/applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php
<?php final class PhabricatorProjectsSearchEngineAttachment extends PhabricatorSearchEngineAttachment { public function getAttachmentName() { return pht('Projects'); } public function getAttachmentDescription() { return pht('Get information about projects.'); } public function loadAttachmentData(array $objects, $spec) { $object_phids = mpull($objects, 'getPHID'); $projects_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($object_phids) ->withEdgeTypes( array( PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, )); $projects_query->execute(); return array( 'projects.query' => $projects_query, ); } public function getAttachmentForObject($object, $data, $spec) { $projects_query = $data['projects.query']; $object_phid = $object->getPHID(); $project_phids = $projects_query->getDestinationPHIDs( array($object_phid), array(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)); return array( 'projectPHIDs' => array_values($project_phids), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php
src/applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php
<?php final class PhabricatorProjectsMembersSearchEngineAttachment extends PhabricatorSearchEngineAttachment { public function getAttachmentName() { return pht('Project Members'); } public function getAttachmentDescription() { return pht('Get the member list for the project.'); } public function willLoadAttachmentData($query, $spec) { $query->needMembers(true); } public function getAttachmentForObject($object, $data, $spec) { $members = array(); foreach ($object->getMemberPHIDs() as $member_phid) { $members[] = array( 'phid' => $member_phid, ); } return array( 'members' => $members, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectTriggerUsageIndexEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectTriggerUsageIndexEngineExtension.php
<?php final class PhabricatorProjectTriggerUsageIndexEngineExtension extends PhabricatorIndexEngineExtension { const EXTENSIONKEY = 'trigger.usage'; public function getExtensionName() { return pht('Trigger Usage'); } public function shouldIndexObject($object) { if (!($object instanceof PhabricatorProjectTrigger)) { return false; } return true; } public function indexObject( PhabricatorIndexEngine $engine, $object) { $usage_table = new PhabricatorProjectTriggerUsage(); $column_table = new PhabricatorProjectColumn(); $conn_w = $object->establishConnection('w'); $active_statuses = array( PhabricatorProjectColumn::STATUS_ACTIVE, ); // Select summary information to populate the usage index. When picking // an "examplePHID", we try to pick an active column. $row = queryfx_one( $conn_w, 'SELECT phid, COUNT(*) N, SUM(IF(status IN (%Ls), 1, 0)) M FROM %R WHERE triggerPHID = %s ORDER BY IF(status IN (%Ls), 1, 0) DESC, id ASC', $active_statuses, $column_table, $object->getPHID(), $active_statuses); if ($row) { $example_phid = $row['phid']; $column_count = $row['N']; $active_count = $row['M']; } else { $example_phid = null; $column_count = 0; $active_count = 0; } queryfx( $conn_w, 'INSERT INTO %R (triggerPHID, examplePHID, columnCount, activeColumnCount) VALUES (%s, %ns, %d, %d) ON DUPLICATE KEY UPDATE examplePHID = VALUES(examplePHID), columnCount = VALUES(columnCount), activeColumnCount = VALUES(activeColumnCount)', $usage_table, $object->getPHID(), $example_phid, $column_count, $active_count); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php
<?php final class PhabricatorProjectsMailEngineExtension extends PhabricatorMailEngineExtension { const EXTENSIONKEY = 'projects'; public function supportsObject($object) { return ($object instanceof PhabricatorProjectInterface); } public function newMailStampTemplates($object) { return array( id(new PhabricatorPHIDMailStamp()) ->setKey('tag') ->setLabel(pht('Tagged with Project')), ); } public function newMailStamps($object, array $xactions) { $editor = $this->getEditor(); $viewer = $this->getViewer(); $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $this->getMailStamp('tag') ->setValue($project_phids); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/ProjectDatasourceEngineExtension.php
src/applications/project/engineextension/ProjectDatasourceEngineExtension.php
<?php final class ProjectDatasourceEngineExtension extends PhabricatorDatasourceEngineExtension { public function newQuickSearchDatasources() { return array( new PhabricatorProjectDatasource(), ); } public function newJumpURI($query) { $viewer = $this->getViewer(); // Send "p" to Projects. if (preg_match('/^p\z/i', $query)) { return '/diffusion/'; } // Send "p <string>" to a search for similar projects. $matches = null; if (preg_match('/^p\s+(.+)\z/i', $query, $matches)) { $raw_query = $matches[1]; $engine = id(new PhabricatorProject()) ->newFerretEngine(); $compiler = id(new PhutilSearchQueryCompiler()) ->setEnableFunctions(true); $raw_tokens = $compiler->newTokens($raw_query); $fulltext_tokens = array(); foreach ($raw_tokens as $raw_token) { $fulltext_token = id(new PhabricatorFulltextToken()) ->setToken($raw_token); $fulltext_tokens[] = $fulltext_token; } $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withFerretConstraint($engine, $fulltext_tokens) ->execute(); if (count($projects) == 1) { // Just one match, jump to project. return head($projects)->getURI(); } else { // More than one match, jump to search. return urisprintf( '/project/?order=relevance&query=%s#R', $raw_query); } } return null; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsAncestorsSearchEngineAttachment.php
src/applications/project/engineextension/PhabricatorProjectsAncestorsSearchEngineAttachment.php
<?php final class PhabricatorProjectsAncestorsSearchEngineAttachment extends PhabricatorSearchEngineAttachment { public function getAttachmentName() { return pht('Project Ancestors'); } public function getAttachmentDescription() { return pht('Get the full ancestor list for each project.'); } public function getAttachmentForObject($object, $data, $spec) { $ancestors = $object->getAncestorProjects(); // Order ancestors by depth, ascending. $ancestors = array_reverse($ancestors); $results = array(); foreach ($ancestors as $ancestor) { $results[] = $ancestor->getRefForConduit(); } return array( 'ancestors' => $results, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php
<?php final class PhabricatorProjectsEditEngineExtension extends PhabricatorEditEngineExtension { const EXTENSIONKEY = 'projects.projects'; const EDITKEY_ADD = 'projects.add'; const EDITKEY_SET = 'projects.set'; const EDITKEY_REMOVE = 'projects.remove'; public function getExtensionPriority() { return 500; } public function isExtensionEnabled() { return PhabricatorApplication::isClassInstalled( 'PhabricatorProjectApplication'); } public function getExtensionName() { return pht('Projects'); } public function supportsObject( PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { return ($object instanceof PhabricatorProjectInterface); } public function buildCustomEditFields( PhabricatorEditEngine $engine, PhabricatorApplicationTransactionInterface $object) { $edge_type = PhabricatorTransactions::TYPE_EDGE; $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $object_phid = $object->getPHID(); if ($object_phid) { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object_phid, $project_edge_type); $project_phids = array_reverse($project_phids); } else { $project_phids = array(); } $viewer = $engine->getViewer(); $projects_field = id(new PhabricatorProjectsEditField()) ->setKey('projectPHIDs') ->setLabel(pht('Tags')) ->setEditTypeKey('projects') ->setAliases(array('project', 'projects', 'tag', 'tags')) ->setIsCopyable(true) ->setUseEdgeTransactions(true) ->setCommentActionLabel(pht('Change Project Tags')) ->setCommentActionOrder(8000) ->setDescription(pht('Select project tags for the object.')) ->setTransactionType($edge_type) ->setMetadataValue('edge:type', $project_edge_type) ->setValue($project_phids) ->setViewer($viewer); $projects_datasource = id(new PhabricatorProjectDatasource()) ->setViewer($viewer); $edit_add = $projects_field->getConduitEditType(self::EDITKEY_ADD) ->setConduitDescription(pht('Add project tags.')); $edit_set = $projects_field->getConduitEditType(self::EDITKEY_SET) ->setConduitDescription( pht('Set project tags, overwriting current value.')); $edit_rem = $projects_field->getConduitEditType(self::EDITKEY_REMOVE) ->setConduitDescription(pht('Remove project tags.')); $projects_field->getBulkEditType(self::EDITKEY_ADD) ->setBulkEditLabel(pht('Add project tags')) ->setDatasource($projects_datasource); $projects_field->getBulkEditType(self::EDITKEY_SET) ->setBulkEditLabel(pht('Set project tags to')) ->setDatasource($projects_datasource); $projects_field->getBulkEditType(self::EDITKEY_REMOVE) ->setBulkEditLabel(pht('Remove project tags')) ->setDatasource($projects_datasource); return array( $projects_field, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsCurtainExtension.php
src/applications/project/engineextension/PhabricatorProjectsCurtainExtension.php
<?php final class PhabricatorProjectsCurtainExtension extends PHUICurtainExtension { const EXTENSIONKEY = 'projects.projects'; public function shouldEnableForObject($object) { return ($object instanceof PhabricatorProjectInterface); } public function getExtensionApplication() { return new PhabricatorProjectApplication(); } public function buildCurtainPanel($object) { $viewer = $this->getViewer(); $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $has_projects = (bool)$project_phids; $project_phids = array_reverse($project_phids); $handles = $viewer->loadHandles($project_phids); // If this object can appear on boards, build the workboard annotations. // Some day, this might be a generic interface. For now, only tasks can // appear on boards. $can_appear_on_boards = ($object instanceof ManiphestTask); $annotations = array(); if ($has_projects && $can_appear_on_boards) { $engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setBoardPHIDs($project_phids) ->setObjectPHIDs(array($object->getPHID())) ->executeLayout(); // TDOO: Generalize this UI and move it out of Maniphest. require_celerity_resource('maniphest-task-summary-css'); foreach ($project_phids as $project_phid) { $handle = $handles[$project_phid]; $columns = $engine->getObjectColumns( $project_phid, $object->getPHID()); $annotation = array(); foreach ($columns as $column) { $project_id = $column->getProject()->getID(); $column_name = pht('(%s)', $column->getDisplayName()); $column_link = phutil_tag( 'a', array( 'href' => $column->getWorkboardURI(), 'class' => 'maniphest-board-link', ), $column_name); $annotation[] = $column_link; } if ($annotation) { $annotations[$project_phid] = array( ' ', phutil_implode_html(', ', $annotation), ); } } } if ($has_projects) { $list = id(new PHUIHandleTagListView()) ->setHandles($handles) ->setAnnotations($annotations) ->setShowHovercards(true); } else { $list = phutil_tag('em', array(), pht('None')); } return $this->newPanel() ->setHeaderText(pht('Tags')) ->setOrder(10000) ->appendChild($list); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php
src/applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php
<?php final class PhabricatorProjectsMembershipIndexEngineExtension extends PhabricatorIndexEngineExtension { const EXTENSIONKEY = 'project.members'; public function getExtensionName() { return pht('Project Members'); } public function shouldIndexObject($object) { if (!($object instanceof PhabricatorProject)) { return false; } return true; } public function indexObject( PhabricatorIndexEngine $engine, $object) { $this->rematerialize($object); } public function rematerialize(PhabricatorProject $project) { $materialize = $project->getAncestorProjects(); array_unshift($materialize, $project); foreach ($materialize as $project) { $this->materializeProject($project); } } private function materializeProject(PhabricatorProject $project) { $material_type = PhabricatorProjectMaterializedMemberEdgeType::EDGECONST; $member_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $project_phid = $project->getPHID(); if ($project->isMilestone()) { $source_phids = array($project->getParentProjectPHID()); $has_subprojects = false; } else { $descendants = id(new PhabricatorProjectQuery()) ->setViewer($this->getViewer()) ->withAncestorProjectPHIDs(array($project->getPHID())) ->withIsMilestone(false) ->withHasSubprojects(false) ->execute(); $descendant_phids = mpull($descendants, 'getPHID'); if ($descendant_phids) { $source_phids = $descendant_phids; $has_subprojects = true; } else { $source_phids = array($project->getPHID()); $has_subprojects = false; } } $conn_w = $project->establishConnection('w'); $any_milestone = queryfx_one( $conn_w, 'SELECT id FROM %T WHERE parentProjectPHID = %s AND milestoneNumber IS NOT NULL LIMIT 1', $project->getTableName(), $project_phid); $has_milestones = (bool)$any_milestone; $project->openTransaction(); // Copy current member edges to create new materialized edges. // See T13596. Avoid executing this as an "INSERT ... SELECT" to reduce // the required level of table locking. Since we're decomposing it into // "SELECT" + "INSERT" anyway, we can also compute exactly which rows // need to be modified. $have_rows = queryfx_all( $conn_w, 'SELECT dst FROM %T WHERE src = %s AND type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $project_phid, $material_type); $want_rows = queryfx_all( $conn_w, 'SELECT dst, dateCreated, seq FROM %T WHERE src IN (%Ls) AND type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $source_phids, $member_type); $have_phids = ipull($have_rows, 'dst', 'dst'); $want_phids = ipull($want_rows, null, 'dst'); $rem_phids = array_diff_key($have_phids, $want_phids); $rem_phids = array_keys($rem_phids); $add_phids = array_diff_key($want_phids, $have_phids); $add_phids = array_keys($add_phids); $rem_sql = array(); foreach ($rem_phids as $rem_phid) { $rem_sql[] = qsprintf( $conn_w, '%s', $rem_phid); } $add_sql = array(); foreach ($add_phids as $add_phid) { $add_row = $want_phids[$add_phid]; $add_sql[] = qsprintf( $conn_w, '(%s, %d, %s, %d, %d)', $project_phid, $material_type, $add_row['dst'], $add_row['dateCreated'], $add_row['seq']); } // Remove materialized members who are no longer project members. if ($rem_sql) { foreach (PhabricatorLiskDAO::chunkSQL($rem_sql) as $sql_chunk) { queryfx( $conn_w, 'DELETE FROM %T WHERE src = %s AND type = %s AND dst IN (%LQ)', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $project_phid, $material_type, $sql_chunk); } } // Add project members who are not yet materialized members. if ($add_sql) { foreach (PhabricatorLiskDAO::chunkSQL($add_sql) as $sql_chunk) { queryfx( $conn_w, 'INSERT IGNORE INTO %T (src, type, dst, dateCreated, seq) VALUES %LQ', PhabricatorEdgeConfig::TABLE_NAME_EDGE, $sql_chunk); } } // Update the hasSubprojects flag. queryfx( $conn_w, 'UPDATE %T SET hasSubprojects = %d WHERE id = %d', $project->getTableName(), (int)$has_subprojects, $project->getID()); // Update the hasMilestones flag. queryfx( $conn_w, 'UPDATE %T SET hasMilestones = %d WHERE id = %d', $project->getTableName(), (int)$has_milestones, $project->getID()); $project->saveTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php
src/applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php
<?php final class PhabricatorProjectsWatchersSearchEngineAttachment extends PhabricatorSearchEngineAttachment { public function getAttachmentName() { return pht('Project Watchers'); } public function getAttachmentDescription() { return pht('Get the watcher list for the project.'); } public function willLoadAttachmentData($query, $spec) { $query->needWatchers(true); } public function getAttachmentForObject($object, $data, $spec) { $watchers = array(); foreach ($object->getWatcherPHIDs() as $watcher_phid) { $watchers[] = array( 'phid' => $watcher_phid, ); } return array( 'watchers' => $watchers, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php
src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php
<?php final class PhabricatorBoardColumnsSearchEngineAttachment extends PhabricatorSearchEngineAttachment { public function getAttachmentName() { return pht('Workboard Columns'); } public function getAttachmentDescription() { return pht('Get the workboard columns where an object appears.'); } public function loadAttachmentData(array $objects, $spec) { $viewer = $this->getViewer(); $objects = mpull($objects, null, 'getPHID'); $object_phids = array_keys($objects); $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($object_phids) ->withEdgeTypes( array( PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, )); $edge_query->execute(); $project_phids = $edge_query->getDestinationPHIDs(); $engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setBoardPHIDs($project_phids) ->setObjectPHIDs($object_phids) ->executeLayout(); $results = array(); foreach ($objects as $phid => $object) { $board_phids = $edge_query->getDestinationPHIDs(array($phid)); $boards = array(); foreach ($board_phids as $board_phid) { $columns = array(); foreach ($engine->getObjectColumns($board_phid, $phid) as $column) { if ($column->getProxyPHID()) { // When an object is in a proxy column, don't return it on this // attachment. This information can be reconstructed from other // queries, is something of an implementation detail, and seems // unlikely to be interesting to API consumers. continue 2; } $columns[] = $column->getRefForConduit(); } // If a project has no workboard, the object won't appear on any // columns. Just omit it from the result set. if (!$columns) { continue; } $boards[$board_phid] = array( 'columns' => $columns, ); } $results[$phid] = $boards; } return $results; } public function getAttachmentForObject($object, $data, $spec) { $boards = idx($data, $object->getPHID(), array()); return array( 'boards' => $boards, ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProject.php
src/applications/project/storage/PhabricatorProject.php
<?php final class PhabricatorProject extends PhabricatorProjectDAO implements PhabricatorApplicationTransactionInterface, PhabricatorFlaggableInterface, PhabricatorPolicyInterface, PhabricatorExtendedPolicyInterface, PhabricatorCustomFieldInterface, PhabricatorDestructibleInterface, PhabricatorFulltextInterface, PhabricatorFerretInterface, PhabricatorConduitResultInterface, PhabricatorColumnProxyInterface, PhabricatorSpacesInterface, PhabricatorEditEngineSubtypeInterface, PhabricatorWorkboardInterface { protected $name; protected $status = PhabricatorProjectStatus::STATUS_ACTIVE; protected $authorPHID; protected $primarySlug; protected $profileImagePHID; protected $icon; protected $color; protected $mailKey; protected $viewPolicy; protected $editPolicy; protected $joinPolicy; protected $isMembershipLocked; protected $parentProjectPHID; protected $hasWorkboard; protected $hasMilestones; protected $hasSubprojects; protected $milestoneNumber; protected $projectPath; protected $projectDepth; protected $projectPathKey; protected $properties = array(); protected $spacePHID; protected $subtype; private $memberPHIDs = self::ATTACHABLE; private $watcherPHIDs = self::ATTACHABLE; private $sparseWatchers = self::ATTACHABLE; private $sparseMembers = self::ATTACHABLE; private $customFields = self::ATTACHABLE; private $profileImageFile = self::ATTACHABLE; private $slugs = self::ATTACHABLE; private $parentProject = self::ATTACHABLE; const TABLE_DATASOURCE_TOKEN = 'project_datasourcetoken'; const ITEM_PICTURE = 'project.picture'; const ITEM_PROFILE = 'project.profile'; const ITEM_POINTS = 'project.points'; const ITEM_WORKBOARD = 'project.workboard'; const ITEM_REPORTS = 'project.reports'; const ITEM_MEMBERS = 'project.members'; const ITEM_MANAGE = 'project.manage'; const ITEM_MILESTONES = 'project.milestones'; const ITEM_SUBPROJECTS = 'project.subprojects'; public static function initializeNewProject( PhabricatorUser $actor, PhabricatorProject $parent = null) { $app = id(new PhabricatorApplicationQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withClasses(array('PhabricatorProjectApplication')) ->executeOne(); $view_policy = $app->getPolicy( ProjectDefaultViewCapability::CAPABILITY); $edit_policy = $app->getPolicy( ProjectDefaultEditCapability::CAPABILITY); $join_policy = $app->getPolicy( ProjectDefaultJoinCapability::CAPABILITY); // If this is the child of some other project, default the Space to the // Space of the parent. if ($parent) { $space_phid = $parent->getSpacePHID(); } else { $space_phid = $actor->getDefaultSpacePHID(); } $default_icon = PhabricatorProjectIconSet::getDefaultIconKey(); $default_color = PhabricatorProjectIconSet::getDefaultColorKey(); return id(new PhabricatorProject()) ->setAuthorPHID($actor->getPHID()) ->setIcon($default_icon) ->setColor($default_color) ->setViewPolicy($view_policy) ->setEditPolicy($edit_policy) ->setJoinPolicy($join_policy) ->setSpacePHID($space_phid) ->setIsMembershipLocked(0) ->attachMemberPHIDs(array()) ->attachSlugs(array()) ->setHasWorkboard(0) ->setHasMilestones(0) ->setHasSubprojects(0) ->setSubtype(PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT) ->attachParentProject($parent); } public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_JOIN, ); } public function getPolicy($capability) { if ($this->isMilestone()) { return $this->getParentProject()->getPolicy($capability); } switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return $this->getViewPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); case PhabricatorPolicyCapability::CAN_JOIN: return $this->getJoinPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { if ($this->isMilestone()) { return $this->getParentProject()->hasAutomaticCapability( $capability, $viewer); } $can_edit = PhabricatorPolicyCapability::CAN_EDIT; switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: if ($this->isUserMember($viewer->getPHID())) { // Project members can always view a project. return true; } break; case PhabricatorPolicyCapability::CAN_EDIT: $parent = $this->getParentProject(); if ($parent) { $can_edit_parent = PhabricatorPolicyFilter::hasCapability( $viewer, $parent, $can_edit); if ($can_edit_parent) { return true; } } break; case PhabricatorPolicyCapability::CAN_JOIN: if (PhabricatorPolicyFilter::hasCapability($viewer, $this, $can_edit)) { // Project editors can always join a project. return true; } break; } return false; } public function describeAutomaticCapability($capability) { // TODO: Clarify the additional rules that parent and subprojects imply. switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return pht('Members of a project can always view it.'); case PhabricatorPolicyCapability::CAN_JOIN: return pht('Users who can edit a project can always join it.'); } return null; } public function getExtendedPolicy($capability, PhabricatorUser $viewer) { $extended = array(); switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: $parent = $this->getParentProject(); if ($parent) { $extended[] = array( $parent, PhabricatorPolicyCapability::CAN_VIEW, ); } break; } return $extended; } public function isUserMember($user_phid) { if ($this->memberPHIDs !== self::ATTACHABLE) { return in_array($user_phid, $this->memberPHIDs); } return $this->assertAttachedKey($this->sparseMembers, $user_phid); } public function setIsUserMember($user_phid, $is_member) { if ($this->sparseMembers === self::ATTACHABLE) { $this->sparseMembers = array(); } $this->sparseMembers[$user_phid] = $is_member; return $this; } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'properties' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'sort128', 'status' => 'text32', 'primarySlug' => 'text128?', 'isMembershipLocked' => 'bool', 'profileImagePHID' => 'phid?', 'icon' => 'text32', 'color' => 'text32', 'mailKey' => 'bytes20', 'joinPolicy' => 'policy', 'parentProjectPHID' => 'phid?', 'hasWorkboard' => 'bool', 'hasMilestones' => 'bool', 'hasSubprojects' => 'bool', 'milestoneNumber' => 'uint32?', 'projectPath' => 'hashpath64', 'projectDepth' => 'uint32', 'projectPathKey' => 'bytes4', 'subtype' => 'text64', ), self::CONFIG_KEY_SCHEMA => array( 'key_icon' => array( 'columns' => array('icon'), ), 'key_color' => array( 'columns' => array('color'), ), 'key_milestone' => array( 'columns' => array('parentProjectPHID', 'milestoneNumber'), 'unique' => true, ), 'key_primaryslug' => array( 'columns' => array('primarySlug'), 'unique' => true, ), 'key_path' => array( 'columns' => array('projectPath', 'projectDepth'), ), 'key_pathkey' => array( 'columns' => array('projectPathKey'), 'unique' => true, ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorProjectProjectPHIDType::TYPECONST); } public function attachMemberPHIDs(array $phids) { $this->memberPHIDs = $phids; return $this; } public function getMemberPHIDs() { return $this->assertAttached($this->memberPHIDs); } public function isArchived() { return ($this->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED); } public function getProfileImageURI() { return $this->getProfileImageFile()->getBestURI(); } public function attachProfileImageFile(PhabricatorFile $file) { $this->profileImageFile = $file; return $this; } public function getProfileImageFile() { return $this->assertAttached($this->profileImageFile); } public function isUserWatcher($user_phid) { if ($this->watcherPHIDs !== self::ATTACHABLE) { return in_array($user_phid, $this->watcherPHIDs); } return $this->assertAttachedKey($this->sparseWatchers, $user_phid); } public function isUserAncestorWatcher($user_phid) { $is_watcher = $this->isUserWatcher($user_phid); if (!$is_watcher) { $parent = $this->getParentProject(); if ($parent) { return $parent->isUserWatcher($user_phid); } } return $is_watcher; } public function getWatchedAncestorPHID($user_phid) { if ($this->isUserWatcher($user_phid)) { return $this->getPHID(); } $parent = $this->getParentProject(); if ($parent) { return $parent->getWatchedAncestorPHID($user_phid); } return null; } public function setIsUserWatcher($user_phid, $is_watcher) { if ($this->sparseWatchers === self::ATTACHABLE) { $this->sparseWatchers = array(); } $this->sparseWatchers[$user_phid] = $is_watcher; return $this; } public function attachWatcherPHIDs(array $phids) { $this->watcherPHIDs = $phids; return $this; } public function getWatcherPHIDs() { return $this->assertAttached($this->watcherPHIDs); } public function getAllAncestorWatcherPHIDs() { $parent = $this->getParentProject(); if ($parent) { $watchers = $parent->getAllAncestorWatcherPHIDs(); } else { $watchers = array(); } foreach ($this->getWatcherPHIDs() as $phid) { $watchers[$phid] = $phid; } return $watchers; } public function attachSlugs(array $slugs) { $this->slugs = $slugs; return $this; } public function getSlugs() { return $this->assertAttached($this->slugs); } public function getColor() { if ($this->isArchived()) { return PHUITagView::COLOR_DISABLED; } return $this->color; } public function getURI() { $id = $this->getID(); return "/project/view/{$id}/"; } public function getProfileURI() { $id = $this->getID(); return "/project/profile/{$id}/"; } public function getWorkboardURI() { return urisprintf('/project/board/%d/', $this->getID()); } public function getReportsURI() { return urisprintf('/project/reports/%d/', $this->getID()); } public function save() { if (!$this->getMailKey()) { $this->setMailKey(Filesystem::readRandomCharacters(20)); } $phid = $this->getPHID(); if ($phid === null || $phid === '') { $this->setPHID($this->generatePHID()); } $path_key = $this->getProjectPathKey(); if ($path_key === null || $path_key === '') { $hash = PhabricatorHash::digestForIndex($this->getPHID()); $hash = substr($hash, 0, 4); $this->setProjectPathKey($hash); } $path = array(); $depth = 0; if ($this->parentProjectPHID) { $parent = $this->getParentProject(); $path[] = $parent->getProjectPath(); $depth = $parent->getProjectDepth() + 1; } $path[] = $this->getProjectPathKey(); $path = implode('', $path); $limit = self::getProjectDepthLimit(); if ($depth >= $limit) { throw new Exception(pht('Project depth is too great.')); } $this->setProjectPath($path); $this->setProjectDepth($depth); $this->openTransaction(); $result = parent::save(); $this->updateDatasourceTokens(); $this->saveTransaction(); return $result; } public static function getProjectDepthLimit() { // This is limited by how many path hashes we can fit in the path // column. return 16; } public function updateDatasourceTokens() { $table = self::TABLE_DATASOURCE_TOKEN; $conn_w = $this->establishConnection('w'); $id = $this->getID(); $slugs = queryfx_all( $conn_w, 'SELECT * FROM %T WHERE projectPHID = %s', id(new PhabricatorProjectSlug())->getTableName(), $this->getPHID()); $all_strings = ipull($slugs, 'slug'); $all_strings[] = $this->getDisplayName(); $all_strings = implode(' ', $all_strings); $tokens = PhabricatorTypeaheadDatasource::tokenizeString($all_strings); $sql = array(); foreach ($tokens as $token) { $sql[] = qsprintf($conn_w, '(%d, %s)', $id, $token); } $this->openTransaction(); queryfx( $conn_w, 'DELETE FROM %T WHERE projectID = %d', $table, $id); foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { queryfx( $conn_w, 'INSERT INTO %T (projectID, token) VALUES %LQ', $table, $chunk); } $this->saveTransaction(); } public function isMilestone() { return ($this->getMilestoneNumber() !== null); } public function getParentProject() { return $this->assertAttached($this->parentProject); } public function attachParentProject(PhabricatorProject $project = null) { $this->parentProject = $project; return $this; } public function getAncestorProjectPaths() { $parts = array(); $path = $this->getProjectPath(); $parent_length = (strlen($path) - 4); for ($ii = $parent_length; $ii > 0; $ii -= 4) { $parts[] = substr($path, 0, $ii); } return $parts; } public function getAncestorProjects() { $ancestors = array(); $cursor = $this->getParentProject(); while ($cursor) { $ancestors[] = $cursor; $cursor = $cursor->getParentProject(); } return $ancestors; } public function supportsEditMembers() { if ($this->isMilestone()) { return false; } if ($this->getHasSubprojects()) { return false; } return true; } public function supportsMilestones() { if ($this->isMilestone()) { return false; } return true; } public function supportsSubprojects() { if ($this->isMilestone()) { return false; } return true; } public function loadNextMilestoneNumber() { $current = queryfx_one( $this->establishConnection('w'), 'SELECT MAX(milestoneNumber) n FROM %T WHERE parentProjectPHID = %s', $this->getTableName(), $this->getPHID()); if (!$current) { $number = 1; } else { $number = (int)$current['n'] + 1; } return $number; } public function getDisplayName() { $name = $this->getName(); // If this is a milestone, show it as "Parent > Sprint 99". if ($this->isMilestone()) { $name = pht( '%s (%s)', $this->getParentProject()->getName(), $name); } return $name; } public function getDisplayIconKey() { if ($this->isMilestone()) { $key = PhabricatorProjectIconSet::getMilestoneIconKey(); } else { $key = $this->getIcon(); } return $key; } public function getDisplayIconIcon() { $key = $this->getDisplayIconKey(); return PhabricatorProjectIconSet::getIconIcon($key); } public function getDisplayIconName() { $key = $this->getDisplayIconKey(); return PhabricatorProjectIconSet::getIconName($key); } public function getDisplayColor() { if ($this->isMilestone()) { return $this->getParentProject()->getColor(); } return $this->getColor(); } public function getDisplayIconComposeIcon() { $icon = $this->getDisplayIconIcon(); return $icon; } public function getDisplayIconComposeColor() { $color = $this->getDisplayColor(); $map = array( 'grey' => 'charcoal', 'checkered' => 'backdrop', ); return idx($map, $color, $color); } public function getProperty($key, $default = null) { return idx($this->properties, $key, $default); } public function setProperty($key, $value) { $this->properties[$key] = $value; return $this; } public function getDefaultWorkboardSort() { return $this->getProperty('workboard.sort.default'); } public function setDefaultWorkboardSort($sort) { return $this->setProperty('workboard.sort.default', $sort); } public function getDefaultWorkboardFilter() { return $this->getProperty('workboard.filter.default'); } public function setDefaultWorkboardFilter($filter) { return $this->setProperty('workboard.filter.default', $filter); } public function getWorkboardBackgroundColor() { return $this->getProperty('workboard.background'); } public function setWorkboardBackgroundColor($color) { return $this->setProperty('workboard.background', $color); } public function getDisplayWorkboardBackgroundColor() { $color = $this->getWorkboardBackgroundColor(); if ($color === null) { $parent = $this->getParentProject(); if ($parent) { return $parent->getDisplayWorkboardBackgroundColor(); } } if ($color === 'none') { $color = null; } return $color; } /* -( PhabricatorCustomFieldInterface )------------------------------------ */ public function getCustomFieldSpecificationForRole($role) { return PhabricatorEnv::getEnvConfig('projects.fields'); } public function getCustomFieldBaseClass() { return 'PhabricatorProjectCustomField'; } public function getCustomFields() { return $this->assertAttached($this->customFields); } public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { $this->customFields = $fields; return $this; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new PhabricatorProjectTransactionEditor(); } public function getApplicationTransactionTemplate() { return new PhabricatorProjectTransaction(); } /* -( PhabricatorSpacesInterface )----------------------------------------- */ public function getSpacePHID() { if ($this->isMilestone()) { return $this->getParentProject()->getSpacePHID(); } return $this->spacePHID; } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->openTransaction(); $this->delete(); $columns = id(new PhabricatorProjectColumn()) ->loadAllWhere('projectPHID = %s', $this->getPHID()); foreach ($columns as $column) { $engine->destroyObject($column); } $slugs = id(new PhabricatorProjectSlug()) ->loadAllWhere('projectPHID = %s', $this->getPHID()); foreach ($slugs as $slug) { $slug->delete(); } $this->saveTransaction(); } /* -( PhabricatorFulltextInterface )--------------------------------------- */ public function newFulltextEngine() { return new PhabricatorProjectFulltextEngine(); } /* -( PhabricatorFerretInterface )--------------------------------------- */ public function newFerretEngine() { return new PhabricatorProjectFerretEngine(); } /* -( PhabricatorConduitResultInterface )---------------------------------- */ public function getFieldSpecificationsForConduit() { return array( id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('name') ->setType('string') ->setDescription(pht('The name of the project.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('slug') ->setType('string') ->setDescription(pht('Primary slug/hashtag.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('subtype') ->setType('string') ->setDescription(pht('Subtype of the project.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('milestone') ->setType('int?') ->setDescription(pht('For milestones, milestone sequence number.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('parent') ->setType('map<string, wild>?') ->setDescription( pht( 'For subprojects and milestones, a brief description of the '. 'parent project.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('depth') ->setType('int') ->setDescription( pht( 'For subprojects and milestones, depth of this project in the '. 'tree. Root projects have depth 0.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('icon') ->setType('map<string, wild>') ->setDescription(pht('Information about the project icon.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('color') ->setType('map<string, wild>') ->setDescription(pht('Information about the project color.')), ); } public function getFieldValuesForConduit() { $color_key = $this->getColor(); $color_name = PhabricatorProjectIconSet::getColorName($color_key); if ($this->isMilestone()) { $milestone = (int)$this->getMilestoneNumber(); } else { $milestone = null; } $parent = $this->getParentProject(); if ($parent) { $parent_ref = $parent->getRefForConduit(); } else { $parent_ref = null; } return array( 'name' => $this->getName(), 'slug' => $this->getPrimarySlug(), 'subtype' => $this->getSubtype(), 'milestone' => $milestone, 'depth' => (int)$this->getProjectDepth(), 'parent' => $parent_ref, 'icon' => array( 'key' => $this->getDisplayIconKey(), 'name' => $this->getDisplayIconName(), 'icon' => $this->getDisplayIconIcon(), ), 'color' => array( 'key' => $color_key, 'name' => $color_name, ), ); } public function getConduitSearchAttachments() { return array( id(new PhabricatorProjectsMembersSearchEngineAttachment()) ->setAttachmentKey('members'), id(new PhabricatorProjectsWatchersSearchEngineAttachment()) ->setAttachmentKey('watchers'), id(new PhabricatorProjectsAncestorsSearchEngineAttachment()) ->setAttachmentKey('ancestors'), ); } /** * Get an abbreviated representation of this project for use in providing * "parent" and "ancestor" information. */ public function getRefForConduit() { return array( 'id' => (int)$this->getID(), 'phid' => $this->getPHID(), 'name' => $this->getName(), ); } /* -( PhabricatorColumnProxyInterface )------------------------------------ */ public function getProxyColumnName() { return $this->getName(); } public function getProxyColumnIcon() { return $this->getDisplayIconIcon(); } public function getProxyColumnClass() { if ($this->isMilestone()) { return 'phui-workboard-column-milestone'; } return null; } /* -( PhabricatorEditEngineSubtypeInterface )------------------------------ */ public function getEditEngineSubtype() { return $this->getSubtype(); } public function setEditEngineSubtype($value) { return $this->setSubtype($value); } public function newEditEngineSubtypeMap() { $config = PhabricatorEnv::getEnvConfig('projects.subtypes'); return PhabricatorEditEngineSubtype::newSubtypeMap($config) ->setDatasource(new PhabricatorProjectSubtypeDatasource()); } public function newSubtypeObject() { $subtype_key = $this->getEditEngineSubtype(); $subtype_map = $this->newEditEngineSubtypeMap(); return $subtype_map->getSubtype($subtype_key); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectCustomFieldStorage.php
src/applications/project/storage/PhabricatorProjectCustomFieldStorage.php
<?php final class PhabricatorProjectCustomFieldStorage extends PhabricatorCustomFieldStorage { public function getApplicationName() { return 'project'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectSchemaSpec.php
src/applications/project/storage/PhabricatorProjectSchemaSpec.php
<?php final class PhabricatorProjectSchemaSpec extends PhabricatorConfigSchemaSpec { public function buildSchemata() { $this->buildEdgeSchemata(new PhabricatorProject()); $this->buildRawSchema( id(new PhabricatorProject())->getApplicationName(), PhabricatorProject::TABLE_DATASOURCE_TOKEN, array( 'id' => 'auto', 'projectID' => 'id', 'token' => 'text128', ), array( 'PRIMARY' => array( 'columns' => array('id'), 'unique' => true, ), 'token' => array( 'columns' => array('token', 'projectID'), 'unique' => true, ), 'projectID' => array( 'columns' => array('projectID'), ), )); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectDAO.php
src/applications/project/storage/PhabricatorProjectDAO.php
<?php abstract class PhabricatorProjectDAO extends PhabricatorLiskDAO { public function getApplicationName() { return 'project'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectTrigger.php
src/applications/project/storage/PhabricatorProjectTrigger.php
<?php final class PhabricatorProjectTrigger extends PhabricatorProjectDAO implements PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, PhabricatorIndexableInterface, PhabricatorDestructibleInterface { protected $name; protected $ruleset = array(); protected $editPolicy; private $triggerRules; private $viewer; private $usage = self::ATTACHABLE; public static function initializeNewTrigger() { $default_edit = PhabricatorPolicies::POLICY_USER; return id(new self()) ->setName('') ->setEditPolicy($default_edit); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'ruleset' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text255', ), self::CONFIG_KEY_SCHEMA => array( ), ) + parent::getConfiguration(); } public function getPHIDType() { return PhabricatorProjectTriggerPHIDType::TYPECONST; } public function getViewer() { return $this->viewer; } public function setViewer(PhabricatorUser $user) { $this->viewer = $user; return $this; } public function getDisplayName() { $name = $this->getName(); if (strlen($name)) { return $name; } return $this->getDefaultName(); } public function getDefaultName() { return pht('Custom Trigger'); } public function getURI() { return urisprintf( '/project/trigger/%d/', $this->getID()); } public function getObjectName() { return pht('Trigger %d', $this->getID()); } public function setRuleset(array $ruleset) { // Clear any cached trigger rules, since we're changing the ruleset // for the trigger. $this->triggerRules = null; parent::setRuleset($ruleset); } public function getTriggerRules($viewer = null) { if ($this->triggerRules === null) { if (!$viewer) { $viewer = $this->getViewer(); } $trigger_rules = self::newTriggerRulesFromRuleSpecifications( $this->getRuleset(), $allow_invalid = true, $viewer); $this->triggerRules = $trigger_rules; } return $this->triggerRules; } public static function newTriggerRulesFromRuleSpecifications( array $list, $allow_invalid, PhabricatorUser $viewer) { // NOTE: With "$allow_invalid" set, we're trying to preserve the database // state in the rule structure, even if it includes rule types we don't // have implementations for, or rules with invalid rule values. // If an administrator adds or removes extensions which add rules, or // an upgrade affects rule validity, existing rules may become invalid. // When they do, we still want the UI to reflect the ruleset state // accurately and "Edit" + "Save" shouldn't destroy data unless the // user explicitly modifies the ruleset. // In this mode, when we run into rules which are structured correctly but // which have types we don't know about, we replace them with "Unknown // Rules". If we know about the type of a rule but the value doesn't // validate, we replace it with "Invalid Rules". These two rule types don't // take any actions when a card is dropped into the column, but they show // the user what's wrong with the ruleset and can be saved without causing // any collateral damage. $rule_map = PhabricatorProjectTriggerRule::getAllTriggerRules(); // If the stored rule data isn't a list of rules (or we encounter other // fundamental structural problems, below), there isn't much we can do // to try to represent the state. if (!is_array($list)) { throw new PhabricatorProjectTriggerCorruptionException( pht( 'Trigger ruleset is corrupt: expected a list of rule '. 'specifications, found "%s".', phutil_describe_type($list))); } $trigger_rules = array(); foreach ($list as $key => $rule) { if (!is_array($rule)) { throw new PhabricatorProjectTriggerCorruptionException( pht( 'Trigger ruleset is corrupt: rule (at index "%s") should be a '. 'rule specification, but is actually "%s".', $key, phutil_describe_type($rule))); } try { PhutilTypeSpec::checkMap( $rule, array( 'type' => 'string', 'value' => 'wild', )); } catch (PhutilTypeCheckException $ex) { throw new PhabricatorProjectTriggerCorruptionException( pht( 'Trigger ruleset is corrupt: rule (at index "%s") is not a '. 'valid rule specification: %s', $key, $ex->getMessage())); } $record = id(new PhabricatorProjectTriggerRuleRecord()) ->setType(idx($rule, 'type')) ->setValue(idx($rule, 'value')); if (!isset($rule_map[$record->getType()])) { if (!$allow_invalid) { throw new PhabricatorProjectTriggerCorruptionException( pht( 'Trigger ruleset is corrupt: rule type "%s" is unknown.', $record->getType())); } $rule = new PhabricatorProjectTriggerUnknownRule(); } else { $rule = clone $rule_map[$record->getType()]; } try { $rule->setRecord($record); } catch (Exception $ex) { if (!$allow_invalid) { throw new PhabricatorProjectTriggerCorruptionException( pht( 'Trigger ruleset is corrupt, rule (of type "%s") does not '. 'validate: %s', $record->getType(), $ex->getMessage())); } $rule = id(new PhabricatorProjectTriggerInvalidRule()) ->setRecord($record) ->setException($ex); } $rule->setViewer($viewer); $trigger_rules[] = $rule; } return $trigger_rules; } public function getDropEffects() { $effects = array(); $rules = $this->getTriggerRules(); foreach ($rules as $rule) { foreach ($rule->getDropEffects() as $effect) { $effects[] = $effect; } } return $effects; } public function newDropTransactions( PhabricatorUser $viewer, PhabricatorProjectColumn $column, $object) { $trigger_xactions = array(); foreach ($this->getTriggerRules($viewer) as $rule) { $rule ->setTrigger($this) ->setColumn($column) ->setObject($object); $xactions = $rule->getDropTransactions( $object, $rule->getRecord()->getValue()); if (!is_array($xactions)) { throw new Exception( pht( 'Expected trigger rule (of class "%s") to return a list of '. 'transactions from "newDropTransactions()", but got "%s".', get_class($rule), phutil_describe_type($xactions))); } $expect_type = get_class($object->getApplicationTransactionTemplate()); assert_instances_of($xactions, $expect_type); foreach ($xactions as $xaction) { $trigger_xactions[] = $xaction; } } return $trigger_xactions; } public function getPreviewEffect() { $header = pht('Trigger: %s', $this->getDisplayName()); return id(new PhabricatorProjectDropEffect()) ->setIcon('fa-cogs') ->setColor('blue') ->setIsHeader(true) ->setContent($header); } public function getSoundEffects() { $sounds = array(); foreach ($this->getTriggerRules() as $rule) { foreach ($rule->getSoundEffects() as $effect) { $sounds[] = $effect; } } return $sounds; } public function getUsage() { return $this->assertAttached($this->usage); } public function attachUsage(PhabricatorProjectTriggerUsage $usage) { $this->usage = $usage; return $this; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new PhabricatorProjectTriggerEditor(); } public function getApplicationTransactionTemplate() { return new PhabricatorProjectTriggerTransaction(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::getMostOpenPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->openTransaction(); $conn = $this->establishConnection('w'); // Remove the reference to this trigger from any columns which use it. queryfx( $conn, 'UPDATE %R SET triggerPHID = null WHERE triggerPHID = %s', new PhabricatorProjectColumn(), $this->getPHID()); // Remove the usage index row for this trigger, if one exists. queryfx( $conn, 'DELETE FROM %R WHERE triggerPHID = %s', new PhabricatorProjectTriggerUsage(), $this->getPHID()); $this->delete(); $this->saveTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectTransaction.php
src/applications/project/storage/PhabricatorProjectTransaction.php
<?php final class PhabricatorProjectTransaction extends PhabricatorModularTransaction { // NOTE: This is deprecated, members are just a normal edge now. const TYPE_MEMBERS = 'project:members'; const MAILTAG_METADATA = 'project-metadata'; const MAILTAG_MEMBERS = 'project-members'; const MAILTAG_WATCHERS = 'project-watchers'; const MAILTAG_OTHER = 'project-other'; public function getApplicationName() { return 'project'; } public function getApplicationTransactionType() { return PhabricatorProjectProjectPHIDType::TYPECONST; } public function getBaseTransactionClass() { return 'PhabricatorProjectTransactionType'; } public function getRequiredHandlePHIDs() { $old = $this->getOldValue(); $new = $this->getNewValue(); $req_phids = array(); switch ($this->getTransactionType()) { case self::TYPE_MEMBERS: $add = array_diff($new, $old); $rem = array_diff($old, $new); $req_phids = array_merge($add, $rem); break; } return array_merge($req_phids, parent::getRequiredHandlePHIDs()); } public function shouldHide() { switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_EDGE: $edge_type = $this->getMetadataValue('edge:type'); switch ($edge_type) { case PhabricatorProjectSilencedEdgeType::EDGECONST: return true; default: break; } } return parent::shouldHide(); } public function shouldHideForMail(array $xactions) { switch ($this->getTransactionType()) { case PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE: case PhabricatorProjectSortTransaction::TRANSACTIONTYPE: case PhabricatorProjectFilterTransaction::TRANSACTIONTYPE: case PhabricatorProjectWorkboardBackgroundTransaction::TRANSACTIONTYPE: return true; } return parent::shouldHideForMail($xactions); } public function getIcon() { switch ($this->getTransactionType()) { case self::TYPE_MEMBERS: return 'fa-user'; } return parent::getIcon(); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); $author_phid = $this->getAuthorPHID(); $author_handle = $this->renderHandleLink($author_phid); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_CREATE: return pht( '%s created this project.', $this->renderHandleLink($author_phid)); case self::TYPE_MEMBERS: $add = array_diff($new, $old); $rem = array_diff($old, $new); if ($add && $rem) { return pht( '%s changed project member(s), added %d: %s; removed %d: %s.', $author_handle, count($add), $this->renderHandleList($add), count($rem), $this->renderHandleList($rem)); } else if ($add) { if (count($add) == 1 && (head($add) == $this->getAuthorPHID())) { return pht( '%s joined this project.', $author_handle); } else { return pht( '%s added %d project member(s): %s.', $author_handle, count($add), $this->renderHandleList($add)); } } else if ($rem) { if (count($rem) == 1 && (head($rem) == $this->getAuthorPHID())) { return pht( '%s left this project.', $author_handle); } else { return pht( '%s removed %d project member(s): %s.', $author_handle, count($rem), $this->renderHandleList($rem)); } } break; } return parent::getTitle(); } public function getMailTags() { $tags = array(); switch ($this->getTransactionType()) { case PhabricatorProjectNameTransaction::TRANSACTIONTYPE: case PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE: case PhabricatorProjectImageTransaction::TRANSACTIONTYPE: case PhabricatorProjectIconTransaction::TRANSACTIONTYPE: case PhabricatorProjectColorTransaction::TRANSACTIONTYPE: $tags[] = self::MAILTAG_METADATA; break; case PhabricatorTransactions::TYPE_EDGE: $type = $this->getMetadata('edge:type'); $type = head($type); $type_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $type_watcher = PhabricatorObjectHasWatcherEdgeType::EDGECONST; if ($type == $type_member) { $tags[] = self::MAILTAG_MEMBERS; } else if ($type == $type_watcher) { $tags[] = self::MAILTAG_WATCHERS; } else { $tags[] = self::MAILTAG_OTHER; } break; case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE: case PhabricatorProjectLockTransaction::TRANSACTIONTYPE: default: $tags[] = self::MAILTAG_OTHER; break; } return $tags; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectSlug.php
src/applications/project/storage/PhabricatorProjectSlug.php
<?php final class PhabricatorProjectSlug extends PhabricatorProjectDAO { protected $slug; protected $projectPHID; protected function getConfiguration() { return array( self::CONFIG_COLUMN_SCHEMA => array( 'slug' => 'text128', ), self::CONFIG_KEY_SCHEMA => array( 'key_slug' => array( 'columns' => array('slug'), 'unique' => true, ), 'key_projectPHID' => array( 'columns' => array('projectPHID'), ), ), ) + parent::getConfiguration(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectCustomFieldNumericIndex.php
src/applications/project/storage/PhabricatorProjectCustomFieldNumericIndex.php
<?php final class PhabricatorProjectCustomFieldNumericIndex extends PhabricatorCustomFieldNumericIndexStorage { public function getApplicationName() { return 'project'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectTriggerUsage.php
src/applications/project/storage/PhabricatorProjectTriggerUsage.php
<?php final class PhabricatorProjectTriggerUsage extends PhabricatorProjectDAO { protected $triggerPHID; protected $examplePHID; protected $columnCount; protected $activeColumnCount; protected function getConfiguration() { return array( self::CONFIG_TIMESTAMPS => false, self::CONFIG_COLUMN_SCHEMA => array( 'examplePHID' => 'phid?', 'columnCount' => 'uint32', 'activeColumnCount' => 'uint32', ), self::CONFIG_KEY_SCHEMA => array( 'key_trigger' => array( 'columns' => array('triggerPHID'), 'unique' => true, ), ), ) + parent::getConfiguration(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectTriggerTransaction.php
src/applications/project/storage/PhabricatorProjectTriggerTransaction.php
<?php final class PhabricatorProjectTriggerTransaction extends PhabricatorModularTransaction { public function getApplicationName() { return 'project'; } public function getApplicationTransactionType() { return PhabricatorProjectTriggerPHIDType::TYPECONST; } public function getBaseTransactionClass() { return 'PhabricatorProjectTriggerTransactionType'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectCustomFieldStringIndex.php
src/applications/project/storage/PhabricatorProjectCustomFieldStringIndex.php
<?php final class PhabricatorProjectCustomFieldStringIndex extends PhabricatorCustomFieldStringIndexStorage { public function getApplicationName() { return 'project'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectColumnTransaction.php
src/applications/project/storage/PhabricatorProjectColumnTransaction.php
<?php final class PhabricatorProjectColumnTransaction extends PhabricatorModularTransaction { public function getApplicationName() { return 'project'; } public function getApplicationTransactionType() { return PhabricatorProjectColumnPHIDType::TYPECONST; } public function getBaseTransactionClass() { return 'PhabricatorProjectColumnTransactionType'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectColumnPosition.php
src/applications/project/storage/PhabricatorProjectColumnPosition.php
<?php final class PhabricatorProjectColumnPosition extends PhabricatorProjectDAO implements PhabricatorPolicyInterface { protected $boardPHID; protected $columnPHID; protected $objectPHID; protected $sequence; private $column = self::ATTACHABLE; private $viewSequence = 0; protected function getConfiguration() { return array( self::CONFIG_TIMESTAMPS => false, self::CONFIG_COLUMN_SCHEMA => array( 'sequence' => 'uint32', ), self::CONFIG_KEY_SCHEMA => array( 'boardPHID' => array( 'columns' => array('boardPHID', 'columnPHID', 'objectPHID'), 'unique' => true, ), 'objectPHID' => array( 'columns' => array('objectPHID', 'boardPHID'), ), 'boardPHID_2' => array( 'columns' => array('boardPHID', 'columnPHID', 'sequence'), ), ), ) + parent::getConfiguration(); } public function getColumn() { return $this->assertAttached($this->column); } public function attachColumn(PhabricatorProjectColumn $column) { $this->column = $column; return $this; } public function setViewSequence($view_sequence) { $this->viewSequence = $view_sequence; return $this; } public function newColumnPositionOrderVector() { // We're ordering both real positions and "virtual" positions which we have // created but not saved yet. // Low sequence numbers go above high sequence numbers. Virtual positions // will have sequence number 0. // High virtual sequence numbers go above low virtual sequence numbers. // The layout engine gets objects in ID order, and this puts them in // reverse ID order. // High IDs go above low IDs. // Broadly, this collectively makes newly added stuff float to the top. return id(new PhutilSortVector()) ->addInt($this->getSequence()) ->addInt(-1 * $this->viewSequence) ->addInt(-1 * $this->getID()); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::getMostOpenPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/storage/PhabricatorProjectColumn.php
src/applications/project/storage/PhabricatorProjectColumn.php
<?php final class PhabricatorProjectColumn extends PhabricatorProjectDAO implements PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, PhabricatorDestructibleInterface, PhabricatorExtendedPolicyInterface, PhabricatorConduitResultInterface { const STATUS_ACTIVE = 0; const STATUS_HIDDEN = 1; protected $name; protected $status; protected $projectPHID; protected $proxyPHID; protected $sequence; protected $properties = array(); protected $triggerPHID; private $project = self::ATTACHABLE; private $proxy = self::ATTACHABLE; private $trigger = self::ATTACHABLE; public static function initializeNewColumn(PhabricatorUser $user) { return id(new PhabricatorProjectColumn()) ->setName('') ->setStatus(self::STATUS_ACTIVE) ->attachProxy(null); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'properties' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text255', 'status' => 'uint32', 'sequence' => 'uint32', 'proxyPHID' => 'phid?', 'triggerPHID' => 'phid?', ), self::CONFIG_KEY_SCHEMA => array( 'key_status' => array( 'columns' => array('projectPHID', 'status', 'sequence'), ), 'key_sequence' => array( 'columns' => array('projectPHID', 'sequence'), ), 'key_proxy' => array( 'columns' => array('projectPHID', 'proxyPHID'), 'unique' => true, ), 'key_trigger' => array( 'columns' => array('triggerPHID'), ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorProjectColumnPHIDType::TYPECONST); } public function attachProject(PhabricatorProject $project) { $this->project = $project; return $this; } public function getProject() { return $this->assertAttached($this->project); } public function attachProxy($proxy) { $this->proxy = $proxy; return $this; } public function getProxy() { return $this->assertAttached($this->proxy); } public function isDefaultColumn() { return (bool)$this->getProperty('isDefault'); } public function isHidden() { $proxy = $this->getProxy(); if ($proxy) { return $proxy->isArchived(); } return ($this->getStatus() == self::STATUS_HIDDEN); } public function getDisplayName() { $proxy = $this->getProxy(); if ($proxy) { return $proxy->getProxyColumnName(); } $name = $this->getName(); if (strlen($name)) { return $name; } if ($this->isDefaultColumn()) { return pht('Backlog'); } return pht('Unnamed Column'); } public function getDisplayType() { if ($this->isDefaultColumn()) { return pht('(Default)'); } if ($this->isHidden()) { return pht('(Hidden)'); } return null; } public function getDisplayClass() { $proxy = $this->getProxy(); if ($proxy) { return $proxy->getProxyColumnClass(); } return null; } public function getHeaderIcon() { $proxy = $this->getProxy(); if ($proxy) { return $proxy->getProxyColumnIcon(); } if ($this->isHidden()) { return 'fa-eye-slash'; } return null; } public function getProperty($key, $default = null) { return idx($this->properties, $key, $default); } public function setProperty($key, $value) { $this->properties[$key] = $value; return $this; } public function getPointLimit() { return $this->getProperty('pointLimit'); } public function setPointLimit($limit) { $this->setProperty('pointLimit', $limit); return $this; } public function getOrderingKey() { $proxy = $this->getProxy(); // Normal columns and subproject columns go first, in a user-controlled // order. // All the milestone columns go last, in their sequential order. if (!$proxy || !$proxy->isMilestone()) { $group = 'A'; $sequence = $this->getSequence(); } else { $group = 'B'; $sequence = $proxy->getMilestoneNumber(); } return sprintf('%s%012d', $group, $sequence); } public function attachTrigger(PhabricatorProjectTrigger $trigger = null) { $this->trigger = $trigger; return $this; } public function getTrigger() { return $this->assertAttached($this->trigger); } public function canHaveTrigger() { // Backlog columns and proxy (subproject / milestone) columns can't have // triggers because cards routinely end up in these columns through tag // edits rather than drag-and-drop and it would likely be confusing to // have these triggers act only a small fraction of the time. if ($this->isDefaultColumn()) { return false; } if ($this->getProxy()) { return false; } return true; } public function getWorkboardURI() { return $this->getProject()->getWorkboardURI(); } public function getDropEffects() { $effects = array(); $proxy = $this->getProxy(); if ($proxy && $proxy->isMilestone()) { $effects[] = id(new PhabricatorProjectDropEffect()) ->setIcon($proxy->getProxyColumnIcon()) ->setColor('violet') ->setContent( pht( 'Move to milestone %s.', phutil_tag('strong', array(), $this->getDisplayName()))); } else { $effects[] = id(new PhabricatorProjectDropEffect()) ->setIcon('fa-columns') ->setColor('blue') ->setContent( pht( 'Move to column %s.', phutil_tag('strong', array(), $this->getDisplayName()))); } if ($this->canHaveTrigger()) { $trigger = $this->getTrigger(); if ($trigger) { foreach ($trigger->getDropEffects() as $trigger_effect) { $effects[] = $trigger_effect; } } } return $effects; } /* -( PhabricatorConduitResultInterface )---------------------------------- */ public function getFieldSpecificationsForConduit() { return array( id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('name') ->setType('string') ->setDescription(pht('The display name of the column.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('project') ->setType('map<string, wild>') ->setDescription(pht('The project the column belongs to.')), id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('proxyPHID') ->setType('phid?') ->setDescription( pht( 'For columns that proxy another object (like a subproject or '. 'milestone), the PHID of the object they proxy.')), ); } public function getFieldValuesForConduit() { return array( 'name' => $this->getDisplayName(), 'proxyPHID' => $this->getProxyPHID(), 'project' => $this->getProject()->getRefForConduit(), ); } public function getConduitSearchAttachments() { return array(); } public function getRefForConduit() { return array( 'id' => (int)$this->getID(), 'phid' => $this->getPHID(), 'name' => $this->getDisplayName(), ); } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new PhabricatorProjectColumnTransactionEditor(); } public function getApplicationTransactionTemplate() { return new PhabricatorProjectColumnTransaction(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { // NOTE: Column policies are enforced as an extended policy which makes // them the same as the project's policies. switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::getMostOpenPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return PhabricatorPolicies::POLICY_USER; } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return $this->getProject()->hasAutomaticCapability( $capability, $viewer); } public function describeAutomaticCapability($capability) { return pht('Users must be able to see a project to see its board.'); } /* -( PhabricatorExtendedPolicyInterface )--------------------------------- */ public function getExtendedPolicy($capability, PhabricatorUser $viewer) { return array( array($this->getProject(), $capability), ); } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->openTransaction(); $this->delete(); $this->saveTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/state/PhabricatorWorkboardViewState.php
src/applications/project/state/PhabricatorWorkboardViewState.php
<?php final class PhabricatorWorkboardViewState extends Phobject { private $viewer; private $project; private $requestState = array(); private $savedQuery; private $searchEngine; private $layoutEngine; private $objects; public function setProject(PhabricatorProject $project) { $this->project = $project; return $this; } public function getProject() { return $this->project; } public function readFromRequest(AphrontRequest $request) { if ($request->getExists('hidden')) { $this->requestState['hidden'] = $request->getBool('hidden'); } if ($request->getExists('order')) { $this->requestState['order'] = $request->getStr('order'); } // On some pathways, the search engine query key may be specified with // either a "?filter=X" query parameter or with a "/query/X/" URI // component. If both are present, the URI component is controlling. // In particular, the "queryKey" URI parameter is used by // "buildSavedQueryFromRequest()" when we are building custom board filters // by invoking SearchEngine code. if ($request->getExists('filter')) { $this->requestState['filter'] = $request->getStr('filter'); } $query_key = $request->getURIData('queryKey'); if ($query_key !== null && strlen($query_key)) { $this->requestState['filter'] = $request->getURIData('queryKey'); } $this->viewer = $request->getViewer(); return $this; } public function getViewer() { return $this->viewer; } public function getSavedQuery() { if ($this->savedQuery === null) { $this->savedQuery = $this->newSavedQuery(); } return $this->savedQuery; } private function newSavedQuery() { $search_engine = $this->getSearchEngine(); $query_key = $this->getQueryKey(); $viewer = $this->getViewer(); if ($search_engine->isBuiltinQuery($query_key)) { $saved_query = $search_engine->buildSavedQueryFromBuiltin($query_key); } else { $saved_query = id(new PhabricatorSavedQueryQuery()) ->setViewer($viewer) ->withQueryKeys(array($query_key)) ->executeOne(); } return $saved_query; } public function getSearchEngine() { if ($this->searchEngine === null) { $this->searchEngine = $this->newSearchEngine(); } return $this->searchEngine; } private function newSearchEngine() { $viewer = $this->getViewer(); // TODO: This URI is not fully state-preserving, because "SearchEngine" // does not preserve URI parameters when constructing some URIs at time of // writing. $board_uri = $this->getProject()->getWorkboardURI(); return id(new ManiphestTaskSearchEngine()) ->setViewer($viewer) ->setBaseURI($board_uri) ->setIsBoardView(true); } public function newWorkboardURI($path = '') { $project = $this->getProject(); $uri = urisprintf('%s%s', $project->getWorkboardURI(), $path); return $this->newURI($uri); } public function newURI($path) { $project = $this->getProject(); $uri = new PhutilURI($path); $request_order = $this->getOrder(); $default_order = $this->getDefaultOrder(); if ($request_order !== $default_order) { $request_value = idx($this->requestState, 'order'); if ($request_value !== null) { $uri->replaceQueryParam('order', $request_value); } else { $uri->removeQueryParam('order'); } } else { $uri->removeQueryParam('order'); } $request_query = $this->getQueryKey(); $default_query = $this->getDefaultQueryKey(); if ($request_query !== $default_query) { $request_value = idx($this->requestState, 'filter'); if ($request_value !== null) { $uri->replaceQueryParam('filter', $request_value); } else { $uri->removeQueryParam('filter'); } } else { $uri->removeQueryParam('filter'); } if ($this->getShowHidden()) { $uri->replaceQueryParam('hidden', 'true'); } else { $uri->removeQueryParam('hidden'); } return $uri; } public function getShowHidden() { $request_show = idx($this->requestState, 'hidden'); if ($request_show !== null) { return $request_show; } return false; } public function getOrder() { $request_order = idx($this->requestState, 'order'); if ($request_order !== null) { if ($this->isValidOrder($request_order)) { return $request_order; } } return $this->getDefaultOrder(); } public function getQueryKey() { $request_query = idx($this->requestState, 'filter'); if ($request_query !== null && strlen($request_query)) { return $request_query; } return $this->getDefaultQueryKey(); } public function setQueryKey($query_key) { $this->requestState['filter'] = $query_key; return $this; } private function isValidOrder($order) { $map = PhabricatorProjectColumnOrder::getEnabledOrders(); return isset($map[$order]); } private function getDefaultOrder() { $project = $this->getProject(); $default_order = $project->getDefaultWorkboardSort(); if ($this->isValidOrder($default_order)) { return $default_order; } return PhabricatorProjectColumnNaturalOrder::ORDERKEY; } private function getDefaultQueryKey() { $project = $this->getProject(); $default_query = $project->getDefaultWorkboardFilter(); if ($default_query !== null && strlen($default_query)) { return $default_query; } return 'open'; } public function getQueryParameters() { return $this->requestState; } public function getLayoutEngine() { if ($this->layoutEngine === null) { $this->layoutEngine = $this->newLayoutEngine(); } return $this->layoutEngine; } private function newLayoutEngine() { $project = $this->getProject(); $viewer = $this->getViewer(); $board_phid = $project->getPHID(); $objects = $this->getObjects(); // Regardless of display order, pass tasks to the layout engine in ID order // so layout is consistent. $objects = msort($objects, 'getID'); $layout_engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($viewer) ->setObjectPHIDs(array_keys($objects)) ->setBoardPHIDs(array($board_phid)) ->setFetchAllBoards(true) ->executeLayout(); return $layout_engine; } public function getBoardContainerPHIDs() { $project = $this->getProject(); $viewer = $this->getViewer(); $container_phids = array($project->getPHID()); if ($project->getHasSubprojects() || $project->getHasMilestones()) { $descendants = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withAncestorProjectPHIDs($container_phids) ->execute(); foreach ($descendants as $descendant) { $container_phids[] = $descendant->getPHID(); } } return $container_phids; } public function getObjects() { if ($this->objects === null) { $this->objects = $this->newObjects(); } return $this->objects; } private function newObjects() { $viewer = $this->getViewer(); $saved_query = $this->getSavedQuery(); $search_engine = $this->getSearchEngine(); $container_phids = $this->getBoardContainerPHIDs(); $task_query = $search_engine->buildQueryFromSavedQuery($saved_query) ->setViewer($viewer) ->withEdgeLogicPHIDs( PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, PhabricatorQueryConstraint::OPERATOR_ANCESTOR, array($container_phids)); $tasks = $task_query->execute(); $tasks = mpull($tasks, null, 'getPHID'); return $tasks; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/icon/PhabricatorProjectIconSet.php
src/applications/project/icon/PhabricatorProjectIconSet.php
<?php final class PhabricatorProjectIconSet extends PhabricatorIconSet { const ICONSETKEY = 'projects'; const SPECIAL_MILESTONE = 'milestone'; public function getSelectIconTitleText() { return pht('Choose Project Icon'); } public static function getDefaultConfiguration() { return array( array( 'key' => 'project', 'icon' => 'fa-briefcase', 'name' => pht('Project'), 'default' => true, 'image' => 'v3/briefcase.png', ), array( 'key' => 'tag', 'icon' => 'fa-tags', 'name' => pht('Tag'), 'image' => 'v3/tag.png', ), array( 'key' => 'policy', 'icon' => 'fa-lock', 'name' => pht('Policy'), 'image' => 'v3/lock.png', ), array( 'key' => 'group', 'icon' => 'fa-users', 'name' => pht('Group'), 'image' => 'v3/people.png', ), array( 'key' => 'folder', 'icon' => 'fa-folder', 'name' => pht('Folder'), 'image' => 'v3/folder.png', ), array( 'key' => 'timeline', 'icon' => 'fa-calendar', 'name' => pht('Timeline'), 'image' => 'v3/calendar.png', ), array( 'key' => 'goal', 'icon' => 'fa-flag-checkered', 'name' => pht('Goal'), 'image' => 'v3/flag.png', ), array( 'key' => 'release', 'icon' => 'fa-truck', 'name' => pht('Release'), 'image' => 'v3/truck.png', ), array( 'key' => 'bugs', 'icon' => 'fa-bug', 'name' => pht('Bugs'), 'image' => 'v3/bug.png', ), array( 'key' => 'cleanup', 'icon' => 'fa-trash-o', 'name' => pht('Cleanup'), 'image' => 'v3/trash.png', ), array( 'key' => 'umbrella', 'icon' => 'fa-umbrella', 'name' => pht('Umbrella'), 'image' => 'v3/umbrella.png', ), array( 'key' => 'communication', 'icon' => 'fa-envelope', 'name' => pht('Communication'), 'image' => 'v3/mail.png', ), array( 'key' => 'organization', 'icon' => 'fa-building', 'name' => pht('Organization'), 'image' => 'v3/organization.png', ), array( 'key' => 'infrastructure', 'icon' => 'fa-cloud', 'name' => pht('Infrastructure'), 'image' => 'v3/cloud.png', ), array( 'key' => 'account', 'icon' => 'fa-credit-card', 'name' => pht('Account'), 'image' => 'v3/creditcard.png', ), array( 'key' => 'experimental', 'icon' => 'fa-flask', 'name' => pht('Experimental'), 'image' => 'v3/experimental.png', ), array( 'key' => 'milestone', 'icon' => 'fa-map-marker', 'name' => pht('Milestone'), 'special' => self::SPECIAL_MILESTONE, 'image' => 'v3/marker.png', ), ); } protected function newIcons() { $map = self::getIconSpecifications(); $icons = array(); foreach ($map as $spec) { $special = idx($spec, 'special'); if ($special === self::SPECIAL_MILESTONE) { continue; } $icons[] = id(new PhabricatorIconSetIcon()) ->setKey($spec['key']) ->setIsDisabled(idx($spec, 'disabled')) ->setIcon($spec['icon']) ->setLabel($spec['name']); } return $icons; } private static function getIconSpecifications() { return PhabricatorEnv::getEnvConfig('projects.icons'); } public static function getDefaultIconKey() { $icons = self::getIconSpecifications(); foreach ($icons as $icon) { if (idx($icon, 'default')) { return $icon['key']; } } return null; } public static function getIconIcon($key) { $spec = self::getIconSpec($key); return idx($spec, 'icon', null); } public static function getIconName($key) { $spec = self::getIconSpec($key); return idx($spec, 'name', null); } public static function getIconImage($key) { $spec = self::getIconSpec($key); return idx($spec, 'image', 'v3/briefcase.png'); } private static function getIconSpec($key) { $icons = self::getIconSpecifications(); foreach ($icons as $icon) { if (idx($icon, 'key') === $key) { return $icon; } } return array(); } public static function getMilestoneIconKey() { $icons = self::getIconSpecifications(); foreach ($icons as $icon) { if (idx($icon, 'special') === self::SPECIAL_MILESTONE) { return idx($icon, 'key'); } } return null; } public static function validateConfiguration($config) { if (!is_array($config)) { throw new Exception( pht('Configuration must be a list of project icon specifications.')); } foreach ($config as $idx => $value) { if (!is_array($value)) { throw new Exception( pht( 'Value for index "%s" should be a dictionary.', $idx)); } PhutilTypeSpec::checkMap( $value, array( 'key' => 'string', 'name' => 'string', 'icon' => 'string', 'image' => 'optional string', 'special' => 'optional string', 'disabled' => 'optional bool', 'default' => 'optional bool', )); if (!preg_match('/^[a-z]{1,32}\z/', $value['key'])) { throw new Exception( pht( 'Icon key "%s" is not a valid icon key. Icon keys must be 1-32 '. 'characters long and contain only lowercase letters. For example, '. '"%s" and "%s" are reasonable keys.', $value['key'], 'tag', 'group')); } $special = idx($value, 'special'); $valid = array( self::SPECIAL_MILESTONE => true, ); if ($special !== null) { if (empty($valid[$special])) { throw new Exception( pht( 'Icon special attribute "%s" is not valid. Recognized special '. 'attributes are: %s.', $special, implode(', ', array_keys($valid)))); } } } $default = null; $milestone = null; $keys = array(); foreach ($config as $idx => $value) { $key = $value['key']; if (isset($keys[$key])) { throw new Exception( pht( 'Project icons must have unique keys, but two icons share the '. 'same key ("%s").', $key)); } else { $keys[$key] = true; } $is_disabled = idx($value, 'disabled'); $image = idx($value, 'image'); if ($image !== null) { $builtin = idx($value, 'image'); $builtin_map = id(new PhabricatorFilesOnDiskBuiltinFile()) ->getProjectBuiltinFiles(); $builtin_map = array_flip($builtin_map); $root = dirname(phutil_get_library_root('phabricator')); $image = $root.'/resources/builtin/projects/'.$builtin; if (!array_key_exists($image, $builtin_map)) { throw new Exception( pht( 'The project image ("%s") specified for ("%s") '. 'was not found in the folder "resources/builtin/projects/".', $builtin, $key)); } } if (idx($value, 'default')) { if ($default === null) { if ($is_disabled) { throw new Exception( pht( 'The project icon marked as the default icon ("%s") must not '. 'be disabled.', $key)); } $default = $value; } else { $original_key = $default['key']; throw new Exception( pht( 'Two different icons ("%s", "%s") are marked as the default '. 'icon. Only one icon may be marked as the default.', $key, $original_key)); } } $special = idx($value, 'special'); if ($special === self::SPECIAL_MILESTONE) { if ($milestone === null) { if ($is_disabled) { throw new Exception( pht( 'The project icon ("%s") with special attribute "%s" must '. 'not be disabled', $key, self::SPECIAL_MILESTONE)); } $milestone = $value; } else { $original_key = $milestone['key']; throw new Exception( pht( 'Two different icons ("%s", "%s") are marked with special '. 'attribute "%s". Only one icon may be marked with this '. 'attribute.', $key, $original_key, self::SPECIAL_MILESTONE)); } } } if ($default === null) { throw new Exception( pht( 'Project icons must include one icon marked as the "%s" icon, '. 'but no such icon exists.', 'default')); } if ($milestone === null) { throw new Exception( pht( 'Project icons must include one icon marked with special attribute '. '"%s", but no such icon exists.', self::SPECIAL_MILESTONE)); } } private static function getColorSpecifications() { return PhabricatorEnv::getEnvConfig('projects.colors'); } public static function getColorMap() { $specifications = self::getColorSpecifications(); return ipull($specifications, 'name', 'key'); } public static function getDefaultColorKey() { $specifications = self::getColorSpecifications(); foreach ($specifications as $specification) { if (idx($specification, 'default')) { return $specification['key']; } } return null; } private static function getAvailableColorKeys() { $list = array(); $specifications = self::getDefaultColorMap(); foreach ($specifications as $specification) { $list[] = $specification['key']; } return $list; } public static function getColorName($color_key) { $map = self::getColorMap(); return idx($map, $color_key); } public static function getDefaultColorMap() { return array( array( 'key' => PHUITagView::COLOR_RED, 'name' => pht('Red'), ), array( 'key' => PHUITagView::COLOR_ORANGE, 'name' => pht('Orange'), ), array( 'key' => PHUITagView::COLOR_YELLOW, 'name' => pht('Yellow'), ), array( 'key' => PHUITagView::COLOR_GREEN, 'name' => pht('Green'), ), array( 'key' => PHUITagView::COLOR_BLUE, 'name' => pht('Blue'), 'default' => true, ), array( 'key' => PHUITagView::COLOR_INDIGO, 'name' => pht('Indigo'), ), array( 'key' => PHUITagView::COLOR_VIOLET, 'name' => pht('Violet'), ), array( 'key' => PHUITagView::COLOR_PINK, 'name' => pht('Pink'), ), array( 'key' => PHUITagView::COLOR_GREY, 'name' => pht('Grey'), ), array( 'key' => PHUITagView::COLOR_CHECKERED, 'name' => pht('Checkered'), ), ); } public static function validateColorConfiguration($config) { if (!is_array($config)) { throw new Exception( pht('Configuration must be a list of project color specifications.')); } $available_keys = self::getAvailableColorKeys(); $available_keys = array_fuse($available_keys); foreach ($config as $idx => $value) { if (!is_array($value)) { throw new Exception( pht( 'Value for index "%s" should be a dictionary.', $idx)); } PhutilTypeSpec::checkMap( $value, array( 'key' => 'string', 'name' => 'string', 'default' => 'optional bool', )); $key = $value['key']; if (!isset($available_keys[$key])) { throw new Exception( pht( 'Color key "%s" is not a valid color key. The supported color '. 'keys are: %s.', $key, implode(', ', $available_keys))); } } $default = null; $keys = array(); foreach ($config as $idx => $value) { $key = $value['key']; if (isset($keys[$key])) { throw new Exception( pht( 'Project colors must have unique keys, but two icons share the '. 'same key ("%s").', $key)); } else { $keys[$key] = true; } if (idx($value, 'default')) { if ($default === null) { $default = $value; } else { $original_key = $default['key']; throw new Exception( pht( 'Two different colors ("%s", "%s") are marked as the default '. 'color. Only one color may be marked as the default.', $key, $original_key)); } } } if ($default === null) { throw new Exception( pht( 'Project colors must include one color marked as the "%s" color, '. 'but no such color exists.', 'default')); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/icon/PhabricatorProjectDropEffect.php
src/applications/project/icon/PhabricatorProjectDropEffect.php
<?php final class PhabricatorProjectDropEffect extends Phobject { private $icon; private $color; private $content; private $conditions = array(); private $isTriggerEffect; private $isHeader; public function setIcon($icon) { $this->icon = $icon; return $this; } public function getIcon() { return $this->icon; } public function setColor($color) { $this->color = $color; return $this; } public function getColor() { return $this->color; } public function setContent($content) { $this->content = $content; return $this; } public function getContent() { return $this->content; } public function toDictionary() { return array( 'icon' => $this->getIcon(), 'color' => $this->getColor(), 'content' => hsprintf('%s', $this->getContent()), 'isTriggerEffect' => $this->getIsTriggerEffect(), 'isHeader' => $this->getIsHeader(), 'conditions' => $this->getConditions(), ); } public function addCondition($field, $operator, $value) { $this->conditions[] = array( 'field' => $field, 'operator' => $operator, 'value' => $value, ); return $this; } public function getConditions() { return $this->conditions; } public function setIsTriggerEffect($is_trigger_effect) { $this->isTriggerEffect = $is_trigger_effect; return $this; } public function getIsTriggerEffect() { return $this->isTriggerEffect; } public function setIsHeader($is_header) { $this->isHeader = $is_header; return $this; } public function getIsHeader() { return $this->isHeader; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectTriggerQuery.php
src/applications/project/query/PhabricatorProjectTriggerQuery.php
<?php final class PhabricatorProjectTriggerQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; private $phids; private $activeColumnMin; private $activeColumnMax; private $needUsage; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function needUsage($need_usage) { $this->needUsage = $need_usage; return $this; } public function withActiveColumnCountBetween($min, $max) { $this->activeColumnMin = $min; $this->activeColumnMax = $max; return $this; } public function newResultObject() { return new PhabricatorProjectTrigger(); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf( $conn, 'trigger.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'trigger.phid IN (%Ls)', $this->phids); } if ($this->activeColumnMin !== null) { $where[] = qsprintf( $conn, 'trigger_usage.activeColumnCount >= %d', $this->activeColumnMin); } if ($this->activeColumnMax !== null) { $where[] = qsprintf( $conn, 'trigger_usage.activeColumnCount <= %d', $this->activeColumnMax); } return $where; } protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { $joins = parent::buildJoinClauseParts($conn); if ($this->shouldJoinUsageTable()) { $joins[] = qsprintf( $conn, 'JOIN %R trigger_usage ON trigger.phid = trigger_usage.triggerPHID', new PhabricatorProjectTriggerUsage()); } return $joins; } private function shouldJoinUsageTable() { if ($this->activeColumnMin !== null) { return true; } if ($this->activeColumnMax !== null) { return true; } return false; } protected function didFilterPage(array $triggers) { if ($this->needUsage) { $usage_map = id(new PhabricatorProjectTriggerUsage())->loadAllWhere( 'triggerPHID IN (%Ls)', mpull($triggers, 'getPHID')); $usage_map = mpull($usage_map, null, 'getTriggerPHID'); foreach ($triggers as $trigger) { $trigger_phid = $trigger->getPHID(); $usage = idx($usage_map, $trigger_phid); if (!$usage) { $usage = id(new PhabricatorProjectTriggerUsage()) ->setTriggerPHID($trigger_phid) ->setExamplePHID(null) ->setColumnCount(0) ->setActiveColumnCount(0); } $trigger->attachUsage($usage); } } return $triggers; } public function getQueryApplicationClass() { return 'PhabricatorProjectApplication'; } protected function getPrimaryTableAlias() { return 'trigger'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectTransactionQuery.php
src/applications/project/query/PhabricatorProjectTransactionQuery.php
<?php final class PhabricatorProjectTransactionQuery extends PhabricatorApplicationTransactionQuery { public function getTemplateApplicationTransaction() { return new PhabricatorProjectTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectColumnSearchEngine.php
src/applications/project/query/PhabricatorProjectColumnSearchEngine.php
<?php final class PhabricatorProjectColumnSearchEngine extends PhabricatorApplicationSearchEngine { public function getResultTypeDescription() { return pht('Workboard Columns'); } public function getApplicationClassName() { return 'PhabricatorProjectApplication'; } public function canUseInPanelContext() { return false; } public function newQuery() { return new PhabricatorProjectColumnQuery(); } protected function buildCustomSearchFields() { return array( id(new PhabricatorPHIDsSearchField()) ->setLabel(pht('Projects')) ->setKey('projectPHIDs') ->setConduitKey('projects') ->setAliases(array('project', 'projects', 'projectPHID')), ); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); if ($map['projectPHIDs']) { $query->withProjectPHIDs($map['projectPHIDs']); } return $query; } protected function getURI($path) { // NOTE: There's no way to query columns in the web UI, at least for // the moment. return null; } protected function getBuiltinQueryNames() { $names = array(); $names['all'] = pht('All'); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $projects, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($projects, 'PhabricatorProjectColumn'); $viewer = $this->requireViewer(); return null; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectTriggerSearchEngine.php
src/applications/project/query/PhabricatorProjectTriggerSearchEngine.php
<?php final class PhabricatorProjectTriggerSearchEngine extends PhabricatorApplicationSearchEngine { public function getResultTypeDescription() { return pht('Triggers'); } public function getApplicationClassName() { return 'PhabricatorProjectApplication'; } public function newQuery() { return id(new PhabricatorProjectTriggerQuery()) ->needUsage(true); } protected function buildCustomSearchFields() { return array( id(new PhabricatorSearchThreeStateField()) ->setLabel(pht('Active')) ->setKey('isActive') ->setOptions( pht('(Show All)'), pht('Show Only Active Triggers'), pht('Show Only Inactive Triggers')), ); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); if ($map['isActive'] !== null) { if ($map['isActive']) { $query->withActiveColumnCountBetween(1, null); } else { $query->withActiveColumnCountBetween(null, 0); } } return $query; } protected function getURI($path) { return '/project/trigger/'.$path; } protected function getBuiltinQueryNames() { $names = array(); $names['active'] = pht('Active Triggers'); $names['all'] = pht('All Triggers'); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'active': return $query->setParameter('isActive', true); case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $triggers, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($triggers, 'PhabricatorProjectTrigger'); $viewer = $this->requireViewer(); $example_phids = array(); foreach ($triggers as $trigger) { $example_phid = $trigger->getUsage()->getExamplePHID(); if ($example_phid) { $example_phids[] = $example_phid; } } $handles = $viewer->loadHandles($example_phids); $list = id(new PHUIObjectItemListView()) ->setViewer($viewer); foreach ($triggers as $trigger) { $usage = $trigger->getUsage(); $column_handle = null; $have_column = false; $example_phid = $usage->getExamplePHID(); if ($example_phid) { $column_handle = $handles[$example_phid]; if ($column_handle->isComplete()) { if (!$column_handle->getPolicyFiltered()) { $have_column = true; } } } $column_count = $usage->getColumnCount(); $active_count = $usage->getActiveColumnCount(); if ($have_column) { if ($active_count > 1) { $usage_description = pht( 'Used on %s and %s other active column(s).', $column_handle->renderLink(), new PhutilNumber($active_count - 1)); } else if ($column_count > 1) { $usage_description = pht( 'Used on %s and %s other column(s).', $column_handle->renderLink(), new PhutilNumber($column_count - 1)); } else { $usage_description = pht( 'Used on %s.', $column_handle->renderLink()); } } else { if ($active_count) { $usage_description = pht( 'Used on %s active column(s).', new PhutilNumber($active_count)); } else if ($column_count) { $usage_description = pht( 'Used on %s column(s).', new PhutilNumber($column_count)); } else { $usage_description = pht( 'Unused trigger.'); } } $item = id(new PHUIObjectItemView()) ->setObjectName($trigger->getObjectName()) ->setHeader($trigger->getDisplayName()) ->setHref($trigger->getURI()) ->addAttribute($usage_description) ->setDisabled(!$active_count); $list->addItem($item); } return id(new PhabricatorApplicationSearchResultView()) ->setObjectList($list) ->setNoDataString(pht('No triggers found.')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectColumnQuery.php
src/applications/project/query/PhabricatorProjectColumnQuery.php
<?php final class PhabricatorProjectColumnQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; private $phids; private $projectPHIDs; private $proxyPHIDs; private $statuses; private $isProxyColumn; private $triggerPHIDs; private $needTriggers; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function withProjectPHIDs(array $project_phids) { $this->projectPHIDs = $project_phids; return $this; } public function withProxyPHIDs(array $proxy_phids) { $this->proxyPHIDs = $proxy_phids; return $this; } public function withStatuses(array $status) { $this->statuses = $status; return $this; } public function withIsProxyColumn($is_proxy) { $this->isProxyColumn = $is_proxy; return $this; } public function withTriggerPHIDs(array $trigger_phids) { $this->triggerPHIDs = $trigger_phids; return $this; } public function needTriggers($need_triggers) { $this->needTriggers = true; return $this; } public function newResultObject() { return new PhabricatorProjectColumn(); } protected function willFilterPage(array $page) { $projects = array(); $project_phids = array_filter(mpull($page, 'getProjectPHID')); if ($project_phids) { $projects = id(new PhabricatorProjectQuery()) ->setParentQuery($this) ->setViewer($this->getViewer()) ->withPHIDs($project_phids) ->execute(); $projects = mpull($projects, null, 'getPHID'); } foreach ($page as $key => $column) { $phid = $column->getProjectPHID(); $project = idx($projects, $phid); if (!$project) { $this->didRejectResult($page[$key]); unset($page[$key]); continue; } $column->attachProject($project); } $proxy_phids = array_filter(mpull($page, 'getProjectPHID')); return $page; } protected function didFilterPage(array $page) { $proxy_phids = array(); foreach ($page as $column) { $proxy_phid = $column->getProxyPHID(); if ($proxy_phid !== null) { $proxy_phids[$proxy_phid] = $proxy_phid; } } if ($proxy_phids) { $proxies = id(new PhabricatorObjectQuery()) ->setParentQuery($this) ->setViewer($this->getViewer()) ->withPHIDs($proxy_phids) ->execute(); $proxies = mpull($proxies, null, 'getPHID'); } else { $proxies = array(); } foreach ($page as $key => $column) { $proxy_phid = $column->getProxyPHID(); if ($proxy_phid !== null) { $proxy = idx($proxies, $proxy_phid); // Only attach valid proxies, so we don't end up getting surprised if // an install somehow gets junk into their database. if (!($proxy instanceof PhabricatorColumnProxyInterface)) { $proxy = null; } if (!$proxy) { $this->didRejectResult($column); unset($page[$key]); continue; } } else { $proxy = null; } $column->attachProxy($proxy); } if ($this->needTriggers) { $trigger_phids = array(); foreach ($page as $column) { if ($column->canHaveTrigger()) { $trigger_phid = $column->getTriggerPHID(); if ($trigger_phid) { $trigger_phids[] = $trigger_phid; } } } if ($trigger_phids) { $triggers = id(new PhabricatorProjectTriggerQuery()) ->setViewer($this->getViewer()) ->setParentQuery($this) ->withPHIDs($trigger_phids) ->execute(); $triggers = mpull($triggers, null, 'getPHID'); } else { $triggers = array(); } foreach ($page as $column) { $trigger = null; if ($column->canHaveTrigger()) { $trigger_phid = $column->getTriggerPHID(); if ($trigger_phid) { $trigger = idx($triggers, $trigger_phid); } } $column->attachTrigger($trigger); } } return $page; } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); } if ($this->projectPHIDs !== null) { $where[] = qsprintf( $conn, 'projectPHID IN (%Ls)', $this->projectPHIDs); } if ($this->proxyPHIDs !== null) { $where[] = qsprintf( $conn, 'proxyPHID IN (%Ls)', $this->proxyPHIDs); } if ($this->statuses !== null) { $where[] = qsprintf( $conn, 'status IN (%Ld)', $this->statuses); } if ($this->triggerPHIDs !== null) { $where[] = qsprintf( $conn, 'triggerPHID IN (%Ls)', $this->triggerPHIDs); } if ($this->isProxyColumn !== null) { if ($this->isProxyColumn) { $where[] = qsprintf($conn, 'proxyPHID IS NOT NULL'); } else { $where[] = qsprintf($conn, 'proxyPHID IS NULL'); } } return $where; } public function getQueryApplicationClass() { return 'PhabricatorProjectApplication'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectColumnTransactionQuery.php
src/applications/project/query/PhabricatorProjectColumnTransactionQuery.php
<?php final class PhabricatorProjectColumnTransactionQuery extends PhabricatorApplicationTransactionQuery { public function getTemplateApplicationTransaction() { return new PhabricatorProjectColumnTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectTriggerTransactionQuery.php
src/applications/project/query/PhabricatorProjectTriggerTransactionQuery.php
<?php final class PhabricatorProjectTriggerTransactionQuery extends PhabricatorApplicationTransactionQuery { public function getTemplateApplicationTransaction() { return new PhabricatorProjectTriggerTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectColumnPositionQuery.php
src/applications/project/query/PhabricatorProjectColumnPositionQuery.php
<?php final class PhabricatorProjectColumnPositionQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; private $boardPHIDs; private $objectPHIDs; private $columnPHIDs; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withBoardPHIDs(array $board_phids) { $this->boardPHIDs = $board_phids; return $this; } public function withObjectPHIDs(array $object_phids) { $this->objectPHIDs = $object_phids; return $this; } public function withColumnPHIDs(array $column_phids) { $this->columnPHIDs = $column_phids; return $this; } public function newResultObject() { return new PhabricatorProjectColumnPosition(); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->boardPHIDs !== null) { $where[] = qsprintf( $conn, 'boardPHID IN (%Ls)', $this->boardPHIDs); } if ($this->objectPHIDs !== null) { $where[] = qsprintf( $conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); } if ($this->columnPHIDs !== null) { $where[] = qsprintf( $conn, 'columnPHID IN (%Ls)', $this->columnPHIDs); } return $where; } public function getQueryApplicationClass() { return 'PhabricatorProjectApplication'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectQuery.php
src/applications/project/query/PhabricatorProjectQuery.php
<?php final class PhabricatorProjectQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; private $phids; private $memberPHIDs; private $watcherPHIDs; private $slugs; private $slugNormals; private $slugMap; private $allSlugs; private $names; private $namePrefixes; private $nameTokens; private $icons; private $colors; private $ancestorPHIDs; private $parentPHIDs; private $isMilestone; private $hasSubprojects; private $minDepth; private $maxDepth; private $minMilestoneNumber; private $maxMilestoneNumber; private $subtypes; private $status = 'status-any'; const STATUS_ANY = 'status-any'; const STATUS_OPEN = 'status-open'; const STATUS_CLOSED = 'status-closed'; const STATUS_ACTIVE = 'status-active'; const STATUS_ARCHIVED = 'status-archived'; private $statuses; private $needSlugs; private $needMembers; private $needAncestorMembers; private $needWatchers; private $needImages; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function withStatus($status) { $this->status = $status; return $this; } public function withStatuses(array $statuses) { $this->statuses = $statuses; return $this; } public function withMemberPHIDs(array $member_phids) { $this->memberPHIDs = $member_phids; return $this; } public function withWatcherPHIDs(array $watcher_phids) { $this->watcherPHIDs = $watcher_phids; return $this; } public function withSlugs(array $slugs) { $this->slugs = $slugs; return $this; } public function withNames(array $names) { $this->names = $names; return $this; } public function withNamePrefixes(array $prefixes) { $this->namePrefixes = $prefixes; return $this; } public function withNameTokens(array $tokens) { $this->nameTokens = array_values($tokens); return $this; } public function withIcons(array $icons) { $this->icons = $icons; return $this; } public function withColors(array $colors) { $this->colors = $colors; return $this; } public function withParentProjectPHIDs($parent_phids) { $this->parentPHIDs = $parent_phids; return $this; } public function withAncestorProjectPHIDs($ancestor_phids) { $this->ancestorPHIDs = $ancestor_phids; return $this; } public function withIsMilestone($is_milestone) { $this->isMilestone = $is_milestone; return $this; } public function withHasSubprojects($has_subprojects) { $this->hasSubprojects = $has_subprojects; return $this; } public function withDepthBetween($min, $max) { $this->minDepth = $min; $this->maxDepth = $max; return $this; } public function withMilestoneNumberBetween($min, $max) { $this->minMilestoneNumber = $min; $this->maxMilestoneNumber = $max; return $this; } public function withSubtypes(array $subtypes) { $this->subtypes = $subtypes; return $this; } public function needMembers($need_members) { $this->needMembers = $need_members; return $this; } public function needAncestorMembers($need_ancestor_members) { $this->needAncestorMembers = $need_ancestor_members; return $this; } public function needWatchers($need_watchers) { $this->needWatchers = $need_watchers; return $this; } public function needImages($need_images) { $this->needImages = $need_images; return $this; } public function needSlugs($need_slugs) { $this->needSlugs = $need_slugs; return $this; } public function newResultObject() { return new PhabricatorProject(); } protected function getDefaultOrderVector() { return array('name'); } public function getBuiltinOrders() { return array( 'name' => array( 'vector' => array('name'), 'name' => pht('Name'), ), ) + parent::getBuiltinOrders(); } public function getOrderableColumns() { return parent::getOrderableColumns() + array( 'name' => array( 'table' => $this->getPrimaryTableAlias(), 'column' => 'name', 'reverse' => true, 'type' => 'string', 'unique' => true, ), 'milestoneNumber' => array( 'table' => $this->getPrimaryTableAlias(), 'column' => 'milestoneNumber', 'type' => 'int', ), 'status' => array( 'table' => $this->getPrimaryTableAlias(), 'column' => 'status', 'type' => 'int', ), ); } protected function newPagingMapFromPartialObject($object) { return array( 'id' => (int)$object->getID(), 'name' => $object->getName(), 'status' => $object->getStatus(), ); } public function getSlugMap() { if ($this->slugMap === null) { throw new PhutilInvalidStateException('execute'); } return $this->slugMap; } protected function willExecute() { $this->slugMap = array(); $this->slugNormals = array(); $this->allSlugs = array(); if ($this->slugs) { foreach ($this->slugs as $slug) { if (PhabricatorSlug::isValidProjectSlug($slug)) { $normal = PhabricatorSlug::normalizeProjectSlug($slug); $this->slugNormals[$slug] = $normal; $this->allSlugs[$normal] = $normal; } // NOTE: At least for now, we query for the normalized slugs but also // for the slugs exactly as entered. This allows older projects with // slugs that are no longer valid to continue to work. $this->allSlugs[$slug] = $slug; } } } protected function willFilterPage(array $projects) { $ancestor_paths = array(); foreach ($projects as $project) { foreach ($project->getAncestorProjectPaths() as $path) { $ancestor_paths[$path] = $path; } } if ($ancestor_paths) { $ancestors = id(new PhabricatorProject())->loadAllWhere( 'projectPath IN (%Ls)', $ancestor_paths); } else { $ancestors = array(); } $projects = $this->linkProjectGraph($projects, $ancestors); $viewer_phid = $this->getViewer()->getPHID(); $material_type = PhabricatorProjectMaterializedMemberEdgeType::EDGECONST; $watcher_type = PhabricatorObjectHasWatcherEdgeType::EDGECONST; $types = array(); $types[] = $material_type; if ($this->needWatchers) { $types[] = $watcher_type; } $all_graph = $this->getAllReachableAncestors($projects); // See T13484. If the graph is damaged (and contains a cycle or an edge // pointing at a project which has been destroyed), some of the nodes we // started with may be filtered out by reachability tests. If any of the // projects we are linking up don't have available ancestors, filter them // out. foreach ($projects as $key => $project) { $project_phid = $project->getPHID(); if (!isset($all_graph[$project_phid])) { $this->didRejectResult($project); unset($projects[$key]); continue; } } if (!$projects) { return array(); } // NOTE: Although we may not need much information about ancestors, we // always need to test if the viewer is a member, because we will return // ancestor projects to the policy filter via ExtendedPolicy calls. If // we skip populating membership data on a parent, the policy framework // will think the user is not a member of the parent project. $all_sources = array(); foreach ($all_graph as $project) { // For milestones, we need parent members. if ($project->isMilestone()) { $parent_phid = $project->getParentProjectPHID(); $all_sources[$parent_phid] = $parent_phid; } $phid = $project->getPHID(); $all_sources[$phid] = $phid; } $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($all_sources) ->withEdgeTypes($types); $need_all_edges = $this->needMembers || $this->needWatchers || $this->needAncestorMembers; // If we only need to know if the viewer is a member, we can restrict // the query to just their PHID. $any_edges = true; if (!$need_all_edges) { if ($viewer_phid) { $edge_query->withDestinationPHIDs(array($viewer_phid)); } else { // If we don't need members or watchers and don't have a viewer PHID // (viewer is logged-out or omnipotent), they'll never be a member // so we don't need to issue this query at all. $any_edges = false; } } if ($any_edges) { $edge_query->execute(); } $membership_projects = array(); foreach ($all_graph as $project) { $project_phid = $project->getPHID(); if ($project->isMilestone()) { $source_phids = array($project->getParentProjectPHID()); } else { $source_phids = array($project_phid); } if ($any_edges) { $member_phids = $edge_query->getDestinationPHIDs( $source_phids, array($material_type)); } else { $member_phids = array(); } if (in_array($viewer_phid, $member_phids)) { $membership_projects[$project_phid] = $project; } if ($this->needMembers || $this->needAncestorMembers) { $project->attachMemberPHIDs($member_phids); } if ($this->needWatchers) { $watcher_phids = $edge_query->getDestinationPHIDs( array($project_phid), array($watcher_type)); $project->attachWatcherPHIDs($watcher_phids); $project->setIsUserWatcher( $viewer_phid, in_array($viewer_phid, $watcher_phids)); } } // If we loaded ancestor members, we've already populated membership // lists above, so we can skip this step. if (!$this->needAncestorMembers) { $member_graph = $this->getAllReachableAncestors($membership_projects); foreach ($all_graph as $phid => $project) { $is_member = isset($member_graph[$phid]); $project->setIsUserMember($viewer_phid, $is_member); } } return $projects; } protected function didFilterPage(array $projects) { $viewer = $this->getViewer(); if ($this->needImages) { $need_images = $projects; // First, try to load custom profile images for any projects with custom // images. $file_phids = array(); foreach ($need_images as $key => $project) { $image_phid = $project->getProfileImagePHID(); if ($image_phid) { $file_phids[$key] = $image_phid; } } if ($file_phids) { $files = id(new PhabricatorFileQuery()) ->setParentQuery($this) ->setViewer($viewer) ->withPHIDs($file_phids) ->execute(); $files = mpull($files, null, 'getPHID'); foreach ($file_phids as $key => $image_phid) { $file = idx($files, $image_phid); if (!$file) { continue; } $need_images[$key]->attachProfileImageFile($file); unset($need_images[$key]); } } // For projects with default images, or projects where the custom image // failed to load, load a builtin image. if ($need_images) { $builtin_map = array(); $builtins = array(); foreach ($need_images as $key => $project) { $icon = $project->getIcon(); $builtin_name = PhabricatorProjectIconSet::getIconImage($icon); $builtin_name = 'projects/'.$builtin_name; $builtin = id(new PhabricatorFilesOnDiskBuiltinFile()) ->setName($builtin_name); $builtin_key = $builtin->getBuiltinFileKey(); $builtins[] = $builtin; $builtin_map[$key] = $builtin_key; } $builtin_files = PhabricatorFile::loadBuiltins( $viewer, $builtins); foreach ($need_images as $key => $project) { $builtin_key = $builtin_map[$key]; $builtin_file = $builtin_files[$builtin_key]; $project->attachProfileImageFile($builtin_file); } } } $this->loadSlugs($projects); return $projects; } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->status != self::STATUS_ANY) { switch ($this->status) { case self::STATUS_OPEN: case self::STATUS_ACTIVE: $filter = array( PhabricatorProjectStatus::STATUS_ACTIVE, ); break; case self::STATUS_CLOSED: case self::STATUS_ARCHIVED: $filter = array( PhabricatorProjectStatus::STATUS_ARCHIVED, ); break; default: throw new Exception( pht( "Unknown project status '%s'!", $this->status)); } $where[] = qsprintf( $conn, 'project.status IN (%Ld)', $filter); } if ($this->statuses !== null) { $where[] = qsprintf( $conn, 'project.status IN (%Ls)', $this->statuses); } if ($this->ids !== null) { $where[] = qsprintf( $conn, 'project.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'project.phid IN (%Ls)', $this->phids); } if ($this->memberPHIDs !== null) { $where[] = qsprintf( $conn, 'e.dst IN (%Ls)', $this->memberPHIDs); } if ($this->watcherPHIDs !== null) { $where[] = qsprintf( $conn, 'w.dst IN (%Ls)', $this->watcherPHIDs); } if ($this->slugs !== null) { $where[] = qsprintf( $conn, 'slug.slug IN (%Ls)', $this->allSlugs); } if ($this->names !== null) { $where[] = qsprintf( $conn, 'project.name IN (%Ls)', $this->names); } if ($this->namePrefixes) { $parts = array(); foreach ($this->namePrefixes as $name_prefix) { $parts[] = qsprintf( $conn, 'project.name LIKE %>', $name_prefix); } $where[] = qsprintf($conn, '%LO', $parts); } if ($this->icons !== null) { $where[] = qsprintf( $conn, 'project.icon IN (%Ls)', $this->icons); } if ($this->colors !== null) { $where[] = qsprintf( $conn, 'project.color IN (%Ls)', $this->colors); } if ($this->parentPHIDs !== null) { $where[] = qsprintf( $conn, 'project.parentProjectPHID IN (%Ls)', $this->parentPHIDs); } if ($this->ancestorPHIDs !== null) { $ancestor_paths = queryfx_all( $conn, 'SELECT projectPath, projectDepth FROM %T WHERE phid IN (%Ls)', id(new PhabricatorProject())->getTableName(), $this->ancestorPHIDs); if (!$ancestor_paths) { throw new PhabricatorEmptyQueryException(); } $sql = array(); foreach ($ancestor_paths as $ancestor_path) { $sql[] = qsprintf( $conn, '(project.projectPath LIKE %> AND project.projectDepth > %d)', $ancestor_path['projectPath'], $ancestor_path['projectDepth']); } $where[] = qsprintf($conn, '%LO', $sql); $where[] = qsprintf( $conn, 'project.parentProjectPHID IS NOT NULL'); } if ($this->isMilestone !== null) { if ($this->isMilestone) { $where[] = qsprintf( $conn, 'project.milestoneNumber IS NOT NULL'); } else { $where[] = qsprintf( $conn, 'project.milestoneNumber IS NULL'); } } if ($this->hasSubprojects !== null) { $where[] = qsprintf( $conn, 'project.hasSubprojects = %d', (int)$this->hasSubprojects); } if ($this->minDepth !== null) { $where[] = qsprintf( $conn, 'project.projectDepth >= %d', $this->minDepth); } if ($this->maxDepth !== null) { $where[] = qsprintf( $conn, 'project.projectDepth <= %d', $this->maxDepth); } if ($this->minMilestoneNumber !== null) { $where[] = qsprintf( $conn, 'project.milestoneNumber >= %d', $this->minMilestoneNumber); } if ($this->maxMilestoneNumber !== null) { $where[] = qsprintf( $conn, 'project.milestoneNumber <= %d', $this->maxMilestoneNumber); } if ($this->subtypes !== null) { $where[] = qsprintf( $conn, 'project.subtype IN (%Ls)', $this->subtypes); } return $where; } protected function shouldGroupQueryResultRows() { if ($this->memberPHIDs || $this->watcherPHIDs || $this->nameTokens) { return true; } if ($this->slugs) { return true; } return parent::shouldGroupQueryResultRows(); } protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { $joins = parent::buildJoinClauseParts($conn); if ($this->memberPHIDs !== null) { $joins[] = qsprintf( $conn, 'JOIN %T e ON e.src = project.phid AND e.type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorProjectMaterializedMemberEdgeType::EDGECONST); } if ($this->watcherPHIDs !== null) { $joins[] = qsprintf( $conn, 'JOIN %T w ON w.src = project.phid AND w.type = %d', PhabricatorEdgeConfig::TABLE_NAME_EDGE, PhabricatorObjectHasWatcherEdgeType::EDGECONST); } if ($this->slugs !== null) { $joins[] = qsprintf( $conn, 'JOIN %T slug on slug.projectPHID = project.phid', id(new PhabricatorProjectSlug())->getTableName()); } if ($this->nameTokens !== null) { $name_tokens = $this->getNameTokensForQuery($this->nameTokens); foreach ($name_tokens as $key => $token) { $token_table = 'token_'.$key; $joins[] = qsprintf( $conn, 'JOIN %T %T ON %T.projectID = project.id AND %T.token LIKE %>', PhabricatorProject::TABLE_DATASOURCE_TOKEN, $token_table, $token_table, $token_table, $token); } } return $joins; } public function getQueryApplicationClass() { return 'PhabricatorProjectApplication'; } protected function getPrimaryTableAlias() { return 'project'; } private function linkProjectGraph(array $projects, array $ancestors) { $ancestor_map = mpull($ancestors, null, 'getPHID'); $projects_map = mpull($projects, null, 'getPHID'); $all_map = $projects_map + $ancestor_map; $done = array(); foreach ($projects as $key => $project) { $seen = array($project->getPHID() => true); if (!$this->linkProject($project, $all_map, $done, $seen)) { $this->didRejectResult($project); unset($projects[$key]); continue; } foreach ($project->getAncestorProjects() as $ancestor) { $seen[$ancestor->getPHID()] = true; } } return $projects; } private function linkProject($project, array $all, array $done, array $seen) { $parent_phid = $project->getParentProjectPHID(); // This project has no parent, so just attach `null` and return. if (!$parent_phid) { $project->attachParentProject(null); return true; } // This project has a parent, but it failed to load. if (empty($all[$parent_phid])) { return false; } // Test for graph cycles. If we encounter one, we're going to hide the // entire cycle since we can't meaningfully resolve it. if (isset($seen[$parent_phid])) { return false; } $seen[$parent_phid] = true; $parent = $all[$parent_phid]; $project->attachParentProject($parent); if (!empty($done[$parent_phid])) { return true; } return $this->linkProject($parent, $all, $done, $seen); } private function getAllReachableAncestors(array $projects) { $ancestors = array(); $seen = mpull($projects, null, 'getPHID'); $stack = $projects; while ($stack) { $project = array_pop($stack); $phid = $project->getPHID(); $ancestors[$phid] = $project; $parent_phid = $project->getParentProjectPHID(); if (!$parent_phid) { continue; } if (isset($seen[$parent_phid])) { continue; } $seen[$parent_phid] = true; $stack[] = $project->getParentProject(); } return $ancestors; } private function loadSlugs(array $projects) { // Build a map from primary slugs to projects. $primary_map = array(); foreach ($projects as $project) { $primary_slug = $project->getPrimarySlug(); if ($primary_slug === null) { continue; } $primary_map[$primary_slug] = $project; } // Link up all of the queried slugs which correspond to primary // slugs. If we can link up everything from this (no slugs were queried, // or only primary slugs were queried) we don't need to load anything // else. $unknown = $this->slugNormals; foreach ($unknown as $input => $normal) { if (isset($primary_map[$input])) { $match = $input; } else if (isset($primary_map[$normal])) { $match = $normal; } else { continue; } $this->slugMap[$input] = array( 'slug' => $match, 'projectPHID' => $primary_map[$match]->getPHID(), ); unset($unknown[$input]); } // If we need slugs, we have to load everything. // If we still have some queried slugs which we haven't mapped, we only // need to look for them. // If we've mapped everything, we don't have to do any work. $project_phids = mpull($projects, 'getPHID'); if ($this->needSlugs) { $slugs = id(new PhabricatorProjectSlug())->loadAllWhere( 'projectPHID IN (%Ls)', $project_phids); } else if ($unknown) { $slugs = id(new PhabricatorProjectSlug())->loadAllWhere( 'projectPHID IN (%Ls) AND slug IN (%Ls)', $project_phids, $unknown); } else { $slugs = array(); } // Link up any slugs we were not able to link up earlier. $extra_map = mpull($slugs, 'getProjectPHID', 'getSlug'); foreach ($unknown as $input => $normal) { if (isset($extra_map[$input])) { $match = $input; } else if (isset($extra_map[$normal])) { $match = $normal; } else { continue; } $this->slugMap[$input] = array( 'slug' => $match, 'projectPHID' => $extra_map[$match], ); unset($unknown[$input]); } if ($this->needSlugs) { $slug_groups = mgroup($slugs, 'getProjectPHID'); foreach ($projects as $project) { $project_slugs = idx($slug_groups, $project->getPHID(), array()); $project->attachSlugs($project_slugs); } } } private function getNameTokensForQuery(array $tokens) { // When querying for projects by name, only actually search for the five // longest tokens. MySQL can get grumpy with a large number of JOINs // with LIKEs and queries for more than 5 tokens are essentially never // legitimate searches for projects, but users copy/pasting nonsense. // See also PHI47. $length_map = array(); foreach ($tokens as $token) { $length_map[$token] = strlen($token); } arsort($length_map); $length_map = array_slice($length_map, 0, 5, true); return array_keys($length_map); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/query/PhabricatorProjectSearchEngine.php
src/applications/project/query/PhabricatorProjectSearchEngine.php
<?php final class PhabricatorProjectSearchEngine extends PhabricatorApplicationSearchEngine { public function getResultTypeDescription() { return pht('Projects'); } public function getApplicationClassName() { return 'PhabricatorProjectApplication'; } public function newQuery() { return id(new PhabricatorProjectQuery()) ->needImages(true) ->needMembers(true) ->needWatchers(true); } protected function buildCustomSearchFields() { $subtype_map = id(new PhabricatorProject())->newEditEngineSubtypeMap(); $hide_subtypes = ($subtype_map->getCount() == 1); return array( id(new PhabricatorSearchTextField()) ->setLabel(pht('Name')) ->setKey('name') ->setDescription( pht( '(Deprecated.) Search for projects with a given name or '. 'hashtag using tokenizer/datasource query matching rules. This '. 'is deprecated in favor of the more powerful "query" '. 'constraint.')), id(new PhabricatorSearchStringListField()) ->setLabel(pht('Slugs')) ->setIsHidden(true) ->setKey('slugs') ->setDescription( pht( 'Search for projects with particular slugs. (Slugs are the same '. 'as project hashtags.)')), id(new PhabricatorUsersSearchField()) ->setLabel(pht('Members')) ->setKey('memberPHIDs') ->setConduitKey('members') ->setAliases(array('member', 'members')), id(new PhabricatorUsersSearchField()) ->setLabel(pht('Watchers')) ->setKey('watcherPHIDs') ->setConduitKey('watchers') ->setAliases(array('watcher', 'watchers')), id(new PhabricatorSearchSelectField()) ->setLabel(pht('Status')) ->setKey('status') ->setOptions($this->getStatusOptions()), id(new PhabricatorSearchThreeStateField()) ->setLabel(pht('Milestones')) ->setKey('isMilestone') ->setOptions( pht('(Show All)'), pht('Show Only Milestones'), pht('Hide Milestones')) ->setDescription( pht( 'Pass true to find only milestones, or false to omit '. 'milestones.')), id(new PhabricatorSearchThreeStateField()) ->setLabel(pht('Root Projects')) ->setKey('isRoot') ->setOptions( pht('(Show All)'), pht('Show Only Root Projects'), pht('Hide Root Projects')) ->setDescription( pht( 'Pass true to find only root projects, or false to omit '. 'root projects.')), id(new PhabricatorSearchIntField()) ->setLabel(pht('Minimum Depth')) ->setKey('minDepth') ->setIsHidden(true) ->setDescription( pht( 'Find projects with a given minimum depth. Root projects '. 'have depth 0, their immediate children have depth 1, and '. 'so on.')), id(new PhabricatorSearchIntField()) ->setLabel(pht('Maximum Depth')) ->setKey('maxDepth') ->setIsHidden(true) ->setDescription( pht( 'Find projects with a given maximum depth. Root projects '. 'have depth 0, their immediate children have depth 1, and '. 'so on.')), id(new PhabricatorSearchDatasourceField()) ->setLabel(pht('Subtypes')) ->setKey('subtypes') ->setAliases(array('subtype')) ->setDescription( pht('Search for projects with given subtypes.')) ->setDatasource(new PhabricatorProjectSubtypeDatasource()) ->setIsHidden($hide_subtypes), id(new PhabricatorSearchCheckboxesField()) ->setLabel(pht('Icons')) ->setKey('icons') ->setOptions($this->getIconOptions()), id(new PhabricatorSearchCheckboxesField()) ->setLabel(pht('Colors')) ->setKey('colors') ->setOptions($this->getColorOptions()), id(new PhabricatorPHIDsSearchField()) ->setLabel(pht('Parent Projects')) ->setKey('parentPHIDs') ->setConduitKey('parents') ->setAliases(array('parent', 'parents', 'parentPHID')) ->setDescription(pht('Find direct subprojects of specified parents.')), id(new PhabricatorPHIDsSearchField()) ->setLabel(pht('Ancestor Projects')) ->setKey('ancestorPHIDs') ->setConduitKey('ancestors') ->setAliases(array('ancestor', 'ancestors', 'ancestorPHID')) ->setDescription( pht('Find all subprojects beneath specified ancestors.')), ); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); if (strlen($map['name'])) { $tokens = PhabricatorTypeaheadDatasource::tokenizeString($map['name']); $query->withNameTokens($tokens); } if ($map['slugs']) { $query->withSlugs($map['slugs']); } if ($map['memberPHIDs']) { $query->withMemberPHIDs($map['memberPHIDs']); } if ($map['watcherPHIDs']) { $query->withWatcherPHIDs($map['watcherPHIDs']); } if ($map['status']) { $status = idx($this->getStatusValues(), $map['status']); if ($status) { $query->withStatus($status); } } if ($map['icons']) { $query->withIcons($map['icons']); } if ($map['colors']) { $query->withColors($map['colors']); } if ($map['isMilestone'] !== null) { $query->withIsMilestone($map['isMilestone']); } $min_depth = $map['minDepth']; $max_depth = $map['maxDepth']; if ($min_depth !== null || $max_depth !== null) { if ($min_depth !== null && $max_depth !== null) { if ($min_depth > $max_depth) { throw new Exception( pht( 'Search constraint "minDepth" must be no larger than '. 'search constraint "maxDepth".')); } } } if ($map['isRoot'] !== null) { if ($map['isRoot']) { if ($max_depth === null) { $max_depth = 0; } else { $max_depth = min(0, $max_depth); } $query->withDepthBetween(null, 0); } else { if ($min_depth === null) { $min_depth = 1; } else { $min_depth = max($min_depth, 1); } } } if ($min_depth !== null || $max_depth !== null) { $query->withDepthBetween($min_depth, $max_depth); } if ($map['parentPHIDs']) { $query->withParentProjectPHIDs($map['parentPHIDs']); } if ($map['ancestorPHIDs']) { $query->withAncestorProjectPHIDs($map['ancestorPHIDs']); } if ($map['subtypes']) { $query->withSubtypes($map['subtypes']); } return $query; } protected function getURI($path) { return '/project/'.$path; } protected function getBuiltinQueryNames() { $names = array(); if ($this->requireViewer()->isLoggedIn()) { $names['joined'] = pht('Joined'); } if ($this->requireViewer()->isLoggedIn()) { $names['watching'] = pht('Watching'); } $names['active'] = pht('Active'); $names['all'] = pht('All'); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); $viewer_phid = $this->requireViewer()->getPHID(); // By default, do not show milestones in the list view. $query->setParameter('isMilestone', false); switch ($query_key) { case 'all': return $query; case 'active': return $query ->setParameter('status', 'active'); case 'joined': return $query ->setParameter('memberPHIDs', array($viewer_phid)) ->setParameter('status', 'active'); case 'watching': return $query ->setParameter('watcherPHIDs', array($viewer_phid)) ->setParameter('status', 'active'); } return parent::buildSavedQueryFromBuiltin($query_key); } private function getStatusOptions() { return array( 'active' => pht('Show Only Active Projects'), 'archived' => pht('Show Only Archived Projects'), 'all' => pht('Show All Projects'), ); } private function getStatusValues() { return array( 'active' => PhabricatorProjectQuery::STATUS_ACTIVE, 'archived' => PhabricatorProjectQuery::STATUS_ARCHIVED, 'all' => PhabricatorProjectQuery::STATUS_ANY, ); } private function getIconOptions() { $options = array(); $set = new PhabricatorProjectIconSet(); foreach ($set->getIcons() as $icon) { if ($icon->getIsDisabled()) { continue; } $options[$icon->getKey()] = array( id(new PHUIIconView()) ->setIcon($icon->getIcon()), ' ', $icon->getLabel(), ); } return $options; } private function getColorOptions() { $options = array(); foreach (PhabricatorProjectIconSet::getColorMap() as $color => $name) { $options[$color] = array( id(new PHUITagView()) ->setType(PHUITagView::TYPE_SHADE) ->setColor($color) ->setName($name), ); } return $options; } protected function renderResultList( array $projects, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($projects, 'PhabricatorProject'); $viewer = $this->requireViewer(); $list = id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($projects) ->setShowWatching(true) ->setShowMember(true) ->renderList(); return id(new PhabricatorApplicationSearchResultView()) ->setObjectList($list) ->setNoDataString(pht('No projects found.')); } protected function getNewUserBody() { $create_button = id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Create a Project')) ->setHref('/project/edit/') ->setColor(PHUIButtonView::GREEN); $icon = $this->getApplication()->getIcon(); $app_name = $this->getApplication()->getName(); $view = id(new PHUIBigInfoView()) ->setIcon($icon) ->setTitle(pht('Welcome to %s', $app_name)) ->setDescription( pht('Projects are flexible storage containers used as '. 'tags, teams, projects, or anything you need to group.')) ->addAction($create_button); return $view; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/mail/ProjectReplyHandler.php
src/applications/project/mail/ProjectReplyHandler.php
<?php final class ProjectReplyHandler extends PhabricatorApplicationTransactionReplyHandler { public function validateMailReceiver($mail_receiver) { if (!($mail_receiver instanceof PhabricatorProject)) { throw new Exception( pht('Mail receiver is not a %s.', 'PhabricatorProject')); } } public function getObjectPrefix() { return PhabricatorProjectProjectPHIDType::TYPECONST; } protected function shouldCreateCommentFromMailBody() { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/command/ProjectAddProjectsEmailCommand.php
src/applications/project/command/ProjectAddProjectsEmailCommand.php
<?php final class ProjectAddProjectsEmailCommand extends MetaMTAEmailTransactionCommand { public function getCommand() { return 'projects'; } public function getCommandSyntax() { return '**!projects** //#project ...//'; } public function getCommandSummary() { return pht('Add related projects.'); } public function getCommandDescription() { return pht( 'Add one or more projects to the object by listing their hashtags. '. 'Separate projects with spaces. For example, use `!projects #ios '. '#feature` to add both related projects.'. "\n\n". 'Projects which are invalid or unrecognized will be ignored. This '. 'command has no effect if you do not specify any projects.'); } public function getCommandAliases() { return array( 'project', ); } public function isCommandSupportedForObject( PhabricatorApplicationTransactionInterface $object) { return ($object instanceof PhabricatorProjectInterface); } public function buildTransactions( PhabricatorUser $viewer, PhabricatorApplicationTransactionInterface $object, PhabricatorMetaMTAReceivedMail $mail, $command, array $argv) { $project_phids = id(new PhabricatorObjectListQuery()) ->setViewer($viewer) ->setAllowedTypes( array( PhabricatorProjectProjectPHIDType::TYPECONST, )) ->setObjectList(implode(' ', $argv)) ->setAllowPartialResults(true) ->execute(); $xactions = array(); $type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = $object->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $type_project) ->setNewValue( array( '+' => array_fuse($project_phids), )); return $xactions; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/interface/PhabricatorProjectInterface.php
src/applications/project/interface/PhabricatorProjectInterface.php
<?php interface PhabricatorProjectInterface {}
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/interface/PhabricatorWorkboardInterface.php
src/applications/project/interface/PhabricatorWorkboardInterface.php
<?php interface PhabricatorWorkboardInterface {}
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/interface/PhabricatorColumnProxyInterface.php
src/applications/project/interface/PhabricatorColumnProxyInterface.php
<?php interface PhabricatorColumnProxyInterface { public function getProxyColumnName(); }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/customfield/PhabricatorProjectDescriptionField.php
src/applications/project/customfield/PhabricatorProjectDescriptionField.php
<?php final class PhabricatorProjectDescriptionField extends PhabricatorProjectStandardCustomField { public function createFields($object) { return PhabricatorStandardCustomField::buildStandardFields( $this, array( 'description' => array( 'name' => pht('Description'), 'type' => 'remarkup', 'description' => pht('Short project description.'), 'fulltext' => PhabricatorSearchDocumentFieldType::FIELD_BODY, ), ), $internal = true); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/customfield/PhabricatorProjectStandardCustomField.php
src/applications/project/customfield/PhabricatorProjectStandardCustomField.php
<?php abstract class PhabricatorProjectStandardCustomField extends PhabricatorProjectCustomField implements PhabricatorStandardCustomFieldInterface { public function getStandardCustomFieldNamespace() { return 'project:internal'; } public function newStorageObject() { return new PhabricatorProjectCustomFieldStorage(); } protected function newStringIndexStorage() { return new PhabricatorProjectCustomFieldStringIndex(); } protected function newNumericIndexStorage() { return new PhabricatorProjectCustomFieldNumericIndex(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/customfield/PhabricatorProjectConfiguredCustomField.php
src/applications/project/customfield/PhabricatorProjectConfiguredCustomField.php
<?php final class PhabricatorProjectConfiguredCustomField extends PhabricatorProjectStandardCustomField implements PhabricatorStandardCustomFieldInterface { public function getStandardCustomFieldNamespace() { return 'project'; } public function createFields($object) { return PhabricatorStandardCustomField::buildStandardFields( $this, PhabricatorEnv::getEnvConfig('projects.custom-field-definitions')); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/customfield/PhabricatorProjectCustomField.php
src/applications/project/customfield/PhabricatorProjectCustomField.php
<?php abstract class PhabricatorProjectCustomField extends PhabricatorCustomField { public function newStorageObject() { return new PhabricatorProjectCustomFieldStorage(); } protected function newStringIndexStorage() { return new PhabricatorProjectCustomFieldStringIndex(); } protected function newNumericIndexStorage() { return new PhabricatorProjectCustomFieldNumericIndex(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/editor/PhabricatorProjectTriggerEditor.php
src/applications/project/editor/PhabricatorProjectTriggerEditor.php
<?php final class PhabricatorProjectTriggerEditor extends PhabricatorApplicationTransactionEditor { public function getEditorApplicationClass() { return 'PhabricatorProjectApplication'; } public function getEditorObjectsDescription() { return pht('Triggers'); } public function getCreateObjectTitle($author, $object) { return pht('%s created this trigger.', $author); } public function getCreateObjectTitleForFeed($author, $object) { return pht('%s created %s.', $author, $object); } public function getTransactionTypes() { $types = parent::getTransactionTypes(); $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; return $types; } protected function supportsSearch() { return true; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/editor/PhabricatorProjectColumnTransactionEditor.php
src/applications/project/editor/PhabricatorProjectColumnTransactionEditor.php
<?php final class PhabricatorProjectColumnTransactionEditor extends PhabricatorApplicationTransactionEditor { public function getEditorApplicationClass() { return 'PhabricatorProjectApplication'; } public function getEditorObjectsDescription() { return pht('Workboard Columns'); } public function getCreateObjectTitle($author, $object) { return pht('%s created this column.', $author); } public function getCreateObjectTitleForFeed($author, $object) { return pht('%s created %s.', $author, $object); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
<?php final class PhabricatorProjectTransactionEditor extends PhabricatorApplicationTransactionEditor { private $isMilestone; private function setIsMilestone($is_milestone) { $this->isMilestone = $is_milestone; return $this; } public function getIsMilestone() { return $this->isMilestone; } public function getEditorApplicationClass() { return 'PhabricatorProjectApplication'; } public function getEditorObjectsDescription() { return pht('Projects'); } public function getCreateObjectTitle($author, $object) { return pht('%s created this project.', $author); } public function getCreateObjectTitleForFeed($author, $object) { return pht('%s created %s.', $author, $object); } public function getTransactionTypes() { $types = parent::getTransactionTypes(); $types[] = PhabricatorTransactions::TYPE_EDGE; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; $types[] = PhabricatorTransactions::TYPE_JOIN_POLICY; return $types; } protected function validateAllTransactions( PhabricatorLiskDAO $object, array $xactions) { $errors = array(); // Prevent creating projects which are both subprojects and milestones, // since this does not make sense, won't work, and will break everything. $parent_xaction = null; foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { case PhabricatorProjectParentTransaction::TRANSACTIONTYPE: case PhabricatorProjectMilestoneTransaction::TRANSACTIONTYPE: if ($xaction->getNewValue() === null) { continue 2; } if (!$parent_xaction) { $parent_xaction = $xaction; continue 2; } $errors[] = new PhabricatorApplicationTransactionValidationError( $xaction->getTransactionType(), pht('Invalid'), pht( 'When creating a project, specify a maximum of one parent '. 'project or milestone project. A project can not be both a '. 'subproject and a milestone.'), $xaction); break 2; } } $is_milestone = $this->getIsMilestone(); $is_parent = $object->getHasSubprojects(); foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { case PhabricatorTransactions::TYPE_EDGE: $type = $xaction->getMetadataValue('edge:type'); if ($type != PhabricatorProjectProjectHasMemberEdgeType::EDGECONST) { break; } if ($is_parent) { $errors[] = new PhabricatorApplicationTransactionValidationError( $xaction->getTransactionType(), pht('Invalid'), pht( 'You can not change members of a project with subprojects '. 'directly. Members of any subproject are automatically '. 'members of the parent project.'), $xaction); } if ($is_milestone) { $errors[] = new PhabricatorApplicationTransactionValidationError( $xaction->getTransactionType(), pht('Invalid'), pht( 'You can not change members of a milestone. Members of the '. 'parent project are automatically members of the milestone.'), $xaction); } break; } } return $errors; } protected function willPublish(PhabricatorLiskDAO $object, array $xactions) { // NOTE: We're using the omnipotent user here because the original actor // may no longer have permission to view the object. return id(new PhabricatorProjectQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withPHIDs(array($object->getPHID())) ->needAncestorMembers(true) ->executeOne(); } protected function shouldSendMail( PhabricatorLiskDAO $object, array $xactions) { return true; } protected function getMailSubjectPrefix() { return pht('[Project]'); } protected function getMailTo(PhabricatorLiskDAO $object) { return array( $this->getActingAsPHID(), ); } protected function getMailCc(PhabricatorLiskDAO $object) { return array(); } public function getMailTagsMap() { return array( PhabricatorProjectTransaction::MAILTAG_METADATA => pht('Project name, hashtags, icon, image, or color changes.'), PhabricatorProjectTransaction::MAILTAG_MEMBERS => pht('Project membership changes.'), PhabricatorProjectTransaction::MAILTAG_WATCHERS => pht('Project watcher list changes.'), PhabricatorProjectTransaction::MAILTAG_OTHER => pht('Other project activity not listed above occurs.'), ); } protected function buildReplyHandler(PhabricatorLiskDAO $object) { return id(new ProjectReplyHandler()) ->setMailReceiver($object); } protected function buildMailTemplate(PhabricatorLiskDAO $object) { $name = $object->getName(); return id(new PhabricatorMetaMTAMail()) ->setSubject("{$name}"); } protected function buildMailBody( PhabricatorLiskDAO $object, array $xactions) { $body = parent::buildMailBody($object, $xactions); $uri = '/project/profile/'.$object->getID().'/'; $body->addLinkSection( pht('PROJECT DETAIL'), PhabricatorEnv::getProductionURI($uri)); return $body; } protected function shouldPublishFeedStory( PhabricatorLiskDAO $object, array $xactions) { return true; } protected function supportsSearch() { return true; } protected function applyFinalEffects( PhabricatorLiskDAO $object, array $xactions) { $materialize = false; $new_parent = null; foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { case PhabricatorTransactions::TYPE_EDGE: switch ($xaction->getMetadataValue('edge:type')) { case PhabricatorProjectProjectHasMemberEdgeType::EDGECONST: $materialize = true; break; } break; case PhabricatorProjectParentTransaction::TRANSACTIONTYPE: case PhabricatorProjectMilestoneTransaction::TRANSACTIONTYPE: $materialize = true; $new_parent = $object->getParentProject(); break; } } if ($new_parent) { // If we just created the first subproject of this parent, we want to // copy all of the real members to the subproject. if (!$new_parent->getHasSubprojects()) { $member_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $project_members = PhabricatorEdgeQuery::loadDestinationPHIDs( $new_parent->getPHID(), $member_type); if ($project_members) { $editor = id(new PhabricatorEdgeEditor()); foreach ($project_members as $phid) { $editor->addEdge($object->getPHID(), $member_type, $phid); } $editor->save(); } } } // TODO: We should dump an informational transaction onto the parent // project to show that we created the sub-thing. if ($materialize) { id(new PhabricatorProjectsMembershipIndexEngineExtension()) ->rematerialize($object); } if ($new_parent) { id(new PhabricatorProjectsMembershipIndexEngineExtension()) ->rematerialize($new_parent); } // See PHI1046. Milestones are always in the Space of their parent project. // Synchronize the database values to match the application values. $conn = $object->establishConnection('w'); queryfx( $conn, 'UPDATE %R SET spacePHID = %ns WHERE parentProjectPHID = %s AND milestoneNumber IS NOT NULL', $object, $object->getSpacePHID(), $object->getPHID()); return parent::applyFinalEffects($object, $xactions); } public function addSlug(PhabricatorProject $project, $slug, $force) { $slug = PhabricatorSlug::normalizeProjectSlug($slug); $table = new PhabricatorProjectSlug(); $project_phid = $project->getPHID(); if ($force) { // If we have the `$force` flag set, we only want to ignore an existing // slug if it's for the same project. We'll error on collisions with // other projects. $current = $table->loadOneWhere( 'slug = %s AND projectPHID = %s', $slug, $project_phid); } else { // Without the `$force` flag, we'll just return without doing anything // if any other project already has the slug. $current = $table->loadOneWhere( 'slug = %s', $slug); } if ($current) { return; } return id(new PhabricatorProjectSlug()) ->setSlug($slug) ->setProjectPHID($project_phid) ->save(); } public function removeSlugs(PhabricatorProject $project, array $slugs) { if (!$slugs) { return; } // We're going to try to delete both the literal and normalized versions // of all slugs. This allows us to destroy old slugs that are no longer // valid. foreach ($this->normalizeSlugs($slugs) as $slug) { $slugs[] = $slug; } $objects = id(new PhabricatorProjectSlug())->loadAllWhere( 'projectPHID = %s AND slug IN (%Ls)', $project->getPHID(), $slugs); foreach ($objects as $object) { $object->delete(); } } public function normalizeSlugs(array $slugs) { foreach ($slugs as $key => $slug) { $slugs[$key] = PhabricatorSlug::normalizeProjectSlug($slug); } $slugs = array_unique($slugs); $slugs = array_values($slugs); return $slugs; } protected function adjustObjectForPolicyChecks( PhabricatorLiskDAO $object, array $xactions) { $copy = parent::adjustObjectForPolicyChecks($object, $xactions); $type_edge = PhabricatorTransactions::TYPE_EDGE; $edgetype_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; // See T13462. If we're creating a milestone, set a dummy milestone // number so the project behaves like a milestone and uses milestone // policy rules. Otherwise, we'll end up checking the default policies // (which are not relevant to milestones) instead of the parent project // policies (which are the correct policies). if ($this->getIsMilestone() && !$copy->isMilestone()) { $copy->setMilestoneNumber(1); } $hint = null; if ($this->getIsMilestone()) { // See T13462. If we're creating a milestone, predict that the members // of the newly created milestone will be the same as the members of the // parent project, since this is the governing rule. $parent = $copy->getParentProject(); $parent = id(new PhabricatorProjectQuery()) ->setViewer($this->getActor()) ->withPHIDs(array($parent->getPHID())) ->needMembers(true) ->executeOne(); $members = $parent->getMemberPHIDs(); $hint = array_fuse($members); } else { $member_xaction = null; foreach ($xactions as $xaction) { if ($xaction->getTransactionType() !== $type_edge) { continue; } $edgetype = $xaction->getMetadataValue('edge:type'); if ($edgetype !== $edgetype_member) { continue; } $member_xaction = $xaction; } if ($member_xaction) { $object_phid = $object->getPHID(); if ($object_phid) { $project = id(new PhabricatorProjectQuery()) ->setViewer($this->getActor()) ->withPHIDs(array($object_phid)) ->needMembers(true) ->executeOne(); $members = $project->getMemberPHIDs(); } else { $members = array(); } $clone_xaction = clone $member_xaction; $hint = $this->getPHIDTransactionNewValue($clone_xaction, $members); $hint = array_fuse($hint); } } if ($hint !== null) { $rule = new PhabricatorProjectMembersPolicyRule(); PhabricatorPolicyRule::passTransactionHintToRule( $copy, $rule, $hint); } return $copy; } protected function expandTransactions( PhabricatorLiskDAO $object, array $xactions) { $actor = $this->getActor(); $actor_phid = $actor->getPHID(); $results = parent::expandTransactions($object, $xactions); $is_milestone = $object->isMilestone(); foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { case PhabricatorProjectMilestoneTransaction::TRANSACTIONTYPE: if ($xaction->getNewValue() !== null) { $is_milestone = true; } break; } } $this->setIsMilestone($is_milestone); return $results; } protected function shouldApplyHeraldRules( PhabricatorLiskDAO $object, array $xactions) { return true; } protected function buildHeraldAdapter( PhabricatorLiskDAO $object, array $xactions) { // Herald rules may run on behalf of other users and need to execute // membership checks against ancestors. $project = id(new PhabricatorProjectQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withPHIDs(array($object->getPHID())) ->needAncestorMembers(true) ->executeOne(); return id(new PhabricatorProjectHeraldAdapter()) ->setProject($project); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/xaction/PhabricatorProjectIconTransaction.php
src/applications/project/xaction/PhabricatorProjectIconTransaction.php
<?php final class PhabricatorProjectIconTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:icon'; public function generateOldValue($object) { return $object->getIcon(); } public function applyInternalEffects($object, $value) { $object->setIcon($value); } public function getTitle() { $set = new PhabricatorProjectIconSet(); $new = $this->getNewValue(); return pht( "%s set this project's icon to %s.", $this->renderAuthor(), $this->renderValue($set->getIconLabel($new))); } public function getTitleForFeed() { $set = new PhabricatorProjectIconSet(); $new = $this->getNewValue(); return pht( '%s set the icon for %s to %s.', $this->renderAuthor(), $this->renderObject(), $this->renderValue($set->getIconLabel($new))); } public function getIcon() { $new = $this->getNewValue(); return PhabricatorProjectIconSet::getIconIcon($new); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false